Coder Social home page Coder Social logo

ianhom / moe Goto Github PK

View Code? Open in Web Editor NEW
65.0 13.0 36.0 4.46 MB

MOE is an event-driven OS for 8/16/32-bit MCUs. MOE means "Minds Of Embedded system", It’s also the name of my lovely baby daughter :sunglasses:

Home Page: https://ianhom.github.io/MOE

License: MIT License

C 99.06% C++ 0.94%
moe multi-task event-driven easy-to-use mcu protothreads schedule

moe's Introduction

MOE

license GitHub release status
中文说明

Smartphone with MOE

The first smartphone with MOE in the world!.......Bazinga!!!


LOGO

Introduce

MOE is an event-driven scheduler system for 8/16/32-bit MCUs. MOE means "Minds Of Embedded system", it’s also the name of my lovely baby daughter 😄
Features with:

Features Description
Event-driven Flexible event queue length, priority event supported.
Timer Useful ms-timer with callback.
Message Easy-use message API for communication between tasks, To-All-Task message with low RAM comsuption supported.
Debug Flexible debug print options for each task or module; Useful easy-assert; CmBacktrace(Hardfault backtrace for Cortex-M)
Protothread Protothread is supported for application module.

For more discussion, please join our QQ Group: 475258651

Supported Platform    

  • MIMXRT1050-EVK.........(coming soon)

How to use

  • Step 1: Port the MOE to your hardware, provide "system clock in ms" and "poll function(if available)", init and run MOE.
/* EXAMPLE CODE */
uint16 GetMsClock(void)    /* Function to get ms clock */
{
    return sg_u16SysClk;  /* System ms clock, increased every 1 ms in hardware timer interrupt */
}

void Poll(void)    /* Function to be Polled */
{
    /* Something you want to do by polling */
    return;
}

void main(void)
{
    ....                         /* Board init operation */
    MOE_Init(GetMsClock, Poll);  /* Init MOE with system clock funtion, and poll function(fill "NULL" if NOT available) */
    MOE_Run();                   /* Start MOE            */
    return;
}
  • Step 2: Create your own tasks or re-use exist app tasks to build your application. (Protothread style application is shown below, For event handler style, please see the source)
/* EXAMPLE CODE */
/* Task 1: Blinking LED */
uint8 Task_PT_Demo_Process(uint8 u8Evt, void *pPara)
{   
    PT_INIT();
    PT_BEGIN();
    MOE_MANDATORY_INIT();  /* Mandatory init, shout call it here only */

    while(1)
    {
        TASK_PT_DEMO_LED_Toggle(LED_RED);
        PT_DELAY(1000);

        TASK_PT_DEMO_LED_Toggle(LED_GREEN);
        PT_DELAY(1000);

        TASK_PT_DEMO_LED_Toggle(LED_BLUE);
        PT_DELAY(1000);
    }
    PT_END();
    return SW_OK;
}
/* EXAMPLE CODE */
/* Task 2: Periodic printing */
uint8 Task_PT_Demo2_Process(uint8 u8Evt, void *pPara)
{    
    PT_INIT(); 
    PT_BEGIN();
    MOE_MANDATORY_INIT();  /* Mandatory init, shout call it here only */

    while(1)
    {
        DBG_PRINT("I am another Task!!\n");
        PT_DELAY(1000);
    }
    PT_END();
    return SW_OK;
}
  • Step 3: Register tasks in Project_Config.h and continue other configuration in the same file.
#define LIST_OF_REG_TASK \
        REG_TASK(Task_PT_Demo_Proces)\
        REG_TASK(Task_PT_Demo2_Proces)
  • Step 4: Run & Enjoy. 😄

Source Tree Structure

Folder Description
App/ App modules which can be re-used in different projects. Please add new app module here for new application requirement
Core/ Core files including scheduler, Event-drivern, timer and message.
Cpu/ Startup and other necessary code for starting MCUs
Debug/ Useful tool & modules for debugging
Driver/ Driver of MCU peripheral and other extended module(sensors or RF parts)
Network/ Stack for kinds fo network(to be done.)
Pub/ Public files including public head file, MACRO and debug file
Utility/ Useful function modules including queue, link list, printf
project/ Files for specific projects including configuration of SW/HW and the main file
Documents/ Description documents including design record, API reference and pictures
Tools/ Useful Tools for configuration, building, debugging, analysis and so on

Useful Documents

Special Thanks

  • 🎉MOE Logo drawing by Miss Cai Jianan.:tada:

moe's People

Contributors

ianhom avatar jiaoweiming215 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

moe's Issues

Make MOE more "real time"

I am planning to make MOE more "real time".
When interrupt happens, MOE switch to the highest priority task.
Save and load PC register value to realise returning.

Diagram

Title

Link
image

Hi ianhom
Could you share the MOE‘’s diagram for me?

Find a new way to register tasks

In Ti osal, tasks process init function sare filled in osal_app.c file which will be modified according each project, I wanna do it in the osal.c which would like to be a fixed file, so I need to find a new way to register task into osal.c file.

To do list for OSAL_Msg module

  • Message head define
  • Message type define
  • Message create
  • Message delete
  • Message send
  • Message receive
  • Code for test
  • Useful API

Make a smaller core

Although timer and message modules are good and useful, maybe a smaller core without them is another good choice

Message poll flag issue

Message poll flag is used to check if it is necessary to do the message process which delete useless message with a "TASK_NO_TASK" for destination task field.
For the beggining design, Receiving and forwarding is processed at the same time, I found it is stupid when I debug the codes----in most situation, you have to know the info of message fisrt before you forward such message........so,it is a bad design.

So now, I seprate the receiving and forwarding functions, however, another issue(not a problem) arises: When a message is received, the destination task will be set as TASK_NO_TASK, and the message poll flag will be set as "Need poll". If the task needs to forward such message, forwarding function will set the destination task as the desired next task, that means, it is unnecessary to do the message process poll......

Think about it.....

Todo List

  • Debug timer code
  • Add message process
  • Debug message code
  • Design friendly & useful API

How to build a good HAL

I have build the main part of scheduler, and it works well, new I need to build useful HAL now. Would anybody want to share ideas about a userful friendly HAL ?

实现了Moe_Timer_Get_Left

Title

Link
image

uint32 Moe_Timer_Get_Left(T_TIMER_NODE* ptNode)
{
uint32 rtrn = 0;
uint32 u32IntSt;
Moe_Timer_Process();
ENTER_CRITICAL_ZONE(u32IntSt);
if(ptNode) {
rtrn = ptNode->tTimer.u32TmLeft - sg_u32TmDiff;
}
EXIT_CRITICAL_ZONE(u32IntSt); /* Exit the critical zone */
return rtrn;
}

Mini shell?

As a os, is it necessary to provide a mini shell?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.