summaryrefslogtreecommitdiff
path: root/gpio
diff options
context:
space:
mode:
Diffstat (limited to 'gpio')
-rw-r--r--gpio/gpio.h2
-rw-r--r--gpio/pin.h11
2 files changed, 12 insertions, 1 deletions
diff --git a/gpio/gpio.h b/gpio/gpio.h
index ef7186f..725d4df 100644
--- a/gpio/gpio.h
+++ b/gpio/gpio.h
@@ -13,7 +13,7 @@ struct GPIO_t {
#elif defined(STM32F4)
volatile uint32_t MODER;
volatile uint32_t OTYPER;
- volatile uint32_t OSPEEDER;
+ volatile uint32_t OSPEEDR;
volatile uint32_t PUPDR;
volatile uint32_t IDR;
volatile uint32_t ODR;
diff --git a/gpio/pin.h b/gpio/pin.h
index 90026c3..aede480 100644
--- a/gpio/pin.h
+++ b/gpio/pin.h
@@ -36,6 +36,13 @@ class Pin {
PullDown,
};
+ enum Speed {
+ Low,
+ Medium,
+ Fast,
+ High,
+ };
+
void set_mode(Mode m) {
#if defined(STM32F1)
if(n < 8) {
@@ -78,6 +85,10 @@ class Pin {
#endif
}
+ void set_speed(Speed s) {
+ g.OSPEEDR = (g.OSPEEDR & ~(3 << (n * 2))) | s << (n * 2);
+ }
+
void on() {
g.BSRR = 1 << n;
}