Api hw gpio pwm (#199)

* initial gpio layer

* move temlplate.c to template.c.example in preparing to applications.mk rework

* separate arduino layer

* separate flipper_hal.x

* prepare to switch applications on v2 core gpio api

* swithch applications to v2 gpio api

* gpio api for local target

* better gpio_disable handling

* remove pwm functions from local target

* inline gpio funcs

* common function to init all api's

* fix local example blink

* move delay us to hal api folder

* move pwm_set/pwm_stop to hal api folder

* update applications to use hal pwm api

* remove gpio mode case warning

* add speaker demo to build

Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
This commit is contained in:
coreglitch
2020-10-26 13:16:54 +06:00
committed by GitHub
parent c8cc3c7dc8
commit f5b342abbe
41 changed files with 464 additions and 341 deletions

View File

@@ -8,41 +8,6 @@ GPIO and HAL implementations
#include "flipper_hal.h"
#include <stdio.h>
void app_gpio_init(GpioPin gpio, GpioMode mode) {
if(gpio.pin != 0) {
switch(mode) {
case GpioModeInput:
printf("[GPIO] %s%d input\n", gpio.port, gpio.pin);
break;
case GpioModeOutput:
printf("[GPIO] %s%d push pull\n", gpio.port, gpio.pin);
break;
case GpioModeOpenDrain:
printf("[GPIO] %s%d open drain\n", gpio.port, gpio.pin);
break;
}
gpio.mode = mode;
} else {
printf("[GPIO] no pin\n");
}
}
void delay_us(uint32_t time) {
// How to deal with it
printf("[DELAY] %d us\n", time);
}
void pwm_set(float value, float freq, TIM_HandleTypeDef* tim, uint32_t channel) {
printf("[TIM] set pwm %d:%d %f Hz, %f%%\n", *tim, channel, freq, value * 100.);
}
void HAL_GPIO_WritePin(const char* port, uint32_t pin, HAL_GPIO_PIN_STATE state) {
printf("[GPIO] set pin %s:%d = %d\n", port, pin, state);
}
HAL_StatusTypeDef
HAL_SPI_Transmit(SPI_HandleTypeDef* hspi, uint8_t* pData, uint16_t size, uint32_t Timeout) {
printf("[SPI] write %d to %s: ", size, *hspi);