/** * @brief Initialization */ void TIMx_BUZZER_Init() { globalBuzzerTick = 0; /* Configure timer */ BuzzerTimHandle.Instance = TIMx_BUZZER; BuzzerTimHandle.Init.Prescaler = 0; // (84 Mhz) BuzzerTimHandle.Init.CounterMode = TIM_COUNTERMODE_UP; BuzzerTimHandle.Init.Period = TIMx_BUZZER_PERIOD - 1; BuzzerTimHandle.Init.ClockDivision = 0; if (HAL_TIM_Base_Init(&BuzzerTimHandle) != HAL_OK) { //Error } GPIO_InitTypeDef GPIO_Init; // Enable peripheral clock BUZZER_CLK_ENABLE(); GPIO_Init.Pin = BUZZER_PIN; GPIO_Init.Mode = GPIO_MODE_OUTPUT_PP; GPIO_Init.Pull = GPIO_PULLUP; GPIO_Init.Speed = GPIO_SPEED_FAST; HAL_GPIO_Init(BUZZER_PORT, &GPIO_Init); HAL_GPIO_WritePin(BUZZER_PORT, BUZZER_PIN, GPIO_PIN_RESET); }
void ExpBuzzerInit(void) { GPIO_InitTypeDef GPIO_InitStruct; /* Enable the GPIO_LED Clock */ BUZZER_CLK_ENABLE(); /* Configure the GPIO_LED pin */ GPIO_InitStruct.Pin = BUZZER; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FAST; HAL_GPIO_Init(BUZZER_PORT, &GPIO_InitStruct); }