# HG changeset patch # User Malte Bayer # Date 1321303080 -3600 # Node ID 1a0ef40ef458910d4553f429fa1e12fab999d26e # Parent 6c59b4293fa9bc9a11716ee685423e75719cb46a fixed track change keys diff -r 6c59b4293fa9 -r 1a0ef40ef458 blackbox/lowlevel.c --- a/blackbox/lowlevel.c Mon Nov 14 21:15:11 2011 +0100 +++ b/blackbox/lowlevel.c Mon Nov 14 21:38:00 2011 +0100 @@ -3,7 +3,9 @@ #include #include "stdint.h" #include "main.h" +#include "driver/adc.h" #include "driver/rs232.h" +#include "lowlevel.h" void LED(uint8_t num, uint8_t state) { switch (num) { @@ -39,6 +41,64 @@ } } +void init_hardware(void) { + RS232_init(); // initialize RS485 interface + RS232_puts_p(PSTR("CARRERA beta loading\n")); + + initADC(); + + // set LED output + DDR(LED1_PORT) |= _BV(LED1); + DDR(LED2_PORT) |= _BV(LED2); + DDR(LED3_PORT) |= _BV(LED3); + DDR(LED4_PORT) |= _BV(LED4); + DDR(LED5_PORT) |= _BV(LED5); + + // set Controller Input Pull-UPs + CONTROLLER_PORT |= (_BV(CONTROLLER1_SW) | _BV(CONTROLLER2_SW) | _BV(CONTROLLER3_SW) | _BV(CONTROLLER4_SW)); + + // switch pull-ups + SW_FUEL_PORT |= _BV(SW_FUEL); + + //RAIL_DETECT_PORT |= _BV(RAIL_DETECT); // enable internal pull-up + DDR(RAIL_POWER_PORT) |= _BV(RAIL_POWER); + + + LED(1, 1); _delay_ms(50); + LED(2, 1); _delay_ms(50); + LED(3, 1); _delay_ms(50); + LED(4, 1); _delay_ms(50); + LED(5, 1); _delay_ms(50); + LED(1, 0); _delay_ms(50); + LED(2, 0); _delay_ms(50); + LED(3, 0); _delay_ms(50); + LED(4, 0); _delay_ms(50); + LED(5, 0); _delay_ms(50); + + //TCCR0 = (1<