![](/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
parallelcpld.cpp@72:895ca792c647, 2014-11-19 (annotated)
- Committer:
- klauss
- Date:
- Wed Nov 19 13:36:33 2014 +0000
- Revision:
- 72:895ca792c647
- Parent:
- 48:195c97f12e8e
- Child:
- 74:81c47fff88a5
send_to_cbx | send2callbox under development -- antes de modularizar melhor o src.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
klauss | 0:4d17cd9c8f9d | 1 | #include "parallelcpld.h" |
klauss | 0:4d17cd9c8f9d | 2 | |
klauss | 72:895ca792c647 | 3 | uint8_t TXBuffer[DATA_SIZE]; |
klauss | 72:895ca792c647 | 4 | ///<UART3 TX Buffer -- Buffer de transmissao para o CPLD |
klauss | 72:895ca792c647 | 5 | uint8_t tx_clear = 1; |
klauss | 0:4d17cd9c8f9d | 6 | |
klauss | 72:895ca792c647 | 7 | // Print a variable using parallel protocol |
klauss | 72:895ca792c647 | 8 | void parallel_write( uint8_t data ){ |
klauss | 72:895ca792c647 | 9 | data0 = BIT0&(data); |
klauss | 72:895ca792c647 | 10 | data1 = BIT1&(data); |
klauss | 72:895ca792c647 | 11 | data2 = BIT2&(data); |
klauss | 72:895ca792c647 | 12 | data3 = BIT3&(data); |
klauss | 72:895ca792c647 | 13 | data4 = BIT4&(data); |
klauss | 72:895ca792c647 | 14 | data5 = BIT5&(data); |
klauss | 72:895ca792c647 | 15 | data6 = BIT6&(data); |
klauss | 72:895ca792c647 | 16 | data7 = BIT7&(data); |
klauss | 0:4d17cd9c8f9d | 17 | } |
klauss | 0:4d17cd9c8f9d | 18 | |
klauss | 72:895ca792c647 | 19 | // Needs: function parallel_write/ Global variables: TXBuffer, tx_clear / Configuration extern interrupt |
klauss | 72:895ca792c647 | 20 | void send2callboxes(){ |
klauss | 72:895ca792c647 | 21 | // Send the first position of TXBuffer first |
klauss | 72:895ca792c647 | 22 | if( tx_clear == 1 ){ |
klauss | 72:895ca792c647 | 23 | //tx_clear = 0; |
klauss | 72:895ca792c647 | 24 | //parallel_write( TXBuffer[ 0 ] ); |
klauss | 72:895ca792c647 | 25 | //DataReady = 1; |
klauss | 72:895ca792c647 | 26 | }else{ |
klauss | 72:895ca792c647 | 27 | // Error if the transmission is still in use |
klauss | 72:895ca792c647 | 28 | if( dparallel ) debug_msg( "Error: Low Overflow Parallel Write TX" ); |
klauss | 72:895ca792c647 | 29 | //pc.printf( "\n\rError: Low Overflow Parallel Write TX\n\r" ); |
klauss | 72:895ca792c647 | 30 | } |
klauss | 0:4d17cd9c8f9d | 31 | } |
klauss | 0:4d17cd9c8f9d | 32 | |
klauss | 0:4d17cd9c8f9d | 33 | //***************************************************************************** |
klauss | 0:4d17cd9c8f9d | 34 | // EXTERN IRQ Handler |
klauss | 0:4d17cd9c8f9d | 35 | //***************************************************************************** |
klauss | 0:4d17cd9c8f9d | 36 | |
klauss | 72:895ca792c647 | 37 | void get2(){ |
klauss | 72:895ca792c647 | 38 | static uint16_t c = 1; |
klauss | 72:895ca792c647 | 39 | // Get Ready the new data |
klauss | 72:895ca792c647 | 40 | DataReady = 0; |
klauss | 0:4d17cd9c8f9d | 41 | tx_clear = 0; |
klauss | 72:895ca792c647 | 42 | |
klauss | 72:895ca792c647 | 43 | if ( c < 300 ){ |
klauss | 72:895ca792c647 | 44 | // Write the next data to be send |
klauss | 72:895ca792c647 | 45 | parallel_write ( TXBuffer[c] ) ; |
klauss | 72:895ca792c647 | 46 | // Allow the data to be capture |
klauss | 72:895ca792c647 | 47 | DataReady = 1; |
klauss | 0:4d17cd9c8f9d | 48 | }else{ |
klauss | 72:895ca792c647 | 49 | // Allow the next package to the transmitted |
klauss | 72:895ca792c647 | 50 | tx_clear = 1; |
klauss | 72:895ca792c647 | 51 | c = 0; |
klauss | 72:895ca792c647 | 52 | } |
klauss | 72:895ca792c647 | 53 | |
klauss | 0:4d17cd9c8f9d | 54 | c++; |
klauss | 0:4d17cd9c8f9d | 55 | } |