Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: read chip status check reset success #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/driver_sx1268.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ uint8_t sx1268_init(sx1268_handle_t *handle)

return 6; /* return error */
}
handle->delay_ms(5); /* delay 5 ms */
handle->delay_ms(1); /* delay 5 ms */
if (handle->reset_gpio_write(0) != 0) /* set low */
{
handle->debug_print("sx1268: reset chip failed.\n"); /* reset chip failed */
Expand All @@ -701,7 +701,7 @@ uint8_t sx1268_init(sx1268_handle_t *handle)

return 6; /* return error */
}
handle->delay_ms(10); /* delay 5 ms */
handle->delay_ms(1); /* delay 5 ms */
if (handle->reset_gpio_write(1) != 0) /* set high */
{
handle->debug_print("sx1268: reset chip failed.\n"); /* reset chip failed */
Expand All @@ -722,16 +722,17 @@ uint8_t sx1268_init(sx1268_handle_t *handle)

return 6; /* return error */
}
prev = 0x00;
if (a_sx1268_spi_write(handle, SX1268_COMMAND_SET_STANDBY, (uint8_t *)&prev, 1) != 0) /* write command */

if(buf[0] & SX1268_CHIP_MODE_MASK != SX1268_CHIP_MODE_STDBY_RC)
{
handle->debug_print("sx1268: set standby failed.\n"); /* set standby failed */
handle->debug_print("sx1268: reset failed.\n"); /* reset failed */
(void)handle->spi_deinit(); /* spi deinit */
(void)handle->reset_gpio_deinit(); /* reset gpio deinit */
(void)handle->busy_gpio_deinit(); /* busy gpio deinit */

return 6; /* return error */
return 7; /* return error */
}

handle->inited = 1; /* flag finish initialization */

return 0; /* success return 0 */
Expand Down
12 changes: 12 additions & 0 deletions src/driver_sx1268.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ extern "C"{
* @{
*/

/**
* @brief sx1268 chip mode mask definition
*
*/
#define SX1268_CHIP_MODE_MASK 0xF0

/**
* @brief sx1268 chip mode definition
*
*/
#define SX1268_CHIP_MODE_STDBY_RC 0x20

/**
* @brief sx1268 bool enumeration definition
*/
Expand Down