Mailbox
Mailbox API Status
API |
BK7258 |
BK7258_cp1 |
---|---|---|
N |
Y |
|
N |
Y |
|
N |
Y |
|
N |
Y |
|
N |
Y |
|
N |
Y |
Mailbox UNIT Number
Capability |
BK7258 |
BK7258_cp1 |
---|---|---|
UNIT Number |
2 |
2 |
Mailbox API Reference
Header File
Functions
-
bk_err_t bk_mailbox_init(void)
Init the MAILBOX driver.
This API init the resoure common to all MAILBOXs:
Init MAILBOX driver control register
Configure MAILBOX interrupt handling function
This API should be called before any other MAILBOX APIs.
- Returns
BK_OK: succeed
others: other errors.
-
bk_err_t bk_mailbox_deinit(void)
Deinit the MAILBOX driver.
This API free all resource related to MAILBOX.
- Returns
BK_OK: succeed
others: other errors.
-
bk_err_t bk_mailbox_set_param(mailbox_data_t *data, uint32_t p0, uint32_t p1, uint32_t p2, uint32_t p3)
Configure the MAILBOX cmd and data.
This API is used to configure data. Write parameters to variables as required by the structure, mailbox_data_t.
example: mailbox_data_t send_data; uint32_t param0 = 123456; uint32_t param1 = 111; uint32_t param2 = 666; uint32_t param3 = 888; mailbox_set_param(&send_data, param0, param1, param2, param3);
- Returns
BK_OK: succeed
others: other errors.
-
bk_err_t bk_mailbox_recv_callback_register(mailbox_endpoint_t src, mailbox_endpoint_t dst, mailbox_callback_t callback)
Register the callback function for MAILBOX.
- Attention
src : Associated with the CPU that needs to send data dst : Associated with the CPU of the current code execution system callback: After receiving the data, it is transmitted to the correspongding processing function. example: The current code runs in CPU0 and receives data from CPU1.
src = MAILBOX_CPU1; dst = MAILBOX_CPU0; callback = receive_from_CPU_1;
- Returns
BK_OK: succeed
BK_ERR_MAILBOX_SRC_DST: MAILBOX data transmission direction error
BK_ERR_MAILBOX_CALLBACK: Insufficient space or wrong format of registered function, etc
others: other errors.
-
bk_err_t bk_mailbox_recv_callback_unregister(mailbox_endpoint_t src, mailbox_endpoint_t dst)
Unregister the callback function for MAILBOX.
- Attention
src : Associated with the CPU that needs to send data dst : Associated with the CPU of the current code execution system callback: After receiving the data, it is transmitted to the correspongding processing function. example: The current code runs in CPU0 and receives data from CPU1.
src = MAILBOX_CPU1 dst = MAILBOX_CPU0
- Returns
BK_OK: succeed
BK_ERR_MAILBOX_SRC_DST: MAILBOX data transmission direction error.
BK_ERR_MAILBOX_CALLBACK: Callback function is not registered.
others: other errors.
-
bk_err_t bk_mailbox_send(mailbox_data_t *data, mailbox_endpoint_t src, mailbox_endpoint_t dst, void *arg)
Unregister the callback function for MAILBOX.
example: The current code runs in CPU0 and send data to CPU1.
src = MAILBOX_ENDPOINT_CPU0 dst = MAILBOX_CPU1 data : mbx ('by mailbox_set_param(&mbx, p0, p1, p2, p3)')
- Attention
Before sending data, need to use the mailbox_set_param() to configure the data format.
- Returns
BK_OK: succeed
BK_ERR_MAILBOX_SRC_DST: MAILBOX data transmission direction error.
BK_ERR_MAILBOX_BOX: No empty box store data.
BK_ERR_MAILBOX_TIMEOUT: Timeout waiting for the opposite end to fetch data.
others: other errors.
Mailbox Typedefs
Header File
Structures
-
struct mailbox_data_t
A MAILBOX has multiple boxes, one box has four spaces to fill in data Define the meaning of each space by user.
|_____________________________| |_____________________________| |_____________________________| |_____________________________| | Mailbox0 | | Mailbox1 | |______________|______________| |______________|______________| | box0 | box1 | | box0 | box1 | | ____________ | ____________ | | ____________ | ____________ | | | param0 | | | param0 | | | | param0 | | | param0 | | | | param1 | | | param1 | | | | param1 | | | param1 | | | | param2 | | | param2 | | | | param2 | | | param2 | | | | param3 | | | param3 | | | | param3 | | | param3 | | | |__________| | |__________| | | |__________| | |__________| | | _____________|______________| |______________|______________| |_____________________________| |_____________________________|
Macros
-
BK_ERR_MAILBOX_SRC_DST
MAILBOX source address error
-
BK_ERR_MAILBOX_ID
MAILBOX BOX number error
-
BK_ERR_MAILBOX_FLAG
MAILBOX flag error
-
BK_ERR_MAILBOX_CALLBACK
MAILBOX callback function error
-
BK_ERR_MAILBOX_TIMEOUT
MAILBOX waite timeout
-
BK_ERR_MAILBOX_NOT_INIT
MAILBOX isnt init
-
BK_ERR_MAILBOX_REPEAT_INIT
MAILBOX repeat init
Type Definitions
-
typedef void (*mailbox_callback_t)(mailbox_data_t *data)
MAILBOX interrupt service routine.
Enumerations
-
enum mailbox_endpoint_t
Values:
-
enumerator MAILBOX_CPU0
MAILBOX CPU0 endpoint
-
enumerator MAILBOX_CPU1
MAILBOX CPU1 endpoint
-
enumerator MAILBOX_CPU2
MAILBOX CPU2 endpoint
-
enumerator MAILBOX_DSP
MAILBOX DSP endpoint
-
enumerator MAILBOX_BT
MAILBOX BT endpoint
-
enumerator MAILBOX_ENDPOINT_INVALID
MAILBOX invalid endpoint
-
enumerator MAILBOX_CPU0
Header File
Type Definitions
-
typedef uint32_t mailbox_id_t
-
typedef uint32_t mailbox_ep_config_t