You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
693 B
31 lines
693 B
#include "spi_proto.h"
|
|
|
|
uint8_t spi_proto_needswrite(uint8_t opcode) {
|
|
if(opcode == 4 || opcode == 5) return 1;
|
|
return 0;
|
|
}
|
|
|
|
uint16_t spi_proto_handlewrite(uint8_t opcode, uint8_t addr) {
|
|
if(opcode == 4) {
|
|
return (uint16_t) (*spi_proto_globals8[addr]);
|
|
} else if(opcode == 5) {
|
|
return (*spi_proto_globals16[addr]);
|
|
} else {
|
|
return 0xFFFF;
|
|
}
|
|
|
|
}
|
|
|
|
void spi_proto_handleread(uint8_t opcode, uint8_t addr, uint16_t data) {
|
|
if(opcode == 2) {
|
|
*spi_proto_globals8[addr] = (uint8_t) data;
|
|
} else if(opcode == 3) {
|
|
*spi_proto_globals16[addr] = data;
|
|
} else if (opcode == 6) {
|
|
funptr_t func = spi_proto_funcs[addr];
|
|
(*func)();
|
|
} else {
|
|
// boom
|
|
}
|
|
}
|