From 986dbc2bbbdc5754b0338ecd0a4dbfa349b2cad6 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Thu, 27 Jun 2024 11:33:49 +0800 Subject: [PATCH] update --- components/api/zi_eeprom.hpp | 4 ++-- components/sensors/i2ceeprom/m24lrxxe_i2c_eeprom.cpp | 14 ++++++++++---- components/sensors/i2ceeprom/m24lrxxe_i2c_eeprom.hpp | 13 +++++++------ components/sensors/i2ceeprom/p24c16_eeprom.cpp | 6 +++--- components/sensors/i2ceeprom/p24c16_eeprom.hpp | 2 +- .../water_cooling_temperature_control_module.hpp | 2 +- 6 files changed, 24 insertions(+), 17 deletions(-) diff --git a/components/api/zi_eeprom.hpp b/components/api/zi_eeprom.hpp index 8a01a34..22ee9ef 100644 --- a/components/api/zi_eeprom.hpp +++ b/components/api/zi_eeprom.hpp @@ -26,8 +26,8 @@ class ZI_EEPROM { * @param len 4的倍数 * @return int32_t */ - virtual int32_t write(int32_t add, uint8_t* val, int32_t *len) = 0; - virtual int32_t read(int32_t add, uint8_t* val, int32_t *len) = 0; + virtual int32_t write(int32_t add, uint8_t* val, int32_t len) = 0; + virtual int32_t read(int32_t add, uint8_t* val, int32_t* len) = 0; virtual bool isOnline() = 0; }; diff --git a/components/sensors/i2ceeprom/m24lrxxe_i2c_eeprom.cpp b/components/sensors/i2ceeprom/m24lrxxe_i2c_eeprom.cpp index 904e06e..e1356c7 100644 --- a/components/sensors/i2ceeprom/m24lrxxe_i2c_eeprom.cpp +++ b/components/sensors/i2ceeprom/m24lrxxe_i2c_eeprom.cpp @@ -17,13 +17,13 @@ static int32_t halstatustoerr(HAL_StatusTypeDef status) { } } -void M24LRXXE_I2C_EEPROM::initialize( I2C_HandleTypeDef* i2c_handle) { m_i2c_handle = i2c_handle; } +void M24LRXXE_I2C_EEPROM::initialize(I2C_HandleTypeDef* i2c_handle) { m_i2c_handle = i2c_handle; } -int32_t M24LRXXE_I2C_EEPROM::write(int32_t add, uint8_t* val, int32_t* len) { - ZASSERT(*len % 4 == 0); +int32_t M24LRXXE_I2C_EEPROM::write(int32_t add, uint8_t* val, int32_t len) { + ZASSERT(len % 4 == 0); ZASSERT(add % 4 == 0); int32_t ecode = 0; - for (int32_t i = 0; i < *len; i += 4) { + for (int32_t i = 0; i < len; i += 4) { ecode = write32(add + i, *(uint32_t*)&val[i]); if (ecode != 0) return ecode; } @@ -39,6 +39,12 @@ int32_t M24LRXXE_I2C_EEPROM::read(int32_t add, uint8_t* val, int32_t* len) { } return ecode; } + +int32_t M24LRXXE_I2C_EEPROM::readCfgReg(int32_t add, uint32_t* val) { + HAL_StatusTypeDef status = HAL_I2C_Mem_Read(m_i2c_handle, CONFIG_ADD << 1, add, I2C_MEMADD_SIZE_16BIT, (uint8_t*)val, 4, 10); + return halstatustoerr(status); +} + bool M24LRXXE_I2C_EEPROM::isOnline() { uint32_t val = 0; int32_t ret = read32(0, &val); diff --git a/components/sensors/i2ceeprom/m24lrxxe_i2c_eeprom.hpp b/components/sensors/i2ceeprom/m24lrxxe_i2c_eeprom.hpp index 802ae9c..449e11e 100644 --- a/components/sensors/i2ceeprom/m24lrxxe_i2c_eeprom.hpp +++ b/components/sensors/i2ceeprom/m24lrxxe_i2c_eeprom.hpp @@ -1,25 +1,26 @@ -#include "sdk\components\api\zi_eeprom.hpp" #include "a8000_protocol\protocol.hpp" +#include "sdk\components\api\zi_eeprom.hpp" #include "sdk\os\zos.hpp" #ifdef HAL_I2C_MODULE_ENABLED namespace iflytop { using namespace std; -//ref::https://iflytop1.feishu.cn/wiki/PO1LwwvaNi4F10kiobMcjSK4nBg +// ref::https://iflytop1.feishu.cn/wiki/PO1LwwvaNi4F10kiobMcjSK4nBg class M24LRXXE_I2C_EEPROM : public ZI_EEPROM { I2C_HandleTypeDef* m_i2c_handle; - public: M24LRXXE_I2C_EEPROM(){}; ~M24LRXXE_I2C_EEPROM(){}; - void initialize( I2C_HandleTypeDef* i2c_handle); + void initialize(I2C_HandleTypeDef* i2c_handle); - virtual int32_t write(int32_t add, uint8_t* val, int32_t *len) override; - virtual int32_t read(int32_t add, uint8_t* val, int32_t *len) override; + virtual int32_t write(int32_t add, uint8_t* val, int32_t len) override; + virtual int32_t read(int32_t add, uint8_t* val, int32_t* len) override; virtual bool isOnline() override; + int32_t readCfgReg(int32_t add, uint32_t* val); + private: int32_t write32(uint16_t add, uint32_t val); int32_t read32(uint16_t add, uint32_t* val); diff --git a/components/sensors/i2ceeprom/p24c16_eeprom.cpp b/components/sensors/i2ceeprom/p24c16_eeprom.cpp index 1eb5e13..86b40b0 100644 --- a/components/sensors/i2ceeprom/p24c16_eeprom.cpp +++ b/components/sensors/i2ceeprom/p24c16_eeprom.cpp @@ -18,11 +18,11 @@ static int32_t halstatustoerr(HAL_StatusTypeDef status) { void P24C16::initialize( I2C_HandleTypeDef* i2c_handle) { m_i2c_handle = i2c_handle; } -int32_t P24C16::write(int32_t add, uint8_t* val, int32_t* len) { - ZASSERT(*len % 4 == 0); +int32_t P24C16::write(int32_t add, uint8_t* val, int32_t len) { + ZASSERT(len % 4 == 0); ZASSERT(add % 4 == 0); int32_t ecode = 0; - for (int32_t i = 0; i < *len; i += 4) { + for (int32_t i = 0; i < len; i += 4) { ecode = write32(add + i, *(uint32_t*)&val[i]); if (ecode != 0) return ecode; } diff --git a/components/sensors/i2ceeprom/p24c16_eeprom.hpp b/components/sensors/i2ceeprom/p24c16_eeprom.hpp index 09dadb5..a17a56f 100644 --- a/components/sensors/i2ceeprom/p24c16_eeprom.hpp +++ b/components/sensors/i2ceeprom/p24c16_eeprom.hpp @@ -15,7 +15,7 @@ class P24C16 : public ZI_EEPROM { void initialize( I2C_HandleTypeDef* i2c_handle); - virtual int32_t write(int32_t add, uint8_t* val, int32_t* len) override; + virtual int32_t write(int32_t add, uint8_t* val, int32_t len) override; virtual int32_t read(int32_t add, uint8_t* val, int32_t* len) override; virtual bool isOnline() override; diff --git a/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.hpp b/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.hpp index c0d42a8..4407741 100644 --- a/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.hpp +++ b/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.hpp @@ -34,7 +34,7 @@ namespace iflytop { */ class WaterCoolingTemperatureControlModule : public ZIModule, public ZI_WaterCoolingTemperatureControler { - ENABLE_MODULE(WaterCoolingTemperatureControlModule, kwater_temperature_ctrl_module, PC_VERSION); + ENABLE_MODULE(WaterCoolingTemperatureControlModule, ktemperature_ctrl_module, PC_VERSION); public: typedef struct {