127#ifndef MMOSAL_TRACK_ALLOCATIONS
137#define mmosal_malloc(size) mmosal_malloc_(size)
149#define mmosal_malloc(size) mmosal_malloc_dbg(size, __func__, __LINE__)
203 unsigned stack_size_u32,
const char *name);
240#define MMOSAL_TASK_ENTER_CRITICAL() \
243 mmosal_task_enter_critical(); \
251#define MMOSAL_TASK_EXIT_CRITICAL() \
254 mmosal_task_exit_critical(); \
354#define MMOSAL_MUTEX_GET_INF(_mutex) \
356 bool ok__ = mmosal_mutex_get((_mutex), UINT32_MAX); \
357 MMOSAL_ASSERT(ok__); \
363#define MMOSAL_MUTEX_RELEASE(_mutex) \
365 bool ok__ = mmosal_mutex_release(_mutex); \
366 MMOSAL_ASSERT(ok__); \
404struct mmosal_sem *
mmosal_sem_create(
unsigned max_count,
unsigned initial_count,
const char *name);
664 return ((int32_t)(a - b)) < 0;
687 return ((int32_t)(a - b)) <= 0;
856#define MMOSAL_FILEID 0
863#ifndef MMOSAL_MAX_FAILURE_RECORDS
864#define MMOSAL_MAX_FAILURE_RECORDS 4
891#ifdef MMOSAL_NO_DEBUGLOG
893#define MMOSAL_LOG_FAILURE_INFO(...)
897#define MMOSAL_LOG_FAILURE_INFO(...) \
900 struct mmosal_failure_info info = { \
901 .lr = (uint32_t)MMPORT_GET_LR(), \
902 .fileid = MMOSAL_FILEID, \
904 .platform_info = { __VA_ARGS__ }, \
907 info.pc = (uint32_t)pc; \
908 mmosal_log_failure_info(&info); \
919#ifndef MMOSAL_NOASSERT
927#define MMOSAL_ASSERT(expr) \
930 MMOSAL_LOG_FAILURE_INFO(0); \
931 mmosal_impl_assert(); \
945#ifndef MMOSAL_ASSERT_LOG_DATA
946#define MMOSAL_ASSERT_LOG_DATA(expr, ...) \
949 MMOSAL_LOG_FAILURE_INFO(__VA_ARGS__); \
950 mmosal_impl_assert(); \
958#define MMOSAL_ASSERT(expr) (void)(expr)
960#define MMOSAL_ASSERT_LOG_DATA(expre, ...) (void)(expr)
963#ifdef ENABLE_MMOSAL_DEV_ASSERT
965#define MMOSAL_DEV_ASSERT(x) MMOSAL_ASSERT(x)
968#define MMOSAL_DEV_ASSERT_LOG_DATA(x, ...) MMOSAL_ASSERT_LOG_DATA(x, __VA_ARGS__)
971#define MMOSAL_DEV_ASSERT(x) ((void)(x))
974#define MMOSAL_DEV_ASSERT_LOG_DATA(x, ...) ((void)(x))
977#if defined(ENABLE_MANUAL_FAILURE_LOG_PROCESSING) && ENABLE_MANUAL_FAILURE_LOG_PROCESSING
1039 strncpy(dst, src, size);
1041 ret = dst[size-1] !=
'\0';
1057#ifndef MMOSAL_DEPRECATED_API_ENABLED
1060#define MMOSAL_DEPRECATED_API_ENABLED (1)
1063#if MMOSAL_DEPRECATED_API_ENABLED
void mmosal_log_failure_info(const struct mmosal_failure_info *info)
Log failure information in a way that it is preserved across reboots so that it can be available for ...
void mmosal_impl_assert(void)
Assertion handler implementation.
void mmosal_task_join(struct mmosal_task *task)
Block until the given task has terminated.
void mmosal_task_notify_from_isr(struct mmosal_task *task)
Notifies a waiting task (mmosal_task_wait_for_notification()) that it can continue.
void mmosal_task_notify(struct mmosal_task *task)
Notifies a waiting task (mmosal_task_wait_for_notification()) that it can continue.
bool mmosal_task_wait_for_notification(uint32_t timeout_ms)
Blocks the current task until a notification is received.
int mmosal_main(mmosal_app_init_cb_t app_init_cb)
OS main function.
void(* mmosal_app_init_cb_t)(void)
Application initialization callback (see mmosal_main for details).
void * mmosal_calloc(size_t nitems, size_t size)
Equivalent of standard library calloc().
void * mmosal_malloc_dbg(size_t size, const char *name, unsigned line_number)
Allocate memory of the given size and return a pointer to it (malloc) – debug version.
void mmosal_free(void *p)
Free the given memory allocation.
void * mmosal_malloc_(size_t size)
Allocate memory of the given size and return a pointer to it (malloc).
void * mmosal_realloc(void *ptr, size_t size)
Equivalent of standard library realloc().
int mmosal_printf(const char *format,...)
OS abstracted version of printf used by morselib.
static bool mmosal_safer_strcpy(char *dst, const char *src, size_t size)
A safer version of strncpy.
struct mmosal_mutex * mmosal_mutex_create(const char *name)
Create a new mutex.
bool mmosal_mutex_is_held_by_active_task(struct mmosal_mutex *mutex)
Check whether the given mutex is held by the active thread.
bool mmosal_mutex_release(struct mmosal_mutex *mutex)
Release a mutex.
void mmosal_mutex_delete(struct mmosal_mutex *mutex)
Delete a mutex.
bool mmosal_mutex_get(struct mmosal_mutex *mutex, uint32_t timeout_ms)
Acquire a mutex.
bool mmosal_queue_pop_from_isr(struct mmosal_queue *queue, void *item)
Pop an item from the queue (from ISR context).
struct mmosal_queue * mmosal_queue_create(size_t num_items, size_t item_size, const char *name)
Create a new queue.
bool mmosal_queue_push(struct mmosal_queue *queue, const void *item, uint32_t timeout_ms)
Push an item into the queue.
void mmosal_queue_delete(struct mmosal_queue *queue)
Delete a queue.
bool mmosal_queue_push_from_isr(struct mmosal_queue *queue, const void *item)
Push an item into the queue (from ISR context).
bool mmosal_queue_pop(struct mmosal_queue *queue, void *item, uint32_t timeout_ms)
Pop an item from the queue.
bool mmosal_semb_give_from_isr(struct mmosal_semb *semb)
Give a binary semaphore (from ISR context).
bool mmosal_semb_wait(struct mmosal_semb *semb, uint32_t timeout_ms)
Wait for a counting semaphore.
struct mmosal_semb * mmosal_semb_create(const char *name)
Create a new binary semaphore.
bool mmosal_semb_give(struct mmosal_semb *semb)
Give a binary semaphore.
void mmosal_semb_delete(struct mmosal_semb *semb)
Delete the given binary semaphore.
bool mmosal_sem_give(struct mmosal_sem *sem)
Give a counting semaphore.
void mmosal_sem_delete(struct mmosal_sem *sem)
Delete the given counting semaphore.
bool mmosal_sem_give_from_isr(struct mmosal_sem *sem)
Give a counting semaphore (from ISR context).
struct mmosal_sem * mmosal_sem_create(unsigned max_count, unsigned initial_count, const char *name)
Create a new counting semaphore.
uint32_t mmosal_sem_get_count(struct mmosal_sem *sem)
Returns the current count of the semaphore.
bool mmosal_sem_wait(struct mmosal_sem *sem, uint32_t timeout_ms)
Wait for a counting semaphore.
struct mmosal_task * mmosal_task_create(mmosal_task_fn_t task_fn, void *argument, enum mmosal_task_priority priority, unsigned stack_size_u32, const char *name)
Create a new task.
void mmosal_task_yield(void)
Yield the active task.
struct mmosal_task * mmosal_task_get_active(void)
Get the handle of the active task.
void mmosal_task_exit_critical(void)
Exit critical section.
void mmosal_enable_interrupts(void)
Enable interrupts.
const char * mmosal_task_name(void)
Get the name of the running task.
void mmosal_task_sleep(uint32_t duration_ms)
Sleep for a period of time, yielding during that time.
void(* mmosal_task_fn_t)(void *arg)
Type definition for task main functions.
void mmosal_disable_interrupts(void)
Disable interrupts.
void mmosal_task_delete(struct mmosal_task *task)
Delete the given task.
void mmosal_task_enter_critical(void)
Enter critical section.
mmosal_task_priority
Enumeration of task priorities (ordered lowest to highest).
@ MMOSAL_TASK_PRI_LOW
Low priority.
@ MMOSAL_TASK_PRI_MIN
Minimum priority.
@ MMOSAL_TASK_PRI_HIGH
High priority.
@ MMOSAL_TASK_PRI_NORM
Normal priority.
@ MMOSAL_TASK_PRI_IDLE
Idle task priority.
bool mmosal_timer_start(struct mmosal_timer *timer)
Start a timer.
void mmosal_timer_delete(struct mmosal_timer *timer)
Delete a timer.
bool mmosal_timer_change_period(struct mmosal_timer *timer, uint32_t new_period)
Change timer period.
bool mmosal_is_timer_active(struct mmosal_timer *timer)
Queries the timer to determine if it running.
void * mmosal_timer_get_arg(struct mmosal_timer *timer)
Get the opaque argument associated with a given timer.
void(* timer_callback_t)(struct mmosal_timer *timer)
Function type definition for timer callbacks.
bool mmosal_timer_stop(struct mmosal_timer *timer)
Stop a timer.
struct mmosal_timer * mmosal_timer_create(const char *name, uint32_t timer_period_ms, bool auto_reload, void *arg, timer_callback_t callback)
Create a new timer.
uint32_t mmosal_get_time_ms(void)
Get the system time in milliseconds.
static uint32_t mmosal_time_max(uint32_t a, uint32_t b)
Given two times, return the one that is greatest (taking into account wrapping).
uint32_t mmosal_ticks_per_second(void)
Get the number of ticks in a second.
static bool mmosal_time_le(uint32_t a, uint32_t b)
Check if time a is less than or equal to time b, taking into account wrapping.
uint32_t mmosal_get_time_ticks(void)
Get the system time in ticks.
static bool mmosal_time_has_passed(uint32_t t)
Check if the given time has already passed.
static bool mmosal_time_lt(uint32_t a, uint32_t b)
Check if time a is less than time b, taking into account wrapping.
char buf[1408]
Statically allocated buffer for HTTP GET request, just under 1 packet size.
Data structure used to store information about a failure that can be preserved across reset.
uint32_t fileid
File identifier.
uint32_t pc
Content of the PC register at assertion.
uint32_t lr
Content of the LR register at assertion.
uint32_t line
Source code line at which the assertion was triggered.
uint32_t platform_info[4]
Arbitrary platform-specific failure info.