157 lines
3.6 KiB
Plaintext
157 lines
3.6 KiB
Plaintext
|
#include "FreeRTOS.h"
|
||
|
#include "task.h"
|
||
|
#include "queue.h"
|
||
|
#include "timers.h"
|
||
|
#include "murax.h"
|
||
|
|
||
|
#include <cstddef>
|
||
|
#include <cstdio>
|
||
|
|
||
|
|
||
|
#define mainTIMER_PERIOD_MS (1 / portTICK_PERIOD_MS) // Ustawienie okresu timera na 1 sekundę
|
||
|
#define QUEUE_LENGTH 5
|
||
|
#define QUEUE_ITEM_SIZE sizeof(uint32_t)
|
||
|
|
||
|
extern "C" {
|
||
|
void vApplicationMallocFailedHook(void);
|
||
|
void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName);
|
||
|
}
|
||
|
|
||
|
/*-----------------------------------------------------------*/
|
||
|
|
||
|
// Deklaracja funkcji dla zadania i callbacku timera
|
||
|
static void hungryTask(void *pvParameters);
|
||
|
static void timerCallback(TimerHandle_t xTimer);
|
||
|
|
||
|
// Globalna kolejka
|
||
|
static QueueHandle_t xQueue;
|
||
|
|
||
|
/*-----------------------------------------------------------*/
|
||
|
|
||
|
/*
|
||
|
#include <include/FreeRTOS/Task.hpp>
|
||
|
|
||
|
class MyTask : public FreeRTOS::Task {
|
||
|
public:
|
||
|
MyTask(const UBaseType_t priority, const char* name)
|
||
|
: FreeRTOS::Task(priority, configMINIMAL_STACK_SIZE, name) {}
|
||
|
void taskFunction() final;
|
||
|
};
|
||
|
|
||
|
// Task to be created.
|
||
|
void MyTask::taskFunction() {
|
||
|
for (;;) {
|
||
|
// Task code goes here.
|
||
|
}
|
||
|
}
|
||
|
// Function that creates a task.
|
||
|
void aFunction() {
|
||
|
// Create the task.
|
||
|
MyTask task((tskIDLE_PRIORITY + 1), "NAME");
|
||
|
|
||
|
// Check that the task was created successfully.
|
||
|
if (task.isValid()) {
|
||
|
// Start the scheduler.
|
||
|
FreeRTOS::Kernel::startScheduler();
|
||
|
}
|
||
|
|
||
|
// Task will be destroyed when the scheduler is stopped and this function
|
||
|
// returns.
|
||
|
}
|
||
|
*/
|
||
|
#include "include/Timer.hpp"
|
||
|
|
||
|
const Timer_Reg* TimeR::ptr = reinterpret_cast<const Timer_Reg*>(0xF0020040);
|
||
|
|
||
|
void print(const char*str){
|
||
|
while(*str){
|
||
|
uart_write(UART,*str);
|
||
|
str++;
|
||
|
}
|
||
|
}
|
||
|
void println(const char*str){
|
||
|
print(str);
|
||
|
uart_write(UART,'\n');
|
||
|
}
|
||
|
|
||
|
#include "X.hpp"
|
||
|
|
||
|
#include "SimpleOStream.hpp"
|
||
|
|
||
|
int main(void) {
|
||
|
|
||
|
// Definicja globalnego obiektu strumienia wyjściowego
|
||
|
SimpleOStream simpleCout;
|
||
|
|
||
|
|
||
|
X var {7};
|
||
|
|
||
|
//afunction();
|
||
|
|
||
|
println("hello world arty a7 v1");
|
||
|
|
||
|
|
||
|
xQueue = xQueueCreate(QUEUE_LENGTH, QUEUE_ITEM_SIZE); // Tworzenie kolejki
|
||
|
if (xQueue == NULL) {
|
||
|
return -1; // Błąd podczas tworzenia kolejki
|
||
|
}
|
||
|
|
||
|
TimerHandle_t xCheckTimer = NULL;
|
||
|
|
||
|
/*
|
||
|
// Inicjalizacja timera
|
||
|
xCheckTimer = xTimerCreate("CheckTimer",
|
||
|
mainTIMER_PERIOD_MS,
|
||
|
pdTRUE,
|
||
|
(void *)0,
|
||
|
timerCallback);
|
||
|
*/
|
||
|
|
||
|
// Start timera
|
||
|
if (xCheckTimer != NULL) {
|
||
|
xTimerStart(xCheckTimer, 0);
|
||
|
}
|
||
|
|
||
|
// Tworzenie zadania hungryTask
|
||
|
xTaskCreate(hungryTask, "Hungry Task", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL);
|
||
|
|
||
|
// Uruchomienie planisty
|
||
|
vTaskStartScheduler();
|
||
|
|
||
|
// Teoretycznie nigdy nie powinniśmy tu dotrzeć
|
||
|
for (;;);
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
/*-----------------------------------------------------------*/
|
||
|
|
||
|
// Definicja funkcji callback timera
|
||
|
static void timerCallback(TimerHandle_t xTimer) {
|
||
|
uint32_t ulValueToSend = 1; // Przykładowa wartość do wysłania
|
||
|
xQueueSendFromISR(xQueue, &ulValueToSend, NULL);
|
||
|
}
|
||
|
|
||
|
// Definicja zadania
|
||
|
static void hungryTask(void *pvParameters) {
|
||
|
uint32_t ulReceivedValue;
|
||
|
for (;;) {
|
||
|
// if (xQueueReceive(xQueue, &ulReceivedValue, portMAX_DELAY) == pdPASS) {
|
||
|
//printf("hungry\n"); // Drukowanie, gdy odbierzemy wartość z kolejki
|
||
|
// }
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/*-----------------------------------------------------------*/
|
||
|
|
||
|
void vApplicationMallocFailedHook(void) {
|
||
|
for (;;);
|
||
|
}
|
||
|
|
||
|
void vApplicationIdleHook(void) {
|
||
|
// Można tu umieścić kod wykonywany w stanie bezczynności
|
||
|
}
|
||
|
|
||
|
void vApplicationStackOverflowHook(TaskHandle_t pxTask, char *pcTaskName) {
|
||
|
for (;;);
|
||
|
}
|