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

<CC_OS>Add Test Applications #200

Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ out/
tools/
backup/
bkp/
projects/
pranjalchanda08 marked this conversation as resolved.
Show resolved Hide resolved
*.elf
*.bin
*.d
Expand Down Expand Up @@ -41,3 +40,7 @@ projects/
*.mod*
*.cmd
*.todo

.vscode/compile_commands.json

.vscode/settings.json
61 changes: 0 additions & 61 deletions .vscode/settings.json

This file was deleted.

1 change: 1 addition & 0 deletions mk/path.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ TOOLS_ROOT ?= $(abspath $(CC_ROOT))/tools
MISC_TOOLS := $(TOOLS_ROOT)/misc_bins

SRC := $(CC_ROOT)/src
CC_OS_ROOT := $(SRC)/include/visor/terravisor/cc_os
pranjalchanda08 marked this conversation as resolved.
Show resolved Hide resolved
OUT_PATH ?= $(CC_ROOT)/out
OUT ?= $(OUT_PATH)/$(PROJECT)

Expand Down
19 changes: 19 additions & 0 deletions projects/demo_cc_os.src/build.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2019, Cyancore Team
#
# File Name : build.mk
# Description : This file build project sources and specifies
# project properties
# Primary Author : Akash Kollipara [[email protected]]
# Organisation : Cyancore Core-Team
#

DEMO_DIR := $(GET_PATH)

OPTIMIZATION := s

EXE_MODE := terravisor

DIR := $(DEMO_DIR)
include mk/obj.mk
51 changes: 51 additions & 0 deletions projects/demo_cc_os.src/project.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* CYANCORE LICENSE
* Copyrights (C) 2019, Cyancore Team
pranjalchanda08 marked this conversation as resolved.
Show resolved Hide resolved
*
* File Name : project.c
* Description : This file consists of project srouces
* Primary Author : Pranjal Chanda [[email protected]]
* Organisation : Cyancore Core-Team
*/
#include <stdio.h>
#include <driver.h>
#include <terravisor/bootstrap.h>
#include <driver/onboardled.h>
#include <terravisor/cc_os/cc_os.h>

#define TASK_WAIT_TICKS 10

/* Define the Tasks */
CC_TASK_DEF( TASK_A, task_handler, NULL, 10, 100);
pranjalchanda08 marked this conversation as resolved.
Show resolved Hide resolved
CC_TASK_DEF( TASK_B, task_handler, NULL, 10, 100);
CC_TASK_DEF( TASK_C, task_handler, NULL, 10, 100);

/* Define Plug */
void plug()
{
bootstrap();
driver_setup_all();

printf("Demo CC OS Program!\n");
cc_os_add_task(&CC_GET_TASK_INST(TASK_A));
cc_os_add_task(&CC_GET_TASK_INST(TASK_B));
cc_os_add_task(&CC_GET_TASK_INST(TASK_C));
cc_os_run();
}

/* Define Play */
void play()
{
/* < ! > Play looping code here*/
return;
}

/* Define the Task Handler */
void task_handler(os_args args _UNUSED)
{
while(CC_OS_TRUE)
{
printf("In Task: %s\n", cc_os_get_curr_task_name());
cc_os_task_wait(TASK_WAIT_TICKS);
}
}
18 changes: 18 additions & 0 deletions projects/demo_cc_os_avr/build.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2019, Cyancore Team
#
# File Name : build.mk
# Description : This file build project sources and specifies
# project properties
# Primary Author : Akash Kollipara [[email protected]]
# Organisation : Cyancore Core-Team
#

PROJECT_DIR := $(GET_PATH)

include $(PROJECT_DIR)/../demo_cc_os.src/build.mk
include $(PROJECT_DIR)/config.mk

DIR := $(PROJECT_DIR)
include mk/obj.mk
17 changes: 17 additions & 0 deletions projects/demo_cc_os_avr/cc_os_config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2019-2023, Cyancore Team
#
# File Name : kern_config.mk
# Description : This file consists of CC_OS kernal configuration
# Primary Author : Pranjal Chanda [[email protected]]
# Organisation : Cyancore Core-Team
#

