Browse Source

Added NRF24L01

master
Englebert 3 years ago
parent
commit
861117495c
  1. 17
      ExpressFC.h
  2. 26
      ExpressFC.ino
  3. 1
      README.md
  4. 1276
      nrf24l01.cpp
  5. 1328
      nrf24l01.h

17
ExpressFC.h

@ -3,14 +3,25 @@
#include "Motors.h"
#include "dshot.h"
#include "nrf24l01.h"
// Pin Definitions
// Pin Definitions -- BEGIN
// For Motors
#define MOTOR1 13
#define MOTOR2 12
#define MOTOR3 14
#define MOTOR4 27
#define LED_BUILTIN 2
// For NRF24L01 receiver
#define CSN_PIN 4
// Pin Definitions -- END
// Default Core Settings
#define CORE0 0
#define CORE1 1
#define MAX_PRIORITIES 25
// Task scheduler
#if CONFIG_FREERTOS_UNICORE
@ -23,6 +34,6 @@ extern uint32_t last_dshot;
// Task Definition
void taskMotor(void *pvParameters);
void taskBlink(void *pvParameters);
// void taskBlink(void *pvParameters);
#endif

26
ExpressFC.ino

@ -38,7 +38,7 @@ void setup() {
// Delay for a while to let the CPU settle down
delay(10);
pinMode(LED_BUILTIN, OUTPUT);
// pinMode(LED_BUILTIN, OUTPUT);
// Serial.print(F("Initializing Motors: "));
// Initialize motors
@ -57,9 +57,10 @@ void setup() {
NULL,
2, // Priority. With 3 (configMAX_PRIORITIES - 1) being the highest and 0 being the lowest.
NULL,
ARDUINO_RUNNING_CORE
CORE0
);
/***
xTaskCreatePinnedToCore(
taskBlink,
"TaskBlink", // Name of the process
@ -67,8 +68,9 @@ void setup() {
NULL,
1, // Priority. With 3 (configMAX_PRIORITIES - 1) being the highest and 0 being the lowest.
NULL,
ARDUINO_RUNNING_CORE
CORE0
);
***/
}
void loop() {
@ -140,10 +142,10 @@ void loop() {
// delay(100);
}
void taskMotor(void *pvParameters) {
(void) pvParameters;
uint32_t counter = 0;
for(;;) {
/***
motors.write_motor(MOTOR1, 1046);
@ -151,12 +153,17 @@ void taskMotor(void *pvParameters) {
motors.write_motor(MOTOR3, 1146);
motors.write_motor(MOTOR4, 1246);
***/
motors.write_motor(1046, 1346, 1146, 2040);
//motors.write_motor(1046, 1046, 1046, 1046);
vTaskDelay(1);
counter++;
if(!(counter % 10)) {
motors.write_motor(1046, 1346, 1146, 2040);
} else {
//motors.write_motor(1046, 1046, 1046, 1046);
vTaskDelay(1);
}
}
}
/****
void taskBlink(void *pvParameters) {
(void) pvParameters;
@ -169,3 +176,8 @@ void taskBlink(void *pvParameters) {
vTaskDelay(10);
}
}
void delay(uint32_t ms) {
vTaskDelay(ms / portTICK_PERIOD_MS);
}
****/

1
README.md

@ -276,3 +276,4 @@ ESP32 CLOCKs:
REF:
- https://brushlesswhoop.com/dshot-and-bidirectional-dshot/
- https://github.com/espressif/arduino-esp32/blob/master/libraries/ESP32/examples/FreeRTOS/FreeRTOS.ino (TRY THIS)
- https://www.digikey.at/en/maker/projects/introduction-to-rtos-solution-to-part-12-multicore-systems/369936f5671d4207a2c954c0637e7d50

1276
nrf24l01.cpp
File diff suppressed because it is too large
View File

1328
nrf24l01.h
File diff suppressed because it is too large
View File

Loading…
Cancel
Save