foxBMS - Unit Tests  1.2.0
The foxBMS Unit Tests API Documentation
i2c.h File Reference

Header for the driver for the I2C module. More...

#include "general.h"
#include "HL_i2c.h"
Include dependency graph for i2c.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define I2C_TIMEOUT   (1000u)
 
#define I2C_TXDMAEN   (0x2u)
 
#define I2C_RXDMAEN   (0x1u)
 

Functions

void I2C_Initialize (void)
 
STD_RETURN_TYPE_e I2C_Read (uint32_t slaveAddress, uint8_t readAddress, uint32_t nrBytes, uint8_t *readData)
 reads from an I2C slave, blocking. More...
 
STD_RETURN_TYPE_e I2C_ReadDirect (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 (uint32_t slaveAddress, uint8_t writeAddress, uint32_t nrBytes, uint8_t *writeData)
 writes to an I2C slave, blocking. More...
 
STD_RETURN_TYPE_e I2C_WriteDirect (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_ReadDma (uint32_t slaveAddress, uint8_t readAddress, uint32_t nrBytes, uint8_t *readData)
 reads from an I2C slave, using DMA. More...
 
STD_RETURN_TYPE_e I2C_WriteDma (uint32_t slaveAddress, uint8_t writeAddress, uint32_t nrBytes, uint8_t *writeData)
 writes to an I2C slave, using DMA. More...
 
void I2C_SetStopNow (void)
 sets stop condition. More...
 

Detailed Description

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:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

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:

  • ″This product uses parts of foxBMS®″
  • ″This product includes parts of foxBMS®″
  • ″This product is derived from foxBMS®″
Author
foxBMS Team
Date
2021-07-22 (date of creation)
Updated
2021-09-28 (date of last update)
Prefix
I2C

Definition in file i2c.h.

Macro Definition Documentation

◆ I2C_RXDMAEN

#define I2C_RXDMAEN   (0x1u)

Receiver DMA enable

Definition at line 70 of file i2c.h.

◆ I2C_TIMEOUT

#define I2C_TIMEOUT   (1000u)

Timeout to avoid infinite loops when waiting for flags

Definition at line 65 of file i2c.h.

◆ I2C_TXDMAEN

#define I2C_TXDMAEN   (0x2u)

Transmitter DMA enable

Definition at line 68 of file i2c.h.

Function Documentation

◆ I2C_Initialize()

void I2C_Initialize ( void  )

Initialize the I2C hardware

This function has to be called before any call to the rest of this API

Definition at line 74 of file i2c.c.

◆ I2C_Read()

STD_RETURN_TYPE_e I2C_Read ( uint32_t  slaveAddress,
uint8_t  readAddress,
uint32_t  nrBytes,
uint8_t *  readData 
)

reads from an I2C slave, blocking.

Parameters
slaveAddressaddress of slave to communicate with
readAddressaddress of first register to read from
nrBytesnumber of registers to read
readDatabuffer containing the read data
Returns
retVal: STD_OK if transmission OK, STD_NOT_OK otherwise

Definition at line 78 of file i2c.c.

Here is the call graph for this function:

◆ I2C_ReadDirect()

STD_RETURN_TYPE_e I2C_ReadDirect ( uint32_t  slaveAddress,
uint32_t  nrBytes,
uint8_t *  readData 
)

reads from an I2C slave, no register address written first, blocking.

Parameters
slaveAddressaddress of slave to communicate with
nrBytesnumber of registers to read
readDatabuffer containing the read data
Returns
retVal: STD_OK if transmission OK, STD_NOT_OK otherwise

Definition at line 183 of file i2c.c.

Here is the call graph for this function:

◆ I2C_ReadDma()

STD_RETURN_TYPE_e I2C_ReadDma ( uint32_t  slaveAddress,
uint8_t  readAddress,
uint32_t  nrBytes,
uint8_t *  readData 
)

reads from an I2C slave, using DMA.

Parameters
slaveAddressaddress of slave to communicate with
readAddressaddress of first register to read from
nrBytesnumber of registers to read
readDatabuffer containing the read data
Returns
retVal: STD_OK if transmission OK, STD_NOT_OK otherwise

Definition at line 433 of file i2c.c.

Here is the call graph for this function:

◆ I2C_SetStopNow()

void I2C_SetStopNow ( void  )

sets stop condition.

Definition at line 563 of file i2c.c.

◆ I2C_Write()

STD_RETURN_TYPE_e I2C_Write ( uint32_t  slaveAddress,
uint8_t  writeAddress,
uint32_t  nrBytes,
uint8_t *  writeData 
)

writes to an I2C slave, blocking.

Parameters
slaveAddressaddress of slave to communicate with
writeAddressaddress of first register to write to
nrBytesnumber of registers to write
writeDatabuffer containing the data to write
Returns
retVal: STD_OK if transmission OK, STD_NOT_OK otherwise

Definition at line 256 of file i2c.c.

Here is the call graph for this function:

◆ I2C_WriteDirect()

STD_RETURN_TYPE_e I2C_WriteDirect ( uint32_t  slaveAddress,
uint32_t  nrBytes,
uint8_t *  writeData 
)

writes to an I2C slave, no register address written first, blocking.

Parameters
slaveAddressaddress of slave to communicate with
nrBytesnumber of registers to write
writeDatabuffer containing the data to write
Returns
retVal: STD_OK if transmission OK, STD_NOT_OK otherwise

Definition at line 356 of file i2c.c.

Here is the call graph for this function:

◆ I2C_WriteDma()

STD_RETURN_TYPE_e I2C_WriteDma ( uint32_t  slaveAddress,
uint8_t  writeAddress,
uint32_t  nrBytes,
uint8_t *  writeData 
)

writes to an I2C slave, using DMA.

Parameters
slaveAddressaddress of slave to communicate with
writeAddressaddress of first register to write to
nrBytesnumber of registers to write
writeDatabuffer containing the data to write
Returns
retVal: STD_OK if transmission OK, STD_NOT_OK otherwise

Definition at line 499 of file i2c.c.

Here is the call graph for this function: