TM STM32Fxxx HAL Libraries  v1.0.0
Libraries for STM32Fxxx (F0, F4 and F7 series) devices based on HAL drivers from ST from Tilen Majerle

Library Functions. More...

Functions

TM_I2C_Result_t TM_I2C_Init (I2C_TypeDef *I2Cx, TM_I2C_PinsPack_t pinspack, uint32_t clockSpeed)
 Initializes I2C peripheral. More...
 
TM_I2C_Result_t TM_I2C_Read (I2C_TypeDef *I2Cx, uint8_t device_address, uint8_t register_address, uint8_t *data)
 Reads single byte from device. More...
 
TM_I2C_Result_t TM_I2C_ReadMulti (I2C_TypeDef *I2Cx, uint8_t device_address, uint8_t register_address, uint8_t *data, uint16_t count)
 Reads multiple bytes from device. More...
 
TM_I2C_Result_t TM_I2C_ReadNoRegister (I2C_TypeDef *I2Cx, uint8_t device_address, uint8_t *data)
 Reads I2C data without specifying register address. More...
 
TM_I2C_Result_t TM_I2C_ReadMultiNoRegister (I2C_TypeDef *I2Cx, uint8_t device_address, uint8_t *data, uint16_t count)
 Reads multiple bytes from device without specifying register address. More...
 
TM_I2C_Result_t TM_I2C_Read16 (I2C_TypeDef *I2Cx, uint8_t device_address, uint16_t register_address, uint8_t *data)
 Reads single byte from device with 16-bit register address. More...
 
TM_I2C_Result_t TM_I2C_Write (I2C_TypeDef *I2Cx, uint8_t device_address, uint8_t register_address, uint8_t data)
 Writes single byte to device. More...
 
TM_I2C_Result_t TM_I2C_WriteMulti (I2C_TypeDef *I2Cx, uint8_t device_address, uint16_t register_address, uint8_t *data, uint16_t count)
 Writes multiple data to device. More...
 
TM_I2C_Result_t TM_I2C_WriteNoRegister (I2C_TypeDef *I2Cx, uint8_t device_address, uint8_t data)
 Writes single byte to device without specifying register address, can be used for command write. More...
 
TM_I2C_Result_t TM_I2C_WriteMultiNoRegister (I2C_TypeDef *I2Cx, uint8_t device_address, uint8_t *data, uint16_t count)
 Writes multiple data to device without register address. More...
 
TM_I2C_Result_t TM_I2C_Write16 (I2C_TypeDef *I2Cx, uint8_t device_address, uint16_t register_address, uint8_t data)
 Writes single byte in a 16-bit length register address. More...
 
TM_I2C_Result_t TM_I2C_IsDeviceConnected (I2C_TypeDef *I2Cx, uint8_t address)
 Checks if device is connected to I2C port and ready to use. More...
 
void TM_I2C_InitCustomPinsCallback (I2C_TypeDef *I2Cx, uint16_t AlternateFunction)
 Callback for custom pins initialization. More...
 
I2C_HandleTypeDef * TM_I2C_GetHandle (I2C_TypeDef *I2Cx)
 Gets pointer to I2C handle structure for specific I2C. More...
 
TM_I2C_Result_t TM_I2C_WriteReadRepeatedStart (I2C_TypeDef *I2Cx, uint8_t device_address, uint8_t write_register_address, uint8_t *write_data, uint16_t write_count, uint8_t read_register_address, uint8_t *read_data, uint16_t read_count)
 Writes and receives amount of data via I2C using repeated start condition. More...
 

Detailed Description

Library Functions.

Function Documentation

I2C_HandleTypeDef* TM_I2C_GetHandle ( I2C_TypeDef *  I2Cx)

Gets pointer to I2C handle structure for specific I2C.

Parameters
*I2CxPointer to I2Cx used for handle
Return values
Pointerto I2C Handle structure
TM_I2C_Result_t TM_I2C_Init ( I2C_TypeDef *  I2Cx,
TM_I2C_PinsPack_t  pinspack,
uint32_t  clockSpeed 
)

Initializes I2C peripheral.

Parameters
*I2CxPointer to I2Cx peripheral you will use for iintialization
pinspackPinspack used for GPIO initialization. This parameter can be a value of TM_I2C_PinsPack_t enumeration
clockSpeedClock speed in units of Hz for I2C communication
Return values
Memberof TM_I2C_Result_t enumeration
void TM_I2C_InitCustomPinsCallback ( I2C_TypeDef *  I2Cx,
uint16_t  AlternateFunction 
)

Callback for custom pins initialization.

When you call TM_I2C_Init() function, and if you pass TM_I2C_PinsPack_Custom to function, then this function will be called where you can initialize custom pins for I2C peripheral.

Parameters
*I2CxI2C for which initialization will be set
AlternateFunctionAlternate function which should be used for GPIO initialization
Return values
None
Note
With __weak parameter to prevent link errors if not defined by user
TM_I2C_Result_t TM_I2C_IsDeviceConnected ( I2C_TypeDef *  I2Cx,
uint8_t  address 
)

Checks if device is connected to I2C port and ready to use.

Parameters
*I2CxPointer to I2Cx peripheral to be used in communication
device_address7-bit, left aligned device address used for communication
Return values
Memberof TM_I2C_Result_t enumeration
TM_I2C_Result_t TM_I2C_Read ( I2C_TypeDef *  I2Cx,
uint8_t  device_address,
uint8_t  register_address,
uint8_t *  data 
)

Reads single byte from device.

