![](/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
Diff: parallelcpld.cpp
- Revision:
- 74:81c47fff88a5
- Parent:
- 72:895ca792c647
- Child:
- 81:3656f00ab3db
diff -r 3b4e282eeff7 -r 81c47fff88a5 parallelcpld.cpp --- a/parallelcpld.cpp Wed Nov 19 14:06:13 2014 +0000 +++ b/parallelcpld.cpp Mon Nov 24 16:43:16 2014 +0000 @@ -1,9 +1,26 @@ #include "parallelcpld.h" -uint8_t TXBuffer[DATA_SIZE]; -///<UART3 TX Buffer -- Buffer de transmissao para o CPLD +DigitalOut data0(p30); //LSB +DigitalOut data1(p31); +DigitalOut data2(p32); +DigitalOut data3(p33); +DigitalOut data4(p34); +DigitalOut data5(p37); +DigitalOut data6(p38); +DigitalOut data7(p39); //MSB + +DigitalOut DataReady(p11); +///<IO 27 + +uint8_t cb_tx_buffer[ __CB_BUFFER_SIZE__ ]; + +uint8_t TXBuffer[ __CB_BUFFER_SIZE__ ]; + uint8_t tx_clear = 1; +ring_buffer * rb = ring_buffer_init( NULL ); +ring_buffer test; + // Print a variable using parallel protocol void parallel_write( uint8_t data ){ data0 = BIT0&(data); @@ -17,16 +34,21 @@ } // Needs: function parallel_write/ Global variables: TXBuffer, tx_clear / Configuration extern interrupt -void send2callboxes(){ +void send2callboxes( uint8_t * buffer ){ // Send the first position of TXBuffer first if( tx_clear == 1 ){ - //tx_clear = 0; - //parallel_write( TXBuffer[ 0 ] ); - //DataReady = 1; + tx_clear = 0; + xmemcpy( TXBuffer, buffer, __CB_BUFFER_SIZE__ ); + parallel_write( TXBuffer[ 0 ] ); + DataReady = 1; + xmemcpy( cb_tx_buffer, buffer, __CB_BUFFER_SIZE__ ); }else{ // Error if the transmission is still in use - if( dparallel ) debug_msg( "Error: Low Overflow Parallel Write TX" ); - //pc.printf( "\n\rError: Low Overflow Parallel Write TX\n\r" ); + uint8_t ret = ring_buffer_add( rb, buffer ); + + if( ret == 0x01 ) if( dparallel ) send_msg("Error: Ring buffer fully charged"); + + if( ret == 0x00 ) if( dparallel ) send_msg("Success : package queued -- on queue %u", rb->size ); } } @@ -50,6 +72,15 @@ tx_clear = 1; c = 0; } - c++; +} + +void tx_buffer_ring_buffer_handler( void ){ + if( ( rb->size != 0x00 ) && ( tx_clear == 1 ) ){ + uint8_t buffer[ __CB_BUFFER_SIZE__ ]; + uint8_t * _rb_next = ring_buffer_get_next( rb ); + xmemcpy( buffer, _rb_next, __CB_BUFFER_SIZE__ ); + if( dparallel ) send_msg( "Ring Buffer less one -- remain %u", rb->size ); + send2callboxes( buffer ); + } } \ No newline at end of file