Eframe
An event-driven programming framework for low power embedded system using 8-bit or 16 MCU
Install / Use
/learn @yulincoder/EframeREADME

eframe is an event-driven programming framework for low power applications using 8-bit or 16 MCU
TODO:
- [X] handler dynamic binding
- [ ] Supports the
handle_doneevent (maybe refer to the TinyOS) - [X] Supports synchronous events by
ef_syncpost(), which can preempt common events.
Whether reasonable?
- [ ] The enevt is deivered to the specified handler at runtime.
- [ ] Events should carray some data.
API List:
Two type in eframe,
ef_event_t和ef_err_t
efPROC(handler) {}Implementation of a handler
ef_event_init()Initizlizing a variable such as define a KEY eventevent_t KEY = ef_event_init();
ef_bindhandler(event, handler)binding a handler to a event
ef_post(event)post a event to the queue.
ef_syncpost(event)post a synchronization event, which is going to be processed immediately.
ef_idle()idle handler
Serial port API:
void ef_tofaceuart(const u8 b)place the function to the interrupt of usart.
void ef_uart_recv(char *buf)read the data in underlying buffer tobuf.
void ef_uart_flush(void)flush the underlying buffer.
Default events in eframe: (Default events does not require binding by ef_bindhandler())
bootedThe same as main function. The first event posted by the MCU when it starts.efEVENT_SCH: That synchronously post the event will tigger the schudler of eframe.
Examples:
1. External interrpt example
xxx_it.c file
-----------------------------------
#include "eframe.h"
// external interrupt
external interrupt function()
{
ef_post(KEY); // post a KEY event to queue.
}
main.c file
-----------------------------------
#include "eframe.h"
// Define the handler in order to process a KEY event
efPROC(key_handler)
{
printf("The KEY1 is pressed.\n");
}
efPROC(booted) // define the handler related `booted`
{
event_t KEY = ef_event_init(); // allocate a unique ID to event.
ef_bindhandler(KEY, key_handler); //bind the key handler to KEY event.
ef_syncpost(efEVENT_SCH); // tigger the scheduler of eframe.
}
2. Serial example
uart_it.c file
-----------------------------------
#include "uartdriver.h"
uart interrupt function()
{
...
ef_tofaceuart(BUFF);
...
}
main.c file
-----------------------------------
efPROC(uart_handler)
{
static char buf[20] = {0};
ef_uart_recv(buf); // read the data from usart buffer
ef_uart_flush(); // flush it
puts(buf); //
}
efPROC(booted)
{
ef_bindhandler(EVENT_UART_EF, uart_handler);
ef_syncpost(efEVENT_SCH);
}
Related Skills
node-connect
339.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.9kCommit, push, and open a PR