ccosconfig_CC_OS_USE_DYNAMIC := 1
ccosconfig_CC_OS_HEAP_SIZE := 1024
ccosconfig_CC_OS_MAX_THREAD := 3
ccosconfig_CC_OS_TASK_STACK_LEN := 255
ccosconfig_CC_OS_POWER_SAVE_EN := 0
pranjalchanda08 marked this conversation as resolved.
Show resolved Hide resolved

include $(CC_OS_ROOT)/cc_os_config.mk
24 changes: 24 additions & 0 deletions projects/demo_cc_os_avr/config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2019-2023, Cyancore Team
#
# File Name : config.mk
# Description : This file consists of project config
# Primary Author : Pranjal Chanda [[email protected]]
# Organisation : Cyancore Core-Team
#

COMPILER := gcc
TC_VER := 5.4.0
FAMILY := mega_avr
PLATFORM := atmega328p
HEAP_SIZE := 256
STACK_SIZE := 256
STDLOG_MEMBUF := 0
BOOTMSGS := 0
EARLYCON_SERIAL := 0
CONSOLE_SERIAL := 0
pranjalchanda08 marked this conversation as resolved.
Show resolved Hide resolved
OBRDLED_ENABLE := 1
TERRAKERN := 1

include $(PROJECT_DIR)/cc_os_config.mk
18 changes: 18 additions & 0 deletions projects/demo_cc_os_riscv/build.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2019, Cyancore Team
#
# File Name : build.mk
# Description : This file build project sources and specifies
# project properties
# Primary Author : Akash Kollipara [[email protected]]
# Organisation : Cyancore Core-Team
#

PROJECT_DIR := $(GET_PATH)

include $(PROJECT_DIR)/../demo_cc_os.src/build.mk
include $(PROJECT_DIR)/config.mk

DIR := $(PROJECT_DIR)
include mk/obj.mk
17 changes: 17 additions & 0 deletions projects/demo_cc_os_riscv/cc_os_config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2019-2023, Cyancore Team
#
# File Name : kern_config.mk
# Description : This file consists of CC_OS kernal configuration
# Primary Author : Pranjal Chanda [[email protected]]
# Organisation : Cyancore Core-Team
#

ccosconfig_CC_OS_USE_DYNAMIC := 1
ccosconfig_CC_OS_HEAP_SIZE := 1024
ccosconfig_CC_OS_MAX_THREAD := 3
ccosconfig_CC_OS_TASK_STACK_LEN := 255
ccosconfig_CC_OS_POWER_SAVE_EN := 0

include $(CC_OS_ROOT)/cc_os_config.mk
24 changes: 24 additions & 0 deletions projects/demo_cc_os_riscv/config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2019-2023, Cyancore Team
#
# File Name : config.mk
# Description : This file consists of project config
# Primary Author : Pranjal Chanda [[email protected]]
# Organisation : Cyancore Core-Team
#

COMPILER := gcc
TC_VER := 10.2.0
FAMILY := sifive
PLATFORM := fe310g002
HEAP_SIZE := 256
STACK_SIZE := 256
STDLOG_MEMBUF := 0
BOOTMSGS := 0
EARLYCON_SERIAL := 0
CONSOLE_SERIAL := 0
OBRDLED_ENABLE := 1
TERRAKERN := 1

include $(PROJECT_DIR)/cc_os_config.mk
4 changes: 2 additions & 2 deletions src/include/visor/terravisor/cc_os/cc_os_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @note Possible values : 1/0
*/
#ifndef ccosconfig_CC_OS_USE_DYNAMIC
#define ccosconfig_CC_OS_USE_DYNAMIC 0
#define ccosconfig_CC_OS_USE_DYNAMIC 1
#endif

/**
Expand Down Expand Up @@ -62,7 +62,7 @@

/**
* @brief If the Kernel shall enter poer save mode during IDLE
*
*
*/
#ifndef ccosconfig_CC_OS_POWER_SAVE_EN
#define ccosconfig_CC_OS_POWER_SAVE_EN 0
Expand Down
21 changes: 21 additions & 0 deletions src/include/visor/terravisor/cc_os/cc_os_config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2019, Cyancore Team
pranjalchanda08 marked this conversation as resolved.
Show resolved Hide resolved
#
# File Name : kern_config.mk
# Description : This file consists of CC_OS kernal configuration
# Primary Author : Akash Kollipara [[email protected]]
pranjalchanda08 marked this conversation as resolved.
Show resolved Hide resolved
# Organisation : Cyancore Core-Team
#

