Lots of refactoring

This commit is contained in:
2025-06-11 10:55:00 -05:00
parent a437bcf8b5
commit aaa7f0dc29
35 changed files with 1165 additions and 809 deletions

45
source/io.c Normal file
View File

@@ -0,0 +1,45 @@
#include "io.h"
#include "spi.h"
#define EXPANDER_SIZE 3
static uint8_t _expanderState[EXPANDER_SIZE]; // copy of Shift register I/O expander
//Port_State[BOTTOM_SR] |= TAP2_LF_ON;
void io_expanderSet(uint8_t port, uint8_t pins, bool update)
{
_expanderState[port] |= pins;
if (update)
{
io_update();
}
}
void io_expanderClear(uint8_t port, uint8_t pins, bool update)
{
_expanderState[port] &= ~pins;
if (update)
{
io_update();
}
}
// update I/O expander
void io_update(void)
{
SPI0_SendBytes(_expanderState, EXPANDER_SIZE, EXPANDER);
}
void io_expanderSetSafe(void)
{
_expanderState[BOT_SR] = 0;
_expanderState[MID_SR] = 0;
_expanderState[TOP_SR] = 0;
io_update();
}