LibDriver BPC
Loading...
Searching...
No Matches
driver_bpc.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_BPC_H
38#define DRIVER_BPC_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
62#ifndef BPC_MAX_START_RANGE
63 #define BPC_MAX_START_RANGE 0.20f
64#endif
65
69#ifndef BPC_MAX_RANGE
70 #define BPC_MAX_RANGE 0.20f
71#endif
72
82
86typedef struct bpc_s
87{
88 uint8_t status;
89 uint16_t year;
90 uint8_t month;
91 uint8_t day;
92 uint8_t week;
93 uint8_t hour;
94 uint8_t minute;
95 uint8_t second;
97
101typedef struct bpc_time_s
102{
103 uint64_t s;
104 uint32_t us;
106
115
119typedef struct bpc_handle_s
120{
121 uint8_t (*timestamp_read)(bpc_time_t *t);
122 void (*delay_ms)(uint32_t ms);
123 void (*debug_print)(const char *const fmt, ...);
124 void (*receive_callback)(bpc_t *data);
125 uint8_t inited;
127 uint16_t decode_len;
130 uint8_t decode_valid;
131 uint8_t trace_valid;
133
149
153
160
167#define DRIVER_BPC_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
168
175#define DRIVER_BPC_LINK_TIMESTAMP_READ(HANDLE, FUC) (HANDLE)->timestamp_read = FUC
176
183#define DRIVER_BPC_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
184
191#define DRIVER_BPC_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
192
199#define DRIVER_BPC_LINK_RECEIVE_CALLBACK(HANDLE, FUC) (HANDLE)->receive_callback = FUC
200
204
211
220uint8_t bpc_info(bpc_info_t *info);
221
232uint8_t bpc_irq_handler(bpc_handle_t *handle);
233
244uint8_t bpc_init(bpc_handle_t *handle);
245
255uint8_t bpc_deinit(bpc_handle_t *handle);
256
260
264
265#ifdef __cplusplus
266}
267#endif
268
269#endif
uint8_t bpc_irq_handler(bpc_handle_t *handle)
irq handler
uint8_t bpc_info(bpc_info_t *info)
get chip's information
uint8_t bpc_init(bpc_handle_t *handle)
initialize the chip
struct bpc_handle_s bpc_handle_t
bpc handle structure definition
struct bpc_s bpc_t
bpc structure definition
struct bpc_time_s bpc_time_t
bpc time structure definition
struct bpc_info_s bpc_info_t
bpc information structure definition
uint8_t bpc_deinit(bpc_handle_t *handle)
close the chip
struct bpc_decode_s bpc_decode_t
bpc decode structure definition
bpc_status_t
bpc status enumeration definition
Definition driver_bpc.h:77
@ BPC_STATUS_FRAME_INVALID
Definition driver_bpc.h:80
@ BPC_STATUS_OK
Definition driver_bpc.h:78
@ BPC_STATUS_PARITY_ERR
Definition driver_bpc.h:79
bpc decode structure definition
Definition driver_bpc.h:111
bpc_time_t t
Definition driver_bpc.h:112
uint32_t diff_us
Definition driver_bpc.h:113
bpc handle structure definition
Definition driver_bpc.h:120
uint8_t decode_valid
Definition driver_bpc.h:130
uint8_t decode_offset
Definition driver_bpc.h:129
uint8_t inited
Definition driver_bpc.h:125
void(* delay_ms)(uint32_t ms)
Definition driver_bpc.h:122
uint8_t trace_valid
Definition driver_bpc.h:131
bpc_decode_t decode[76]
Definition driver_bpc.h:126
void(* receive_callback)(bpc_t *data)
Definition driver_bpc.h:124
void(* debug_print)(const char *const fmt,...)
Definition driver_bpc.h:123
uint8_t(* timestamp_read)(bpc_time_t *t)
Definition driver_bpc.h:121
bpc_time_t last_time
Definition driver_bpc.h:128
uint16_t decode_len
Definition driver_bpc.h:127
bpc information structure definition
Definition driver_bpc.h:138
float temperature_max
Definition driver_bpc.h:146
float supply_voltage_max_v
Definition driver_bpc.h:143
uint32_t driver_version
Definition driver_bpc.h:147
float temperature_min
Definition driver_bpc.h:145
float max_current_ma
Definition driver_bpc.h:144
char manufacturer_name[32]
Definition driver_bpc.h:140
float supply_voltage_min_v
Definition driver_bpc.h:142
char interface[8]
Definition driver_bpc.h:141
char chip_name[32]
Definition driver_bpc.h:139
bpc structure definition
Definition driver_bpc.h:87
uint8_t month
Definition driver_bpc.h:90
uint8_t week
Definition driver_bpc.h:92
uint16_t year
Definition driver_bpc.h:89
uint8_t day
Definition driver_bpc.h:91
uint8_t second
Definition driver_bpc.h:95
uint8_t minute
Definition driver_bpc.h:94
uint8_t status
Definition driver_bpc.h:88
uint8_t hour
Definition driver_bpc.h:93
bpc time structure definition
Definition driver_bpc.h:102
uint64_t s
Definition driver_bpc.h:103
uint32_t us
Definition driver_bpc.h:104