Updated submodules

This commit is contained in:
Terje 2021-03-10 10:50:59 +01:00
parent 85afe339fd
commit 27714698b2
11 changed files with 36 additions and 19 deletions

@ -1 +1 @@
Subproject commit 292df8b7cc2a7d9df7a647483eef6ba8c68c250d Subproject commit 4b6eb7b971db033136af2835e3949d2ff6b32da5

@ -1 +1 @@
Subproject commit 8ee8eea4e4974ae54787b01aa4a17fa744580246 Subproject commit 5261a606d1a653d5f571a8f6d1a05eb78c066707

@ -1 +1 @@
Subproject commit 7dab08e2947afccd2c5431c91235f8d36d313310 Subproject commit 60d89338fd81a95be030eee127ba0df5c83b9a88

View File

@ -94,7 +94,7 @@ static const i2c_hardware_t i2c4_hardware = {
} }
}; };
static bool force_clock (i2c_hardware_t *hardware) static bool force_clock (const i2c_hardware_t *hardware)
{ {
bool ret = false; bool ret = false;
uint32_t sda_pin = hardware->sda_pin.pin; uint32_t sda_pin = hardware->sda_pin.pin;
@ -127,7 +127,7 @@ static bool force_clock (i2c_hardware_t *hardware)
return ret; return ret;
} }
static void setClock (IMXRT_LPI2C_t *port, uint32_t frequency) static void set_clock (IMXRT_LPI2C_t *port, uint32_t frequency)
{ {
port->MCR = 0; port->MCR = 0;
@ -219,7 +219,7 @@ void i2c_init (void)
*hardware->clock_gate_register |= hardware->clock_gate_mask; *hardware->clock_gate_register |= hardware->clock_gate_mask;
port->MCR = LPI2C_MCR_RST; port->MCR = LPI2C_MCR_RST;
setClock(port, 100000); set_clock(port, 100000);
// Setup SDA register // Setup SDA register
*(portControlRegister(hardware->sda_pin.pin)) = PINCONFIG; *(portControlRegister(hardware->sda_pin.pin)) = PINCONFIG;
@ -238,6 +238,22 @@ void i2c_init (void)
} }
} }
// wait until ready for transfer, try peripheral reset if bus hangs
inline static bool wait_ready (void)
{
while(i2cIsBusy) {
if(port->MSR & LPI2C_MSR_PLTF) {
if(force_clock(hardware)) {
port->MCR = LPI2C_MCR_RST;
set_clock(port, 100000);
} else
return false;
}
}
return true;
}
// get bytes (max 8 if local buffer, else max 255), waits for result // get bytes (max 8 if local buffer, else max 255), waits for result
uint8_t *I2C_Receive (uint32_t i2cAddr, uint8_t *buf, uint16_t bytes, bool block) uint8_t *I2C_Receive (uint32_t i2cAddr, uint8_t *buf, uint16_t bytes, bool block)
{ {
@ -338,11 +354,10 @@ nvs_transfer_result_t i2c_nvs_transfer (nvs_transfer_t *transfer, bool read)
void I2C_GetKeycode (uint32_t i2cAddr, keycode_callback_ptr callback) void I2C_GetKeycode (uint32_t i2cAddr, keycode_callback_ptr callback)
{ {
while(i2cIsBusy); if(wait_ready()) {
i2c.keycode_callback = callback;
i2c.keycode_callback = callback; I2C_Receive(i2cAddr, NULL, 1, false);
}
I2C_Receive(i2cAddr, NULL, 1, false);
} }
#endif #endif
@ -504,7 +519,9 @@ hal.stream.write(ASCII_EOL);
} }
#endif #endif
break; break;
default: break;
default:
break;
} }
} }

@ -1 +1 @@
Subproject commit 0ae3a110b6064596022aa978a5d0a1f14abaa0d7 Subproject commit 639ac771ebdf6163300ea111be5725958be7076b

@ -1 +1 @@
Subproject commit 942f5607ba4d6428d8a2f5b690e251d80d462c61 Subproject commit 6ececce9e0aa6da9a1ce1fc8cc1861b81b9ff705

@ -1 +1 @@
Subproject commit 3652e142c228c7a168cfa929497f570d541511f5 Subproject commit 4ffa4a9826d557d260faa6d7023e196eeeb62c6e

@ -1 +1 @@
Subproject commit 3ba87d7450bb6c4f4ded4cce96a0c71cffc48fa5 Subproject commit 66d77893856e9e12fd6dfa2f5293716a4eb21a80

@ -1 +1 @@
Subproject commit b6240a9f9d88b7ef8ac368474589495cf2f43d24 Subproject commit 48c2de6609d400c8f817e3512c8c29ddbaa4fa9c

@ -1 +1 @@
Subproject commit 1f5a0df4e0a58480ab7c4e80f0f018152aa2da01 Subproject commit ee0d184bad9f329d327bf0547a272c717cf55029

@ -1 +1 @@
Subproject commit 2f81fc6ce340133a48bd5a8209c34220d269308a Subproject commit 7d8866da54ba5d2b5dc2450a4801909f29c2b7f8