Merge remote-tracking branch 'origin/task_prep'
This commit is contained in:
@@ -4,38 +4,14 @@
|
||||
#include "task.h"
|
||||
#include <cr_section_macros.h>
|
||||
#include "FreeRTOSCPP/Kernel.hpp"
|
||||
#include "FreeRTOSCPP/Task.hpp"
|
||||
|
||||
class LedTask : public FreeRTOS::Task {
|
||||
public:
|
||||
LedTask(const UBaseType_t priority, const char* name)
|
||||
: FreeRTOS::Task(priority, configMINIMAL_STACK_SIZE, name) {}
|
||||
void taskFunction() final;
|
||||
private:
|
||||
int led;
|
||||
};
|
||||
|
||||
// Task to be created.
|
||||
void LedTask::taskFunction() {
|
||||
bool LedState = false;
|
||||
for (;;) {
|
||||
Board_LED_Set(led, LedState);
|
||||
LedState = (bool) !LedState;
|
||||
led++;
|
||||
if(led > 2){
|
||||
led = 0;
|
||||
}
|
||||
vTaskDelay(configTICK_RATE_HZ / 2);
|
||||
}
|
||||
}
|
||||
|
||||
#include "threads/master/Master.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
SystemCoreClockUpdate();
|
||||
Board_Init();
|
||||
// Create a task before starting the kernel.
|
||||
LedTask task1((tskIDLE_PRIORITY + 1UL), "vTaskLed1");
|
||||
Master master;
|
||||
|
||||
// Start the real time kernel with preemption.
|
||||
FreeRTOS::Kernel::startScheduler();
|
||||
|
||||
22
source/shoh/src/threads/master/Master.cpp
Normal file
22
source/shoh/src/threads/master/Master.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Master.cpp
|
||||
*
|
||||
* Created on: 4 Apr 2023
|
||||
* Author: tylen
|
||||
*/
|
||||
|
||||
#include "Master.h"
|
||||
|
||||
void Master::taskFunction() {
|
||||
bool LedState = true;
|
||||
for (;;) {
|
||||
Board_LED_Set(led, LedState);
|
||||
LedState = (bool) !LedState;
|
||||
led++;
|
||||
if(led > 2){
|
||||
led = 0;
|
||||
}
|
||||
vTaskDelay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
34
source/shoh/src/threads/master/Master.h
Normal file
34
source/shoh/src/threads/master/Master.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Master.h
|
||||
*
|
||||
* Created on: 4 Apr 2023
|
||||
* Author: tylen
|
||||
*/
|
||||
|
||||
#ifndef THREADS_MASTER_MASTER_H_
|
||||
#define THREADS_MASTER_MASTER_H_
|
||||
|
||||
#include "chip.h"
|
||||
#include "board.h"
|
||||
#include "FreeRTOSCPP/Task.hpp"
|
||||
#include "FreeRTOSCPP/Kernel.hpp"
|
||||
#include "task.h"
|
||||
|
||||
|
||||
class Master : public FreeRTOS::Task {
|
||||
public:
|
||||
Master(): FreeRTOS::Task((tskIDLE_PRIORITY + 1UL),
|
||||
configMINIMAL_STACK_SIZE * 10,
|
||||
"master"){};
|
||||
virtual ~Master() = default;
|
||||
|
||||
Master(Master&&) noexcept = default;
|
||||
Master& operator=(Master&&) noexcept = default;
|
||||
|
||||
void taskFunction();
|
||||
private:
|
||||
int led;
|
||||
};
|
||||
|
||||
|
||||
#endif /* THREADS_MASTER_MASTER_H_ */
|
||||
Reference in New Issue
Block a user