Tim Bots
/
RTOSTest
A test program to see why the RTOS doesn't like to play with the serial interrupt.
Diff: main.cpp
- Revision:
- 0:7cdb93589064
- Child:
- 1:54099c52b7dc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Dec 28 19:27:23 2012 +0000 @@ -0,0 +1,60 @@ +#include "mbed.h" + +#define DEBUG + +DigitalOut led1(LED1); +DigitalOut led2(LED2); +Serial probe(p9,p10); + +#ifdef DEBUG +Serial pc(USBTX,USBRX); +#endif + +char serialBuffer[256]; +unsigned char serialBufferLoc = 0; + +void rxInterrupt(void){ + NVIC_DisableIRQ(UART3_IRQn); + uint32_t IRR3 = LPC_UART3->IIR; + led2=!led2; + serialBuffer[serialBufferLoc] = LPC_UART3->RBR; + +#ifdef DEBUG + pc.putc(serialBuffer[serialBufferLoc]); +#endif + + if (serialBuffer[serialBufferLoc] == 0x0A) { + pc.printf("cr found\r\n"); + } + + serialBufferLoc++; + NVIC_EnableIRQ(UART3_IRQn); +} + +void serialProbeInit(void){ + probe.baud(9600); + probe.format(8,Serial::None,1); + probe.attach(&rxInterrupt,Serial::RxIrq); +} + +#ifdef DEBUG +void serialPcInit(void){ + pc.baud(115200); + pc.format(8,Serial::None,1); +} +#endif + +int main(){ + serialProbeInit(); +#ifdef DEBUG + serialPcInit(); + pc.printf("Comtest, MBED started\r\n"); +#endif + while(1){ + led1 = 1; + wait(0.2); + led1 = 0; + led2 = 0; + wait(0.2); + } +}