fix multithread logic in template app, update gpio HAL (#250)
* fix multithread logic * more buffer for dallas id string * update apps to use new logic * delay_us small speedup * add consant qualifier to gpio records and some core api * fix some apps to use simpler method of getting gpio record * fix ibutton app, stupid stack problem
This commit is contained in:
@@ -2,7 +2,11 @@
|
||||
#include <stdio.h>
|
||||
|
||||
// init GPIO
|
||||
void hal_gpio_init(GpioPin* gpio, GpioMode mode, GpioPull pull, GpioSpeed speed){
|
||||
void hal_gpio_init(
|
||||
const GpioPin* gpio,
|
||||
const GpioMode mode,
|
||||
const GpioPull pull,
|
||||
const GpioSpeed speed) {
|
||||
// TODO more mode
|
||||
if(gpio->pin != 0) {
|
||||
switch(mode) {
|
||||
@@ -17,7 +21,7 @@ void hal_gpio_init(GpioPin* gpio, GpioMode mode, GpioPull pull, GpioSpeed speed)
|
||||
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;
|
||||
@@ -28,7 +32,7 @@ void hal_gpio_init(GpioPin* gpio, GpioMode mode, GpioPull pull, GpioSpeed speed)
|
||||
}
|
||||
|
||||
// write value to GPIO, false = LOW, true = HIGH
|
||||
void hal_gpio_write(GpioPin* gpio, bool state){
|
||||
void hal_gpio_write(const GpioPin* gpio, const bool state) {
|
||||
if(gpio->pin != 0) {
|
||||
if(state) {
|
||||
printf("[GPIO] %s%d on\n", gpio->port, gpio->pin);
|
||||
@@ -41,7 +45,7 @@ void hal_gpio_write(GpioPin* gpio, bool state){
|
||||
}
|
||||
|
||||
// read value from GPIO, false = LOW, true = HIGH
|
||||
bool hal_gpio_read(const GpioPin* gpio){
|
||||
bool hal_gpio_read(const GpioPin* gpio) {
|
||||
// TODO emulate pin state?
|
||||
return false;
|
||||
}
|
||||
|
@@ -40,10 +40,14 @@ typedef struct {
|
||||
} GpioPin;
|
||||
|
||||
// init GPIO
|
||||
void hal_gpio_init(GpioPin* gpio, GpioMode mode, GpioPull pull, GpioSpeed speed);
|
||||
void hal_gpio_init(
|
||||
const GpioPin* gpio,
|
||||
const GpioMode mode,
|
||||
const GpioPull pull,
|
||||
const GpioSpeed speed);
|
||||
|
||||
// write value to GPIO, false = LOW, true = HIGH
|
||||
void hal_gpio_write(GpioPin* gpio, bool state);
|
||||
void hal_gpio_write(const GpioPin* gpio, const bool state);
|
||||
|
||||
// read value from GPIO, false = LOW, true = HIGH
|
||||
bool hal_gpio_read(const GpioPin* gpio);
|
Reference in New Issue
Block a user