Parameters
*I2CxPointer to I2Cx peripheral to be used in communication
device_address7-bit, left aligned device address used for communication
register_addressRegister address from where read will be done
*dataPointer to variable where data will be stored from read operation
Return values
Memberof TM_I2C_Result_t enumeration
TM_I2C_Result_t TM_I2C_Read16 ( I2C_TypeDef *  I2Cx,
uint8_t  device_address,
uint16_t  register_address,
uint8_t *  data 
)

Reads single byte from device with 16-bit register address.

Parameters
*I2CxPointer to I2Cx peripheral to be used in communication
device_address7-bit, left aligned device address used for communication
register_addressRegister address from where read will be done
*dataPointer to variable where data will be stored from read operation
Return values
Memberof TM_I2C_Result_t enumeration
TM_I2C_Result_t TM_I2C_ReadMulti ( I2C_TypeDef *  I2Cx,
uint8_t  device_address,
uint8_t  register_address,
uint8_t *  data,
uint16_t  count 
)

Reads multiple bytes from device.

Parameters
*I2CxPointer to I2Cx peripheral to be used in communication
device_address7-bit, left aligned device address used for communication
register_addressRegister address from where read operation will start
*dataPointer to variable where data will be stored from read operation
countNumber of elements to read from device
Return values
Memberof TM_I2C_Result_t enumeration
TM_I2C_Result_t TM_I2C_ReadMultiNoRegister ( I2C_TypeDef *  I2Cx,
uint8_t  device_address,
uint8_t *  data,
uint16_t  count 
)

Reads multiple bytes from device without specifying register address.

Parameters
*I2CxPointer to I2Cx peripheral to be used in communication
device_address7-bit, left aligned device address used for communication
*dataPointer to variable where data will be stored from read operation
countNumber of elements to read from device
Return values
Memberof TM_I2C_Result_t enumeration
TM_I2C_Result_t TM_I2C_ReadNoRegister ( I2C_TypeDef *  I2Cx,
uint8_t  device_address,
uint8_t *  data 
)

Reads I2C data without specifying register address.

Note
This can be used if your sensors just sends data, without any registers
Parameters
*I2CxPointer to I2Cx peripheral to be used in communication
device_address7-bit, left aligned device address used for communication
*dataPointer to variable where data will be stored from read operation
Return values
Memberof TM_I2C_Result_t enumeration
TM_I2C_Result_t TM_I2C_Write ( I2C_TypeDef *  I2Cx,
uint8_t  device_address,
uint8_t  register_address,
uint8_t  data 
)

Writes single byte to device.

Parameters
*I2CxPointer to I2Cx peripheral to be used in communication
device_address7-bit, left aligned device address used for communication
register_addressRegister address where you want to write data
dataData to be written to device
Return values
Memberof TM_I2C_Result_t enumeration
TM_I2C_Result_t TM_I2C_Write16 ( I2C_TypeDef *  I2Cx,
uint8_t  device_address,
uint16_t  register_address,
uint8_t  data 
)

Writes single byte in a 16-bit length register address.

Parameters
*I2CxPointer to I2Cx peripheral to be used in communication
device_address7-bit, left aligned device address used for communication
register_addressRegister address where data will be written
dataData byte to write
Return values
Memberof TM_I2C_Result_t enumeration
TM_I2C_Result_t TM_I2C_WriteMulti ( I2C_TypeDef *  I2Cx,
uint8_t  device_address,
uint16_t  register_address,
uint8_t *  data,
uint16_t  count 
)

Writes multiple data to device.

Parameters
*I2CxPointer to I2Cx peripheral to be used in communication
device_address7-bit, left aligned device address used for communication
register_addressRegister address where data will be written
*dataData to be written to device.
countNumber of elements to write starting at register register_address
Return values
Memberof TM_I2C_Result_t enumeration
TM_I2C_Result_t TM_I2C_WriteMultiNoRegister ( I2C_TypeDef *  I2Cx,
uint8_t  device_address,
uint8_t *  data,
uint16_t  count 
)

Writes multiple data to device without register address.

Parameters
*I2CxPointer to I2Cx peripheral to be used in communication
device_address7-bit, left aligned device address used for communication
*dataPointer to data array t obe written to device. Array length is the same as number of elements you want to write
countNumber of elements to write
Return values
Memberof TM_I2C_Result_t enumeration
TM_I2C_Result_t TM_I2C_WriteNoRegister ( I2C_TypeDef *  I2Cx,
uint8_t  device_address,
uint8_t  data 
)

Writes single byte to device without specifying register address, can be used for command write.

Parameters
*I2CxPointer to I2Cx peripheral to be used in communication
device_address7-bit, left aligned device address used for communication
dataData to be written to device
Return values
Memberof TM_I2C_Result_t enumeration
TM_I2C_Result_t TM_I2C_WriteReadRepeatedStart ( I2C_TypeDef *  I2Cx,
uint8_t  device_address,
uint8_t  write_register_address,
uint8_t *  write_data,
uint16_t  write_count,
uint8_t  read_register_address,
uint8_t *  read_data,
uint16_t  read_count 
)

Writes and receives amount of data via I2C using repeated start condition.

Parameters
*I2CxPointer to I2Cx peripheral to be used in communication
device_address7-bit, left aligned device address used for communication
write_register_addressRegister address to start writing to
*write_dataPointer to data array where data for write are stored
write_countNumber of elements to write
read_register_addressRegister address where reading will start
*read_dataPointer to array where data will be saved
read_countNumber of elements to read
Return values
Memberof TM_I2C_Result_t enumeration