ArcticLampyrid / uexecuter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UEXECUTER

Languages: Chinese | English

UEXECUTER is a cute function caller, which takes human-readable strings as instructions, and calls functions on the microcontroller via serial communication. Currently, it supports STM32F4 series microcontrollers and ARM hardware floating point model (-mfloat-abi=hard).

Features

  • Human-readable instructions
  • Support for ARM hardware floating point model
  • Easy to use

Usage

  1. Define the service and register your function:
    double add_f32_f64_i32(float x, double y, int32_t z)
    {
        return x + y + z;
    }
    double add_f32_f64(float x, double y)
    {
        return x + y;
    }
    UEXECUTER_DEFINE_SERVICE(my_uexecuter_service){
        // C-compatible way, provide result type and param types manually
        UEXECUTER_FUNCTION_PROTOTYPE(add_f32_f64_i32, "add_f32_f64_i32", UEXECUTER_CALLER_TYPE_F64,
                                     UEXECUTER_CALLER_TYPE_F32, UEXECUTER_CALLER_TYPE_F64, UEXECUTER_CALLER_TYPE_I32), 
         // C++ only, use AUTO to automatically detect prototype
        UEXECUTER_FUNCTION_PROTOTYPE_AUTO(add_f32_f64, "add_f32_f64"),
    };
  2. Init the uexecuter system with your service:
    static uexecuter_t uexecuter;
    uexecuter_init(&uexecuter, my_uexecuter_service, UEXECUTER_SERVICE_N_FUNC(my_uexecuter_service));
  3. Configure your transport system and bind your uexecuter to it:
    static uexecuter_transport_stm32_t uexecuter_transport;
    uexecuter_transport_stm32_init(&uexecuter_transport, USART1);
    uexecuter_bind(&uexecuter, &uexecuter_transport.base);
    uexecuter_transport_stm32_begin(&uexecuter_transport);
    extern "C" void usart1_irq()
    {
        uexecuter_transport_stm32_handle_isr(&uexecuter_transport);
    }
    extern "C" void USART1_IRQHandler(void) // generated by STM32CubeMX, usually in stm32f4xx_it.c
    {
        return usart1_irq();
    }
  4. If you are going to calculate time elapsed, please make sure the interpret priority of SysTick is higher than that of USART.

LICENSE

Licensed under MPL-2.0

About

License:Mozilla Public License 2.0


Languages

Language:C 99.9%Language:Assembly 0.0%Language:C++ 0.0%Language:CMake 0.0%