stm32-async-1wire 3.2.0
Non-blocking 1-Wire master for STM32 with DS18B20 temperature and DS2431 EEPROM drivers
Loading...
Searching...
No Matches
ow_stats.h
Go to the documentation of this file.
1
21
22#ifndef OW_STATS_H
23#define OW_STATS_H
24
25#include "ow_config.h"
26#include "ow_version.h"
27#include <stdint.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#if OW_STATS_ENABLE
34
36#define OW_STATS_MAX_SENSORS 8
37
39#define OW_STATS_HIST_BUCKETS 16
40
44typedef struct {
45 uint8_t rom[8];
46 uint8_t min_pulse;
47 uint8_t max_pulse;
48 uint32_t count;
49 uint32_t crc_err;
50 uint32_t no_presence;
51 uint32_t generic_err;
53
65
69void ow_stats_init(void);
70
82void ow_stats_capture_pulse(const volatile uint8_t* pulse, uint8_t n,
83 const uint8_t* rom);
84
90void ow_stats_count_error(int16_t error, const uint8_t* rom);
91
101
109
119uint8_t ow_stats_dump_poll(void);
120
124void ow_stats_reset(void);
125
130uint32_t ow_stats_tick(void);
131
142void ow_stats_putchar(char c);
144void ow_stats_puts(const char* s);
146void ow_stats_print_int(int32_t v);
148void ow_stats_print_hex(uint8_t v);
152
153#else /* OW_STATS_ENABLE == 0 — zero-overhead stubs */
154
155static inline void ow_stats_init(void) {}
156static inline void ow_stats_capture_pulse(const volatile uint8_t* pulse,
157 uint8_t n, const uint8_t* rom) {
158 (void)pulse;
159 (void)n;
160 (void)rom;
161}
162static inline void ow_stats_count_error(int16_t error, const uint8_t* rom) {
163 (void)error;
164 (void)rom;
165}
166static inline void ow_stats_capture_overrun(void) {}
167static inline void ow_stats_dump_start(void) {}
168static inline uint8_t ow_stats_dump_poll(void) { return 1; }
169static inline void ow_stats_reset(void) {}
170static inline uint32_t ow_stats_tick(void) { return 0; }
171
172#endif /* OW_STATS_ENABLE */
173
174#ifdef __cplusplus
175}
176#endif
177
178#endif /* OW_STATS_H */
Central compile-time configuration for the 1-Wire stack.
uint32_t ow_stats_tick(void)
Increment the cycle counter (called from the demo callback).
void ow_stats_init(void)
Zero-initialise the statistics context.
#define OW_STATS_HIST_BUCKETS
Definition ow_stats.h:39
void ow_stats_capture_overrun(void)
Record a capture overrun (TIMx_SR.CC4OF).
void ow_stats_capture_pulse(const volatile uint8_t *pulse, uint8_t n, const uint8_t *rom)
Snapshot raw pulse durations before decode_scratchpad().
void ow_stats_count_error(int16_t error, const uint8_t *rom)
Record an error event.
void ow_stats_putchar(char c)
Write a single character to the output.
void ow_stats_reset(void)
Reset all counters and histogram, keep sensor ROM table.
#define OW_STATS_MAX_SENSORS
Definition ow_stats.h:36
void ow_stats_dump_start(void)
Begin a non-blocking stats dump via UART.
void ow_stats_print_int(int32_t v)
Write a signed integer in decimal to the output.
void ow_stats_puts(const char *s)
Write a NUL-terminated string to the output.
void ow_stats_print_hex(uint8_t v)
Write a byte as two hex digits to the output.
uint8_t ow_stats_dump_poll(void)
Advance the non-blocking stats dump by one line.
void ow_stats_tx_enqueue(char c)
Enqueue a single character into the TX ring buffer (non-blocking).
Library version (semantic versioning).
Per-sensor statistics record.
Definition ow_stats.h:44
uint8_t max_pulse
Definition ow_stats.h:47
uint8_t min_pulse
Definition ow_stats.h:46
uint32_t no_presence
Definition ow_stats.h:50
uint8_t rom[8]
Definition ow_stats.h:45
uint32_t count
Definition ow_stats.h:48
uint32_t crc_err
Definition ow_stats.h:49
uint32_t generic_err
Definition ow_stats.h:51
Aggregate statistics context.
Definition ow_stats.h:57
uint32_t total_errors
Definition ow_stats.h:62
ow_stats_sensor_t sensors[OW_STATS_MAX_SENSORS]
Definition ow_stats.h:58
uint32_t histogram[OW_STATS_HIST_BUCKETS]
Definition ow_stats.h:60
uint8_t sensor_count
Definition ow_stats.h:59
uint32_t capture_overruns
Definition ow_stats.h:63
uint32_t total_cycles
Definition ow_stats.h:61