The flow chart is as follows:
The I2C interrupt processing function is as follows:
/**
* @brief This function handles I2C1 Event interrupt request, tx, rx
* buffer and number of bytes will be changed.
* @param None
* @retval None
*/
void I2C1_EV_IRQHandler(void)
{
#ifdef ARC_I2C_IRQ
uint32_t i2cEvent;
I2C_param_struct __IO *pI2C_param;
pI2C_param = ARC_get_I2C_param();
i2cEvent = I2C_GetLastEvent(I2C1);
switch (i2cEvent)
{
case I2C_EVENT_MASTER_MODE_SELECT:/* EV5 */
if(pI2C_param->I2C_DIRECTION == ARC_I2C_DIRECTION_TX)
{
I2C_Send7bitAddress(I2C1, pI2C_param->DeviceAddr, I2C_Direction_Transmitter);
}
else
{
I2C_Send7bitAddress(I2C1, pI2C_param->DeviceAddr, I2C_Direction_Receiver);
}
break;
/* Master Transmitter -------------------------------------------------------*/
case I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED:
I2C_SendData(I2C1, pI2C_param->SubAddr);
if(pI2C_param->TxNumOfBytes == 0)
I2C_ITConfig(I2C1, I2C_IT_BUF, DISABLE);
break;
case I2C_EVENT_MASTER_BYTE_TRANSMITTING: /* Without BTF, EV8 */
if(pI2C_param->TX_I2C_Index < pI2C_param->TxNumOfBytes)
{
I2C_SendData(I2C1, pI2C_param->TxData[pI2C_param->TX_I2C_Index++]);
}
else
{
I2C_ITConfig(I2C1, I2C_IT_BUF, DISABLE);
}
break;
case I2C_EVENT_MASTER_BYTE_TRANSMITTED: /* With BTF EV8-2 */
if(pI2C_param->TX_Generate_stop == 1)
{
I2C_GenerateSTOP(I2C1, ENABLE);
I2C_ITConfig(I2C1, I2C_IT_EVT, DISABLE);
}
else
{
pI2C_param->I2C_DIRECTION = ARC_I2C_DIRECTION_RX;
I2C_ITConfig(I2C1, I2C_IT_BUF, ENABLE);
I2C_GenerateSTART(I2C1, ENABLE);
}
break;
/* Master Receiver -------------------------------------------------------*/
case I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED:
if(pI2C_param->RX_I2C_Index == (pI2C_param->RxNumOfBytes - 1))
{
I2C_AcknowledgeConfig(I2C1, DISABLE);
I2C_GenerateSTOP(I2C1, ENABLE);
}
break;
case I2C_EVENT_MASTER_BYTE_RECEIVED:
pI2C_param->RxData[pI2C_param->RX_I2C_Index++] = I2C_ReceiveData (I2C1);
if(pI2C_param->RX_I2C_Index == (pI2C_param->RxNumOfBytes - 1))
{
I2C_AcknowledgeConfig(I2C1, DISABLE);
I2C_GenerateSTOP(I2C1, ENABLE);
}
break;
default:
break;
}
#endif
}
Previous article:STM32 I2C Hardware
Next article:About I2C hardware DMA implementation of STM32
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- FAQ_ How to choose a high-speed crystal for BlueNRG-x
- 2021 STMicroelectronics Industry Summit Tour- Shanghai/Beijing
- Summary: RCSN Play Anxinke's new esp32s3 development board
- How should Japan deal with nuclear waste water? Give us some ideas
- RTL diagram timing, can anyone help me explain why the two outputs in this diagram are in the two-choice mode?
- Now DCDC design tools are made like this
- The disappearing boundary between MCU and MPU
- DS18B20 STM32G474 driver
- 【Fudan Micro FM33LC046N】Clock output test
- Python Basics: Dictionary Application