void dfu_rx_handler() { if (rx_handler) { rx_handler(); } }
int main(void) { uint8_t current_state = 0; // Used to store the current state of TX state machine uint16_t pulse_count = 0; // Used to store the current number of pulses GPIO_init(); init_timer_0A(); init_timer_0B(); nvic_init(); PWM_init(); // IR Rx GPIO port (PB4) for asynch receive init_IR_rx(); // Delay for microcontroller clock to stabilize delay_timer_0A(500); current_state = 1; // Activate the tx_state_machine while(1) { // If the 562us timer expired then it is time to update state machine /* if (mod_period_flag) { mod_period_flag = 0; tx_state_machine(¤t_state, &pulse_count, IR_address, IR_data_GREEN); //<--- TX CHANGE HERE!! } */ // If RX port senses an edge, store the timer count if (rx_interrupt_flag) { rx_interrupt_flag = 0; rx_handler(); } } }
void cdc_rx_handler() { if (rx_handler) { rx_handler(); } }
void rx_collect(uint8_t rx_data){ static uint32_t count = 0; if(rx_data != LINE_END){ if(count < BUFFER_SIZE -1){ rx_buffer[count] = rx_data; count++; } }else{ rx_buffer[count] = '\0'; if(rx_handler != NULL){ rx_handler(rx_buffer); } count = 0; } }
//------------------------------------------------------------------------------ void multicast_link_read_data (int groupP) { //------------------------------------------------------------------------------ #ifdef BYPASS_PHY //pthread_mutex_lock(&Bypass_phy_wr_mutex); // while(Bypass_phy_wr){ // msg("[Multicast read] BYPASS_PHY_NOT_YET READY, Waiting for signal\n"); // pthread_cond_wait(&Bypass_phy_wr_cond,&Bypass_phy_wr_mutex); // } //msg("[Multicast read] BYPASS_PHY TX Signal\n"); //pthread_mutex_unlock(&Bypass_phy_wr_mutex); //pthread_mutex_lock(&Bypass_phy_wr_mutex); // Bypass_phy_wr=1; // pthread_mutex_unlock(&Bypass_phy_wr_mutex); #endif //BYPASS_PHY int num_bytes; //msg("multicast link read INNNNNNNNNNNNNNNNNN\n"); // msg("multicast_link_read_data: groupP=%d,rx_buffer = %p\n",groupP,group_list[groupP].rx_buffer ); if ((groupP <= MULTICAST_LINK_NUM_GROUPS) && (groupP >= 0)) { if ((num_bytes = recvfrom (group_list[groupP].socket, group_list[groupP].rx_buffer, 40000, 0, 0, 0)) < 0) { fprintf (stderr, "ERROR: %s line %d multicast_link_read_data()/recvfrom() %m", __FILE__, __LINE__); } else { // msg("multicast_link_read_data: groupP=%d,rx_buffer = %p,NUm_bytes=%d\n",groupP,group_list[groupP].rx_buffer,num_bytes ); //msg("MULTICAST calling rx_handler\n"); rx_handler(num_bytes,group_list[groupP].rx_buffer); } } else { fprintf(stderr,"ERROR: groupP out of bounds %d\n",groupP); } //msg("ENNNNND multicast_link_read_data: groupP=%d,rx_buffer = %p, num_bytes=%d\n",groupP,group_list[groupP].rx_buffer,num_bytes ); }