A test program to see why the RTOS doesn't like to play with the serial interrupt.

Dependencies:   mbed-rtos mbed

Committer:
the_programmer
Date:
Fri Dec 28 19:27:23 2012 +0000
Revision:
0:7cdb93589064
Child:
1:54099c52b7dc
Initial commit (stripped version of full code)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
the_programmer 0:7cdb93589064 1 #include "mbed.h"
the_programmer 0:7cdb93589064 2
the_programmer 0:7cdb93589064 3 #define DEBUG
the_programmer 0:7cdb93589064 4
the_programmer 0:7cdb93589064 5 DigitalOut led1(LED1);
the_programmer 0:7cdb93589064 6 DigitalOut led2(LED2);
the_programmer 0:7cdb93589064 7 Serial probe(p9,p10);
the_programmer 0:7cdb93589064 8
the_programmer 0:7cdb93589064 9 #ifdef DEBUG
the_programmer 0:7cdb93589064 10 Serial pc(USBTX,USBRX);
the_programmer 0:7cdb93589064 11 #endif
the_programmer 0:7cdb93589064 12
the_programmer 0:7cdb93589064 13 char serialBuffer[256];
the_programmer 0:7cdb93589064 14 unsigned char serialBufferLoc = 0;
the_programmer 0:7cdb93589064 15
the_programmer 0:7cdb93589064 16 void rxInterrupt(void){
the_programmer 0:7cdb93589064 17 NVIC_DisableIRQ(UART3_IRQn);
the_programmer 0:7cdb93589064 18 uint32_t IRR3 = LPC_UART3->IIR;
the_programmer 0:7cdb93589064 19 led2=!led2;
the_programmer 0:7cdb93589064 20 serialBuffer[serialBufferLoc] = LPC_UART3->RBR;
the_programmer 0:7cdb93589064 21
the_programmer 0:7cdb93589064 22 #ifdef DEBUG
the_programmer 0:7cdb93589064 23 pc.putc(serialBuffer[serialBufferLoc]);
the_programmer 0:7cdb93589064 24 #endif
the_programmer 0:7cdb93589064 25
the_programmer 0:7cdb93589064 26 if (serialBuffer[serialBufferLoc] == 0x0A) {
the_programmer 0:7cdb93589064 27 pc.printf("cr found\r\n");
the_programmer 0:7cdb93589064 28 }
the_programmer 0:7cdb93589064 29
the_programmer 0:7cdb93589064 30 serialBufferLoc++;
the_programmer 0:7cdb93589064 31 NVIC_EnableIRQ(UART3_IRQn);
the_programmer 0:7cdb93589064 32 }
the_programmer 0:7cdb93589064 33
the_programmer 0:7cdb93589064 34 void serialProbeInit(void){
the_programmer 0:7cdb93589064 35 probe.baud(9600);
the_programmer 0:7cdb93589064 36 probe.format(8,Serial::None,1);
the_programmer 0:7cdb93589064 37 probe.attach(&rxInterrupt,Serial::RxIrq);
the_programmer 0:7cdb93589064 38 }
the_programmer 0:7cdb93589064 39
the_programmer 0:7cdb93589064 40 #ifdef DEBUG
the_programmer 0:7cdb93589064 41 void serialPcInit(void){
the_programmer 0:7cdb93589064 42 pc.baud(115200);
the_programmer 0:7cdb93589064 43 pc.format(8,Serial::None,1);
the_programmer 0:7cdb93589064 44 }
the_programmer 0:7cdb93589064 45 #endif
the_programmer 0:7cdb93589064 46
the_programmer 0:7cdb93589064 47 int main(){
the_programmer 0:7cdb93589064 48 serialProbeInit();
the_programmer 0:7cdb93589064 49 #ifdef DEBUG
the_programmer 0:7cdb93589064 50 serialPcInit();
the_programmer 0:7cdb93589064 51 pc.printf("Comtest, MBED started\r\n");
the_programmer 0:7cdb93589064 52 #endif
the_programmer 0:7cdb93589064 53 while(1){
the_programmer 0:7cdb93589064 54 led1 = 1;
the_programmer 0:7cdb93589064 55 wait(0.2);
the_programmer 0:7cdb93589064 56 led1 = 0;
the_programmer 0:7cdb93589064 57 led2 = 0;
the_programmer 0:7cdb93589064 58 wait(0.2);
the_programmer 0:7cdb93589064 59 }
the_programmer 0:7cdb93589064 60 }