CryptoAuthLib v3.7.6
Microchip CryptoAuthentication Library
 
Loading...
Searching...
No Matches
hal_swi_gpio.h File Reference

ATCA Hardware abstraction layer for SWI over GPIO drivers. More...

#include <stdlib.h>
#include "cryptoauthlib.h"
#include "atca_status.h"
#include "atca_hal.h"
#include "atca_config.h"

Macros

Macros for Bit-Banged 1WIRE Timing

Times to drive bits at 230.4 kbps.

#define tPUP   0
 
#define tDSCHG   150
 
#define tRESET   96
 
#define tRRT   1
 
#define tDRR   1
 
#define tMSDR   2
 
#define tHTSS   150
 
#define tDACK   2
 
#define tDACK_DLY   atca_delay_us(tDACK)
 
#define tRRT_DLY   atca_delay_ms(tRRT)
 
#define tDRR_DLY   atca_delay_us(tDRR)
 
#define tMSDR_DLY   atca_delay_us(tMSDR)
 
#define tDSCHG_DLY   atca_delay_us(tDSCHG)
 
#define tRESET_DLY   atca_delay_us(tRESET)
 
#define tHTSS_DLY   atca_delay_us(tHTSS)
 
#define tLOW0_MIN   6
 
#define tLOW0_MAX   16
 
#define tLOW1_MIN   1
 
#define tLOW1_MAX   2
 
#define tRCV_MIN   4
 
#define tRCV_MAX   6
 
#define tBIT_MIN   (tLOW0_MIN + tPUP + tRCV_MIN)
 
#define tBIT_MAX   75
 
#define tWAKEUP   1
 
#define tLOW0_TYPICAL   (tLOW0_MIN + ((tLOW0_MAX - tLOW0_MIN) / 2))
 
#define tLOW1_TYPICAL   (tLOW1_MIN + ((tLOW1_MAX - tLOW1_MIN) / 2))
 
#define tBIT_TYPICAL   (tBIT_MIN + ((tBIT_MAX - tBIT_MIN) / 2 ))
 
#define tLOW0_HDLY   atca_delay_us(11)
 
#define tRD_HDLY   atca_delay_us(1)
 
#define tLOW1_HDLY   atca_delay_us(1)
 
#define tRCV0_HDLY   atca_delay_us(11)
 
#define tRCV1_HDLY   atca_delay_us(14)
 
#define tRD_DLY   atca_delay_us(1)
 
#define tHIGH_SPEED_DLY   atca_delay_us(1)
 
#define tSWIN_DLY   atca_delay_us(1)
 
#define tLOW0_DLY   atca_delay_us(tLOW0_TYPICAL)
 
#define tLOW1_DLY   atca_delay_us(tLOW1_TYPICAL)
 
#define tBIT_DLY   atca_delay_us(tBIT_TYPICAL)
 
#define tRCV0_DLY   atca_delay_us(tBIT_TYPICAL - tLOW0_TYPICAL)
 
#define tRCV1_DLY   atca_delay_us(tBIT_TYPICAL - tLOW1_TYPICAL)
 
#define send_logic0_1wire(...)   send_logic_bit(__VA_ARGS__, ATCA_GPIO_LOGIC_BIT0)
 
#define send_logic1_1wire(...)   send_logic_bit(__VA_ARGS__, ATCA_GPIO_LOGIC_BIT1)
 
#define send_ACK_1wire(...)   send_logic0_1wire(__VA_ARGS__)
 
#define send_NACK_1wire(...)   send_logic1_1wire(__VA_ARGS__)
 
#define ATCA_1WIRE_RESET_WORD_ADDR   0x00
 
#define ATCA_1WIRE_SLEEP_WORD_ADDR   0x01
 
#define ATCA_1WIRE_SLEEP_WORD_ADDR_ALTERNATE   0x02
 
#define ATCA_1WIRE_COMMAND_WORD_ADDR   0x03
 
#define ATCA_1WIRE_RESPONSE_LENGTH_SIZE   0x01
 
#define ATCA_1WIRE_BIT_MASK   0x80
 
#define ATCA_GPIO_WRITE   0
 
#define ATCA_GPIO_READ   1
 
#define ATCA_GPIO_INPUT_DIR   0
 
#define ATCA_GPIO_OUTPUT_DIR   1
 
#define ATCA_GPIO_LOGIC_BIT0   0
 
#define ATCA_GPIO_LOGIC_BIT1   1
 
#define ATCA_GPIO_ACK   ATCA_GPIO_LOGIC_BIT0
 
#define ATCA_GPIO_CLEAR   0
 
#define ATCA_GPIO_SET   1
 
#define ATCA_MIN_RESPONSE_LENGTH   4
 
#define PIN_INPUT_DIR(pin)   PORT_GroupInputEnable(GET_PORT_GROUP(pin), GET_PIN_MASK(pin))
 
#define PIN_OUTPUT_DIR(pin)   PORT_GroupOutputEnable(GET_PORT_GROUP(pin), GET_PIN_MASK(pin))
 

Macros for Bit-Banged SWI Timing

Times to drive bits at 230.4 kbps.

#define BIT_DELAY_1L   atca_delay_us(4)
 
#define BIT_DELAY_1H   atca_delay_us(4)
 should be 4.34 us, is 4.05us
 
#define BIT_DELAY_5   atca_delay_us(26)
 
#define BIT_DELAY_7   atca_delay_us(34)
 
#define RX_TX_DELAY   atca_delay_us(65)
 
#define ATCA_SWI_WAKE_WORD_ADDR   ((uint8_t)0x00)
 
#define ATCA_SWI_CMD_WORD_ADDR   ((uint8_t)0x77)
 
#define ATCA_SWI_TX_WORD_ADDR   ((uint8_t)0x88)
 
#define ATCA_SWI_IDLE_WORD_ADDR   ((uint8_t)0xBB)
 
#define ATCA_SWI_SLEEP_WORD_ADDR   ((uint8_t)0xCC)
 
#define ATCA_SWI_BIT_MASK   0x01
 
enum  protocol_type { ATCA_PROTOCOL_1WIRE , ATCA_PROTOCOL_SWI , NO_OF_PROTOCOL }
 
enum  delay_type {
  LOGIC0_1 , LOGIC0_2 , LOGIC0_3 , LOGIC0_4 ,
  LOGIC1_1 , LOGIC1_2 , NO_OF_DELAYS
}
 

Detailed Description

ATCA Hardware abstraction layer for SWI over GPIO drivers.

Macro Definition Documentation

◆ ATCA_SWI_WAKE_WORD_ADDR

#define ATCA_SWI_WAKE_WORD_ADDR   ((uint8_t)0x00)

SWI WORD Address

◆ BIT_DELAY_1L

#define BIT_DELAY_1L   atca_delay_us(4)

delay macro for width of one pulse (start pulse or zero pulse) should be 4.34 us, is 4.05 us

◆ BIT_DELAY_5

#define BIT_DELAY_5   atca_delay_us(26)

time to keep pin high for five pulses plus stop bit (used to bit-bang CryptoAuth 'zero' bit) should be 26.04 us, is 26.92 us

◆ BIT_DELAY_7

#define BIT_DELAY_7   atca_delay_us(34)

time to keep pin high for seven bits plus stop bit (used to bit-bang CryptoAuth 'one' bit) should be 34.72 us, is 35.13 us

◆ RX_TX_DELAY

#define RX_TX_DELAY   atca_delay_us(65)

turn around time when switching from receive to transmit should be 93 us (Setting little less value as there would be other process before these steps)