Buzzer.c 525 B

12345678910111213141516171819202122232425
  1. #include "stm32f10x.h" // Device header
  2. void Buzzer_Init(void)
  3. {
  4. RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
  5. GPIO_InitTypeDef GPIO_InitStruture;
  6. GPIO_InitStruture.GPIO_Mode = GPIO_Mode_Out_PP;
  7. GPIO_InitStruture.GPIO_Pin = GPIO_Pin_12;
  8. GPIO_InitStruture.GPIO_Speed = GPIO_Speed_50MHz;
  9. GPIO_Init(GPIOB, &GPIO_InitStruture);
  10. GPIO_ResetBits(GPIOB, GPIO_Pin_12);
  11. }
  12. void Buzzer_ON(void)
  13. {
  14. GPIO_SetBits(GPIOB, GPIO_Pin_12);
  15. }
  16. void Buzzer_OFF(void)
  17. {
  18. GPIO_ResetBits(GPIOB, GPIO_Pin_12);
  19. }