|
|
|
|
@ -23,9 +23,13 @@ uint16_t spi_master_communicate(uint8_t opcode, uint8_t addr, uint16_t value)
|
|
|
|
|
write_data[1] = addr;
|
|
|
|
|
write_data[2] = value >> 8;
|
|
|
|
|
write_data[3] = value & 0xff;
|
|
|
|
|
spi_mst_start_packet();
|
|
|
|
|
spi_mst_write_read(4,write_data);
|
|
|
|
|
spi_mst_end_packet();
|
|
|
|
|
while(write_data[0] == 0){
|
|
|
|
|
spi_mst_start_packet();
|
|
|
|
|
spi_mst_write_read(4,write_data);
|
|
|
|
|
spi_mst_end_packet();
|
|
|
|
|
}
|
|
|
|
|
return (write_data[2] << 8) | read_data[3];
|
|
|
|
|
}
|
|
|
|
|
@ -89,8 +93,8 @@ void call_func(uint8_t number)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t spi_proto_needswrite(uint8_t opcode) {
|
|
|
|
|
if(opcode == 4 || opcode == 5) return 1;
|
|
|
|
|
return 0;
|
|
|
|
|
if(opcode == 4 || opcode == 5) return 0;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint16_t spi_proto_handlewrite(uint8_t opcode, uint8_t addr) {
|
|
|
|
|
@ -99,7 +103,7 @@ uint16_t spi_proto_handlewrite(uint8_t opcode, uint8_t addr) {
|
|
|
|
|
} else if(opcode == 5) {
|
|
|
|
|
return (*spi_proto_globals16[addr]);
|
|
|
|
|
} else {
|
|
|
|
|
return 0xFFFF;
|
|
|
|
|
return 0xFeFe;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|