LibDriver MCP9600
Loading...
Searching...
No Matches
driver_mcp9600.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_MCP9600_H
38#define DRIVER_MCP9600_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
62typedef enum
63{
67
76
87
102
112
127
142
153
162
171
175typedef enum
176{
180
189
198
207
216
220typedef struct mcp9600_handle_s
221{
222 uint8_t (*iic_init)(void);
223 uint8_t (*iic_deinit)(void);
224 uint8_t (*iic_write_cmd)(uint8_t addr, uint8_t *buf, uint16_t len);
225 uint8_t (*iic_read_cmd)(uint8_t addr, uint8_t *buf, uint16_t len);
226 void (*delay_ms)(uint32_t ms);
227 void (*debug_print)(const char *const fmt, ...);
228 uint8_t inited;
229 uint8_t iic_addr;
231
247
251
258
265#define DRIVER_MCP9600_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
266
273#define DRIVER_MCP9600_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
274
281#define DRIVER_MCP9600_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
282
289#define DRIVER_MCP9600_LINK_IIC_READ_COMMAND(HANDLE, FUC) (HANDLE)->iic_read_cmd = FUC
290
297#define DRIVER_MCP9600_LINK_IIC_WRITE_COMMAND(HANDLE, FUC) (HANDLE)->iic_write_cmd = FUC
298
305#define DRIVER_MCP9600_LINK_IIC_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
306
313#define DRIVER_MCP9600_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
314
318
325
334uint8_t mcp9600_info(mcp9600_info_t *info);
335
346
357
369uint8_t mcp9600_init(mcp9600_handle_t *handle);
370
382uint8_t mcp9600_deinit(mcp9600_handle_t *handle);
383
395
407
425uint8_t mcp9600_continuous_read(mcp9600_handle_t *handle, int16_t *hot_raw, float *hot_s,
426 int16_t *delta_raw, float *delta_s, int16_t *cold_raw, float *cold_s);
427
445uint8_t mcp9600_single_read(mcp9600_handle_t *handle, int16_t *hot_raw, float *hot_s,
446 int16_t *delta_raw, float *delta_s, int16_t *cold_raw, float *cold_s);
447
460uint8_t mcp9600_get_hot_junction_temperature(mcp9600_handle_t *handle, int16_t *raw, float *s);
461
474uint8_t mcp9600_get_junction_thermocouple_delta(mcp9600_handle_t *handle, int16_t *raw, float *s);
475
488uint8_t mcp9600_get_cold_junction_temperature(mcp9600_handle_t *handle, int16_t *raw, float *s);
489
502uint8_t mcp9600_get_raw_adc(mcp9600_handle_t *handle, int32_t *raw, double *uv);
503
516
529
542
555
568
580
593
605
618
632
645
658
671
684
697
710
723
735uint8_t mcp9600_get_mode(mcp9600_handle_t *handle, mcp9600_mode_t *mode);
736
748uint8_t mcp9600_alert_limit_convert_to_register(mcp9600_handle_t *handle, float c, int16_t *reg);
749
761uint8_t mcp9600_alert_limit_convert_to_data(mcp9600_handle_t *handle, int16_t reg, float *c);
762
776uint8_t mcp9600_set_alert_limit(mcp9600_handle_t *handle, mcp9600_alert_t alert, int16_t reg);
777
791uint8_t mcp9600_get_alert_limit(mcp9600_handle_t *handle, mcp9600_alert_t alert, int16_t *reg);
792
804uint8_t mcp9600_alert_hysteresis_convert_to_register(mcp9600_handle_t *handle, float c, uint8_t *reg);
805
817uint8_t mcp9600_alert_hysteresis_convert_to_data(mcp9600_handle_t *handle, uint8_t reg, float *c);
818
832uint8_t mcp9600_set_alert_hysteresis(mcp9600_handle_t *handle, mcp9600_alert_t alert, uint8_t reg);
833
847uint8_t mcp9600_get_alert_hysteresis(mcp9600_handle_t *handle, mcp9600_alert_t alert, uint8_t *reg);
848
862
876uint8_t mcp9600_get_interrupt(mcp9600_handle_t *handle, mcp9600_alert_t alert, uint8_t *status);
877
893
909
924
939
954
969
984
999
1014
1029
1042uint8_t mcp9600_get_device_id_revision(mcp9600_handle_t *handle, uint8_t *id, uint8_t *revision);
1043
1047
1054
1068uint8_t mcp9600_set_reg(mcp9600_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
1069
1083uint8_t mcp9600_get_reg(mcp9600_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
1084
1088
1092
1093#ifdef __cplusplus
1094}
1095#endif
1096
1097#endif
mcp9600_active_level_t
mcp9600 active level enumeration definition
uint8_t mcp9600_get_cold_junction_resolution(mcp9600_handle_t *handle, mcp9600_cold_junction_resolution_t *resolution)
get the cold junction resolution
mcp9600_mode_t
mcp9600 mode enumeration definition
uint8_t mcp9600_set_alert_hysteresis(mcp9600_handle_t *handle, mcp9600_alert_t alert, uint8_t reg)
set the alert hysteresis
uint8_t mcp9600_get_interrupt(mcp9600_handle_t *handle, mcp9600_alert_t alert, uint8_t *status)
get the interrupt flag
mcp9600_input_range_t
mcp9600 input range enumeration definition
mcp9600_cold_junction_resolution_t
mcp9600 cold junction resolution enumeration definition
mcp9600_address_t
mcp9600 address enumeration definition
struct mcp9600_info_s mcp9600_info_t
mcp9600 information structure definition
mcp9600_thermocouple_type_t
mcp9600 thermocouple type enumeration definition
uint8_t mcp9600_get_alert_hysteresis(mcp9600_handle_t *handle, mcp9600_alert_t alert, uint8_t *reg)
get the alert hysteresis
uint8_t mcp9600_set_active_level(mcp9600_handle_t *handle, mcp9600_alert_t alert, mcp9600_active_level_t level)
set the active level
uint8_t mcp9600_set_detect_edge(mcp9600_handle_t *handle, mcp9600_alert_t alert, mcp9600_detect_edge_t edge)
set the detect edge
uint8_t mcp9600_clear_status_burst_complete_flag(mcp9600_handle_t *handle)
clear the burst complete status flag
uint8_t mcp9600_get_alert_output(mcp9600_handle_t *handle, mcp9600_alert_t alert, mcp9600_bool_t *enable)
get the alert output
uint8_t mcp9600_get_cold_junction_temperature(mcp9600_handle_t *handle, int16_t *raw, float *s)
get the cold junction temperature
uint8_t mcp9600_set_cold_junction_resolution(mcp9600_handle_t *handle, mcp9600_cold_junction_resolution_t resolution)
set the cold junction resolution
mcp9600_filter_coefficient_t
mcp9600 filter coefficient enumeration definition
uint8_t mcp9600_get_active_level(mcp9600_handle_t *handle, mcp9600_alert_t alert, mcp9600_active_level_t *level)
get the active level
uint8_t mcp9600_get_junction_thermocouple_delta(mcp9600_handle_t *handle, int16_t *raw, float *s)
get the junction thermocouple delta
uint8_t mcp9600_single_read(mcp9600_handle_t *handle, int16_t *hot_raw, float *hot_s, int16_t *delta_raw, float *delta_s, int16_t *cold_raw, float *cold_s)
read data once
mcp9600_adc_resolution_t
mcp9600 adc resolution enumeration definition
uint8_t mcp9600_get_status_temperature_update_flag(mcp9600_handle_t *handle, mcp9600_bool_t *status)
get the temperature update status flag
uint8_t mcp9600_clear_interrupt(mcp9600_handle_t *handle, mcp9600_alert_t alert)
clear the interrupt flag
uint8_t mcp9600_set_alert_limit(mcp9600_handle_t *handle, mcp9600_alert_t alert, int16_t reg)
set the alert limit
uint8_t mcp9600_get_addr_pin(mcp9600_handle_t *handle, mcp9600_address_t *addr_pin)
get the iic address pin
uint8_t mcp9600_set_thermocouple_type(mcp9600_handle_t *handle, mcp9600_thermocouple_type_t type)
set the thermocouple type
uint8_t mcp9600_stop_continuous_read(mcp9600_handle_t *handle)
stop reading data
uint8_t mcp9600_set_mode(mcp9600_handle_t *handle, mcp9600_mode_t mode)
set the mode
uint8_t mcp9600_start_continuous_read(mcp9600_handle_t *handle)
start reading data
uint8_t mcp9600_get_adc_resolution(mcp9600_handle_t *handle, mcp9600_adc_resolution_t *resolution)
get the adc resolution
struct mcp9600_handle_s mcp9600_handle_t
mcp9600 handle structure definition
uint8_t mcp9600_alert_hysteresis_convert_to_data(mcp9600_handle_t *handle, uint8_t reg, float *c)
convert the register raw data to the alert hysteresis
uint8_t mcp9600_get_raw_adc(mcp9600_handle_t *handle, int32_t *raw, double *uv)
get the raw adc
mcp9600_burst_mode_sample_t
mcp9600 burst mode sample enumeration definition
uint8_t mcp9600_get_temperature_maintain_detect(mcp9600_handle_t *handle, mcp9600_alert_t alert, mcp9600_temperature_maintain_detect_t *maintain_detect)
get the temperature maintain detect
uint8_t mcp9600_get_detect_edge(mcp9600_handle_t *handle, mcp9600_alert_t alert, mcp9600_detect_edge_t *edge)
get the detect edge
uint8_t mcp9600_alert_limit_convert_to_register(mcp9600_handle_t *handle, float c, int16_t *reg)
convert the alert limit to the register raw data
uint8_t mcp9600_get_mode(mcp9600_handle_t *handle, mcp9600_mode_t *mode)
get the mode
uint8_t mcp9600_alert_limit_convert_to_data(mcp9600_handle_t *handle, int16_t reg, float *c)
convert the register raw data to the alert limit
uint8_t mcp9600_get_thermocouple_type(mcp9600_handle_t *handle, mcp9600_thermocouple_type_t *type)
get the thermocouple type
uint8_t mcp9600_alert_hysteresis_convert_to_register(mcp9600_handle_t *handle, float c, uint8_t *reg)
convert the alert hysteresis to the register raw data
mcp9600_alert_status_t
mcp9600 alert status enumeration definition
uint8_t mcp9600_get_status_burst_complete_flag(mcp9600_handle_t *handle, mcp9600_bool_t *status)
get the burst complete status flag
mcp9600_interrupt_mode_t
mcp9600 interrupt mode enumeration definition
uint8_t mcp9600_get_alert_limit(mcp9600_handle_t *handle, mcp9600_alert_t alert, int16_t *reg)
get the alert limit
mcp9600_alert_t
mcp9600 alert enumeration definition
mcp9600_bool_t
mcp9600 bool enumeration definition
uint8_t mcp9600_get_burst_mode_sample(mcp9600_handle_t *handle, mcp9600_burst_mode_sample_t *sample)
get the burst mode sample
uint8_t mcp9600_set_alert_output(mcp9600_handle_t *handle, mcp9600_alert_t alert, mcp9600_bool_t enable)
set the alert output
uint8_t mcp9600_set_addr_pin(mcp9600_handle_t *handle, mcp9600_address_t addr_pin)
set the iic address pin
uint8_t mcp9600_set_filter_coefficient(mcp9600_handle_t *handle, mcp9600_filter_coefficient_t coefficient)
set the filter coefficient
uint8_t mcp9600_set_temperature_maintain_detect(mcp9600_handle_t *handle, mcp9600_alert_t alert, mcp9600_temperature_maintain_detect_t maintain_detect)
set the temperature maintain detect
uint8_t mcp9600_set_burst_mode_sample(mcp9600_handle_t *handle, mcp9600_burst_mode_sample_t sample)
set the burst mode sample
uint8_t mcp9600_get_filter_coefficient(mcp9600_handle_t *handle, mcp9600_filter_coefficient_t *coefficient)
get the filter coefficient
mcp9600_temperature_maintain_detect_t
mcp9600 temperature maintain detect enumeration definition
uint8_t mcp9600_get_status_input_range(mcp9600_handle_t *handle, mcp9600_input_range_t *range)
get the input range status
uint8_t mcp9600_info(mcp9600_info_t *info)
get chip information
uint8_t mcp9600_get_device_id_revision(mcp9600_handle_t *handle, uint8_t *id, uint8_t *revision)
get the device id and revision
uint8_t mcp9600_get_hot_junction_temperature(mcp9600_handle_t *handle, int16_t *raw, float *s)
get the hot junction temperature
uint8_t mcp9600_set_interrupt_mode(mcp9600_handle_t *handle, mcp9600_alert_t alert, mcp9600_interrupt_mode_t mode)
set the interrupt mode
uint8_t mcp9600_get_interrupt_mode(mcp9600_handle_t *handle, mcp9600_alert_t alert, mcp9600_interrupt_mode_t *mode)
get the interrupt mode
uint8_t mcp9600_clear_status_temperature_update_flag(mcp9600_handle_t *handle)
clear the temperature update status flag
uint8_t mcp9600_deinit(mcp9600_handle_t *handle)
close the chip
uint8_t mcp9600_set_adc_resolution(mcp9600_handle_t *handle, mcp9600_adc_resolution_t resolution)
set the adc resolution
mcp9600_detect_edge_t
mcp9600 detect edge enumeration definition
uint8_t mcp9600_continuous_read(mcp9600_handle_t *handle, int16_t *hot_raw, float *hot_s, int16_t *delta_raw, float *delta_s, int16_t *cold_raw, float *cold_s)
read data continuously
uint8_t mcp9600_get_alert_status(mcp9600_handle_t *handle, mcp9600_alert_t alert, mcp9600_alert_status_t *status)
get the alert status
uint8_t mcp9600_init(mcp9600_handle_t *handle)
initialize the chip
@ MCP9600_ACTIVE_LEVEL_LOW
@ MCP9600_ACTIVE_LEVEL_HIGH
@ MCP9600_MODE_NORMAL
@ MCP9600_MODE_BURST
@ MCP9600_MODE_SHUTDOWN
@ MCP9600_INPUT_RANGE_WITHIN
@ MCP9600_INPUT_RANGE_EXCEEDS
@ MCP9600_COLD_JUNCTION_RESOLUTION_0P25
@ MCP9600_COLD_JUNCTION_RESOLUTION_0P0625
@ MCP9600_ADDRESS_0
@ MCP9600_ADDRESS_1
@ MCP9600_THERMOCOUPLE_TYPE_R
@ MCP9600_THERMOCOUPLE_TYPE_T
@ MCP9600_THERMOCOUPLE_TYPE_K
@ MCP9600_THERMOCOUPLE_TYPE_S
@ MCP9600_THERMOCOUPLE_TYPE_E
@ MCP9600_THERMOCOUPLE_TYPE_N
@ MCP9600_THERMOCOUPLE_TYPE_B
@ MCP9600_THERMOCOUPLE_TYPE_J
@ MCP9600_FILTER_COEFFICIENT_6
@ MCP9600_FILTER_COEFFICIENT_5
@ MCP9600_FILTER_COEFFICIENT_1
@ MCP9600_FILTER_COEFFICIENT_3
@ MCP9600_FILTER_COEFFICIENT_7
@ MCP9600_FILTER_COEFFICIENT_2
@ MCP9600_FILTER_COEFFICIENT_4
@ MCP9600_FILTER_COEFFICIENT_0
@ MCP9600_ADC_RESOLUTION_18_BIT
@ MCP9600_ADC_RESOLUTION_16_BIT
@ MCP9600_ADC_RESOLUTION_12_BIT
@ MCP9600_ADC_RESOLUTION_14_BIT
@ MCP9600_BURST_MODE_SAMPLE_8
@ MCP9600_BURST_MODE_SAMPLE_32
@ MCP9600_BURST_MODE_SAMPLE_4
@ MCP9600_BURST_MODE_SAMPLE_2
@ MCP9600_BURST_MODE_SAMPLE_128
@ MCP9600_BURST_MODE_SAMPLE_64
@ MCP9600_BURST_MODE_SAMPLE_1
@ MCP9600_BURST_MODE_SAMPLE_16
@ MCP9600_ALERT_STATUS_LESS
@ MCP9600_ALERT_STATUS_OVER
@ MCP9600_INTERRUPT_MODE_INTERRUPT
@ MCP9600_INTERRUPT_MODE_COMPARATOR
@ MCP9600_ALERT_2
@ MCP9600_ALERT_3
@ MCP9600_ALERT_1
@ MCP9600_ALERT_4
@ MCP9600_BOOL_TRUE
@ MCP9600_BOOL_FALSE
@ MCP9600_TEMPERATURE_MAINTAIN_DETECT_HOT_JUNCTION
@ MCP9600_TEMPERATURE_MAINTAIN_DETECT_COLD_JUNCTION
@ MCP9600_DETECT_EDGE_FALLING
@ MCP9600_DETECT_EDGE_RISING
uint8_t mcp9600_get_reg(mcp9600_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
uint8_t mcp9600_set_reg(mcp9600_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
mcp9600 handle structure definition
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_read_cmd)(uint8_t addr, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
uint8_t(* iic_write_cmd)(uint8_t addr, uint8_t *buf, uint16_t len)
mcp9600 information structure definition
uint32_t driver_version
char manufacturer_name[32]