增加注释,增加代码可读性
This commit is contained in:
parent
fcfcf0e108
commit
b1d61a880b
|
@ -145,7 +145,7 @@
|
|||
</tool>
|
||||
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.archiver.506412204" name="GNU ARM Cross Archiver" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.archiver"/>
|
||||
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.createflash.1461589245" name="GNU ARM Cross Create Flash Image" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.createflash">
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.createflash.choice.1937707052" name="Output file format (-O)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createflash.choice" useByScannerDiscovery="false" value="ilg.gnuarmeclipse.managedbuild.cross.option.createflash.choice.ihex" valueType="enumerated"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.createflash.choice.1937707052" name="Output file format (-O)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createflash.choice" useByScannerDiscovery="false" value="ilg.gnuarmeclipse.managedbuild.cross.option.createflash.choice.binary" valueType="enumerated"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.createlisting.82359725" name="GNU ARM Cross Create Listing" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.createlisting">
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.source.601724476" name="Display source (--source|-S)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.source" value="true" valueType="boolean"/>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<launchConfiguration type="ilg.gnumcueclipse.debug.gdbjtag.jlink.launchConfigurationType">
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.PERIPHERALS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <peripherals/> "/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.adapterName" value="J-Link"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.binFileStartAddress" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.binFileStartAddress" value="0x08000000"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doConnectToRunning" value="false"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doContinue" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doDebugInRam" value="false"/>
|
||||
|
@ -26,7 +26,7 @@
|
|||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.firstResetSpeed" value="4000"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.firstResetType" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.flashDeviceName" value="STM32L071RB"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.flashDownloadHex" value="true"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.flashDownloadHex" value="false"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.forceQuitGdbServer" value="false"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbClientOtherCommands" value="set mem inaccessible-by-default off"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbClientOtherOptions" value=""/>
|
||||
|
|
|
@ -51,7 +51,7 @@ uint32_t device_id_dec(void)
|
|||
|
||||
#else
|
||||
//默认设备ID
|
||||
uint32_t dev_id = 250400003;
|
||||
uint32_t dev_id = 240400000;
|
||||
|
||||
dev_par.id_hex[0] = (dev_id>>24)&0xFF;
|
||||
dev_par.id_hex[1] = (dev_id>>16)&0xFF;
|
||||
|
|
|
@ -35,26 +35,26 @@
|
|||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t logo;
|
||||
uint8_t head;
|
||||
uint8_t length;
|
||||
uint8_t packs_all;
|
||||
uint8_t packs_num;
|
||||
uint8_t dev_id[4];
|
||||
uint8_t collect_time[4];
|
||||
uint8_t csq;
|
||||
uint8_t voltage[2];
|
||||
uint8_t temperature[2];
|
||||
uint8_t methane[2];
|
||||
uint8_t methane_state[2];
|
||||
uint8_t water[2];
|
||||
uint8_t distance[2];
|
||||
uint8_t pci[2];
|
||||
uint8_t turn;
|
||||
uint8_t rsrp[2];
|
||||
uint8_t snr[2];
|
||||
uint8_t gps_latitude[4];
|
||||
uint8_t gps_longitude[4];
|
||||
uint8_t logo; // 标识
|
||||
uint8_t head; // 报头文
|
||||
uint8_t length; // 上报字节长度
|
||||
uint8_t packs_all; // 数据包总数
|
||||
uint8_t packs_num; // 数据包序号
|
||||
uint8_t dev_id[4]; // 设备ID
|
||||
uint8_t collect_time[4]; // 采集时间
|
||||
uint8_t csq; // 接收信号强度RSSI
|
||||
uint8_t voltage[2]; // 电池电压
|
||||
uint8_t temperature[2]; // 测量温度
|
||||
uint8_t methane[2]; // 激光甲烷浓度
|
||||
uint8_t methane_state[2]; // 激光甲烷传感器状态码
|
||||
uint8_t water[2]; // 水浸+井盖异动
|
||||
uint8_t distance[2]; // 超声波测距
|
||||
uint8_t pci[2]; // 物理小区标识PCI
|
||||
uint8_t turn; // 侧翻报警
|
||||
uint8_t rsrp[2]; // 参考信号接收功率
|
||||
uint8_t snr[2]; // 信噪比
|
||||
uint8_t gps_latitude[4]; // GPS维度
|
||||
uint8_t gps_longitude[4]; // GPS经度
|
||||
}iot_device_message_t;
|
||||
|
||||
/*
|
||||
|
|
|
@ -253,7 +253,7 @@ uint8_t i_csq_deal(char* data, uint8_t len)
|
|||
#endif
|
||||
LOG_OUT("csq=%d\r\n", csq_value);
|
||||
|
||||
i_dev_mess.csq = csq_value;
|
||||
i_dev_mess.csq = csq_value; // 信号强度RSSI数值(0~0x31),上传十六进制数据到平台,平台换算成十进制数据
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
extern iot_control_t iot_ctl;
|
||||
extern rt_timer_t iot_timer_3;
|
||||
extern iot_device_message_t i_dev_mess;
|
||||
iot_device_message_t i_dev_mess_test;
|
||||
|
||||
extern iot_device_set_message_t i_set_mess;
|
||||
|
||||
extern rt_uint8_t iot_send_buff[IOT_SEND_BUFF_SIZE];
|
||||
|
@ -61,7 +63,6 @@ void app_iot_up_update(uint8_t cmd, uint16_t data)
|
|||
iot_send_head_len = 17;
|
||||
memcpy(iot_send_buff, "AT+MIPSEND=0,41,\"", iot_send_head_len);
|
||||
#endif
|
||||
|
||||
user_num_tran_ascll_2(iot_send_buff+iot_send_head_len, &i_dev_mess, iot_send_len);
|
||||
}
|
||||
else if(cmd == CMD_DOWN_ACK)
|
||||
|
|
|
@ -104,6 +104,34 @@ void user_num_tran_ascll_2(uint8_t *data1, uint8_t *data2, uint8_t data2_len)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 数组转字符串(test)
|
||||
*/
|
||||
void user_num_tran_ascll_2_test(uint8_t *data1, uint8_t *data2, uint8_t data2_len)
|
||||
{
|
||||
// 检查输入指针是否有效
|
||||
if (data1 == NULL || data2 == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const char hex_digits[16] = "0123456789ABCDEF";
|
||||
|
||||
for (uint8_t t = 0; t < data2_len; t++)
|
||||
{
|
||||
uint8_t byte = *(data2 + t);
|
||||
|
||||
// 高4位转换
|
||||
uint8_t high_nibble = (byte >> 4) & 0x0F;
|
||||
*(data1 + (t * 2)) = hex_digits[high_nibble];
|
||||
|
||||
// 低4位转换
|
||||
uint8_t low_nibble = byte & 0x0F;
|
||||
*(data1 + (t * 2) + 1) = hex_digits[low_nibble];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 字符串转数组+合并
|
||||
*/
|
||||
|
|
|
@ -7,6 +7,7 @@ uint8_t user_num_tran_char(uint32_t number, uint8_t* addr, uint32_t end_flag);
|
|||
void user_char_tran_numbuff(uint8_t *addr1, uint8_t *addr2, uint32_t max_len, uint32_t end_flag);
|
||||
uint32_t user_char_tran_num(uint8_t *addr1, uint32_t over_len);
|
||||
void user_num_tran_ascll_2(uint8_t *data1, uint8_t *data2, uint8_t data2_len);
|
||||
void user_num_tran_ascll_2_test(uint8_t *data1, uint8_t *data2, uint8_t data2_len);
|
||||
uint8_t user_char_tran_numbuff_2(uint8_t *p_original,uint8_t *p_tran,uint8_t p_len);
|
||||
uint8_t user_char_tran_numbuff_3(uint8_t *addr1, uint16_t p_len);
|
||||
uint8_t user_check_sum(uint8_t *buff, uint8_t len);
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* EEPROM芯片 */
|
||||
#include "bsp_at24c512.h"
|
||||
|
||||
extern iic_control_t iic_ctl_at24c;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#include "bsp_eeprom.h"
|
||||
|
||||
extern iot_device_set_message_t i_set_mess;
|
||||
extern CircularBuffer ccbuff ;
|
||||
extern CircularBuffer ccbuff;
|
||||
extern iot_control_t iot_ctl;
|
||||
|
||||
//数据读取缓存
|
||||
uint8_t eeprom_buffer[EEPROM_DATA_SIZE] = {0};
|
||||
uint8_t eeprom_buffer2[EEPROM_DATA_SIZE] = {0};
|
||||
uint8_t eeprom_buffer[EEPROM_DATA_SIZE] = { 0 };
|
||||
uint8_t eeprom_buffer2[EEPROM_DATA_SIZE] = { 0 };
|
||||
|
||||
/*
|
||||
* 保存写入
|
||||
|
@ -19,7 +19,6 @@ void mcu_eeprom_save(void)
|
|||
//LOG_OUT("sizeof 1=%d\r\n", sizeof(i_set_mess));
|
||||
//LOG_OUT("sizeof 2=%d\r\n", sizeof(ccbuff));
|
||||
|
||||
|
||||
memset(eeprom_buffer, 0x00, sizeof(eeprom_buffer));
|
||||
memset(eeprom_buffer2, 0x00, sizeof(eeprom_buffer2));
|
||||
|
||||
|
@ -28,47 +27,42 @@ void mcu_eeprom_save(void)
|
|||
eeprom_buffer[0] = 0xAA;
|
||||
eeprom_buffer[1] = 0xBB;
|
||||
|
||||
memcpy(eeprom_buffer+2, &i_set_mess, sizeof(i_set_mess));
|
||||
memcpy(eeprom_buffer+40, &ccbuff, sizeof(ccbuff) );
|
||||
memcpy(eeprom_buffer + 2, &i_set_mess, sizeof(i_set_mess));
|
||||
memcpy(eeprom_buffer + 40, &ccbuff, sizeof(ccbuff));
|
||||
|
||||
memcpy(eeprom_buffer+84 ,&iot_ctl.i_w_packet, 2);
|
||||
memcpy(eeprom_buffer+86 ,&iot_ctl.i_w_packet_alarm, 2);
|
||||
memcpy(eeprom_buffer + 84, &iot_ctl.i_w_packet, 2);
|
||||
memcpy(eeprom_buffer + 86, &iot_ctl.i_w_packet_alarm, 2);
|
||||
|
||||
eeprom_buffer[90] = crc8_crc8(eeprom_buffer, 88);
|
||||
eeprom_buffer[91] = crc8_crc8(eeprom_buffer, 88);
|
||||
|
||||
|
||||
LOG_OUT("\r\n");
|
||||
for(uint8_t i=0; i<EEPROM_DATA_SIZE; i++)
|
||||
for (uint8_t i = 0; i < EEPROM_DATA_SIZE; i++)
|
||||
{
|
||||
LOG_OUT("%x ",eeprom_buffer[i]);
|
||||
LOG_OUT("%x ", eeprom_buffer[i]);
|
||||
}
|
||||
LOG_OUT("\r\n");
|
||||
|
||||
for(uint8_t t=0; t<10; t++)
|
||||
for (uint8_t t = 0; t < 10; t++)
|
||||
{
|
||||
mcu_eeprom_write(EEPROM_WRITE_ADDR, eeprom_buffer, EEPROM_DATA_SIZE);
|
||||
mcu_eeprom_read(EEPROM_WRITE_ADDR, eeprom_buffer2, EEPROM_DATA_SIZE);
|
||||
|
||||
if(memcmp(eeprom_buffer, eeprom_buffer2, EEPROM_DATA_SIZE) == 0)
|
||||
if (memcmp(eeprom_buffer, eeprom_buffer2, EEPROM_DATA_SIZE) == 0)
|
||||
{
|
||||
LOG_OUT("\r\nwok t=%d\r\n", t);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(uint8_t i=0; i<EEPROM_DATA_SIZE; i++)
|
||||
for (uint8_t i = 0; i < EEPROM_DATA_SIZE; i++)
|
||||
{
|
||||
LOG_OUT("%x ",eeprom_buffer2[i]);
|
||||
LOG_OUT("%x ", eeprom_buffer2[i]);
|
||||
}
|
||||
LOG_OUT("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -80,11 +74,11 @@ void mcu_eeprom_power(void)
|
|||
memset(eeprom_buffer, 0x00, sizeof(eeprom_buffer));
|
||||
memset(eeprom_buffer2, 0x00, sizeof(eeprom_buffer2));
|
||||
|
||||
for(uint8_t t=0; t<10; t++)
|
||||
for (uint8_t t = 0; t < 10; t++)
|
||||
{
|
||||
mcu_eeprom_read(EEPROM_WRITE_ADDR, eeprom_buffer, EEPROM_DATA_SIZE);
|
||||
mcu_eeprom_read(EEPROM_WRITE_ADDR, eeprom_buffer2, EEPROM_DATA_SIZE);
|
||||
if(memcmp(eeprom_buffer, eeprom_buffer2, EEPROM_DATA_SIZE) == 0)
|
||||
if (memcmp(eeprom_buffer, eeprom_buffer2, EEPROM_DATA_SIZE) == 0)
|
||||
{
|
||||
LOG_OUT("\r\nrok t=%d\r\n", t);
|
||||
break;
|
||||
|
@ -92,22 +86,20 @@ void mcu_eeprom_power(void)
|
|||
}
|
||||
|
||||
LOG_OUT("\r\n");
|
||||
for(uint8_t i=0; i<EEPROM_DATA_SIZE; i++)
|
||||
for (uint8_t i = 0; i < EEPROM_DATA_SIZE; i++)
|
||||
{
|
||||
LOG_OUT("%x ",eeprom_buffer[i]);
|
||||
LOG_OUT("%x ", eeprom_buffer[i]);
|
||||
}
|
||||
LOG_OUT("\r\n");
|
||||
|
||||
|
||||
if( (eeprom_buffer[90] == crc8_crc8(eeprom_buffer, 88)) &&
|
||||
(eeprom_buffer[0] == 0xAA) && (eeprom_buffer[1] == 0xBB) )
|
||||
if ((eeprom_buffer[90] == crc8_crc8(eeprom_buffer, 88)) && (eeprom_buffer[0] == 0xAA) && (eeprom_buffer[1] == 0xBB))
|
||||
{
|
||||
LOG_OUT("eeprom data recover\r\n");
|
||||
|
||||
memcpy(&i_set_mess, eeprom_buffer+2, sizeof(i_set_mess));
|
||||
memcpy(&ccbuff, eeprom_buffer+40, sizeof(ccbuff) );
|
||||
memcpy(&iot_ctl.i_w_packet, eeprom_buffer+84 , 2);
|
||||
memcpy(&iot_ctl.i_w_packet_alarm, eeprom_buffer+86 , 2);
|
||||
memcpy(&i_set_mess, eeprom_buffer + 2, sizeof(i_set_mess));
|
||||
memcpy(&ccbuff, eeprom_buffer + 40, sizeof(ccbuff));
|
||||
memcpy(&iot_ctl.i_w_packet, eeprom_buffer + 84, 2);
|
||||
memcpy(&iot_ctl.i_w_packet_alarm, eeprom_buffer + 86, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -119,8 +111,6 @@ void mcu_eeprom_power(void)
|
|||
iot_ctl.i_w_packet = 0;
|
||||
iot_ctl.i_w_packet_alarm = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -134,9 +124,9 @@ void mcu_eeprom_write(uint16_t address, uint8_t *data, uint16_t len)
|
|||
HAL_StatusTypeDef status = HAL_OK;
|
||||
|
||||
HAL_FLASHEx_DATAEEPROM_Unlock();
|
||||
for(uint8_t i=0; i<len; i++)
|
||||
for (uint8_t i = 0; i < len; i++)
|
||||
{
|
||||
status +=HAL_FLASHEx_DATAEEPROM_Program(FLASH_TYPEPROGRAMDATA_BYTE, EEPROM_BASE_ADDR+address+i, *data);
|
||||
status += HAL_FLASHEx_DATAEEPROM_Program(FLASH_TYPEPROGRAMDATA_BYTE, EEPROM_BASE_ADDR + address + i, *data);
|
||||
data++;
|
||||
}
|
||||
HAL_FLASHEx_DATAEEPROM_Lock();
|
||||
|
@ -152,8 +142,8 @@ void mcu_eeprom_write(uint16_t address, uint8_t *data, uint16_t len)
|
|||
void mcu_eeprom_read(uint16_t address, uint8_t *buffer, uint16_t len)
|
||||
{
|
||||
uint8_t *read_address = 0;
|
||||
read_address = (uint8_t *)(EEPROM_BASE_ADDR+address);
|
||||
while(len--)
|
||||
read_address = (uint8_t *) (EEPROM_BASE_ADDR + address);
|
||||
while (len--)
|
||||
{
|
||||
*buffer++ = *read_address++;
|
||||
}
|
||||
|
@ -168,9 +158,9 @@ void mcu_eeprom_erase(uint16_t address, uint16_t len)
|
|||
level = rt_hw_interrupt_disable();
|
||||
HAL_FLASHEx_DATAEEPROM_Unlock();
|
||||
|
||||
for(uint8_t i=0; i<len; i=i+4)
|
||||
for (uint8_t i = 0; i < len; i = i + 4)
|
||||
{
|
||||
if( HAL_FLASHEx_DATAEEPROM_Erase(EEPROM_BASE_ADDR + address + i) != HAL_OK)
|
||||
if (HAL_FLASHEx_DATAEEPROM_Erase(EEPROM_BASE_ADDR + address + i) != HAL_OK)
|
||||
{
|
||||
i--;
|
||||
}
|
||||
|
|
|
@ -259,7 +259,7 @@ rt_size_t gas_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
|
|||
}
|
||||
#endif
|
||||
}
|
||||
else if(pos == GAS_AIR)
|
||||
else if(pos == GAS_AIR) // 压力传感器
|
||||
{
|
||||
uint32_t temp1_pressure = 0;
|
||||
float temp2_pressure = 0;
|
||||
|
|
|
@ -32,7 +32,7 @@ rt_size_t water_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size
|
|||
|
||||
LOG_OUT("water=%x\r\n", water_state);
|
||||
|
||||
if( STATE_LID_READ == GPIO_PIN_SET)
|
||||
if( STATE_LID_READ == GPIO_PIN_SET) // 井盖异动触发限位开关
|
||||
{
|
||||
water_state |= 0x02;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue