Azure Sphere MT3620 M4 API Reference Manual
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Function

This section provides high level APIs to upper layer. More...

Overview

This section provides high level APIs to upper layer.

Functions

int mtk_os_hal_mbox_open_channel (mbox_channel_t channel)
 Open MBOX channel. More...
 
int mtk_os_hal_mbox_close_channel (mbox_channel_t channel)
 Close MBOX channel. More...
 
int mtk_os_hal_mbox_fifo_read (mbox_channel_t channel, struct mbox_fifo_item *buf, mbox_tr_type_t type)
 This function is used to read MBOX channel FIFO data. More...
 
int mtk_os_hal_mbox_fifo_write (mbox_channel_t channel, const struct mbox_fifo_item *buf, mbox_tr_type_t type)
 This function is used to write data to MBOX channel FIFO. More...
 
int mtk_os_hal_mbox_ioctl (mbox_channel_t channel, mbox_ioctl_t ctrl, void *arg)
 Control various hardware settings of MBOX. More...
 
int mtk_os_hal_mbox_sw_int_register_cb (mbox_channel_t channel, mtk_os_hal_mbox_cb cb, u32 irq_status)
 This function is used to register user software interrupt callback. More...
 
int mtk_os_hal_mbox_sw_int_unregister_cb (mbox_channel_t channel)
 This function is used to unregister user software interrupt callback. More...
 
int mtk_os_hal_mbox_fifo_register_cb (mbox_channel_t channel, mtk_os_hal_mbox_cb cb, struct mbox_fifo_event *mask)
 This function is used to register user FIFO interrupt callback. More...
 
int mtk_os_hal_mbox_fifo_unregister_cb (mbox_channel_t channel)
 This function is used to unregister user FIFO interrupt callback. More...
 

Function Documentation

int mtk_os_hal_mbox_open_channel ( mbox_channel_t  channel)

Open MBOX channel.

Parameters
[in]channel: MBOX channel, it can be OS_HAL_MBOX_CH0~OS_HAL_MBOX_CH1.
Returns
MBOX_OK means success.
-MBOX_EDEFAULT means fail.
int mtk_os_hal_mbox_close_channel ( mbox_channel_t  channel)

Close MBOX channel.

Parameters
[in]channel: MBOX channel, it can be OS_HAL_MBOX_CH0~OS_HAL_MBOX_CH1.
Returns
MBOX_OK means success.
-MBOX_EDEFAULT means fail.
int mtk_os_hal_mbox_fifo_read ( mbox_channel_t  channel,
struct mbox_fifo_item buf,
mbox_tr_type_t  type 
)

This function is used to read MBOX channel FIFO data.

Usage: Reading data and/or cmd from FIFO when receiving write interrupt or non-empty interrupt.

Parameters
[in]channel: MBOX channel.
[out]buf: Buffer to load data and/or cmd.
[in]type: Transfer type; see mbox_tr_type_t for details.
Returns
Return MBOX_OK if reading succeeds.
Return others if reading fails.
int mtk_os_hal_mbox_fifo_write ( mbox_channel_t  channel,
const struct mbox_fifo_item buf,
mbox_tr_type_t  type 
)

This function is used to write data to MBOX channel FIFO.

Usage: Writing data and/or cmd to FIFO.

Parameters
[in]channel: MBOX channel.
[in]buf: The data and/or cmd to be transferred.
[in]type: Transfer type; see mbox_tr_type_t for details.
Returns
Return MBOX_OK if writing succeeds.
Return others if writing fails.
int mtk_os_hal_mbox_ioctl ( mbox_channel_t  channel,
mbox_ioctl_t  ctrl,
void *  arg 
)

Control various hardware settings of MBOX.

Usage: Getting/setting MBOX hardware settings.

Parameters
[in]channel: MBOX channel.
[in]ctrl:
Operation on Non-Full/Non-Empty threshold values:
MBOX_IOSET_NE_THRS,
MBOX_IOGET_NE_THRS,
MBOX_IOSET_NF_THRS,
MBOX_IOGET_NF_THRS.

