Example #1
0
int platform_init()
{
    // Set the clocking to run from PLL
#if defined( FORLM3S9B92 ) || defined( FORLM3S9D92 )
    MAP_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
#else
    MAP_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);
#endif

    // Setup PIO
    pios_init();

    // Setup SSIs
    spis_init();

    // Setup UARTs
    uarts_init();

    // Setup timers
    timers_init();

    // Setup PWMs
    pwms_init();

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

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

    // Setup system timer
    cmn_systimer_set_base_freq( MAP_SysCtlClockGet() );
    cmn_systimer_set_interrupt_freq( SYSTICKHZ );

    // Setup ethernet (TCP/IP)
    eth_init();

    // Common platform initialization code
    cmn_platform_init();

    // Virtual timers
    // If the ethernet controller is used the timer is already initialized, so skip this sequence
#if VTMR_NUM_TIMERS > 0 && !defined( BUILD_UIP )
    // Configure SysTick for a periodic interrupt.
    MAP_SysTickPeriodSet( MAP_SysCtlClockGet() / SYSTICKHZ );
    MAP_SysTickEnable();
    MAP_SysTickIntEnable();
    MAP_IntMasterEnable();
#endif

    // All done
    return PLATFORM_OK;
}
Example #2
0
int platform_init()
{
  // Set the clocking to run from PLL
  RCC_Configuration();

  // Setup IRQ's
  NVIC_Configuration();

  // Setup PIO
  pios_init();

  // Setup UARTs
  uarts_init();
  
  // Setup SPIs
  spis_init();
  
  // Setup timers
  timers_init();
  
  // Setup PWMs
  pwms_init();

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

  // Setup CANs
  cans_init();

  // Setup system timer
  cmn_systimer_set_base_freq( HCLK );
  cmn_systimer_set_interrupt_freq( SYSTICKHZ );
  
  // Enable SysTick
  if ( SysTick_Config( HCLK / SYSTICKHZ ) )
  { 
    /* Capture error */ 
    while (1);
  }

  // Flash initialization (for WOFS)
  FLASH_Unlock();
  
  cmn_platform_init();

  // All done
  return PLATFORM_OK;
}
Example #3
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;
}
Example #4
0
int platform_init()
{

  // Setup IRQ's
  NVIC_Configuration();

  // Setup PIO
  pios_init();

  // Setup UARTs
  uarts_init();

  // Setup SPIs
  spis_init();

  // Setup timers
  timers_init();

  // Setup PWMs
  pwms_init();

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

#if (NUM_CAN > 0)
  // Setup CANs
  cans_init();
#endif

  // Setup system timer
  cmn_systimer_set_base_freq( HCLK );
  cmn_systimer_set_interrupt_freq( SYSTICKHZ );

  // Enable SysTick
  if ( SysTick_Config( HCLK / SYSTICKHZ ) )
  {
    /* Capture error */
    while (1);
  }

  cmn_platform_init();

  // All done
  return PLATFORM_OK;
}
Example #5
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;
}