![](/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@99:e80850c51106, 2015-01-19 (annotated)
- Committer:
- klauss
- Date:
- Mon Jan 19 18:00:42 2015 +0000
- Revision:
- 99:e80850c51106
- Parent:
- 86:bf7b0d4c3232
- Child:
- 104:62646ef786a3
wip header cb tx delay
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 | 74:81c47fff88a5 | 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 | 74:81c47fff88a5 | 14 | if( RXBuffer[ RX_c ] != RXBuffer[ RX_c - 1 ] ){ |
klauss | 0:4d17cd9c8f9d | 15 | // led3 =!led3; |
klauss | 0:4d17cd9c8f9d | 16 | } |
klauss | 0:4d17cd9c8f9d | 17 | |
klauss | 0:4d17cd9c8f9d | 18 | RX_c++; |
klauss | 0:4d17cd9c8f9d | 19 | |
klauss | 78:1353744f01e1 | 20 | led4 =!led4; |
klauss | 78:1353744f01e1 | 21 | |
klauss | 74:81c47fff88a5 | 22 | if ( RX_c == 300 ){ |
klauss | 86:bf7b0d4c3232 | 23 | status = __READ__; |
klauss | 86:bf7b0d4c3232 | 24 | missed_pkg++; |
klauss | 99:e80850c51106 | 25 | cpld_pkg_rx_counter++; |
klauss | 0:4d17cd9c8f9d | 26 | } |
klauss | 0:4d17cd9c8f9d | 27 | } |
klauss | 0:4d17cd9c8f9d | 28 | |
klauss | 0:4d17cd9c8f9d | 29 | void RXFrameSync (void) { |
klauss | 0:4d17cd9c8f9d | 30 | RX_c = 0; |
klauss | 74:81c47fff88a5 | 31 | status = __WAITING__; |
klauss | 0:4d17cd9c8f9d | 32 | } |
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 | void initRX (void) { |
klauss | 0:4d17cd9c8f9d | 49 | |
klauss | 0:4d17cd9c8f9d | 50 | RXHeadPtr = IntBuff; // Initial state |
klauss | 0:4d17cd9c8f9d | 51 | RXHeadPtr = RXTailPtr; |
klauss | 0:4d17cd9c8f9d | 52 | |
klauss | 0:4d17cd9c8f9d | 53 | } |
klauss | 0:4d17cd9c8f9d | 54 | |
klauss | 0:4d17cd9c8f9d | 55 | void SerialRecvInterrupt (void) // UART3 Serial Interrupt Handler |
klauss | 0:4d17cd9c8f9d | 56 | { |
klauss | 0:4d17cd9c8f9d | 57 | static uint8_t data = 0; |
klauss | 0:4d17cd9c8f9d | 58 | while ( LPC_UART3->LSR &= (0<<1) ) {} |
klauss | 0:4d17cd9c8f9d | 59 | // *(RXBuffer+idx) = LPC_UART3->RBR; Receive data from UART3 RX |
klauss | 0:4d17cd9c8f9d | 60 | |
klauss | 0:4d17cd9c8f9d | 61 | data = LPC_UART3->RBR; // Receive data from UART3 RX |
klauss | 0:4d17cd9c8f9d | 62 | |
klauss | 0:4d17cd9c8f9d | 63 | RXHeadPtr = &data; |
klauss | 0:4d17cd9c8f9d | 64 | |
klauss | 0:4d17cd9c8f9d | 65 | RXHeadPtr++; |
klauss | 0:4d17cd9c8f9d | 66 | move++; |
klauss | 0:4d17cd9c8f9d | 67 | |
klauss | 0:4d17cd9c8f9d | 68 | if ( RXHeadPtr == (IntBuff+899) ) |
klauss | 0:4d17cd9c8f9d | 69 | { |
klauss | 0:4d17cd9c8f9d | 70 | RXHeadPtr = IntBuff; |
klauss | 0:4d17cd9c8f9d | 71 | } |
klauss | 0:4d17cd9c8f9d | 72 | |
klauss | 0:4d17cd9c8f9d | 73 | } |
klauss | 0:4d17cd9c8f9d | 74 | |
klauss | 0:4d17cd9c8f9d | 75 | void RcvRX( void ) { |
klauss | 0:4d17cd9c8f9d | 76 | |
klauss | 0:4d17cd9c8f9d | 77 | static uint16_t p = 0; |
klauss | 0:4d17cd9c8f9d | 78 | static uint8_t data = 0; |
klauss | 0:4d17cd9c8f9d | 79 | |
klauss | 0:4d17cd9c8f9d | 80 | if ( move ) { |
klauss | 0:4d17cd9c8f9d | 81 | |
klauss | 0:4d17cd9c8f9d | 82 | data = *RXTailPtr; |
klauss | 0:4d17cd9c8f9d | 83 | |
klauss | 0:4d17cd9c8f9d | 84 | RXBuffer[p] = data; |
klauss | 0:4d17cd9c8f9d | 85 | RXTailPtr++; |
klauss | 0:4d17cd9c8f9d | 86 | move--; |
klauss | 0:4d17cd9c8f9d | 87 | p++; |
klauss | 0:4d17cd9c8f9d | 88 | } |
klauss | 0:4d17cd9c8f9d | 89 | |
klauss | 0:4d17cd9c8f9d | 90 | if ( RXTailPtr == (IntBuff+899) ) { |
klauss | 0:4d17cd9c8f9d | 91 | RXTailPtr = IntBuff; |
klauss | 0:4d17cd9c8f9d | 92 | } |
klauss | 0:4d17cd9c8f9d | 93 | |
klauss | 0:4d17cd9c8f9d | 94 | if ( p == 300 ) { |
klauss | 0:4d17cd9c8f9d | 95 | processRX = 1; |
klauss | 0:4d17cd9c8f9d | 96 | p = 0; |
klauss | 0:4d17cd9c8f9d | 97 | } |
klauss | 0:4d17cd9c8f9d | 98 | |
klauss | 0:4d17cd9c8f9d | 99 | } |
klauss | 0:4d17cd9c8f9d | 100 | */ |