コード例 #1
0
ファイル: can.c プロジェクト: gedare/rtems
rtems_status_code can_open( const lpc176x_can_number minor, can_freq freq )
{
  const can_driver_entry *const can_driver = &can_driver_table[ minor ];
  rtems_status_code             sc = RTEMS_INVALID_NUMBER;

  if ( CAN_DRIVER_IS_MINOR_VALID( minor ) ) {
    /*Enable CAN and acceptance filter modules.*/
    sc =
      lpc176x_module_enable( can_driver->module, LPC176X_MODULE_PCLK_DEFAULT );
    RTEMS_CHECK_SC( sc, "enable can module" );
    sc = lpc176x_module_enable( LPC176X_MODULE_ACCF,
      LPC176X_MODULE_PCLK_DEFAULT );
    RTEMS_CHECK_SC( sc, "enable acceptance filter" );
    /*Set pin functions.*/
    setpins( minor );

    can_reset( can_driver );
    can_driver->device->IER = CAN_DEFAULT_INTERRUPT_CONFIGURATION;
    sc = can_frequency( can_driver, freq );
    RTEMS_CHECK_SC( sc, "Configure CAN frequency" );
    can_initialize();

    acceptance_filter_device->AFMR = CAN_ACCF_AFMR_ACCBP;     /*Bypass Filter.*/
  }

  return sc;
}
コード例 #2
0
/*
   swich_state
   This function must be call each 10ms aprox. (between 2ms and 20ms) in order to view the display correctly.
   Call this function only once if you want to turn off the display (after calling set_dX(false)).
*/
void clockdisplay::switch_state()
{
    byte i1, i2, i3, i4;
    i1 = i2 = i3 = i4 = 0x10; //Set all digits as non-visible
    state ^= 1; //switch commons cathodes states
    if (base10) //select decimal digits, if visible
    {
        if (v1)
        {
            i1 = (b1/10)%10;
        }
        if (v2)
        {
            i2 = b1%10;
        }
        if (v3)
        {
            i3 = (b2/10)%10;
        }
        if (v4)
        {
            i4 = b2%10;
        }
    }
    else //select hexadecimal digits, if visible
    {
        if (v1)
        {
            i1 = b1/16;
        }
        if (v2)
        {
            i2 = b1%16;
        }
        if (v3)
        {
            i3 = b2/16;
        }
        if (v4)
        {
            i4 = b2%16;
        }
    }
    setpins(i1, i2, i3, i4);
}