11bcc5e0c3
- Add static memory pool implementation (se050_mem_pool.c/h) - Replace all malloc/calloc with pool allocations - Replace all free with pool deallocations - Remove strdup usage (use fixed-size buffer instead) - Update I2C HAL to use fixed-size dev_path array - All 24 tests pass with static memory only Suitable for embedded environments (u-boot, ESP32) without heap.
46 lines
1.2 KiB
C
46 lines
1.2 KiB
C
/**
|
|
* @file se050_i2c_hal.h
|
|
* @brief SE050 I2C HAL Interface
|
|
*/
|
|
|
|
#ifndef SE050_I2C_HAL_H
|
|
#define SE050_I2C_HAL_H
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <string.h>
|
|
|
|
/* Status codes */
|
|
typedef enum {
|
|
SE050_OK = 0,
|
|
SE050_ERR_INVALID_ARG = -1,
|
|
SE050_ERR_I2C = -2,
|
|
SE050_ERR_TIMEOUT = -3,
|
|
SE050_ERR_INTERNAL = -4,
|
|
SE050_ERR_SESSION = -5,
|
|
SE050_ERR_FAIL = -6,
|
|
SE050_ERR_RNG = -7,
|
|
SE050_ERR_ECDH = -8,
|
|
SE050_ERR_NOT_INIT = -9,
|
|
SE050_ERR_SCP03 = -10
|
|
} se050_status_t;
|
|
|
|
/* I2C HAL structure */
|
|
#define SE050_I2C_DEV_PATH_MAX 64
|
|
|
|
typedef struct {
|
|
void *handle; /**< I2C file descriptor */
|
|
uint8_t slave_addr; /**< I2C slave address */
|
|
char dev_path[SE050_I2C_DEV_PATH_MAX]; /**< I2C device path */
|
|
int wakeup_pin; /**< Wakeup GPIO pin (-1 if unused) */
|
|
} se050_i2c_hal_t;
|
|
|
|
/* Public API */
|
|
se050_status_t se050_i2c_init(se050_i2c_hal_t *hal, const char *dev_path, uint8_t slave_addr);
|
|
void se050_i2c_close(se050_i2c_hal_t *hal);
|
|
int se050_i2c_read(se050_i2c_hal_t *hal, uint8_t *buffer, int length);
|
|
int se050_i2c_write(se050_i2c_hal_t *hal, const uint8_t *buffer, int length);
|
|
se050_status_t se050_i2c_wakeup(se050_i2c_hal_t *hal);
|
|
|
|
#endif /* SE050_I2C_HAL_H */
|