Skip to content

Commit

Permalink
andre ke fw102 onboarding queues
Browse files Browse the repository at this point in the history
  • Loading branch information
nohyp3 committed Sep 6, 2024
1 parent 96feda2 commit d2a9572
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions projects/queues/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include <stdbool.h>
#include <stdint.h>

#include "FreeRTOS.h"
#include "tasks.h"
#include "queues.h"
#include "status.h"
#include "delay.h"

#include "log.h"
#include "misc.h"


#define ITEM_SZ 6
#define QUEUE_LEN 5
#define BUF_SIZE (QUEUE_LEN * ITEM_SZ)

static const char s_list[QUEUE_LEN][ITEM_SZ] = {
"Item1",
"Item2",
"Item3",
"Item4",
"Item5"
};

// Task static entities
static uint8_t s_queue1_buf[BUF_SIZE];
static Queue s_queue1 = {
// Add parameters
};


TASK(task1, TASK_STACK_512) {
LOG_DEBUG("Task 1 initialized!\n");
StatusCode ret;
while (true) {
// Your code goes here
int counter = 0;
queue_send(&s_queue1, &s_list[counter], 0);
counter++;
delay(100);
if(STATUS_CODE_OK){
LOG_DEBUG("write to queue failed");
}

}
}

TASK(task2, TASK_STACK_512) {
string_t item = "";
LOG_DEBUG("Task 2 initialized!\n");
const char outstr[ITEM_SZ];
StatusCode ret;
while (true) {
// Your code goes here
queue_receive(&s_queue1, &string_t, 1000);
LOG_DEBUG("Received: %u\n",item);
}
}

int main(void) {
log_init();
// Initialize queues here

tasks_init_task(task1, TASK_PRIORITY(2), NULL);
tasks_init_task(task2, TASK_PRIORITY(2), NULL);

LOG_DEBUG("Program start...\n");
queue_init(&s_queue1);
tasks_start();

return 0;
}

0 comments on commit d2a9572

Please sign in to comment.