mirror of
https://github.com/clockworkpi/PicoCalc.git
synced 2025-12-12 18:28:53 +01:00
Merge pull request #25 from shtirlic/i2creadfirst
Fix i2c slave scl freeze if read address first recieved
This commit is contained in:
commit
6b8553e04c
@ -36,7 +36,7 @@ void set_pmu_flag(void) { pmu_flag = true; }
|
|||||||
|
|
||||||
HardwareSerial Serial1(PA10, PA9);
|
HardwareSerial Serial1(PA10, PA9);
|
||||||
|
|
||||||
uint8_t write_buffer[10];
|
uint8_t write_buffer[10] = {0};
|
||||||
uint8_t write_buffer_len = 0;
|
uint8_t write_buffer_len = 0;
|
||||||
|
|
||||||
uint8_t io_matrix[9];//for IO matrix,last bytye is the restore key(c64 only)
|
uint8_t io_matrix[9];//for IO matrix,last bytye is the restore key(c64 only)
|
||||||
@ -180,7 +180,13 @@ void receiveEvent(int howMany) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-this is after receiveEvent-------------------------------
|
//-this is after receiveEvent-------------------------------
|
||||||
void requestEvent() { Wire.write(write_buffer,write_buffer_len ); }
|
void requestEvent() {
|
||||||
|
if (write_buffer_len > 0 && write_buffer_len <= sizeof(write_buffer)) {
|
||||||
|
Wire.write(write_buffer,write_buffer_len );
|
||||||
|
} else {
|
||||||
|
Wire.write((uint8_t)0); // Send something minimal to avoid stalling
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void report_bat(){
|
void report_bat(){
|
||||||
if (PMU.isBatteryConnect()) {
|
if (PMU.isBatteryConnect()) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user