stop run cmd

This commit is contained in:
wmano
2025-10-27 20:50:06 +08:00
parent 8b6f231b28
commit e7b859851b
16 changed files with 368 additions and 241 deletions
+2 -2
View File
@@ -15,7 +15,7 @@ int chrg_eload_read_regs (rt_uint8_t addr, rt_uint16_t reg, rt_uint16_t len)
u16_to_u8v(reg, &buf[2]);
u16_to_u8v(len, &buf[4]);
crc = mb_crc16(buf, 6);
u16_to_u8v(crc, &buf[6]);
u16_to_u8v(swap_u16(crc), &buf[6]);
return chrg_south_send(buf, 8);
}
@@ -30,7 +30,7 @@ int chrg_eload_write_reg (rt_uint8_t addr, rt_uint16_t reg, rt_uint16_t value)
u16_to_u8v(reg, &buf[2]);
u16_to_u8v(value, &buf[4]);
crc = mb_crc16(buf, 6);
u16_to_u8v(crc, &buf[6]);
u16_to_u8v(swap_u16(crc), &buf[6]);
return chrg_south_send(buf, 8);
}
+17 -1
View File
@@ -1,10 +1,26 @@
#include <rtthread.h>
#include "chrg_sink.h"
#include "chrg_north.h"
#include "chrg_north_pkg.h"
#include "chrg_utils.h"
int sink_get_vc (rt_uint16_t vol, rt_uint16_t cur)
{
rt_uint16_t len = 0;
rt_uint8_t data[12] = {0};
rt_uint8_t frame[16] = {0};
return 0;
u16_to_u8v(vol, &data[0]);
u16_to_u8v(cur, &data[2]);
data[4] = 0x00;
data[5] = 0x00;
chrg_north_pkg_encode(ID_SINK, SINK_CMD_GET_VOLTAGE, data, 6, frame, &len);
return chrg_north_send(frame, len);
}
+15
View File
@@ -119,5 +119,20 @@ rt_uint16_t u8v_to_u16 (rt_uint8_t *buf)
return 0;
}
// rt_uint16_t 高低位互换
rt_uint16_t swap_u16 (rt_uint16_t x)
{
return ((x & 0x00FF) << 8) |
((x & 0xFF00) >> 8);
}
// rt_uint32_t 高低位互换
rt_uint32_t swap_u32 (rt_uint32_t x)
{
return ((x & 0x000000FF) << 24) |
((x & 0x0000FF00) << 8) |
((x & 0x00FF0000) >> 8) |
((x & 0xFF000000) >> 24);
}
@@ -11,6 +11,10 @@ extern rt_uint8_t u16_to_u8v (rt_uint16_t value, rt_uint8_t *buf);
extern rt_uint16_t u8v_to_u16 (rt_uint8_t *buf);
extern rt_uint16_t swap_u16 (rt_uint16_t x);
extern rt_uint32_t swap_u32 (rt_uint32_t x);
#endif