Example #1
0
/**
 * @brief Initializes the LEDs
 * @retval None
 */
void Blox_LED_Init(void) {
  Blox_LED_RCC_Configuration();
  Blox_LED_GPIO_Configuration();
  
  Blox_System_Register_DeInit(&RCC_DeInit);
  Blox_System_Register_DeInit(&Blox_LED_DeInit_GPIO);
}
Example #2
0
/**
 * @brief Initializes Timer.
 * @param TIMx where x can be (1...8) to select the timer.
 * @param TIM_CLK specifies the TIM_CLK to set for the given timer
 *   where TIM_CLK can be in the range of 1.1kHz to 72MHz
 *   TIM_CLK = SYS_CLK / (PSC + 1)
 * @retval None
 */
void Blox_Timer_Init(uint8_t TIMx, uint32_t TIM_CLK) {
    TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
    TIM_PSC[TIMx-1] = (uint16_t) (SystemCoreClock / TIM_CLK) - 1;
    Blox_Timer_RCC_Configuration(TIMx);
    Blox_Timer_NVIC_Configuration(TIMx);
    TIM_TimeBaseStructure.TIM_Period = 65535;
    TIM_TimeBaseStructure.TIM_Prescaler = TIM_PSC[TIMx-1];
    TIM_TimeBaseStructure.TIM_ClockDivision = 0;
    TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
    switch(TIMx) {
    case 1:
        TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure);
        break;
    case 2:
        TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
        break;
    case 3:
        TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
        break;
    case 4:
        TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);
        break;
    case 5:
        TIM_TimeBaseInit(TIM5, &TIM_TimeBaseStructure);
        break;
    case 6:
        TIM_TimeBaseInit(TIM6, &TIM_TimeBaseStructure);
        break;
    case 7:
        TIM_TimeBaseInit(TIM7, &TIM_TimeBaseStructure);
        break;
    case 8:
        TIM_TimeBaseInit(TIM8, &TIM_TimeBaseStructure);
        break;
    }

    Blox_System_Register_DeInit(&RCC_DeInit);
    Blox_System_Register_DeInit(&Blox_Timer_DeInit_Timer);
}