先不说其它的,直接上代码
#define TWI_INSTANCE_ID 0
/* Indicates if operation on TWI has ended. */
static volatile bool m_xfer_done = false;
/* Buffer for samples read from temperature sensor. */
static uint8_t m_sample;
static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID);
/**
* @brief Function for handling data from temperature sensor.
*
* @param[in] temp Temperature in Celsius degrees read from sensor.
*/
__STATIC_INLINE void data_handler(uint8_t temp)
{
// NRF_LOG_INFO("Temperature: %d Celsius degrees.", temp);
}
/**
* @brief TWI events handler.
*/
void twi_handler(nrf_drv_twi_evt_t const * p_event, void * p_context)
{
switch (p_event->type)
{
case NRF_DRV_TWI_EVT_DONE:
if (p_event->xfer_desc.type &#