Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fwxv 999 roshan hegde 103 hw #326

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions projects/hello_world/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!--
General guidelines
These are just guidelines, not strict rules - document however seems best.
A README for a firmware-only project (e.g. Babydriver, MPXE, bootloader, CAN explorer) should answer the following questions:
- What is it?
- What problem does it solve?
- How do I use it? (with usage examples / example commands, etc)
- How does it work? (architectural overview)
A README for a board project (powering a hardware board, e.g. power distribution, centre console, charger, BMS carrier) should answer the following questions:
- What is the purpose of the board?
- What are all the things that the firmware needs to do?
- How does it fit into the overall system?
- How does it work? (architectural overview, e.g. what each module's purpose is or how data flows through the firmware)
-->
# hello_world
6 changes: 6 additions & 0 deletions projects/hello_world/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"libs": [
"FreeRTOS",
"ms-common"
]
}
11 changes: 11 additions & 0 deletions projects/hello_world/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <stdio.h>
#include "log.h" // The library includes

int main(void) {
int i = 0;
while (1) {
LOG_DEBUG("Hello World %d\n", i);
i++;
}
return 0;
}
15 changes: 15 additions & 0 deletions projects/queues/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!--
General guidelines
These are just guidelines, not strict rules - document however seems best.
A README for a firmware-only project (e.g. Babydriver, MPXE, bootloader, CAN explorer) should answer the following questions:
- What is it?
- What problem does it solve?
- How do I use it? (with usage examples / example commands, etc)
- How does it work? (architectural overview)
A README for a board project (powering a hardware board, e.g. power distribution, centre console, charger, BMS carrier) should answer the following questions:
- What is the purpose of the board?
- What are all the things that the firmware needs to do?
- How does it fit into the overall system?
- How does it work? (architectural overview, e.g. what each module's purpose is or how data flows through the firmware)
-->
# queues
6 changes: 6 additions & 0 deletions projects/queues/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"libs": [
"FreeRTOS",
"ms-common"
]
}
73 changes: 73 additions & 0 deletions projects/queues/src/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 "delay.h"
#include "log.h"
#include "misc.h"
#include "queues.h"
#include "status.h"
#include "tasks.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
.num_items = QUEUE_LEN,
.item_size = ITEM_SZ,
.storage_buf = s_queue1_buf
};

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

TASK(task2, TASK_STACK_512) {
LOG_DEBUG("Task 2 initialized!\n");
const char outstr[ITEM_SZ];
StatusCode ret;
while (true) {
for (int i = 0; i < QUEUE_LEN; i++) {
// Your code goes here
ret = queue_receive(&s_queue1, outstr, 0);
if (ret != STATUS_CODE_OK) {
LOG_DEBUG("read from queue failed!\n");
}
LOG_DEBUG("Received: %s\n", outstr);
delay_ms(1000);
}
}
}

int main(void) {
tasks_init();
log_init();
// Initialize queues here
queue_init(&s_queue1);

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

LOG_DEBUG("Program start...\n");
tasks_start();

return 0;
}
15 changes: 15 additions & 0 deletions projects/task1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!--
General guidelines
These are just guidelines, not strict rules - document however seems best.
A README for a firmware-only project (e.g. Babydriver, MPXE, bootloader, CAN explorer) should answer the following questions:
- What is it?
- What problem does it solve?
- How do I use it? (with usage examples / example commands, etc)
- How does it work? (architectural overview)
A README for a board project (powering a hardware board, e.g. power distribution, centre console, charger, BMS carrier) should answer the following questions:
- What is the purpose of the board?
- What are all the things that the firmware needs to do?
- How does it fit into the overall system?
- How does it work? (architectural overview, e.g. what each module's purpose is or how data flows through the firmware)
-->
# task1
6 changes: 6 additions & 0 deletions projects/task1/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"libs": [
"FreeRTOS",
"ms-common"
]
}
77 changes: 77 additions & 0 deletions projects/task1/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#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
.num_items = QUEUE_LEN,
.item_size = ITEM_SZ,
.storage_buf = s_queue1_buf
};


TASK(task1, TASK_STACK_512) {
LOG_DEBUG("Task 1 initialized!\n");
StatusCode ret;
for (int i = 0; i < QUEUE_LEN; i++) {
// Your code goes here
ret = queue_send(&s_queue1, s_list[i], 0);
if (ret != STATUS_CODE_OK) {
LOG_DEBUG("write to queue failed!\n");
}
delay_ms(1000);
}
}

TASK(task2, TASK_STACK_512) {
LOG_DEBUG("Task 2 initialized!\n");
const char outstr[ITEM_SZ];
StatusCode ret;
for (int i = 0; i < QUEUE_LEN; i++) {
// Your code goes here
ret = queue_receive(&s_queue1, outstr, 0);
if (ret != STATUS_CODE_OK) {
LOG_DEBUG("read from queue failed!\n");
}
LOG_DEBUG("Received: %s\n", outstr);
delay_ms(1000);
}
}

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

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

LOG_DEBUG("Program start...\n");
tasks_start();

return 0;
}
Loading