/
AtmelAtsha204a.h
87 lines (68 loc) · 2.89 KB
/
AtmelAtsha204a.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/** \file AtmelAtsha204a.h
* Header file for plain-C atmel_atsha204a functions, used in module tests.
* \author Garry Jeromson
* \date 16.06.2015
*
* Copyright (c) 2015 Enclustra GmbH, Switzerland.
* All rights reserved.
*/
#pragma once
//-------------------------------------------------------------------------------------------------
// Includes
//-------------------------------------------------------------------------------------------------
#include "AtmelAtsha204aTypes.h"
#include "StandardIncludes.h"
//-------------------------------------------------------------------------------------------------
// Constants
//-------------------------------------------------------------------------------------------------
/// The number of milliseconds it takes for the device to come out of sleep mode
#define ATMEL_ATSHA204A_WAKE_TIME_MILLISECONDS (10)
/// Average time for the read command to complete, after which polling should start
#define ATMEL_ATSHA204A_READ_EXECUTION_TIME_MILLISECONDS (1)
//-------------------------------------------------------------------------------------------------
// Global variables
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
// Function declarations
//-------------------------------------------------------------------------------------------------
/**
* \brief Wake the device by setting I2C SDA low for the required time period.
*
* Note that this is achieved by a general call to device address 0x00.
**
* @param verifyDeviceType Set true to verify the device type by reading back a command response
* immediately after wake
* @return Result code
*/
EN_RESULT AtmelAtsha204a_Wake(bool verifyDeviceType);
/**
* \brief Put the device in low-power sleep mode.
* @return Result code
*/
EN_RESULT AtmelAtsha204a_Sleep();
/**
* \brief Encode an address for reading or writing.
*
* @param[in] zone Zone select
* @param[in] slotIndex Slot select
* @param[in] wordOffset Word offset within the given slot
* @param[out] encodedAddress The encoded address
* @return Result code
*/
EN_RESULT AtmelAtsha204a_EncodeAddress(EZoneSelect_t zone,
uint8_t slotIndex,
uint8_t wordOffset,
uint16_t* encodedAddress);
/**
* \brief Read from the device.
*
* @param[in] sizeSelect Size select, 4 or 32 bytes
* @param[in] zoneSelect Zone select
* @param[in] encodedAddress Encoded address
* @param[out] pReadData Buffer to receive read data
* @return Result code
*/
EN_RESULT AtmelAtsha204a_Read(EReadSizeSelect_t sizeSelect,
EZoneSelect_t zoneSelect,
uint16_t encodedAddress,
uint8_t* pReadData);