Example #1
0
int rt_hw_cpu_init(void)
{
    MAP_IntMasterDisable();
    IntRegister(FAULT_HARD, HardFault_Handler);	
    IntRegister(FAULT_PENDSV, PendSV_Handler);
    IntRegister(FAULT_SYSTICK, SysTick_Handler);
    
    // Enable lazy stacking for interrupt handlers.  This allows floating-point
    // instructions to be used within interrupt handlers, but at the expense of
    // extra stack usage.
    MAP_FPULazyStackingEnable();

    // Set the clocking to run directly from the external crystal/oscillator.
    // TODO: The SYSCTL_XTAL_ value must be changed to match the value of the
    // crystal on your board.
    SysClock = MAP_SysCtlClockFreqSet(
                (SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480),
                SYS_CLOCK_DEFAULT);

    MAP_SysTickDisable();
    MAP_SysTickPeriodSet(SysClock/ RT_TICK_PER_SECOND - 1);
    MAP_SysTickIntEnable();
    MAP_SysTickEnable();	

    return 0;
}
Example #2
0
void init_hardware()
{
    // Set SysTick timer period (TN_SYS_TICK_FQ_HZ)
    MAP_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                       SYSCTL_XTAL_16MHZ);
    ///////////
    MAP_SysTickDisable();
    MAP_SysTickPeriodSet(MAP_SysCtlClockGet() / TN_SYS_TICK_FQ_HZ);
    MAP_SysTickIntEnable();
    MAP_SysTickEnable();
}
Example #3
0
void suspend(void)
{
	stay_asleep = true;

	HWREG(NVIC_SYS_CTRL) |= NVIC_SYS_CTRL_SLEEPDEEP;

	while(stay_asleep) {
		MAP_IntMasterDisable();  // Set PRIMASK so CPU wakes on IRQ but ISRs don't execute until PRIMASK is cleared
		MAP_SysTickDisable();  // Halt SysTick during suspend mode - millis will no longer increment

		CPUwfi_safe();

		MAP_SysTickEnable();   // Re-enable SysTick before ISRs start (in case ISR uses millis/micros)
		MAP_IntMasterEnable();  // Clearing PRIMASK allows pending ISRs to run
	}

	HWREG(NVIC_SYS_CTRL) &= ~(NVIC_SYS_CTRL_SLEEPDEEP);
}
Example #4
0
/**
 * This function will initial LPC40xx board.
 */
void rt_hw_board_init()
{
  MAP_IntMasterDisable();
    IntRegister(FAULT_HARD, HardFault_Handler);	
    IntRegister(FAULT_PENDSV, PendSV_Handler);
    IntRegister(FAULT_SYSTICK, SysTick_Handler);
    
	  //
    // Enable lazy stacking for interrupt handlers.  This allows floating-point
    // instructions to be used within interrupt handlers, but at the expense of
    // extra stack usage.
    //
    MAP_FPULazyStackingEnable();

    //
    // Set the clocking to run directly from the external crystal/oscillator.
    // TODO: The SYSCTL_XTAL_ value must be changed to match the value of the
    // crystal on your board.
    //
    SysClock = MAP_SysCtlClockFreqSet(
                (SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480),
                SYS_CLOCK_DEFAULT);

    MAP_SysTickDisable();
    MAP_SysTickPeriodSet(SysClock/ RT_TICK_PER_SECOND - 1);
    MAP_SysTickIntEnable();
    MAP_SysTickEnable();	

    /* set pend exception priority */
    //IntPrioritySet(FAULT_PENDSV, (1 << 5) - 1);
    
    /*init uart device*/		
    rt_hw_uart_init();
    //redirect RTT stdio to CONSOLE device
    rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
    //
    // Enable interrupts to the processor.
    //
	  MAP_IntMasterEnable();
}