Github Repo | C Header | C source | JS source |
---|---|---|---|
cesanta/mongoose-os | mgos_system.h | mgos_system.c | api_sys.js |
HAL that needs to be implemented for each hardware platform.
size_t mgos_get_heap_size(void);
Get system memory size.
size_t mgos_get_free_heap_size(void);
Get system free memory.
size_t mgos_get_min_free_heap_size(void);
Get minimal watermark of the system free memory.
size_t mgos_get_fs_memory_usage(void);
Get filesystem memory usage
size_t mgos_get_fs_size(void);
Get filesystem size. Deprecated, please use mgos_vfs_get_space_total("/") instead.
size_t mgos_get_free_fs_size(void);
Get filesystem free space. Deprecated, please use mgos_vfs_get_space_free("/") instead.
void mgos_fs_gc(void);
Garbage-collect filesystem
void mgos_wdt_feed(void);
Feed watchdog
void mgos_wdt_set_timeout(int secs);
Set watchdog timeout
void mgos_wdt_enable(void);
Enable watchdog
void mgos_wdt_disable(void);
Disable watchdog
void mgos_system_restart(void) __attribute__((noreturn));
Restart system
void mgos_msleep(uint32_t msecs);
Delay given number of milliseconds
void mgos_usleep(uint32_t usecs);
Delay given number of microseconds
void mgos_ints_disable(void);
Disable interrupts
void mgos_ints_enable(void);
Enable interrupts
typedef void (*mgos_cb_t)(void *arg);
Callback for
mgos_invoke_cb()
bool mgos_invoke_cb(mgos_cb_t cb, void *arg, bool from_isr);
Invoke a callback in the main MGOS event loop. Returns true if the callback has been scheduled for execution.
uint32_t mgos_get_cpu_freq(void);
Get the CPU frequency in Hz
struct mgos_rlock_type *mgos_rlock_create(void);
Create a recursive lock.
void mgos_rlock(struct mgos_rlock_type *l);
Acquire a recursive lock.
void mgos_runlock(struct mgos_rlock_type *l);
Release a recursive lock.
void mgos_rlock_destroy(struct mgos_rlock_type *l);
Destroy a recursive lock.
Sys._sbuf(len)
Helper function to allocate string of at least given length. Note that the resulting string is usually bigger than this, and it is always longer than 5 bytes; that's to guarantee that the string data is stored in a common buffer and not inlined into mjs_val_t, thus the buffer can be used as an "output" buffer: a string can be passed to some function which will alter the contents, and these changes will be visible to the caller.
Sys.calloc(nmemb, size)
Allocate a memory region.
Note: currently memory allocated this way must be explicitly released with
free()
.
Sys.total_ram()
Return total available RAM in bytes.
Sys.free_ram()
Return free available RAM in bytes.
Sys.reboot(ms)
Reboot the system after ms
milliseconds. Return value: none.
Sys.uptime()
Return number of seconds since last reboot.
Sys.usleep(microseconds)
Sleep given number of microseconds. Return value: none.
Sys.wdt_feed()
Feed the watchdog timer. Return value: none.
edit this doc