L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
mysensors.h
Go to the documentation of this file.
1/*
2 * mysensors.h
3 *
4 * Created on: 6. 1. 2026
5 * Author: Milan
6 *
7 * helpers for standard HAL fncs
8 * The sensors reading data.
9 */
10
11#ifndef INC_MYSENSORS_H_
12#define INC_MYSENSORS_H_
13
14#include "stm32wlxx_hal.h"
15#include "mymems.h"
16
17/**
18 * @brief State machine states for the sensor reading process.
19 *
20 * The state machine is driven either by the sequencer (timer-based) or
21 * by direct polling via sensors_Start() / sensors_Work(). It progresses
22 * sequentially through the states; completion is signalled when SENS_DONE
23 * is returned.
24 */
25typedef enum
26{
27 SENS_BEGIN = 0, /**< Entry state: I2C is initialised and the sequence is prepared */
28 SENS_INIT, /**< Sensor initialisation: each active sensor is (re-)initialised if not already */
29 SENS_START, /**< Sensors powered on (xxx_On() called for the current group) */
30 SENS_READ, /**< Data read issued (xxx_Read() called for the current group) */
31 SENS_STOP, /**< Sensors powered off (xxx_Off() called for the current group) */
32 SENS_DATAREADY, /**< All sensor data collected; ready for post-processing or LoRa uplink */
33 SENS_SERVICE, /**< Service actions executed (e.g. SPS30 fan cleaning); data may be unavailable */
34 SENS_END, /**< Sequence complete: I2C is de-initialised for power saving */
35 SENS_DONE /**< Final state: caller may read sensor data and schedule the next cycle */
37
38
39/**
40 * @brief Initialization of all sensors, must be called before for store of hi2c handler
41 * @param hi2c
42 */
43void sensors_Init(I2C_HandleTypeDef* hi2c);
44
45/**
46 * @brief the sensors sequencer initialization and set the process in sequencer
47 * - create task
48 * - create timer
49 * - process data
50 * - fire event CFG_SEQ_Task_MyLoraSend - data are ready for loraWan processing
51
52 * @param sensortAppBit - bit for task
53 * @param mylorawanAppBit - bit for event firing
54 */
55void sensorsSeq_Init(uint32_t sensortAppBit, uint32_t mylorawanAppBit);
56
57/**
58 * @brief The copying data from current sensors buffer to backUp - _bck_XXXXX
59 */
61
62/**
63 * @brief collecting sensor data into CayenneLppGetBuffer buffer for sending them via LoRa
64 * the methods works with _bck_XXXXX senzor, not with real
65 * @param sizeOut - the size(bytes) in buffer, the size is max 254, uint8_t is enough
66 * @retval address of buffer or null, if no data
67 */
68uint8_t * sensors_CayennelFromBckData(uint8_t *sizeOut);
69
70/**
71 * @brief filling the data block from sensor data - store to memory
72 * the methods works with _bck_XXXXX senzor, not with real
73 * at the begin is writte the timeout of sensor measuring in minutes * 100
74 */
76
77/**
78 * @brief reading from memory block and filling specified sensor from memory - ready for sensors_CayennelData
79 * the methods works with _bck_XXXXX senzor, not with real
80 * @retval size of total read from data block, 0 - if is other than expected data
81 */
83
84
85/**
86 * @brief the System goes to OFF mode - retiming of timer sensor reading
87 */
88void sensors_Retiming();
89
90
91/**
92 * @brief possible to I2C turn on/off - cumulative
93 */
94void i2c_OnOff(uint8_t onOff);
95
96
97/*
98 * for non sequencer ....
99 * sensors_Start();
100 * if (sensors_Read() == SENS_DONE)
101 * ; finished
102 *
103 */
104
105/**
106 * @brief - non squncer processing
107 * start of reading - prepare of internal state machine
108 */
109void sensors_Start();
110
111/**
112 * @brief - no sequncer processing
113 * reading data from sensor according to group specification
114 * @retval SENS_DONE - process of reading finished, otherwise current state of status machine
115 */
117
118
119#endif /* INC_MYSENSORS_H_ */
sens_ProcessDef_t
State machine states for the sensor reading process.
Definition mysensors.h:26
@ SENS_SERVICE
Definition mysensors.h:33
@ SENS_INIT
Definition mysensors.h:28
@ SENS_START
Definition mysensors.h:29
@ SENS_READ
Definition mysensors.h:30
@ SENS_DATAREADY
Definition mysensors.h:32
@ SENS_DONE
Definition mysensors.h:35
@ SENS_STOP
Definition mysensors.h:31
@ SENS_BEGIN
Definition mysensors.h:27
@ SENS_END
Definition mysensors.h:34
void sensors_Init(I2C_HandleTypeDef *hi2c)
Initialization of all sensors, must be called before for store of hi2c handler.
Definition mysensors.c:399
void sensors_WriteFromBckToDataBlock(mems_DataBlock_t *data)
filling the data block from sensor data - store to memory the methods works with _bck_XXXXX senzor,...
Definition mysensors.c:530
sens_ProcessDef_t sensors_Work()
no sequncer processing reading data from sensor according to group specification
Definition mysensors.c:328
void sensorsSeq_Init(uint32_t sensortAppBit, uint32_t mylorawanAppBit)
the sensors sequencer initialization and set the process in sequencer
Definition mysensors.c:436
void sensors_Start()
non squncer processing start of reading - prepare of internal state machine
Definition mysensors.c:319
uint8_t * sensors_CayennelFromBckData(uint8_t *sizeOut)
collecting sensor data into CayenneLppGetBuffer buffer for sending them via LoRa the methods works wi...
Definition mysensors.c:469
void sensors_Retiming()
the System goes to OFF mode - retiming of timer sensor reading
Definition mysensors.c:424
void i2c_OnOff(uint8_t onOff)
possible to I2C turn on/off - cumulative
Definition mysensors.c:184
void sensors_CopyToBck()
The copying data from current sensors buffer to backUp - _bck_XXXXX.
Definition mysensors.c:447
uint8_t sensors_ReadToBckFromDataBlock(const mems_DataBlock_t *data)
reading from memory block and filling specified sensor from memory - ready for sensors_CayennelData t...
Definition mysensors.c:575
Sensor data record stored as one element in the flash circular queue.
Definition mymems.h:78