Implemented input register memory map (not used yet)
This commit is contained in:
parent
3b60430824
commit
ccc9922d0a
@ -50,22 +50,58 @@ const uint16_t tim21_prescaler = 60000-1; // 100Hz
|
||||
//const uint16_t tim21_period = 12000-1; // 60s
|
||||
const uint16_t tim21_period = 1200-1; // 6s
|
||||
//const uint16_t tim21_period = 200-1; // 1s
|
||||
|
||||
/* Input register memory map (just a suggestion, not implemented yet)
|
||||
* (All registers are 16-bit)
|
||||
* -------------------------
|
||||
*
|
||||
* 30010 : CO2 [ppm] Unsigned value in range [0,40000]
|
||||
* 30011 : T [deg_C * 10] From SHT4x; unsigned value in range [0; 1250]; e.g. 21.5 C => 215
|
||||
* 30012 : RH [%] From SHT4x; unsigned value in range [0; 100]
|
||||
*
|
||||
* Backup T and RH sensor:
|
||||
* 30013 : T [deg_C * 10] From SCD4x; unsigned value in range [0; 600]; e.g. 21.5 C => 215
|
||||
* 30014 : RH [%] From SCD4x; unsigned value in range [0; 100]
|
||||
*
|
||||
* Extended temperature range:
|
||||
* 30015 : T [deg_C * 10] From SHT4x; signed value (two's complement) in range [-400;1250]
|
||||
* 30016 : T [deg_C * 10] From SCD4x; signed value (two's complement) in range [-100;600]; e.g. -12.3 C => -123
|
||||
*
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
* - je potreba uzivateli zpristupnit T a RH z SCD4x? Pripadne je tam nechat, ale pouze jako zalozni?
|
||||
* - jaky pouzit format pro signed hodnoty? Two's complement (int16_t)? Nebo jich tam dat vic (one's complement)?
|
||||
* - omezit rozsah? Pro mereni T v interieru nema smysl +125 deg C (na to uz jsou pozarni cidla, haha)
|
||||
* - pocatecni cislo registru (30010) jsem si vymyslel. Muzeme pouzit jine, treba primo zacatek input registru (30001)
|
||||
*
|
||||
*/
|
||||
/* Input registers memory map implementation */
|
||||
union {
|
||||
struct {
|
||||
uint16_t CO2; // 30010
|
||||
uint16_t T_SHT4x; // 30011
|
||||
uint16_t RH_SHT4x; // 30012
|
||||
uint16_t T_SCD4x; // 30013
|
||||
uint16_t RH_SCD4x; // 30014
|
||||
int16_t T_SHT4x_signed; // 30015
|
||||
int16_t T_SCD4x_signed; // 30016
|
||||
};
|
||||
struct {
|
||||
uint16_t main_values[3]; // CO2, T_SHT4x, RH_SHT4x
|
||||
uint16_t backup_values[2]; // T_SCD4x, RH_SCD4x
|
||||
int16_t extented_range_values[2]; // T_SHT4x_signed, T_SCD4x_signed
|
||||
};
|
||||
struct {
|
||||
uint16_t unsigned_values[5];
|
||||
int16_t signed_values[2];
|
||||
};
|
||||
} measured_values;
|
||||
|
||||
/* Variables to store the measured data */
|
||||
int CO2, T_SCD4x, RH_SCD4x;
|
||||
int T_SHT4x, RH_SHT4x;
|
||||
uint16_t sps30_measured_data[10];
|
||||
/* TODO maybe use union for measured value?
|
||||
* this would make modbus register readout easier */
|
||||
union {
|
||||
struct {
|
||||
uint16_t CO2; // input register 30010
|
||||
uint16_t T_SCD4x; // input register 30011
|
||||
uint16_t RH_SCD4x; // input register 30012
|
||||
uint16_t T_SHT4x; // input register 30013
|
||||
uint16_t RH_SHT4x; // input register 30014
|
||||
};
|
||||
uint16_t array[5];
|
||||
} measured_values;
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
@ -191,10 +227,9 @@ int main(void)
|
||||
* processing the message: this can be done by disabling RX interrupt */
|
||||
LL_LPUART_DisableIT_RXNE(LPUART1);
|
||||
modbus_slave_process_msg(modbus_buffer, lpuart1_rx_message_len);
|
||||
LL_LPUART_EnableIT_RXNE(LPUART1);
|
||||
|
||||
/* Reset the RX DONE flag */
|
||||
lpuart1_rx_done = 0;
|
||||
LL_LPUART_EnableIT_RXNE(LPUART1);
|
||||
}
|
||||
|
||||
/* It is time for measurement */
|
||||
|
Loading…
Reference in New Issue
Block a user