now using BSP_GPIO

This commit is contained in:
2024-05-18 02:10:29 +02:00
parent 2d903dcf11
commit 467d7c4de9
4 changed files with 108 additions and 5 deletions

View File

@@ -9,7 +9,7 @@
#include "ee24.h"
#include "i2c.h"
#include "cmsis_os2.h"
#include "gpio.h"
#include "BSP_GPIO.h"
#define BSP_EE24_I2C &hi2c2
#define BSP_EE24_ADDRESS EE24_ADDRESS_DEFAULT
@@ -71,7 +71,7 @@ bool BSP_EE24_Init(void) {
ee24_lock = osMutexNew(NULL);
// wc control high disables write
HAL_GPIO_WritePin(EEPROM_WC_GPIO_Port, EEPROM_WC_Pin, GPIO_PIN_SET);
BSP_GPIO_EE24WriteProtectOn();
// Read the Partition Table header from the EEPROM
BSP_EE24_TableHeader header = {0};
@@ -121,9 +121,9 @@ bool BSP_EE24_Read(uint32_t Address, uint8_t *Data, size_t Len) {
*/
bool BSP_EE24_Write(uint32_t Address, uint8_t *Data, size_t Len) {
osMutexAcquire(ee24_lock,BSP_EE24_MUTEXT_TIMEOUT);
HAL_GPIO_WritePin(EEPROM_WC_GPIO_Port, EEPROM_WC_Pin, GPIO_PIN_RESET); // low enables write;
BSP_GPIO_EE24WriteProtectOff();
bool status = EE24_Write(&hee24,Address,Data,Len,BSP_EE24_TIMEOUT);
HAL_GPIO_WritePin(EEPROM_WC_GPIO_Port, EEPROM_WC_Pin, GPIO_PIN_SET); // high disables write;
BSP_GPIO_EE24WriteProtectOn();
osMutexRelease(ee24_lock);
return status;
}