From 653b809a0ff852c5f5184fd46a5364dd16ac2133 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sun, 22 Jan 2012 10:53:16 +0100 Subject: Added Pin::set_pull(). --- hal/pin.h | 10 ++++++++++ 1 file changed, 10 insertions(+) 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); -- cgit v1.2.3