mppt/App/inc/uart_send.h

62 lines
2.5 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* uart_send.h
*
* Created on: 2024年11月19日
* Author: psx
*/
#ifndef APP_INC_UART_SEND_H_
#define APP_INC_UART_SEND_H_
#include "uart_dev.h"
#define RS485_MAX_PACK_DATA_LEN 60
/* 指定对齐方式为1字节 */
#pragma pack(push,1)
typedef struct _send_data_info{
device_handle device;
uint8_t dataState; //储存数据的状态1有数据0无数据
uint8_t dataLen; //数据长度
uint8_t Counter; //已经发送的长度
uint8_t *data; //储存数据的内容
}send_data_info;
typedef struct _uart_send_info {
uint8_t insertState; //能否插入指示大于0代表能插入
uint8_t sendStateGw:1; //能否发送指示1需要发送0不需要发送
uint8_t sendStateBat:1; //能否发送指示
uint8_t sendOverStateGw:1; //发送完成指示1发送完成0发送中
uint8_t sendOverStateBat:1; //发送完成指示
uint8_t GwState:1; //向上通信485总线空闲状态1空闲0繁忙
uint8_t idleStateGw:1; //向上通信空闲状态1没数据到来0有数据到来
uint8_t BatState:1; //向下通信485总线空闲状态
uint8_t idleStateBat:1; //向下通信空闲状态
// uint8_t sendStateGw; //能否发送指示1需要发送0不需要发送
// uint8_t sendStateBat; //能否发送指示
// uint8_t sendOverStateGw; //发送完成指示1发送完成0发送中
// uint8_t sendOverStateBat; //发送完成指示
// uint8_t GwState; //向上通信485总线空闲状态1空闲0繁忙
// uint8_t idleStateGw; //向上通信空闲状态1没数据到来0有数据到来
// uint8_t BatState; //向下通信485总线空闲状态
// uint8_t idleStateBat; //向下通信空闲状态
send_data_info *insertData; //通过该指针写入数据
send_data_info *sendDataGw; //通过该指针发送数据
send_data_info *sendDataBat; //通过该指针发送数据
send_data_info data1; //储存数据的第1个位置
send_data_info data2; //储存数据的第2个位置
send_data_info data3; //储存数据的第3个位置
}uart_send_info;
/* 恢复默认的对齐设置 */
#pragma pack(pop)
extern uart_send_info uart_send;
void send_init(void);
void check_sendState(void);
void uart_interruptSend(device_handle device, uint8_t buff[], uint8_t len);
void uartDMA_Init(device_handle device, uint8_t buff[], uint8_t len);
#endif /* APP_INC_UART_SEND_H_ */