1#include "sx1262/sx1262.h"
25 for (started = 0; started < 0x0000FFFF; started++) {
26 int p = mculib_pin_get(nctx->mculib_handle, SX1262_BUSY);
31 printf(
"[sx1262] timeout\r\n");
35 uint8_t *data,
const uint16_t data_length) {
41 r = mculib_pin_set(nctx->mculib_handle, SX1262_CSN, 1);
42 MCULIB_ERR_RET(
"RD_CSN1", r);
45 r = mculib_pin_set(nctx->mculib_handle, SX1262_CSN, 0);
46 MCULIB_ERR_RET(
"RD_CSN0", r);
49 for (i = 0; i < command_length; i++) {
50 r = mculib_spi_write_and_read(nctx->mculib_handle, 2,
command[i], &res);
51 MCULIB_ERR_RET(
"RD_READ", r);
54 for (i = 0; i < data_length; i++) {
55 r = mculib_spi_write_and_read(nctx->mculib_handle, 2, 0, &res);
56 MCULIB_ERR_RET(
"RD_STATUS", r);
60 r = mculib_pin_set(nctx->mculib_handle, SX1262_CSN, 1);
70 r = mculib_pin_set(nctx->mculib_handle, SX1262_CSN, 1);
71 MCULIB_ERR_RET(
"WR_CSN1", r);
74 r = mculib_pin_set(nctx->mculib_handle, SX1262_CSN, 0);
75 MCULIB_ERR_RET(
"WR_CSN0", r);
78 for (i = 0; i < command_length; i++) {
79 r = mculib_spi_write_and_read(nctx->mculib_handle, 2,
command[i], &res);
80 MCULIB_ERR_RET(
"WR_WRITE", r)
84 for (i = 0; i < data_length; i++) {
85 r = mculib_spi_write_and_read(nctx->mculib_handle, 2, data[i], &res);
86 MCULIB_ERR_RET(
"WR_STATUS", r)
97 r = mculib_pin_set(nctx->mculib_handle, SX1262_CSN, 1);
103 printf(
"[sx1262] Reset called\r\n");
104 int r = mculib_pin_set(nctx->mculib_handle, SX1262_RESET, 0);
106 MCULIB_ERR_RET(
"RESET0", r);
108 r = mculib_pin_set(nctx->mculib_handle, SX1262_RESET, 1);
109 MCULIB_ERR_RET(
"RESET1", r);
115 printf(
"[sx1262] wakeup called\r\n");
116 r = mculib_pin_set(nctx->mculib_handle, SX1262_CSN, 0);
117 MCULIB_ERR_RET(
"WK_CSNSETPIN", r);
118 r = mculib_spi_write_only(nctx->mculib_handle, 2, 0);
119 MCULIB_ERR_RET(
"WK_WRITE1", r)
120 r = mculib_spi_write_only(nctx->mculib_handle, 2, 0);
121 MCULIB_ERR_RET(
"WK_WRITE2", r)
122 r = mculib_pin_set(nctx->mculib_handle, SX1262_CSN, 1);
123 MCULIB_ERR_RET(
"WK_XSN", r);
SX126x radio driver definition.
Hardware Abstraction Layer for SX126x.
sx126x_hal_status_t sx126x_hal_reset(struct network_context *nctx)
sx126x_hal_status_t sx126x_hal_wakeup(struct network_context *nctx)
sx126x_hal_status_t sx126x_hal_write(struct network_context *nctx, const uint8_t *command, const uint16_t command_length, const uint8_t *data, const uint16_t data_length)
sx126x_hal_status_t sx126x_hal_read(struct network_context *nctx, const uint8_t *command, const uint16_t command_length, uint8_t *data, const uint16_t data_length)