CryptoAuthLib
Atmel CryptoAuthentication Library
|
Hardware Interface Functions - SWI bit-banged. More...
Functions | |
void | swi_set_pin (uint8_t id) |
Set SWI signal pin. Other functions will use this pin. More... | |
void | swi_enable (void) |
Configure GPIO pin for SWI signal as output. More... | |
void | swi_disable (void) |
Configure GPIO pin for SWI signal as input. More... | |
void | swi_set_signal_pin (uint8_t is_high) |
Set signal pin Low or High. More... | |
void | swi_send_wake_token (void) |
Send a Wake Token. More... | |
void | swi_send_bytes (uint8_t count, uint8_t *buffer) |
Send a number of bytes. More... | |
void | swi_send_byte (uint8_t byte) |
Send one byte. More... | |
ATCA_STATUS | swi_receive_bytes (uint8_t count, uint8_t *buffer) |
Receive a number of bytes. More... | |
Variables | |
SWIBuses | swi_buses_default |
Hardware Interface Functions - SWI bit-banged.
void swi_disable | ( | void | ) |
Configure GPIO pin for SWI signal as input.
void swi_enable | ( | void | ) |
Configure GPIO pin for SWI signal as output.
ATCA_STATUS swi_receive_bytes | ( | uint8_t | count, |
uint8_t * | buffer | ||
) |
Receive a number of bytes.
[in] | count | number of bytes to receive |
[out] | buffer | pointer to receive buffer |
Receive bits and store in buffer.
Make sure that the variable below is big enough. Change it to uint16_t if 255 is too small, but be aware that the loop resolution decreases on an 8-bit controller in that case.
Detect start bit.
Wait for falling edge.
Wait for rising edge.
For an Atmel microcontroller this might be faster than "pulse_count++".
Trying to measure the time of start bit and calculating the timeout for zero bit detection is not accurate enough for an 8 MHz 8-bit CPU. So let's just wait the maximum time for the falling edge of a zero bit to arrive after we have detected the rising edge of the start bit.
Detect possible edge indicating zero bit.
For an Atmel microcontroller this might be faster than "pulse_count++".
Wait for rising edge of zero pulse before returning. Otherwise we might interpret its rising edge as the next start pulse.
Update byte at current buffer index.
received "one" bit
Indicate that we timed out after having received at least one byte.
void swi_send_byte | ( | uint8_t | byte | ) |
Send one byte.
[in] | byte | byte to send |
void swi_send_bytes | ( | uint8_t | count, |
uint8_t * | buffer | ||
) |
Send a number of bytes.
[in] | count | number of bytes to send. |
[in] | buffer | pointer to buffer containing bytes to send |
Wait turn around time.
< Send Logic 1 (7F)
< Send Logic 0 (7D)
void swi_send_wake_token | ( | void | ) |
Send a Wake Token.
void swi_set_pin | ( | uint8_t | id | ) |
Set SWI signal pin. Other functions will use this pin.
[in] | id | definition of GPIO pin to be used |
void swi_set_signal_pin | ( | uint8_t | is_high | ) |
Set signal pin Low or High.
[in] | is_high | 0: Low, else: High. |
SWIBuses swi_buses_default |