LibDriver MAX6675
Loading...
Searching...
No Matches
driver_max6675_read_test.c
Go to the documentation of this file.
1
36
38
39static max6675_handle_t gs_handle;
40
49uint8_t max6675_read_test(uint32_t times)
50{
51 uint8_t res;
52 uint32_t i;
53 max6675_info_t info;
54
55 /* link functions */
62
63 /* max6675 info */
64 res = max6675_info(&info);
65 if (res != 0)
66 {
67 max6675_interface_debug_print("max6675: get info failed.\n");
68
69 return 1;
70 }
71 else
72 {
73 /* print chip information */
74 max6675_interface_debug_print("max6675: chip is %s.\n", info.chip_name);
75 max6675_interface_debug_print("max6675: manufacturer is %s.\n", info.manufacturer_name);
76 max6675_interface_debug_print("max6675: interface is %s.\n", info.interface);
77 max6675_interface_debug_print("max6675: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
78 max6675_interface_debug_print("max6675: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
79 max6675_interface_debug_print("max6675: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
80 max6675_interface_debug_print("max6675: max current is %0.2fmA.\n", info.max_current_ma);
81 max6675_interface_debug_print("max6675: max temperature is %0.1fC.\n", info.temperature_max);
82 max6675_interface_debug_print("max6675: min temperature is %0.1fC.\n", info.temperature_min);
83 }
84
85 /* max6675 init */
86 res = max6675_init(&gs_handle);
87 if (res != 0)
88 {
89 max6675_interface_debug_print("max6675: init failed.\n");
90
91 return 1;
92 }
93
94 /* start read test */
95 max6675_interface_debug_print("max6675: start read test.\n");
96
97 for (i = 0; i < times; i++)
98 {
99 uint16_t raw;
100 float temp;
101
102 /* read data */
103 res = max6675_read(&gs_handle, &raw, &temp);
104 if (res != 0)
105 {
106 max6675_interface_debug_print("max6675: read failed.\n");
107 (void)max6675_deinit(&gs_handle);
108
109 return 1;
110 }
111
112 /* output */
113 max6675_interface_debug_print("max6675: temperature is %0.2fC.\n", temp);
114
115 /* delay 1000ms */
117 }
118
119 /* finish read test */
120 max6675_interface_debug_print("max6675: finish read test.\n");
121 (void)max6675_deinit(&gs_handle);
122
123 return 0;
124}
driver max6675 read test header file
uint8_t max6675_read(max6675_handle_t *handle, uint16_t *raw, float *temp)
read the temperature
uint8_t max6675_info(max6675_info_t *info)
get chip's information
struct max6675_info_s max6675_info_t
max6675 information structure definition
uint8_t max6675_init(max6675_handle_t *handle)
initialize the chip
struct max6675_handle_s max6675_handle_t
max6675 handle structure definition
uint8_t max6675_deinit(max6675_handle_t *handle)
close the chip
void max6675_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t max6675_interface_spi_init(void)
interface spi bus init
uint8_t max6675_interface_spi_deinit(void)
interface spi bus deinit
uint8_t max6675_interface_spi_read_cmd(uint8_t *buf, uint16_t len)
interface spi bus read command
void max6675_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t max6675_read_test(uint32_t times)
read test
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v