summaryrefslogtreecommitdiff
path: root/hal
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2012-01-22 10:53:16 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2012-01-22 10:53:16 +0100
commit653b809a0ff852c5f5184fd46a5364dd16ac2133 (patch)
tree8045c25f47c4141923fe211def08132184878b82 /hal
parent005e0ba51aafb6b26383fbd7df9000399c79098d (diff)
Added Pin::set_pull().
Diffstat (limited to 'hal')
-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);