CARME-M4 BSP  V1.5

CARME-M4 I2C high level functions. More...

+ Collaboration diagram for I2C:

Files

file  i2c.h
 I2C board support package for the CARME module.
 
file  i2c.c
 I2C board support package for the CARME module.
 

Macros

#define CARME_I2C_BOARD   I2C2
 
#define CARME_I2C_AUDIO   I2C3
 
#define CARME_I2C_SPEED   100000
 
#define CARME_I2C_ADDR_BOARD   0xA0
 
#define CARME_I2C_ADDR_AUDIO   0x33
 
#define CARME_ERROR_I2C_TIMEOUT   CARME_ERROR_I2C_BASE + 0
 
#define TIMEOUT_MAX   0x3000
 

Functions

void CARME_I2C_Init (I2C_TypeDef *I2Cx)
 I2C initialization. More...
 
ERROR_CODES CARME_I2C_Write (I2C_TypeDef *I2Cx, uint8_t addr, uint16_t reg, uint8_t twoByte, uint8_t *pdata, uint16_t count)
 Write data to an I2C slave device on a specific register address. More...
 
ERROR_CODES CARME_I2C_Read (I2C_TypeDef *I2Cx, uint8_t addr, uint16_t reg, uint8_t twoByte, uint8_t *pdata, uint16_t count)
 Read data from an I2C slave device on a specific register address. More...
 
static void CARME_I2C_Settings (I2C_TypeDef *I2Cx)
 I2C interface initialization. More...
 
static ERROR_CODES CARME_I2C_Timeout (I2C_TypeDef *I2Cx)
 Restart the I2C periph if a timeout has occurred. More...
 

Variables

static CARME_Port_Pin_t CARME_I2C_Port_Pin []
 I2C Port and Pin association. More...
 
static I2C_InitTypeDef I2C_InitStruct [2]
 I2C init structures to reinitialize the interface, if it is crashed.
 

Detailed Description

CARME-M4 I2C high level functions.

Macro Definition Documentation

#define CARME_ERROR_I2C_TIMEOUT   CARME_ERROR_I2C_BASE + 0

I2C timeout

Definition at line 92 of file i2c.h.

#define CARME_I2C_ADDR_AUDIO   0x33

I2C Address of master on the I2C audio bus

Definition at line 88 of file i2c.h.

#define CARME_I2C_ADDR_BOARD   0xA0

I2C Address of master on the I2C board bus

Definition at line 85 of file i2c.h.

#define CARME_I2C_AUDIO   I2C3

I2C to audio codec

Definition at line 82 of file i2c.h.

#define CARME_I2C_BOARD   I2C2

I2C on board and external

Examples:
i2c.c.

Definition at line 81 of file i2c.h.

#define CARME_I2C_SPEED   100000

I2C speed in Hz

Definition at line 84 of file i2c.h.

#define TIMEOUT_MAX   0x3000

I2C timeout in systicks

Definition at line 87 of file i2c.c.

Function Documentation

void CARME_I2C_Init ( I2C_TypeDef *  I2Cx)

I2C initialization.

Parameters
[in]I2CxThe I2C port which will be used. Possible values are CARME_I2C_BOARD and CARME_I2C_AUDIO.
Returns
None
Examples:
i2c.c.

Definition at line 124 of file i2c.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ERROR_CODES CARME_I2C_Read ( I2C_TypeDef *  I2Cx,
uint8_t  addr,
uint16_t  reg,
uint8_t  twoByte,
uint8_t *  pdata,
uint16_t  count 
)

Read data from an I2C slave device on a specific register address.

Parameters
[in]I2CxThe I2C port which will be used. Possible values are CARME_I2C_BOARD and CARME_I2C_AUDIO.
[in]addrAddress of the slave device.
[in]regRegister address of the slave device.
[in]twoByteIf the register address is two Byte long (ex. 0x01F3) set this parameter to 1.
[out]pdataPointer to the data array.
[in]countNumber of bytes in the array.
Returns
ERROR_CODES

Definition at line 312 of file i2c.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void CARME_I2C_Settings ( I2C_TypeDef *  I2Cx)
static

I2C interface initialization.

Parameters
[in]I2CxThe I2C port which will be used. Possible values are CARME_I2C_BOARD and CARME_I2C_AUDIO.
Returns
None

Definition at line 165 of file i2c.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ERROR_CODES CARME_I2C_Timeout ( I2C_TypeDef *  I2Cx)
static

Restart the I2C periph if a timeout has occurred.

Parameters
[in]I2CxThe I2C port which will be used. Possible values are CARME_I2C_BOARD and CARME_I2C_AUDIO.
Returns
ERROR_CODES

Definition at line 198 of file i2c.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ERROR_CODES CARME_I2C_Write ( I2C_TypeDef *  I2Cx,
uint8_t  addr,
uint16_t  reg,
uint8_t  twoByte,
uint8_t *  pdata,
uint16_t  count 
)

Write data to an I2C slave device on a specific register address.

Parameters
[in]I2CxThe I2C port which will be used. Possible values are CARME_I2C_BOARD and CARME_I2C_AUDIO.
[in]addrAddress of the slave device.
[in]regRegister address of the slave device.
[in]twoByteIf the register address is two Byte long (ex. 0x01F3) set this parameter to 1.
[in]pdataPointer to the data array.
[in]countNumber of bytes in the array.
Returns
ERROR_CODES
Examples:
i2c.c.

Definition at line 226 of file i2c.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

CARME_Port_Pin_t CARME_I2C_Port_Pin[]
static
Initial value:
= {
{ GPIOH, GPIO_Pin_4, GPIO_Mode_AF, GPIO_AF_I2C2 },
{ GPIOH, GPIO_Pin_5, GPIO_Mode_AF, GPIO_AF_I2C2 },
{ GPIOH, GPIO_Pin_7, GPIO_Mode_AF, GPIO_AF_I2C3 },
{ GPIOH, GPIO_Pin_8, GPIO_Mode_AF, GPIO_AF_I2C3 }
}

I2C Port and Pin association.

Definition at line 99 of file i2c.c.