![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
UART3Interrupt.cpp@105:a930035b6556, 2015-03-10 (annotated)
- Committer:
- klauss
- Date:
- Tue Mar 10 18:10:57 2015 +0000
- Revision:
- 105:a930035b6556
- Parent:
- 104:62646ef786a3
- Child:
- 106:a34fcf9f0e02
sprint 0;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
klauss | 0:4d17cd9c8f9d | 1 | #include "UART3Interrupt.h" |
klauss | 0:4d17cd9c8f9d | 2 | |
klauss | 105:a930035b6556 | 3 | char RXBuffer[CB_BUFFER_SIZE]; |
klauss | 74:81c47fff88a5 | 4 | ///< UART3 RX Buffer |
klauss | 74:81c47fff88a5 | 5 | |
klauss | 0:4d17cd9c8f9d | 6 | volatile uint16_t RX_c = 0; |
klauss | 0:4d17cd9c8f9d | 7 | |
klauss | 74:81c47fff88a5 | 8 | ///< UART3 Serial Interrupt Handler |
klauss | 74:81c47fff88a5 | 9 | void SerialRecvInterrupt( void ){ |
klauss | 74:81c47fff88a5 | 10 | while ( LPC_UART3 -> LSR & ( 0<<1 ) ) {} |
klauss | 74:81c47fff88a5 | 11 | // Receive data from UART3 RX |
klauss | 74:81c47fff88a5 | 12 | *( RXBuffer + RX_c ) = LPC_UART3 -> RBR; |
klauss | 0:4d17cd9c8f9d | 13 | |
klauss | 104:62646ef786a3 | 14 | if( RXBuffer[ RX_c ] != RXBuffer[ RX_c - 1 ] ) |
klauss | 104:62646ef786a3 | 15 | { |
klauss | 104:62646ef786a3 | 16 | // FIXME remove this if ... |
klauss | 0:4d17cd9c8f9d | 17 | } |
klauss | 0:4d17cd9c8f9d | 18 | |
klauss | 0:4d17cd9c8f9d | 19 | RX_c++; |
klauss | 0:4d17cd9c8f9d | 20 | |
klauss | 78:1353744f01e1 | 21 | led4 =!led4; |
klauss | 78:1353744f01e1 | 22 | |
klauss | 74:81c47fff88a5 | 23 | if ( RX_c == 300 ){ |
klauss | 86:bf7b0d4c3232 | 24 | status = __READ__; |
klauss | 86:bf7b0d4c3232 | 25 | missed_pkg++; |
klauss | 99:e80850c51106 | 26 | cpld_pkg_rx_counter++; |
klauss | 0:4d17cd9c8f9d | 27 | } |
klauss | 0:4d17cd9c8f9d | 28 | } |
klauss | 0:4d17cd9c8f9d | 29 | |
klauss | 0:4d17cd9c8f9d | 30 | void RXFrameSync (void) { |
klauss | 0:4d17cd9c8f9d | 31 | RX_c = 0; |
klauss | 74:81c47fff88a5 | 32 | status = __WAITING__; |
klauss | 0:4d17cd9c8f9d | 33 | } |
klauss | 0:4d17cd9c8f9d | 34 | |
klauss | 0:4d17cd9c8f9d | 35 | |
klauss | 0:4d17cd9c8f9d | 36 | |
klauss | 0:4d17cd9c8f9d | 37 | |
klauss | 0:4d17cd9c8f9d | 38 | |
klauss | 0:4d17cd9c8f9d | 39 | |
klauss | 0:4d17cd9c8f9d | 40 | |
klauss | 0:4d17cd9c8f9d | 41 | |
klauss | 0:4d17cd9c8f9d | 42 | |
klauss | 0:4d17cd9c8f9d | 43 | |
klauss | 0:4d17cd9c8f9d | 44 | |
klauss | 0:4d17cd9c8f9d | 45 | |
klauss | 0:4d17cd9c8f9d | 46 | |
klauss | 0:4d17cd9c8f9d | 47 | |
klauss | 0:4d17cd9c8f9d | 48 | /* |
klauss | 0:4d17cd9c8f9d | 49 | void initRX (void) { |
klauss | 0:4d17cd9c8f9d | 50 | |
klauss | 0:4d17cd9c8f9d | 51 | RXHeadPtr = IntBuff; // Initial state |
klauss | 0:4d17cd9c8f9d | 52 | RXHeadPtr = RXTailPtr; |
klauss | 0:4d17cd9c8f9d | 53 | |
klauss | 0:4d17cd9c8f9d | 54 | } |
klauss | 0:4d17cd9c8f9d | 55 | |
klauss | 0:4d17cd9c8f9d | 56 | void SerialRecvInterrupt (void) // UART3 Serial Interrupt Handler |
klauss | 0:4d17cd9c8f9d | 57 | { |
klauss | 0:4d17cd9c8f9d | 58 | static uint8_t data = 0; |
klauss | 0:4d17cd9c8f9d | 59 | while ( LPC_UART3->LSR &= (0<<1) ) {} |
klauss | 0:4d17cd9c8f9d | 60 | // *(RXBuffer+idx) = LPC_UART3->RBR; Receive data from UART3 RX |
klauss | 0:4d17cd9c8f9d | 61 | |
klauss | 0:4d17cd9c8f9d | 62 | data = LPC_UART3->RBR; // Receive data from UART3 RX |
klauss | 0:4d17cd9c8f9d | 63 | |
klauss | 0:4d17cd9c8f9d | 64 | RXHeadPtr = &data; |
klauss | 0:4d17cd9c8f9d | 65 | |
klauss | 0:4d17cd9c8f9d | 66 | RXHeadPtr++; |
klauss | 0:4d17cd9c8f9d | 67 | move++; |
klauss | 0:4d17cd9c8f9d | 68 | |
klauss | 0:4d17cd9c8f9d | 69 | if ( RXHeadPtr == (IntBuff+899) ) |
klauss | 0:4d17cd9c8f9d | 70 | { |
klauss | 0:4d17cd9c8f9d | 71 | RXHeadPtr = IntBuff; |
klauss | 0:4d17cd9c8f9d | 72 | } |
klauss | 0:4d17cd9c8f9d | 73 | |
klauss | 0:4d17cd9c8f9d | 74 | } |
klauss | 0:4d17cd9c8f9d | 75 | |
klauss | 0:4d17cd9c8f9d | 76 | void RcvRX( void ) { |
klauss | 0:4d17cd9c8f9d | 77 | |
klauss | 0:4d17cd9c8f9d | 78 | static uint16_t p = 0; |
klauss | 0:4d17cd9c8f9d | 79 | static uint8_t data = 0; |
klauss | 0:4d17cd9c8f9d | 80 | |
klauss | 0:4d17cd9c8f9d | 81 | if ( move ) { |
klauss | 0:4d17cd9c8f9d | 82 | |
klauss | 0:4d17cd9c8f9d | 83 | data = *RXTailPtr; |
klauss | 0:4d17cd9c8f9d | 84 | |
klauss | 0:4d17cd9c8f9d | 85 | RXBuffer[p] = data; |
klauss | 0:4d17cd9c8f9d | 86 | RXTailPtr++; |
klauss | 0:4d17cd9c8f9d | 87 | move--; |
klauss | 0:4d17cd9c8f9d | 88 | p++; |
klauss | 0:4d17cd9c8f9d | 89 | } |
klauss | 0:4d17cd9c8f9d | 90 | |
klauss | 0:4d17cd9c8f9d | 91 | if ( RXTailPtr == (IntBuff+899) ) { |
klauss | 0:4d17cd9c8f9d | 92 | RXTailPtr = IntBuff; |
klauss | 0:4d17cd9c8f9d | 93 | } |
klauss | 0:4d17cd9c8f9d | 94 | |
klauss | 0:4d17cd9c8f9d | 95 | if ( p == 300 ) { |
klauss | 0:4d17cd9c8f9d | 96 | processRX = 1; |
klauss | 0:4d17cd9c8f9d | 97 | p = 0; |
klauss | 0:4d17cd9c8f9d | 98 | } |
klauss | 0:4d17cd9c8f9d | 99 | |
klauss | 0:4d17cd9c8f9d | 100 | } |
klauss | 0:4d17cd9c8f9d | 101 | */ |