LED.c 566 B

123456789101112131415161718192021222324252627
  1. #include "LED.h"
  2. void LEDGPIO_Init(void)
  3. {
  4. GPIO_InitTypeDef GPIO_InitStructure;
  5. RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC ,ENABLE);
  6. GPIO_InitStructure.GPIO_Pin=GPIO_Pin_3 | GPIO_Pin_2 ; //--LED0-PC3 LED1-PC2
  7. GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
  8. GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
  9. GPIO_Init(GPIOC,&GPIO_InitStructure);
  10. LED0 = 1;
  11. LED1 = 1;
  12. }
  13. void LED_Toogle( uint8_t cnt)
  14. {
  15. uint8_t num = cnt*2;
  16. while( num-- )
  17. {
  18. GPIOC->ODR ^= GPIO_Pin_2;
  19. GPIOC->ODR ^= GPIO_Pin_3;
  20. delay_ms(400);
  21. }
  22. }