44 lines
1018 B
C
44 lines
1018 B
C
#ifndef _MBUSCOMM_H_
|
|
#define _MBUSCOMM_H_
|
|
|
|
#include <main.h>
|
|
#include <stdint.h>
|
|
|
|
|
|
typedef struct {
|
|
uint8_t start1;
|
|
uint8_t length1;
|
|
uint8_t length2;
|
|
uint8_t start2;
|
|
uint8_t l;
|
|
uint8_t c;
|
|
uint8_t a;
|
|
uint8_t ci;
|
|
uint8_t *userdata;
|
|
uint8_t chksum;
|
|
uint8_t stop;
|
|
} t_longframe;
|
|
|
|
typedef enum {
|
|
MBCR_SUCCESS = 0,
|
|
MBCR_ERROR_TIMEOUT,
|
|
MBCR_ERROR_LOOP_FAILURE,
|
|
MBCR_ERROR_TX_REG_UNACCESSIBLE,
|
|
MBCR_ERROR_OUT_OF_MEMORY__FRAME,
|
|
MBCR_ERROR_OUT_OF_MEMORY__USERDATA,
|
|
MBCR_ERROR_STATE_ENGINE__START1,
|
|
MBCR_ERROR_STATE_ENGINE__LENGTH1,
|
|
MBCR_ERROR_STATE_ENGINE__LENGTH2,
|
|
MBCR_ERROR_STATE_ENGINE__START2,
|
|
MBCR_ERROR_STATE_ENGINE__INVALID_CHKSUM,
|
|
MBCR_ERROR_STATE_ENGINE__STOP,
|
|
MBCR_ERROR_STATE_ENGINE__ILLEGAL_STATE,
|
|
MBCR_ERROR_STATE_ENGINE__UNKNOWN
|
|
} t_mbusCommResult;
|
|
|
|
void mbusCommRequest(uint8_t cmd, uint8_t addr);
|
|
void mbusCommTxCpltCallback(UART_HandleTypeDef *huart);
|
|
void mbusCommRxCpltCallback(UART_HandleTypeDef *huart);
|
|
|
|
#endif // _MBUSCOMM_H_
|