Example #1
0
int platform_uart_set_buffer( unsigned id, unsigned log2size )
{
  if( id == SERMUX_PHYS_ID ) // mere mortals aren't allowed to mess with VUART physical interface buffering
    return PLATFORM_ERR;
#ifdef BUF_ENABLE_UART
  if( log2size == 0 )
  {
    if( id >= SERMUX_SERVICE_ID_FIRST ) // Virtual UARTs need buffers no matter what
      return PLATFORM_ERR; 
    // Disable buffering
    buf_set( BUF_ID_UART, id, BUF_SIZE_NONE, BUF_DSIZE_U8 );
  }  
  else
  {
    // Enable buffering
    if( buf_set( BUF_ID_UART, id, log2size, BUF_DSIZE_U8 ) == PLATFORM_ERR )
      return PLATFORM_ERR;
    if( id >= SERMUX_SERVICE_ID_FIRST ) // No need for aditional setup on virtual UARTs
      return PLATFORM_OK;    
    // Enable UART RX interrupt 
    if( platform_cpu_set_interrupt( INT_UART_RX, id, PLATFORM_CPU_ENABLE ) != PLATFORM_INT_OK )
      return PLATFORM_ERR;
    // Setup our C handler
    if( elua_int_get_c_handler( INT_UART_RX ) != cmn_uart_rx_inthandler )
      prev_uart_rx_handler = elua_int_set_c_handler( INT_UART_RX, cmn_uart_rx_inthandler );
  }
  return PLATFORM_OK;
#else // BUF_ENABLE_UART
  return PLATFORM_ERR;
#endif // BUF_ENABLE_UART
}
Example #2
0
// Common interrupt handling
void cmn_int_handler( elua_int_id id, elua_int_resnum resnum )
{
  elua_int_add( id, resnum );
#ifdef BUILD_C_INT_HANDLERS
  elua_int_c_handler phnd = elua_int_get_c_handler( id );
  if( phnd )
    phnd( resnum );
#endif
}
Example #3
0
// Setup the serial multiplexer
void cmn_uart_setup_sermux()
{
  // Enable UART RX interrupt 
  if( platform_cpu_set_interrupt( INT_UART_RX, SERMUX_PHYS_ID, PLATFORM_CPU_ENABLE ) == PLATFORM_INT_OK )
  {
    // Setup our C handler
    if( elua_int_get_c_handler( INT_UART_RX ) != cmn_uart_rx_inthandler )
      prev_uart_rx_handler = elua_int_set_c_handler( INT_UART_RX, cmn_uart_rx_inthandler );
  }
  else // We don't have a choice but to get stuck here, as we can't print an error anyway, since the console most likely lives on a virtual UART
    while( 1 );      
}