Microchip® Advanced Software Framework

sha204_comm.c File Reference
#include "sha204_comm.h"
#include "sha204_timer.h"
#include "sha204_lib_return_codes.h"

Functions

void sha204c_calculate_crc (uint8_t length, uint8_t *data, uint8_t *crc)
 This function calculates CRC. More...
 
uint8_t sha204c_check_crc (uint8_t *response)
 < definitions and declarations for the Communication module More...
 
uint8_t sha204c_resync (uint8_t size, uint8_t *response)
 This function re-synchronizes communication. More...
 
uint8_t sha204c_send_and_receive (struct sha204_send_and_receive_parameters *args)
 This function runs a communication sequence: Append CRC to tx buffer, send command, delay, and verify response after receiving it. More...
 
uint8_t sha204c_wakeup (uint8_t *response)
 This function wakes up a SHA204 device and receives a response. More...
 

uint8_t sha204c_check_crc ( uint8_t *  response)

< definitions and declarations for the Communication module

This function checks the consistency of a response.

< definitions for timer functions < declarations of function return codes

Parameters
[in]responsepointer to response
Returns
status of the consistency check

References SHA204_BAD_CRC, SHA204_BUFFER_POS_COUNT, SHA204_CRC_SIZE, SHA204_SUCCESS, and sha204c_calculate_crc().

Referenced by sha204c_send_and_receive().

uint8_t sha204c_resync ( uint8_t  size,
uint8_t *  response 
)

This function re-synchronizes communication.

Be aware that succeeding only after waking up the device could mean that it had gone to sleep and lost its TempKey in the process.
Re-synchronizing communication is done in a maximum of three steps:

  1. Try to re-synchronize without sending a Wake token. This step is implemented in the Physical layer.
  2. If the first step did not succeed send a Wake token.
  3. Try to read the Wake response.
Parameters
[in]sizesize of response buffer
[out]responsepointer to Wake-up response buffer
Returns
status of the operation

References SHA204_RESYNC_WITH_WAKEUP, SHA204_SUCCESS, sha204c_wakeup(), sha204p_resync(), and sha204p_sleep().

Referenced by sha204c_send_and_receive().