flipperzero-firmware/firmware/targets/local/api-hal/api-hal-gpio.c
DrZlo13 979af6c165
Core code cleanup (#206)
* add delay function
* todo about delay_isr
* remove arduino defines and fix all apps to use core-api/hal-api
* delay for local target
* remove warnings of task_equal
* fix BSP_SD_Init
* fix USBD_static
* grio read constant pointer to gpio
* add TODO about ISR context
* const void* arg for pubsub api
* mark unused functions
* app pointers now pointed to constant apps
* fix printf format
* fix "unused" warnings in local target
* fix const pin read in local target
* fix int to pointer warnings in local target
* power read mutex error fix
* delete old makefile
* add -werror

Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
Co-authored-by: aanper <mail@s3f.ru>
2020-10-29 10:58:19 +03:00

48 lines
1.2 KiB
C

#include "api-hal-gpio.h"
#include <stdio.h>
// init GPIO
void hal_gpio_init(GpioPin* gpio, GpioMode mode, GpioPull pull, GpioSpeed speed){
// TODO more mode
if(gpio->pin != 0) {
switch(mode) {
case GpioModeInput:
printf("[GPIO] %s%d input\n", gpio->port, gpio->pin);
break;
case GpioModeOutputPushPull:
printf("[GPIO] %s%d push pull\n", gpio->port, gpio->pin);
break;
case GpioModeOutputOpenDrain:
printf("[GPIO] %s%d open drain\n", gpio->port, gpio->pin);
break;
default:
printf("[GPIO] %s%d mode %d unsupported\n", gpio->port, gpio->pin, mode);
break;
}
} else {
printf("[GPIO] no pin\n");
}
}
// write value to GPIO, false = LOW, true = HIGH
void hal_gpio_write(GpioPin* gpio, bool state){
if(gpio->pin != 0) {
if(state) {
printf("[GPIO] %s%d on\n", gpio->port, gpio->pin);
} else {
printf("[GPIO] %s%d off\n", gpio->port, gpio->pin);
}
} else {
printf("[GPIO] no pin\n");
}
}
// read value from GPIO, false = LOW, true = HIGH
bool hal_gpio_read(const GpioPin* gpio){
// TODO emulate pin state?
return false;
}