foxBMS - Unit Tests
1.5.0
The foxBMS Unit Tests API Documentation
|
Header for the driver for the I2C module. More...
Go to the source code of this file.
Macros | |
#define | I2C_TIMEOUT_us (1000u) |
#define | I2C_TXDMAEN (0x2u) |
#define | I2C_RXDMAEN (0x1u) |
#define | I2C_DDR_REGISTER_DATA_MASK (0xFFu) |
#define | I2C_TASK_HANDLE (ftsk_taskHandleI2c) |
#define | I2C_NOTIFICATION_TX_INDEX (1u) |
#define | I2C_NOTIFICATION_RX_INDEX (2u) |
#define | I2C_NO_NOTIFIED_VALUE (0x0u) |
#define | I2C_TX_NOTIFIED_VALUE (0x51u) |
#define | I2C_RX_NOTIFIED_VALUE (0x61u) |
#define | I2C_RX_NOTCOME_VALUE (0x62u) |
#define | I2C_NOTIFICATION_TIMEOUT_ms (2u) |
#define | I2C_PRESCALER_MASK (0xFFu) |
#define | I2C_FACTOR_MHZ_TO_HZ (1000000u) |
#define | I2C_FACTOR_S_TO_US (1000000u) |
#define | I2C_FACTOR_WORD_TO_BITS (9u) |
#define | I2C_TX_TIME_MARGIN_us (5u) |
#define | I2C_DFACTOR_VALUE_PRESCALER_0 (7u) |
#define | I2C_DFACTOR_VALUE_PRESCALER_1 (6u) |
#define | I2C_DFACTOR_VALUE_PRESCALER_OTHER (5u) |
Functions | |
void | I2C_Initialize (void) |
Initialize the I2C hardware with dedicated HAL functions. Has to be called before any call to the rest of this API. More... | |
STD_RETURN_TYPE_e | I2C_Read (i2cBASE_t *pI2cInterface, uint32_t slaveAddress, uint32_t nrBytes, uint8_t *readData) |
reads from an I2C slave, no register address written first, blocking. More... | |
STD_RETURN_TYPE_e | I2C_Write (i2cBASE_t *pI2cInterface, uint32_t slaveAddress, uint32_t nrBytes, uint8_t *writeData) |
writes to an I2C slave, no register address written first, blocking. More... | |
STD_RETURN_TYPE_e | I2C_WriteRead (i2cBASE_t *pI2cInterface, uint32_t slaveAddress, uint32_t nrBytesWrite, uint8_t *writeData, uint32_t nrBytesRead, uint8_t *readData) |
reads from an I2C slave, blocking. More... | |
STD_RETURN_TYPE_e | I2C_ReadDma (i2cBASE_t *pI2cInterface, uint32_t slaveAddress, uint32_t nrBytes, uint8_t *readData) |
reads from an I2C slave, no register address written first, using DMA. More... | |
STD_RETURN_TYPE_e | I2C_WriteDma (i2cBASE_t *pI2cInterface, uint32_t slaveAddress, uint32_t nrBytes, uint8_t *writeData) |
writes to an I2C slave, no register address written first, using DMA. More... | |
STD_RETURN_TYPE_e | I2C_WriteReadDma (i2cBASE_t *pI2cInterface, uint32_t slaveAddress, uint32_t nrBytesWrite, uint8_t *writeData, uint32_t nrBytesRead, uint8_t *readData) |
reads from an I2C slave, using DMA. More... | |
uint8_t | I2C_ReadLastRxByte (i2cBASE_t *pI2cInterface) |
Used to read last byte received per I2C. More... | |
bool | I2C_WaitReceive (i2cBASE_t *pI2cInterface, uint32_t timeout_us) |
Waits for the I2C Rx buffer to be full. More... | |
Variables | |
uint8_t | i2c_rxLastByteInterface1 |
uint8_t | i2c_rxLastByteInterface2 |
Header for the driver for the I2C module.
SPDX-License-Identifier: BSD-3-Clause
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
We kindly request you to use one or more of the following phrases to refer to foxBMS in your hardware, software, documentation or advertising materials:
Definition in file i2c.h.
#define I2C_DFACTOR_VALUE_PRESCALER_0 (7u) |
#define I2C_DFACTOR_VALUE_PRESCALER_1 (6u) |
#define I2C_DFACTOR_VALUE_PRESCALER_OTHER (5u) |
#define I2C_NOTIFICATION_TIMEOUT_ms (2u) |
#define I2C_TASK_HANDLE (ftsk_taskHandleI2c) |
void I2C_Initialize | ( | void | ) |
STD_RETURN_TYPE_e I2C_Read | ( | i2cBASE_t * | pI2cInterface, |
uint32_t | slaveAddress, | ||
uint32_t | nrBytes, | ||
uint8_t * | readData | ||
) |
reads from an I2C slave, no register address written first, blocking.
pI2cInterface | I2C interface to use |
slaveAddress | address of slave to communicate with |
nrBytes | number of registers to read |
readData | buffer containing the read data |
Definition at line 226 of file i2c.c.
STD_RETURN_TYPE_e I2C_ReadDma | ( | i2cBASE_t * | pI2cInterface, |
uint32_t | slaveAddress, | ||
uint32_t | nrBytes, | ||
uint8_t * | readData | ||
) |
reads from an I2C slave, no register address written first, using DMA.
pI2cInterface | I2C interface to use |
slaveAddress | address of slave to communicate with |
nrBytes | number of registers to read |
readData | buffer containing the read data |
Definition at line 415 of file i2c.c.
uint8_t I2C_ReadLastRxByte | ( | i2cBASE_t * | pI2cInterface | ) |
bool I2C_WaitReceive | ( | i2cBASE_t * | pI2cInterface, |
uint32_t | timeout_us | ||
) |
Waits for the I2C Rx buffer to be full.
When the buffer is full, the received byte can be read. If the buffer is full before timeout_us microseconds are elapsed, the function returns true, false otherwise. The function also returns false if a NACK condition is detected.
pI2cInterface | I2C interface to use |
timeout_us | time in microseconds to wait until the buffer is full |
Definition at line 772 of file i2c.c.
STD_RETURN_TYPE_e I2C_Write | ( | i2cBASE_t * | pI2cInterface, |
uint32_t | slaveAddress, | ||
uint32_t | nrBytes, | ||
uint8_t * | writeData | ||
) |
writes to an I2C slave, no register address written first, blocking.
pI2cInterface | I2C interface to use |
slaveAddress | address of slave to communicate with |
nrBytes | number of registers to write |
writeData | buffer containing the data to write |
Definition at line 283 of file i2c.c.
STD_RETURN_TYPE_e I2C_WriteDma | ( | i2cBASE_t * | pI2cInterface, |
uint32_t | slaveAddress, | ||
uint32_t | nrBytes, | ||
uint8_t * | writeData | ||
) |
writes to an I2C slave, no register address written first, using DMA.
pI2cInterface | I2C interface to use |
slaveAddress | address of slave to communicate with |
nrBytes | number of registers to write |
writeData | buffer containing the data to write |
Definition at line 510 of file i2c.c.
STD_RETURN_TYPE_e I2C_WriteRead | ( | i2cBASE_t * | pI2cInterface, |
uint32_t | slaveAddress, | ||
uint32_t | nrBytesWrite, | ||
uint8_t * | writeData, | ||
uint32_t | nrBytesRead, | ||
uint8_t * | readData | ||
) |
reads from an I2C slave, blocking.
pI2cInterface | I2C interface to use |
slaveAddress | address of slave to communicate with |
nrBytesWrite | number of registers to read |
writeData | buffer containing the read data |
nrBytesRead | number of registers to read |
readData | buffer containing the read data |
Definition at line 335 of file i2c.c.
STD_RETURN_TYPE_e I2C_WriteReadDma | ( | i2cBASE_t * | pI2cInterface, |
uint32_t | slaveAddress, | ||
uint32_t | nrBytesWrite, | ||
uint8_t * | writeData, | ||
uint32_t | nrBytesRead, | ||
uint8_t * | readData | ||
) |
reads from an I2C slave, using DMA.
pI2cInterface | I2C interface to use |
slaveAddress | address of slave to communicate with |
nrBytesWrite | number of registers to read |
writeData | buffer containing the read data |
nrBytesRead | number of registers to read |
readData | buffer containing the read data |
Definition at line 599 of file i2c.c.