Пример #1
0
void HAL_Core_Setup(void) {

    /* Reset system to disable IWDG if enabled in bootloader */
    IWDG_Reset_Enable(0);

    HAL_Core_Setup_finalize();

    bootloader_update_if_needed();
    HAL_Bootloader_Lock(true);

#if !MODULAR_FIRMWARE
    module_user_init_hook();
#endif
}
Пример #2
0
/*********************************************************************************
  *Function     : void init(void)
  *Description  : initiale
  *Input        : none
  *Output       : none
  *Return       : none
  *author       : lz
  *date         : 6-December-2014
  *Others       : none        
**********************************************************************************/ 
void init(void)
{
    //disable JTAG-DP,release pin 29(PB3),30(PB4),23(PA15)
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO , ENABLE);
    
#ifdef DFU_BUILD_ENABLE
    NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x5000); // lz
#endif

#ifdef SWD_JTAG_DISABLE
    /* Disable the Serial Wire JTAG Debug Port SWJ-DP */
    GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);
#endif

    // Set Systick to 1ms interval, common to all SAM3 variants
    if (SysTick_Config(SystemCoreClock / 1000))
    {
        // Capture error
        while (true);
    }
    /* Configure the SysTick Handler Priority: Preemption priority and subpriority */
    NVIC_SetPriority(SysTick_IRQn, SYSTICK_IRQ_PRIORITY);	
    
    //digital pin  default output  low
    for (unsigned i = 0; i < FIRST_ANALOG_PIN+TOTAL_ANALOG_PINS; i++)
    {
        pinMode(i, OUTPUT);
        digitalWrite(i, LOW);
    }

    RTC_Configuration(); 

    DWT_Init();

#ifdef IWDG_RESET_ENABLE
    IWDG_Reset_Enable(3 * TIMING_IWDG_RELOAD);
#endif

    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
    TIM1_Configuration();
    TIM_Cmd(TIM1, DISABLE); //定时器关闭
    NVIC_DisableIRQ(TIM1_UP_IRQn);
}
Пример #3
0
/*******************************************************************************
 * Function Name  : HAL_Core_Config.
 * Description    : Called in startup routine, before calling C++ constructors.
 * Input          : None.
 * Output         : None.
 * Return         : None.
 *******************************************************************************/
void HAL_Core_Config(void)
{
	// this ensures the stm32_it.c functions aren't dropped by the linker, thinking
	// they are unused. Without this none of the interrupts handlers are linked.
	linkme();
	DECLARE_SYS_HEALTH(ENTERED_SparkCoreConfig);
#ifdef DFU_BUILD_ENABLE
	/* Set the Vector Table(VT) base location at 0x5000 */
	NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x5000);

	USE_SYSTEM_FLAGS = 1;
#endif

#ifdef SWD_JTAG_DISABLE
	/* Disable the Serial Wire JTAG Debug Port SWJ-DP */
	GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);
#else
#ifdef SWD_ENABLE_JTAG_DISABLE
  /* Disable JTAG, but enable SWJ-DP */
  GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
#endif
#endif

	Set_System();

	SysTick_Configuration();

	/* Enable CRC clock */
	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE);

	HAL_RTC_Configuration();

	/* Execute Stop mode if STOP mode flag is set via System.sleep(pin, mode) */
	HAL_Core_Execute_Stop_Mode();

	LED_SetRGBColor(RGB_COLOR_WHITE);
	LED_On(LED_RGB);

#ifdef IWDG_RESET_ENABLE
	// ToDo this needs rework for new bootloader
	/* Check if the system has resumed from IWDG reset */
	if (RCC_GetFlagStatus(RCC_FLAG_IWDGRST) != RESET)
	{
		/* IWDGRST flag set */
		IWDG_SYSTEM_RESET = 1;

		/* Clear reset flags */
		RCC_ClearFlag();
	}

	/* We are duplicating the IWDG call here for compatibility with old bootloader */
	/* Set IWDG Timeout to 3 secs */
	IWDG_Reset_Enable(3 * TIMING_IWDG_RELOAD);
#endif

#ifdef DFU_BUILD_ENABLE
	Load_SystemFlags();
#endif

	sFLASH_Init();

        module_user_init_hook();
}