summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/src/p2m.c47
1 files changed, 45 insertions, 2 deletions
diff --git a/firmware/src/p2m.c b/firmware/src/p2m.c
index 3f4f2f2..11fe393 100644
--- a/firmware/src/p2m.c
+++ b/firmware/src/p2m.c
@@ -6,7 +6,9 @@
#include <LPC17xx.h>
-#define SPI
+//#define SPI
+#define IRQ_BLINKY
+//#define BLINKY
#ifdef DMA
@@ -19,7 +21,7 @@ int main (void)
// int i = 0;
while(1) {
- // fiprintf(stderr, "Play #%d: %d samples\n\r", i++, sizeof(samples) / sizeof(short));
+ //fiprintf(stderr, "Play #%d: %d samples\n\r", i++, sizeof(samples) / sizeof(short));
dac_play_samples(samples, sizeof(samples) / sizeof(short));
}
return 0;
@@ -30,6 +32,47 @@ volatile uint32_t temp;
void _delay(uint32_t del);
+#ifdef IRQ_BLINKY
+
+volatile int resume = 0;
+
+void TIMER0_IRQHandler (void)
+{
+ LPC_TIM0->IR = 1; /* clear interrupt flag */
+ resume = 1 - resume;
+ //timer0_counter++;
+ return;
+}
+
+int main (void)
+{
+ LPC_SC->PCONP |= ( 1 << 15 ); // power up GPIO
+ LPC_GPIO1->FIODIR |= 1 << 29; // puts P1.29 into output mode.
+
+ int delayInMs = 1000;
+
+ // Enable timer interrupts
+ LPC_TIM0->MR0 = delayInMs * (9000000 / 1000-1); // interval
+ LPC_TIM0->MCR = 3; // Interrupt and Reset on MR0
+ NVIC_EnableIRQ(TIMER0_IRQn);
+ LPC_TIM0->TCR = 1;
+
+ while(1) {
+ LPC_GPIO1->FIOPIN |= 1 << 29; // make P1.29 high
+
+ while(resume == 0) __WFI();
+
+ LPC_GPIO1->FIOPIN &= ~( 1 << 29 ); // make P1.29 low
+
+ while(resume == 1) __WFI();
+ }
+
+ return 0;
+
+}
+
+#endif
+
#ifdef BLINKY
int main (void)