如何解决将CMSIS驱动程序结构链接到CMSIS Cortex-M4外围设备
我想知道如何将CMSIS驱动程序(例如I2C驱动程序数据结构)链接到其物理外围设备?
这是 Driver_I2C.h
中的结构typedef struct _ARM_DRIVER_I2C {
ARM_DRIVER_VERSION (*GetVersion) (void); ///< Pointer to \ref ARM_I2C_GetVersion : Get driver version.
ARM_I2C_CAPABILITIES (*GetCapabilities)(void); ///< Pointer to \ref ARM_I2C_GetCapabilities : Get driver capabilities.
int32_t (*Initialize) (ARM_I2C_SignalEvent_t cb_event); ///< Pointer to \ref ARM_I2C_Initialize : Initialize I2C Interface.
int32_t (*Uninitialize) (void); ///< Pointer to \ref ARM_I2C_Uninitialize : De-initialize I2C Interface.
int32_t (*PowerControl) (ARM_POWER_STATE state); ///< Pointer to \ref ARM_I2C_PowerControl : Control I2C Interface Power.
int32_t (*MasterTransmit) (uint32_t addr,const uint8_t *data,uint32_t num,bool xfer_pending); ///< Pointer to \ref ARM_I2C_MasterTransmit : Start transmitting data as I2C Master.
int32_t (*MasterReceive) (uint32_t addr,uint8_t *data,bool xfer_pending); ///< Pointer to \ref ARM_I2C_MasterReceive : Start receiving data as I2C Master.
int32_t (*SlaveTransmit) ( const uint8_t *data,uint32_t num); ///< Pointer to \ref ARM_I2C_SlaveTransmit : Start transmitting data as I2C Slave.
int32_t (*SlaveReceive) ( uint8_t *data,uint32_t num); ///< Pointer to \ref ARM_I2C_SlaveReceive : Start receiving data as I2C Slave.
int32_t (*GetDataCount) (void); ///< Pointer to \ref ARM_I2C_GetDataCount : Get transferred data count.
int32_t (*Control) (uint32_t control,uint32_t arg); ///< Pointer to \ref ARM_I2C_Control : Control I2C Interface.
ARM_I2C_STATUS (*GetStatus) (void); ///< Pointer to \ref ARM_I2C_GetStatus : Get I2C status.
} const ARM_DRIVER_I2C;
我在 main.c 中创建一个使用此结构的变量:
ARM_DRIVER_I2C Driver_I2C0; //Create a instance of I2C0
但是如何将变量链接到CMSIS Cortex M4外围I2C0? ( TM4C123GH6PM.h )
typedef struct { /*!< I2C0 Structure */
__IO uint32_t MSA; /*!< I2C Master Slave Address */
union {
__IO uint32_t MCS_I2C0_ALT; /*!< I2C Master Control/Status */
__IO uint32_t MCS; /*!< I2C Master Control/Status */
};
__IO uint32_t MDR; /*!< I2C Master Data */
__IO uint32_t MTPR; /*!< I2C Master Timer Period */
__IO uint32_t MIMR; /*!< I2C Master Interrupt Mask */
__IO uint32_t MRIS; /*!< I2C Master Raw Interrupt Status */
__IO uint32_t MMIS; /*!< I2C Master Masked Interrupt Status */
__O uint32_t MICR; /*!< I2C Master Interrupt Clear */
__IO uint32_t MCR; /*!< I2C Master Configuration */
__IO uint32_t MCLKOCNT; /*!< I2C Master Clock Low Timeout Count */
__I uint32_t RESERVED0;
__IO uint32_t MBMON; /*!< I2C Master Bus Monitor */
__I uint32_t RESERVED1[2];
__IO uint32_t MCR2; /*!< I2C Master Configuration 2 */
__I uint32_t RESERVED2[497];
__IO uint32_t SOAR; /*!< I2C Slave Own Address */
union {
__IO uint32_t SCSR_I2C0_ALT; /*!< I2C Slave Control/Status */
__IO uint32_t SCSR; /*!< I2C Slave Control/Status */
};
__IO uint32_t SDR; /*!< I2C Slave Data */
__IO uint32_t SIMR; /*!< I2C Slave Interrupt Mask */
__IO uint32_t SRIS; /*!< I2C Slave Raw Interrupt Status */
__IO uint32_t SMIS; /*!< I2C Slave Masked Interrupt Status */
__O uint32_t SICR; /*!< I2C Slave Interrupt Clear */
__IO uint32_t SOAR2; /*!< I2C Slave Own Address 2 */
__IO uint32_t SACKCTL; /*!< I2C Slave ACK Control */
__I uint32_t RESERVED3[487];
__IO uint32_t PP; /*!< I2C Peripheral Properties */
__IO uint32_t PC; /*!< I2C Peripheral Configuration */
} I2C0_Type;
问题:CMSIS模板是否具有处理该链接的方法,或者我需要自己添加链接(例如,添加指向该M4皮质结构的指针)吗?
谢谢:)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。