Modularizando o src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

Revision:
109:a5b8264ffbbc
Parent:
106:a34fcf9f0e02
Child:
112:6ae726539ab9
--- a/parallelcpld.cpp	Wed Mar 18 13:33:54 2015 +0000
+++ b/parallelcpld.cpp	Tue Apr 07 14:27:44 2015 +0000
@@ -12,9 +12,11 @@
 DigitalOut DataReady(p11);                  
 ///<IO 27
 
-uint8_t cb_tx_buffer[ CB_BUFFER_SIZE ];
+DigitalOut hw_extern_wdt( p23 );
 
-uint8_t TXBuffer[ CB_BUFFER_SIZE ]; 
+uint8_t cb_tx_buffer[ __CB_BUFFER_SIZE__ ];
+
+uint8_t TXBuffer[ __CB_BUFFER_SIZE__ ]; 
 
 uint8_t tx_clear = 1;
 
@@ -45,20 +47,25 @@
     
     delay_to_send_to_cbx.reset();
     
+    if ( drop_entendi_pkg )
+    {
+        debug_msg( "Droped entendi pkg" );
+        return;    
+    }
+    
     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 ] );
         DataReady = 1;
-        xmemcpy( cb_tx_buffer, buffer, CB_BUFFER_SIZE );
+        xmemcpy( cb_tx_buffer, buffer, __CB_BUFFER_SIZE__ );
         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[ 6 ];
         
-        //pra debug, encaminha todos os pacotes da rede fibra para o servidor de fw
         if( debug_fw ){
             buffer[ 0 ] |= BIT7;
             fw_cbx_pkg( ext, port, ( char *)buffer );
@@ -71,8 +78,6 @@
         // Error if the transmission is still in use
         uint8_t ret = ring_buffer_add( rb, buffer );
         
-        delayed_pkg_to_cb++;
-        
         if( ret == 0x01 ) if( dparallel ) debug_msg("Error: Ring buffer fully charged");
         
         if( ret == 0x00 ) if( dparallel ) debug_msg("Success : package queued -- on queue %u", rb->size );
@@ -105,9 +110,9 @@
 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 buffer[ __CB_BUFFER_SIZE__ ];
         uint8_t * _rb_next = ring_buffer_get_next( rb );
-        //xmemcpy( buffer, _rb_next, CB_BUFFER_SIZE );
+        //xmemcpy( buffer, _rb_next, __CB_BUFFER_SIZE__ );
         if( dparallel ) send_msg( "Ring Buffer less one -- remain %u", rb->size );
         send2callboxes( _rb_next );        
     }