Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
UART3Interrupt.cpp@117:e9facba9db27, 2015-04-23 (annotated)
- Committer:
- klauss
- Date:
- Thu Apr 23 21:53:28 2015 +0000
- Revision:
- 117:e9facba9db27
- Parent:
- 116:39a41ebb675c
- Child:
- 119:ee6a53069455
merge dos fw contendo as funcionalidade de bootloader e o fw que estava em campo na ultima vistoria
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 | 117:e9facba9db27 | 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 | 114:472502b31a12 | 14 | if( RXBuffer[ RX_c ] != RXBuffer[ RX_c - 1 ] ){ |
klauss | 114:472502b31a12 | 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 | 114:472502b31a12 | 32 | } |
klauss | 114:472502b31a12 | 33 | |
klauss | 114:472502b31a12 | 34 | |
klauss | 114:472502b31a12 | 35 | |
klauss | 114:472502b31a12 | 36 | |
klauss | 114:472502b31a12 | 37 | |
klauss | 114:472502b31a12 | 38 | |
klauss | 114:472502b31a12 | 39 | |
klauss | 114:472502b31a12 | 40 | |
klauss | 114:472502b31a12 | 41 | |
klauss | 114:472502b31a12 | 42 | |
klauss | 114:472502b31a12 | 43 | |
klauss | 114:472502b31a12 | 44 | |
klauss | 114:472502b31a12 | 45 | |
klauss | 114:472502b31a12 | 46 | |
klauss | 114:472502b31a12 | 47 | /* |
klauss | 114:472502b31a12 | 48 | void initRX (void) { |
klauss | 114:472502b31a12 | 49 | |
klauss | 114:472502b31a12 | 50 | RXHeadPtr = IntBuff; // Initial state |
klauss | 114:472502b31a12 | 51 | RXHeadPtr = RXTailPtr; |
klauss | 114:472502b31a12 | 52 | |
klauss | 114:472502b31a12 | 53 | } |
klauss | 114:472502b31a12 | 54 | |
klauss | 114:472502b31a12 | 55 | void SerialRecvInterrupt (void) // UART3 Serial Interrupt Handler |
klauss | 114:472502b31a12 | 56 | { |
klauss | 114:472502b31a12 | 57 | static uint8_t data = 0; |
klauss | 114:472502b31a12 | 58 | while ( LPC_UART3->LSR &= (0<<1) ) {} |
klauss | 114:472502b31a12 | 59 | // *(RXBuffer+idx) = LPC_UART3->RBR; Receive data from UART3 RX |
klauss | 114:472502b31a12 | 60 | |
klauss | 114:472502b31a12 | 61 | data = LPC_UART3->RBR; // Receive data from UART3 RX |
klauss | 114:472502b31a12 | 62 | |
klauss | 114:472502b31a12 | 63 | RXHeadPtr = &data; |
klauss | 114:472502b31a12 | 64 | |
klauss | 114:472502b31a12 | 65 | RXHeadPtr++; |
klauss | 114:472502b31a12 | 66 | move++; |
klauss | 114:472502b31a12 | 67 | |
klauss | 114:472502b31a12 | 68 | if ( RXHeadPtr == (IntBuff+899) ) |
klauss | 114:472502b31a12 | 69 | { |
klauss | 114:472502b31a12 | 70 | RXHeadPtr = IntBuff; |
klauss | 114:472502b31a12 | 71 | } |
klauss | 114:472502b31a12 | 72 | |
klauss | 114:472502b31a12 | 73 | } |
klauss | 114:472502b31a12 | 74 | |
klauss | 114:472502b31a12 | 75 | void RcvRX( void ) { |
klauss | 114:472502b31a12 | 76 | |
klauss | 114:472502b31a12 | 77 | static uint16_t p = 0; |
klauss | 114:472502b31a12 | 78 | static uint8_t data = 0; |
klauss | 114:472502b31a12 | 79 | |
klauss | 114:472502b31a12 | 80 | if ( move ) { |
klauss | 114:472502b31a12 | 81 | |
klauss | 114:472502b31a12 | 82 | data = *RXTailPtr; |
klauss | 114:472502b31a12 | 83 | |
klauss | 114:472502b31a12 | 84 | RXBuffer[p] = data; |
klauss | 114:472502b31a12 | 85 | RXTailPtr++; |
klauss | 114:472502b31a12 | 86 | move--; |
klauss | 114:472502b31a12 | 87 | p++; |
klauss | 114:472502b31a12 | 88 | } |
klauss | 114:472502b31a12 | 89 | |
klauss | 114:472502b31a12 | 90 | if ( RXTailPtr == (IntBuff+899) ) { |
klauss | 114:472502b31a12 | 91 | RXTailPtr = IntBuff; |
klauss | 114:472502b31a12 | 92 | } |
klauss | 114:472502b31a12 | 93 | |
klauss | 114:472502b31a12 | 94 | if ( p == 300 ) { |
klauss | 114:472502b31a12 | 95 | processRX = 1; |
klauss | 114:472502b31a12 | 96 | p = 0; |
klauss | 114:472502b31a12 | 97 | } |
klauss | 114:472502b31a12 | 98 | |
klauss | 114:472502b31a12 | 99 | } |
klauss | 114:472502b31a12 | 100 | */ |