Skip to content
Snippets Groups Projects
Select Git revision
  • 15bb6ac628c3f3ed68d947f00c272f1bb3600328
  • master default
  • analog_clock
  • mem_usage
  • longint_issue
  • more_fonts
  • more_fonts_ng
  • utime_time_ms
  • genofire/ble-personal_state
  • ios-workarounds
  • schneider/maxim-sdk-update
  • rahix/simple_menu
  • ch3/splashscreen
  • koalo/bhi160-works-but-dirty
  • koalo/wip/i2c-for-python
  • renze/safe_mode
  • renze/hatchery_apps
  • schneider/fundamental-test
  • koalo/factory-reset
  • msgctl/gfx_rle
  • msgctl/faultscreen
  • v1.4
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
29 results

genapi.py

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    mp_sys_kernel.c 13.26 KiB
    /// kernel is a micropython C module which allows access to the badge's
    /// 'kernel', ie. FreeRTOS/ESP-IDF/... This is a low-level API intended to be
    /// used for use by badge developers.
    
    #include <stdio.h>
    #include <string.h>
    #include "flow3r_bsp.h"
    #include "py/obj.h"
    #include "py/runtime.h"
    #include "st3m_console.h"
    #include "st3m_usb.h"
    #include "st3m_version.h"
    
    #if (configUSE_TRACE_FACILITY != 1)
    #error config_USE_TRACE_FACILITY must be set
    #endif
    
    /// task object which represents a snapshot of a FreeRTOS task at a given time.
    ///
    /// Properties:
    ///  - number: The FreeRTOS task number
    ///  - stack_left: High water mark of stack usage by task, ie. highest ever
    ///                recorded use of stack. The units seem arbitrary.
    ///  - run_time: The run time allocated to this task so far, as defined by the
    ///              FreeRTOS run time stats clock. The units are arbitrary and
    ///              should only be used comparatively against other task runtimes,
    ///              and the global total runtime value from scheduler_stats.
    ///  - state: one of kernel.{RUNNING,READY,BLOCKED,SUSPENDED,DELETED,INVALID}
    ///  - core_affinity: bitmask of where this task is allowed to be scheduled. Bit
    ///                   0 is core 0, bit 1 is core 1. The value 0b11 (3) means the
    ///                   task is allowed to run on any core.
    typedef struct _task_obj_t {
        mp_obj_base_t base;
    
        char name[configMAX_TASK_NAME_LEN];
        uint32_t number;
        uint16_t stack_left;
        uint32_t run_time;
        eTaskState state;
        uint32_t core_affinity;
    } task_obj_t;
    
    const mp_obj_type_t task_type;
    
    STATIC void task_print(const mp_print_t *print, mp_obj_t self_in,
                           mp_print_kind_t kind) {
        (void)kind;
        task_obj_t *self = MP_OBJ_TO_PTR(self_in);
        mp_print_str(print, "Task(name=");
        mp_print_str(print, self->name);
        mp_print_str(print, ",state=");
        switch (self->state) {
            case eRunning:
                mp_print_str(print, "RUNNING");
                break;
            case eReady:
                mp_print_str(print, "READY");
                break;
            case eBlocked:
                mp_print_str(print, "BLOCKED");
                break;
            case eSuspended:
                mp_print_str(print, "SUSPENDED");
                break;
            case eDeleted:
                mp_print_str(print, "DELETED");
                break;
            case eInvalid:
                mp_print_str(print, "INVALID");
                break;