// Helper function for buffers static int cmn_recv_helper( unsigned id, timer_data_type timeout ) { #ifdef BUF_ENABLE_UART t_buf_data data; #endif #ifdef BUF_ENABLE_UART if( buf_is_enabled( BUF_ID_UART, id ) ) { if( timeout == 0 ) { if ( ( buf_read( BUF_ID_UART, id, &data ) ) == PLATFORM_UNDERFLOW ) return -1; } else { while( ( buf_read( BUF_ID_UART, id, &data ) ) == PLATFORM_UNDERFLOW ); } return ( int )data; } else #endif // #ifdef BUF_ENABLE_UART if( id < NUM_UART || id == CDC_UART_ID ) return platform_s_uart_recv( id, timeout ); return -1; }
static void cmn_uart_rx_inthandler( picoc_int_resnum resnum ) { if( buf_is_enabled( BUF_ID_UART, resnum ) || resnum == SERMUX_PHYS_ID ) cmn_rx_handler( resnum, platform_s_uart_recv( resnum, 0 ) ); // Chain to previous handler if( prev_uart_rx_handler != NULL ) prev_uart_rx_handler( resnum ); }
static void cmn_uart_rx_inthandler( elua_int_resnum resnum ) { int data; if( buf_is_enabled( BUF_ID_UART, resnum ) || resnum == SERMUX_PHYS_ID ) { while( -1 != ( data = platform_s_uart_recv( resnum, 0 ) ) ) cmn_rx_handler( resnum, ( u8 )data ); } // Chain to previous handler if( prev_uart_rx_handler != NULL ) prev_uart_rx_handler( resnum ); }
// Helper function for buffers static int cmn_recv_helper( unsigned id, s32 timeout ) { #ifdef BUF_ENABLE_UART t_buf_data data; if( buf_is_enabled( BUF_ID_UART, id ) ) { if( timeout == 0 ) { if ( ( buf_read( BUF_ID_UART, id, &data ) ) == PLATFORM_UNDERFLOW ) return -1; } else { while( ( buf_read( BUF_ID_UART, id, &data ) ) == PLATFORM_UNDERFLOW ); } return ( int )data; } else #endif return platform_s_uart_recv( id, timeout ); }