CryptoAuthLib
Microchip CryptoAuthentication Library
swi_bitbang_samd21.c File Reference

Hardware Interface Functions - SWI bit-banged. More...

#include <asf.h>
#include <stdint.h>
#include "swi_bitbang_samd21.h"
#include "atca_command.h"

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.This function should not be called directly ,instead should use hal_swi_send() which call this function. 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.This function should not be called directly ,instead should use hal_swi_receive() which call this function. More...
 

Variables

SWIBuses swi_buses_default
 

Detailed Description

Hardware Interface Functions - SWI bit-banged.

Function Documentation

◆ swi_disable()

void swi_disable ( void  )

Configure GPIO pin for SWI signal as input.

◆ swi_enable()

void swi_enable ( void  )

Configure GPIO pin for SWI signal as output.

◆ swi_receive_bytes()

ATCA_STATUS swi_receive_bytes ( uint8_t  count,
uint8_t *  buffer 
)

Receive a number of bytes.This function should not be called directly ,instead should use hal_swi_receive() which call this function.

Parameters
[in]countnumber of bytes to receive
[out]bufferpointer to receive buffer
Returns
ATCA_SUCCESS on success, otherwise an error code.

Receive bits and store in buffer.

Detect start bit.

Wait for falling edge.

Wait for rising edge.

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.

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.

◆ swi_send_byte()

void swi_send_byte ( uint8_t  byte)

Send one byte.

Parameters
[in]bytebyte to send

◆ swi_send_bytes()

void swi_send_bytes ( uint8_t  count,
uint8_t *  buffer 
)

Send a number of bytes.This function should not be called directly ,instead should use hal_swi_send() which call this function.

Parameters
[in]countnumber of bytes to send.
[in]bufferpointer to buffer containing bytes to send

< Send Logic 1 (7F)

< Send Logic 0 (7D)

◆ swi_send_wake_token()

void swi_send_wake_token ( void  )

Send a Wake Token.

◆ swi_set_pin()

void swi_set_pin ( uint8_t  id)

Set SWI signal pin. Other functions will use this pin.

Parameters
[in]iddefinition of GPIO pin to be used

◆ swi_set_signal_pin()

void swi_set_signal_pin ( uint8_t  is_high)

Set signal pin Low or High.

Parameters
[in]is_high0: Low, else: High.

Variable Documentation

◆ swi_buses_default

SWIBuses swi_buses_default
Initial value:
= {
{ EXT3_PIN_3, EXT3_PIN_9, EXT3_PIN_I2C_SDA, EXT3_PIN_13, EXT2_PIN_13, EXT2_PIN_5, EXT2_PIN_7, EXT2_PIN_9, EXT2_PIN_3, EXT2_PIN_15, EXT2_PIN_17, EXT1_PIN_3, EXT1_PIN_5, EXT1_PIN_7, EXT1_PIN_9, EXT1_PIN_13, EXT1_PIN_15, EXT1_PIN_17, EXT3_PIN_7, EXT3_PIN_10, EXT3_PIN_I2C_SCL, EXT3_PIN_14, EXT2_PIN_4, EXT2_PIN_6, EXT2_PIN_8, EXT2_PIN_10, EXT2_PIN_14, EXT2_PIN_16, EXT2_PIN_18, EXT1_PIN_4, EXT1_PIN_6, EXT1_PIN_8, EXT1_PIN_10, EXT1_PIN_14, EXT1_PIN_16, EXT1_PIN_18 }
}