-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is an incomplete example
- Loading branch information
Showing
12 changed files
with
273 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.pio | ||
.vscode/.browse.c_cpp.db* | ||
.vscode/c_cpp_properties.json | ||
.vscode/launch.json | ||
.vscode/ipch | ||
|
||
# ESP component registry cache | ||
managed_components/ | ||
|
||
# generated sdkconfig files | ||
sdkconfig.* | ||
!sdkconfig.defaults |
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.16.0) | ||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
# include parent folder (repo root) as a component library | ||
list(APPEND EXTRA_COMPONENT_DIRS ../../) | ||
# in user projects (external to RF24 repo), they should use `idf_component_register()` instead | ||
project(getting_started) |
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,10 @@ | ||
config RF24_CE_PIN | ||
int "The GPIO pin number used for the radio's CE pin" | ||
help | ||
If undefined, then the main app's code defaults to using pin 7. | ||
|
||
config RF24_CSN_PIN | ||
int "The GPIO pin number used for the radio's CSN pin" | ||
help | ||
If undefined, then the main app's code defaults to using pin 8. | ||
|
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,21 @@ | ||
dependencies: | ||
espressif/esp_tinyusb: | ||
component_hash: f151d680d6847bfcfd5d8eb6d1c3ff926c208e6b963b2e83643a141bc70baa15 | ||
source: | ||
service_url: https://api.components.espressif.com/ | ||
type: service | ||
version: 1.4.4 | ||
espressif/tinyusb: | ||
component_hash: 6e128177d3fe5027750a75e1ff64c655a7b53fa64eff8c1a4a8a5a4daa7924d1 | ||
source: | ||
service_url: https://api.components.espressif.com/ | ||
type: service | ||
version: 0.15.0~7 | ||
idf: | ||
component_hash: null | ||
source: | ||
type: idf | ||
version: 5.2.1 | ||
manifest_hash: 65bdfdf3ce9ef7f7d3d9c4c075a17d649adf01fa2984a9b54e4b8b493274a309 | ||
target: esp32s2 | ||
version: 1.0.0 |
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,39 @@ | ||
|
||
This directory is intended for project header files. | ||
|
||
A header file is a file containing C declarations and macro definitions | ||
to be shared between several project source files. You request the use of a | ||
header file in your project source file (C, C++, etc) located in `src` folder | ||
by including it, with the C preprocessing directive `#include'. | ||
|
||
```src/main.c | ||
|
||
#include "header.h" | ||
|
||
int main (void) | ||
{ | ||
... | ||
} | ||
``` | ||
|
||
Including a header file produces the same results as copying the header file | ||
into each source file that needs it. Such copying would be time-consuming | ||
and error-prone. With a header file, the related declarations appear | ||
in only one place. If they need to be changed, they can be changed in one | ||
place, and programs that include the header file will automatically use the | ||
new version when next recompiled. The header file eliminates the labor of | ||
finding and changing all the copies as well as the risk that a failure to | ||
find one copy will result in inconsistencies within a program. | ||
|
||
In C, the usual convention is to give header files names that end with `.h'. | ||
It is most portable to use only letters, digits, dashes, and underscores in | ||
header file names, and at most one dot. | ||
|
||
Read more about using header files in official GCC documentation: | ||
|
||
* Include Syntax | ||
* Include Operation | ||
* Once-Only Headers | ||
* Computed Includes | ||
|
||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html |
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,46 @@ | ||
|
||
This directory is intended for project specific (private) libraries. | ||
PlatformIO will compile them to static libraries and link into executable file. | ||
|
||
The source code of each library should be placed in an own separate directory | ||
("lib/your_library_name/[here are source files]"). | ||
|
||
For example, see a structure of the following two libraries `Foo` and `Bar`: | ||
|
||
|--lib | ||
| | | ||
| |--Bar | ||
| | |--docs | ||
| | |--examples | ||
| | |--src | ||
| | |- Bar.c | ||
| | |- Bar.h | ||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html | ||
| | | ||
| |--Foo | ||
| | |- Foo.c | ||
| | |- Foo.h | ||
| | | ||
| |- README --> THIS FILE | ||
| | ||
|- platformio.ini | ||
|--src | ||
|- main.c | ||
|
||
and a contents of `src/main.c`: | ||
``` | ||
#include <Foo.h> | ||
#include <Bar.h> | ||
|
||
int main (void) | ||
{ | ||
... | ||
} | ||
|
||
``` | ||
|
||
PlatformIO Library Dependency Finder will find automatically dependent | ||
libraries scanning project source files. | ||
|
||
More information about PlatformIO Library Dependency Finder | ||
- https://docs.platformio.org/page/librarymanager/ldf.html |
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,23 @@ | ||
; PlatformIO Project Configuration File | ||
; | ||
; Build options: build flags, source filter | ||
; Upload options: custom upload port, speed and extra flags | ||
; Library options: dependencies, extra library storages | ||
; Advanced options: extra scripting | ||
; | ||
; Please visit documentation for the other options and examples | ||
; https://docs.platformio.org/page/projectconf.html | ||
[env] | ||
platform = espressif32 | ||
framework = espidf | ||
|
||
[env:adafruit_qtpy_esp32s2] | ||
board = adafruit_qtpy_esp32s2 | ||
build_flags = | ||
; using A1 for CE_PIN | ||
-D CONFIG_RF24_CE_PIN=17 | ||
; using A2 for CSN_PIN | ||
-D CONFIG_RF24_CSN_PIN=9 | ||
-D CONFIG_RF24_DEFAULT_MOSI=35 | ||
-D CONFIG_RF24_DEFAULT_MISO=37 | ||
-D CONFIG_RF24_DEFAULT_SCLK=36 |
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 @@ | ||
CONFIG_TINYUSB_CDC_ENABLED=y |
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,19 @@ | ||
# This file was automatically generated for projects | ||
# without default 'CMakeLists.txt' file. | ||
|
||
FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*) | ||
|
||
idf_component_register(SRCS ${app_sources} | ||
REQUIRES RF24 | ||
# # for user projects (that don't belong in the RF24 repo), use the component registry | ||
# REQUIRES nRF24/RF24 | ||
) | ||
|
||
if(DEFINED CONFIG_RF24_CE_PIN) | ||
target_compile_definitions(main PUBLIC CE_PIN=${CONFIG_RF24_CE_PIN}) | ||
endif() | ||
|
||
if(DEFINED CONFIG_RF24_CSN_PIN) | ||
target_compile_definitions(main PUBLIC CSN_PIN=${CONFIG_RF24_CSN_PIN}) | ||
endif() | ||
|
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,4 @@ | ||
## IDF Component Manager Manifest File | ||
dependencies: | ||
espressif/esp_tinyusb: "^1" | ||
idf: "^5.0" |
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,92 @@ | ||
#include <RF24.h> | ||
#include "esp_log.h" | ||
#include "freertos/FreeRTOS.h" | ||
#include "freertos/task.h" | ||
#include "tinyusb.h" | ||
#include "tusb_cdc_acm.h" | ||
#include "tusb_console.h" | ||
#include "sdkconfig.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#ifdef CONFIG_RF24_CE_PIN | ||
#define CE_PIN CONFIG_RF24_CE_PIN | ||
#else | ||
#define CE_PIN 7 | ||
#endif | ||
|
||
#ifdef CONFIG_RF24_CSN_PIN | ||
#define CSN_PIN CONFIG_RF24_CSN_PIN | ||
#else | ||
#define CSN_PIN 8 | ||
#endif | ||
|
||
RF24 radio = RF24(CE_PIN, CSN_PIN); | ||
|
||
static const char* TAG = "RF24/examples_esp/getting_started"; | ||
|
||
void setupSerialUSB(); // See definition below | ||
|
||
void app_main(void) | ||
{ | ||
setupSerialUSB(); | ||
|
||
SPIClass spi; | ||
spi.begin(); | ||
fprintf(stdout, "SPI bus configured\n"); | ||
|
||
// if (!radio.begin(&spi)) { | ||
// while (true) { | ||
// fprintf(stdout, "radio hardware not responding!\n"); | ||
// } | ||
// } | ||
while (true) { | ||
fprintf(stdout, "radio is ready to configure.\n"); | ||
vTaskDelay(1000 / portTICK_PERIOD_MS); | ||
} | ||
} | ||
|
||
/** Setup TinyUSB for CDC serial communication */ | ||
void setupSerialUSB() | ||
{ | ||
ESP_LOGI(TAG, "USB initialization"); | ||
const tinyusb_config_t tusb_cfg = { | ||
.device_descriptor = NULL, // Use the default device descriptor specified in Menuconfig | ||
.string_descriptor = NULL, // Use the default string descriptors specified in Menuconfig | ||
.string_descriptor_count = 0, | ||
.external_phy = false, // Use internal USB PHY (in most cases) | ||
#if (TUD_OPT_HIGH_SPEED) | ||
.fs_configuration_descriptor = NULL, // Use the default full-speed configuration descriptor according to settings in Menuconfig | ||
.hs_configuration_descriptor = NULL, // Use the default high-speed configuration descriptor according to settings in Menuconfig | ||
.qualifier_descriptor = NULL, // Use the default qualifier descriptor, with values from default device descriptor | ||
#else | ||
.configuration_descriptor = NULL, // Use the default configuration descriptor according to settings in Menuconfig | ||
#endif // TUD_OPT_HIGH_SPEED | ||
.self_powered = false, | ||
.vbus_monitor_io = 0, | ||
}; | ||
ESP_ERROR_CHECK(tinyusb_driver_install(&tusb_cfg)); | ||
|
||
const tinyusb_config_cdcacm_t acm_cfg = { | ||
.usb_dev = TINYUSB_USBDEV_0, | ||
.cdc_port = TINYUSB_CDC_ACM_0, | ||
.rx_unread_buf_sz = 64, | ||
.callback_rx = NULL, | ||
.callback_rx_wanted_char = NULL, | ||
.callback_line_state_changed = NULL, | ||
.callback_line_coding_changed = NULL}; | ||
ESP_ERROR_CHECK(tusb_cdc_acm_init(&acm_cfg)); | ||
|
||
ESP_LOGI(TAG, "USB initialization DONE"); | ||
esp_tusb_init_console(TINYUSB_CDC_ACM_0); // log to usb | ||
|
||
// the delay here isn't needed, but any `abort()` called immediately after this function would | ||
// prevent the OS from seeing the USB port enumerated as a CDC Serial device | ||
vTaskDelay(1000 / portTICK_PERIOD_MS); // remove this when lib is working properly | ||
} | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
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