-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API for low-level register manipulation
+ corresponding example
- Loading branch information
1 parent
b8b3888
commit 3f575c2
Showing
6 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
set(EXTRA_COMPONENT_DIRS "../../") | ||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
project(sx127x_lowlevel) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
idf_component_register(SRCS "main.c" INCLUDE_DIRS "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include <driver/spi_common.h> | ||
#include <driver/spi_master.h> | ||
#include <esp_log.h> | ||
#include <sx127x.h> | ||
#include <sx127x_registers.h> | ||
|
||
// TTGO lora32 v2.1 1.6.1 | ||
#define SCK 5 | ||
#define MISO 19 | ||
#define MOSI 27 | ||
#define SS 18 | ||
#define RST 23 | ||
#define DIO0 26 | ||
// older versions of TTGO require manual wiring of pins below | ||
#define DIO1 33 | ||
#define DIO2 32 | ||
|
||
// Heltec lora32 v2 | ||
// #define DIO1 35 | ||
// #define DIO2 34 | ||
|
||
static const char *TAG = "sx127x"; | ||
|
||
sx127x device; | ||
|
||
void app_main() { | ||
ESP_LOGI(TAG, "starting up"); | ||
spi_bus_config_t config = { | ||
.mosi_io_num = MOSI, | ||
.miso_io_num = MISO, | ||
.sclk_io_num = SCK, | ||
.quadwp_io_num = -1, | ||
.quadhd_io_num = -1, | ||
.max_transfer_sz = 0, | ||
}; | ||
ESP_ERROR_CHECK(spi_bus_initialize(SPI2_HOST, &config, 1)); | ||
spi_device_interface_config_t dev_cfg = { | ||
.clock_speed_hz = 4E6, | ||
.spics_io_num = SS, | ||
.queue_size = 16, | ||
.command_bits = 0, | ||
.address_bits = 8, | ||
.dummy_bits = 0, | ||
.mode = 0}; | ||
spi_device_handle_t spi_device; | ||
ESP_ERROR_CHECK(spi_bus_add_device(SPI2_HOST, &dev_cfg, &spi_device)); | ||
ESP_ERROR_CHECK(sx127x_create(spi_device, &device)); | ||
|
||
uint8_t value = 0b01100111; | ||
ESP_ERROR_CHECK(sx127x_write_register(REGINVERTIQ, value, &device.spi_device)); | ||
printf("written: %d\n", value); | ||
uint8_t written = 0; | ||
ESP_ERROR_CHECK(sx127x_read_register(REGINVERTIQ, &device.spi_device, &written)); | ||
printf("read: %d\n", written); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters