I am having some difficulty reading the NRF_GPIO->IN. Specifically I have set up one event function for three different input pins, the phase of a motor. The event is on toggle of any of the pins which then enters the event function. The problem: I want to know the phase of the motor as it has just changed, one of the pins has toggled. All three pins are currently entering the event function on time. Now, I want to know what the state of the three pins are after entering the event function. I am not sure that the in_cfg configuration has attached the pins 6,7,and, 8 to the input buffer, which seems to default to disconnected. I have read many post and somewhere I have seen this written in documentation, but I am not sure where.
Question: why does this enter the pwm contorl of the case, is the NRF_GPIO->IN always reading zero? Do pins 6,7,and 8 need to be connected to the input buffer in order to NRF_GPIO-> IN? How do I write the r/w bit in each of the PIN_CF register with the abstraction layers, libraries, HAL, driver?
//Motor Phase Interrupt handler hs2,hs1,hs0 void phase_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { int32_t motorPhase = 0x00; motorPhase = (NRF_GPIO->IN>>6) && 0x00000007; switch (motorPhase) { case 6: if(NRF_GPIOTE_POLARITY_TOGGLE == action) { nrf_drv_gpiote_out_set(cntrl1); nrf_drv_gpiote_out_clear(cntrl2); nrf_drv_gpiote_out_clear(cntrl3); seq_values[0].channel_0 = 5|0x8000; seq_values[0].channel_1 = 0|0x8000; seq_values[0].channel_2 = 0|0x8000; nrf_pwm_values_t new_pwm_values; new_pwm_values.p_individual = seq_values; nrf_drv_pwm_sequence_values_update(&m_pwm0,1,new_pwm_values); } break; case 7: if(NRF_GPIOTE_POLARITY_TOGGLE == action) { nrf_drv_gpiote_out_clear(cntrl1); nrf_drv_gpiote_out_set(cntrl2); nrf_drv_gpiote_out_clear(cntrl3); seq_values[0].channel_0 = 0|0x8000; seq_values[0].channel_1 = 5|0x8000; seq_values[0].channel_2 = 0|0x8000; nrf_pwm_values_t new_pwm_values; new_pwm_values.p_individual = seq_values; nrf_drv_pwm_sequence_values_update(&m_pwm0,1,new_pwm_values); } break; case 8: if(NRF_GPIOTE_POLARITY_TOGGLE == action) { nrf_drv_gpiote_out_clear(cntrl1); nrf_drv_gpiote_out_clear(cntrl2); nrf_drv_gpiote_out_set(cntrl3); seq_values[0].channel_0 = 0|0x8000; seq_values[0].channel_1 = 0|0x8000; seq_values[0].channel_2 = 5|0x8000; nrf_pwm_values_t new_pwm_values; new_pwm_values.p_individual = seq_values; nrf_drv_pwm_sequence_values_update(&m_pwm0,1,new_pwm_values); } break; default: break; } }