Skip to content

Commit

Permalink
Merge pull request #761 from kripton/kripton-rp2xxx
Browse files Browse the repository at this point in the history
Minor changes in the rp2xx howto document
  • Loading branch information
2bndy5 committed Apr 15, 2021
2 parents b909085 + 4abf8f4 commit afa3e41
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions docs/pico_sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ Follow the Raspberry Pi Foundation's
setup a proper development environment on your host PC (the machine that
will build your project).

It is important to remember that the pico-sdk repository should exist in the same directory that the RF24 repository (or your project's directory) exists.
Either set an environment variable named `PICO_SDK_PATH` that points to your
local clone of the pico-sdk or put the pico-sdk next to the `RF24` folder or
the folder containing your project using the `RF24` library:

path/to/github/repos/
pico-sdk/
RF24/

Alternatively, the RF24 repository (and optionally the RF24Network and RF24Mesh
repositories) can be included into your project's "lib" folder as copies or
git submodules. for more detail, see the below instructions to incorporate RF24 libs into your project.
git submodules. For more detail, see the below instructions to incorporate
RF24 libs into your project.

## Building the RF24 examples for the Pico SDK
1. Create a "build" directory in the RF24 repository's root directory, then navigate to
the new "build" directory.
1. Create a "build" directory in the RF24 repository's root directory and
navigate to it:
```shell
cd RF24
mkdir build
Expand Down Expand Up @@ -72,12 +75,19 @@ In order to use the RF24 libraries in your RP2040 based project:
include(../lib/RF24Mesh/CMakeLists.txt)
```
3. In the same CMakeLists.txt file from step 2, add the RF24 libraries into the
`target_link_libraries` configuration.
`target_link_libraries` configuration:
```txt
target_include_directories(target_name PRIVATE ${CMAKE_CURRENT_LIST_DIR})
target_link_libraries(${CMAKE_PROJECT_NAME}
# ... Your project's other libraries ...
RF24
RF24Network
RF24Mesh
)
```
If you are using tinyUSB, this line (or similar) should already exist:
```txt
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR})
```
Where `target_name` is specified prior to this call using
[`add_executable()`](https://cmake.org/cmake/help/latest/command/add_executable.html#command:add_executable)
4. Finally, remember to include the necessary RF24* libraries' header files in your
project's source code where applicable.
```cpp
Expand Down Expand Up @@ -125,7 +135,7 @@ void main()
To specify the default SPI pins used at build time, you can use either:
1. declare these pins in the CMakeLists.txt file
```txt
target_compile_definitions(target_name
target_compile_definitions(${CMAKE_PROJECT_NAME}
PUBLIC PICO_DEFAULT_SPI=0 # can only be 0 or 1 (as in `spi0` or `spi1`)
PUBLIC PICO_DEFAULT_SPI_SCK_PIN=2 # depends on which SPI bus (0 or 1) is being used
PUBLIC PICO_DEFAULT_SPI_TX_PIN=3 # depends on which SPI bus (0 or 1) is being used
Expand Down

0 comments on commit afa3e41

Please sign in to comment.