2016-06-05 22:11:35 +03:00
|
|
|
#ifndef __GENERIC_GPIO_H
|
|
|
|
#define __GENERIC_GPIO_H
|
2016-05-25 18:37:40 +03:00
|
|
|
|
2017-08-27 20:58:19 +03:00
|
|
|
#include <stdint.h> // uint8_t
|
2016-05-25 18:37:40 +03:00
|
|
|
|
|
|
|
struct gpio_out {
|
|
|
|
uint8_t pin;
|
|
|
|
};
|
|
|
|
struct gpio_out gpio_out_setup(uint8_t pin, uint8_t val);
|
2018-08-21 00:06:41 +03:00
|
|
|
void gpio_out_reset(struct gpio_out g, uint8_t val);
|
2018-05-16 00:04:30 +03:00
|
|
|
void gpio_out_toggle_noirq(struct gpio_out g);
|
2016-05-25 18:37:40 +03:00
|
|
|
void gpio_out_toggle(struct gpio_out g);
|
|
|
|
void gpio_out_write(struct gpio_out g, uint8_t val);
|
|
|
|
|
|
|
|
struct gpio_in {
|
|
|
|
uint8_t pin;
|
|
|
|
};
|
|
|
|
struct gpio_in gpio_in_setup(uint8_t pin, int8_t pull_up);
|
2018-08-21 00:06:41 +03:00
|
|
|
void gpio_in_reset(struct gpio_in g, int8_t pull_up);
|
2016-05-25 18:37:40 +03:00
|
|
|
uint8_t gpio_in_read(struct gpio_in g);
|
|
|
|
|
|
|
|
struct gpio_pwm {
|
|
|
|
uint8_t pin;
|
|
|
|
};
|
|
|
|
struct gpio_pwm gpio_pwm_setup(uint8_t pin, uint32_t cycle_time, uint8_t val);
|
|
|
|
void gpio_pwm_write(struct gpio_pwm g, uint8_t val);
|
|
|
|
|
|
|
|
struct gpio_adc {
|
|
|
|
uint8_t pin;
|
|
|
|
};
|
|
|
|
struct gpio_adc gpio_adc_setup(uint8_t pin);
|
2016-11-03 00:30:34 +03:00
|
|
|
uint32_t gpio_adc_sample(struct gpio_adc g);
|
2016-05-25 18:37:40 +03:00
|
|
|
uint16_t gpio_adc_read(struct gpio_adc g);
|
2016-11-03 00:30:34 +03:00
|
|
|
void gpio_adc_cancel_sample(struct gpio_adc g);
|
2016-05-25 18:37:40 +03:00
|
|
|
|
2018-05-04 19:27:52 +03:00
|
|
|
struct spi_config {
|
|
|
|
uint32_t cfg;
|
|
|
|
};
|
|
|
|
struct spi_config spi_setup(uint32_t bus, uint8_t mode, uint32_t rate);
|
2018-07-08 01:03:00 +03:00
|
|
|
void spi_prepare(struct spi_config config);
|
2018-05-04 19:27:52 +03:00
|
|
|
void spi_transfer(struct spi_config config, uint8_t receive_data
|
|
|
|
, uint8_t len, uint8_t *data);
|
2016-05-25 18:37:40 +03:00
|
|
|
|
|
|
|
#endif // gpio.h
|