diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index cf9e0be..ab6f426 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/README.md b/README.md index cd41b81..1795bf3 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,26 @@ ``` -设计文档:https://iflytop1.feishu.cn/wiki/CQWNw4ZBXiStBkkQRo0czgnbnxc ``` ``` - V2: - 完成需求 - V3: - 1.当控制电机时,会重置电机异常标志位 - V4: - 1.去掉压力传感器传感器信息自动上报 - V5: - 添加看门狗 +app/ 应用目录 +app/mainboard/basic 存放基础数据结构,基础数据服务,不涉及业务的基础服务。 + 例如结构体,不含有方法的类,数据存储。 + +BASIC_BOARD +BASIC +SERVICE/BOARD/ +SERVICE/PAGE,SERVICE + +UTILS + + + + + + + ``` -```c -BoardTypeId: - 0x080E0000: - kLargeSpaceDMLiquidCtrlBoard = 0x1, // 大空间消毒机液路板 - kLargeSpaceDMPowerCtrlBoard = 0x2, // 大空间消毒机电源板 - kSmallSpaceDMLiquidCtrlBoard = 0x3, // 小空间消毒机液路板 - kSmallSpaceDMPowerCtrlBoard = 0x4, // 小空间消毒机电源板 - kPipeDMLiquidCtrlBoard = 0x5, // 管道式消毒机液路板 - kPipeDMPowerCtrlBoard = 0x6, // 管道式消毒机电源板 - kDrawBarDMLiquidCtrlBoard = 0x7, // 手持拉杆箱消毒机液路板 - kDrawBarDMPowerCtrlBoard = 0x8, // 手持拉杆箱消毒机电源板 - kDrawBarDMExtBallValveCtrl = 0x9, // 手持拉杆箱消毒机外部球阀控制板 - kH2O2SensorBoard = 0xA, // H2O2传感器板 - - -``` \ No newline at end of file + + diff --git a/app_protocols/zscanprotocol b/app_protocols/zscanprotocol index d11d41c..8a3aeaf 160000 --- a/app_protocols/zscanprotocol +++ b/app_protocols/zscanprotocol @@ -1 +1 @@ -Subproject commit d11d41c1062568f629d5ec2bc6435319b7ea83e3 +Subproject commit 8a3aeaf8883a3c7d01594e0399fbe96bf8b9cf72 diff --git a/stm32basic b/stm32basic index 54ccfa2..7628a01 160000 --- a/stm32basic +++ b/stm32basic @@ -1 +1 @@ -Subproject commit 54ccfa2fd5128c9a2f243eb2394a51cb47595f13 +Subproject commit 7628a01fff313fd263d7de7e93d7d652b4325e59 diff --git a/stm32components b/stm32components index d387a6d..03d9638 160000 --- a/stm32components +++ b/stm32components @@ -1 +1 @@ -Subproject commit d387a6d07dd669a43fafc96016635e3b95830a0c +Subproject commit 03d9638ccbc69971524957a68e51842da0960940 diff --git a/ucomponents/hmp110/HMM100-Datasheet-B210813ZH.pdf b/ucomponents/hmp110/HMM100-Datasheet-B210813ZH.pdf deleted file mode 100644 index d08dbeb..0000000 Binary files a/ucomponents/hmp110/HMM100-Datasheet-B210813ZH.pdf and /dev/null differ diff --git a/ucomponents/hmp110/HMP110 DOC247480-A Simplified Models.zip b/ucomponents/hmp110/HMP110 DOC247480-A Simplified Models.zip deleted file mode 100644 index a1a47c8..0000000 Binary files a/ucomponents/hmp110/HMP110 DOC247480-A Simplified Models.zip and /dev/null differ diff --git a/ucomponents/hmp110/HMP110-Datasheet-B210852ZH.pdf b/ucomponents/hmp110/HMP110-Datasheet-B210852ZH.pdf deleted file mode 100644 index fbfc201..0000000 Binary files a/ucomponents/hmp110/HMP110-Datasheet-B210852ZH.pdf and /dev/null differ diff --git a/ucomponents/hmp110/hmp110.cpp b/ucomponents/hmp110/hmp110.cpp deleted file mode 100644 index a162cd2..0000000 --- a/ucomponents/hmp110/hmp110.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#include "hmp110.hpp" - -#include "stm32components/modbus/modbus_block_host.hpp" - -using namespace iflytop; - -#define TAG "HMP110" - -void HMP110::init(ModbusBlockHost* modbusBlockHost) { - m_modbusBlockHost = modbusBlockHost; - m_id = 240; - - m_cache_lock.init(); - m_chlock.init(); -} - -bool HMP110::readReg03(uint8_t slaveAddr, uint16_t regAddr, uint16_t* regVal, int overtimems) { // - zlock_guard lck(m_chlock); - // ZLOGI(TAG, "=============== readReg03 %d %d", slaveAddr, regAddr); - bool ret = m_modbusBlockHost->readReg03(slaveAddr, regAddr, regVal, overtimems); - // ZLOGI(TAG, "=============== END%d", ret); - - - return ret; -} -bool HMP110::readReg03Muti(uint8_t slaveAddr, uint16_t regAddr, uint16_t* regVal, int regNum, int overtimems) { // - zlock_guard lck(m_chlock); - // ZLOGI(TAG, "=============== readReg03Muti %d %d %d", slaveAddr, regAddr, regNum); - bool ret = m_modbusBlockHost->readReg03Muti(slaveAddr, regAddr, regVal, regNum, overtimems); - // ZLOGI(TAG, "=============== END%d", ret); - return ret; -} -bool HMP110::ping(int id) { - int16_t val = 0; - return readReg03(id, 0x1F00, (uint16_t*)&val, 300); -} - -void HMP110::setid(int32_t id) { m_id = id; } - -void HMP110::read_calibration_date(int32_t* year, int32_t* month, int32_t* day) { // TODO - *year = 1; - *month = 2; - *day = 3; -} -int32_t HMP110::read_errorcode() { - int16_t val = 0; - bool suc = readReg03(m_id, 0x0200, (uint16_t*)&val, 300); - if (!suc) { - return -1; - } - - if (val == 1) { - return 0; - } - uint16_t ecodebuf[2]; - suc = readReg03Muti(m_id, 0x0203, ecodebuf, 2, 300); - - uint32_t ecode = ecodebuf[0] | (((uint32_t)ecodebuf[1]) << 16); - return ecode; -} - -bool HMP110::read_reg(int32_t add, uint16_t* val, size_t len) { - // ZLOGI(TAG, "read_reg %x %d", add, len); - bool suc = readReg03Muti(m_id, add, val, len, 300); - // if (suc) - // for (size_t i = 0; i < len; i++) { - // ZLOGI(TAG, "val[%d] = %d", i, val[i]); - // } - // else - // ZLOGE(TAG, "read_reg failed"); - return suc; -} - -bool HMP110::read_sensor_data(hmp110_sensordata_t* sensordata) { - uint16_t buf[7]; - bool suc = readReg03Muti(m_id, 0x0100, buf, 7, 300); - if (!suc) { - return false; - } - - sensordata->rh = buf[0]; - sensordata->temp = buf[1]; - sensordata->df_ptemp = buf[2]; - sensordata->ah = buf[3]; - sensordata->mr = buf[4]; - sensordata->wet_bulb_temp = buf[5]; - sensordata->enthalpy = buf[6]; - return true; -} - -void HMP110::updateSensorDataAndErrorcode() { - bool suc = read_sensor_data(&m_rdbuf); - osDelay(100); - int32_t errorcode = read_errorcode(); - if (errorcode != 0) { - ZLOGE(TAG, "errorcode: %d", errorcode); - } - if (!suc) { - ZLOGE(TAG, "read_sensor_data failed"); - errorcode = -1; - } - - { - zlock_guard lck(m_cache_lock); - m_cachedata = m_rdbuf; - m_cache_errorcode = errorcode; - } -} - -int32_t HMP110::read_cache_errorcode() { - zlock_guard lck(m_cache_lock); - return m_cache_errorcode; -} -bool HMP110::read_cache_sensor_data(hmp110_sensordata_t* sensordata) { - zlock_guard lck(m_cache_lock); - *sensordata = m_cachedata; - return true; -} diff --git a/ucomponents/hmp110/hmp110.hpp b/ucomponents/hmp110/hmp110.hpp deleted file mode 100644 index 21a88b8..0000000 --- a/ucomponents/hmp110/hmp110.hpp +++ /dev/null @@ -1,70 +0,0 @@ -#pragma once -#include -#include - -#include "stm32basic/stm32basic.hpp" -#include "stm32components/stm32components.hpp" - -namespace iflytop { - -#define PXX_PRESSURE_SENSOR_NUM 10 - -class HMP110 { - public: -#pragma pack(1) - - typedef struct { - int16_t rh; // Relative humidity %RH * 10 - int16_t temp; // Temperature °C * 10 - int16_t df_ptemp; // Dew/frost point temperature °C * 10 - int16_t ah; // Absolute humidity g/m3 * 10 - int16_t mr; // Mixing ratio g/kg * 10 - int16_t wet_bulb_temp; // Wet-bulb temperature °C * 10 - int16_t enthalpy; // Enthalpy kJ/kg * 10 - } hmp110_sensordata_t; -#pragma pack() - - private: - /*********************************************************************************************************************** - * DATA * - ***********************************************************************************************************************/ - - ModbusBlockHost* m_modbusBlockHost = NULL; - int32_t m_id = 0; - zmutex m_lock; - - hmp110_sensordata_t m_rdbuf; - - hmp110_sensordata_t m_cachedata; - int32_t m_cache_errorcode = 0; - zmutex m_cache_lock; - - zmutex m_chlock; - - public: - /*********************************************************************************************************************** - * FUNC * - ***********************************************************************************************************************/ - - void init(ModbusBlockHost* modbusBlockHost); - - bool ping(int id); - bool ping(); - void setid(int32_t id); - - void read_calibration_date(int32_t* year, int32_t* month, int32_t* day); // TODO - int32_t read_errorcode(); // ret == -1 表明设备不在线 - bool read_reg(int32_t add, uint16_t* val, size_t len); - bool read_sensor_data(hmp110_sensordata_t* sensordata); - - void updateSensorDataAndErrorcode(); - - int32_t read_cache_errorcode(); - bool read_cache_sensor_data(hmp110_sensordata_t* sensordata); - - public: - bool readReg03(uint8_t slaveAddr, uint16_t regAddr, uint16_t* regVal, int overtimems); - bool readReg03Muti(uint8_t slaveAddr, uint16_t regAddr, uint16_t* regVal, int regNum, int overtimems); -}; - -} // namespace iflytop \ No newline at end of file diff --git a/ucomponents/hpp272/HPP272-使用说明书.pdf b/ucomponents/hpp272/HPP272-使用说明书.pdf deleted file mode 100644 index 8efceaf..0000000 Binary files a/ucomponents/hpp272/HPP272-使用说明书.pdf and /dev/null differ diff --git a/ucomponents/hpp272/README.md b/ucomponents/hpp272/README.md deleted file mode 100644 index 2732662..0000000 --- a/ucomponents/hpp272/README.md +++ /dev/null @@ -1,8 +0,0 @@ - -``` -注意事项: - 1. 串口停止位是2位 - 2. 波特率19200 - 3. 默认ID 240 - -``` \ No newline at end of file diff --git a/ucomponents/hpp272/hpp272.cpp b/ucomponents/hpp272/hpp272.cpp deleted file mode 100644 index 7ea3161..0000000 --- a/ucomponents/hpp272/hpp272.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "hpp272.hpp" - -#include "stm32components/modbus/modbus_block_host.hpp" - -using namespace iflytop; - -#define TAG "HPP272" - -void HPP272::init(ModbusBlockHost* modbusBlockHost) { - m_modbusBlockHost = modbusBlockHost; - m_id = 240; - - m_cache_lock.init(); -} -bool HPP272::ping(int id) { - int16_t val = 0; - return m_modbusBlockHost->readReg03(id, 0x1F00, (uint16_t*)&val, 100); -} - -void HPP272::setid(int32_t id) { m_id = id; } - -void HPP272::read_calibration_date(int32_t* year, int32_t* month, int32_t* day) { // TODO - *year = 0; - *month = 0; - *day = 0; -} -int32_t HPP272::read_errorcode() { - int16_t val = 0; - bool suc = m_modbusBlockHost->readReg03(m_id, 0x0200, (uint16_t*)&val, 100); - if (!suc) { - return -1; - } - - // 0 = Status OK. - // 1 = Critical error,maintenance needed. - // 2 = Error, device may recover automatically. - // 4 = Warning. - // 8 = Notification. - // 16 = Calibration enabled - - return val; -} - -bool HPP272::read_reg(int32_t add, uint16_t* val, size_t len) { return m_modbusBlockHost->readReg03Muti(m_id, add, val, len, 100); } - -bool HPP272::read_sensor_data(hpp272_data_t* sensordata) { // - return m_modbusBlockHost->readReg03Muti(m_id, 0x0100, (uint16_t*)sensordata, sizeof(*sensordata) / 2, 100); -} - -void HPP272::updateSensorDataAndErrorcode() { - if (!read_sensor_data(&m_readbuf)) { - return; - } - int32_t errorcode = read_errorcode(); - - { - zlock_guard lck(m_cache_lock); - m_cachedata = m_readbuf; - m_cache_errorcode = errorcode; - } -} - -int32_t HPP272::read_cache_errorcode() { - zlock_guard lck(m_cache_lock); - return m_cache_errorcode; -} -bool HPP272::read_cache_sensor_data(hpp272_data_t* sensordata) { - zlock_guard lck(m_cache_lock); - *sensordata = m_cachedata; - return true; -} diff --git a/ucomponents/hpp272/hpp272.hpp b/ucomponents/hpp272/hpp272.hpp deleted file mode 100644 index 7fdb0ec..0000000 --- a/ucomponents/hpp272/hpp272.hpp +++ /dev/null @@ -1,78 +0,0 @@ -#pragma once -#include -#include - -#include "stm32basic/stm32basic.hpp" -#include "stm32components/stm32components.hpp" - -namespace iflytop { - -#define PXX_PRESSURE_SENSOR_NUM 10 - -class HPP272 { - public: -#pragma pack(1) - typedef struct { - uint16_t hydrogen_peroxide_volume; // ppm 0x0100 - uint16_t h2o_h2o2_rs; // %RS * 100 - uint16_t temperature1; // °C * 100 - uint16_t relative_humidity; // %RH * 100 - uint16_t absolute_hydrogen_peroxide; // mg/m3 - uint16_t h2o_h2o2dew_point_temperature; // °C * 100 - uint16_t reserved1; // - uint16_t water_volume; // ppm - uint16_t water_vapor_pressure; // hpa - uint16_t absolute_humidity; // g/m3 - uint16_t water_vapor_saturation_pressure_h2o; // hpa - uint16_t temperature2; // °C * 100 - uint16_t h2o2_vapor_pressure; // hpa - uint16_t water_vapor_saturation_pressure_h2o_h2o2; // hpa - } hpp272_data_t; -#pragma pack() - - private: - /*********************************************************************************************************************** - * DATA * - ***********************************************************************************************************************/ - - ModbusBlockHost* m_modbusBlockHost = NULL; - - int32_t m_id = 0; - zmutex m_lock; - - hpp272_data_t m_readbuf; - - hpp272_data_t m_cachedata; - int32_t m_cache_errorcode = 0; - zmutex m_cache_lock; - - public: - /*********************************************************************************************************************** - * FUNC * - ***********************************************************************************************************************/ - - /** - * @brief - * - * @param modbusBlockHost - */ - void init(ModbusBlockHost* modbusBlockHost); - - bool ping(int id); - bool ping(); - void setid(int32_t id); - - void read_calibration_date(int32_t* year, int32_t* month, int32_t* day); // TODO - int32_t read_errorcode(); // see datasheet page83 - bool read_reg(int32_t add, uint16_t* val, size_t len); - bool read_sensor_data(hpp272_data_t* sensordata); - - void updateSensorDataAndErrorcode(); - - int32_t read_cache_errorcode(); - bool read_cache_sensor_data(hpp272_data_t* sensordata); - - public: -}; - -} // namespace iflytop \ No newline at end of file diff --git a/ucomponents/hpp272/过氧化氢传感器读取.zip b/ucomponents/hpp272/过氧化氢传感器读取.zip deleted file mode 100644 index 0e7ab1b..0000000 Binary files a/ucomponents/hpp272/过氧化氢传感器读取.zip and /dev/null differ diff --git a/ucomponents/pxx_pressure_sensor_driver/DP600--RS485通讯说明书V0.1.docx b/ucomponents/pxx_pressure_sensor_driver/DP600--RS485通讯说明书V0.1.docx deleted file mode 100644 index f601635..0000000 Binary files a/ucomponents/pxx_pressure_sensor_driver/DP600--RS485通讯说明书V0.1.docx and /dev/null differ diff --git a/ucomponents/pxx_pressure_sensor_driver/HCP300新说明书.pdf b/ucomponents/pxx_pressure_sensor_driver/HCP300新说明书.pdf deleted file mode 100644 index baf38ef..0000000 Binary files a/ucomponents/pxx_pressure_sensor_driver/HCP300新说明书.pdf and /dev/null differ diff --git a/ucomponents/pxx_pressure_sensor_driver/P100标准MODBUS RTU通讯协议.pdf b/ucomponents/pxx_pressure_sensor_driver/P100标准MODBUS RTU通讯协议.pdf deleted file mode 100644 index f869cf1..0000000 Binary files a/ucomponents/pxx_pressure_sensor_driver/P100标准MODBUS RTU通讯协议.pdf and /dev/null differ diff --git a/ucomponents/pxx_pressure_sensor_driver/pxx_pressure_sensor_bus.cpp b/ucomponents/pxx_pressure_sensor_driver/pxx_pressure_sensor_bus.cpp deleted file mode 100644 index 735fcdb..0000000 --- a/ucomponents/pxx_pressure_sensor_driver/pxx_pressure_sensor_bus.cpp +++ /dev/null @@ -1,243 +0,0 @@ -#include "pxx_pressure_sensor_bus.hpp" - - -using namespace iflytop; - -#define TAG "PxxSensor" - -/** - * @brief - * - * - * p100_protocol - * 0x0000:从机地址位 - * p600_protocol - * 0x0018H:从机地址位 - * - * - * - * 程序编写指标参考: - * 响应频率 : 模拟信号输出≤500Hz、数字信号输出≤5Hz - * 指令回执响应时间 : 20ms - * - * 推荐指令间隔: - * 指令间隔至少30ms - */ - -#define OVERTIME_MS 50 - -static const char* protocolType2Str(PXXPressureSensorBus::protocol_type_t type) { - switch (type) { - case PXXPressureSensorBus::kp100_protocol: - return "P100"; - case PXXPressureSensorBus::kdp600_protocol: - return "DP600"; - case PXXPressureSensorBus::kothers_protocol: - return "OTHERS"; - default: - return "UNKNOWN"; - } -} - -static const char* p100uint2Str(uint8_t uint) { - switch (uint) { - case 0: - return "Mpa"; - case 1: - return "kpa"; - case 2: - return "pa"; - case 3: - return "bar"; - case 4: - return "Mbar"; - case 5: - return "kgcm2"; - case 6: - return "psi"; - case 7: - return "mh2o"; - case 8: - return "mh2o"; - default: - return "UNKNOWN"; - } -} - -/*********************************************************************************************************************** - * GLOBAL * - ***********************************************************************************************************************/ - -static osThreadId PxxPressureSensorThread; -static void onPxxPressureSensorThreadStart(void const* argument) { ((PXXPressureSensorBus*)argument)->threadFuncStart(); } - -/*********************************************************************************************************************** - * CLASS * - ***********************************************************************************************************************/ - -bool PXXPressureSensorBus::pingDevice(int id) { - uint16_t add = 0; - bool suc = m_modbusBlockHost->readReg03(id, 0x0000, &add, OVERTIME_MS); - return suc; -} - -bool PXXPressureSensorBus::tryProbeProtocolP100(int id, sensor_t* sensor) { - uint16_t add = 0; - bool suc = m_modbusBlockHost->readReg03(id, 0x0000, &add, OVERTIME_MS); - if (!suc) { - return false; - } - if (id != add) { - return false; - } - osDelay(10); - int16_t val[6] = {0}; - - suc = m_modbusBlockHost->readReg03Muti(id, 0x02, (uint16_t*)val, 5, 50); - if (!suc) { - return false; - } - sensor->p100_sensor_info.precision = val[1]; - sensor->p100_sensor_info.pressure_unit = val[0]; - sensor->p100_sensor_info.value = val[2]; - sensor->p100_sensor_info.zero_point = val[3]; - sensor->p100_sensor_info.range_full_point = val[4]; - - sensor->id = id; - sensor->type = kp100_protocol; - sensor->detected = true; - - return true; -} -bool PXXPressureSensorBus::tryProbeProtocolDP600(int id, sensor_t* sensor) { - uint16_t add = 0; - bool suc = m_modbusBlockHost->readReg03(id, 0x0018, &add, OVERTIME_MS); - // ZLOGI(TAG, "tryProbeProtocolDP600 id:%d add:%d suc:%d", id, add, suc); - if (!suc) { - return false; - } - if (id != add) { - return false; - } - - sensor->id = id; - sensor->type = kdp600_protocol; - sensor->detected = true; - return true; -} - -void PXXPressureSensorBus::probeSensor() { - memset(sensors, 0, sizeof(sensors)); - for (size_t i = 1; i < ZARRAY_SIZE(sensors); i++) { - osDelay(30); - bool pingSuc = false; - pingSuc = pingDevice(i); - ZLOGI(TAG, "pingDevice id:%d,%s", i, pingSuc ? "online" : "offline"); - if (pingSuc) { - sensorNum++; - if (tryProbeProtocolP100(i, &sensors[i])) continue; - osDelay(30); - if (tryProbeProtocolDP600(i, &sensors[i])) continue; - - sensors[i].id = i; - sensors[i].type = kothers_protocol; - sensors[i].detected = true; - } else { - } - } - - /** - * @brief DUMP Sensor State - */ - ZLOGI(TAG, "detect pressure sensor list:(%d)", sensorNum); - for (size_t i = 0; i < ZARRAY_SIZE(sensors); i++) { - if (sensors[i].detected) { - if (sensors[i].type == kp100_protocol) { - ZLOGI(TAG, " Sensor[%d] id:%d ptype:%s precision:%d unit:%s zero:%d full:%d", i, sensors[i].id, // - protocolType2Str(sensors[i].type), // - sensors[i].p100_sensor_info.precision, // - p100uint2Str(sensors[i].p100_sensor_info.pressure_unit), // - sensors[i].p100_sensor_info.zero_point, // - sensors[i].p100_sensor_info.range_full_point); - } else { - ZLOGI(TAG, " Sensor[%d] id:%d ptype:%s detected:%d", i, sensors[i].id, protocolType2Str(sensors[i].type), sensors[i].detected); - } - } - } - ZLOGI(TAG, "end"); - initedEnd = true; -} - -void PXXPressureSensorBus::threadFuncStart() { - /** - * @brief 枚举传感器设备 - */ - probeSensor(); - /** - * @brief 周期采集传感器数据 - */ - while (true) { - // - for (size_t i = 0; i < ZARRAY_SIZE(sensors); i++) { - if (!sensors[i].detected) { - continue; - } - - bool suc = false; - - if (sensors[i].type == kp100_protocol) { - int16_t val = 0; - suc = m_modbusBlockHost->readReg03(i, 0x0004, (uint16_t*)&val, OVERTIME_MS); - { - zlock_guard l(m_lock); - if (suc) sensors[i].val = val; - sensors[i].online = suc; - } - } else if (sensors[i].type == kdp600_protocol) { - int16_t val = 0; - suc = m_modbusBlockHost->readReg03(i, 0x0000, (uint16_t*)&val, OVERTIME_MS); - - { - zlock_guard l(m_lock); - if (suc) sensors[i].val = val; - sensors[i].online = suc; - } - } else { - { - zlock_guard l(m_lock); - sensors[i].online = false; - } - continue; - } - osDelay(50); - } - osDelay(50); - } -} - -void PXXPressureSensorBus::init(UART_HandleTypeDef* huart) { - // - m_lock.init(); - - m_modbusBlockHost = new ModbusBlockHost(); // - m_modbusBlockHost->initialize(huart); - - osThreadDef(PxxPressureSensorThread, onPxxPressureSensorThreadStart, osPriorityNormal, 0, 1024); - PxxPressureSensorThread = osThreadCreate(osThread(PxxPressureSensorThread), this); - - while (!initedEnd) { - osDelay(10); - } -} -bool PXXPressureSensorBus::readData(int32_t id, int16_t* data) { - zlock_guard l(m_lock); - if (id < 0 || id >= ZARRAY_SIZE(sensors)) { - return false; - } - if (!sensors[id].online) { - return false; - } - *data = sensors[id].val; - return true; -} -void PXXPressureSensorBus::probe() {} diff --git a/ucomponents/pxx_pressure_sensor_driver/pxx_pressure_sensor_bus.hpp b/ucomponents/pxx_pressure_sensor_driver/pxx_pressure_sensor_bus.hpp deleted file mode 100644 index ad2c1d7..0000000 --- a/ucomponents/pxx_pressure_sensor_driver/pxx_pressure_sensor_bus.hpp +++ /dev/null @@ -1,73 +0,0 @@ -#pragma once -#include -#include - -#include "stm32components/modbus/modbus_block_host.hpp" - -namespace iflytop { - -#define PXX_PRESSURE_SENSOR_NUM 10 - -class PXXPressureSensorBus { - public: - /*********************************************************************************************************************** - * STRUCT * - ***********************************************************************************************************************/ - - typedef enum { - kp100_protocol, - kdp600_protocol, - kothers_protocol, - } protocol_type_t; - - typedef struct { - uint8_t precision; // 0,1,2,3 - uint8_t pressure_unit; // 0:map,1:kpa,2:pa - int16_t value; - int16_t zero_point; - int16_t range_full_point; - } p100_sensor_info_t; - - typedef struct { - uint16_t id; - protocol_type_t type; - bool detected; - bool online; - p100_sensor_info_t p100_sensor_info; - - int32_t val; - } sensor_t; - - private: - /*********************************************************************************************************************** - * DATA * - ***********************************************************************************************************************/ - - ModbusBlockHost* m_modbusBlockHost; - bool initedEnd = false; - zmutex m_lock; - - public: - sensor_t sensors[PXX_PRESSURE_SENSOR_NUM] = {0}; - int32_t sensorNum = 0; - - public: - /*********************************************************************************************************************** - * FUNC * - ***********************************************************************************************************************/ - void init(UART_HandleTypeDef *huart); - bool readData(int32_t id, int16_t* data); - - private: - void probe(); - - public: - void threadFuncStart(); - - bool pingDevice(int id); - bool tryProbeProtocolP100(int id, sensor_t* sensor); - bool tryProbeProtocolDP600(int id, sensor_t* sensor); - void probeSensor(); -}; - -} // namespace iflytop \ No newline at end of file diff --git a/ucomponents/ucomponents.hpp b/ucomponents/ucomponents.hpp index c958bf5..c2c1096 100644 --- a/ucomponents/ucomponents.hpp +++ b/ucomponents/ucomponents.hpp @@ -1,5 +1,2 @@ #pragma once -#include "hmp110/hmp110.hpp" -#include "hpp272/hpp272.hpp" -#include "preportional_valve/preportional_valve_ctrl.hpp" -#include "pxx_pressure_sensor_driver/pxx_pressure_sensor_bus.hpp" \ No newline at end of file +#include "preportional_valve/preportional_valve_ctrl.hpp" \ No newline at end of file diff --git a/usrc/app/apublicboard/public_board_initer.cpp b/usrc/app/apublicboard/public_board_initer.cpp new file mode 100644 index 0000000..888ef7e --- /dev/null +++ b/usrc/app/apublicboard/public_board_initer.cpp @@ -0,0 +1,117 @@ +#include "public_board_initer.hpp" + +#include "appcfg/publicboard.hpp" +using namespace iflytop; + +#include "main.h" +/** + * @brief 资料列表 + * + * CAN1 PA11 PA12 + * UART1 PA9 PA10 + * TIM6 + * TIM7 + * + */ + +/* TIM6 init function */ +void PublicBoardIniter::MX_TIM6_Init(void) { + __HAL_RCC_TIM6_CLK_ENABLE(); + + TIM_MasterConfigTypeDef sMasterConfig = {0}; + htim6.Instance = TIM6; + htim6.Init.Prescaler = 71; + htim6.Init.CounterMode = TIM_COUNTERMODE_UP; + htim6.Init.Period = 65535; + htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + if (HAL_TIM_Base_Init(&htim6) != HAL_OK) { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim6, &sMasterConfig) != HAL_OK) { + Error_Handler(); + } + + /* TIM6 interrupt Init */ + HAL_NVIC_SetPriority(TIM6_DAC_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn); +} +/* TIM7 init function */ +void PublicBoardIniter::MX_TIM7_Init(void) { + __HAL_RCC_TIM7_CLK_ENABLE(); + + TIM_MasterConfigTypeDef sMasterConfig = {0}; + htim7.Instance = TIM7; + htim7.Init.Prescaler = 81; + htim7.Init.CounterMode = TIM_COUNTERMODE_UP; + htim7.Init.Period = 65535; + htim7.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + if (HAL_TIM_Base_Init(&htim7) != HAL_OK) { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim7, &sMasterConfig) != HAL_OK) { + Error_Handler(); + } + + /* TIM7 interrupt Init */ + HAL_NVIC_SetPriority(TIM7_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(TIM7_IRQn); +} + +static void debug_uart_init() { + GPIO_InitTypeDef GPIO_InitStruct = {0}; + static_assert(PA9 == DEBUG_UART_TX); + static_assert(PA10 == DEBUG_UART_RX); + + /*********************************************************************************************************************** + * IO初始化 * + ***********************************************************************************************************************/ + __HAL_RCC_USART1_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_DMA2_CLK_ENABLE(); + + GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF7_USART1; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + huart1.Instance = USART1; + huart1.Init.BaudRate = 460800; + huart1.Init.WordLength = UART_WORDLENGTH_8B; + huart1.Init.StopBits = UART_STOPBITS_1; + huart1.Init.Parity = UART_PARITY_NONE; + huart1.Init.Mode = UART_MODE_TX_RX; + huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; + huart1.Init.OverSampling = UART_OVERSAMPLING_16; + if (HAL_UART_Init(&huart1) != HAL_OK) { + Error_Handler(); + } + + /*********************************************************************************************************************** + * DMA初始化 * + ***********************************************************************************************************************/ + HAL_NVIC_SetPriority(DMA2_Stream2_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA2_Stream2_IRQn); + hdma2_stream2.Instance = DMA2_Stream2; + hdma2_stream2.Init.Channel = DMA_CHANNEL_4; + hdma2_stream2.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma2_stream2.Init.PeriphInc = DMA_PINC_DISABLE; + hdma2_stream2.Init.MemInc = DMA_MINC_ENABLE; + hdma2_stream2.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; + hdma2_stream2.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; + hdma2_stream2.Init.Mode = DMA_NORMAL; + hdma2_stream2.Init.Priority = DMA_PRIORITY_LOW; + hdma2_stream2.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma2_stream2) != HAL_OK) { + Error_Handler(); + } + + __HAL_LINKDMA(&huart1, hdmarx, hdma2_stream2); + HAL_NVIC_SetPriority(USART1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(USART1_IRQn); +} \ No newline at end of file diff --git a/usrc/app/apublicboard/public_board_initer.hpp b/usrc/app/apublicboard/public_board_initer.hpp new file mode 100644 index 0000000..5c48202 --- /dev/null +++ b/usrc/app/apublicboard/public_board_initer.hpp @@ -0,0 +1,19 @@ +#pragma once +#include "appdep.hpp" +#include "project_configs.h" +namespace iflytop { +#define PB PublicBoardIniter::ins() +class PublicBoardIniter { + private: + /* data */ + public: + static PublicBoardIniter* ins() { + static PublicBoardIniter instance; + return &instance; + } + + void MX_TIM6_Init(); + void MX_TIM7_Init(); +}; + +} // namespace iflytop \ No newline at end of file diff --git a/usrc/app/main_controler/abasicboard/basicboard.cpp b/usrc/app/main_controler/abasicboard/basicboard.cpp new file mode 100644 index 0000000..0ab2347 --- /dev/null +++ b/usrc/app/main_controler/abasicboard/basicboard.cpp @@ -0,0 +1,3 @@ +#include "basicboard.hpp" +using namespace iflytop; + diff --git a/usrc/app/main_controler/abasicboard/basicboard.hpp b/usrc/app/main_controler/abasicboard/basicboard.hpp new file mode 100644 index 0000000..28d5c51 --- /dev/null +++ b/usrc/app/main_controler/abasicboard/basicboard.hpp @@ -0,0 +1,19 @@ +#pragma once +#include "appdep.hpp" +namespace iflytop { +using namespace std; +class BasicBoard { + private: + /* data */ + BasicBoard() {} + + public: + static BasicBoard* ins() { + static BasicBoard instance; + return &instance; + } + + +}; + +} // namespace iflytop \ No newline at end of file diff --git a/usrc/app/main_controler/main_controler.cpp b/usrc/app/main_controler/main_controler.cpp new file mode 100644 index 0000000..0baba7f --- /dev/null +++ b/usrc/app/main_controler/main_controler.cpp @@ -0,0 +1,3 @@ +#include "main_controler.hpp" + +using namespace iflytop; diff --git a/usrc/app/main_controler/main_controler.hpp b/usrc/app/main_controler/main_controler.hpp new file mode 100644 index 0000000..a3b22d4 --- /dev/null +++ b/usrc/app/main_controler/main_controler.hpp @@ -0,0 +1,14 @@ +#pragma once +#include "appdep.hpp" + +namespace iflytop { +class MainControler { + + public: + static MainControler* ins() { + static MainControler instance; + return &instance; + } + void init(){} +}; +} // namespace iflytop \ No newline at end of file diff --git a/usrc/app/main_controler_ui/README.md b/usrc/app/main_controler_ui/README.md new file mode 100644 index 0000000..aaf2c10 --- /dev/null +++ b/usrc/app/main_controler_ui/README.md @@ -0,0 +1,118 @@ +-¼ҳ +-ҳ +-Һѡҳ +-õҳ +-ҳ +-ҳ + +``` + + +------------------------------------------------------------------ + + ------------------------- + ҳ潻 + ------------------------- + | + -----------[״̬ص]--- + û + ----------------------- + ------------------ + ־û + ------------------ + + +ҳ潻 +û +ó־û +ƹ +ң +ſ + +------------------------------------------------------------------ + +``` + +``` + osDelay(1000); + ʼĻԪ״̬ + 1.¼ҳ + 2.ҳ + ... + ... + ... + ... + + ijЩ״̬ıʱ + ޸ĻӦԪ״̬ + 1.ʵ״̬ı + 2.㶯ģʽ±û״̬ı + 3.Զģʽ±û״̬ı + 4.ӵ״̬ + ޸ıʵ״̬1.Ƿߣ2.Ч + + config: + index,val + index,val + index,val + index,val + index,val + index,val + + ʰ¼ + Ʊ + ñʵ״̬ + + + 㶯 + +------------------------------------------------------ + Ļ + + ---> ޸ + ---> ޸״̬ + ---> лҳ + ---> + +``` + +``` + +----------------------------- +ҳ߼ + ҳ1 + ҳ2 + ҳ3 + +ң¼ + Һ + ̰¼ + ¼ + + ̰¼ + ¼ + +----------------------------- + + + + + +``` + +``` +1.ҳд + ҳ¼ص-> + ҳҳ¼->ҳ + +2.ң&&ң״̬ + ҵ״̬ + 1.¼ϱ + 2.ҵ״̬ʾ + + ״̬ + 1. + 2.͵״̬ + 3.豸״̬ + +``` diff --git a/ucomponents/hmp110/HMP60-and-HMP110-Series-User-Guide-M211060EN-L.pdf b/usrc/app/main_controler_ui/hand_acid_mainboard_ui.HMI similarity index 51% rename from ucomponents/hmp110/HMP60-and-HMP110-Series-User-Guide-M211060EN-L.pdf rename to usrc/app/main_controler_ui/hand_acid_mainboard_ui.HMI index 3409388..4398987 100644 Binary files a/ucomponents/hmp110/HMP60-and-HMP110-Series-User-Guide-M211060EN-L.pdf and b/usrc/app/main_controler_ui/hand_acid_mainboard_ui.HMI differ diff --git a/usrc/app/main_controler_ui/ui.h b/usrc/app/main_controler_ui/ui.h new file mode 100644 index 0000000..3729de8 --- /dev/null +++ b/usrc/app/main_controler_ui/ui.h @@ -0,0 +1,424 @@ +//pages +#define pg_gvar 0 +#define pg_pStart 1 +#define pg_login 2 +#define pg_main 3 +#define pg_keybAcidCh 4 +#define pg_menuAdmin 5 +#define pg_menuAdmin2 6 +#define pg_menuUsr 7 +#define pg_muInterval 8 +#define pg_muUsrMgr 9 +#define pg_muTmrMgr 10 +#define pg_muAcidType 11 +#define pg_muSettings 12 +#define pg_muDeviceInfo 13 +#define pg_muAudit 14 +#define pg_alert 15 +#define pg_confirm 16 +#define pg_changePasswd 17 +#define pg_keybdB 18 +#define pg_keybdAP 19 +#define pg_keybdA 20 +#define pg_keyPasswd 21 +//gvar.objs +#define ob_gvar_gvar 0 +#define ob_gvar_menupageid 1 +#define ob_gvar_bt0 2 +//pStart.objs +#define ob_pStart_pStart 0 +#define ob_pStart_j0 1 +#define ob_pStart_tm0 2 +//login.objs +#define ob_login_login 0 +#define ob_login_blogin 1 +#define ob_login_txtPasswd 2 +#define ob_login_txtUser0 3 +#define ob_login_txtUser1 4 +#define ob_login_txtUser2 5 +#define ob_login_txtUser3 6 +#define ob_login_txtUser4 7 +#define ob_login_txtUser5 8 +#define ob_login_m0 9 +#define ob_login_chooseUsr 10 +#define ob_login_cUsrName 11 +#define ob_login_uen0 12 +#define ob_login_uen1 13 +#define ob_login_uen2 14 +#define ob_login_uen3 15 +#define ob_login_uen4 16 +#define ob_login_uen5 17 +//main.objs +#define ob_main_main 0 +#define ob_main_acidch0 1 +#define ob_main_MenuButton 2 +#define ob_main_acidname0 3 +#define ob_main_acideval0 4 +#define ob_main_sysInfo 5 +#define ob_main_clock 6 +#define ob_main_acidname0id 7 +#define ob_main_acidname1id 8 +#define ob_main_acidname2id 9 +#define ob_main_acidname3id 10 +#define ob_main_RemoterS 11 +#define ob_main_AcidState 12 +#define ob_main_RunMode 13 +#define ob_main_RunModeVal 14 +#define ob_main_acidch1 15 +#define ob_main_acidname1 16 +#define ob_main_acideval1 17 +#define ob_main_acidch2 18 +#define ob_main_acidname2 19 +#define ob_main_acideval2 20 +#define ob_main_acidch3 21 +#define ob_main_acidname3 22 +#define ob_main_acideval3 23 +//keybAcidCh.objs +#define ob_keybAcidCh_keybAcidCh 0 +#define ob_keybAcidCh_bak 1 +#define ob_keybAcidCh_b0 2 +#define ob_keybAcidCh_b1 3 +#define ob_keybAcidCh_b2 4 +#define ob_keybAcidCh_b3 5 +#define ob_keybAcidCh_b4 6 +#define ob_keybAcidCh_b5 7 +#define ob_keybAcidCh_b6 8 +#define ob_keybAcidCh_b7 9 +#define ob_keybAcidCh_b8 10 +#define ob_keybAcidCh_b9 11 +#define ob_keybAcidCh_b10 12 +#define ob_keybAcidCh_b11 13 +#define ob_keybAcidCh_b12 14 +#define ob_keybAcidCh_b13 15 +#define ob_keybAcidCh_b14 16 +#define ob_keybAcidCh_loadpageid 17 +#define ob_keybAcidCh_loadcmpid 18 +#define ob_keybAcidCh_loadcmname 19 +#define ob_keybAcidCh_txt 20 +#define ob_keybAcidCh_fn0 21 +//menuAdmin.objs +#define ob_menuAdmin_menuAdmin 0 +#define ob_menuAdmin_home 1 +#define ob_menuAdmin_muInterval 2 +#define ob_menuAdmin_changePasswd 3 +#define ob_menuAdmin_muTmrMgr 4 +#define ob_menuAdmin_muAcidType 5 +#define ob_menuAdmin_muUsrMgr 6 +#define ob_menuAdmin_muSettings 7 +#define ob_menuAdmin_muAudit 8 +#define ob_menuAdmin_muDeviceInfo 9 +#define ob_menuAdmin_unlogin 10 +//menuAdmin2.objs +#define ob_menuAdmin2_menuAdmin2 0 +#define ob_menuAdmin2_home 1 +#define ob_menuAdmin2_muInterval 2 +#define ob_menuAdmin2_changePasswd 3 +#define ob_menuAdmin2_muAcidType 4 +#define ob_menuAdmin2_muUsrMgr 5 +#define ob_menuAdmin2_muSettings 6 +#define ob_menuAdmin2_muDeviceInfo 7 +#define ob_menuAdmin2_unlogin 8 +//menuUsr.objs +#define ob_menuUsr_menuUsr 0 +#define ob_menuUsr_home 1 +#define ob_menuUsr_muInterval 2 +#define ob_menuUsr_changePasswd 3 +#define ob_menuUsr_muDeviceInfo 4 +#define ob_menuUsr_unlogin 5 +//muInterval.objs +#define ob_muInterval_muInterval 0 +#define ob_muInterval_t0 1 +#define ob_muInterval_t1 2 +#define ob_muInterval_bak 3 +#define ob_muInterval_frompage 4 +#define ob_muInterval_stAcidInte 5 +#define ob_muInterval_t2 6 +//muUsrMgr.objs +#define ob_muUsrMgr_muUsrMgr 0 +#define ob_muUsrMgr_bak 1 +#define ob_muUsrMgr_t0 2 +#define ob_muUsrMgr_t2 3 +#define ob_muUsrMgr_t3 4 +#define ob_muUsrMgr_t4 5 +#define ob_muUsrMgr_sw1 6 +#define ob_muUsrMgr_t6 7 +#define ob_muUsrMgr_sw2 8 +#define ob_muUsrMgr_t8 9 +#define ob_muUsrMgr_sw3 10 +#define ob_muUsrMgr_t10 11 +#define ob_muUsrMgr_sw4 12 +#define ob_muUsrMgr_t12 13 +#define ob_muUsrMgr_b1 14 +#define ob_muUsrMgr_b0 15 +#define ob_muUsrMgr_b2 16 +#define ob_muUsrMgr_b3 17 +#define ob_muUsrMgr_frompage 18 +//muTmrMgr.objs +#define ob_muTmrMgr_muTmrMgr 0 +#define ob_muTmrMgr_select0 1 +#define ob_muTmrMgr_select1 2 +#define ob_muTmrMgr_select2 3 +#define ob_muTmrMgr_bak 4 +#define ob_muTmrMgr_select3 5 +#define ob_muTmrMgr_select4 6 +#define ob_muTmrMgr_select5 7 +#define ob_muTmrMgr_b0 8 +#define ob_muTmrMgr_frompage 9 +//muAcidType.objs +#define ob_muAcidType_muAcidType 0 +#define ob_muAcidType_frompage 1 +#define ob_muAcidType_bak 2 +#define ob_muAcidType_t1 3 +#define ob_muAcidType_t2 4 +#define ob_muAcidType_t3 5 +#define ob_muAcidType_t4 6 +#define ob_muAcidType_t5 7 +#define ob_muAcidType_t6 8 +#define ob_muAcidType_t7 9 +#define ob_muAcidType_t8 10 +#define ob_muAcidType_t9 11 +#define ob_muAcidType_t10 12 +#define ob_muAcidType_t11 13 +#define ob_muAcidType_t12 14 +#define ob_muAcidType_t13 15 +#define ob_muAcidType_t14 16 +#define ob_muAcidType_t15 17 +//muSettings.objs +#define ob_muSettings_muSettings 0 +#define ob_muSettings_t0 1 +#define ob_muSettings_t1 2 +#define ob_muSettings_bak 3 +#define ob_muSettings_frompage 4 +#define ob_muSettings_stAcidInte 5 +#define ob_muSettings_t2 6 +//muDeviceInfo.objs +#define ob_muDeviceInfo_muDeviceInfo 0 +#define ob_muDeviceInfo_bak 1 +#define ob_muDeviceInfo_t2 2 +#define ob_muDeviceInfo_t3 3 +#define ob_muDeviceInfo_t6 4 +#define ob_muDeviceInfo_t7 5 +#define ob_muDeviceInfo_t10 6 +#define ob_muDeviceInfo_t11 7 +#define ob_muDeviceInfo_frompage 8 +//muAudit.objs +#define ob_muAudit_muAudit 0 +#define ob_muAudit_bak 1 +#define ob_muAudit_t0 2 +#define ob_muAudit_t1 3 +#define ob_muAudit_t2 4 +#define ob_muAudit_b0 5 +#define ob_muAudit_b1 6 +#define ob_muAudit_frompage 7 +//alert.objs +#define ob_alert_alert 0 +#define ob_alert_t0 1 +#define ob_alert_confirmkey 2 +#define ob_alert_info 3 +#define ob_alert_frompage 4 +//confirm.objs +#define ob_confirm_confirm 0 +#define ob_confirm_t0 1 +#define ob_confirm_confirmkey 2 +#define ob_confirm_info 3 +#define ob_confirm_canclekey 4 +#define ob_confirm_frompage 5 +//changePasswd.objs +#define ob_changePasswd_changePasswd 0 +#define ob_changePasswd_t2 1 +#define ob_changePasswd_t3 2 +#define ob_changePasswd_t4 3 +#define ob_changePasswd_t5 4 +#define ob_changePasswd_b0 5 +#define ob_changePasswd_b1 6 +#define ob_changePasswd_t0 7 +#define ob_changePasswd_t1 8 +#define ob_changePasswd_frompage 9 +//keybdB.objs +#define ob_keybdB_keybdB 0 +#define ob_keybdB_b0 1 +#define ob_keybdB_show 2 +#define ob_keybdB_b210 3 +#define ob_keybdB_b1 4 +#define ob_keybdB_b2 5 +#define ob_keybdB_b3 6 +#define ob_keybdB_b4 7 +#define ob_keybdB_b5 8 +#define ob_keybdB_b6 9 +#define ob_keybdB_b7 10 +#define ob_keybdB_b8 11 +#define ob_keybdB_b200 12 +#define ob_keybdB_b9 13 +#define ob_keybdB_loadpageid 14 +#define ob_keybdB_tm0 15 +#define ob_keybdB_loadcmpid 16 +#define ob_keybdB_input 17 +#define ob_keybdB_temp 18 +#define ob_keybdB_inputlenth 19 +#define ob_keybdB_t2 20 +#define ob_keybdB_b251 21 +#define ob_keybdB_temp2 22 +#define ob_keybdB_tempstr 23 +#define ob_keybdB_b10 24 +#define ob_keybdB_b11 25 +#define ob_keybdB_loadcmname 26 +//keybdAP.objs +#define ob_keybdAP_keybdAP 0 +#define ob_keybdAP_loadpageid 1 +#define ob_keybdAP_loadcmpid 2 +#define ob_keybdAP_b0 3 +#define ob_keybdAP_b251 4 +#define ob_keybdAP_b210 5 +#define ob_keybdAP_b1 6 +#define ob_keybdAP_b2 7 +#define ob_keybdAP_b3 8 +#define ob_keybdAP_b4 9 +#define ob_keybdAP_b5 10 +#define ob_keybdAP_b6 11 +#define ob_keybdAP_b7 12 +#define ob_keybdAP_b8 13 +#define ob_keybdAP_b200 14 +#define ob_keybdAP_b20 15 +#define ob_keybdAP_b21 16 +#define ob_keybdAP_b22 17 +#define ob_keybdAP_b23 18 +#define ob_keybdAP_b24 19 +#define ob_keybdAP_b25 20 +#define ob_keybdAP_b26 21 +#define ob_keybdAP_b27 22 +#define ob_keybdAP_b28 23 +#define ob_keybdAP_b220 24 +#define ob_keybdAP_b40 25 +#define ob_keybdAP_b41 26 +#define ob_keybdAP_b42 27 +#define ob_keybdAP_b43 28 +#define ob_keybdAP_b44 29 +#define ob_keybdAP_b45 30 +#define ob_keybdAP_b46 31 +#define ob_keybdAP_b230 32 +#define ob_keybdAP_b240 33 +#define ob_keybdAP_b242 34 +#define ob_keybdAP_b241 35 +#define ob_keybdAP_b244 36 +#define ob_keybdAP_b231 37 +#define ob_keybdAP_b245 38 +#define ob_keybdAP_refshowbu 39 +#define ob_keybdAP_tm0 40 +#define ob_keybdAP_input 41 +#define ob_keybdAP_show 42 +#define ob_keybdAP_temp 43 +#define ob_keybdAP_inputlenth 44 +#define ob_keybdAP_b249 45 +#define ob_keybdAP_b201 46 +#define ob_keybdAP_b9 47 +#define ob_keybdAP_b232 48 +#define ob_keybdAP_b243 49 +#define ob_keybdAP_pa_z 50 +#define ob_keybdAP_pa_d 51 +#define ob_keybdAP_pastr1 52 +#define ob_keybdAP_ii 53 +#define ob_keybdAP_loadpa 54 +#define ob_keybdAP_pastr0 55 +#define ob_keybdAP_bp1 56 +#define ob_keybdAP_bp2 57 +#define ob_keybdAP_bp3 58 +#define ob_keybdAP_bp4 59 +#define ob_keybdAP_bp5 60 +#define ob_keybdAP_bp6 61 +#define ob_keybdAP_bp7 62 +#define ob_keybdAP_bp8 63 +#define ob_keybdAP_bp9 64 +#define ob_keybdAP_bp10 65 +#define ob_keybdAP_bp11 66 +#define ob_keybdAP_bp12 67 +#define ob_keybdAP_bp13 68 +#define ob_keybdAP_bp14 69 +#define ob_keybdAP_bp15 70 +#define ob_keybdAP_bp16 71 +#define ob_keybdAP_bp17 72 +#define ob_keybdAP_bp18 73 +#define ob_keybdAP_b10 74 +#define ob_keybdAP_b11 75 +#define ob_keybdAP_temp2 76 +#define ob_keybdAP_tempstr 77 +#define ob_keybdAP_loadcmname 78 +//keybdA.objs +#define ob_keybdA_keybdA 0 +#define ob_keybdA_loadpageid 1 +#define ob_keybdA_loadcmpid 2 +#define ob_keybdA_b0 3 +#define ob_keybdA_b251 4 +#define ob_keybdA_b210 5 +#define ob_keybdA_b1 6 +#define ob_keybdA_b2 7 +#define ob_keybdA_b3 8 +#define ob_keybdA_b4 9 +#define ob_keybdA_b5 10 +#define ob_keybdA_b6 11 +#define ob_keybdA_b7 12 +#define ob_keybdA_b8 13 +#define ob_keybdA_b200 14 +#define ob_keybdA_b20 15 +#define ob_keybdA_b21 16 +#define ob_keybdA_b22 17 +#define ob_keybdA_b23 18 +#define ob_keybdA_b24 19 +#define ob_keybdA_b25 20 +#define ob_keybdA_b26 21 +#define ob_keybdA_b27 22 +#define ob_keybdA_b28 23 +#define ob_keybdA_b220 24 +#define ob_keybdA_b40 25 +#define ob_keybdA_b41 26 +#define ob_keybdA_b42 27 +#define ob_keybdA_b43 28 +#define ob_keybdA_b44 29 +#define ob_keybdA_b45 30 +#define ob_keybdA_b46 31 +#define ob_keybdA_b230 32 +#define ob_keybdA_b240 33 +#define ob_keybdA_b242 34 +#define ob_keybdA_b241 35 +#define ob_keybdA_b243 36 +#define ob_keybdA_b231 37 +#define ob_keybdA_b244 38 +#define ob_keybdA_refshow 39 +#define ob_keybdA_tm0 40 +#define ob_keybdA_input 41 +#define ob_keybdA_show 42 +#define ob_keybdA_temp 43 +#define ob_keybdA_inputlenth 44 +#define ob_keybdA_b249 45 +#define ob_keybdA_b201 46 +#define ob_keybdA_b9 47 +#define ob_keybdA_b232 48 +#define ob_keybdA_tempstr 49 +#define ob_keybdA_temp2 50 +#define ob_keybdA_loadcmname 51 +//keyPasswd.objs +#define ob_keyPasswd_keyPasswd 0 +#define ob_keyPasswd_b0 1 +#define ob_keyPasswd_show 2 +#define ob_keyPasswd_b210 3 +#define ob_keyPasswd_b1 4 +#define ob_keyPasswd_b2 5 +#define ob_keyPasswd_b3 6 +#define ob_keyPasswd_b4 7 +#define ob_keyPasswd_b5 8 +#define ob_keyPasswd_b6 9 +#define ob_keyPasswd_b7 10 +#define ob_keyPasswd_b8 11 +#define ob_keyPasswd_b200 12 +#define ob_keyPasswd_b9 13 +#define ob_keyPasswd_loadpageid 14 +#define ob_keyPasswd_tm0 15 +#define ob_keyPasswd_loadcmpid 16 +#define ob_keyPasswd_input 17 +#define ob_keyPasswd_temp 18 +#define ob_keyPasswd_inputlenth 19 +#define ob_keyPasswd_t2 20 +#define ob_keyPasswd_b251 21 +#define ob_keyPasswd_temp2 22 +#define ob_keyPasswd_tempstr 23 +#define ob_keyPasswd_b249 24 +#define ob_keyPasswd_loadcmname 25 diff --git a/usrc/app/valvecontroler/valvecontroler.cpp b/usrc/app/valvecontroler/valvecontroler.cpp new file mode 100644 index 0000000..bff395d --- /dev/null +++ b/usrc/app/valvecontroler/valvecontroler.cpp @@ -0,0 +1,5 @@ +#include "valvecontroler.hpp" + +using namespace iflytop; + +void ValvaControler::init() {} \ No newline at end of file diff --git a/usrc/app/valvecontroler/valvecontroler.hpp b/usrc/app/valvecontroler/valvecontroler.hpp new file mode 100644 index 0000000..57cd082 --- /dev/null +++ b/usrc/app/valvecontroler/valvecontroler.hpp @@ -0,0 +1,13 @@ +#pragma once +#include "appdep.hpp" + +namespace iflytop { +class ValvaControler { + public: + static ValvaControler* ins() { + static ValvaControler instance; + return &instance; + } + void init(); +}; +} // namespace iflytop \ No newline at end of file diff --git a/usrc/app_main.cpp b/usrc/app_main.cpp index f8417d0..51fdda6 100644 --- a/usrc/app_main.cpp +++ b/usrc/app_main.cpp @@ -2,6 +2,10 @@ #include // #include "appdep.hpp" +#include "apppublic/boardid.hpp" +// +#include "app/main_controler/main_controler.hpp" +#include "app/valvecontroler/valvecontroler.hpp" #define TAG "main" extern void umain(); @@ -12,6 +16,8 @@ void StartDefaultTask(void const *argument) { umain(); } * MAIN * *******************************************************************************/ +using namespace iflytop; + /* IWDG init function */ void MX_IWDG_Init(void) { hiwdg.Instance = IWDG; @@ -22,6 +28,30 @@ void MX_IWDG_Init(void) { } } +static ZGPIO debuglight0; +static ZGPIO debuglight1; +static bool errorFlag; +static inline void debugLightLoop() { + static bool light = false; + static uint32_t lastcall = 0; + + if (errorFlag) { + if (zos_haspassedms(lastcall) > 30) { + light = !light; + debuglight0.write(light); + debuglight1.write(light); + lastcall = zos_get_tick(); + } + } else { + if (zos_haspassedms(lastcall) > 300) { + light = !light; + debuglight0.write(light); + debuglight1.write(light); + lastcall = zos_get_tick(); + } + } +} + int32_t getDeviceIdFromFlash() { int32_t *deviceId = (int32_t *)BOARD_TYPE_ID_FLASH_ADD; if (*deviceId <= 0) { @@ -32,9 +62,21 @@ int32_t getDeviceIdFromFlash() { void umain() { MX_IWDG_Init(); + + debuglight0.initAsOutput(DEBUG_LIGHT_IO0, kxs_gpio_nopull, false, false); + debuglight1.initAsOutput(DEBUG_LIGHT_IO1, kxs_gpio_nopull, false, false); + int32_t id = getDeviceIdFromFlash(); + if (id == boardid::kbmainboard) { + MainControler::ins()->init(); + } else if (id == boardid::kvalveboard) { + ValvaControler::ins()->init(); + } else { + errorFlag = true; + } + while (true) { osDelay(30); - // debug_light_ctrl(); + debugLightLoop(); HAL_IWDG_Refresh(&hiwdg); } } diff --git a/usrc/appcfg/publicboard.hpp b/usrc/appcfg/publicboard.hpp new file mode 100644 index 0000000..58c5a02 --- /dev/null +++ b/usrc/appcfg/publicboard.hpp @@ -0,0 +1,4 @@ +#pragma once + +#define DEBUG_UART_TX PA9 +#define DEBUG_UART_RX PA10 \ No newline at end of file