commit
b7980537dc
@ -48,9 +48,9 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/freertos}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/freertos/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/common}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/master}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/peripherals}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/FreeRTOSCPP}""/>
|
||||
</option>
|
||||
<option id="com.crt.advproject.cpp.misc.dialect.4036734" name="Language standard" superClass="com.crt.advproject.cpp.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.cpp17" valueType="enumerated"/>
|
||||
<inputType id="com.crt.advproject.compiler.cpp.input.2005422649" superClass="com.crt.advproject.compiler.cpp.input"/>
|
||||
@ -79,9 +79,9 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/freertos}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/freertos/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/common}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/master}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/peripherals}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/FreeRTOSCPP}""/>
|
||||
</option>
|
||||
<option id="com.crt.advproject.c.misc.dialect.82852045" name="Language standard" superClass="com.crt.advproject.c.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c17" valueType="enumerated"/>
|
||||
<inputType id="com.crt.advproject.compiler.input.765511076" superClass="com.crt.advproject.compiler.input"/>
|
||||
@ -98,9 +98,9 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/freertos}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/freertos/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/common}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/master}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/peripherals}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/FreeRTOSCPP}""/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1836378919" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
<inputType id="com.crt.advproject.assembler.input.339410672" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
|
||||
@ -197,6 +197,7 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/master}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/peripherals}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/FreeRTOSCPP}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/common}""/>
|
||||
</option>
|
||||
<inputType id="com.crt.advproject.compiler.cpp.input.903614193" superClass="com.crt.advproject.compiler.cpp.input"/>
|
||||
</tool>
|
||||
@ -225,6 +226,7 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/master}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/peripherals}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/FreeRTOSCPP}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/common}""/>
|
||||
</option>
|
||||
<option id="com.crt.advproject.c.misc.dialect.1008527937" name="Language standard" superClass="com.crt.advproject.c.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c17" valueType="enumerated"/>
|
||||
<inputType id="com.crt.advproject.compiler.input.246185412" superClass="com.crt.advproject.compiler.input"/>
|
||||
@ -244,6 +246,7 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/master}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/peripherals}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/FreeRTOSCPP}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/common}""/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1117166373" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
<inputType id="com.crt.advproject.assembler.input.2071009798" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
|
||||
@ -331,7 +334,14 @@
|
||||
<boardId>LPCXpresso11U68</boardId>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
<storageModule moduleId="refreshScope"/>
|
||||
<storageModule moduleId="refreshScope" versionNumber="2">
|
||||
<configuration configurationName="Debug">
|
||||
<resource resourceType="PROJECT" workspacePath="/shoh"/>
|
||||
</configuration>
|
||||
<configuration configurationName="Release">
|
||||
<resource resourceType="PROJECT" workspacePath="/shoh"/>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="com.crt.advproject.config.exe.debug.401943083;com.crt.advproject.config.exe.debug.401943083.;com.crt.advproject.gas.exe.debug.1514460309;com.crt.advproject.assembler.input.339410672">
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include <cr_section_macros.h>
|
||||
#include "common/ThreadCommon.h"
|
||||
#include "ThreadCommon.h"
|
||||
#include "Master.h"
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ int main(void)
|
||||
ThreadCommon::QueueManager* qmanager = new ThreadCommon::QueueManager;
|
||||
//Creating queues
|
||||
qmanager->createQueue(100,
|
||||
sizeof(ThreadCommon::Event),
|
||||
sizeof(Event),
|
||||
ThreadCommon::QueueManager::master_event_all);
|
||||
|
||||
//Creating tasks
|
||||
@ -24,10 +24,9 @@ int main(void)
|
||||
static_cast<void*>(qmanager));
|
||||
|
||||
//<Queue_test>
|
||||
QueueHandle_t master_event_all_q = qmanager->getQueue(ThreadCommon::QueueManager::master_event_all);
|
||||
ThreadCommon::Event* e = new ThreadCommon::Event(ThreadCommon::Rotary, 1);
|
||||
Event* e = new Event(Event::Rotary, 1);
|
||||
|
||||
qmanager->send<ThreadCommon::Event>(ThreadCommon::QueueManager::master_event_all, e, 1000);
|
||||
qmanager->send<Event>(ThreadCommon::QueueManager::master_event_all, e, 1000);
|
||||
//</Queue_test>
|
||||
|
||||
// Start the real time kernel with preemption.
|
||||
|
||||
55
source/shoh/src/threads/common/Event.h
Normal file
55
source/shoh/src/threads/common/Event.h
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Event.h
|
||||
*
|
||||
* Created on: 26 Apr 2023
|
||||
* Author: tylen
|
||||
*/
|
||||
|
||||
#ifndef THREADS_COMMON_EVENT_H_
|
||||
#define THREADS_COMMON_EVENT_H_
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
typedef short int EventRawData;
|
||||
const EventRawData ERROR_RETURN = -999;
|
||||
|
||||
class Event
|
||||
{
|
||||
public:
|
||||
enum EventType
|
||||
{
|
||||
Null,
|
||||
Rotary,
|
||||
InternalTemp,
|
||||
ExternalTemp,
|
||||
SetPoint
|
||||
};
|
||||
|
||||
Event(Event::EventType type, EventRawData data)
|
||||
{
|
||||
events.insert({type, data});
|
||||
}
|
||||
|
||||
void inline addData(Event::EventType type, EventRawData data)
|
||||
{
|
||||
const auto pos = events.find(type);
|
||||
// No duplicates
|
||||
if (pos == events.end())
|
||||
events.insert({type, data});
|
||||
}
|
||||
|
||||
EventRawData getDataOf(Event::EventType e) const
|
||||
{
|
||||
const auto pos = events.find(e);
|
||||
if (pos == events.end())
|
||||
return ERROR_RETURN;
|
||||
return pos->second;
|
||||
}
|
||||
|
||||
private:
|
||||
std::map <Event::EventType, EventRawData> events;
|
||||
};
|
||||
|
||||
|
||||
#endif /* THREADS_COMMON_EVENT_H_ */
|
||||
@ -18,38 +18,6 @@
|
||||
|
||||
namespace ThreadCommon
|
||||
{
|
||||
typedef enum EventType
|
||||
{
|
||||
Null,
|
||||
Rotary,
|
||||
Temperature,
|
||||
Manager
|
||||
};
|
||||
|
||||
class Event
|
||||
{
|
||||
public:
|
||||
Event(ThreadCommon::EventType type, uint8_t data)
|
||||
{
|
||||
_type = type;
|
||||
_data = data;
|
||||
}
|
||||
|
||||
ThreadCommon::EventType getType() const
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
uint8_t getData() const
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
private:
|
||||
ThreadCommon::EventType _type;
|
||||
uint8_t _data;
|
||||
};
|
||||
|
||||
class ThreadManager
|
||||
{
|
||||
public:
|
||||
|
||||
@ -13,12 +13,12 @@ Master::Master(ThreadCommon::QueueManager* qm) : _qm(qm)
|
||||
}
|
||||
|
||||
void Master::taskFunction() {
|
||||
ThreadCommon::Event data(ThreadCommon::Null, 0);
|
||||
Event data(Event::Null, 0);
|
||||
int led = 0;
|
||||
bool LedState = true;
|
||||
for (;;) {
|
||||
_qm->receive<ThreadCommon::Event>(ThreadCommon::QueueManager::master_event_all, &data, portMAX_DELAY);
|
||||
if(data.getData() == 1 && data.getType() == ThreadCommon::EventType::Rotary){
|
||||
_qm->receive<Event>(ThreadCommon::QueueManager::master_event_all, &data, portMAX_DELAY);
|
||||
if(data.getDataOf(Event::Rotary) == 1){
|
||||
Board_LED_Set(led, LedState);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,8 @@
|
||||
|
||||
#include "chip.h"
|
||||
#include "board.h"
|
||||
#include "threads/common/ThreadCommon.h"
|
||||
#include "ThreadCommon.h"
|
||||
#include "Event.h"
|
||||
#include "task.h"
|
||||
#include <string>
|
||||
|
||||
@ -23,7 +24,7 @@ public:
|
||||
//Master(Master&&) noexcept = default;
|
||||
//Master& operator=(Master&&) noexcept = default;
|
||||
private:
|
||||
ThreadCommon::Event* message;
|
||||
Event* message;
|
||||
ThreadCommon::QueueManager* _qm;
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user