|
Hierodule 1.6.2
Utility module set for STM32 MCUs
|
Elements of the module that are confined to the scope of the compilation unit. Perfectly corresponds to the module's source file, except the IRQ handlers. More...
Functions | |
| void | Idle (HIERODULE_I2C_Wrapper *Wrapper, uint32_t NumberOfPeriods) |
| Blocks for given number of I2C clock periods. | |
| void | EnableClockStretching (HIERODULE_I2C_Wrapper *Wrapper) |
| Enables clock stretching for the I2C peripheral of a wrapper. | |
| void | DisableClockStretching (HIERODULE_I2C_Wrapper *Wrapper) |
| Disables clock stretching for the I2C peripheral of a wrapper. | |
| static uint8_t | ReceiveData (HIERODULE_I2C_Wrapper *Wrapper) |
| Read and returns the data register content of the I2C peripheral. | |
| void | TransmitData (HIERODULE_I2C_Wrapper *Wrapper, uint8_t Byte) |
| Writes a byte into the data register of the I2C peripheral. | |
| void | ACK_Next (HIERODULE_I2C_Wrapper *Wrapper) |
| Configure the I2C peripheral to "ACK" the next byte received. | |
| void | NACK_Next (HIERODULE_I2C_Wrapper *Wrapper) |
| Configure the I2C peripheral to "NACK" the next byte received. | |
| void | Start (HIERODULE_I2C_Wrapper *Wrapper) |
| Makes the I2C peripheral generate a start condition. | |
| void | Stop (HIERODULE_I2C_Wrapper *Wrapper) |
| Makes the I2C peripheral generate a stop condition. | |
| void | ReceiveByteAsMaster (HIERODULE_I2C_Wrapper *Wrapper) |
| Handles incoming data for an I2C peripheral in master receiver mode. | |
| void | ReceiveByteAsSlave (HIERODULE_I2C_Wrapper *Wrapper) |
| Handles incoming data for an I2C peripheral in slave receiver mode. | |
| void | TransmitByteAsMaster (HIERODULE_I2C_Wrapper *Wrapper) |
| Transmits the next data in the buffer for an I2C peripheral in master transmitter mode. | |
| void | TransmitByteAsSlave (HIERODULE_I2C_Wrapper *Wrapper) |
| Transmits the next data in the buffer for an I2C peripheral in slave transmitter mode. | |
| void | ReturnToIdleState (HIERODULE_I2C_Wrapper *Wrapper) |
| Invokes the on-SRX-finished routine if assigned and sets the I2C wrapper status back to idle. | |
| void | Receive_NACK (HIERODULE_I2C_Wrapper *Wrapper) |
| Receives the NACK response, invokes the on-SRX-finished routine and sets the wrapper status back to idle. | |
| void | I2C_IRQ_Handler (HIERODULE_I2C_Wrapper *Wrapper) |
| The base IRQ body to be used for all I2C IRQs. | |
Variables | |
| static HIERODULE_I2C_Wrapper * | I2C1_Wrapper |
| I2C wrapper pointer meant for I2C1. | |
| static HIERODULE_I2C_Wrapper * | I2C2_Wrapper |
| I2C wrapper pointer meant for I2C2. Requires the device specific macro __STM32F103xB_H or __STM32F401xC_H to be defined. | |
| static HIERODULE_I2C_Wrapper * | I2C3_Wrapper |
| I2C wrapper pointer meant for I2C3. Requires the device specific macro __STM32F401xC_H to be defined. | |
Implements the routines defined in the header file and routines necessary for those in the background. Pointers of I2C wrappers are also defined here.
IRQ definitions with custom ISR implementations are also included at the end of the file.
| void ACK_Next | ( | HIERODULE_I2C_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the I2C wrapper. |
Self-explanatory code, nothing to elaborate.
Definition at line 157 of file hierodule_i2c.c.
References Wrapper.
Referenced by HIERODULE_I2C_InitWrapper(), and ReceiveByteAsMaster().
| void DisableClockStretching | ( | HIERODULE_I2C_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the I2C wrapper. |
Self-explanatory code, nothing to elaborate.
Definition at line 94 of file hierodule_i2c.c.
References Wrapper.
Referenced by HIERODULE_I2C_MasterReceive(), and HIERODULE_I2C_MasterTransmit().
| void EnableClockStretching | ( | HIERODULE_I2C_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the I2C wrapper. |
Self-explanatory code, nothing to elaborate.
Definition at line 68 of file hierodule_i2c.c.
References Wrapper.
Referenced by HIERODULE_I2C_InitWrapper(), ReceiveByteAsMaster(), and TransmitByteAsMaster().
| void I2C_IRQ_Handler | ( | HIERODULE_I2C_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the I2C wrapper. |
Transmission control is performed by handling the interrupt flags in accordance to the wrapper's status.
Definition at line 629 of file hierodule_i2c.c.
References HIERODULE_I2C_Status_IDLE, HIERODULE_I2C_Status_MRX, HIERODULE_I2C_Status_MRX_ADR, HIERODULE_I2C_Status_MRX_SB, HIERODULE_I2C_Status_MTX, HIERODULE_I2C_Status_MTX_ADR, HIERODULE_I2C_Status_MTX_SB, HIERODULE_I2C_Status_SRX, HIERODULE_I2C_Status_STX, Receive_NACK(), ReceiveByteAsMaster(), ReceiveByteAsSlave(), ReceiveData(), ReturnToIdleState(), TransmitByteAsMaster(), TransmitByteAsSlave(), TransmitData(), and Wrapper.
Referenced by I2C1_EV_IRQHandler(), I2C1_IRQHandler(), I2C2_EV_IRQHandler(), and I2C3_EV_IRQHandler().
| void Idle | ( | HIERODULE_I2C_Wrapper * | Wrapper, |
| uint32_t | NumberOfPeriods ) |
| Wrapper | Pointer to the I2C wrapper. |
| NumberOfPeriods | Number of I2C clock periods. |
The period length is calculated beforehand with a HIERODULE_I2C_InitWrapper call.
Definition at line 55 of file hierodule_i2c.c.
References Wrapper.
Referenced by TransmitByteAsSlave().
| void NACK_Next | ( | HIERODULE_I2C_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the I2C wrapper. |
Self-explanatory code, nothing to elaborate.
Definition at line 174 of file hierodule_i2c.c.
References Wrapper.
Referenced by HIERODULE_I2C_MasterReceive(), and ReceiveByteAsMaster().
| void Receive_NACK | ( | HIERODULE_I2C_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the I2C wrapper. |
Only to be used when exiting slave transmitter mode.
Definition at line 355 of file hierodule_i2c.c.
References HIERODULE_I2C_Status_IDLE, HIERODULE_I2C_Status_STX, TransmitByteAsSlave(), and Wrapper.
Referenced by I2C_IRQ_Handler().
| void ReceiveByteAsMaster | ( | HIERODULE_I2C_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the I2C wrapper. |
The received byte is appended to the MRX buffer of the wrapper.
The data is "ACKed" or "NACKed", depending on whether it's the last byte the master expects to receive. The wrapper is returned to the idle state in the latter case and depending on the device, clock stretching is enabled back again.
Definition at line 229 of file hierodule_i2c.c.
References ACK_Next(), EnableClockStretching(), HIERODULE_I2C_Status_IDLE, NACK_Next(), ReceiveData(), Stop(), and Wrapper.
Referenced by I2C_IRQ_Handler().
| void ReceiveByteAsSlave | ( | HIERODULE_I2C_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the I2C wrapper. |
The routine is stateless, assuming the wrapper status handling is performed accordingly.
Definition at line 266 of file hierodule_i2c.c.
References ReceiveData(), and Wrapper.
Referenced by I2C_IRQ_Handler().
|
static |
| Wrapper | Pointer to the I2C wrapper. |
Defined as static to avoid the multiple definition error some compilers throw since a function with the same name also exists within another module; that will be fixed in a future release.
Definition at line 122 of file hierodule_i2c.c.
References Wrapper.
Referenced by I2C_IRQ_Handler(), ReceiveByteAsMaster(), and ReceiveByteAsSlave().
| void ReturnToIdleState | ( | HIERODULE_I2C_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the I2C wrapper. |
Only to be used when exiting slave receiver mode.
Definition at line 334 of file hierodule_i2c.c.
References HIERODULE_I2C_Status_IDLE, and Wrapper.
Referenced by I2C_IRQ_Handler().
| void Start | ( | HIERODULE_I2C_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the I2C wrapper. |
Self-explanatory code, nothing to elaborate.
Definition at line 191 of file hierodule_i2c.c.
References Wrapper.
Referenced by HIERODULE_I2C_MasterReceive(), and HIERODULE_I2C_MasterTransmit().
| void Stop | ( | HIERODULE_I2C_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the I2C wrapper. |
Self-explanatory code, nothing to elaborate.
Definition at line 208 of file hierodule_i2c.c.
References Wrapper.
Referenced by ReceiveByteAsMaster(), and TransmitByteAsMaster().
| void TransmitByteAsMaster | ( | HIERODULE_I2C_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the I2C wrapper. |
The MTX buffer should be set before initializing the transmission.
Definition at line 284 of file hierodule_i2c.c.
References EnableClockStretching(), HIERODULE_I2C_Status_IDLE, Stop(), TransmitData(), and Wrapper.
Referenced by I2C_IRQ_Handler().
| void TransmitByteAsSlave | ( | HIERODULE_I2C_Wrapper * | Wrapper | ) |
| Wrapper | Pointer to the I2C wrapper. |
The STX buffer should be set before initializing the transmission.
Definition at line 318 of file hierodule_i2c.c.
References Idle(), TransmitData(), and Wrapper.
Referenced by I2C_IRQ_Handler(), and Receive_NACK().
| void TransmitData | ( | HIERODULE_I2C_Wrapper * | Wrapper, |
| uint8_t | Byte ) |
| Wrapper | Pointer to the I2C wrapper. |
| Byte | Byte to be written into the data register. |
Self-explanatory code, nothing to elaborate.
Definition at line 140 of file hierodule_i2c.c.
References Wrapper.
Referenced by I2C_IRQ_Handler(), TransmitByteAsMaster(), and TransmitByteAsSlave().
|
static |
Definition at line 27 of file hierodule_i2c.c.
Referenced by HIERODULE_I2C_InitWrapper(), I2C1_EV_IRQHandler(), and I2C1_IRQHandler().
|
static |
Definition at line 34 of file hierodule_i2c.c.
Referenced by HIERODULE_I2C_InitWrapper(), and I2C2_EV_IRQHandler().
|
static |
Definition at line 44 of file hierodule_i2c.c.
Referenced by HIERODULE_I2C_InitWrapper(), and I2C3_EV_IRQHandler().