summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2012-03-25 01:35:06 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2012-03-25 01:35:06 +0100
commitcda233164f4f1a658e7ca595555b9b7edd05c33c (patch)
tree5e984f386579d2f2170084a08d9a8cd60bf85352
parent27800e7bfd8b01c7a1480333588c040ece6c4859 (diff)
Added Pin::set() and Pin::get().
-rw-r--r--hal/pin.h39
1 files changed, 35 insertions, 4 deletions
diff --git a/hal/pin.h b/hal/pin.h
index e2b0a62..1ad3ca2 100644
--- a/hal/pin.h
+++ b/hal/pin.h
@@ -61,13 +61,21 @@ class Pin {
g.BSRR = 1 << 16 << n;
}
- void toggle() {
- if(g.ODR & (1 << n)) {
- off();
- } else {
+ void set(bool value) {
+ if(value) {
on();
+ } else {
+ off();
}
}
+
+ bool get() {
+ return g.IDR & (1 << n);
+ }
+
+ void toggle() {
+ set(!(g.ODR & (1 << n)));
+ }
};
static Pin PA0(GPIOA, 0);
@@ -97,6 +105,29 @@ static Pin PB6(GPIOB, 6);
static Pin PB7(GPIOB, 7);
static Pin PB8(GPIOB, 8);
static Pin PB9(GPIOB, 9);
+static Pin PB10(GPIOB, 10);
+static Pin PB11(GPIOB, 11);
+static Pin PB12(GPIOB, 12);
+static Pin PB13(GPIOB, 13);
+static Pin PB14(GPIOB, 14);
+static Pin PB15(GPIOB, 15);
+
+static Pin PC0(GPIOC, 0);
+static Pin PC1(GPIOC, 1);
+static Pin PC2(GPIOC, 2);
+static Pin PC3(GPIOC, 3);
+static Pin PC4(GPIOC, 4);
+static Pin PC5(GPIOC, 5);
+static Pin PC6(GPIOC, 6);
+static Pin PC7(GPIOC, 7);
+static Pin PC8(GPIOC, 8);
+static Pin PC9(GPIOC, 9);
+static Pin PC10(GPIOC, 10);
+static Pin PC11(GPIOC, 11);
+static Pin PC12(GPIOC, 12);
+static Pin PC13(GPIOC, 13);
+static Pin PC14(GPIOC, 14);
+static Pin PC15(GPIOC, 15);
static Pin PD12(GPIOD, 12);
static Pin PD13(GPIOD, 13);