rotary: init task [#9]
This commit is contained in:
parent
e4885adbc9
commit
809358b341
@ -50,6 +50,7 @@
|
||||
<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:/${ProjName}/src/threads/rotary}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/peripherals}""/>
|
||||
</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"/>
|
||||
@ -303,31 +304,31 @@
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="com.crt.config">
|
||||
<projectStorage><?xml version="1.0" encoding="UTF-8"?>
|
||||
<TargetConfig>
|
||||
<Properties property_2="LPC11U6x_256K.cfx" property_3="NXP" property_4="LPC11U68" property_count="5" version="100300"/>
|
||||
<infoList vendor="NXP">
|
||||
<info chip="LPC11U68" flash_driver="LPC11U6x_256K.cfx" match_id="0x0" name="LPC11U68" stub="crt_emu_cm3_gen">
|
||||
<chip>
|
||||
<name>LPC11U68</name>
|
||||
<family>LPC11U6x</family>
|
||||
<vendor>NXP (formerly Philips)</vendor>
|
||||
<reset board="None" core="Real" sys="Real"/>
|
||||
<clock changeable="TRUE" freq="12MHz" is_accurate="TRUE"/>
|
||||
<memory can_program="true" id="Flash" is_ro="true" type="Flash"/>
|
||||
<memory id="RAM" type="RAM"/>
|
||||
<memory id="Periph" is_volatile="true" type="Peripheral"/>
|
||||
<memoryInstance derived_from="Flash" id="MFlash256" location="0x0" size="0x40000"/>
|
||||
<memoryInstance derived_from="RAM" id="Ram0_32" location="0x10000000" size="0x8000"/>
|
||||
<memoryInstance derived_from="RAM" id="Ram1_2" location="0x20000000" size="0x800"/>
|
||||
<memoryInstance derived_from="RAM" id="Ram2USB_2" location="0x20004000" size="0x800"/>
|
||||
</chip>
|
||||
<processor>
|
||||
<name gcc_name="cortex-m0">Cortex-M0</name>
|
||||
<family>Cortex-M</family>
|
||||
</processor>
|
||||
</info>
|
||||
</infoList>
|
||||
<projectStorage><?xml version="1.0" encoding="UTF-8"?>
|
||||
<TargetConfig>
|
||||
<Properties property_2="LPC11U6x_256K.cfx" property_3="NXP" property_4="LPC11U68" property_count="5" version="100300"/>
|
||||
<infoList vendor="NXP">
|
||||
<info chip="LPC11U68" flash_driver="LPC11U6x_256K.cfx" match_id="0x0" name="LPC11U68" stub="crt_emu_cm3_gen">
|
||||
<chip>
|
||||
<name>LPC11U68</name>
|
||||
<family>LPC11U6x</family>
|
||||
<vendor>NXP (formerly Philips)</vendor>
|
||||
<reset board="None" core="Real" sys="Real"/>
|
||||
<clock changeable="TRUE" freq="12MHz" is_accurate="TRUE"/>
|
||||
<memory can_program="true" id="Flash" is_ro="true" type="Flash"/>
|
||||
<memory id="RAM" type="RAM"/>
|
||||
<memory id="Periph" is_volatile="true" type="Peripheral"/>
|
||||
<memoryInstance derived_from="Flash" id="MFlash256" location="0x0" size="0x40000"/>
|
||||
<memoryInstance derived_from="RAM" id="Ram0_32" location="0x10000000" size="0x8000"/>
|
||||
<memoryInstance derived_from="RAM" id="Ram1_2" location="0x20000000" size="0x800"/>
|
||||
<memoryInstance derived_from="RAM" id="Ram2USB_2" location="0x20004000" size="0x800"/>
|
||||
</chip>
|
||||
<processor>
|
||||
<name gcc_name="cortex-m0">Cortex-M0</name>
|
||||
<family>Cortex-M</family>
|
||||
</processor>
|
||||
</info>
|
||||
</infoList>
|
||||
</TargetConfig></projectStorage>
|
||||
</storageModule>
|
||||
<storageModule moduleId="com.crt.advproject">
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
#include <cr_section_macros.h>
|
||||
#include "ThreadCommon.h"
|
||||
#include "Master.h"
|
||||
#include "Rotary.h"
|
||||
|
||||
|
||||
int main(void)
|
||||
@ -17,20 +18,15 @@ int main(void)
|
||||
qmanager->createQueue(100,
|
||||
sizeof(Event),
|
||||
ThreadCommon::QueueManager::master_event_all);
|
||||
|
||||
//Creating tasks
|
||||
manager->createTask(master_thread, "master",
|
||||
configMINIMAL_STACK_SIZE * 10,tskIDLE_PRIORITY + 1UL,
|
||||
static_cast<void*>(qmanager));
|
||||
|
||||
//<Queue_test>
|
||||
Event* e = new Event(Event::Rotary, 1);
|
||||
|
||||
qmanager->send<Event>(ThreadCommon::QueueManager::master_event_all, e, 1000);
|
||||
//</Queue_test>
|
||||
configMINIMAL_STACK_SIZE * 10,tskIDLE_PRIORITY + 1UL,
|
||||
static_cast<void*>(qmanager));
|
||||
manager->createTask(rotary_thread, "rotary",
|
||||
configMINIMAL_STACK_SIZE * 10,tskIDLE_PRIORITY + 1UL,
|
||||
static_cast<void*>(qmanager));
|
||||
|
||||
// Start the real time kernel with preemption.
|
||||
//FreeRTOS::Kernel::startScheduler();
|
||||
vTaskStartScheduler ();
|
||||
|
||||
return 1;
|
||||
|
||||
@ -18,6 +18,13 @@
|
||||
|
||||
namespace ThreadCommon
|
||||
{
|
||||
enum RotaryAction
|
||||
{
|
||||
Right,
|
||||
Left,
|
||||
Press,
|
||||
Idle
|
||||
};
|
||||
class ThreadManager
|
||||
{
|
||||
public:
|
||||
|
||||
@ -18,7 +18,7 @@ void Master::taskFunction() {
|
||||
bool LedState = true;
|
||||
for (;;) {
|
||||
_qm->receive<Event>(ThreadCommon::QueueManager::master_event_all, &data, portMAX_DELAY);
|
||||
if(data.getDataOf(Event::Rotary) == 1){
|
||||
if(data.getDataOf(Event::Rotary) == ThreadCommon::RotaryAction::Idle){
|
||||
Board_LED_Set(led, LedState);
|
||||
}
|
||||
}
|
||||
|
||||
26
source/shoh/src/threads/rotary/Rotary.cpp
Normal file
26
source/shoh/src/threads/rotary/Rotary.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Rotary.cpp
|
||||
*
|
||||
* Created on: 26 Apr 2023
|
||||
* Author: tylen
|
||||
*/
|
||||
|
||||
#include "Rotary.h"
|
||||
|
||||
Rotary::Rotary(ThreadCommon::QueueManager* qm) : _qm(qm) {}
|
||||
|
||||
Rotary::~Rotary() {}
|
||||
|
||||
void Rotary::taskFunction()
|
||||
{
|
||||
Event data(Event::Null, 0);
|
||||
Event* e = new Event(Event::Rotary, ThreadCommon::RotaryAction::Idle);
|
||||
_qm->send<Event>(ThreadCommon::QueueManager::master_event_all, e, 10);
|
||||
for (;;) {}
|
||||
}
|
||||
|
||||
void rotary_thread(void* pvParams)
|
||||
{
|
||||
Rotary r(static_cast<ThreadCommon::QueueManager*>(pvParams));
|
||||
r.taskFunction();
|
||||
}
|
||||
26
source/shoh/src/threads/rotary/Rotary.h
Normal file
26
source/shoh/src/threads/rotary/Rotary.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Rotary.h
|
||||
*
|
||||
* Created on: 26 Apr 2023
|
||||
* Author: tylen
|
||||
*/
|
||||
|
||||
#ifndef THREADS_ROTARY_ROTARY_H_
|
||||
#define THREADS_ROTARY_ROTARY_H_
|
||||
|
||||
#include "Event.h"
|
||||
#include "ThreadCommon.h"
|
||||
|
||||
class Rotary {
|
||||
public:
|
||||
Rotary(ThreadCommon::QueueManager* qm);
|
||||
virtual ~Rotary();
|
||||
void taskFunction();
|
||||
private:
|
||||
Event* message;
|
||||
ThreadCommon::QueueManager* _qm;
|
||||
};
|
||||
|
||||
void rotary_thread(void* pvParams);
|
||||
|
||||
#endif /* THREADS_ROTARY_ROTARY_H_ */
|
||||
Loading…
x
Reference in New Issue
Block a user