45 lines
753 B
C
45 lines
753 B
C
#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();
|
|
} |