| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #include "led.h"
- #include "stm32f10x.h"
- #include "stdint.h"
- void led_init()
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE);
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14 | GPIO_Pin_15;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_Init(GPIOB, &GPIO_InitStructure);
- GPIO_SetBits(GPIOB, GPIO_Pin_14 | GPIO_Pin_15);
- }
- void led_flash()
- {
- static uint8_t flag = 0;
-
- if(flag)
- {
- flag = 0;
- GPIO_SetBits(GPIOB, GPIO_Pin_14);
- }else
- {
- flag = 1;
- GPIO_ResetBits(GPIOB, GPIO_Pin_14);
- }
- }
- void led_status()
- {
- static uint8_t flag = 0;
-
- if(flag)
- {
- flag = 0;
- GPIO_SetBits(GPIOB, GPIO_Pin_15);
- }else
- {
- flag = 1;
- GPIO_ResetBits(GPIOB, GPIO_Pin_15);
- }
- }
-
- void led_clear()
- {
- GPIO_SetBits(GPIOB, GPIO_Pin_14);
- GPIO_SetBits(GPIOB, GPIO_Pin_15);
- }
|