mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-23 11:13:09 +00:00
68a3f6b4b7
* Add F5 target, lp5562 driver and api-hal-light. Update api-usage, switch to F5 by default. * API HAL: add i2c and hardware version api. Dolphin: show hardware version. * OTP version generator and flashing utility. * Assets script: fix code formatting * Backport F5 changes to F4 * F4: disable insomnia, prevent damage to BLE RX path * F5 HAL API Light: remove magic delay to fix magic BLE * Dolphin: HW target validation on start * invert RSSI indication in sub-1 * API HAL: rename board to body in version api * Gpio tester: detach and release viewport on exit Co-authored-by: aanper <mail@s3f.ru>
55 lines
No EOL
1.8 KiB
C
55 lines
No EOL
1.8 KiB
C
#include <api-hal-light.h>
|
|
#include <stm32wbxx_ll_gpio.h>
|
|
|
|
// LCD backlight
|
|
#define BOOT_LCD_BL_PORT GPIOA
|
|
#define BOOT_LCD_BL_PIN LL_GPIO_PIN_15
|
|
// LEDs
|
|
#define LED_RED_PORT GPIOA
|
|
#define LED_RED_PIN LL_GPIO_PIN_1
|
|
#define LED_GREEN_PORT GPIOA
|
|
#define LED_GREEN_PIN LL_GPIO_PIN_2
|
|
#define LED_BLUE_PORT GPIOA
|
|
#define LED_BLUE_PIN LL_GPIO_PIN_3
|
|
|
|
static void api_hal_light_gpio_set(GPIO_TypeDef* port, uint32_t pin, uint8_t value) {
|
|
if (value) {
|
|
LL_GPIO_ResetOutputPin(port, pin);
|
|
} else {
|
|
LL_GPIO_SetOutputPin(port, pin);
|
|
}
|
|
}
|
|
|
|
void api_hal_light_init() {
|
|
LL_GPIO_SetPinMode(BOOT_LCD_BL_PORT, BOOT_LCD_BL_PIN, LL_GPIO_MODE_OUTPUT);
|
|
LL_GPIO_SetPinSpeed(BOOT_LCD_BL_PORT, BOOT_LCD_BL_PIN, LL_GPIO_SPEED_FREQ_LOW);
|
|
LL_GPIO_SetPinOutputType(BOOT_LCD_BL_PORT, BOOT_LCD_BL_PIN, LL_GPIO_OUTPUT_PUSHPULL);
|
|
|
|
LL_GPIO_SetPinMode(LED_RED_PORT, LED_RED_PIN, LL_GPIO_MODE_OUTPUT);
|
|
LL_GPIO_SetPinOutputType(LED_RED_PORT, LED_RED_PIN, LL_GPIO_OUTPUT_OPENDRAIN);
|
|
|
|
LL_GPIO_SetPinMode(LED_GREEN_PORT, LED_GREEN_PIN, LL_GPIO_MODE_OUTPUT);
|
|
LL_GPIO_SetPinOutputType(LED_GREEN_PORT, LED_GREEN_PIN, LL_GPIO_OUTPUT_OPENDRAIN);
|
|
|
|
LL_GPIO_SetPinMode(LED_BLUE_PORT, LED_BLUE_PIN, LL_GPIO_MODE_OUTPUT);
|
|
LL_GPIO_SetPinOutputType(LED_BLUE_PORT, LED_BLUE_PIN, LL_GPIO_OUTPUT_OPENDRAIN);
|
|
}
|
|
|
|
void api_hal_light_set(Light light, uint8_t value) {
|
|
switch(light) {
|
|
case LightRed:
|
|
api_hal_light_gpio_set(LED_RED_PORT, LED_RED_PIN, value);
|
|
break;
|
|
case LightGreen:
|
|
api_hal_light_gpio_set(LED_GREEN_PORT, LED_GREEN_PIN, value);
|
|
break;
|
|
case LightBlue:
|
|
api_hal_light_gpio_set(LED_BLUE_PORT, LED_BLUE_PIN, value);
|
|
break;
|
|
case LightBacklight:
|
|
api_hal_light_gpio_set(BOOT_LCD_BL_PORT, BOOT_LCD_BL_PIN, !value);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
} |