![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Versao com problema no socket rx
Dependencies: EthernetInterface NTPClient mbed-rtos mbed
parallelcpld.cpp@0:4d17cd9c8f9d, 2014-09-09 (annotated)
- Committer:
- klauss
- Date:
- Tue Sep 09 20:01:24 2014 +0000
- Revision:
- 0:4d17cd9c8f9d
20140726 copy
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
klauss | 0:4d17cd9c8f9d | 1 | #include "mbed.h" |
klauss | 0:4d17cd9c8f9d | 2 | #include <stdint.h> |
klauss | 0:4d17cd9c8f9d | 3 | #include "parallelcpld.h" |
klauss | 0:4d17cd9c8f9d | 4 | #include "configs.h" |
klauss | 0:4d17cd9c8f9d | 5 | #include "bits.h" |
klauss | 0:4d17cd9c8f9d | 6 | |
klauss | 0:4d17cd9c8f9d | 7 | uint8_t TXBuffer[DATA_SIZE]; // UART3 TX Buffer |
klauss | 0:4d17cd9c8f9d | 8 | uint8_t tx_clear =1; |
klauss | 0:4d17cd9c8f9d | 9 | |
klauss | 0:4d17cd9c8f9d | 10 | void parallel_write( uint8_t data) // Print a variable using parallel protocol |
klauss | 0:4d17cd9c8f9d | 11 | { |
klauss | 0:4d17cd9c8f9d | 12 | data0 = BIT0&(data); |
klauss | 0:4d17cd9c8f9d | 13 | data1 = BIT1&(data); |
klauss | 0:4d17cd9c8f9d | 14 | data2 = BIT2&(data); |
klauss | 0:4d17cd9c8f9d | 15 | data3 = BIT3&(data); |
klauss | 0:4d17cd9c8f9d | 16 | data4 = BIT4&(data); |
klauss | 0:4d17cd9c8f9d | 17 | data5 = BIT5&(data); |
klauss | 0:4d17cd9c8f9d | 18 | data6 = BIT6&(data); |
klauss | 0:4d17cd9c8f9d | 19 | data7 = BIT7&(data); |
klauss | 0:4d17cd9c8f9d | 20 | } |
klauss | 0:4d17cd9c8f9d | 21 | |
klauss | 0:4d17cd9c8f9d | 22 | |
klauss | 0:4d17cd9c8f9d | 23 | void send2callboxes(){ // Needs: function parallel_write/ Global variables: TXBuffer, tx_clear / Configuration extern interrupt |
klauss | 0:4d17cd9c8f9d | 24 | |
klauss | 0:4d17cd9c8f9d | 25 | if ( tx_clear == 1) |
klauss | 0:4d17cd9c8f9d | 26 | { |
klauss | 0:4d17cd9c8f9d | 27 | parallel_write( TXBuffer[0] ); // Send the first position of TXBuffer first |
klauss | 0:4d17cd9c8f9d | 28 | DataReady = 1; |
klauss | 0:4d17cd9c8f9d | 29 | |
klauss | 0:4d17cd9c8f9d | 30 | }else |
klauss | 0:4d17cd9c8f9d | 31 | { |
klauss | 0:4d17cd9c8f9d | 32 | uart0_text("Error: Overflow Parallel Write TX"); // Error if the transmission is still in use |
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 | // EXTERN IRQ Handler |
klauss | 0:4d17cd9c8f9d | 40 | //***************************************************************************** |
klauss | 0:4d17cd9c8f9d | 41 | |
klauss | 0:4d17cd9c8f9d | 42 | void get2(){ |
klauss | 0:4d17cd9c8f9d | 43 | |
klauss | 0:4d17cd9c8f9d | 44 | static uint16_t c = 1; |
klauss | 0:4d17cd9c8f9d | 45 | DataReady = 0; // Get Ready the new data |
klauss | 0:4d17cd9c8f9d | 46 | // led3 = !led3; |
klauss | 0:4d17cd9c8f9d | 47 | tx_clear = 0; |
klauss | 0:4d17cd9c8f9d | 48 | |
klauss | 0:4d17cd9c8f9d | 49 | if ( c < 300 ) |
klauss | 0:4d17cd9c8f9d | 50 | { |
klauss | 0:4d17cd9c8f9d | 51 | parallel_write ( TXBuffer[c] ) ; // Write the next data to be send |
klauss | 0:4d17cd9c8f9d | 52 | DataReady = 1; // Allow the data to be capture |
klauss | 0:4d17cd9c8f9d | 53 | |
klauss | 0:4d17cd9c8f9d | 54 | }else{ |
klauss | 0:4d17cd9c8f9d | 55 | // led1 = 0; |
klauss | 0:4d17cd9c8f9d | 56 | // led2 = 0; |
klauss | 0:4d17cd9c8f9d | 57 | // led3 = 1; |
klauss | 0:4d17cd9c8f9d | 58 | // led4 = 1; |
klauss | 0:4d17cd9c8f9d | 59 | tx_clear = 1; // Allow the next package to the transmitted |
klauss | 0:4d17cd9c8f9d | 60 | c = 0; |
klauss | 0:4d17cd9c8f9d | 61 | } |
klauss | 0:4d17cd9c8f9d | 62 | c++; |
klauss | 0:4d17cd9c8f9d | 63 | } |