55 #include <ti/devices/msp432p4xx/inc/msp.h>
56 #include <ti/devices/msp432p4xx/driverlib/eusci.h>
58 #define EUSCI_B_I2C_NO_AUTO_STOP EUSCI_B_CTLW1_ASTP_0
59 #define EUSCI_B_I2C_SET_BYTECOUNT_THRESHOLD_FLAG EUSCI_B_CTLW1_ASTP_1
60 #define EUSCI_B_I2C_SEND_STOP_AUTOMATICALLY_ON_BYTECOUNT_THRESHOLD \
63 #define EUSCI_B_I2C_SET_DATA_RATE_1MBPS 1000000
64 #define EUSCI_B_I2C_SET_DATA_RATE_400KBPS 400000
65 #define EUSCI_B_I2C_SET_DATA_RATE_100KBPS 100000
67 #define EUSCI_B_I2C_CLOCKSOURCE_ACLK EUSCI_B_CTLW0_SSEL__ACLK
68 #define EUSCI_B_I2C_CLOCKSOURCE_SMCLK EUSCI_B_CTLW0_SSEL__SMCLK
70 #define EUSCI_B_I2C_OWN_ADDRESS_OFFSET0 0x00
71 #define EUSCI_B_I2C_OWN_ADDRESS_OFFSET1 0x02
72 #define EUSCI_B_I2C_OWN_ADDRESS_OFFSET2 0x04
73 #define EUSCI_B_I2C_OWN_ADDRESS_OFFSET3 0x06
75 #define EUSCI_B_I2C_OWN_ADDRESS_DISABLE 0x00
76 #define EUSCI_B_I2C_OWN_ADDRESS_ENABLE EUSCI_B_I2COA0_OAEN
78 #define EUSCI_B_I2C_TRANSMIT_MODE EUSCI_B_CTLW0_TR
79 #define EUSCI_B_I2C_RECEIVE_MODE 0x00
81 #define EUSCI_B_I2C_TIMEOUT_DISABLE EUSCI_B_CTLW1_CLTO_0
82 #define EUSCI_B_I2C_TIMEOUT_28_MS EUSCI_B_CTLW1_CLTO_1
83 #define EUSCI_B_I2C_TIMEOUT_31_MS EUSCI_B_CTLW1_CLTO_2
84 #define EUSCI_B_I2C_TIMEOUT_34_MS EUSCI_B_CTLW1_CLTO_3
86 #define EUSCI_B_I2C_NAK_INTERRUPT EUSCI_B_IE_NACKIE
87 #define EUSCI_B_I2C_ARBITRATIONLOST_INTERRUPT EUSCI_B_IE_ALIE
88 #define EUSCI_B_I2C_STOP_INTERRUPT EUSCI_B_IE_STPIE
89 #define EUSCI_B_I2C_START_INTERRUPT EUSCI_B_IE_STTIE
90 #define EUSCI_B_I2C_TRANSMIT_INTERRUPT0 EUSCI_B_IE_TXIE0
91 #define EUSCI_B_I2C_TRANSMIT_INTERRUPT1 EUSCI_B_IE_TXIE1
92 #define EUSCI_B_I2C_TRANSMIT_INTERRUPT2 EUSCI_B_IE_TXIE2
93 #define EUSCI_B_I2C_TRANSMIT_INTERRUPT3 EUSCI_B_IE_TXIE3
94 #define EUSCI_B_I2C_RECEIVE_INTERRUPT0 EUSCI_B_IE_RXIE0
95 #define EUSCI_B_I2C_RECEIVE_INTERRUPT1 EUSCI_B_IE_RXIE1
96 #define EUSCI_B_I2C_RECEIVE_INTERRUPT2 EUSCI_B_IE_RXIE2
97 #define EUSCI_B_I2C_RECEIVE_INTERRUPT3 EUSCI_B_IE_RXIE3
98 #define EUSCI_B_I2C_BIT9_POSITION_INTERRUPT EUSCI_B_IE_BIT9IE
99 #define EUSCI_B_I2C_CLOCK_LOW_TIMEOUT_INTERRUPT EUSCI_B_IE_CLTOIE
100 #define EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT EUSCI_B_IE_BCNTIE
102 #define EUSCI_B_I2C_BUS_BUSY EUSCI_B_STATW_BBUSY
103 #define EUSCI_B_I2C_BUS_NOT_BUSY 0x00
105 #define EUSCI_B_I2C_STOP_SEND_COMPLETE 0x00
106 #define EUSCI_B_I2C_SENDING_STOP EUSCI_B_CTLW0_TXSTP
108 #define EUSCI_B_I2C_START_SEND_COMPLETE 0x00
109 #define EUSCI_B_I2C_SENDING_START EUSCI_B_CTLW0_TXSTT
224 extern void I2C_initSlave(uint32_t moduleInstance, uint_fast16_t slaveAddress,
225 uint_fast8_t slaveAddressOffset, uint32_t slaveOwnAddressEnable);
295 uint_fast16_t slaveAddress);
320 extern void I2C_setMode(uint32_t moduleInstance, uint_fast8_t mode);
348 extern void I2C_setTimeout(uint32_t moduleInstance, uint_fast16_t timeout);
375 extern uint_fast8_t
I2C_getMode(uint32_t moduleInstance);
400 extern void I2C_slavePutData(uint32_t moduleInstance, uint8_t transmitData);
510 uint8_t txData, uint32_t timeout);
571 uint8_t txData, uint32_t timeout);
629 uint8_t txData, uint32_t timeout);
690 uint8_t txData, uint32_t timeout);
855 uint8_t *txData, uint32_t timeout);
1349 void (*intHandler)(
void));
1398 #define EUSCI_B_I2C_slaveInit I2C_initSlave
1399 #define EUSCI_B_I2C_enable I2C_enableModule
1400 #define EUSCI_B_I2C_disable I2C_disableModule
1401 #define EUSCI_B_I2C_setSlaveAddress I2C_setSlaveAddress
1402 #define EUSCI_B_I2C_setMode I2C_setMode
1403 #define EUSCI_B_I2C_getMode I2C_getMode
1404 #define EUSCI_B_I2C_slaveDataPut I2C_slavePutData
1405 #define EUSCI_B_I2C_slaveDataGet I2C_slaveGetData
1406 #define EUSCI_B_I2C_isBusBusy I2C_isBusBusy
1407 #define EUSCI_B_I2C_masterIsStopSent I2C_masterIsStopSent
1408 #define EUSCI_B_I2C_masterIsStartSent I2C_masterIsStartSent
1409 #define EUSCI_B_I2C_enableInterrupt I2C_enableInterrupt
1410 #define EUSCI_B_I2C_disableInterrupt I2C_disableInterrupt
1411 #define EUSCI_B_I2C_clearInterruptFlag I2C_clearInterruptFlag
1412 #define EUSCI_B_I2C_getInterruptStatus I2C_getEnabledInterruptStatus
1413 #define EUSCI_B_I2C_masterSendSingleByte I2C_masterSendSingleByte
1414 #define EUSCI_B_I2C_masterReceiveSingleByte I2C_masterReceiveSingleByte
1415 #define EUSCI_B_I2C_masterSendSingleByteWithTimeout I2C_masterSendSingleByteWithTimeout
1416 #define EUSCI_B_I2C_masterMultiByteSendStart I2C_masterSendMultiByteStart
1417 #define EUSCI_B_I2C_masterMultiByteSendStartWithTimeout I2C_masterSendMultiByteStartWithTimeout
1418 #define EUSCI_B_I2C_masterMultiByteSendNext I2C_masterSendMultiByteNext
1419 #define EUSCI_B_I2C_masterMultiByteSendNextWithTimeout I2C_masterSendMultiByteNextWithTimeout
1420 #define EUSCI_B_I2C_masterMultiByteSendFinish I2C_masterSendMultiByteFinish
1421 #define EUSCI_B_I2C_masterMultiByteSendFinishWithTimeout I2C_masterSendMultiByteFinishWithTimeout
1422 #define EUSCI_B_I2C_masterSendStart I2C_masterSendStart
1423 #define EUSCI_B_I2C_masterMultiByteSendStop I2C_masterSendMultiByteStop
1424 #define EUSCI_B_I2C_masterMultiByteSendStopWithTimeout I2C_masterSendMultiByteStopWithTimeout
1425 #define EUSCI_B_I2C_masterReceiveStart I2C_masterReceiveStart
1426 #define EUSCI_B_I2C_masterMultiByteReceiveNext I2C_masterReceiveMultiByteNext
1427 #define EUSCI_B_I2C_masterMultiByteReceiveFinish I2C_masterReceiveMultiByteFinish
1428 #define EUSCI_B_I2C_masterMultiByteReceiveFinishWithTimeout I2C_masterReceiveMultiByteFinishWithTimeout
1429 #define EUSCI_B_I2C_masterMultiByteReceiveStop I2C_masterReceiveMultiByteStop
1430 #define EUSCI_B_I2C_enableMultiMasterMode I2C_enableMultiMasterMode
1431 #define EUSCI_B_I2C_disableMultiMasterMode I2C_disableMultiMasterMode
1432 #define EUSCI_B_I2C_masterSingleReceive I2C_masterReceiveSingle
1433 #define EUSCI_B_I2C_getReceiveBufferAddressForDMA I2C_getReceiveBufferAddressForDMA
1434 #define EUSCI_B_I2C_getTransmitBufferAddressForDMA I2C_getTransmitBufferAddressForDMA
void I2C_slaveSendNAK(uint32_t moduleInstance)
Definition: i2c.c:814
bool I2C_masterSendMultiByteFinishWithTimeout(uint32_t moduleInstance, uint8_t txData, uint32_t timeout)
Definition: i2c.c:430
bool I2C_masterSendMultiByteStartWithTimeout(uint32_t moduleInstance, uint8_t txData, uint32_t timeout)
Definition: i2c.c:324
void I2C_setMode(uint32_t moduleInstance, uint_fast8_t mode)
Definition: i2c.c:138
uint8_t I2C_masterReceiveSingleByte(uint32_t moduleInstance)
Definition: i2c.c:173
void I2C_disableInterrupt(uint32_t moduleInstance, uint_fast16_t mask)
Definition: i2c.c:671
uint32_t dataRate
Definition: i2c.h:125
bool I2C_masterSendMultiByteStopWithTimeout(uint32_t moduleInstance, uint32_t timeout)
Definition: i2c.c:487
void I2C_masterReceiveMultiByteStop(uint32_t moduleInstance)
Definition: i2c.c:581
uint8_t I2C_masterReceiveMultiByteFinish(uint32_t moduleInstance)
Definition: i2c.c:524
uint8_t I2C_masterReceiveSingle(uint32_t moduleInstance)
Definition: i2c.c:588
uint_fast8_t byteCounterThreshold
Definition: i2c.h:126
uint8_t I2C_isBusBusy(uint32_t moduleInstance)
Definition: i2c.c:204
uint32_t I2C_getTransmitBufferAddressForDMA(uint32_t moduleInstance)
Definition: i2c.c:607
uint_fast8_t autoSTOPGeneration
Definition: i2c.h:127
bool I2C_masterIsStartSent(uint32_t moduleInstance)
Definition: i2c.c:618
uint8_t I2C_masterIsStopSent(uint32_t moduleInstance)
Definition: i2c.c:612
bool I2C_masterSendSingleByteWithTimeout(uint32_t moduleInstance, uint8_t txData, uint32_t timeout)
Definition: i2c.c:246
bool I2C_masterSendMultiByteNextWithTimeout(uint32_t moduleInstance, uint8_t txData, uint32_t timeout)
Definition: i2c.c:376
uint_fast16_t I2C_getEnabledInterruptStatus(uint32_t moduleInstance)
Definition: i2c.c:744
void I2C_masterSendMultiByteStart(uint32_t moduleInstance, uint8_t txData)
Definition: i2c.c:299
bool I2C_masterReceiveMultiByteFinishWithTimeout(uint32_t moduleInstance, uint8_t *txData, uint32_t timeout)
Definition: i2c.c:545
void I2C_registerInterrupt(uint32_t moduleInstance, void(*intHandler)(void))
Definition: i2c.c:756
void I2C_slavePutData(uint32_t moduleInstance, uint8_t transmitData)
Definition: i2c.c:192
uint_fast8_t I2C_getMode(uint32_t moduleInstance)
Gets the mode of the I2C device.
Definition: i2c.c:750
void I2C_masterReceiveStart(uint32_t moduleInstance)
Definition: i2c.c:512
uint8_t I2C_masterReceiveMultiByteNext(uint32_t moduleInstance)
Definition: i2c.c:519
void I2C_initMaster(uint32_t moduleInstance, const eUSCI_I2C_MasterConfig *config)
Definition: i2c.c:36
uint_fast16_t I2C_getInterruptStatus(uint32_t moduleInstance, uint16_t mask)
Definition: i2c.c:720
void I2C_setTimeout(uint32_t moduleInstance, uint_fast16_t timeout)
Definition: i2c.c:149
void I2C_masterSendMultiByteNext(uint32_t moduleInstance, uint8_t txData)
Definition: i2c.c:361
void I2C_initSlave(uint32_t moduleInstance, uint_fast16_t slaveAddress, uint_fast8_t slaveAddressOffset, uint32_t slaveOwnAddressEnable)
Definition: i2c.c:92
void I2C_clearInterruptFlag(uint32_t moduleInstance, uint_fast16_t mask)
Definition: i2c.c:696
void I2C_masterSendSingleByte(uint32_t moduleInstance, uint8_t txData)
Definition: i2c.c:211
void I2C_unregisterInterrupt(uint32_t moduleInstance)
Definition: i2c.c:785
uint32_t i2cClk
Definition: i2c.h:124
void I2C_enableMultiMasterMode(uint32_t moduleInstance)
Definition: i2c.c:630
uint32_t I2C_getReceiveBufferAddressForDMA(uint32_t moduleInstance)
Definition: i2c.c:602
void I2C_masterSendStart(uint32_t moduleInstance)
Definition: i2c.c:624
void I2C_enableInterrupt(uint32_t moduleInstance, uint_fast16_t mask)
Definition: i2c.c:646
uint8_t I2C_slaveGetData(uint32_t moduleInstance)
Definition: i2c.c:198
void I2C_masterSendMultiByteStop(uint32_t moduleInstance)
Definition: i2c.c:471
void I2C_setSlaveAddress(uint32_t moduleInstance, uint_fast16_t slaveAddress)
Definition: i2c.c:132
void I2C_disableModule(uint32_t moduleInstance)
Definition: i2c.c:124
void I2C_disableMultiMasterMode(uint32_t moduleInstance)
Definition: i2c.c:638
uint_fast8_t selectClockSource
Definition: i2c.h:123
bool I2C_masterSendMultiByteFinish(uint32_t moduleInstance, uint8_t txData)
Definition: i2c.c:400
void I2C_enableModule(uint32_t moduleInstance)
Definition: i2c.c:117