除了阅读大量的ST官方文档,剩下的信息就基本来自这里了。感谢分享经验的兄弟们,等有时间我也来分享一些心得……
话说那个CPAL库还是不错的,虽有些小问题,总体上功能挺好,覆盖了I2C操作的所有模式,用软件弥补了硬件的不足,并且支持多任务并行操作,就是有点复杂,要舍得花时间搞定。先贴出来几段调试输出(semihost方式),看到这些就差不多成功了:
/////////////////////////////////////////////////////////
// Init.
LOG <CPAL_I2C_StructInit> : I2C Device Structure set to Default Value
LOG <CPAL_I2C_Init> : I2C Device Init
LOG : I2C Device Disabled
LOG : I2C Device IOs Deinit
LOG : I2C Device Clock Deinit
LOG : I2C Device DMA Deinit
LOG : I2C Device Clock Init
LOG : I2C Device IOs Init
LOG : I2C Device Enabled
LOG : I2C Device Config
LOG : I2C Device DMA Init
LOG : I2C Device IT Init
/////////////////////////////////////////////////////////
// Write one byte
: I2C Device Ready
LOG <CPAL_I2C_Write> : I2C Device Write OP
LOG : I2C Device Master
LOG : I2C Device DMA TX Enabled
LOG : I2C Device Ready TX
LOG : I2C Device Generates Start
LOG : I2C Device EVT IT Enabled
LOG <I2C_EV_IRQHandler> : I2C Device Master IT
LOG : I2C Device Start Acknowledged
LOG : I2C Device 7bit Address
LOG : I2C Device Busy TX
LOG : I2C Device Target Address Sent
LOG <CPAL_I2C_DMA_TX_IRQHandler> : I2C Device TX DMA
LOG : I2C Device TX Complete
/////////////////////////////////////////////////////////
// Read 3-byte
: I2C Device Master TX DMA Disabled
LOG <CPAL_I2C_Read> : I2C Device Perform Read OP
LOG : I2C Device Master No Memory Address Mode
LOG : I2C Device Ready RX
LOG : I2C Device Master
LOG : I2C Device Generates Start
LOG : I2C Device EVT IT Enabled
LOG <I2C_EV_IRQHandler> : I2C Device Master IT
LOG : I2C Device Start Acknowledged
LOG : I2C Device 7bit Address
LOG : I2C Device Busy RX
LOG : I2C Device Target Address Sent
LOG <CPAL_I2C_DMA_RX_IRQHandler> : I2C Device RX DMA
LOG : I2C Device RX Complete
|