ccosconfig_CC_OS_USE_DYNAMIC ?= 0
ccosconfig_CC_OS_HEAP_SIZE ?= 1024
ccosconfig_CC_OS_MAX_THREAD ?= 2
ccosconfig_CC_OS_TASK_STACK_LEN ?= 255
ccosconfig_CC_OS_POWER_SAVE_EN ?= 0

$(eval $(call add_define,ccosconfig_CC_OS_USE_DYNAMIC))
$(eval $(call add_define,ccosconfig_CC_OS_HEAP_SIZE))
$(eval $(call add_define,ccosconfig_CC_OS_MAX_THREAD))
$(eval $(call add_define,ccosconfig_CC_OS_TASK_STACK_LEN))
$(eval $(call add_define,ccosconfig_CC_OS_POWER_SAVE_EN))
1 change: 1 addition & 0 deletions src/include/visor/terravisor/cc_os/cc_os_sem.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ static sem_t _Name##_sem = { \
}; \
static sem_t * _Name##_sem_inst = &_Name##_sem
#else
#define CC_SEM_DEF(_Name) \
static sem_t * _Name##_sem_inst = CC_OS_NULL_PTR
#endif
/*****************************************************
Expand Down
32 changes: 25 additions & 7 deletions src/include/visor/terravisor/cc_os/cc_os_tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
/*****************************************************
* TYPEDEFS
*****************************************************/
typedef void *os_args;
typedef const void * os_args;
typedef void (*task_fn)(os_args args);
typedef const char c_char;

/**
* @brief TASK infrastructure structure
Expand All @@ -35,8 +34,8 @@ typedef struct cc_os_task
task_fn task_fn; ///>> Task funcion
os_args args; ///>> Task Args ptr
c_char *name; ///>> String name of the task
size_t priority; ///>> For waited tasks
size_t *stack_ptr; ///>> Stack pointer of the task
uint8_t *stack_ptr; ///>> Stack pointer of the task
pranjalchanda08 marked this conversation as resolved.
Show resolved Hide resolved
uint8_t priority; ///>> For waited tasks
size_t stack_len; ///>> Stack lengths of the task
cc_sched_tcb_t *task_tcb_ptr; ///>> For internal use only
} cc_os_task_t;
Expand All @@ -51,16 +50,28 @@ typedef struct cc_os_task
* @note DO NOT use space in place of TASK_Name as it would result build errors.
*
*/
#if CC_OS_DYNAMIC == CC_OS_FALSE
#define CC_TASK_DEF(_NAME, _fn, _args, _PRI, STACK_LEN) \
static size_t _NAME##_stack[STACK_LEN]; \
extern void _fn (os_args args); \
static uint8_t _NAME##_stack[STACK_LEN]; \
static cc_os_task_t _NAME##_task = { \
.args = _args, \
.task_fn = _fn, \
.name = #_NAME, \
.priority = _PRI, \
.stack_ptr = _NAME##_stack, \
.stack_len = STACK_LEN}

#else
#define CC_TASK_DEF(_NAME, _fn, _args, _PRI, STACK_LEN) \
extern void _fn (os_args args); \
static cc_os_task_t _NAME##_task = { \
.args = _args, \
.task_fn = _fn, \
.name = #_NAME, \
.priority = _PRI, \
.stack_ptr = CC_OS_NULL_PTR, \
.stack_len = STACK_LEN}
#endif
/**
* @brief Function to get the instance using its name of already declared task.
* @brief Usage: cc_os_task_t * task = &(CC_GET_TASK_INST(TASK_Name));
Expand Down Expand Up @@ -131,8 +142,15 @@ status_t cc_os_resume_all_task(void);
* @param sched_algo[in] The algorithm that needs to be selected to
* @return status_t
*/
status_t set_cc_os_sched_algo(cc_sched_algo_t sched_algo);
status_t cc_os_set_sched_algo(cc_sched_algo_t sched_algo);

/**
* @brief Get name of current running task
*
* @param None
* @return Pointer to the current task name
*/
const char * cc_os_get_curr_task_name(void);
/**
* @brief A Function to put the current task to a waiting state and yield
* @note To just Yeild set ticks to 0
Expand Down
Loading