12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #ifndef __CJT188_H
- #define __CJT188_H
- #include "stm32f2xx.h"
- #include "stdint.h"
- #include "usart.h"
- #include "stdbool.h"
- #define _CJT_RXSIZE 64
- #define _CTJ_CTRL_GPIO USART_485_DE_GPIO_PORT
- #define _CTJ_CTRL_PIN USART_485_DE_PIN
- typedef struct
- {
- uint16_t rxIndex;
- uint8_t rxBuf[_CJT_RXSIZE];
- uint32_t rxTime;
- uint8_t txBusy;
- uint32_t timeout;
- uint8_t done;
- }CTJBus_t;
- #define gettick( ) ( xTaskGetTickCount() )
- // 初始化
- bool cjt_init(uint32_t timeout);
- // 回调函数
- void cjt_callback(UART_HandleTypeDef *husart);
- // 接收函数
- uint16_t cjt_receiveRaw(uint32_t timeout);
- // 发送函数
- bool cjt_sendRaw(uint8_t *data, uint16_t size, uint32_t timeout);
- // 读取数据
- bool cjt_read_meter_data(uint8_t* slaveAddress, double* data, uint8_t protocol);
- // 读取地址
- bool cjt_read_addr(uint8_t *data);
- // 设置地址
- bool cjt_set_addr(uint8_t *addr);
- double data_translate_to_float(uint8_t* msg);
- #endif
|