Hello, I have a problem with GPIO Input control
My sensor work on special clock generated by MCU
I've controlled this sensor by Arduino like this
//SCK digital pin 4, SDIO digital pin 5
digitalWrite(SCKI,HIGH); // bit22 delayMicroseconds(TIMING); // bit22 - TIMING over 2us digitalWrite(SCKI,LOW); // bit22 - Set delayMicroseconds(SCKTIMING); // SCK TIMING 2us~64us-20% read[22] = digitalRead(SDIO); // bit22 - Captured
digitalWrite(SCKI,HIGH); // bit21 delayMicroseconds(TIMING); // bit21 - TIMING digitalWrite(SCKI,LOW); // bit21 - Set delayMicroseconds(SCKTIMING); // SCK TIMING 2us~64us-20% read[21] = digitalRead(SDIO); // bit21 - Captured
digitalWrite(SCKI,HIGH); // bit20
delayMicroseconds(TIMING); // bit20 - TIMING
digitalWrite(SCKI,LOW); // bit20 - Set
delayMicroseconds(SCKTIMING); // SCK TIMING 2us~64us-20%
read[20] = digitalRead(SDIO); // bit20 - Captured
digitalWrite(SCKI,HIGH); // bit19
delayMicroseconds(TIMING); // bit19 - TIMING
digitalWrite(SCKI,LOW); // bit19 - Set
delayMicroseconds(SCKTIMING); // SCK TIMING 2us~64us-20%
read[19] = digitalRead(SDIO); // bit19 - Captured
I made this special clock by using delay function, because it doesn't have to use accurate. And it works well. Each rising and falling clock, SDIO(digiatl pin 5) transfer 0 or 1 to arduino.
So I changed this source for nRF51822 like this
nrf_gpio_pin_set(SCK); nrf_delay_us(TIMING); nrf_gpio_pin_clear(SCK); nrf_delay_us(SCKTIMING); read[22] = nrf_gpio_pin_read(SDI);
nrf_gpio_pin_set(SCK);
nrf_delay_us(TIMING);
nrf_gpio_pin_clear(SCK);
nrf_delay_us(SCKTIMING);
read[21] = nrf_gpio_pin_read(SDI);
nrf_gpio_pin_set(SCK);
nrf_delay_us(TIMING);
nrf_gpio_pin_clear(SCK);
nrf_delay_us(SCKTIMING);
read[20] = nrf_gpio_pin_read(SDI);
And the sensor start condition is like this
(nrf_gpio_pin_read(SDI) == 0
when I debugged, nRF51822 cannot read SDI's value is zero.
digitalRead(SDIO) function means reads 0 or 1 . But nRF51822, I think it's not simple like that.
Is there any good function for bit capture like digitalRead() in nRF51822?
my development board is nRF51-DK and my development platform is Keil-MDK v5