From 4d57c8cbce62165c58fde6563d6de52b6b437dcd Mon Sep 17 00:00:00 2001 From: Ryan Rahman Date: Tue, 17 Sep 2024 20:40:59 +0000 Subject: [PATCH 1/4] Complete task 1 --- projects/task1/src/main.c | 53 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 projects/task1/src/main.c diff --git a/projects/task1/src/main.c b/projects/task1/src/main.c new file mode 100644 index 000000000..8b81d396b --- /dev/null +++ b/projects/task1/src/main.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; +} From 9ecac9b4e2b836084aedde31a07c4b5fb2e8e63f Mon Sep 17 00:00:00 2001 From: Ryan Rahman Date: Thu, 19 Sep 2024 21:31:08 +0000 Subject: [PATCH 2/4] Complete task 1 --- --platform=x86 | 4 ++++ projects/hello_world/README.md | 15 +++++++++++++++ projects/hello_world/config.json | 7 +++++++ projects/hello_world/src/main | Bin 0 -> 33432 bytes projects/hello_world/src/main.c | 10 ++++++++++ projects/task1/README.md | 15 +++++++++++++++ projects/task1/config.json | 6 ++++++ 7 files changed, 57 insertions(+) create mode 100644 --platform=x86 create mode 100644 projects/hello_world/README.md create mode 100644 projects/hello_world/config.json create mode 100755 projects/hello_world/src/main create mode 100644 projects/hello_world/src/main.c create mode 100644 projects/task1/README.md create mode 100644 projects/task1/config.json 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 0000000000000000000000000000000000000000..2a847c587250e31946cecdf2226ad37be2e26db3 GIT binary patch literal 33432 zcmeI5U1(HC6vt<8)|i;6X=zJK8*-n-FA}LD=|k(?nxzRA6HTaFLm5qW*DP*!%kHLC z6YW|_{fGfm6av!X$Ad;HO-mk3Y(AtYf`Ud`8~UK3U}=y@1z(h=_MEx1o4ac@4?eUH z{{v@d&N(yZp83t)$GLOu(d6HSLbwEpLHYuz=@z10nA8*EHPT8_DQi6Mc{h63SF<-$ z)Z|Rp6Bg&$M+2p-^ZM#C!)m^j=@Z(XMQ&CqNr{w+z_x@osL9UfTV*e1g&x8-uPZHX zkxcigBV|0%(hyI(vhy9(`G}Dcww?L%biPzv%Eovi7K&`qwNQcoNcE#bF*K{ zmdK}}h+l>x!Kkt``JLAJd^!o+**SDbHM|eqq*7LR>O69F_1ao{H!S@UP^%=X%^@c% z?^O}0lv|>XZFp+FJQ}OSvgd0{XoTW1EC(PjVi9&z-{0EhpueT8H05e5S))fH;6XD^_J^LHnO z;JsUYr-$^w8L@ksNuG z&eir78P-E#l-#Tggu_vDLo^oln{#LqAGLi$FWA}g*TYf;O}=hIm%^*jB;=Z6a^ zOOeW?{O;+fNILrHf&d7B00@8p2!H?xfB*=900@8p2!H?xfB*=900@8p2!H?xfB*=9 z00@8p2!H?xfB*=900@8p2!H?xfB*=900@8p2!H?xfB*=900@8p2!H?xfB*=900@8p z2>b^GOnPPwsgIPuGvK_|+xd|IzDqnMs&COP?pDg9=Nj6UAICzGL@*t7N%0~Z9M2JB zyQn9dn`B^Hps^(pkWGQj{yLf!cJ* zJf7908|j}+FI9SHX^(Cdj?nZjnv%-#68R{FYo{=1^@d9K5ycq~OTG}hg=wg(-EGga zf9XnkB`)>wqX(Lck8j-3JA2LT%fHtx+-p@F8(MuD- z5%({nqg#z?->k=NeQi71e;w?o+`shHOz|4eK>gO8bLJ1phkFK=Z}@tmKlj3)@$;?5 zy7MC^IyyeM{qx-~?jH%}9ABEd@ + +#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 From fdb2ebec845ae58f458e469b3eb76a1564bfc201 Mon Sep 17 00:00:00 2001 From: Ryan Rahman Date: Thu, 19 Sep 2024 21:55:42 +0000 Subject: [PATCH 3/4] ryan rahman tasks commit --- projects/task1/src/{main.c => tasks/tasks.c} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename projects/task1/src/{main.c => tasks/tasks.c} (100%) diff --git a/projects/task1/src/main.c b/projects/task1/src/tasks/tasks.c similarity index 100% rename from projects/task1/src/main.c rename to projects/task1/src/tasks/tasks.c From 9ebb21fb234a308f5dd103a00dcf94f8672e6dae Mon Sep 17 00:00:00 2001 From: Ryan Rahman Date: Fri, 20 Sep 2024 14:17:24 +0000 Subject: [PATCH 4/4] ryan rahman tasks commit --- projects/task1/src/queues1.c | 82 ++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 projects/task1/src/queues1.c 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; +}