#pragma once #ifndef LED_H #define LED_H // time to show one led digit, ms #define LED_ONE_PERIOD 2 #define LED_DIGITS_NUM 8 /* LED AAA F B F B GGG E C E C DDD P */ #define LED_SEG1_PORT GPIOA #define LED_SEG1_PINS GPIO_PIN_3 #define LED_SEG_DP GPIO_PIN_3 #define LED_SEG3_PORT GPIOC #define LED_SEG3_PINS (GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_3 | GPIO_PIN_5) #define LED_SEG_A GPIO_PIN_3 #define LED_SEG_F GPIO_PIN_4 #define LED_SEG_B GPIO_PIN_5 #define LED_SEG_E GPIO_PIN_6 #define LED_SEG_G GPIO_PIN_7 #define LED_SEG2_PORT GPIOD #define LED_SEG2_PINS (GPIO_PIN_1 | GPIO_PIN_4) #define LED_SEG_C GPIO_PIN_1 #define LED_SEG_D GPIO_PIN_4 #define LED_OUT_OFF {LED_SEG1_PORT->ODR |= LED_SEG1_PINS; LED_SEG2_PORT->ODR |= LED_SEG2_PINS; LED_SEG3_PORT->ODR |= LED_SEG3_PINS;} #define LED_OUT_DP GPIOA->ODR &= ~LED_SEG_DP #define LED_OUT_MM GPIOC->ODR &= ~LED_SEG_G #define LED_OUT_0 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B|LED_SEG_E|LED_SEG_F); GPIOD->ODR &= ~(LED_SEG2_PINS) #define LED_OUT_1 GPIOC->ODR &= ~(LED_SEG_B); GPIOD->ODR &= ~(LED_SEG_C) #define LED_OUT_2 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B|LED_SEG_E|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG_D) #define LED_OUT_3 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG2_PINS) #define LED_OUT_4 GPIOC->ODR &= ~(LED_SEG_B|LED_SEG_F|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG_C) #define LED_OUT_5 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_F|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG2_PINS) #define LED_OUT_6 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_E|LED_SEG_F|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG2_PINS) #define LED_OUT_7 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B); GPIOD->ODR &= ~(LED_SEG_C) #define LED_OUT_8 GPIOC->ODR &= ~(LED_SEG3_PINS); GPIOD->ODR &= ~(LED_SEG2_PINS) #define LED_OUT_9 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B|LED_SEG_F|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG2_PINS) #define LED_OUT_H GPIOC->ODR &= ~(LED_SEG_B|LED_SEG_E|LED_SEG_F|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG_C) #define LED_OUT_PL GPIOC->ODR &= ~(LED_SEG_B|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG_C) #define LED_OUT_O GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B|LED_SEG_F|LED_SEG_G); /* shift register control pins */ #define SPI_PORT GPIOA #define SPI_SCK GPIO_PIN_1 #define SPI_DATA GPIO_PIN_2 typedef enum { led_Plus = 0xa, led_Minus = 0xb, led_H = 0xc, led_O = 0xd, led_Off = 0xff } led_sym_t; extern uint8_t LedDigits[]; extern uint8_t LedPoint[]; void led_OutputValue(void); #endif // LED_H