Hardware semaphore operations:
MBOX_IOSET_SEM_POST,
MBOX_IOSET_SEM_PEND.

Software interrupt operations:
MBOX_IOSET_SWINT_TRIG,
MBOX_IOSET_SWINT_EN,
MBOX_IOGET_SWINT_EN,
MBOX_IOSET_SWINT_CTRL,
MBOX_IOGET_SWINT_STS,
MBOX_IOSET_CLEAR_SWINT.

FIFO interrupt operations:
MBOX_IOSET_INT_EN,
MBOX_IOGET_INT_EN,
MBOX_IOGET_INT_STS,
MBOX_IOSET_CLEAR_INT.

Get FIFO count values:
MBOX_IOGET_POST_FIFO_CNT,
MBOX_IOGET_ACPT_FIFO_CNT.
[in]arg:
MBOX_IOSET_NE_THRS: u32*, threshold value;
MBOX_IOSET_NF_THRS: u32*, threshold value;

MBOX_IOSET_SEM_POST: not used;

MBOX_IOSET_SWINT_TRIG: u32*, interrupt number (0 ~ 7);
MBOX_IOSET_SWINT_EN: u32*, interrupt mask (0 ~ 0xFF);
MBOX_IOSET_SWINT_CTRL: struct mbox_swint_arg*;
MBOX_IOSET_CLEAR_SWINT: u32*, software interrupt mask to be cleared;

MBOX_IOSET_INT_EN: struct mbox_int_arg*;
MBOX_IOSET_CLEAR_INT: struct mbox_int_arg*;

[out]arg:
MBOX_IOGET_NE_THRS: u32*, buffer to load threshold value;
MBOX_IOGET_NF_THRS: u32*, buffer to load threshold value;

MBOX_IOSET_SEM_PEND: u32*, buffer to load sema status;

MBOX_IOGET_SWINT_EN: u32*, buffer to load sw int mask;
MBOX_IOGET_SWINT_STS: u32*, buffer to load the status value;

MBOX_IOGET_INT_EN: struct mbox_fifo_event*, buffer to load int mask;
MBOX_IOGET_INT_STS: struct mbox_fifo_event*, to load int status;

MBOX_IOGET_POST_FIFO_CNT: u32*, buffer to load the FIFO count which indicates how many elements have already been written;
MBOX_IOGET_ACPT_FIFO_CNT: u32*, buffer to load the FIFO count which indicates how many elements can be read.
Returns
Return MBOX_OK if operation succeeds.
Return others if operation fails .
int mtk_os_hal_mbox_sw_int_register_cb ( mbox_channel_t  channel,
mtk_os_hal_mbox_cb  cb,
u32  irq_status 
)

This function is used to register user software interrupt callback.

Parameters
[in]channel: MBOX channel.
[in]cb: User callback funtion pointer.
[in]irq_status: Software interrupt enable mask. Set irq_status bit[i] = 1 to enable software interrupt #i, i = 0~7.
Returns
Return MBOX_OK if registration succeeds.
Return others if registration fails.
int mtk_os_hal_mbox_sw_int_unregister_cb ( mbox_channel_t  channel)

This function is used to unregister user software interrupt callback.

Parameters
[in]channel: MBOX channel.
Returns
Return MBOX_OK if unregistration succeeds.
Return -MBOX_EDEFAULT if unregistration fails.
int mtk_os_hal_mbox_fifo_register_cb ( mbox_channel_t  channel,
mtk_os_hal_mbox_cb  cb,
struct mbox_fifo_event mask 
)

This function is used to register user FIFO interrupt callback.

Parameters
[in]channel: MBOX channel.
[in]cb: User callback funtion pointer.
[in]mask: Fifo interrupt enable mask.
Returns
Return MBOX_OK if registration succeeds.
Return others if registration fails.
int mtk_os_hal_mbox_fifo_unregister_cb ( mbox_channel_t  channel)

This function is used to unregister user FIFO interrupt callback.

Parameters
[in]channel: MBOX channel.
Returns
Return MBOX_OK if unregistration succeeds.
Return -MBOX_EDEFAULT if unregistration fails.