nrf5/hal: Started implementation of hal_twi.c (non-DMA). Init function started.
This commit is contained in:
parent
70d64e2892
commit
0629abac53
@ -36,6 +36,19 @@ static const uint32_t hal_twi_frequency_lookup[] = {
|
||||
};
|
||||
|
||||
void hal_twi_master_init(NRF_TWI_Type * p_instance, hal_twi_init_t const * p_twi_init) {
|
||||
|
||||
#if NRF52840_XXAA
|
||||
p_instance->PSEL.SCL = p_twi_init->scl_pin->pin;
|
||||
p_instance->PSEL.SDA = p_twi_init->sda_pin->pin;
|
||||
p_instance->PSEL.SCL |= (p_twi_init->scl_pin->port << TWI_PSEL_SCL_PORT_Pos);
|
||||
p_instance->PSEL.SDA |= (p_twi_init->sda_pin->port << TWI_PSEL_SDA_PORT_Pos);
|
||||
#else
|
||||
p_instance->PSELSCL = p_twi_init->scl_pin->pin;
|
||||
p_instance->PSELSDA = p_twi_init->sda_pin->pin;
|
||||
#endif
|
||||
|
||||
p_instance->FREQUENCY = hal_twi_frequency_lookup[p_twi_init->freq];
|
||||
p_instance->ENABLE = (TWI_ENABLE_ENABLE_Enabled << TWI_ENABLE_ENABLE_Pos);
|
||||
}
|
||||
|
||||
void hal_twi_master_tx(NRF_TWI_Type * p_instance,
|
||||
@ -43,7 +56,7 @@ void hal_twi_master_tx(NRF_TWI_Type * p_instance,
|
||||
uint16_t transfer_size,
|
||||
const uint8_t * tx_data,
|
||||
bool stop) {
|
||||
|
||||
p_instance->ADDRESS = addr;
|
||||
}
|
||||
|
||||
void hal_twi_master_rx(NRF_TWI_Type * p_instance,
|
||||
|
Loading…
Reference in New Issue
Block a user