summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hal/pin.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/hal/pin.h b/hal/pin.h
index 4102e6a..e2b0a62 100644
--- a/hal/pin.h
+++ b/hal/pin.h
@@ -23,6 +23,12 @@ class Pin {
OpenDrain,
};
+ enum Pull {
+ PullNone,
+ PullUp,
+ PullDown,
+ };
+
void set_mode(Mode m) {
g.MODER = (g.MODER & ~(3 << (n * 2))) | m << (n * 2);
}
@@ -35,6 +41,10 @@ class Pin {
}
}
+ void set_pull(Pull p) {
+ g.PUPDR = (g.PUPDR & ~(3 << (n * 2))) | p << (n * 2);
+ }
+
void set_af(int af) {
if(n < 8) {
g.AFRL = (g.AFRL & ~(0xf << (n * 4))) | af << (n * 4);