使用的例程是MSP430FR6043EVM_USS_Water_Demo,单步调试的时候跳到了common->DesignCenter->comm->drivers->i2cslave.c中的I2CSLAVE__EUSCI_VECTOR中断,看不懂这个中断在传输什么数据。
#pragma vector=I2CSLAVE__EUSCI_VECTOR __interrupt void I2CSlave_ISR(void) { uint8_t ui8Data; uint16_t u16Temp; switch (__even_in_range(I2CSLAVE__EUSCI_IV, USCI_I2C_UCTXIFG0)) { case USCI_I2C_UCSTTIFG: // // Check for the repeated start case. If this is a repeated start // and the previous operation was a write to this device, // handle the written (received) data. If this is a first-time stard, // the previous I2C state is eI2CSlaveIsIdle. // if (g_I2CSlaveStatus == eI2CSlaveIsBeingWrittenTo) { if (I2CSlave_handleEndOfReceive() == true) { __bic_SR_register_on_exit(I2CSLAVE__LPMx_bits); } } // // Reset the I2C Index to zero to begin the new transaction. // Then check the I2C mode (read/write) to determine // the transaction mode. // g_ui16I2CIndex = 0; if (EUSCI_B_I2C_getMode(I2CSLAVE__EUSCI_B_PERIPHERAL) == EUSCI_B_I2C_TRANSMIT_MODE) { // // If this is a read operation (read from this device), // cancel the slave request flag and trigger and active // exit to alert the application that the flag has changed. // g_I2CSlaveStatus = eI2CSlaveIsBeingRead; g_bI2CSlaveRequestPending = false; __bic_SR_register_on_exit(I2CSLAVE__LPMx_bits); // // If the driver is set up to send the number of bytes to be read // before the rest of the buffer, load the number as the first data byte. // Otherwise, load the first byte of the transmit buffer into the peripheral. // if (g_pI2CSlavePort->bSendReadLengthFirst == true) { ui8Data = g_ui16I2CLength; } else { ui8Data = g_pI2CTransmitBuffer[g_ui16I2CIndex++]; } EUSCI_B_I2C_slavePutData( I2CSLAVE__EUSCI_B_PERIPHERAL, ui8Data ); } else { // // If this is a write operation (write from master to this device), // update the status accordingly and continue (no additional action is necessary). // g_I2CSlaveStatus = eI2CSlaveIsBeingWrittenTo; } // // If the slave timeout feature is enabled, schedule a // transaction timeout. // #if (I2CSLAVE__TIMEOUT_ENABLE==true) Timer_scheduleDelayedFunction(eTimerDelayedFunction_B); #endif /* I2CSLAVE__TIMEOUT_ENABLE==true */ break; case USCI_I2C_UCSTPIFG: // // If the timeout feature is enabled, cancel // the transaction timeout as the operation // has finished successfully. // #if (I2CSLAVE__TIMEOUT_ENABLE==true) Timer_cancelDelayedFunction(eTimerDelayedFunction_B); #endif /* I2CSLAVE__TIMEOUT_ENABLE==true */ if (g_I2CSlaveStatus == eI2CSlaveIsBeingWrittenTo) { // // If the operation that is ending was a write to this // device, handle the written (received) data, and exit // active if the callback function requested it. // if (I2CSlave_handleEndOfReceive() == true) { __bic_SR_register_on_exit(I2CSLAVE__LPMx_bits); } } else if (g_I2CSlaveStatus == eI2CSlaveIsBeingRead) { // // If the opreation that is ending was a read from this device, // exit active in case a transmit (read) buffer pointer update // was pending upon this read. // __bic_SR_register_on_exit(I2CSLAVE__LPMx_bits); } // // Set new status to idle, as the I2C transaction has stopped. // g_I2CSlaveStatus = eI2CSlaveIsIdle; break; case USCI_I2C_UCRXIFG0: // // Grab the received (written) byte from the I2C peripheral. // If there is receive buffer space left, store the received // byte in the receive buffer. Otherwise, discard it and call // the error callback fxn if one is registered. // ui8Data = EUSCI_B_I2C_slaveGetData(I2CSLAVE__EUSCI_B_PERIPHERAL); if (g_ui16I2CIndex < g_pI2CSlavePort->ui16ReceiveBufferSize) { g_pI2CSlavePort->pReceiveBuffer[g_ui16I2CIndex++] = ui8Data; } else { if (g_pI2CSlavePort->pvErrorCallback != 0) { g_pI2CSlavePort->pvErrorCallback(eI2CSlaveReceiveBufferFull); } } break; case USCI_I2C_UCTXIFG0: // // If the transmit index is less than the length, there is still // valid data in the buffer. Load the next byte. // Else, there is no valid data left in the buffer, so transmit // the invalid byte. // u16Temp = g_ui16I2CLength; if (g_ui16I2CIndex<u16Temp) { ui8Data = g_pI2CTransmitBuffer[g_ui16I2CIndex++]; } else { ui8Data = I2CSLAVE__INVALID_BYTE; if (g_pI2CSlavePort->pvErrorCallback != 0) { g_pI2CSlavePort->pvErrorCallback(eI2CSlaveWasReadBeyondTransmitBuffer); } } EUSCI_B_I2C_slavePutData(I2CSLAVE__EUSCI_B_PERIPHERAL, ui8Data); break; } } #endif /* I2CSLAVE__ENABLE==true */