Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
Diff: parallelcpld.cpp
- Revision:
- 126:1f90756250fb
- Parent:
- 125:8ff4dc96ad58
- Child:
- 132:05cd37f7e007
diff -r 8ff4dc96ad58 -r 1f90756250fb parallelcpld.cpp --- a/parallelcpld.cpp Wed May 13 21:18:12 2015 +0000 +++ b/parallelcpld.cpp Wed May 20 19:50:31 2015 +0000 @@ -14,16 +14,13 @@ DigitalOut hw_extern_wdt( p23 ); -uint8_t cb_tx_buffer[ CB_BUFFER_SIZE ]; +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; - -Timer delay_to_send_to_cbx; // Print a variable using parallel protocol void parallel_write( uint8_t data ){ @@ -38,60 +35,60 @@ } // Needs: function parallel_write/ Global variables: TXBuffer, tx_clear / Configuration extern interrupt -void send2callboxes( uint8_t * buffer ){ - static bool once = true; - if( once ){ - delay_to_send_to_cbx.start(); - once = false; - } - - delay_to_send_to_cbx.reset(); - - if ( drop_entendi_pkg && ( buffer[ TYPE_PLACE ] == INVITE ) ) +void send2callboxes( uint8_t * buffer ) +{ + if ( drop_entendi_pkg and ( buffer[ TYPE_PLACE ] == INVITE ) ) { debug_msg( "Droped entendi pkg" ); return; } - - if( tx_clear == 1 ){ + + if( tx_clear == 1 ) + { tx_clear = 0; - xmemcpy( TXBuffer, buffer, CB_BUFFER_SIZE ); + xmemcpy ( TXBuffer, buffer, CB_BUFFER_SIZE ); // Send the first position of TXBuffer first - parallel_write ( TXBuffer[ 0 ] ); + parallel_write ( TXBuffer [ 0 ] ); DataReady = 1; cpld_pkg_tx_counter++; uint16_t ext = ( ( uint16_t )buffer[ 0 ] ) << 8 | buffer[ 1 ]; uint16_t port = ( ( uint16_t )buffer[ 2 ] ) << 8 | buffer[ 3 ]; - uint8_t type = buffer[ TYPE_PLACE ]; + uint8_t type = buffer [ TYPE_PLACE ]; - if( debug_fw ){ + if ( debug_fw ) + { buffer[ 0 ] |= BIT7; - fw_cbx_pkg( ext, port, ( char *)buffer ); + fw_cbx_pkg ( ext, ( char *)buffer ); } - if( type != AUDIO ) + if ( ( type not_eq AUDIO ) and not ( do_not_show_this_invite_pkg ) ) { - xmemcpy( cb_tx_buffer, buffer, CB_BUFFER_SIZE ); + xmemcpy ( cb_tx_buffer, buffer, CB_BUFFER_SIZE ); if ( debug_show_tx_cpld ) { - char str[ 256 ]; - strcpy( str, "TX :: \n\r" ); - for( register uint16_t i = 0; i < 32; i++ ) { - char tmp[ 16 ]; - snprintf ( tmp, sizeof ( tmp ), "%02x ", cb_tx_buffer [ i ] ); - strcat( str, tmp ); + char str [ 256 ]; + strcpy ( str, "TX :: \n\r" ); + for ( register uint16_t i = 0; i < 32; i++ ) + { + char tmp [ 8 ]; + sprintf ( tmp, "%02x ", cb_tx_buffer [ i ] ); + strcat ( str, tmp ); } strcat ( str, "\n\r " ); - send_msg( "%s", str ); + send_msg ( "%s", str ); } - if ( debug_cb_tx == true ) send_msg("H -> CBx :: ( %d, %d ) -- Type :: %d", ext, port, type ); + if ( debug_cb_tx ) send_msg ("H -> CBx :: ( %d, %d ) -- Type :: %d", ext, port, type ); + + if ( debug_sqn ) send_msg ("H -> CBx :: ( %d, %d ) -- Type :: %d -- seq_num :: %u", ext, port, type, cb_tx_buffer [ SEQ_NUM_PLACE ] ); } + + do_not_show_this_invite_pkg = false; }else{ // Error if the transmission is still in use @@ -129,11 +126,8 @@ } void tx_buffer_ring_buffer_handler( void ){ - //if( ( rb->size != 0x00 ) && ( tx_clear == 1 ) && ( delay_to_send_to_cbx.read_ms() > 7 ) ){ 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( _rb_next ); }