灯丝可点亮
This commit is contained in:
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
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
#include "main.h"
|
||||
#include "main.h"
|
||||
#include "cmsis_os.h"
|
||||
#include "cpy_prot.h"
|
||||
#include "Param/param.h"
|
||||
@@ -135,38 +135,6 @@ static int daq_recv_packet(uint16_t data_len) {
|
||||
}
|
||||
|
||||
|
||||
static int makeDataPacket(uint8_t *data)
|
||||
{
|
||||
uint16_t ulPos = 0;
|
||||
uint16_t i = 0;
|
||||
uint16_t ulLen = adcDataQueueLen();
|
||||
|
||||
if (ulLen < 5)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
adcDataUnitDef *ptRetData = (adcDataUnitDef *)(data + 4);
|
||||
|
||||
for (i = 0; i < ulLen; ++i)
|
||||
{
|
||||
ulPos = gtAdcDataQueue.ulReadPos + i;
|
||||
if (ulPos >= ADC_QUEUE_LEN)
|
||||
{
|
||||
ulPos -= ADC_QUEUE_LEN;
|
||||
}
|
||||
volatile adcDataUnitDef *ptData = >AdcDataQueue.atQueue[ulPos];
|
||||
memcpy(&ptRetData[i], (uint8_t *)ptData, sizeof(adcDataUnitDef));
|
||||
}
|
||||
|
||||
uint16_t usDataLen = ulLen * sizeof(adcDataUnitDef);
|
||||
|
||||
*((uint16_t *)(data + 0)) = usDataLen; ///< 长度
|
||||
*((uint16_t *)(data + 2)) = crc16(data + 4, usDataLen); ///< 校验
|
||||
|
||||
return usDataLen + 4;
|
||||
}
|
||||
|
||||
|
||||
int cpyProtPacketHandle(uint8_t cmd, const uint8_t *data, uint16_t len) {
|
||||
// 处理接收到的数据包
|
||||
@@ -204,34 +172,6 @@ int cpyProtPacketHandle(uint8_t cmd, const uint8_t *data, uint16_t len) {
|
||||
daq_send_packet(cmd | CPY_PROT_CMD_ACK, (const uint8_t *)gptSysParam, sizeof(sysParamDef));
|
||||
break;
|
||||
|
||||
case CPY_PROT_CMD_SAMPLE_LEN:
|
||||
{
|
||||
uint16_t usLen = adcDataQueueLen();
|
||||
|
||||
daq_send_packet(cmd | CPY_PROT_CMD_ACK, (const uint8_t *)&usLen, sizeof(uint16_t));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case CPY_PROT_CMD_SAMPLE_DATA:
|
||||
{
|
||||
uint16_t usLen = adcDataQueueLen();
|
||||
if (usLen == 0) {
|
||||
const char *err_msg = "no sample data";
|
||||
daq_send_packet(cmd | CPY_PROT_CMD_ACK, (const uint8_t *)err_msg, strlen(err_msg));
|
||||
break;
|
||||
}
|
||||
|
||||
static uint8_t data[PACKET_DATA_UNIT_NUM * sizeof(adcDataUnitDef)];
|
||||
usLen = makeDataPacket(data);
|
||||
if (usLen == 0) {
|
||||
const char *err_msg = "make data packet failed";
|
||||
daq_send_packet(cmd | CPY_PROT_CMD_ACK, (const uint8_t *)err_msg, strlen(err_msg));
|
||||
break;
|
||||
}
|
||||
daq_send_packet(cmd | CPY_PROT_CMD_ACK, (const uint8_t *)data, usLen);
|
||||
}
|
||||
break;
|
||||
case CPY_PROT_CMD_IAP:
|
||||
iapPacketHandler(data);
|
||||
break;
|
||||
@@ -311,48 +251,7 @@ static int waitTxComplete(int timeout_ms)
|
||||
|
||||
static void ioCheck(void)
|
||||
{
|
||||
static int ioRelay = 0;
|
||||
static int ioSample = 0;
|
||||
|
||||
if (DI_REALY_ASSERTED()) {
|
||||
if (ioRelay < 0) {
|
||||
ioRelay = 0;
|
||||
}
|
||||
ioRelay++;
|
||||
if (ioRelay >= 3) {
|
||||
ioRelay = 3;
|
||||
DO_RELAY_ASSERT();
|
||||
}
|
||||
} else {
|
||||
if (ioRelay > 0) {
|
||||
ioRelay = 0;
|
||||
}
|
||||
ioRelay--;
|
||||
if (ioRelay <= -3) {
|
||||
ioRelay = -3;
|
||||
DO_RELAY_ASSERT();
|
||||
}
|
||||
}
|
||||
|
||||
if (DI_SIMPLE_ASSERTED()) {
|
||||
if (ioSample < 0) {
|
||||
ioSample = 0;
|
||||
}
|
||||
ioSample++;
|
||||
if (ioSample >= 3) {
|
||||
ioSample = 3;
|
||||
adcSampleStart();
|
||||
}
|
||||
} else {
|
||||
if (ioSample > 0) {
|
||||
ioSample = 0;
|
||||
}
|
||||
ioSample--;
|
||||
if (ioSample <= -3) {
|
||||
ioSample = -3;
|
||||
adcSampleStop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void cpyProtThread(void *arg)
|
||||
|
||||
Reference in New Issue
Block a user