Lora-net / LoRaMac-node

Reference implementation and documentation of a LoRa network node.
Other
1.89k stars 1.09k forks source link

Question about the SX126xReset funtion #616

Closed Lozeonjyu closed 5 years ago

Lozeonjyu commented 5 years ago

Hi,

I am using the Nucleo L073+Sx1261 shield to load the code. During the code reading, I find something that confuses me a little bit.

In the file sx1261mbxbas-board.c, it introduces the sx126x reset function:

void SX126xReset( void )
{
    DelayMs( 10 );
    GpioInit( &SX126x.Reset, RADIO_RESET, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 );
    DelayMs( 20 );
    GpioInit( &SX126x.Reset, RADIO_RESET, PIN_ANALOGIC, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); // internal pull-up
    DelayMs( 10 );
}

It seems like the micro drives the reset pin low and let the reset pin go back, but why it initializes again as analog rather than just writegpio 1 to the reset pin? And why setting the pin analogic can let the reset pin go back high again?

Thanks

abrinlee commented 5 years ago

Just clarifying...

The questions is why the use of PIN_ANALOGIC (Which I believe makes it an analog input pin) for the GPIO pin type instead of PIN_OUTPUT and then set back to a "1".

mluis1 commented 5 years ago

The radio reset pin has an internal pull-up. Thus, in order to avoid the MCU driving a 1 we just set the pin as input.

abrinlee commented 5 years ago

Thank you for responding. I appreciate the follow up. Close the issue.