Created
November 13, 2017 09:14
-
-
Save anonymous/f20b78d4280f1de81a803458c418399c to your computer and use it in GitHub Desktop.
TWI Initialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool init_twi (void) { | |
// Variables | |
uint32_t err_code; | |
//NRF_LOG_INFO("twi_init: Initializing TWI....\r\n"); | |
// Main parameters to configure the TWI communication | |
const nrf_drv_twi_config_t twi_mpu_config = { | |
.scl = TWI_SCL_PIN, | |
.sda = TWI_SDA_PIN, | |
.frequency = NRF_TWI_FREQ_400K, | |
.interrupt_priority = APP_IRQ_PRIORITY_LOW | |
}; | |
// Initialize the TWI driver | |
err_code = nrf_drv_twi_init(&m_twi_instance, &twi_mpu_config, twi_event_handler, NULL); | |
// Check if error | |
if ( err_code != NRF_SUCCESS ) return false; | |
// Enable the TWI driver | |
nrf_drv_twi_enable(&m_twi_instance); | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment