added drivers

This commit is contained in:
2023-09-25 21:32:15 +02:00
parent 0d74fea761
commit 4829b04024
28 changed files with 6621 additions and 3 deletions

19
app/drivers/led/led.c Normal file
View File

@@ -0,0 +1,19 @@
#include "led.h"
void led_init(led_handle_t *hled, GPIO_TypeDef *port, uint16_t pin)
{
hled->port = port;
hled->pin = pin;
HAL_GPIO_WritePin(port, pin, GPIO_PIN_SET);
}
void led_on(led_handle_t *hled)
{
HAL_GPIO_WritePin(hled->port, hled->pin, GPIO_PIN_RESET);
}
void led_off(led_handle_t *hled)
{
HAL_GPIO_WritePin(hled->port, hled->pin, GPIO_PIN_SET);
}

13
app/drivers/led/led.h Normal file
View File

@@ -0,0 +1,13 @@
#pragma once
#include "gpio.h"
typedef struct
{
GPIO_TypeDef *port;
uint16_t pin;
} led_handle_t;
void led_init(led_handle_t *hled, GPIO_TypeDef *port, uint16_t pin);
void led_on(led_handle_t *hled);
void led_off(led_handle_t *hled);