From 37daa32f7b033f979452c7a308c74428fe1c6d94 Mon Sep 17 00:00:00 2001 From: Ruben Noroian Date: Sun, 10 Nov 2024 17:28:41 -0500 Subject: [PATCH 01/12] add cerb changes to build proper --- Core/Src/pdu.c | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/Core/Src/pdu.c b/Core/Src/pdu.c index 586d2920..2ca6e818 100644 --- a/Core/Src/pdu.c +++ b/Core/Src/pdu.c @@ -19,6 +19,43 @@ static osMutexAttr_t pdu_mutex_attributes; +/*Function specifications +typedef int (*WritePtr)(uint16_t dev_addr, uint16_t mem_address, + uint16_t mem_add_size, uint8_t *data, uint16_t size, + int delay); +typedef int (*ReadPtr)(uint16_t dev_addr, uint16_t mem_address, + uint16_t mem_add_size, uint8_t *data, uint16_t size, + int delay); + +*/ + +I2C_HandleTypeDef* i2c_handler; + +int stm_i2c_write(uint16_t dev_addr, uint16_t address, + uint16_t mem_add_size, uint8_t *data, uint16_t size, + int delay){ + + return HAL_I2C_Mem_Write(i2c_handler, dev_addr, address, mem_add_size, data, size, + delay); + + +}; + + +int stm_i2c_read(uint16_t dev_addr, uint16_t address, + uint16_t mem_add_size, uint8_t *data, uint16_t size, + int delay){ + + return HAL_I2C_Mem_Read(i2c_handler, dev_addr, address, mem_add_size, data, size, + delay); +}; + + + + + + + static uint8_t sound_rtds(pdu_t *pdu) { if (!pdu) @@ -129,7 +166,9 @@ pdu_t *init_pdu(I2C_HandleTypeDef *hi2c) /* Initialize Control GPIO Expander */ pdu->ctrl_expander = malloc(sizeof(pca9539_t)); assert(pdu->ctrl_expander); - pca9539_init(pdu->ctrl_expander, pdu->hi2c, CTRL_ADDR); + + //NEED + pca9539_init(pdu->ctrl_expander, stm_i2c_write, stm_i2c_read, CTRL_ADDR); // write everything OFF, FAULT 1 is off uint8_t buf = 0b00000010; From a942577508fa2fe6e86e59249fb5a59d5f44164f Mon Sep 17 00:00:00 2001 From: Ruben Noroian Date: Sun, 10 Nov 2024 18:05:12 -0500 Subject: [PATCH 02/12] new changes --- Core/Src/pdu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Core/Src/pdu.c b/Core/Src/pdu.c index 2ca6e818..4aedd1ec 100644 --- a/Core/Src/pdu.c +++ b/Core/Src/pdu.c @@ -29,24 +29,24 @@ typedef int (*ReadPtr)(uint16_t dev_addr, uint16_t mem_address, */ -I2C_HandleTypeDef* i2c_handler; +extern I2C_HandleTypeDef hi2c2; -int stm_i2c_write(uint16_t dev_addr, uint16_t address, +static inline int stm_i2c_write(uint16_t dev_addr, uint16_t address, uint16_t mem_add_size, uint8_t *data, uint16_t size, int delay){ - return HAL_I2C_Mem_Write(i2c_handler, dev_addr, address, mem_add_size, data, size, + return HAL_I2C_Mem_Write(&hi2c2, dev_addr, address, mem_add_size, data, size, delay); }; -int stm_i2c_read(uint16_t dev_addr, uint16_t address, +static inline int stm_i2c_read(uint16_t dev_addr, uint16_t address, uint16_t mem_add_size, uint8_t *data, uint16_t size, int delay){ - return HAL_I2C_Mem_Read(i2c_handler, dev_addr, address, mem_add_size, data, size, + return HAL_I2C_Mem_Read(&hi2c2, dev_addr, address, mem_add_size, data, size, delay); }; From 8f7768f39cbfa143c163aecda43005deac78a107 Mon Sep 17 00:00:00 2001 From: Ruben Noroian Date: Thu, 5 Dec 2024 15:05:13 -0500 Subject: [PATCH 03/12] fixed formatting of functions --- Core/Src/pdu.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/Core/Src/pdu.c b/Core/Src/pdu.c index 0a7aa1f2..364dbbb1 100644 --- a/Core/Src/pdu.c +++ b/Core/Src/pdu.c @@ -19,21 +19,9 @@ static osMutexAttr_t pdu_mutex_attributes; -/*Function specifications -typedef int (*WritePtr)(uint16_t dev_addr, uint16_t mem_address, - uint16_t mem_add_size, uint8_t *data, uint16_t size, - int delay); -typedef int (*ReadPtr)(uint16_t dev_addr, uint16_t mem_address, - uint16_t mem_add_size, uint8_t *data, uint16_t size, - int delay); - -*/ - extern I2C_HandleTypeDef hi2c2; -static inline int stm_i2c_write(uint16_t dev_addr, uint16_t address, - uint16_t mem_add_size, uint8_t *data, uint16_t size, - int delay){ +static inline int stm_i2c_write(uint16_t dev_addr, uint16_t address, uint16_t mem_add_size, uint8_t *data, uint16_t size, int delay){ return HAL_I2C_Mem_Write(&hi2c2, dev_addr, address, mem_add_size, data, size, delay); @@ -42,20 +30,12 @@ static inline int stm_i2c_write(uint16_t dev_addr, uint16_t address, }; -static inline int stm_i2c_read(uint16_t dev_addr, uint16_t address, - uint16_t mem_add_size, uint8_t *data, uint16_t size, - int delay){ +static inline int stm_i2c_read(uint16_t dev_addr, uint16_t address, uint16_t mem_add_size, uint8_t *data, uint16_t size, int delay){ return HAL_I2C_Mem_Read(&hi2c2, dev_addr, address, mem_add_size, data, size, delay); }; - - - - - - static uint8_t sound_rtds(pdu_t *pdu) { if (!pdu) From 155a2250861f057d772f04de6f967dc5fdbf5166 Mon Sep 17 00:00:00 2001 From: Ruben Noroian Date: Thu, 5 Dec 2024 15:06:07 -0500 Subject: [PATCH 04/12] fixed formatting of functions --- Core/Src/pdu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Core/Src/pdu.c b/Core/Src/pdu.c index 364dbbb1..2a99d53c 100644 --- a/Core/Src/pdu.c +++ b/Core/Src/pdu.c @@ -23,8 +23,7 @@ extern I2C_HandleTypeDef hi2c2; static inline int stm_i2c_write(uint16_t dev_addr, uint16_t address, uint16_t mem_add_size, uint8_t *data, uint16_t size, int delay){ - return HAL_I2C_Mem_Write(&hi2c2, dev_addr, address, mem_add_size, data, size, - delay); + return HAL_I2C_Mem_Write(&hi2c2, dev_addr, address, mem_add_size, data, size, delay); }; @@ -32,8 +31,7 @@ static inline int stm_i2c_write(uint16_t dev_addr, uint16_t address, uint16_t me static inline int stm_i2c_read(uint16_t dev_addr, uint16_t address, uint16_t mem_add_size, uint8_t *data, uint16_t size, int delay){ - return HAL_I2C_Mem_Read(&hi2c2, dev_addr, address, mem_add_size, data, size, - delay); + return HAL_I2C_Mem_Read(&hi2c2, dev_addr, address, mem_add_size, data, size, delay); }; static uint8_t sound_rtds(pdu_t *pdu) From 3513daa44505ad8fb4d1813fcaf548d12d919577 Mon Sep 17 00:00:00 2001 From: Ruben Noroian Date: Thu, 5 Dec 2024 15:09:04 -0500 Subject: [PATCH 05/12] fixed formatting of functions --- Core/Src/pdu.c | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/Core/Src/pdu.c b/Core/Src/pdu.c index 2a99d53c..eba272f7 100644 --- a/Core/Src/pdu.c +++ b/Core/Src/pdu.c @@ -21,18 +21,44 @@ static osMutexAttr_t pdu_mutex_attributes; extern I2C_HandleTypeDef hi2c2; -static inline int stm_i2c_write(uint16_t dev_addr, uint16_t address, uint16_t mem_add_size, uint8_t *data, uint16_t size, int delay){ - - return HAL_I2C_Mem_Write(&hi2c2, dev_addr, address, mem_add_size, data, size, delay); - - -}; - +static inline int stm_i2c_write( + uint16_t dev_addr, + uint16_t address, + uint16_t mem_add_size, + uint8_t *data, + uint16_t size, + int delay +){ + return HAL_I2C_Mem_Write( + &hi2c2, + dev_addr, + address, + mem_add_size, + data, + size, + delay + ); +} -static inline int stm_i2c_read(uint16_t dev_addr, uint16_t address, uint16_t mem_add_size, uint8_t *data, uint16_t size, int delay){ +static inline int stm_i2c_read( + uint16_t dev_addr, + uint16_t address, + uint16_t mem_add_size, + uint8_t *data, + uint16_t size, + int delay +){ + return HAL_I2C_Mem_Read( + &hi2c2, + dev_addr, + address, + mem_add_size, + data, + size, + delay + ); +} - return HAL_I2C_Mem_Read(&hi2c2, dev_addr, address, mem_add_size, data, size, delay); -}; static uint8_t sound_rtds(pdu_t *pdu) { From 83dcd2a99ece366d22bf26308d351fca2e289a98 Mon Sep 17 00:00:00 2001 From: Ruben Noroian Date: Thu, 5 Dec 2024 15:30:12 -0500 Subject: [PATCH 06/12] fixed formatting of functions --- Core/Src/pdu.c | 47 ++++++++++++----------------------------------- 1 file changed, 12 insertions(+), 35 deletions(-) diff --git a/Core/Src/pdu.c b/Core/Src/pdu.c index eba272f7..445f6063 100644 --- a/Core/Src/pdu.c +++ b/Core/Src/pdu.c @@ -21,45 +21,22 @@ static osMutexAttr_t pdu_mutex_attributes; extern I2C_HandleTypeDef hi2c2; -static inline int stm_i2c_write( - uint16_t dev_addr, - uint16_t address, - uint16_t mem_add_size, - uint8_t *data, - uint16_t size, - int delay -){ - return HAL_I2C_Mem_Write( - &hi2c2, - dev_addr, - address, - mem_add_size, - data, - size, - delay - ); +static inline int stm_i2c_write(uint16_t dev_addr, uint16_t address, + uint16_t mem_add_size, uint8_t *data, uint16_t size, + int delay) +{ + return HAL_I2C_Mem_Write(&hi2c2, dev_addr, address, + mem_add_size, data, size, delay); } -static inline int stm_i2c_read( - uint16_t dev_addr, - uint16_t address, - uint16_t mem_add_size, - uint8_t *data, - uint16_t size, - int delay -){ - return HAL_I2C_Mem_Read( - &hi2c2, - dev_addr, - address, - mem_add_size, - data, - size, - delay - ); +static inline int stm_i2c_read(uint16_t dev_addr, uint16_t address, + uint16_t mem_add_size, uint8_t *data, uint16_t size, + int delay) +{ + return HAL_I2C_Mem_Write(&hi2c2, dev_addr, address, + mem_add_size, data, size, delay); } - static uint8_t sound_rtds(pdu_t *pdu) { if (!pdu) From bc5abaa5739cbabf39f01819fa124c70bcf891dc Mon Sep 17 00:00:00 2001 From: Ruben Noroian Date: Thu, 5 Dec 2024 15:33:22 -0500 Subject: [PATCH 07/12] fixed formatting of functions --- Core/Src/pdu.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Core/Src/pdu.c b/Core/Src/pdu.c index 445f6063..1932a4f9 100644 --- a/Core/Src/pdu.c +++ b/Core/Src/pdu.c @@ -22,19 +22,21 @@ static osMutexAttr_t pdu_mutex_attributes; extern I2C_HandleTypeDef hi2c2; static inline int stm_i2c_write(uint16_t dev_addr, uint16_t address, - uint16_t mem_add_size, uint8_t *data, uint16_t size, - int delay) + uint16_t mem_add_size, uint8_t *data, + uint16_t size, int delay) { return HAL_I2C_Mem_Write(&hi2c2, dev_addr, address, - mem_add_size, data, size, delay); + mem_add_size, data, + size, delay); } static inline int stm_i2c_read(uint16_t dev_addr, uint16_t address, - uint16_t mem_add_size, uint8_t *data, uint16_t size, - int delay) + uint16_t mem_add_size, uint8_t *data, + uint16_t size, int delay) { return HAL_I2C_Mem_Write(&hi2c2, dev_addr, address, - mem_add_size, data, size, delay); + mem_add_size, data, + size, delay); } static uint8_t sound_rtds(pdu_t *pdu) From d0d83c9ccda149a7a88c2d79ac610f76928cc766 Mon Sep 17 00:00:00 2001 From: Ruben Noroian Date: Thu, 5 Dec 2024 16:00:39 -0500 Subject: [PATCH 08/12] new base --- Drivers/Embedded-Base | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index ce612aa9..3bb4e772 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit ce612aa9f584ab945913f4f1d284150e2ff8fe3b +Subproject commit 3bb4e772c7f8dabb728d40da849ac2d661df4ce8 From dd02ec5c688d654d1ebcd263de040fbdc8659251 Mon Sep 17 00:00:00 2001 From: Ruben Noroian Date: Sun, 8 Dec 2024 16:24:45 -0500 Subject: [PATCH 09/12] other changes --- Core/Src/pdu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Core/Src/pdu.c b/Core/Src/pdu.c index 1932a4f9..ef84ed60 100644 --- a/Core/Src/pdu.c +++ b/Core/Src/pdu.c @@ -24,6 +24,7 @@ extern I2C_HandleTypeDef hi2c2; static inline int stm_i2c_write(uint16_t dev_addr, uint16_t address, uint16_t mem_add_size, uint8_t *data, uint16_t size, int delay) + { return HAL_I2C_Mem_Write(&hi2c2, dev_addr, address, mem_add_size, data, @@ -151,7 +152,8 @@ pdu_t *init_pdu(I2C_HandleTypeDef *hi2c) assert(pdu->ctrl_expander); //NEED - pca9539_init(pdu->ctrl_expander, stm_i2c_write, stm_i2c_read, CTRL_ADDR); + pca9539_init(pdu->ctrl_expander, stm_i2c_write, stm_i2c_read, + CTRL_ADDR); // write everything OFF, FAULT 1 is off uint8_t buf = 0b00000010; From 81ac26400a453779759c20e2886adce4acf03fa1 Mon Sep 17 00:00:00 2001 From: Ruben Noroian Date: Sun, 8 Dec 2024 16:35:21 -0500 Subject: [PATCH 10/12] added comments and clang --- Core/Src/pdu.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Core/Src/pdu.c b/Core/Src/pdu.c index fdae2cb9..fae0d3f7 100644 --- a/Core/Src/pdu.c +++ b/Core/Src/pdu.c @@ -19,9 +19,12 @@ static osMutexAttr_t pdu_mutex_attributes; +//hi2c2 variable to pass to the function wrappers extern I2C_HandleTypeDef hi2c2; -static inline int stm_i2c_write(uint16_t dev_addr, uint16_t address, +//Function wrapper for the STM specific HAL write function +//Serves as function pointer for PCA PAL +static inline int pca_i2c_write(uint16_t dev_addr, uint16_t address, uint16_t mem_add_size, uint8_t *data, uint16_t size, int delay) @@ -31,7 +34,9 @@ static inline int stm_i2c_write(uint16_t dev_addr, uint16_t address, size, delay); } -static inline int stm_i2c_read(uint16_t dev_addr, uint16_t address, +//Function wrapper for the STM specific HAL read function +//Serves as function pointer for PCA PAL +static inline int pca_i2c_read(uint16_t dev_addr, uint16_t address, uint16_t mem_add_size, uint8_t *data, uint16_t size, int delay) { @@ -152,7 +157,7 @@ pdu_t *init_pdu(I2C_HandleTypeDef *hi2c) assert(pdu->ctrl_expander); //NEED - pca9539_init(pdu->ctrl_expander, stm_i2c_write, stm_i2c_read, + pca9539_init(pdu->ctrl_expander, pca_i2c_write, pca_i2c_read, CTRL_ADDR); // write everything OFF, FAULT 1 is off From 0917b05f0f707346db5bcfb643a7214ce7e5cb0b Mon Sep 17 00:00:00 2001 From: Ruben Noroian Date: Sun, 8 Dec 2024 16:39:19 -0500 Subject: [PATCH 11/12] fix clang --- Core/Src/pdu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Core/Src/pdu.c b/Core/Src/pdu.c index fae0d3f7..fbd17504 100644 --- a/Core/Src/pdu.c +++ b/Core/Src/pdu.c @@ -34,6 +34,7 @@ static inline int pca_i2c_write(uint16_t dev_addr, uint16_t address, size, delay); } + //Function wrapper for the STM specific HAL read function //Serves as function pointer for PCA PAL static inline int pca_i2c_read(uint16_t dev_addr, uint16_t address, From ee1ad5b52b54c77fc0cae016b052e6b744c1f2d8 Mon Sep 17 00:00:00 2001 From: Ruben Noroian Date: Sun, 8 Dec 2024 16:43:21 -0500 Subject: [PATCH 12/12] final clang --- Core/Src/pdu.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/Core/Src/pdu.c b/Core/Src/pdu.c index fbd17504..22f26f82 100644 --- a/Core/Src/pdu.c +++ b/Core/Src/pdu.c @@ -25,25 +25,22 @@ extern I2C_HandleTypeDef hi2c2; //Function wrapper for the STM specific HAL write function //Serves as function pointer for PCA PAL static inline int pca_i2c_write(uint16_t dev_addr, uint16_t address, - uint16_t mem_add_size, uint8_t *data, - uint16_t size, int delay) + uint16_t mem_add_size, uint8_t *data, + uint16_t size, int delay) { - return HAL_I2C_Mem_Write(&hi2c2, dev_addr, address, - mem_add_size, data, - size, delay); + return HAL_I2C_Mem_Write(&hi2c2, dev_addr, address, mem_add_size, data, + size, delay); } - //Function wrapper for the STM specific HAL read function //Serves as function pointer for PCA PAL static inline int pca_i2c_read(uint16_t dev_addr, uint16_t address, - uint16_t mem_add_size, uint8_t *data, - uint16_t size, int delay) + uint16_t mem_add_size, uint8_t *data, + uint16_t size, int delay) { - return HAL_I2C_Mem_Write(&hi2c2, dev_addr, address, - mem_add_size, data, - size, delay); + return HAL_I2C_Mem_Write(&hi2c2, dev_addr, address, mem_add_size, data, + size, delay); } static uint8_t sound_rtds(pdu_t *pdu) @@ -158,8 +155,8 @@ pdu_t *init_pdu(I2C_HandleTypeDef *hi2c) assert(pdu->ctrl_expander); //NEED - pca9539_init(pdu->ctrl_expander, pca_i2c_write, pca_i2c_read, - CTRL_ADDR); + pca9539_init(pdu->ctrl_expander, pca_i2c_write, pca_i2c_read, + CTRL_ADDR); // write everything OFF, FAULT 1 is off uint8_t buf = 0b00000010;