/*
* WARNING: be careful changing this code, it is very timing dependent
*/
// TODO: resolve/remove build warnings
// default wait implementation cannot be called within interrupt
// this method seems to be more accurate than GPT timers
// TODO: correct speeds...
// 0: about 189kbps (Experimental only)
// 1: about 137kbps (default)
// 2: about 75kbps
// 3: about 39kbps
// 4: about 26kbps
// 5: about 20kbps
// Serial pulse period in microseconds. At the moment, going lower than 12 causes communication failure
inline static void
inline static void
inline static void
inline static void
inline static void
inline static bool
inline static void
inline static void
void ;
// Use thread + palWaitLineTimeout instead of palSetLineCallback
// - Methods like setPinOutput and palEnableLineEvent/palDisableLineEvent
// cause the interrupt to lock up, which would limit to only receiving data...
static ;
static
static SSTD_t *Transaction_table = NULL;
static uint8_t Transaction_table_size = 0;
void
void
// Used by the master to synchronize timing with the slave.
static void
// Used by the slave to send a synchronization signal to the master.
static void
// Reads a byte from the serial line
static uint8_t
// Sends a byte with MSB ordering
static void
// interrupt handle to be used by the slave device
void
/////////
// start transaction by initiator
//
// int soft_serial_transaction(int sstd_index)
//
// Returns:
// TRANSACTION_END
// TRANSACTION_NO_RESPONSE
// TRANSACTION_DATA_ERROR
// this code is very time dependent, so we need to disable interrupts
int int
if return TRANSACTION_TYPE_ERROR;
SSTD_t *trans = &Transaction_table;
// TODO: remove extra delay between transactions
;
// this code is very time dependent, so we need to disable interrupts
;
// signal to the slave that we want to start a transaction
;
;
;
// wait for the slaves response
;
;
;
// check if the slave is present
if
// if the slave is present syncronize with it
uint8_t checksum = 0;
// send data to the slave
; // first chunk is transaction id
;
for
;
;
;
; // read mid pulses
// receive data from the slave
uint8_t checksum_computed = 0;
for
checksum_computed ^= 7;
uint8_t checksum_received = ;
;
;
if
// always, release the line when not in use
;
;
;
return TRANSACTION_END;
}