2020-10-28 19:40:08 +01:00
|
|
|
#ifndef _MBUSCOMM_H_
|
|
|
|
#define _MBUSCOMM_H_
|
|
|
|
|
2020-11-02 15:04:53 +01:00
|
|
|
#include <main.h>
|
2020-10-28 19:40:08 +01:00
|
|
|
#include <stdint.h>
|
2020-11-03 15:08:04 +01:00
|
|
|
#include <stdbool.h>
|
2020-11-02 19:23:11 +01:00
|
|
|
|
|
|
|
|
2020-11-03 14:31:59 +01:00
|
|
|
#define MBUSDEVICE_NAMELENGTH 24
|
2020-11-03 14:00:54 +01:00
|
|
|
#define MBUSDEVICE_NUM_OF_CONSIDEREDFIELDS 4
|
|
|
|
typedef struct {
|
|
|
|
char deviceName[MBUSDEVICE_NAMELENGTH];
|
|
|
|
uint8_t address;
|
2020-11-18 13:42:55 +01:00
|
|
|
int8_t consideredField[MBUSDEVICE_NUM_OF_CONSIDEREDFIELDS];
|
2020-11-03 14:37:58 +01:00
|
|
|
uint32_t requests;
|
|
|
|
uint32_t failures;
|
2020-11-03 15:08:04 +01:00
|
|
|
int32_t period;
|
|
|
|
int32_t delay;
|
|
|
|
bool waiting;
|
2020-11-03 14:00:54 +01:00
|
|
|
} t_mbusDevice;
|
2020-11-02 19:23:11 +01:00
|
|
|
|
2020-11-03 14:31:59 +01:00
|
|
|
typedef enum {
|
|
|
|
MBCRR_TRIGGERED = 0,
|
2020-11-16 17:53:18 +01:00
|
|
|
MBCRR_BUSY = 1,
|
|
|
|
MBCRR_DISABLED = 2
|
2020-11-03 14:31:59 +01:00
|
|
|
} e_mbusCommRequestResult;
|
|
|
|
|
2020-11-06 21:16:17 +01:00
|
|
|
typedef struct {
|
|
|
|
uint32_t requestCnt;
|
|
|
|
uint32_t errorCnt;
|
|
|
|
} t_mbusCommStats;
|
|
|
|
|
2020-11-17 15:38:11 +01:00
|
|
|
// e_mbusCommRequestResult mbusCommRequest(t_mbusDevice *mbusDevice);
|
|
|
|
void mbusCommInit();
|
2020-11-16 17:53:18 +01:00
|
|
|
void mbusCommEnable(bool enable);
|
2020-11-02 15:04:53 +01:00
|
|
|
void mbusCommTxCpltCallback(UART_HandleTypeDef *huart);
|
2020-11-02 15:41:07 +01:00
|
|
|
void mbusCommRxCpltCallback(UART_HandleTypeDef *huart);
|
2020-11-06 21:16:17 +01:00
|
|
|
void mbusCommSetStats(t_mbusCommStats stats);
|
|
|
|
t_mbusCommStats *mbusCommGetStats();
|
2020-10-28 19:40:08 +01:00
|
|
|
|
|
|
|
#endif // _MBUSCOMM_H_
|