在与上位机通信的时候, 一些数据下发, 上位机是按照大端模式, 为了便于计算, 我们需要调整上位机的数据格式为小端模式
单片机存储一个uint32与uint16内存如下
union {
uint32_t word;
char bytes[4];
} test;
test.word = 0x12345678;
ut_log("uint32_t bytes[0]=%02X, bytes[1]=%02X, bytes[2]=%02X, bytes[3]=%02X\r\n",test.bytes[0], test.bytes[1], test.bytes[2], test.bytes[3]);
union {
uint16_t word;
char bytes[4];
} test_u16;
test_u16.word = 0x1234;
ut_log("uint16_t bytes[0]=%02X, bytes[1]=%02X\r\n",test_u16.bytes[0], test_u16.bytes[1]);
uint32_t bytes0=78, bytes1=56, bytes2=34, bytes3=12
uint16_t bytes0=34, bytes1=12