forked from QuantumLeaps/qpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DPP example running on ESP32 DevKitC board
- Loading branch information
Showing
13 changed files
with
2,649 additions
and
19 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,6 @@ | ||
# The following five lines of boilerplate have to be in your project's | ||
# CMakeLists in this exact order for cmake to work correctly | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
project(dpp-esp32devkitc) |
32 changes: 32 additions & 0 deletions
32
examples/esp-idf/dpp-esp32devkitc/components/qp-c/CMakeLists.txt
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,32 @@ | ||
# ------------------------------------------------------------ | ||
# register component | ||
# ------------------------------------------------------------ | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
set(required_modules "freertos") | ||
|
||
set(qpc_path "../../../../../") | ||
|
||
set(src_dirs ${qpc_path}/ports/esp-idf | ||
${qpc_path}/src/qf | ||
${qpc_path}/include | ||
) | ||
|
||
set(include_dirs ${qpc_path}/include | ||
${qpc_path}ports/esp-idf | ||
${qpc_path}/src | ||
) | ||
|
||
if(CONFIG_QPC_QSPY_ENABLE) | ||
list(APPEND src_dirs ${qpc_path}/src/qs) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DQ_SPY") | ||
endif() | ||
|
||
idf_component_register( | ||
SRC_DIRS ${src_dirs} | ||
# exclude qf_actq.c because esp-idf port is using message queues; see note in qpc/doxygen/dir.dox | ||
EXCLUDE_SRCS ${qpc_path}/src/qf/qf_actq.c | ||
INCLUDE_DIRS ${include_dirs} | ||
PRIV_REQUIRES ${required_modules} | ||
) | ||
|
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,59 @@ | ||
menu "QP/C Real-Time Embedded Framework" | ||
config QP_ENABLED | ||
bool "QP/C Real-Time Embedded Framework" | ||
default y | ||
help | ||
Select this option to enable QPC Framework | ||
|
||
menu "QP/C Configuration" | ||
visible if QP_ENABLED | ||
choice QPC_PINNED_TO_CORE_CHOICE | ||
prompt "The cpu core which QPC run" | ||
depends on !FREERTOS_UNICORE | ||
default QPC_PINNED_TO_CORE_1 | ||
help | ||
Specify the cpu core to run QPC. | ||
config QPC_PINNED_TO_CORE_0 | ||
bool "Core 0 (PRO CPU)" | ||
config QPC_PINNED_TO_CORE_1 | ||
bool "Core 1 (APP CPU)" | ||
config QPC_NO_CORE_AFFINITY | ||
bool "No Affinity (PRO or APP CPU)" | ||
endchoice #QPC_PINNED_TO_CORE_CHOICE | ||
|
||
menu "Event Memory Pool" | ||
visible if QP_ENABLED | ||
config QPC_SMALL_POOL_SIZE | ||
int "Small Memory Pool Size" | ||
range 16 512 | ||
default 32 | ||
help | ||
Max number of events in a small memory pool | ||
config QPC_MEDIUM_POOL_SIZE | ||
int "Medium Memory Pool Size" | ||
range 16 512 | ||
default 32 | ||
help | ||
Max number of events in a medium memory pool | ||
config QPC_MEDIUM_POOL_ENTRY_SIZE | ||
int "Medium Memory Pool Entry Size" | ||
default 16 | ||
config QPC_LARGE_POOL_SIZE | ||
int "Large Memory Pool Size" | ||
range 16 512 | ||
default 32 | ||
help | ||
Max number of events in a large memory pool | ||
config QPC_LARGE_POOL_ENTRY_SIZE | ||
int "Large Memory Pool Entry Size" | ||
default 32 | ||
|
||
endmenu #"Event Memory Pool" | ||
|
||
endmenu #QPC Configuration | ||
|
||
config QPC_QSPY_ENABLE | ||
bool "Enable QSpy" | ||
default n | ||
|
||
endmenu |
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,2 @@ | ||
idf_component_register(SRC_DIRS . | ||
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,38 @@ | ||
#include "qpc.h" | ||
#include "qf_port.h" | ||
#include "esp_log.h" | ||
#include "esp_freertos_hooks.h" | ||
|
||
static const char * TAG = "bsp"; | ||
|
||
int_t qf_run_active = 0; | ||
|
||
static IRAM_ATTR void freertos_tick_hook(void) | ||
{ | ||
BaseType_t xHigherPriorityTaskWoken = pdFALSE; | ||
if(qf_run_active != 0) { | ||
/* process time events for rate 0 */ | ||
QTIMEEVT_TICK_FROM_ISR(0U, &xHigherPriorityTaskWoken, &freertos_tick_hook); | ||
/* notify FreeRTOS to perform context switch from ISR, if needed */ | ||
if(xHigherPriorityTaskWoken) { | ||
portYIELD_FROM_ISR(); | ||
} | ||
} | ||
} | ||
|
||
void QF_onStartup(void) | ||
{ | ||
esp_register_freertos_tick_hook_for_cpu(freertos_tick_hook, QPC_CPU_NUM); | ||
|
||
/* enable QF ticks from tick hook */ | ||
qf_run_active = 100; | ||
|
||
ESP_LOGI(TAG, "QF started."); | ||
|
||
/* Note: Additional hook stuff can be placed here */ | ||
} | ||
|
||
IRAM_ATTR void Q_onAssert(char_t const * const module, int_t location) | ||
{ | ||
ESP_LOGE(TAG, "Q_onAssert: module:%s loc:%d\n", module, location); | ||
} |
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,65 @@ | ||
/*.$file${.::dpp.h} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ | ||
/* | ||
* Model: dpp.qm | ||
* File: ${.::dpp.h} | ||
* | ||
* This code has been generated by QM 5.1.3 <www.state-machine.com/qm/>. | ||
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost. | ||
* | ||
* This program is open source software: you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License as published | ||
* by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* for more details. | ||
*/ | ||
/*.$endhead${.::dpp.h} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ | ||
#ifndef DPP_H | ||
#define DPP_H | ||
|
||
enum DPPSignals { | ||
EAT_SIG = Q_USER_SIG, /* published by Table to let a philosopher eat */ | ||
DONE_SIG, /* published by Philosopher when done eating */ | ||
PAUSE_SIG, /* published by BSP to pause serving forks */ | ||
SERVE_SIG, /* published by BSP to serve re-start serving forks */ | ||
TEST_SIG, /* published by BSP to test the application */ | ||
MAX_PUB_SIG, /* the last published signal */ | ||
|
||
HUNGRY_SIG, /* posted direclty to Table from hungry Philo */ | ||
TIMEOUT_SIG, /* used by Philosophers for time events */ | ||
MAX_SIG /* the last signal */ | ||
}; | ||
|
||
/*.$declare${Events::TableEvt} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ | ||
/*.${Events::TableEvt} .....................................................*/ | ||
typedef struct { | ||
/* protected: */ | ||
QEvt super; | ||
|
||
/* public: */ | ||
uint8_t philoNum; | ||
} TableEvt; | ||
/*.$enddecl${Events::TableEvt} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ | ||
|
||
/* number of philosophers */ | ||
#define N_PHILO ((uint8_t)5) | ||
|
||
/*.$declare${AOs::Philo_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ | ||
/*.${AOs::Philo_ctor} ......................................................*/ | ||
void Philo_ctor(void); | ||
/*.$enddecl${AOs::Philo_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ | ||
/*.$declare${AOs::AO_Philo[N_PHILO]} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ | ||
extern QActive * const AO_Philo[N_PHILO]; | ||
/*.$enddecl${AOs::AO_Philo[N_PHILO]} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ | ||
|
||
/*.$declare${AOs::Table_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ | ||
/*.${AOs::Table_ctor} ......................................................*/ | ||
void Table_ctor(void); | ||
/*.$enddecl${AOs::Table_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ | ||
/*.$declare${AOs::AO_Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ | ||
extern QActive * const AO_Table; | ||
/*.$enddecl${AOs::AO_Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ | ||
|
||
#endif /* DPP_H */ |
Oops, something went wrong.