diff --git a/--platform=x86 b/--platform=x86 new file mode 100644 index 000000000..85eb69106 --- /dev/null +++ b/--platform=x86 @@ -0,0 +1,4 @@ +scons: Reading SConscript files ... +scons: done reading SConscript files. +scons: Building targets ... +scons: building terminated because of errors. diff --git a/projects/hello_world/README.md b/projects/hello_world/README.md new file mode 100644 index 000000000..dbf13db0c --- /dev/null +++ b/projects/hello_world/README.md @@ -0,0 +1,15 @@ + +# hello_world \ No newline at end of file diff --git a/projects/hello_world/config.json b/projects/hello_world/config.json new file mode 100644 index 000000000..ef1bba36e --- /dev/null +++ b/projects/hello_world/config.json @@ -0,0 +1,7 @@ +{ + "libs": [ + "FreeRTOS", + "ms-common", + "master" + ] +} \ No newline at end of file diff --git a/projects/hello_world/src/main b/projects/hello_world/src/main new file mode 100755 index 000000000..2a847c587 Binary files /dev/null and b/projects/hello_world/src/main differ diff --git a/projects/hello_world/src/main.c b/projects/hello_world/src/main.c new file mode 100644 index 000000000..95c41dd5a --- /dev/null +++ b/projects/hello_world/src/main.c @@ -0,0 +1,10 @@ +#include + +#include "log.h" +//#include "master_task.h" +//#include "tasks.h" + +int main() { + LOG_DEBUG("Hello World \n"); + return 0; +} diff --git a/projects/task1/README.md b/projects/task1/README.md new file mode 100644 index 000000000..da2157574 --- /dev/null +++ b/projects/task1/README.md @@ -0,0 +1,15 @@ + +# task1 \ No newline at end of file diff --git a/projects/task1/config.json b/projects/task1/config.json new file mode 100644 index 000000000..4019f4748 --- /dev/null +++ b/projects/task1/config.json @@ -0,0 +1,6 @@ +{ + "libs": [ + "FreeRTOS", + "ms-common" + ] +} \ No newline at end of file diff --git a/projects/task1/src/queues1.c b/projects/task1/src/queues1.c new file mode 100644 index 000000000..e0d1b0f63 --- /dev/null +++ b/projects/task1/src/queues1.c @@ -0,0 +1,82 @@ +#include +#include + +#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 = STATUS_CODE_OK; + uint32_t to_send = 0; + while (to_send < 6) { + // Your code goes here + ret = queue_send(&s_queue1, &s_list[to_send], 0); + delay_ms(100); + to_send++; + if (ret != STATUS_CODE_OK){ + LOG_DEBUG("write to queue failed"); + } + } +} + +TASK(task2, TASK_STACK_512) { + LOG_DEBUG("Task 2 initialized!\n"); + char outstr[ITEM_SZ]; + uint32_t to_recieve = 0; + StatusCode ret = STATUS_CODE_OK; + while (to_recieve<5) { + // Your code goes here + ret = queue_receive(&s_queue1, &outstr, 1000); + delay_ms(100); + LOG_DEBUG("Received: %s\n", outstr); + if (ret != STATUS_CODE_OK){ + LOG_DEBUG("read from queue failed"); + } + to_recieve ++; + } +} + +int main(void) { + + log_init(); + // Initialize queues here + tasks_init(); + 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; +} diff --git a/projects/task1/src/tasks/tasks.c b/projects/task1/src/tasks/tasks.c new file mode 100644 index 000000000..8b81d396b --- /dev/null +++ b/projects/task1/src/tasks/tasks.c @@ -0,0 +1,53 @@ +#include +#include + +#include "FreeRTOS.h" +#include "tasks.h" + +#include "gpio.h" +#include "log.h" +#include "misc.h" +#include "delay.h" + +// Non blocking delay. Simply consumes cpu cycles until a given time has passed +static void prv_delay(const TickType_t delay_ms) { + TickType_t curr_tick = xTaskGetTickCount(); + while(xTaskGetTickCount() - curr_tick < pdMS_TO_TICKS(delay_ms)) + {} +} + +TASK(task1, TASK_STACK_512) { + int counter1 = 0; + while (true) { + // Your code here + LOG_DEBUG("task1 \t"); + LOG_DEBUG("%d \n",counter1); + counter1 ++; + delay_ms(1000); + } +} + +TASK(task2, TASK_STACK_512) { + int counter2 = 0; + while (true) { + // Your code here + LOG_DEBUG("task2 \t"); + LOG_DEBUG("%d \n",counter2); + counter2 ++; + prv_delay(1000); + } +} + +int main(void) { + log_init(); + // Create tasks here + tasks_init(); + tasks_init_task(task1,TASK_PRIORITY(2),NULL); + tasks_init_task(task2,TASK_PRIORITY(1),NULL); + + LOG_DEBUG("Program start...\n"); + // Start the scheduler + tasks_start(); + + return 0; +}