Compare commits
2 Commits
fd6cf82bd3
...
4f7d2bd49b
Author | SHA1 | Date |
---|---|---|
|
4f7d2bd49b | |
|
152d6d4ec1 |
|
@ -5,4 +5,16 @@
|
||||||
|
|
||||||
extern uint16_t checkModebusCrc(uint8_t *arr_buff, uint8_t len);
|
extern uint16_t checkModebusCrc(uint8_t *arr_buff, uint8_t len);
|
||||||
|
|
||||||
|
// void downSensorDataAnalysis(device_handle device);
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t getTickDiff(uint32_t lastTick);
|
||||||
|
|
||||||
|
void J1_SensorDataAnalysis(void);
|
||||||
|
void J2_SensorDataAnalysis(void);
|
||||||
|
void J3_SensorDataAnalysis(void);
|
||||||
|
void J4_SensorDataAnalysis(void);
|
||||||
|
void J5_0_SensorDataAnalysis(void);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,22 +1,390 @@
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
|
||||||
#include "downUartParse.h"
|
#include "downUartParse.h"
|
||||||
|
#include "upUartParse.h"
|
||||||
|
#include "queueUart.h"
|
||||||
|
|
||||||
/* 1秒的节拍数 */
|
// /* 1秒的节拍数 */
|
||||||
#define tick_1S configTICK_RATE_HZ
|
// #define tick_1S configTICK_RATE_HZ
|
||||||
|
|
||||||
/* 状态机 */
|
|
||||||
typedef enum {
|
|
||||||
wait = 0, /* 串口状态机初始状态 */
|
|
||||||
startFlag, /* 接收到帧头 */
|
|
||||||
// address, /* 设备地址 */
|
|
||||||
functionCode, /* 接收到功能码 */
|
|
||||||
dataLen, /* 接收到数据长度 */
|
|
||||||
crcCheckBitGW, /* 接收到校验位 */
|
|
||||||
endFlagGW, /* 接收到帧尾 */
|
|
||||||
} uartStateMachine;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// /* 状态机 */
|
||||||
|
// typedef enum {
|
||||||
|
// wait = 0, /* 串口状态机初始状态 */
|
||||||
|
// startFlag, /* 接收到帧头 */
|
||||||
|
// // address, /* 设备地址 */
|
||||||
|
// functionCode, /* 接收到功能码 */
|
||||||
|
// dataLen, /* 接收到数据长度 */
|
||||||
|
// crcCheckBitGW, /* 接收到校验位 */
|
||||||
|
// endFlagGW, /* 接收到帧尾 */
|
||||||
|
// } uartStateMachine;
|
||||||
|
|
||||||
|
|
||||||
|
/* 储存gw485数据 */
|
||||||
|
static uint8_t J1_485RxBuffer[128];
|
||||||
|
static uint16_t J1_485RxBufferIndex = 0;
|
||||||
|
static uint8_t J2_485RxBuffer[128];
|
||||||
|
static uint16_t J2_485RxBufferIndex = 0;
|
||||||
|
static uint8_t J3_485RxBuffer[128];
|
||||||
|
static uint16_t J3_485RxBufferIndex = 0;
|
||||||
|
static uint8_t J4_485RxBuffer[128];
|
||||||
|
static uint16_t J4_485RxBufferIndex = 0;
|
||||||
|
static uint8_t J5_0_485RxBuffer[128];
|
||||||
|
static uint16_t J5_0_485RxBufferIndex = 0;
|
||||||
|
|
||||||
|
/* 100ms */
|
||||||
|
#define delayTick 50
|
||||||
|
#define maxdataLen 100
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 接收J1口传来的数据
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void J1_SensorDataAnalysis(void)
|
||||||
|
{
|
||||||
|
static uint32_t tick;
|
||||||
|
|
||||||
|
if (J1_485RxBufferIndex == 0) {
|
||||||
|
tick = xTaskGetTickCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 单次进入最多6ms(3个时钟周期),串口中有数据 */
|
||||||
|
uint32_t nowTick = xTaskGetTickCount();
|
||||||
|
while ((getTickDiff(nowTick) < 3)
|
||||||
|
&& (uart_dev_char_present(g_J1_uart6_handle) == 1)
|
||||||
|
&& (maxdataLen > J1_485RxBufferIndex)) {
|
||||||
|
J1_485RxBuffer[J1_485RxBufferIndex++] = uart_dev_in_char(g_J1_uart6_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 当时间到达或者数据量到达,就打包发送给智能模块 */
|
||||||
|
if ((J1_485RxBufferIndex >= maxdataLen) || (getTickDiff(tick) > delayTick)) {
|
||||||
|
uint32_t tempLen = 6 + J1_485RxBufferIndex + queueUartSendInfoSize;
|
||||||
|
if (xPortGetFreeHeapSize() < tempLen + 1024) {
|
||||||
|
J1_485RxBufferIndex = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t *Buff = (uint8_t *)pvPortMalloc(tempLen);
|
||||||
|
queueUartSendInfo *sendBuff = (queueUartSendInfo *)Buff;
|
||||||
|
sendBuff->length = 6 + J1_485RxBufferIndex;
|
||||||
|
sendBuff->data = Buff + sizeof(queueUartSendInfo);
|
||||||
|
uint8_t *send = sendBuff->data;
|
||||||
|
|
||||||
|
/* 起始标志 */
|
||||||
|
*send = 'S';
|
||||||
|
*(send + 1) = 'L';
|
||||||
|
|
||||||
|
/* 端口号 */
|
||||||
|
send += 2;
|
||||||
|
*send = 1;
|
||||||
|
|
||||||
|
/* 数据包长度 */
|
||||||
|
send += 1;
|
||||||
|
*send = (uint8_t)(J1_485RxBufferIndex >> 8);
|
||||||
|
*(send + 1) = (uint8_t)(J1_485RxBufferIndex);
|
||||||
|
|
||||||
|
/* 数据包 */
|
||||||
|
send += 2;
|
||||||
|
memcpy((char *)send, (char *)J1_485RxBuffer, J1_485RxBufferIndex);
|
||||||
|
|
||||||
|
/* 结束标志 */
|
||||||
|
send += J1_485RxBufferIndex;
|
||||||
|
*send = 0x17;
|
||||||
|
|
||||||
|
/* 队列中有空间,则将发送数据 */
|
||||||
|
if (uxQueueSpacesAvailable(upward_uart_Queue)) {
|
||||||
|
xQueueSend(upward_uart_Queue, &Buff, 10);
|
||||||
|
}
|
||||||
|
/* 队列无空间,将数据丢弃 */
|
||||||
|
else {
|
||||||
|
vPortFree(Buff);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 发送完成或遇到问题,将buff中的数据清零 */
|
||||||
|
J1_485RxBufferIndex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 接收J2口传来的数据
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void J2_SensorDataAnalysis(void)
|
||||||
|
{
|
||||||
|
static uint32_t tick;
|
||||||
|
|
||||||
|
if (J2_485RxBufferIndex == 0) {
|
||||||
|
tick = xTaskGetTickCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 单次进入最多6ms(3个时钟周期),串口中有数据 */
|
||||||
|
uint32_t nowTick = xTaskGetTickCount();
|
||||||
|
while ((getTickDiff(nowTick) < 3)
|
||||||
|
&& (uart_dev_char_present(g_J2_uart7_handle) == 1)
|
||||||
|
&& (maxdataLen > J2_485RxBufferIndex)) {
|
||||||
|
J2_485RxBuffer[J2_485RxBufferIndex++] = uart_dev_in_char(g_J2_uart7_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 当时间到达或者数据量到达,就打包发送给智能模块 */
|
||||||
|
if ((J2_485RxBufferIndex >= maxdataLen) || (getTickDiff(tick) > delayTick)) {
|
||||||
|
|
||||||
|
uint32_t tempLen = 6 + J2_485RxBufferIndex + queueUartSendInfoSize;
|
||||||
|
if (xPortGetFreeHeapSize() < tempLen + 1024) {
|
||||||
|
J2_485RxBufferIndex = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t *Buff = (uint8_t *)pvPortMalloc(tempLen);
|
||||||
|
queueUartSendInfo *sendBuff = (queueUartSendInfo *)Buff;
|
||||||
|
sendBuff->length = 6 + J2_485RxBufferIndex;
|
||||||
|
sendBuff->data = Buff + sizeof(queueUartSendInfo);
|
||||||
|
uint8_t *send = sendBuff->data;
|
||||||
|
|
||||||
|
/* 起始标志 */
|
||||||
|
*send = 'S';
|
||||||
|
*(send + 1) = 'L';
|
||||||
|
|
||||||
|
/* 端口号 */
|
||||||
|
send += 2;
|
||||||
|
*send = 2;
|
||||||
|
|
||||||
|
/* 数据包长度 */
|
||||||
|
send += 1;
|
||||||
|
*send = (uint8_t)(J2_485RxBufferIndex >> 8);
|
||||||
|
*(send + 1) = (uint8_t)(J2_485RxBufferIndex);
|
||||||
|
|
||||||
|
/* 数据包 */
|
||||||
|
send += 2;
|
||||||
|
memcpy((char *)send, (char *)J2_485RxBuffer, J2_485RxBufferIndex);
|
||||||
|
|
||||||
|
/* 结束标志 */
|
||||||
|
send += J2_485RxBufferIndex;
|
||||||
|
*send = 0x17;
|
||||||
|
|
||||||
|
/* 队列中有空间,则将发送数据 */
|
||||||
|
if (uxQueueSpacesAvailable(upward_uart_Queue)) {
|
||||||
|
xQueueSend(upward_uart_Queue, &Buff, 10);
|
||||||
|
}
|
||||||
|
/* 队列无空间,将数据丢弃 */
|
||||||
|
else {
|
||||||
|
vPortFree(Buff);
|
||||||
|
}
|
||||||
|
|
||||||
|
J2_485RxBufferIndex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 接收J3口传来的数据
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void J3_SensorDataAnalysis(void)
|
||||||
|
{
|
||||||
|
static uint32_t tick;
|
||||||
|
|
||||||
|
if (J3_485RxBufferIndex == 0) {
|
||||||
|
tick = xTaskGetTickCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 单次进入最多6ms(3个时钟周期),串口中有数据 */
|
||||||
|
uint32_t nowTick = xTaskGetTickCount();
|
||||||
|
while ((getTickDiff(nowTick) < 3)
|
||||||
|
&& (uart_dev_char_present(g_J3_usart2_handle) == 1)
|
||||||
|
&& (maxdataLen > J3_485RxBufferIndex)) {
|
||||||
|
J3_485RxBuffer[J3_485RxBufferIndex++] = uart_dev_in_char(g_J3_usart2_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 当时间到达或者数据量到达,就打包发送给智能模块 */
|
||||||
|
if ((J3_485RxBufferIndex >= maxdataLen) || (getTickDiff(tick) > delayTick)) {
|
||||||
|
|
||||||
|
uint32_t tempLen = 6 + J3_485RxBufferIndex + queueUartSendInfoSize;
|
||||||
|
if (xPortGetFreeHeapSize() < tempLen + 1024) {
|
||||||
|
J3_485RxBufferIndex = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t *Buff = (uint8_t *)pvPortMalloc(tempLen);
|
||||||
|
queueUartSendInfo *sendBuff = (queueUartSendInfo *)Buff;
|
||||||
|
sendBuff->length = 6 + J3_485RxBufferIndex;
|
||||||
|
sendBuff->data = Buff + sizeof(queueUartSendInfo);
|
||||||
|
uint8_t *send = sendBuff->data;
|
||||||
|
|
||||||
|
/* 起始标志 */
|
||||||
|
*send = 'S';
|
||||||
|
*(send + 1) = 'L';
|
||||||
|
|
||||||
|
/* 端口号 */
|
||||||
|
send += 2;
|
||||||
|
*send = 3;
|
||||||
|
|
||||||
|
/* 数据包长度 */
|
||||||
|
send += 1;
|
||||||
|
*send = (uint8_t)(J3_485RxBufferIndex >> 8);
|
||||||
|
*(send + 1) = (uint8_t)(J3_485RxBufferIndex);
|
||||||
|
|
||||||
|
/* 数据包 */
|
||||||
|
send += 2;
|
||||||
|
memcpy((char *)send, (char *)J3_485RxBuffer, J3_485RxBufferIndex);
|
||||||
|
|
||||||
|
/* 结束标志 */
|
||||||
|
send += J3_485RxBufferIndex;
|
||||||
|
*send = 0x17;
|
||||||
|
|
||||||
|
/* 队列中有空间,则将发送数据 */
|
||||||
|
if (uxQueueSpacesAvailable(upward_uart_Queue)) {
|
||||||
|
xQueueSend(upward_uart_Queue, &Buff, 10);
|
||||||
|
}
|
||||||
|
/* 队列无空间,将数据丢弃 */
|
||||||
|
else {
|
||||||
|
vPortFree(Buff);
|
||||||
|
}
|
||||||
|
|
||||||
|
J3_485RxBufferIndex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 接收J4口传来的数据
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void J4_SensorDataAnalysis(void)
|
||||||
|
{
|
||||||
|
static uint32_t tick;
|
||||||
|
|
||||||
|
if (J4_485RxBufferIndex == 0) {
|
||||||
|
tick = xTaskGetTickCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 单次进入最多6ms(3个时钟周期),串口中有数据 */
|
||||||
|
uint32_t nowTick = xTaskGetTickCount();
|
||||||
|
while ((getTickDiff(nowTick) < 3)
|
||||||
|
&& (uart_dev_char_present(g_J4_uart8_handle) == 1)
|
||||||
|
&& (maxdataLen > J4_485RxBufferIndex)) {
|
||||||
|
J4_485RxBuffer[J4_485RxBufferIndex++] = uart_dev_in_char(g_J4_uart8_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 当时间到达或者数据量到达,就打包发送给智能模块 */
|
||||||
|
if ((J4_485RxBufferIndex >= maxdataLen) || (getTickDiff(tick) > delayTick)) {
|
||||||
|
|
||||||
|
uint32_t tempLen = 6 + J4_485RxBufferIndex + queueUartSendInfoSize;
|
||||||
|
if (xPortGetFreeHeapSize() < tempLen + 1024) {
|
||||||
|
J4_485RxBufferIndex = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t *Buff = (uint8_t *)pvPortMalloc(tempLen);
|
||||||
|
queueUartSendInfo *sendBuff = (queueUartSendInfo *)Buff;
|
||||||
|
sendBuff->length = 6 + J4_485RxBufferIndex;
|
||||||
|
sendBuff->data = Buff + sizeof(queueUartSendInfo);
|
||||||
|
uint8_t *send = sendBuff->data;
|
||||||
|
|
||||||
|
/* 起始标志 */
|
||||||
|
*send = 'S';
|
||||||
|
*(send + 1) = 'L';
|
||||||
|
|
||||||
|
/* 端口号 */
|
||||||
|
send += 2;
|
||||||
|
*send = 4;
|
||||||
|
|
||||||
|
/* 数据包长度 */
|
||||||
|
send += 1;
|
||||||
|
*send = (uint8_t)(J4_485RxBufferIndex >> 8);
|
||||||
|
*(send + 1) = (uint8_t)(J4_485RxBufferIndex);
|
||||||
|
|
||||||
|
/* 数据包 */
|
||||||
|
send += 2;
|
||||||
|
memcpy((char *)send, (char *)J4_485RxBuffer, J4_485RxBufferIndex);
|
||||||
|
|
||||||
|
/* 结束标志 */
|
||||||
|
send += J4_485RxBufferIndex;
|
||||||
|
*send = 0x17;
|
||||||
|
|
||||||
|
/* 队列中有空间,则将发送数据 */
|
||||||
|
if (uxQueueSpacesAvailable(upward_uart_Queue)) {
|
||||||
|
xQueueSend(upward_uart_Queue, &Buff, 10);
|
||||||
|
}
|
||||||
|
/* 队列无空间,将数据丢弃 */
|
||||||
|
else {
|
||||||
|
vPortFree(Buff);
|
||||||
|
}
|
||||||
|
|
||||||
|
J4_485RxBufferIndex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 接收J5_0口传来的数据
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void J5_0_SensorDataAnalysis(void)
|
||||||
|
{
|
||||||
|
static uint32_t tick;
|
||||||
|
|
||||||
|
if (J5_0_485RxBufferIndex == 0) {
|
||||||
|
tick = xTaskGetTickCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 单次进入最多6ms(3个时钟周期),串口中有数据 */
|
||||||
|
uint32_t nowTick = xTaskGetTickCount();
|
||||||
|
while ((getTickDiff(nowTick) < 3)
|
||||||
|
&& (uart_dev_char_present(g_J5_0_usart3_handle) == 1)
|
||||||
|
&& (maxdataLen > J5_0_485RxBufferIndex)) {
|
||||||
|
J5_0_485RxBuffer[J5_0_485RxBufferIndex++] = uart_dev_in_char(g_J5_0_usart3_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 当时间到达或者数据量到达,就打包发送给智能模块 */
|
||||||
|
if ((J5_0_485RxBufferIndex >= maxdataLen) || (getTickDiff(tick) > delayTick)) {
|
||||||
|
|
||||||
|
uint32_t tempLen = 6 + J5_0_485RxBufferIndex + queueUartSendInfoSize;
|
||||||
|
if (xPortGetFreeHeapSize() < tempLen + 1024) {
|
||||||
|
J5_0_485RxBufferIndex = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t *Buff = (uint8_t *)pvPortMalloc(tempLen);
|
||||||
|
queueUartSendInfo *sendBuff = (queueUartSendInfo *)Buff;
|
||||||
|
sendBuff->length = 6 + J5_0_485RxBufferIndex;
|
||||||
|
sendBuff->data = Buff + sizeof(queueUartSendInfo);
|
||||||
|
uint8_t *send = sendBuff->data;
|
||||||
|
|
||||||
|
/* 起始标志 */
|
||||||
|
*send = 'S';
|
||||||
|
*(send + 1) = 'L';
|
||||||
|
|
||||||
|
/* 端口号 */
|
||||||
|
send += 2;
|
||||||
|
*send = getConnectPort();
|
||||||
|
|
||||||
|
/* 数据包长度 */
|
||||||
|
send += 1;
|
||||||
|
*send = (uint8_t)(J5_0_485RxBufferIndex >> 8);
|
||||||
|
*(send + 1) = (uint8_t)(J5_0_485RxBufferIndex);
|
||||||
|
|
||||||
|
/* 数据包 */
|
||||||
|
send += 2;
|
||||||
|
memcpy((char *)send, (char *)J5_0_485RxBuffer, J5_0_485RxBufferIndex + 1);
|
||||||
|
|
||||||
|
/* 结束标志 */
|
||||||
|
send += J5_0_485RxBufferIndex;
|
||||||
|
*send = 0x17;
|
||||||
|
|
||||||
|
/* 队列中有空间,则将发送数据 */
|
||||||
|
if (uxQueueSpacesAvailable(upward_uart_Queue)) {
|
||||||
|
xQueueSend(upward_uart_Queue, &Buff, 10);
|
||||||
|
}
|
||||||
|
/* 队列无空间,将数据丢弃 */
|
||||||
|
else {
|
||||||
|
vPortFree(Buff);
|
||||||
|
}
|
||||||
|
|
||||||
|
J5_0_485RxBufferIndex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "parameter.h"
|
#include "parameter.h"
|
||||||
#include "busIdleDetection.h"
|
#include "busIdleDetection.h"
|
||||||
|
#include "downUartParse.h"
|
||||||
|
|
||||||
|
|
||||||
#define Common_TASK_PRIO 2
|
#define Common_TASK_PRIO 2
|
||||||
|
@ -23,7 +24,7 @@
|
||||||
#define UpReceive_STK_SIZE 256
|
#define UpReceive_STK_SIZE 256
|
||||||
|
|
||||||
#define DownReceive_TASK_PRIO 4
|
#define DownReceive_TASK_PRIO 4
|
||||||
#define DownReceive_STK_SIZE 256
|
#define DownReceive_STK_SIZE 1024
|
||||||
|
|
||||||
#define FreeMemory_TASK_PRIO 5
|
#define FreeMemory_TASK_PRIO 5
|
||||||
#define FreeMemory_STK_SIZE 256
|
#define FreeMemory_STK_SIZE 256
|
||||||
|
@ -54,6 +55,7 @@ static void common_Task(void *pvParameters)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
uint16_t HeapSizeNum = 0;
|
uint16_t HeapSizeNum = 0;
|
||||||
|
uint16_t LedNum = 0;
|
||||||
|
|
||||||
/* 用于绝对延时 */
|
/* 用于绝对延时 */
|
||||||
TickType_t xLastWakeTime;
|
TickType_t xLastWakeTime;
|
||||||
|
@ -61,6 +63,8 @@ static void common_Task(void *pvParameters)
|
||||||
// 初始化 xLastWakeTime
|
// 初始化 xLastWakeTime
|
||||||
xLastWakeTime = xTaskGetTickCount();
|
xLastWakeTime = xTaskGetTickCount();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
// uint8_t *Buff = (uint8_t *)pvPortMalloc(200);
|
// uint8_t *Buff = (uint8_t *)pvPortMalloc(200);
|
||||||
// if (Buff == NULL) {
|
// if (Buff == NULL) {
|
||||||
|
@ -71,7 +75,7 @@ static void common_Task(void *pvParameters)
|
||||||
// queueUartSendInfo *sendBuff = (queueUartSendInfo *)Buff;
|
// queueUartSendInfo *sendBuff = (queueUartSendInfo *)Buff;
|
||||||
// sendBuff->length = sizeof("hello world\n");
|
// sendBuff->length = sizeof("hello world\n");
|
||||||
// sendBuff->data = Buff + sizeof(queueUartSendInfo);
|
// sendBuff->data = Buff + sizeof(queueUartSendInfo);
|
||||||
// strlcpy((char *)sendBuff->data, "hello world\n", sizeof("hello world\n"));
|
// memcpy((char *)sendBuff->data, "hello world\n", sizeof("hello world\n"));
|
||||||
|
|
||||||
// xQueueSend(upward_uart_Queue, &Buff, 10);
|
// xQueueSend(upward_uart_Queue, &Buff, 10);
|
||||||
|
|
||||||
|
@ -90,7 +94,7 @@ static void common_Task(void *pvParameters)
|
||||||
// sendBuff->length = sizeof("hello world\n");
|
// sendBuff->length = sizeof("hello world\n");
|
||||||
// sendBuff->data = Buff + sizeof(queueTimeShareSendInfo);
|
// sendBuff->data = Buff + sizeof(queueTimeShareSendInfo);
|
||||||
// sendBuff->connectPort = connectJ0;
|
// sendBuff->connectPort = connectJ0;
|
||||||
// strlcpy((char *)sendBuff->data, "hello world\n", sizeof("hello world\n"));
|
// memcpy((char *)sendBuff->data, "hello world\n", sizeof("hello world\n"));
|
||||||
|
|
||||||
// xQueueSend(J5_0_485_Queue, &Buff, 10);
|
// xQueueSend(J5_0_485_Queue, &Buff, 10);
|
||||||
|
|
||||||
|
@ -100,12 +104,19 @@ static void common_Task(void *pvParameters)
|
||||||
setWorkVoltage(getInVoltage());
|
setWorkVoltage(getInVoltage());
|
||||||
|
|
||||||
/* 当内存碎片过多时,后续可以在其中处理 */
|
/* 当内存碎片过多时,后续可以在其中处理 */
|
||||||
if (HeapSizeNum == 25) {
|
if (HeapSizeNum++ == 25) {
|
||||||
HeapSizeNum = 0;
|
HeapSizeNum = 0;
|
||||||
log_info("xPortGetFreeHeapSize : %d",xPortGetFreeHeapSize());
|
log_info("xPortGetFreeHeapSize : %d",xPortGetFreeHeapSize());
|
||||||
|
// log_info("getRs485State : %d\n", getRs485State(g_J5_0_usart3_handle));
|
||||||
|
// log_info("getUartSendState : %d\n", getUartSendState(g_J5_0_usart3_handle));
|
||||||
|
// log_info("getBUSIDLEFlag : %d\n", getBUSIDLEFlag(g_J5_0_usart3_handle));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LedNum++ == 3) {
|
||||||
|
LedNum = 0;
|
||||||
|
ledToggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapSizeNum++;
|
|
||||||
vTaskDelayUntil(&xLastWakeTime, xFrequency);
|
vTaskDelayUntil(&xLastWakeTime, xFrequency);
|
||||||
// vTaskDelay(200);
|
// vTaskDelay(200);
|
||||||
}
|
}
|
||||||
|
@ -137,14 +148,19 @@ static void UpReceive_Task(void *pvParameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 解析传感率发送来的数据
|
* @brief 解析传感器发送来的数据
|
||||||
* @param
|
* @param
|
||||||
* @retval
|
* @retval
|
||||||
*/
|
*/
|
||||||
static void DownReceive_Task(void *pvParameters)
|
static void DownReceive_Task(void *pvParameters)
|
||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
vTaskDelay(1000);
|
J1_SensorDataAnalysis();
|
||||||
|
J2_SensorDataAnalysis();
|
||||||
|
J3_SensorDataAnalysis();
|
||||||
|
J4_SensorDataAnalysis();
|
||||||
|
J5_0_SensorDataAnalysis();
|
||||||
|
vTaskDelay(5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,6 +206,12 @@ void startApp(void)
|
||||||
binarySemaphoreInit();
|
binarySemaphoreInit();
|
||||||
softwareTimeInit();
|
softwareTimeInit();
|
||||||
|
|
||||||
|
Delay_Ms(1000);
|
||||||
|
set_485_Read();
|
||||||
|
|
||||||
|
writePwrCtrlState(Android_PwrCtrl, GPIO_SET);
|
||||||
|
// writePwrCtrlState(J1_PwrCtrl, GPIO_SET);
|
||||||
|
|
||||||
/* create task */
|
/* create task */
|
||||||
xTaskCreate((TaskFunction_t )common_Task,
|
xTaskCreate((TaskFunction_t )common_Task,
|
||||||
(const char* )"commonTask",
|
(const char* )"commonTask",
|
||||||
|
@ -226,7 +248,6 @@ void startApp(void)
|
||||||
(UBaseType_t )FreeMemory_TASK_PRIO,
|
(UBaseType_t )FreeMemory_TASK_PRIO,
|
||||||
(TaskHandle_t* )&FreeMemory_Handler);
|
(TaskHandle_t* )&FreeMemory_Handler);
|
||||||
|
|
||||||
|
|
||||||
vTaskStartScheduler();
|
vTaskStartScheduler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ void readConfigParameter(void)
|
||||||
parameter.J2_485_Baud = 9600;
|
parameter.J2_485_Baud = 9600;
|
||||||
parameter.J3_485_Baud = 9600;
|
parameter.J3_485_Baud = 9600;
|
||||||
parameter.J4_485_Baud = 9600;
|
parameter.J4_485_Baud = 9600;
|
||||||
parameter.J5_0_485_Baud = 9600;
|
parameter.J5_0_485_Baud = 115200;
|
||||||
parameter.upWard_Uart_Baud = 115200;
|
parameter.upWard_Uart_Baud = 115200;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,6 +158,7 @@ void uartQueueSend(void)
|
||||||
if (!flag) {
|
if (!flag) {
|
||||||
/* 延时三个系统节拍 */
|
/* 延时三个系统节拍 */
|
||||||
vTaskDelay(3);
|
vTaskDelay(3);
|
||||||
|
log_info("getRs485State : %d\n", getRs485State(g_J5_0_usart3_handle));
|
||||||
}
|
}
|
||||||
flag = 0;
|
flag = 0;
|
||||||
}
|
}
|
||||||
|
@ -215,6 +216,8 @@ void binarySemaphoreFreeMemory(void)
|
||||||
if (xActivatedMember == J1_BinarySemaphore) {
|
if (xActivatedMember == J1_BinarySemaphore) {
|
||||||
// 执行相关逻辑
|
// 执行相关逻辑
|
||||||
vPortFree(queueRecvData.J1_485_data);
|
vPortFree(queueRecvData.J1_485_data);
|
||||||
|
vTaskDelay(1);
|
||||||
|
readJ1_485;
|
||||||
setJ1_485_SendState(0);
|
setJ1_485_SendState(0);
|
||||||
// 处理二值信号量事件
|
// 处理二值信号量事件
|
||||||
xSemaphoreTake(J1_BinarySemaphore, 0);
|
xSemaphoreTake(J1_BinarySemaphore, 0);
|
||||||
|
@ -222,24 +225,32 @@ void binarySemaphoreFreeMemory(void)
|
||||||
|
|
||||||
else if (xActivatedMember == J2_BinarySemaphore) {
|
else if (xActivatedMember == J2_BinarySemaphore) {
|
||||||
vPortFree(queueRecvData.J2_485_data);
|
vPortFree(queueRecvData.J2_485_data);
|
||||||
|
vTaskDelay(1);
|
||||||
|
readJ2_485;
|
||||||
setJ2_485_SendState(0);
|
setJ2_485_SendState(0);
|
||||||
xSemaphoreTake(J2_BinarySemaphore, 0);
|
xSemaphoreTake(J2_BinarySemaphore, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (xActivatedMember == J3_BinarySemaphore) {
|
else if (xActivatedMember == J3_BinarySemaphore) {
|
||||||
vPortFree(queueRecvData.J3_485_data);
|
vPortFree(queueRecvData.J3_485_data);
|
||||||
|
vTaskDelay(1);
|
||||||
|
readJ3_485;
|
||||||
setJ3_485_SendState(0);
|
setJ3_485_SendState(0);
|
||||||
xSemaphoreTake(J3_BinarySemaphore, 0);
|
xSemaphoreTake(J3_BinarySemaphore, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (xActivatedMember == J4_BinarySemaphore) {
|
else if (xActivatedMember == J4_BinarySemaphore) {
|
||||||
vPortFree(queueRecvData.J4_485_data);
|
vPortFree(queueRecvData.J4_485_data);
|
||||||
|
vTaskDelay(1);
|
||||||
|
readJ4_485;
|
||||||
setJ4_485_SendState(0);
|
setJ4_485_SendState(0);
|
||||||
xSemaphoreTake(J4_BinarySemaphore, 0);
|
xSemaphoreTake(J4_BinarySemaphore, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (xActivatedMember == J5_0_BinarySemaphore) {
|
else if (xActivatedMember == J5_0_BinarySemaphore) {
|
||||||
vPortFree(queueRecvData.J5_0_485_data);
|
vPortFree(queueRecvData.J5_0_485_data);
|
||||||
|
vTaskDelay(1);
|
||||||
|
readJ5_0_485;
|
||||||
setJ5_0_485_SendState(0);
|
setJ5_0_485_SendState(0);
|
||||||
xSemaphoreTake(J5_0_BinarySemaphore, 0);
|
xSemaphoreTake(J5_0_BinarySemaphore, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -300,6 +300,7 @@ uint16_t ReadRegisterPort9_Power(void *pMsg)
|
||||||
uint16_t WriteRegisterPort1_Power(void *pMsg)
|
uint16_t WriteRegisterPort1_Power(void *pMsg)
|
||||||
{
|
{
|
||||||
writePwrCtrlState(J1_PwrCtrl, (uint8_t)(*(uint16_t *)pMsg));
|
writePwrCtrlState(J1_PwrCtrl, (uint8_t)(*(uint16_t *)pMsg));
|
||||||
|
log_info("state %d\n", (uint8_t)(*(uint16_t *)pMsg));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,14 +476,14 @@ uint8_t analysisFunctionCodeGW(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gw485RxBufferIndex >= 5 && gw485RxBuffer[2] == SL_Function_Code_Write_Register) {
|
// if (gw485RxBufferIndex >= 5 && gw485RxBuffer[2] == SL_Function_Code_Write_Register) {
|
||||||
/* дÈë¼Ä´æÆ÷ÆðʼµØÖ· */
|
// /* 写入寄存器起始地址 */
|
||||||
uint16_t startResAddr = ((gw485RxBuffer[3] << 8) | gw485RxBuffer[4]);
|
// uint16_t startResAddr = ((gw485RxBuffer[3] << 8) | gw485RxBuffer[4]);
|
||||||
if (startResAddr < maxStartWriteResAddr) {
|
// if (startResAddr < maxStartWriteResAddr) {
|
||||||
state = writeRegStartAddressGW;
|
// state = writeRegStartAddressGW;
|
||||||
return TRUE;
|
// return TRUE;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* 解析配置文件下发帧数 */
|
/* 解析配置文件下发帧数 */
|
||||||
if ((gw485RxBufferIndex >= 5) && (gw485RxBuffer[2] == SL_Function_Code_Distribution_Profile)) {
|
if ((gw485RxBufferIndex >= 5) && (gw485RxBuffer[2] == SL_Function_Code_Distribution_Profile)) {
|
||||||
|
@ -522,16 +523,17 @@ uint8_t analysisFunctionCodeGW(void)
|
||||||
#define ReadRegStartAddressGWMaxLen 7
|
#define ReadRegStartAddressGWMaxLen 7
|
||||||
uint8_t analysisReadRegStartAddressGW(void)
|
uint8_t analysisReadRegStartAddressGW(void)
|
||||||
{
|
{
|
||||||
if (gw485RxBufferIndex >= 7) {
|
if (gw485RxBufferIndex >= ReadRegStartAddressGWMaxLen) {
|
||||||
/* 读取寄存器起始地址 */
|
/* 读取寄存器起始地址 */
|
||||||
uint16_t resAddrLen = ((gw485RxBuffer[5] << 8) | gw485RxBuffer[6]);
|
uint16_t resAddrLen = ((gw485RxBuffer[5] << 8) | gw485RxBuffer[6]);
|
||||||
if (resAddrLen < maxReadResAddrLen) {
|
if (resAddrLen < maxReadResAddrLen) {
|
||||||
state = readRegStartNumberGW;
|
state = readRegStartNumberGW;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
log_error("resAddrLen : %d \n", resAddrLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gw485RxBufferIndex < functionCodeGWMaxLen) {
|
if (gw485RxBufferIndex < ReadRegStartAddressGWMaxLen) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
state = wait;
|
state = wait;
|
||||||
|
@ -580,7 +582,7 @@ uint8_t analysisCrcCheckBitGW(void)
|
||||||
/* 结束标志校验校验 */
|
/* 结束标志校验校验 */
|
||||||
if (gw485RxBufferIndex == frameLength) {
|
if (gw485RxBufferIndex == frameLength) {
|
||||||
if (gw485RxBuffer[frameLength - 1] == 0x16) {
|
if (gw485RxBuffer[frameLength - 1] == 0x16) {
|
||||||
state = endFlagSL;
|
state = endFlagGW;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -639,7 +641,7 @@ uint8_t analysisWriteRegStartAddressGW(void)
|
||||||
uint16_t resAddrLen = ((gw485RxBuffer[5] << 8) | gw485RxBuffer[6]);
|
uint16_t resAddrLen = ((gw485RxBuffer[5] << 8) | gw485RxBuffer[6]);
|
||||||
if (resAddrLen < maxReadResAddrLen) {
|
if (resAddrLen < maxReadResAddrLen) {
|
||||||
frameLength = 10 + 2 * resAddrLen;
|
frameLength = 10 + 2 * resAddrLen;
|
||||||
state = readRegStartNumberGW;
|
state = writeRegStartNumberGW;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -665,12 +667,14 @@ uint8_t analysisWriteRegStartNumberGW(void)
|
||||||
/* crc校验 */
|
/* crc校验 */
|
||||||
if (gw485RxBufferIndex >= WriteRegStartNumberGWMaxLen) {
|
if (gw485RxBufferIndex >= WriteRegStartNumberGWMaxLen) {
|
||||||
uint16_t tempCrc = 0;
|
uint16_t tempCrc = 0;
|
||||||
tempCrc = (gw485RxBuffer[frameLength - 3] << 8) | gw485RxBuffer[frameLength - 2];
|
tempCrc = ((uint16_t)gw485RxBuffer[frameLength - 3] << 8) | (uint16_t)gw485RxBuffer[frameLength - 2];
|
||||||
|
|
||||||
if (tempCrc == checkModebusCrc(gw485RxBuffer, frameLength - 3)) {
|
if (tempCrc == checkModebusCrc(gw485RxBuffer, frameLength - 3)) {
|
||||||
state = crcCheckBitGW;
|
state = crcCheckBitGW;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
// log_error("tempCrc : %x \n", tempCrc);
|
||||||
|
// log_error("checkModebusCrc : %x \n", checkModebusCrc(gw485RxBuffer, frameLength - 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gw485RxBufferIndex < WriteRegStartNumberGWMaxLen) {
|
if (gw485RxBufferIndex < WriteRegStartNumberGWMaxLen) {
|
||||||
|
@ -879,39 +883,56 @@ uint8_t analysisEndFlagSL(void)
|
||||||
if (gw485RxBuffer[2] > 0 && gw485RxBuffer[2] < 5) {
|
if (gw485RxBuffer[2] > 0 && gw485RxBuffer[2] < 5) {
|
||||||
Buff = (uint8_t *)pvPortMalloc(tempLen + queueUartSendInfoSize);
|
Buff = (uint8_t *)pvPortMalloc(tempLen + queueUartSendInfoSize);
|
||||||
queueUartSendInfo *sendBuff = (queueUartSendInfo *)Buff;
|
queueUartSendInfo *sendBuff = (queueUartSendInfo *)Buff;
|
||||||
sendBuff->length = tempLen + 1;
|
sendBuff->length = tempLen;
|
||||||
sendBuff->data = Buff + queueUartSendInfoSize;
|
sendBuff->data = Buff + queueUartSendInfoSize;
|
||||||
strlcpy((char *)sendBuff->data, (char *)&gw485RxBuffer[5], tempLen + 1);
|
memcpy((char *)sendBuff->data, (char *)&gw485RxBuffer[5], tempLen);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Buff = (uint8_t *)pvPortMalloc(tempLen + queueTimeShareSendInfoSize);
|
Buff = (uint8_t *)pvPortMalloc(tempLen + queueTimeShareSendInfoSize);
|
||||||
queueTimeShareSendInfo *sendBuff = (queueTimeShareSendInfo *)Buff;
|
queueTimeShareSendInfo *sendBuff = (queueTimeShareSendInfo *)Buff;
|
||||||
sendBuff->length = tempLen + 1;
|
sendBuff->length = tempLen;
|
||||||
sendBuff->data = Buff + queueTimeShareSendInfoSize;
|
sendBuff->data = Buff + queueTimeShareSendInfoSize;
|
||||||
strlcpy((char *)sendBuff->data, (char *)&gw485RxBuffer[5], tempLen + 1);
|
memcpy((char *)sendBuff->data, (char *)&gw485RxBuffer[5], tempLen);
|
||||||
|
// printf("\n\n\n\n\n%s\n", (char *)gw485RxBuffer);
|
||||||
|
// printf("%s\n%d\n\n\n\n\n\n", sendBuff->data, tempLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* 通过不同的端口将数据发送到不同的地方 */
|
/* 通过不同的端口将数据发送到不同的地方 */
|
||||||
if (gw485RxBuffer[2] == 1) {
|
if (gw485RxBuffer[2] == 1) {
|
||||||
if (uxQueueSpacesAvailable(J1_485_Queue)) {
|
if (uxQueueSpacesAvailable(J1_485_Queue)) {
|
||||||
xQueueSend(J1_485_Queue, &Buff, 10);
|
xQueueSend(J1_485_Queue, &Buff, 10);
|
||||||
}
|
}
|
||||||
|
/* 队列中无空间,释放内存,退出 */
|
||||||
|
else {
|
||||||
|
vPortFree(Buff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (gw485RxBuffer[2] == 2) {
|
else if (gw485RxBuffer[2] == 2) {
|
||||||
if (uxQueueSpacesAvailable(J2_485_Queue)) {
|
if (uxQueueSpacesAvailable(J2_485_Queue)) {
|
||||||
xQueueSend(J2_485_Queue, &Buff, 10);
|
xQueueSend(J2_485_Queue, &Buff, 10);
|
||||||
}
|
}
|
||||||
|
/* 队列中无空间,释放内存,退出 */
|
||||||
|
else {
|
||||||
|
vPortFree(Buff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (gw485RxBuffer[2] == 3) {
|
else if (gw485RxBuffer[2] == 3) {
|
||||||
if (uxQueueSpacesAvailable(J3_485_Queue)) {
|
if (uxQueueSpacesAvailable(J3_485_Queue)) {
|
||||||
xQueueSend(J3_485_Queue, &Buff, 10);
|
xQueueSend(J3_485_Queue, &Buff, 10);
|
||||||
}
|
}
|
||||||
|
/* 队列中无空间,释放内存,退出 */
|
||||||
|
else {
|
||||||
|
vPortFree(Buff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (gw485RxBuffer[2] == 4) {
|
else if (gw485RxBuffer[2] == 4) {
|
||||||
if (uxQueueSpacesAvailable(J4_485_Queue)) {
|
if (uxQueueSpacesAvailable(J4_485_Queue)) {
|
||||||
xQueueSend(J4_485_Queue, &Buff, 10);
|
xQueueSend(J4_485_Queue, &Buff, 10);
|
||||||
}
|
}
|
||||||
|
/* 队列中无空间,释放内存,退出 */
|
||||||
|
else {
|
||||||
|
vPortFree(Buff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (gw485RxBuffer[2] == 5) {
|
else if (gw485RxBuffer[2] == 5) {
|
||||||
queueTimeShareSendInfo *sendBuff = (queueTimeShareSendInfo *)Buff;
|
queueTimeShareSendInfo *sendBuff = (queueTimeShareSendInfo *)Buff;
|
||||||
|
@ -919,6 +940,10 @@ uint8_t analysisEndFlagSL(void)
|
||||||
if (uxQueueSpacesAvailable(J5_0_485_Queue)) {
|
if (uxQueueSpacesAvailable(J5_0_485_Queue)) {
|
||||||
xQueueSend(J5_0_485_Queue, &Buff, 10);
|
xQueueSend(J5_0_485_Queue, &Buff, 10);
|
||||||
}
|
}
|
||||||
|
/* 队列中无空间,释放内存,退出 */
|
||||||
|
else {
|
||||||
|
vPortFree(Buff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (gw485RxBuffer[2] == 6) {
|
else if (gw485RxBuffer[2] == 6) {
|
||||||
queueTimeShareSendInfo *sendBuff = (queueTimeShareSendInfo *)Buff;
|
queueTimeShareSendInfo *sendBuff = (queueTimeShareSendInfo *)Buff;
|
||||||
|
@ -926,6 +951,10 @@ uint8_t analysisEndFlagSL(void)
|
||||||
if (uxQueueSpacesAvailable(J5_0_485_Queue)) {
|
if (uxQueueSpacesAvailable(J5_0_485_Queue)) {
|
||||||
xQueueSend(J5_0_485_Queue, &Buff, 10);
|
xQueueSend(J5_0_485_Queue, &Buff, 10);
|
||||||
}
|
}
|
||||||
|
/* 队列中无空间,释放内存,退出 */
|
||||||
|
else {
|
||||||
|
vPortFree(Buff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (gw485RxBuffer[2] == 7) {
|
else if (gw485RxBuffer[2] == 7) {
|
||||||
queueTimeShareSendInfo *sendBuff = (queueTimeShareSendInfo *)Buff;
|
queueTimeShareSendInfo *sendBuff = (queueTimeShareSendInfo *)Buff;
|
||||||
|
@ -933,6 +962,10 @@ uint8_t analysisEndFlagSL(void)
|
||||||
if (uxQueueSpacesAvailable(J5_0_485_Queue)) {
|
if (uxQueueSpacesAvailable(J5_0_485_Queue)) {
|
||||||
xQueueSend(J5_0_485_Queue, &Buff, 10);
|
xQueueSend(J5_0_485_Queue, &Buff, 10);
|
||||||
}
|
}
|
||||||
|
/* 队列中无空间,释放内存,退出 */
|
||||||
|
else {
|
||||||
|
vPortFree(Buff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (gw485RxBuffer[2] == 8) {
|
else if (gw485RxBuffer[2] == 8) {
|
||||||
queueTimeShareSendInfo *sendBuff = (queueTimeShareSendInfo *)Buff;
|
queueTimeShareSendInfo *sendBuff = (queueTimeShareSendInfo *)Buff;
|
||||||
|
@ -940,6 +973,10 @@ uint8_t analysisEndFlagSL(void)
|
||||||
if (uxQueueSpacesAvailable(J5_0_485_Queue)) {
|
if (uxQueueSpacesAvailable(J5_0_485_Queue)) {
|
||||||
xQueueSend(J5_0_485_Queue, &Buff, 10);
|
xQueueSend(J5_0_485_Queue, &Buff, 10);
|
||||||
}
|
}
|
||||||
|
/* 队列中无空间,释放内存,退出 */
|
||||||
|
else {
|
||||||
|
vPortFree(Buff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (gw485RxBuffer[2] == 9) {
|
else if (gw485RxBuffer[2] == 9) {
|
||||||
queueTimeShareSendInfo *sendBuff = (queueTimeShareSendInfo *)Buff;
|
queueTimeShareSendInfo *sendBuff = (queueTimeShareSendInfo *)Buff;
|
||||||
|
@ -947,6 +984,10 @@ uint8_t analysisEndFlagSL(void)
|
||||||
if (uxQueueSpacesAvailable(J5_0_485_Queue)) {
|
if (uxQueueSpacesAvailable(J5_0_485_Queue)) {
|
||||||
xQueueSend(J5_0_485_Queue, &Buff, 10);
|
xQueueSend(J5_0_485_Queue, &Buff, 10);
|
||||||
}
|
}
|
||||||
|
/* 队列中无空间,释放内存,退出 */
|
||||||
|
else {
|
||||||
|
vPortFree(Buff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (gw485RxBuffer[2] == 0) {
|
else if (gw485RxBuffer[2] == 0) {
|
||||||
queueTimeShareSendInfo *sendBuff = (queueTimeShareSendInfo *)Buff;
|
queueTimeShareSendInfo *sendBuff = (queueTimeShareSendInfo *)Buff;
|
||||||
|
@ -954,6 +995,10 @@ uint8_t analysisEndFlagSL(void)
|
||||||
if (uxQueueSpacesAvailable(J5_0_485_Queue)) {
|
if (uxQueueSpacesAvailable(J5_0_485_Queue)) {
|
||||||
xQueueSend(J5_0_485_Queue, &Buff, 10);
|
xQueueSend(J5_0_485_Queue, &Buff, 10);
|
||||||
}
|
}
|
||||||
|
/* 队列中无空间,释放内存,退出 */
|
||||||
|
else {
|
||||||
|
vPortFree(Buff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
@ -989,6 +1034,7 @@ void GW_MsgProcFunc_Read_Register(device_handle device,uint8_t *buff, uint16_t b
|
||||||
if (xPortGetFreeHeapSize() < tempLen + 1024) {
|
if (xPortGetFreeHeapSize() < tempLen + 1024) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *Buff = (uint8_t *)pvPortMalloc(tempLen);
|
uint8_t *Buff = (uint8_t *)pvPortMalloc(tempLen);
|
||||||
queueUartSendInfo *sendBuff = (queueUartSendInfo *)Buff;
|
queueUartSendInfo *sendBuff = (queueUartSendInfo *)Buff;
|
||||||
sendBuff->length = 8 + 2 * Register_Number_16;
|
sendBuff->length = 8 + 2 * Register_Number_16;
|
||||||
|
@ -1034,6 +1080,9 @@ void GW_MsgProcFunc_Read_Register(device_handle device,uint8_t *buff, uint16_t b
|
||||||
if (uxQueueSpacesAvailable(upward_uart_Queue)) {
|
if (uxQueueSpacesAvailable(upward_uart_Queue)) {
|
||||||
xQueueSend(upward_uart_Queue, &Buff, 10);
|
xQueueSend(upward_uart_Queue, &Buff, 10);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
vPortFree(Buff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1049,7 +1098,7 @@ void GW_MsgProcFunc_Write_Register(device_handle device, void *pMsg, uint32_t Ms
|
||||||
/* 将指令中的数据读取出来 */
|
/* 将指令中的数据读取出来 */
|
||||||
uint16_t content[maxWriteResAddrLen] = {0};
|
uint16_t content[maxWriteResAddrLen] = {0};
|
||||||
for (uint16_t var = 0; var < Register_Number; var++) {
|
for (uint16_t var = 0; var < Register_Number; var++) {
|
||||||
content[var] = gw485RxBuffer[14 + 2 * var] << 8 | gw485RxBuffer[14 + 2 * var + 1];
|
content[var] = gw485RxBuffer[7 + 2 * var] << 8 | gw485RxBuffer[7 + 2 * var + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 将数据写入到寄存器中 */
|
/* 将数据写入到寄存器中 */
|
||||||
|
|
|
@ -28,5 +28,6 @@ void writePwrCtrlState(uint8_t type, uint8_t State);
|
||||||
uint8_t readPwrCtrlState(uint8_t type);
|
uint8_t readPwrCtrlState(uint8_t type);
|
||||||
void startResetAndroidModule(void);
|
void startResetAndroidModule(void);
|
||||||
void stopResetAndroidModule(void);
|
void stopResetAndroidModule(void);
|
||||||
|
void ledToggle(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -102,8 +102,8 @@ void setUpward_uart_SendState(uint8_t state);
|
||||||
|
|
||||||
/* J5_0连接到哪个端口 */
|
/* J5_0连接到哪个端口 */
|
||||||
typedef enum _connectPortEnum {
|
typedef enum _connectPortEnum {
|
||||||
connectJ0 = 1,
|
connectJ0 = 0,
|
||||||
connectJ5,
|
connectJ5 = 5,
|
||||||
connectJ6,
|
connectJ6,
|
||||||
connectJ7,
|
connectJ7,
|
||||||
connectJ8,
|
connectJ8,
|
||||||
|
|
|
@ -106,3 +106,14 @@ void stopResetAndroidModule(void)
|
||||||
{
|
{
|
||||||
HD_GPIO_Write(GPIO_PwrKey_GPIO_PROT, GPIO_PwrKey_GPIO_PIN, GPIO_RESET);
|
HD_GPIO_Write(GPIO_PwrKey_GPIO_PROT, GPIO_PwrKey_GPIO_PIN, GPIO_RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ·×ªLEDµÆµçƽ
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void ledToggle(void)
|
||||||
|
{
|
||||||
|
HD_GPIO_Write(LED_GPIO_PROT, LED_GPIO_PIN
|
||||||
|
, !(HD_OutputGPIO_Read(LED_GPIO_PROT, LED_GPIO_PIN)));
|
||||||
|
}
|
||||||
|
|
|
@ -490,7 +490,6 @@ void J3_Interrupt()
|
||||||
USART_ITConfig(J3_USART, USART_IT_TXE, DISABLE);
|
USART_ITConfig(J3_USART, USART_IT_TXE, DISABLE);
|
||||||
// setJ3_485_SendState(0);
|
// setJ3_485_SendState(0);
|
||||||
J3_485_IN_TXE();
|
J3_485_IN_TXE();
|
||||||
readJ3_485;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
USART_SendData(J3_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
USART_SendData(J3_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||||
|
@ -500,6 +499,8 @@ void J3_Interrupt()
|
||||||
#ifdef RS485BUSIDLE1
|
#ifdef RS485BUSIDLE1
|
||||||
/* 空闲中断 */
|
/* 空闲中断 */
|
||||||
if (USART_GetITStatus(J3_USART, USART_IT_IDLE) != RESET) {
|
if (USART_GetITStatus(J3_USART, USART_IT_IDLE) != RESET) {
|
||||||
|
J3_USART->STATR;
|
||||||
|
J3_USART->DATAR;
|
||||||
J3_485_IN_IDLE();
|
J3_485_IN_IDLE();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -529,7 +530,6 @@ void J5_0_Interrupt()
|
||||||
USART_ITConfig(J5_0_USART, USART_IT_TXE, DISABLE);
|
USART_ITConfig(J5_0_USART, USART_IT_TXE, DISABLE);
|
||||||
// setJ5_0_485_SendState(0);
|
// setJ5_0_485_SendState(0);
|
||||||
J5_0_485_IN_TXE();
|
J5_0_485_IN_TXE();
|
||||||
readJ5_0_485;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
USART_SendData(J5_0_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
USART_SendData(J5_0_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||||
|
@ -539,6 +539,8 @@ void J5_0_Interrupt()
|
||||||
#ifdef RS485BUSIDLE1
|
#ifdef RS485BUSIDLE1
|
||||||
/* 空闲中断 */
|
/* 空闲中断 */
|
||||||
if (USART_GetITStatus(J5_0_USART, USART_IT_IDLE) != RESET) {
|
if (USART_GetITStatus(J5_0_USART, USART_IT_IDLE) != RESET) {
|
||||||
|
J5_0_USART->STATR;
|
||||||
|
J5_0_USART->DATAR;
|
||||||
J5_0_485_IN_IDLE();
|
J5_0_485_IN_IDLE();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -594,7 +596,6 @@ void J1_Interrupt()
|
||||||
USART_ITConfig(J1_USART, USART_IT_TXE, DISABLE);
|
USART_ITConfig(J1_USART, USART_IT_TXE, DISABLE);
|
||||||
// setJ1_485_SendState(0);
|
// setJ1_485_SendState(0);
|
||||||
J1_485_IN_TXE();
|
J1_485_IN_TXE();
|
||||||
readJ1_485;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
USART_SendData(J1_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
USART_SendData(J1_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||||
|
@ -604,6 +605,8 @@ void J1_Interrupt()
|
||||||
#ifdef RS485BUSIDLE1
|
#ifdef RS485BUSIDLE1
|
||||||
/* 空闲中断 */
|
/* 空闲中断 */
|
||||||
if (USART_GetITStatus(J1_USART, USART_IT_IDLE) != RESET) {
|
if (USART_GetITStatus(J1_USART, USART_IT_IDLE) != RESET) {
|
||||||
|
J1_USART->STATR;
|
||||||
|
J1_USART->DATAR;
|
||||||
J1_485_IN_IDLE();
|
J1_485_IN_IDLE();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -633,7 +636,6 @@ void J2_Interrupt()
|
||||||
USART_ITConfig(J2_USART, USART_IT_TXE, DISABLE);
|
USART_ITConfig(J2_USART, USART_IT_TXE, DISABLE);
|
||||||
// setJ2_485_SendState(0);
|
// setJ2_485_SendState(0);
|
||||||
J2_485_IN_TXE();
|
J2_485_IN_TXE();
|
||||||
readJ2_485;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
USART_SendData(J2_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
USART_SendData(J2_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||||
|
@ -643,6 +645,8 @@ void J2_Interrupt()
|
||||||
#ifdef RS485BUSIDLE1
|
#ifdef RS485BUSIDLE1
|
||||||
/* 空闲中断 */
|
/* 空闲中断 */
|
||||||
if (USART_GetITStatus(J2_USART, USART_IT_IDLE) != RESET) {
|
if (USART_GetITStatus(J2_USART, USART_IT_IDLE) != RESET) {
|
||||||
|
J2_USART->STATR;
|
||||||
|
J2_USART->DATAR;
|
||||||
J2_485_IN_IDLE();
|
J2_485_IN_IDLE();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -672,7 +676,6 @@ void J4_Interrupt()
|
||||||
USART_ITConfig(J4_USART, USART_IT_TXE, DISABLE);
|
USART_ITConfig(J4_USART, USART_IT_TXE, DISABLE);
|
||||||
// setJ4_485_SendState(0);
|
// setJ4_485_SendState(0);
|
||||||
J4_485_IN_TXE();
|
J4_485_IN_TXE();
|
||||||
readJ4_485;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
USART_SendData(J4_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
USART_SendData(J4_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||||
|
@ -682,6 +685,8 @@ void J4_Interrupt()
|
||||||
#ifdef RS485BUSIDLE1
|
#ifdef RS485BUSIDLE1
|
||||||
/* 空闲中断 */
|
/* 空闲中断 */
|
||||||
if (USART_GetITStatus(J4_USART, USART_IT_IDLE) != RESET) {
|
if (USART_GetITStatus(J4_USART, USART_IT_IDLE) != RESET) {
|
||||||
|
J4_USART->STATR;
|
||||||
|
J4_USART->DATAR;
|
||||||
J4_485_IN_IDLE();
|
J4_485_IN_IDLE();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -871,7 +876,7 @@ void setBUSIDLEFlag(device_handle device, uint8_t state)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (state != 0 || state != 1) {
|
if (state != 0 && state != 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,10 @@
|
||||||
#define WDI_GPIO_PROT GPIOC
|
#define WDI_GPIO_PROT GPIOC
|
||||||
#define WDI_GPIO_PIN GPIO_Pin_13
|
#define WDI_GPIO_PIN GPIO_Pin_13
|
||||||
|
|
||||||
|
/* LED多신 */
|
||||||
|
#define LED_GPIO_PROT GPIOB
|
||||||
|
#define LED_GPIO_PIN GPIO_Pin_8
|
||||||
|
|
||||||
#define GPIOTypeDef GPIO_TypeDef
|
#define GPIOTypeDef GPIO_TypeDef
|
||||||
#define GPIOPin uint16_t
|
#define GPIOPin uint16_t
|
||||||
|
|
||||||
|
@ -51,4 +55,5 @@ void HD_GPIO_Write(GPIOTypeDef *GPIOx, GPIOPin GPIO_Pin, BitOperation BitVal);
|
||||||
uint8_t HD_InputGPIO_Read(GPIOTypeDef *GPIOx, GPIOPin GPIO_Pin);
|
uint8_t HD_InputGPIO_Read(GPIOTypeDef *GPIOx, GPIOPin GPIO_Pin);
|
||||||
uint8_t HD_OutputGPIO_Read(GPIOTypeDef *GPIOx, GPIOPin GPIO_Pin);
|
uint8_t HD_OutputGPIO_Read(GPIOTypeDef *GPIOx, GPIOPin GPIO_Pin);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -51,6 +51,9 @@
|
||||||
#define write485 Bit_SET
|
#define write485 Bit_SET
|
||||||
#define read485 Bit_RESET
|
#define read485 Bit_RESET
|
||||||
|
|
||||||
|
|
||||||
|
void set_485_Read(void);
|
||||||
|
|
||||||
/* J1_UART6 */
|
/* J1_UART6 */
|
||||||
void J1_485_Init(uint32_t baud);
|
void J1_485_Init(uint32_t baud);
|
||||||
#define readJ1_485 GPIO_WriteBit(J1_DE_PROT, J1_DE_PIN, read485);
|
#define readJ1_485 GPIO_WriteBit(J1_DE_PROT, J1_DE_PIN, read485);
|
||||||
|
|
|
@ -58,6 +58,12 @@ void HD_GPIO_Init(void)
|
||||||
GPIO_InitStructure.GPIO_Pin = WDI_GPIO_PIN;
|
GPIO_InitStructure.GPIO_Pin = WDI_GPIO_PIN;
|
||||||
GPIO_Init(WDI_GPIO_PROT, &GPIO_InitStructure);
|
GPIO_Init(WDI_GPIO_PROT, &GPIO_InitStructure);
|
||||||
GPIO_WriteBit(WDI_GPIO_PROT, WDI_GPIO_PIN, Bit_SET);
|
GPIO_WriteBit(WDI_GPIO_PROT, WDI_GPIO_PIN, Bit_SET);
|
||||||
|
|
||||||
|
/* LEDÒý½Å */
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
|
||||||
|
GPIO_InitStructure.GPIO_Pin = LED_GPIO_PIN;
|
||||||
|
GPIO_Init(LED_GPIO_PROT, &GPIO_InitStructure);
|
||||||
|
GPIO_WriteBit(LED_GPIO_PROT, LED_GPIO_PIN, Bit_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,6 +14,22 @@ void UART8_IRQHandler(void) __attribute__((interrupt()));
|
||||||
#define write Bit_SET
|
#define write Bit_SET
|
||||||
#define read Bit_RESET
|
#define read Bit_RESET
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief 设置所有485状态为读
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void set_485_Read(void)
|
||||||
|
{
|
||||||
|
readJ1_485;
|
||||||
|
readJ2_485;
|
||||||
|
readJ3_485;
|
||||||
|
readJ4_485;
|
||||||
|
readJ5_0_485;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief 初始化UART6对应的J1_485,默认为接收
|
* @brief 初始化UART6对应的J1_485,默认为接收
|
||||||
* @param baud 波特率
|
* @param baud 波特率
|
||||||
|
@ -29,7 +45,8 @@ void J1_485_Init(uint32_t baud)
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
||||||
GPIO_Init(J1_DE_PROT, &GPIO_InitStructure);
|
GPIO_Init(J1_DE_PROT, &GPIO_InitStructure);
|
||||||
readJ1_485;
|
// readJ1_485;
|
||||||
|
writeJ1_485;
|
||||||
|
|
||||||
USART_InitTypeDef USART_InitStructure;
|
USART_InitTypeDef USART_InitStructure;
|
||||||
NVIC_InitTypeDef NVIC_InitStructure;
|
NVIC_InitTypeDef NVIC_InitStructure;
|
||||||
|
@ -83,7 +100,8 @@ void J2_485_Init(uint32_t baud)
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
||||||
GPIO_Init(J2_DE_PROT, &GPIO_InitStructure);
|
GPIO_Init(J2_DE_PROT, &GPIO_InitStructure);
|
||||||
readJ2_485;
|
// readJ2_485;
|
||||||
|
writeJ2_485;
|
||||||
|
|
||||||
USART_InitTypeDef USART_InitStructure;
|
USART_InitTypeDef USART_InitStructure;
|
||||||
NVIC_InitTypeDef NVIC_InitStructure;
|
NVIC_InitTypeDef NVIC_InitStructure;
|
||||||
|
@ -136,7 +154,8 @@ void J3_485_Init(uint32_t baud)
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
||||||
GPIO_Init(J3_DE_PROT, &GPIO_InitStructure);
|
GPIO_Init(J3_DE_PROT, &GPIO_InitStructure);
|
||||||
readJ3_485;
|
// readJ3_485;
|
||||||
|
writeJ3_485;
|
||||||
|
|
||||||
USART_InitTypeDef USART_InitStructure;
|
USART_InitTypeDef USART_InitStructure;
|
||||||
NVIC_InitTypeDef NVIC_InitStructure;
|
NVIC_InitTypeDef NVIC_InitStructure;
|
||||||
|
@ -189,7 +208,8 @@ void J4_485_Init(uint32_t baud)
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
||||||
GPIO_Init(J4_DE_PROT, &GPIO_InitStructure);
|
GPIO_Init(J4_DE_PROT, &GPIO_InitStructure);
|
||||||
readJ4_485;
|
// readJ4_485;
|
||||||
|
writeJ4_485;
|
||||||
|
|
||||||
USART_InitTypeDef USART_InitStructure;
|
USART_InitTypeDef USART_InitStructure;
|
||||||
NVIC_InitTypeDef NVIC_InitStructure;
|
NVIC_InitTypeDef NVIC_InitStructure;
|
||||||
|
@ -242,7 +262,8 @@ void J5_0_485_Init(uint32_t baud)
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
||||||
GPIO_Init(J5_0_DE_PROT, &GPIO_InitStructure);
|
GPIO_Init(J5_0_DE_PROT, &GPIO_InitStructure);
|
||||||
readJ5_0_485;
|
// readJ5_0_485;
|
||||||
|
writeJ5_0_485;
|
||||||
// writeJ5_0_485;
|
// writeJ5_0_485;
|
||||||
GPIO_InitStructure.GPIO_Pin = J5_0_A_PIN;
|
GPIO_InitStructure.GPIO_Pin = J5_0_A_PIN;
|
||||||
GPIO_Init(J5_0_DE_PROT, &GPIO_InitStructure);
|
GPIO_Init(J5_0_DE_PROT, &GPIO_InitStructure);
|
||||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
19
README.md
19
README.md
|
@ -113,7 +113,26 @@ uint8_t *Buff = (uint8_t *)pvPortMalloc(200);
|
||||||
|
|
||||||
## 串口接收传感器数据
|
## 串口接收传感器数据
|
||||||
|
|
||||||
|
100ms后,向上丢数据,或者空闲中断后向上丢数据
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 测试指令
|
||||||
|
|
||||||
|
#### 查询端口0电源数据
|
||||||
|
|
||||||
|
>53 4C 00 00 11 53 4C 11 11 11 11 11 11 11 30 01 00 00 0C 23 68 16 17
|
||||||
|
|
||||||
|
#### 查询端口1倾角传感器数据
|
||||||
|
|
||||||
|
> 53 4C 01 00 09 4A 59 09 00 02 01 01 05 b5 17
|
||||||
|
|
||||||
|
#### 打开端口1电源
|
||||||
|
|
||||||
|
>47 57 10 00 03 00 01 00 01 18 9C 16
|
||||||
|
|
||||||
|
#### 查看端口1电源
|
||||||
|
|
||||||
|
>47 57 30 00 03 00 01 27 50 16
|
||||||
|
|
Loading…
Reference in New Issue