I am attempting to move some of TI's driverlib functions over to my own drivers so that the code is smaller and easier to handle. However, I am having a lot of trouble with the driverlib, specifically the eUSCI declarations. This line:
/* Disable the USCI module and clears the other bits of control register */
BITBAND_PERI(EUSCI_B_CMSIS(moduleInstance)->rCTLW0.r,UCSWRST_OFS) = 1;
is in the I2C_initMaster() function in driverlib.c. However I cannot find a declaration for the ->rCTLW0.r
segment. Is there a way around using this?
driverlib/MSP432P4xx/eusci.h
has:
#define EUSCI_A_CMSIS(x) ((EUSCI_A_Type *) x)
inc/msp432p401r.h
has:
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;
That rXXX.r
stuff is used only in the ROM driverlib. It looks as if each register was declared as a union, probably to allow all bytes to be accessed separately. The source code of the ROM driverlib cannot ever be changed, but the source code of the driverlib that you can compile yourself (driverlib/MSP432P4xx/i2c.c
, not rom/MSP432P4xx/driverlib.c
) uses the correct declarations.
(And if you don't like the CMSIS-style register accesses, use msp432p401r_classic.h
.)