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

Merge updates from pinedio #44

Merged
merged 6 commits into from
May 9, 2022
Merged
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
32 changes: 30 additions & 2 deletions examples/spi_test2/spi_test2_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@

#include <nuttx/ioexpander/gpio.h>

/* Define the SPI Test Driver for SX1262. (Not the regular SPI Driver) */

#ifdef CONFIG_LIBSX1262_SPI_DEVPATH
#define SPI_DEVPATH CONFIG_LIBSX1262_SPI_DEVPATH
#else
#define SPI_DEVPATH "/dev/spitest0"
#endif /* CONFIG_LIBSX1262_SPI_DEVPATH */

/* Define the GPIO for SX1262 Chip Select */

#ifdef CONFIG_LIBSX1262_CS_DEVPATH
#define CS_DEVPATH CONFIG_LIBSX1262_CS_DEVPATH
#else
#define CS_DEVPATH "/dev/gpio1"
#endif /* CONFIG_LIBSX1262_CS_DEVPATH */

/****************************************************************************
* Public Functions
****************************************************************************/
Expand All @@ -43,12 +59,12 @@ int main(int argc, FAR char *argv[])
{
/* Open GPIO Output for SPI Chip Select */

int cs = open("/dev/gpio1", O_RDWR);
int cs = open(CS_DEVPATH, O_RDWR);
assert(cs >= 0);

/* Open SPI Test Driver */

int fd = open("/dev/spitest0", O_RDWR);
int fd = open(SPI_DEVPATH, O_RDWR);
assert(fd >= 0);

/* Set SPI Chip Select to Low */
Expand Down Expand Up @@ -116,6 +132,17 @@ int main(int argc, FAR char *argv[])
}
printf("\nSX1262 Register 8 is 0x%02x\n", rx_data[4]);

/* Register 8 should be 0x80 */

if (rx_data[4] == 0x80)
{
printf("SX1262 is OK\n");
}
else
{
printf("***** ERROR: SX1262 is NOT OK! Check SPI connection\n");
}

/* Close SPI Test Driver */

close(fd);
Expand Down Expand Up @@ -171,5 +198,6 @@ gpout_write: Writing 1
Read Register 8: received
a8 a8 a8 a8 80
SX1262 Register 8 is 0x80
SX1262 is OK
spi_test_driver_close:
*/