Esempio n. 1
0
// Prepare Hardware Channel
int platform_adc_update_sequence( )
{
  elua_adc_dev_state *d = adc_get_dev_state( 0 );

  CloseADC10();   // Ensure the ADC is off before setting the configuration

  AD1CSSL = 0;
  AD1PCFG = 0xffffffff;

  platform_setup_adcs();

  d->seq_ctr = 0;
  while( d->seq_ctr < d->seq_len )
  {
    AD1CSSLSET = (1 << d->ch_state[ d->seq_ctr ]->id);
    AD1PCFGCLR = (1 << d->ch_state[ d->seq_ctr ]->id);
    d->seq_ctr++;
  }
  d->seq_ctr = 0;

  EnableADC10();

  // start conversion
  AD1CON1SET = _AD1CON1_ASAM_MASK;
  AD1CON1SET = _AD1CON1_SAMP_MASK;
  
  return PLATFORM_OK;
}
Esempio n. 2
0
int platform_init()
{
  // Set up microcontroller system and SystemCoreClock variable
  SystemInit();

  // DeInit NVIC and SCBNVIC
  NVIC_DeInit();
  NVIC_SCBDeInit();

  // Configure the NVIC Preemption Priority Bits:
  // two (2) bits of preemption priority, six (6) bits of sub-priority.
  // Since the Number of Bits used for Priority Levels is five (5), so the
  // actual bit number of sub-priority is three (3)
  NVIC_SetPriorityGrouping(0x05);

  //  Set Vector table offset value
#if (__RAM_MODE__==1)
  NVIC_SetVTOR(0x10000000);
#else
  NVIC_SetVTOR(0x00000000);
#endif

  // Setup peripherals
  platform_setup_timers();
  //platform_setup_pwm();

#ifdef BUILD_ADC
  // Setup ADCs
  platform_setup_adcs();
#endif

  // Setup CANs
  cans_init();

  // Setup pin routing
  platform_setup_pins();

  // System timer setup
  cmn_systimer_set_base_freq( lpc17xx_get_cpu_frequency() );
  cmn_systimer_set_interrupt_freq( SYSTICKHZ );

  // Enable SysTick
  SysTick_Config( lpc17xx_get_cpu_frequency() / SYSTICKHZ );

  // Common platform initialization code
  cmn_platform_init();

  return PLATFORM_OK;
}
Esempio n. 3
0
int platform_init()
{
  unsigned i;
  TIM_InitTypeDef tim;
  TIM_TypeDef* base;  
        
  // System configuration
  platform_config_scu();
  
  // PIO setup
  for( i = 0; i < 10; i ++ )
    GPIO_DeInit( ( GPIO_TypeDef* )port_data[ i ] );
    
  // UART setup
  platform_gpio_uart_setup();

  // Initialize timers
  for( i = 0; i < NUM_PHYS_TIMER; i ++ )
  {
    base = ( TIM_TypeDef* )str9_timer_data[ i ];
    TIM_DeInit( base );
    TIM_StructInit( &tim );
    tim.TIM_Clock_Source = TIM_CLK_APB;
    tim.TIM_Prescaler = 255;      
    TIM_Init( base, &tim );    
    TIM_CounterCmd( base, TIM_START );
  }
  
 cmn_platform_init();

#ifdef BUILD_ADC
  // Setup ADCs
  platform_setup_adcs();
#endif

#ifdef BUILD_CAN
  // Setup CANs
  cans_init();
#endif

  // Initialize system timer
  cmn_systimer_set_base_freq( 1000000 );
  cmn_systimer_set_interrupt_freq( VTMR_FREQ_HZ );
  platform_s_timer_set_match_int( VTMR_TIMER_ID, 1000000 / VTMR_FREQ_HZ, PLATFORM_TIMER_INT_CYCLIC );
  return PLATFORM_OK;
}
Esempio n. 4
0
int platform_init()
{
  // Complete CPU initialization
  platform_setup_cpu();

  // External memory
  platform_setup_extmem();   

  // Setup peripherals
  platform_setup_timers();
  platform_setup_pwm();
  
#ifdef BUILD_ADC
  // Setup ADCs
  platform_setup_adcs();
#endif

  // Common platform initialization code
  cmn_platform_init();

  return PLATFORM_OK;
}