Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
parallelcpld.cpp
00001 #include "parallelcpld.h" 00002 00003 DigitalOut data0(p30); //LSB 00004 DigitalOut data1(p31); 00005 DigitalOut data2(p32); 00006 DigitalOut data3(p33); 00007 DigitalOut data4(p34); 00008 DigitalOut data5(p37); 00009 DigitalOut data6(p38); 00010 DigitalOut data7(p39); //MSB 00011 00012 DigitalOut DataReady(p11); 00013 ///<IO 27 00014 00015 DigitalOut hw_extern_wdt( p23 ); 00016 00017 uint8_t cb_tx_buffer [ CB_BUFFER_SIZE ]; 00018 00019 uint8_t TXBuffer[ CB_BUFFER_SIZE ]; 00020 00021 uint8_t tx_clear = 1; 00022 00023 ring_buffer * rb = ring_buffer_init( NULL ); 00024 00025 // Print a variable using parallel protocol 00026 void parallel_write( uint8_t data ){ 00027 data0 = BIT0&(data); 00028 data1 = BIT1&(data); 00029 data2 = BIT2&(data); 00030 data3 = BIT3&(data); 00031 data4 = BIT4&(data); 00032 data5 = BIT5&(data); 00033 data6 = BIT6&(data); 00034 data7 = BIT7&(data); 00035 } 00036 00037 // Needs: function parallel_write/ Global variables: TXBuffer, tx_clear / Configuration extern interrupt 00038 void send2callboxes( uint8_t * buffer ) 00039 { 00040 if ( drop_entendi_pkg and ( buffer[ TYPE_PLACE ] == INVITE ) ) 00041 { 00042 vz_debug ( "Droped entendi pkg" ); 00043 return; 00044 } 00045 00046 if( tx_clear == 1 ) 00047 { 00048 tx_clear = 0; 00049 xmemcpy ( TXBuffer, buffer, CB_BUFFER_SIZE ); 00050 00051 // Send the first position of TXBuffer first 00052 parallel_write ( TXBuffer [ 0 ] ); 00053 DataReady = 1; 00054 00055 cpld_pkg_tx_counter++; 00056 00057 uint16_t ext = ( ( uint16_t )buffer[ 0 ] ) << 8 | buffer[ 1 ]; 00058 uint16_t port = ( ( uint16_t )buffer[ 2 ] ) << 8 | buffer[ 3 ]; 00059 uint8_t type = buffer [ TYPE_PLACE ]; 00060 00061 if ( debug_fw ) 00062 { 00063 buffer[ 0 ] |= BIT7; 00064 fw_cbx_pkg ( ext, ( char *)buffer ); 00065 } 00066 00067 if ( ( type not_eq AUDIO ) and not ( do_not_show_this_invite_pkg ) ) 00068 { 00069 xmemcpy ( cb_tx_buffer, buffer, CB_BUFFER_SIZE ); 00070 00071 if ( debug_show_tx_cpld ) 00072 { 00073 char str [ 256 ]; 00074 strcpy ( str, "TX :: \n\r" ); 00075 for ( register uint16_t i = 0; i < 32; i++ ) 00076 { 00077 char tmp [ 8 ]; 00078 sprintf ( tmp, "%02x ", cb_tx_buffer [ i ] ); 00079 strcat ( str, tmp ); 00080 } 00081 strcat ( str, "\n\r " ); 00082 00083 vz_printf ( "%s", str ); 00084 } 00085 00086 if ( debug_cb_tx ) vz_printf ("H -> CBx :: ( %d, %d ) -- Type :: %d", ext, port, type ); 00087 00088 if ( debug_sqn ) vz_printf ("H -> CBx :: ( %d, %d ) -- Type :: %d -- seq_num :: %u", ext, port, type, cb_tx_buffer [ SEQ_NUM_PLACE ] ); 00089 } 00090 00091 do_not_show_this_invite_pkg = false; 00092 00093 }else{ 00094 // Error if the transmission is still in use 00095 uint8_t ret = ring_buffer_add( rb, buffer ); 00096 00097 delayed_pkg_to_cb++; 00098 00099 if( ret == 0x01 ) if( dparallel ) vz_debug ("Error: Ring buffer fully charged"); 00100 00101 if( ret == 0x00 ) if( dparallel ) vz_debug ("Success : package queued -- on queue %u", rb->size ); 00102 } 00103 } 00104 00105 //***************************************************************************** 00106 // EXTERN IRQ Handler 00107 //***************************************************************************** 00108 00109 void get2(){ 00110 static uint16_t c = 1; 00111 // Get Ready the new data 00112 DataReady = 0; 00113 tx_clear = 0; 00114 00115 if ( c < 300 ){ 00116 // Write the next data to be send 00117 parallel_write ( TXBuffer[c] ) ; 00118 // Allow the data to be capture 00119 DataReady = 1; 00120 }else{ 00121 // Allow the next package to the transmitted 00122 tx_clear = 1; 00123 c = 0; 00124 } 00125 c++; 00126 } 00127 00128 void tx_buffer_ring_buffer_handler( void ){ 00129 if( ( rb->size != 0x00 ) && ( tx_clear == 1 ) ){ 00130 uint8_t * _rb_next = ring_buffer_get_next( rb ); 00131 if( dparallel ) vz_printf ( "Ring Buffer less one -- remain %u", rb->size ); 00132 send2callboxes( _rb_next ); 00133 } 00134 }
Generated on Tue Jul 12 2022 16:25:06 by
