|
|
|
|
@ -22,13 +22,11 @@ static THD_FUNCTION(SlaveThread, arg) {
|
|
|
|
|
chRegSetThreadName("split_protocol_tx_rx");
|
|
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
|
split_shared_memory_lock();
|
|
|
|
|
if (unlikely(!react_to_transaction())) {
|
|
|
|
|
/* Clear the receive queue, to start with a clean slate.
|
|
|
|
|
* Parts of failed transactions or spurious bytes could still be in it. */
|
|
|
|
|
serial_transport_driver_clear();
|
|
|
|
|
}
|
|
|
|
|
split_shared_memory_unlock();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -64,6 +62,8 @@ static inline bool react_to_transaction(void) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
split_shared_memory_lock_autounlock();
|
|
|
|
|
|
|
|
|
|
split_transaction_desc_t* transaction = &split_transaction_table[transaction_id];
|
|
|
|
|
|
|
|
|
|
/* Send back the handshake which is XORed as a simple checksum,
|
|
|
|
|
@ -102,9 +102,7 @@ static inline bool react_to_transaction(void) {
|
|
|
|
|
* @return bool Indicates success of transaction.
|
|
|
|
|
*/
|
|
|
|
|
bool soft_serial_transaction(int index) {
|
|
|
|
|
split_shared_memory_lock();
|
|
|
|
|
bool result = initiate_transaction((uint8_t)index);
|
|
|
|
|
split_shared_memory_unlock();
|
|
|
|
|
|
|
|
|
|
if (unlikely(!result)) {
|
|
|
|
|
/* Clear the receive queue, to start with a clean slate.
|
|
|
|
|
@ -125,6 +123,8 @@ static inline bool initiate_transaction(uint8_t transaction_id) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
split_shared_memory_lock_autounlock();
|
|
|
|
|
|
|
|
|
|
split_transaction_desc_t* transaction = &split_transaction_table[transaction_id];
|
|
|
|
|
|
|
|
|
|
/* Send transaction table index to the slave, which doubles as basic handshake token. */
|
|
|
|
|
|