summaryrefslogtreecommitdiff
path: root/gpio
diff options
context:
space:
mode:
Diffstat (limited to 'gpio')
-rw-r--r--gpio/gpio.h9
-rw-r--r--gpio/pin.h12
2 files changed, 14 insertions, 7 deletions
diff --git a/gpio/gpio.h b/gpio/gpio.h
index 9a693df..b7dd163 100644
--- a/gpio/gpio.h
+++ b/gpio/gpio.h
@@ -12,7 +12,7 @@ struct GPIO_reg_t {
volatile uint32_t BSRR;
volatile uint32_t BRR;
volatile uint32_t LCKR;
- #elif defined(STM32F4)
+ #elif defined(STM32F3) || defined(STM32F4)
volatile uint32_t MODER;
volatile uint32_t OTYPER;
volatile uint32_t OSPEEDR;
@@ -38,6 +38,13 @@ static GPIO_t GPIOA(0x40010800);
static GPIO_t GPIOB(0x40010c00);
static GPIO_t GPIOC(0x40011000);
static GPIO_t GPIOD(0x40011400);
+#elif defined(STM32F3)
+static GPIO_t GPIOA(0x48000000);
+static GPIO_t GPIOB(0x48000400);
+static GPIO_t GPIOC(0x48000800);
+static GPIO_t GPIOD(0x48000c00);
+static GPIO_t GPIOE(0x48001000);
+static GPIO_t GPIOF(0x48001400);
#elif defined(STM32F4)
static GPIO_t GPIOA(0x40020000);
static GPIO_t GPIOB(0x40020400);
diff --git a/gpio/pin.h b/gpio/pin.h
index 485cb33..d8089d3 100644
--- a/gpio/pin.h
+++ b/gpio/pin.h
@@ -17,7 +17,7 @@ class Pin {
Output = 0x3,
AF = 0xb,
Analog = 0x0,
- #elif defined(STM32F4)
+ #elif defined(STM32F3) || defined(STM32F4)
Input,
Output,
AF,
@@ -50,7 +50,7 @@ class Pin {
} else {
g.reg.CRH = (g.reg.CRH & ~(0xf << (n * 4 - 32))) | m << (n * 4 - 32);
}
- #elif defined(STM32F4)
+ #elif defined(STM32F3) || defined(STM32F4)
g.reg.MODER = (g.reg.MODER & ~(3 << (n * 2))) | m << (n * 2);
#endif
}
@@ -58,7 +58,7 @@ class Pin {
void set_type(Type t) {
#if defined(STM32F1)
// TODO: Unified configure() method?
- #elif defined(STM32F4)
+ #elif defined(STM32F3) || defined(STM32F4)
if(t) {
g.reg.OTYPER |= 1 << n;
} else {
@@ -70,13 +70,13 @@ class Pin {
void set_pull(Pull p) {
#if defined(STM32F1)
// TODO: Unified configure() method?
- #elif defined(STM32F4)
+ #elif defined(STM32F3) || defined(STM32F4)
g.reg.PUPDR = (g.reg.PUPDR & ~(3 << (n * 2))) | p << (n * 2);
#endif
}
void set_af(int af) {
- #if defined(STM32F4)
+ #if defined(STM32F3) || defined(STM32F4)
if(n < 8) {
g.reg.AFRL = (g.reg.AFRL & ~(0xf << (n * 4))) | af << (n * 4);
} else {
@@ -86,7 +86,7 @@ class Pin {
}
void set_speed(Speed s) {
- #if defined(STM32F4)
+ #if defined(STM32F3) || defined(STM32F4)
g.reg.OSPEEDR = (g.reg.OSPEEDR & ~(3 << (n * 2))) | s << (n * 2);
#endif
}