From c3d8f5876d6c1016e60a6a1dd33272dc8950163f Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sun, 4 Dec 2011 02:04:14 +0100 Subject: Fixed Pin class. --- main.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'main.cpp') 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 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); -- cgit v1.2.3