2017-08-20 12:41:17 +00:00
|
|
|
/*
|
|
|
|
* LedConfig.h
|
|
|
|
*
|
|
|
|
* Created on: 05.07.2017
|
|
|
|
* Author: mateusz
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LEDCONFIG_H_
|
|
|
|
#define LEDCONFIG_H_
|
|
|
|
|
2020-07-12 22:13:39 +00:00
|
|
|
// PC8 - LED1 - upper
|
|
|
|
// PC9 - LED2 - lower
|
|
|
|
|
2021-05-30 11:54:25 +00:00
|
|
|
#ifdef STM32F10X_MD_VL
|
2020-07-12 22:13:39 +00:00
|
|
|
#include <stm32f10x.h>
|
2021-05-30 11:54:25 +00:00
|
|
|
#endif
|
|
|
|
#ifdef STM32L471xx
|
|
|
|
#include <stm32l4xx.h>
|
|
|
|
#include <stm32l4xx_ll_gpio.h>
|
|
|
|
#endif
|
|
|
|
|
2020-07-12 22:13:39 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#define BLINK_DURATION_MSEC 20 * BLINK_MSEC_PER_SVC_CALL
|
|
|
|
#define BLINK_MSEC_PER_SVC_CALL 10
|
2017-08-20 12:41:17 +00:00
|
|
|
|
|
|
|
/* C++ detection */
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2020-07-12 22:13:39 +00:00
|
|
|
extern uint8_t led_blinking_led2;
|
|
|
|
extern uint8_t led_blinking_led1;
|
|
|
|
|
|
|
|
void led_config(void);
|
2020-10-29 18:48:06 +00:00
|
|
|
void led_init(void);
|
2023-10-29 05:36:28 +00:00
|
|
|
void led_deinit(void);
|
2020-07-12 22:13:39 +00:00
|
|
|
void led_service_blink(void);
|
|
|
|
|
2021-05-30 11:54:25 +00:00
|
|
|
#ifdef STM32F10X_MD_VL
|
2020-07-12 22:13:39 +00:00
|
|
|
inline void led_control_led1_upper(bool _in) {
|
|
|
|
if (_in == true) {
|
|
|
|
GPIOC->BSRR |= GPIO_BSRR_BS8;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GPIOC->BSRR |= GPIO_BSRR_BR8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void led_control_led2_bottom(bool _in) {
|
|
|
|
if (_in == true) {
|
|
|
|
GPIOC->BSRR |= GPIO_BSRR_BS9;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GPIOC->BSRR |= GPIO_BSRR_BR9;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void led_flip_led1_upper(void) {
|
|
|
|
if ((GPIOC->ODR & GPIO_ODR_ODR8) == GPIO_ODR_ODR8) {
|
|
|
|
GPIOC->BSRR |= GPIO_BSRR_BR8;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GPIOC->BSRR |= GPIO_BSRR_BS8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void led_flip_led2_bottom(void) {
|
|
|
|
if ((GPIOC->ODR & GPIO_ODR_ODR9) == GPIO_ODR_ODR9) {
|
|
|
|
GPIOC->BSRR |= GPIO_BSRR_BR9;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GPIOC->BSRR |= GPIO_BSRR_BS9;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void led_blink_led1_upper(void) {
|
|
|
|
led_blinking_led1 = BLINK_DURATION_MSEC;
|
|
|
|
|
|
|
|
led_flip_led1_upper();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void led_blink_led2_botoom(void) {
|
|
|
|
led_blinking_led2 = BLINK_DURATION_MSEC;
|
|
|
|
|
|
|
|
led_flip_led2_bottom();
|
|
|
|
|
|
|
|
}
|
2021-05-30 11:54:25 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef STM32L471xx
|
2023-10-29 05:36:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Switches on or off upper LED in ParaTNC or bottom led
|
|
|
|
* in ParaMETEO. In ParaMETEO leds are distinguished when
|
|
|
|
* holding the PCB on longer edge towards bottom, and
|
|
|
|
* weather sensors connectors upwards.
|
|
|
|
* @param _in
|
|
|
|
*/
|
2021-05-30 11:54:25 +00:00
|
|
|
inline void led_control_led1_upper(bool _in) {
|
|
|
|
if (_in == true) {
|
|
|
|
GPIOC->BSRR |= GPIO_BSRR_BS8;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GPIOC->BSRR |= GPIO_BSRR_BR8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-29 05:36:28 +00:00
|
|
|
/**
|
|
|
|
* Switches on or off bottom LED in ParaTNC or upper led
|
|
|
|
* in ParaMETEO. In ParaMETEO leds are distinguished when
|
|
|
|
* holding the PCB on longer edge towards bottom, and
|
|
|
|
* weather sensors connectors upwards.
|
|
|
|
* @param _in
|
|
|
|
*/
|
2021-05-30 11:54:25 +00:00
|
|
|
inline void led_control_led2_bottom(bool _in) {
|
|
|
|
if (_in == true) {
|
2021-09-21 19:39:05 +00:00
|
|
|
GPIOC->BSRR |= GPIO_BSRR_BS9;
|
2021-05-30 11:54:25 +00:00
|
|
|
}
|
|
|
|
else {
|
2021-09-21 19:39:05 +00:00
|
|
|
GPIOC->BSRR |= GPIO_BSRR_BR9;
|
2021-05-30 11:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void led_flip_led1_upper(void) {
|
|
|
|
if ((GPIOC->ODR & GPIO_ODR_ODR_8) == GPIO_ODR_ODR_8) {
|
|
|
|
GPIOC->BSRR |= GPIO_BSRR_BR8;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GPIOC->BSRR |= GPIO_BSRR_BS8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void led_flip_led2_bottom(void) {
|
2021-09-21 19:39:05 +00:00
|
|
|
if ((GPIOA->ODR & GPIO_ODR_ODR_9) == GPIO_ODR_ODR_9) {
|
|
|
|
GPIOC->BSRR |= GPIO_BSRR_BR9;
|
2021-05-30 11:54:25 +00:00
|
|
|
}
|
|
|
|
else {
|
2021-09-21 19:39:05 +00:00
|
|
|
GPIOC->BSRR |= GPIO_BSRR_BS9;
|
2021-05-30 11:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void led_blink_led1_upper(void) {
|
|
|
|
led_blinking_led1 = BLINK_DURATION_MSEC;
|
|
|
|
|
|
|
|
led_flip_led1_upper();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void led_blink_led2_botoom(void) {
|
|
|
|
led_blinking_led2 = BLINK_DURATION_MSEC;
|
|
|
|
|
|
|
|
led_flip_led2_bottom();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2017-08-20 12:41:17 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* LEDCONFIG_H_ */
|