Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_atsha204.h
1 #ifndef _BC_ATSHA204_H
2 #define _BC_ATSHA204_H
3 
4 #include <bc_common.h>
5 #include <bc_i2c.h>
6 #include <bc_scheduler.h>
7 
8 #define BC_ATSHA204_RX_BUFFER_SIZE 32
9 
13 
14 typedef enum
15 {
18 
21 
24 
26 
28 
30 
32 
33 typedef enum
34 {
35  BC_ATSHA204_STATE_READY = 0,
36  BC_ATSHA204_STATE_READ_SERIAL_NUMBER = 1,
37  BC_ATSHA204_STATE_READ_SERIAL_NUMBER2 = 2,
38  BC_ATSHA204_STATE_SERIAL_NUMBER = 3
39 
40 } bc_atsha204_state_t;
41 
42 struct bc_atsha204_t
43 {
44  bc_i2c_channel_t _i2c_channel;
45  uint8_t _i2c_address;
46  void (*_event_handler)(bc_atsha204_t *, bc_atsha204_event_t, void *);
47  void *_event_param;
48  bc_scheduler_task_id_t _task_id;
49  bc_atsha204_state_t _state;
50  bool _ready;
51  uint8_t _rx_buffer[BC_ATSHA204_RX_BUFFER_SIZE];
52 
53 };
54 
56 
61 
62 void bc_atsha204_init(bc_atsha204_t *self, bc_i2c_channel_t i2c_channel, uint8_t i2c_address);
63 
68 
69 void bc_atsha204_set_event_handler(bc_atsha204_t *self, void (*event_handler)(bc_atsha204_t *, bc_atsha204_event_t, void *), void *event_param);
70 
75 
77 
82 
84 
91 
92 bool bc_atsha204_get_serial_number(bc_atsha204_t *self, void *destination, size_t size);
93 
95 
96 #endif // _BC_ATSHA204_H
97 
Event revision number is available.
Definition: bc_atsha204.h:20
bool bc_atsha204_read_serial_number(bc_atsha204_t *self)
Reqeust for serial number.
Definition: bc_atsha204.c:40
bc_atsha204_event_t
Definition: bc_atsha204.h:14
size_t bc_scheduler_task_id_t
Task ID assigned by scheduler.
Definition: bc_scheduler.h:18
Event serial number is available.
Definition: bc_atsha204.h:23
bool bc_atsha204_is_ready(bc_atsha204_t *self)
Check if is ready for commands.
Definition: bc_atsha204.c:35
struct bc_atsha204_t bc_atsha204_t
ATSHA204 instance.
Definition: bc_atsha204.h:29
bc_i2c_channel_t
I2C channels.
Definition: bc_i2c.h:15
bool bc_atsha204_get_serial_number(bc_atsha204_t *self, void *destination, size_t size)
Get serial number.
Definition: bc_atsha204.c:59
void bc_atsha204_set_event_handler(bc_atsha204_t *self, void(*event_handler)(bc_atsha204_t *, bc_atsha204_event_t, void *), void *event_param)
Set callback function.
Definition: bc_atsha204.c:29
void bc_atsha204_init(bc_atsha204_t *self, bc_i2c_channel_t i2c_channel, uint8_t i2c_address)
Initialize ATSHA204 driver.
Definition: bc_atsha204.c:15