fixed function names.

This commit is contained in:
Jake Goodwin 2025-02-12 11:31:48 -08:00
parent 6146e986b5
commit 792596377a
1 changed files with 15 additions and 13 deletions

View File

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