aboutsummaryrefslogtreecommitdiffstats
path: root/src/stm32f1/gpio.h
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@chown.ath.cx>2018-03-31 15:34:59 +0200
committerKevinOConnor <kevin@koconnor.net>2018-04-09 18:08:29 -0400
commit75d57372115eb70ac22d16240c5c887df8ae1da8 (patch)
treed31b31d32f80916c8406fc663994260a1acaa786 /src/stm32f1/gpio.h
parente097b085209e4737abc71dbb0fc06408a6e1f6d1 (diff)
downloadkutter-75d57372115eb70ac22d16240c5c887df8ae1da8.tar.gz
kutter-75d57372115eb70ac22d16240c5c887df8ae1da8.tar.xz
kutter-75d57372115eb70ac22d16240c5c887df8ae1da8.zip
Add STM32F103 port
Add a fully functional STM32F1 port, currently mostly targeting STM32F103 microcontrollers. This requires an 8 MHz XTAL. The maximum possible step rate is around 282K steps per second. This uses stm32flash to burn the firmware. The bootloader needs to be started by setting BOOT0 to 1 and resetting the MCU. There is no automatic bootloader, unlike on Arduino. Signed-off-by: Grigori Goronzy <greg@kinoho.net>
Diffstat (limited to 'src/stm32f1/gpio.h')
-rw-r--r--src/stm32f1/gpio.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/stm32f1/gpio.h b/src/stm32f1/gpio.h
new file mode 100644
index 00000000..b5a8621e
--- /dev/null
+++ b/src/stm32f1/gpio.h
@@ -0,0 +1,32 @@
+#ifndef __STM32F1_GPIO_H
+#define __STM32F1_GPIO_H
+
+#include <stdint.h>
+#include "stm32f1xx.h"
+
+void gpio_peripheral(char bank, uint32_t bit, char ptype, uint32_t pull_up);
+
+struct gpio_out {
+ GPIO_TypeDef *regs;
+ uint32_t bit;
+};
+struct gpio_out gpio_out_setup(uint8_t pin, uint8_t val);
+void gpio_out_toggle(struct gpio_out g);
+void gpio_out_write(struct gpio_out g, uint8_t val);
+
+struct gpio_in {
+ GPIO_TypeDef *regs;
+ uint32_t bit;
+};
+struct gpio_in gpio_in_setup(uint8_t pin, int8_t pull_up);
+uint8_t gpio_in_read(struct gpio_in g);
+
+struct gpio_adc {
+ uint32_t bit;
+};
+struct gpio_adc gpio_adc_setup(uint8_t pin);
+uint32_t gpio_adc_sample(struct gpio_adc g);
+uint16_t gpio_adc_read(struct gpio_adc g);
+void gpio_adc_cancel_sample(struct gpio_adc g);
+
+#endif // gpio.h