diff --git a/src/main.c b/src/main.c index e86517e..7e1333a 100644 --- a/src/main.c +++ b/src/main.c @@ -11,6 +11,11 @@ #include #include +//These are only included during development for the LSP server. +#include "iotn13.h" +// #include "iotn13a.h" + + // ############################# // Globals // ############################# @@ -31,7 +36,7 @@ volatile uint16_t tick_count; // Prototypes // ############################# - +static inline void InitTimer0(void); static void InitBtn(btn_state *b, uint8_t input_pin, uint8_t output_pin); static void ToggleOutput(btn_state *b); static void ClearButtonTimer(btn_state *b); @@ -52,10 +57,8 @@ int main(int argc, char **argv) { while (1) { fader_pos = ReadADC() >> 2; - /* UpdateButtonOutput(&btn1); UpdateButtonInput(&btn1); - */ } /* @@ -92,7 +95,7 @@ void InitProg(void) { /*Set the debounced state to all high*/ debounced_state = 0xFF; - init_btn(&btn1, PIN_SW1, PIN_ACTIVE1); + InitBtn(&btn1, BUTTON_PIN, PIN_ACTIVE1); /*Wait 5ms for pull-up resistors voltage to become stable.*/ _delay_ms(5); @@ -116,15 +119,14 @@ void InitProg(void) { InitTimer0(); } -uint16_t ReadADC(void); -{ +uint16_t ReadADC(void) { // Initialize ADC ADMUX = (1 << MUX1) | (1 << MUX0); // Select ADC3 (PB3) ADCSRA = (1 << ADEN) | (1 << ADPS1) | (1 << ADPS0); // Enable ADC, prescaler 8 ADCSRA |= (1 << ADSC); // Start conversion - while (ADCSRA & (1 << ADSC)) - ; // Wait for conversion to finish + while (ADCSRA & (1 << ADSC)) { + } // Wait for conversion to finish return ADC; } @@ -148,7 +150,7 @@ void MotorCoast(void) { static void InitBtn(btn_state *b, uint8_t input_pin, uint8_t output_pin) { b->is_long_pressed = 0; b->is_pressed = 0; - b->is_bypassed = 0; + b->is_active = 0; b->pressed_ticks = 0; b->timer_enabled = 0; b->input_pin = input_pin; @@ -164,11 +166,11 @@ static void InitBtn(btn_state *b, uint8_t input_pin, uint8_t output_pin) { /*This is the fancy function to toggle output pins*/ static void ToggleOutput(btn_state *b) { - if (!b->is_bypassed) { - b->is_bypassed = 1; + if (!b->is_active) { + b->is_active = 1; PORTB |= (1 << b->output_pin); } else { - b->is_bypassed = 0; + b->is_active = 0; PORTB &= ~(1 << b->output_pin); } } @@ -267,7 +269,7 @@ static inline void DebounceSwitch() { } /*Setup the timer0 on the AVR*/ -static inline void InitTimer0() { +static inline void InitTimer0(void) { /*Zero out the tick_count var*/ tick_count = 0;