Lots of refactoring
This commit is contained in:
45
source/io.c
Normal file
45
source/io.c
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user