MSP432p401r:此声明在哪里?

时间:2018-11-26 06:36:17

标签: msp430 code-composer msp432

我试图将TI的一些driverlib函数移到我自己的驱动程序上,以使代码更小且更易于处理。但是,我在driverlib方面遇到很多麻烦,特别是eUSCI声明。 这行:

/* Disable the USCI module and clears the other bits of control register */
BITBAND_PERI(EUSCI_B_CMSIS(moduleInstance)->rCTLW0.r,UCSWRST_OFS) = 1;

位于driverlib.c的I2C_initMaster()函数中。但是,我找不到->rCTLW0.r段的声明。有没有办法解决这个问题?

1 个答案:

答案 0 :(得分:0)

driverlib/MSP432P4xx/eusci.h具有:

#define EUSCI_A_CMSIS(x) ((EUSCI_A_Type *) x)

inc/msp432p401r.h具有:

typedef struct {
  __IO uint16_t CTLW0;                           /**< eUSCI_Ax Control Word Register 0 */
  __IO uint16_t CTLW1;                           /**< eUSCI_Ax Control Word Register 1 */
       uint16_t RESERVED0;
  __IO uint16_t BRW;                             /**< eUSCI_Ax Baud Rate Control Word Register */
  __IO uint16_t MCTLW;                           /**< eUSCI_Ax Modulation Control Word Register */
  __IO uint16_t STATW;                           /**< eUSCI_Ax Status Register */
  __I  uint16_t RXBUF;                           /**< eUSCI_Ax Receive Buffer Register */
  __IO uint16_t TXBUF;                           /**< eUSCI_Ax Transmit Buffer Register */
  __IO uint16_t ABCTL;                           /**< eUSCI_Ax Auto Baud Rate Control Register */
  __IO uint16_t IRCTL;                           /**< eUSCI_Ax IrDA Control Word Register */
       uint16_t RESERVED1[3];
  __IO uint16_t IE;                              /**< eUSCI_Ax Interrupt Enable Register */
  __IO uint16_t IFG;                             /**< eUSCI_Ax Interrupt Flag Register */
  __I  uint16_t IV;                              /**< eUSCI_Ax Interrupt Vector Register */
} EUSCI_A_Type;

rXXX.r的内容仅在ROM驱动程序库中使用。看起来好像每个寄存器都被声明为联合,可能是允许所有字节分别访问。 ROM driverlib的源代码无法更改,但是可以自行编译的driverlib的源代码(driverlib/MSP432P4xx/i2c.c,而不是rom/MSP432P4xx/driverlib.c)使用正确的声明。

(如果您不喜欢CMSIS样式的寄存器访问,请使用msp432p401r_classic.h。)