summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2011-12-04 02:04:14 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2011-12-04 02:04:14 +0100
commitc3d8f5876d6c1016e60a6a1dd33272dc8950163f (patch)
treed77c309ee50fb6ab14e63d2ccb1d419d6b0fad6e /main.cpp
parenta3bce929687e476af5dc7e2e757617b8cb27c627 (diff)
Fixed Pin class.
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/main.cpp b/main.cpp
index fa4d1a8..e34d90e 100644
--- a/main.cpp
+++ b/main.cpp
@@ -13,6 +13,8 @@
#include "xbee.h"
#include "gps.h"
+#include "pin.h"
+
template<class T>
inline void saturate(T& var, T absmax) {
if(var > absmax) {
@@ -80,24 +82,32 @@ uint32_t gps_stack[256];
Thread gps_thread(gps_stack, sizeof(gps_stack), gps_thread_main);
+static Pin& led_green = PD12;
+static Pin& led_yellow = PD13;
+static Pin& led_red = PD14;
+static Pin& led_blue = PD15;
+
int main() {
// Initialize system timer.
STK.LOAD = 168000000 / 8 / 1000; // 1000 Hz.
STK.CTRL = 0x03;
- RCC.enable(RCC.AFIO);
- RCC.enable(RCC.IOPA);
- RCC.enable(RCC.IOPB);
+ RCC.enable(RCC.GPIOA);
+ RCC.enable(RCC.GPIOB);
+ RCC.enable(RCC.GPIOD);
- GPIOA.CRL = 0x4400bbbb;
- GPIOA.CRH = 0x444444b4;
+ led_green.set_mode(Pin::Output);
+ led_yellow.set_mode(Pin::Output);
+ led_red.set_mode(Pin::Output);
+ led_blue.set_mode(Pin::Output);
- GPIOB.CRL = 0xff444434;
- GPIOB.CRH = 0x44444444;
- GPIOB.ODR = 1 << 1;
RCC.enable(RCC.DMA1);
RCC.enable(RCC.ADC1);
+ PB6.set_af(7);
+ PB7.set_af(7);
+ PB6.set_mode(Pin::Output);
+ PB7.set_mode(Pin::Output);
// Give all hardware enough time to initialize.
Time::sleep(200);