diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2012-10-09 18:44:46 +0200 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2012-10-09 18:44:46 +0200 |
commit | 66344e89ed16f06546ef3a5480d416a6d24c53b8 (patch) | |
tree | b6754783d0489947353e810d24b222e46e7f0744 | |
parent | fca86554077f380c639409331c10a3dd4680d8a9 (diff) |
Add GPIO speed setting.
-rw-r--r-- | gpio/gpio.h | 2 | ||||
-rw-r--r-- | gpio/pin.h | 11 |
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; @@ -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; } |