|
TM STM32F4xx Libraries
v1.0.0
Libraries for STM32F4xx devices from Tilen Majerle
|
Library Functions. More...
Functions | |
| void | TM_I2C_Init (I2C_TypeDef *I2Cx, TM_I2C_PinsPack_t pinspack, uint32_t clockSpeed) |
| Initializes I2C. More... | |
| uint8_t | TM_I2C_Read (I2C_TypeDef *I2Cx, uint8_t address, uint8_t reg) |
| Reads single byte from slave. More... | |
| void | TM_I2C_ReadMulti (I2C_TypeDef *I2Cx, uint8_t address, uint8_t reg, uint8_t *data, uint16_t count) |
| Reads multi bytes from slave. More... | |
| uint8_t | TM_I2C_ReadNoRegister (I2C_TypeDef *I2Cx, uint8_t address) |
| Reads byte from slave without specify register address. More... | |
| void | TM_I2C_ReadMultiNoRegister (I2C_TypeDef *I2Cx, uint8_t address, uint8_t *data, uint16_t count) |
| Reads multi bytes from slave without setting register from where to start read. More... | |
| void | TM_I2C_Write (I2C_TypeDef *I2Cx, uint8_t address, uint8_t reg, uint8_t data) |
| Writes single byte to slave. More... | |
| void | TM_I2C_WriteMulti (I2C_TypeDef *I2Cx, uint8_t address, uint8_t reg, uint8_t *data, uint16_t count) |
| Writes multi bytes to slave. More... | |
| void | TM_I2C_WriteNoRegister (I2C_TypeDef *I2Cx, uint8_t address, uint8_t data) |
| Writes byte to slave without specify register address. More... | |
| void | TM_I2C_WriteMultiNoRegister (I2C_TypeDef *I2Cx, uint8_t address, uint8_t *data, uint16_t count) |
| Writes multi bytes to slave without setting register from where to start write. More... | |
| uint8_t | TM_I2C_IsDeviceConnected (I2C_TypeDef *I2Cx, uint8_t address) |
| Checks if device is connected to I2C bus. More... | |
| int16_t | TM_I2C_Start (I2C_TypeDef *I2Cx, uint8_t address, uint8_t direction, uint8_t ack) |
| I2C Start condition. More... | |
| uint8_t | TM_I2C_Stop (I2C_TypeDef *I2Cx) |
| Stop condition on I2C. More... | |
| uint8_t | TM_I2C_ReadNack (I2C_TypeDef *I2Cx) |
| Reads byte without ack. More... | |
| uint8_t | TM_I2C_ReadAck (I2C_TypeDef *I2Cx) |
| Reads byte with ack. More... | |
| void | TM_I2C_WriteData (I2C_TypeDef *I2Cx, uint8_t data) |
| Writes to slave. More... | |
| void | TM_I2C_InitCustomPinsCallback (I2C_TypeDef *I2Cx, uint16_t AlternateFunction) |
| Callback for custom pins initialization. More... | |
Library Functions.
| void TM_I2C_Init | ( | I2C_TypeDef * | I2Cx, |
| TM_I2C_PinsPack_t | pinspack, | ||
| uint32_t | clockSpeed | ||
| ) |
Initializes I2C.
| *I2Cx | I2C used |
| pinspack | Pins used. This parameter can have a value of TM_I2C_PinsPack_t enumeration |
| clockSpeed | Clock speed for SCL in Hertz |
| None |
| 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.
| *I2Cx | I2C for which initialization will be set |
| AlternateFunction | Alternate function which should be used for GPIO initialization |
| None |
| uint8_t TM_I2C_IsDeviceConnected | ( | I2C_TypeDef * | I2Cx, |
| uint8_t | address | ||
| ) |
Checks if device is connected to I2C bus.
| *I2Cx | I2C used |
| address | 7 bit slave address, left aligned, bits 7:1 are used, LSB bit is not used |
| Device | status:
|
| uint8_t TM_I2C_Read | ( | I2C_TypeDef * | I2Cx, |
| uint8_t | address, | ||
| uint8_t | reg | ||
| ) |
Reads single byte from slave.
| *I2Cx | I2C used |
| address | 7 bit slave address, left aligned, bits 7:1 are used, LSB bit is not used |
| reg | register to read from |
| Data | from slave |
| uint8_t TM_I2C_ReadAck | ( | I2C_TypeDef * | I2Cx | ) |
Reads byte with ack.
| *I2Cx | I2C used |
| Byte | from slave |
| void TM_I2C_ReadMulti | ( | I2C_TypeDef * | I2Cx, |
| uint8_t | address, | ||
| uint8_t | reg, | ||
| uint8_t * | data, | ||
| uint16_t | count | ||
| ) |
Reads multi bytes from slave.
| *I2Cx | I2C used |
| uint8_t | address: 7 bit slave address, left aligned, bits 7:1 are used, LSB bit is not used |
| uint8_t | reg: register to read from |
| uint8_t | *data: pointer to data array to store data from slave |
| uint8_t | count: how many bytes will be read |
| None |
| void TM_I2C_ReadMultiNoRegister | ( | I2C_TypeDef * | I2Cx, |
| uint8_t | address, | ||
| uint8_t * | data, | ||
| uint16_t | count | ||
| ) |
Reads multi bytes from slave without setting register from where to start read.
| *I2Cx | I2C used |
| address | 7 bit slave address, left aligned, bits 7:1 are used, LSB bit is not used |
| *data | pointer to data array to store data from slave |
| count | how many bytes will be read |
| None |
| uint8_t TM_I2C_ReadNack | ( | I2C_TypeDef * | I2Cx | ) |
Reads byte without ack.
| *I2Cx | I2C used |
| Byte | from slave |
| uint8_t TM_I2C_ReadNoRegister | ( | I2C_TypeDef * | I2Cx, |
| uint8_t | address | ||
| ) |
Reads byte from slave without specify register address.
| *I2Cx | I2C used |
| address | 7 bit slave address, left aligned, bits 7:1 are used, LSB bit is not used |
| Data | from slave |
| int16_t TM_I2C_Start | ( | I2C_TypeDef * | I2Cx, |
| uint8_t | address, | ||
| uint8_t | direction, | ||
| uint8_t | ack | ||
| ) |
I2C Start condition.
| *I2Cx | I2C used |
| address | slave address |
| direction | master to slave or slave to master |
| ack | ack enabled or disabled |
| Start | condition status |
| uint8_t TM_I2C_Stop | ( | I2C_TypeDef * | I2Cx | ) |
Stop condition on I2C.
| *I2Cx | I2C used |
| Stop | condition status |
| void TM_I2C_Write | ( | I2C_TypeDef * | I2Cx, |
| uint8_t | address, | ||
| uint8_t | reg, | ||
| uint8_t | data | ||
| ) |
Writes single byte to slave.
| *I2Cx | I2C used |
| address | 7 bit slave address, left aligned, bits 7:1 are used, LSB bit is not used |
| reg | register to write to |
| data | data to be written |
| None |
| void TM_I2C_WriteData | ( | I2C_TypeDef * | I2Cx, |
| uint8_t | data | ||
| ) |
Writes to slave.
| *I2Cx | I2C used |
| data | data to be sent |
| None |
| void TM_I2C_WriteMulti | ( | I2C_TypeDef * | I2Cx, |
| uint8_t | address, | ||
| uint8_t | reg, | ||
| uint8_t * | data, | ||
| uint16_t | count | ||
| ) |
Writes multi bytes to slave.
| *I2Cx | I2C used |
| address | 7 bit slave address, left aligned, bits 7:1 are used, LSB bit is not used |
| reg | register to write to |
| *data | pointer to data array to write it to slave |
| count | how many bytes will be written |
| None |
| void TM_I2C_WriteMultiNoRegister | ( | I2C_TypeDef * | I2Cx, |
| uint8_t | address, | ||
| uint8_t * | data, | ||
| uint16_t | count | ||
| ) |
Writes multi bytes to slave without setting register from where to start write.
| *I2Cx | I2C used |
| address | 7 bit slave address, left aligned, bits 7:1 are used, LSB bit is not used |
| *data | pointer to data array to write data to slave |
| count | how many bytes you want to write |
| None |
| void TM_I2C_WriteNoRegister | ( | I2C_TypeDef * | I2Cx, |
| uint8_t | address, | ||
| uint8_t | data | ||
| ) |
Writes byte to slave without specify register address.
Useful if you have I2C device to read like that:
| *I2Cx | I2C used |
| address | 7 bit slave address, left aligned, bits 7:1 are used, LSB bit is not used |
| data | data byte which will be send to device |
| None |