Detailed Description
Mail box is one of the simplest way to communicate with the DSP. This mailbox implementation on top of libeasynmc implements the simplest possible mailbox with the following assumptions:
- One mail box can only contain one message at a time.
- Each time the mailbox status changes - an LP interrupt is issued by whoever made the change.
To actually use this API you have to declare one or more mailboxes in your DSP application. They are normally allocated in easyconf.asm using EASYNMC_MBOX() macro. Each mailbox will be placed in a dedicated section that will be used to identify it.
Each mailbox has dedicated message buffer associated with it. The size of the buffer is defined by the EASYNMC_MBOX() macro when compiling the DSP app. From the host application you can query buffer size using easynmc_mbox_get_size().
To actually attach the mailbox API to your DSP app you have to call easynmc_mbox_new() on an easynmc handle BEFORE calling easynmc_load_abs(); easynmc_mbox_new() will return a pointer you will be passing around all the mailbox API calls. After loading the abs file, you should call easynmc_mbox_available() which will tell you if the abs loader has located your mailbox correctly. If your DSP app lacks a corresponding section, this is the place for you to find out and handle the error.
The mailbox automatically becomes unavailable when the application is stopped. There's no need to free the mailbox before starting the app again - it will be attached on the next abs file load
When you are done working with a mailbox you can free it using easynmc_mbox_free(). Doing that when the application
Enumeration Type Documentation
Function Documentation
int easynmc_mbox_available |
( |
struct easynmc_sync * |
s | ) |
|
Returns non-zero value when the mailbox becomes valid, e.g. the abs loader located it's section. You should do this check every time you load a new abs file before doing any operations on an easynmc_sync.
- Parameters
-
- Returns
Definition at line 76 of file easynmc-bsync.c.
void easynmc_mbox_free |
( |
struct easynmc_sync * |
s | ) |
|
uint32_t* easynmc_mbox_get_buffer |
( |
struct easynmc_sync * |
s | ) |
|
Returns internal mmaped() data buffer of a sync
- Parameters
-
- Returns
Definition at line 177 of file easynmc-bsync.c.
int easynmc_mbox_get_size |
( |
struct easynmc_sync * |
s | ) |
|
int easynmc_mbox_get_status |
( |
struct easynmc_sync * |
s | ) |
|
Get сurrent sync status.
- Parameters
-
- Returns
Definition at line 199 of file easynmc-bsync.c.
Create a new mailbox and associate it with an easynmc handle. The mail box should be associated with the handle BEFORE the app is loaded into the nmc (e.g. call this BEFORE easynmc_load_abs())
- Parameters
-
h | easynmc handle |
section | section containing sync data. Define this in your easyconf.asm See nmc-examples/sync-example |
- Returns
Definition at line 64 of file easynmc-bsync.c.
int easynmc_mbox_post |
( |
struct easynmc_sync * |
s, |
|
|
uint32_t * |
data, |
|
|
uint32_t |
len |
|
) |
| |
Put data of len 32-bit words into the sync. The data length should not exceed the length allocated on the sync. Otherwise an error is returned. This function may block until the sync becomes ready for operation once more. For non-blocking alternative - see easynmc_mbox_post_nonblock()
- Parameters
-
- Returns
Definition at line 101 of file easynmc-bsync.c.
int easynmc_mbox_post_noblock |
( |
struct easynmc_sync * |
s, |
|
|
uint32_t * |
data, |
|
|
uint32_t |
len |
|
) |
| |
Non-blocking alternative. Returns -EAGAIN if sync is now owned by Neuromatrix
- Parameters
-
- Returns
Definition at line 114 of file easynmc-bsync.c.
int easynmc_mbox_recv |
( |
struct easynmc_sync * |
s, |
|
|
uint32_t * |
data, |
|
|
uint32_t * |
len |
|
) |
| |
Get data from a sync. The data is stored into the user buffer. The buffer should have sufficient space to store all the data that can be found in a sync. The actual length of the data retrieved is stored into len parameter. This function may block until sync becomes available. For non-blocking variant - see easynmc_sync_get_nonblock()
- Parameters
-
s | |
data | - pointer to store data from a sync |
len | - pointer to store length |
- Returns
Definition at line 131 of file easynmc-bsync.c.
int easynmc_mbox_recv_nonblock |
( |
struct easynmc_sync * |
s, |
|
|
uint32_t * |
data, |
|
|
uint32_t |
len |
|
) |
| |
Non-blocking alternative to easynmc_sync_get(). Returns -EAGAIN if the sync is in use by DSP core.
- Parameters
-
- Returns
Definition at line 145 of file easynmc-bsync.c.
void easynmc_mbox_set_status |
( |
struct easynmc_sync * |
s | ) |
|
Set сurrent sync status.
- Parameters
-
- Returns
Definition at line 188 of file easynmc-bsync.c.
Variable Documentation
uint32_t easynmc_mbox_data::data[] |
uint32_t easynmc_mbox_data::datalen |
uint32_t easynmc_mbox::offset |
uint32_t easynmc_mbox_data::sync_status |