-
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.
- ran clang-format - conforms to utility/template - create how-to doc (w/ pics) - CMake support mimics PicoSDK implementation
- Loading branch information
Showing
18 changed files
with
347 additions
and
272 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 was deleted.
Oops, something went wrong.
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
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,48 @@ | ||
# Using RF24 in the STM32Cube IDE | ||
|
||
The RF24 library can be integrated with any STM32Cube project. | ||
|
||
## Required Hardware | ||
|
||
The nRF24L01 radio requires 1 SPI bus and 2 GPIO pins for minimal usage. If using the radio's IRQ pin, then that will require an additional GPIO pin. | ||
|
||
You can use the IDE set up the necessary GPIO/SPI pins and have the IDE automatically generate the code to initialize the resources. | ||
|
||
The RF24 libaray manages the CSN pin without using the STM32HAL features. When setting up the SPI bus, there's no need to use the chips reserved CS pin associated with the selected SPI bus. The RF24 library allows using any GPIO output pin. | ||
|
||
## Basic Project Setup | ||
|
||
To integrate the RF24 library code into your STM32Cube project, follow these steps: | ||
|
||
1. Create a copy of the library in your project's "Drivers" directory. | ||
2. Exclude all sub-directories except "STM32" in the RF24/utility/ directory. | ||
3. Open your project's settings and add 2 symbols. | ||
1. right-click the project's root folder and select properties. | ||
![select project properties](../images/STM32Cube-project-properties.png) | ||
2. In the "C/C++ General" -> "Paths and Symbols" from the side menu. | ||
![select path and symbols](../images/STM32Cube-project-path-symbols.png) | ||
3. Select the "Symbols" tab in the main portion of the properties dialogue. | ||
![select symbols](../images/STM32Cube-project-symbols.png) | ||
4. Add the following variables (case-sensitive) to both "GNU C" and "GNU C++" categories: | ||
- `STM32` (used by RF24_arch_config.h and RF24.cpp) | ||
- `STM32yx` where `yx` describes the family of the desired STM32 chip. | ||
For example: | ||
|
||
- If using an STM32F103 chip, then set a variable named `STM32F1` | ||
- If using an STM32F411 chip, then set a variable named `STM32F4` | ||
|
||
![add symbols](../images/STM32Cube-language-symbols.png) | ||
4. Now you can use the RF24 library anywhere in your project like so: | ||
|
||
```cpp | ||
#include "RF24.h" | ||
|
||
RF24 radio = RF24(GPIO_PIN_3, GPIO_PIN_4); | ||
if (!radio.begin()) { | ||
return 1; // failed to init radio hardware | ||
} | ||
``` | ||
|
||
## Using multiple SPI buses | ||
|
||
TODO |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,27 @@ | ||
# # Include this file if you want to use the RF24 library | ||
# # in YOUR (STM32Cube) project. | ||
# # NOTE: This is preliminary support for CMake (which is not typically used in STM32Cube IDE) | ||
|
||
cmake_minimum_required(VERSION 3.12) | ||
|
||
set(CMAKE_C_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
add_library(rf24 INTERFACE | ||
../../RF24.cpp | ||
${CMAKE_CURRENT_LIST_DIR}/RF24_arch_config.h | ||
${CMAKE_CURRENT_LIST_DIR}/spi.cpp | ||
${CMAKE_CURRENT_LIST_DIR}/gpio.cpp | ||
${CMAKE_CURRENT_LIST_DIR}/compatibility.cpp | ||
) | ||
|
||
# STM32_ARCH option set in RF24/CMakeLists.txt | ||
target_compile_definitions(rf24 PUBLIC -DSTM32 -D${STM32_ARCH}) | ||
|
||
# STM32CubeHalIncludes array/variable set in the project's CMakeLists.txt | ||
target_include_directories(rf24 PRIVATE . ${STM32CubeHalIncludes} ../Core/Inc) | ||
|
||
target_compile_options(rf24 PRIVATE -Ofast) | ||
|
||
# STM32CubeHal library discovery in project's CMakeLists.txt | ||
target_link_libraries(rf24 PRIVATE STM32CubeHal) |
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,14 @@ | ||
#include "compatibility.h" | ||
|
||
uint32_t rf24_get_time_us() | ||
{ | ||
return 1000 * HAL_GetTick() + 1000 - (SysTick->VAL / (SystemCoreClock / 1000000)); | ||
}; | ||
|
||
void __usleep(int32_t usecs) | ||
{ | ||
uint32_t now = rf24_get_time_us(); | ||
uint32_t blocked_until = now + usecs; | ||
while (blocked_until > rf24_get_time_us()) { | ||
} | ||
}; |
Oops, something went wrong.