NorthStar-Endurance-TestBench/EnduranceTestBench/nms_hal/hal_i2c.h

78 lines
3.4 KiB
C

/******************************************************************************
* @file hal_i2c.h
* @copyright Nehemis SARL reserves all rights even in the event of industrial
* property rights. We reserve all rights of disposal such as
* copying and passing on to third parties.
*
* @brief STM HAL layer wrapper class for I2C.
*
******************************************************************************/
#ifndef HAL_I2C_H
#define HAL_I2C_H
/******************************************************************************
* Include Header Files
******************************************************************************/
#include "map_hal.h"
#include "nms_types.h"
#include "stdint.h"
#include "i2c.h"
/******************************************************************************
* Function Prototypes
******************************************************************************/
/**
* @brief Initializes the I2C hardware interface.
* This function configures the necessary resources and sets up the
* I2C hardware to prepare it for use.
*
* @return Error code: 0 if successful, nonzero otherwise.
*/
uint32 HalI2CInit(void);
/**
* @brief Reads data from a specific memory address on an I2C device.
* This function sends a memory read request to the I2C device and
* stores the received data in a provided buffer.
*
* @param module_en The I2C module to be used (depends on the system configuration).
* devAddr_u16 The 7-bit address of the I2C device.
* memAddr_u16 The memory address within the I2C device to read from.
* memAddrSize_u16 The size of the memory address (e.g., 8-bit, 16-bit).
* pData_pu8 Pointer to the buffer where the read data will be stored.
* size_u16 Number of bytes to read.
*
* @return Error code: 0 if successful, nonzero otherwise.
*/
uint32 HalI2CRead(MapHalI2cModule_en module_en, uint16 devAddr_u16, uint16 memAddr_u16, uint16 memAddrSize_u16, uint8 *pData_pu8, uint16 size_u16);
/**
* @brief Writes data to a specific memory address on an I2C device.
* This function sends a memory write request to the I2C device to
* write data from the provided buffer to the device's memory.
*
* @param module_en The I2C module to be used (depends on the system configuration).
* devAddr_u16 The 7-bit address of the I2C device.
* memAddr_u16 The memory address within the I2C device to read from.
* memAddrSize_u16 The size of the memory address (e.g., 8-bit, 16-bit).
* pData_pu8 Pointer to the buffer where the read data will be stored.
* size_u16 Number of bytes to write.
*
* @return Error code: 0 if successful, nonzero otherwise.
*/
uint32 HalI2CWrite(MapHalI2cModule_en module_en, uint16 devAddr_u16, uint16 memAddr_u16, uint16 memAddrSize_u16, uint8 *pData_pu8, uint16 size_u16);
/**
* @brief Transmits in master mode an amount of data in blocking mode.
*
* @param module_en The I2C module to be used (depends on the system configuration).
* devAddr_u16 The 7-bit address of the I2C device.
* pData_pu8 Pointer to the buffer where the read data will be stored.
* size_u16 Number of bytes to write.
*
* @return Error code: 0 if successful, nonzero otherwise.
*/
uint32 HalI2CMasterTransmit(MapHalI2cModule_en module_en, uint16 devAddr_u16, uint8 *pData_pu8, uint16 size_u16);
#endif /* HAL_I2C_H */