A memory monitor module that uses the task_sched.h scheduler to periodically execute a task that sends messages about the content of specified memory locations via the task_tlv.h module. The set of monitored memory locations can be updated while the task scheduler is running.
memmon.h | A memory monitor module that uses the task_sched.h scheduler to periodically execute a task that sends messages about the content of specified memory locations via the task_tlv.h module. |
Data Types | |
Variables | |
memmon_ptr | The type of pointers to memory locations in the memory monitor API. |
memmon_cptr | The type of pointers to constant memory locations in the memory monitor API. |
Macros | |
MEMMON_MAKE_PTR | Converts a pointer to an arbitrary type into a pointer that is compatible with the memory monitor API (a memmon_ptr), without triggering compiler warnings. |
MEMMON_MAKE_CPTR | Converts a pointer to an arbitrary type into a pointer-to-constant that is compatible with the memory monitor API (a memmon_cptr), without triggering compiler warnings. |
memmon_spec | Specifies a memory monitor. |
Variables | |
ptr | Pointer to the memory location to monitor. |
size | Size in bytes of the memory location to monitor. |
delay_div | Notification rate divisor to apply to the monitor. |
delay_count | Used internally by the memory monitor task to keep track of the number of task executions since the lastest notification was sent. |
memmon_header | Specifies the byte format of a memory monitor notification header. |
Variables | |
mon_i | Index number of the memory monitor. |
ptr | Address of the monitored memory location. |
Global Variables | |
Macros | |
MEMMON_MAX_SIZE | Maximum size in bytes of a monitored memory location. |
Variables | |
memmon_max_monitors | The maximum number of simultaneously registered memory monitors. |
memmon_n_monitors | The number of registered memory monitors. |
memmon_msg_count | Number of notification attempts made by the memory monitor task. |
memmon_drop_count | Number of failed notification attempts made by the memory monitor task. |
memmon_free_ram | Available unused RAM in bytes. |
API Functions | |
Functions | |
memmon_get_free_ram | Obtains the amount of available unused RAM. |
memmon_init | Initializes the memory monitor module. |
memmon_add | Registers a memory monitor. |
memmon_remove | Unregisters a memory monitor with a specified index number. |
memmon_remove_ptr | Unregisters a memory monitor monitoring a specified location. |
memmon_shutdown | Shuts down the memory monitor module. |
Variables | |
memmon_ptr | The type of pointers to memory locations in the memory monitor API. |
memmon_cptr | The type of pointers to constant memory locations in the memory monitor API. |
Macros | |
MEMMON_MAKE_PTR | Converts a pointer to an arbitrary type into a pointer that is compatible with the memory monitor API (a memmon_ptr), without triggering compiler warnings. |
MEMMON_MAKE_CPTR | Converts a pointer to an arbitrary type into a pointer-to-constant that is compatible with the memory monitor API (a memmon_cptr), without triggering compiler warnings. |
Converts a pointer to an arbitrary type into a pointer that is compatible with the memory monitor API (a memmon_ptr), without triggering compiler warnings. Function-like macro.
P | A pointer. The macro will evaluate to a pointer containing the same address as this pointer. |
A memmon_ptr containing the same address as P.
Converts a pointer to an arbitrary type into a pointer-to-constant that is compatible with the memory monitor API (a memmon_cptr), without triggering compiler warnings. Function-like macro.
P | A pointer. The macro will evaluate to a pointer containing the same address as this pointer. |
A memmon_cptr containing the same address as P.
typedef struct memmon_spec
Specifies a memory monitor.
Variables | |
ptr | Pointer to the memory location to monitor. |
size | Size in bytes of the memory location to monitor. |
delay_div | Notification rate divisor to apply to the monitor. |
delay_count | Used internally by the memory monitor task to keep track of the number of task executions since the lastest notification was sent. |
Macros | |
MEMMON_MAX_SIZE | Maximum size in bytes of a monitored memory location. |
Variables | |
memmon_max_monitors | The maximum number of simultaneously registered memory monitors. |
memmon_n_monitors | The number of registered memory monitors. |
memmon_msg_count | Number of notification attempts made by the memory monitor task. |
memmon_drop_count | Number of failed notification attempts made by the memory monitor task. |
memmon_free_ram | Available unused RAM in bytes. |
extern ptrdiff_t memmon_free_ram
Available unused RAM in bytes. Updated at the start of each execution of the memory monitor task. Uses memmon_get_free_ram to obtain the amount of unused RAM.
Functions | |
memmon_get_free_ram | Obtains the amount of available unused RAM. |
memmon_init | Initializes the memory monitor module. |
memmon_add | Registers a memory monitor. |
memmon_remove | Unregisters a memory monitor with a specified index number. |
memmon_remove_ptr | Unregisters a memory monitor monitoring a specified location. |
memmon_shutdown | Shuts down the memory monitor module. |
ptrdiff_t memmon_get_free_ram( void )
Obtains the amount of available unused RAM.
NOTE: This function can be used even if the memory monitor module hasn’t been initialized with memmon_init.
Available free RAM in bytes.
void memmon_init( uint8_t task_num_cat, uint8_t max_mon, memmon_spec * mon_array, sched_time delay, uint8_t tlv_typ, uint8_t inm_dstadr )
Initializes the memory monitor module. Creates the memory monitor task.
CAUTION: This function MUST be called before any memory monitors are registered.
task_num_cat | A TCSB value (see sched_task) containing the task instance and category numbers that should be used by the memory monitor task. (The sleep bit is ignored.) |
max_mon | Maximum number of simultaneously registered memory monitors. |
mon_array | Pointer to memory where memmon_spec structs representing registered memory monitors should be stored. The specified memory location MUST be large enough to store at least max_mon such structs and remain valid until memmon_shutdown is called. |
delay | Scheduler delay of the memory monitor task. |
tlv_typ | TLV message type identifier to use for memory monitor notification messages (TTLV_MSG_T_MEMMON_DATA is recommended). |
inm_dstadr | INM destination address to use for memory monitor notification messages. |
uint8_t memmon_add( const memmon_spec * mon )
Registers a memory monitor.
mon | Pointer to a memmon_spec specifying the monitor to register. |
The index number of the registered memory monitor, or memmon_max_monitors if the monitor couldn’t be registered.
uint8_t memmon_remove_ptr( memmon_cptr mon_ptr )
Unregisters a memory monitor monitoring a specified location.
mon_ptr | Address of the memory location monitored by the monitor to unregister. |
A true value if and only if a matching registered memory monitor was found and removed by this call.
The type of pointers to memory locations in the memory monitor API.
typedef uint8_t *memmon_ptr
The type of pointers to constant memory locations in the memory monitor API.
typedef const uint8_t *memmon_cptr
Specifies a memory monitor.
typedef struct memmon_spec
Pointer to the memory location to monitor.
memmon_cptr ptr
Size in bytes of the memory location to monitor.
uint8_t size
Notification rate divisor to apply to the monitor.
uint8_t delay_div
Used internally by the memory monitor task to keep track of the number of task executions since the lastest notification was sent.
uint8_t delay_count
Specifies the byte format of a memory monitor notification header.
typedef struct __attribute__ ( (__packed__) ) memmon_header
Index number of the memory monitor.
uint8_t mon_i
Address of the monitored memory location.
memmon_cptr ptr
The maximum number of simultaneously registered memory monitors.
extern uint8_t memmon_max_monitors
The number of registered memory monitors.
extern uint8_t memmon_n_monitors
Number of notification attempts made by the memory monitor task.
extern uint16_t memmon_msg_count
Number of failed notification attempts made by the memory monitor task.
extern uint16_t memmon_drop_count
Available unused RAM in bytes.
extern ptrdiff_t memmon_free_ram
Obtains the amount of available unused RAM.
ptrdiff_t memmon_get_free_ram( void )
Initializes the memory monitor module.
void memmon_init( uint8_t task_num_cat, uint8_t max_mon, memmon_spec * mon_array, sched_time delay, uint8_t tlv_typ, uint8_t inm_dstadr )
Registers a memory monitor.
uint8_t memmon_add( const memmon_spec * mon )
Unregisters a memory monitor with a specified index number.
uint8_t memmon_remove( uint8_t mon_i )
Unregisters a memory monitor monitoring a specified location.
uint8_t memmon_remove_ptr( memmon_cptr mon_ptr )
Shuts down the memory monitor module.
void memmon_shutdown( void )
Represents an instance of a task that can be scheduled for execution.
typedef struct sched_task