SemiDrive SSDK Appication Program Interface PTG3.0
Data Structures | Enumerations | Functions
sdrv_mbox.h File Reference
#include <types.h>
#include <compiler.h>
#include <sdrv_common.h>

Go to the source code of this file.

Data Structures

struct  sdrv_mbox_chan_req
 
struct  sdrv_mbox_config
 
struct  sdrv_mbox_chan
 
struct  sdrv_mbox_dev
 

Enumerations

enum  sdrv_mbox_rproc_t
 
enum  sdrv_mbox_addr_t
 

Functions

int sdrv_mbox_received (sdrv_mbox_chan_t *chan, uint8_t *data, uint32_t len)
 
status_t sdrv_mbox_send_nobuf (sdrv_mbox_chan_t *sdrv_chan, uint8_t *data, uint32_t len, uint32_t timeout)
 
status_t sdrv_mbox_send (sdrv_mbox_chan_t *sdrv_chan, uint8_t *data, uint32_t len, uint32_t timeout)
 
uint8_t * sdrv_mbox_alloc_buffer (sdrv_mbox_chan_t *sdrv_chan, uint32_t len)
 
status_t sdrv_mbox_send_nocopy (sdrv_mbox_chan_t *chan, uint8_t *data, uint32_t len, uint32_t timeout)
 
sdrv_mbox_chan_tsdrv_mbox_request_channel (sdrv_mbox_t *dev, sdrv_mbox_chan_req_t *chan_req)
 
status_t sdrv_mbox_release_channel (sdrv_mbox_chan_t *chan)
 
status_t sdrv_mbox_set_callback (sdrv_mbox_chan_t *chan, sdrv_mbox_rxcallback callback, void *arg)
 
uint32_t sdrv_mbox_mtu (sdrv_mbox_t *dev)
 
status_t sdrv_mbox_init (sdrv_mbox_t *dev, const sdrv_mbox_config_t *cfg)
 

Detailed Description

Revision History:

Macro Definition Documentation

◆ SDRV_MBOX_ANY_ADDR

#define SDRV_MBOX_ANY_ADDR   -1

◆ SDRV_MBOX_CHN_NUM

#define SDRV_MBOX_CHN_NUM   8U

◆ SDRV_MBOX_NO_WAIT

#define SDRV_MBOX_NO_WAIT   0U

◆ SDRV_MBOX_SHORT_BUF_LEN

#define SDRV_MBOX_SHORT_BUF_LEN   4U

◆ SDRV_MBOX_WAIT_FOREVER

#define SDRV_MBOX_WAIT_FOREVER   0xffffffffU

Typedef Documentation

◆ sdrv_mbox_chan_req_t

◆ sdrv_mbox_chan_t

◆ sdrv_mbox_config_t

◆ sdrv_mbox_rxcallback

typedef int(* sdrv_mbox_rxcallback) (void *arg, uint8_t *data, uint32_t len)

◆ sdrv_mbox_t

typedef struct sdrv_mbox_dev sdrv_mbox_t

Enumeration Type Documentation

◆ sdrv_mbox_addr_t

sdrv mbox address id

Mbox address id is used to define different mbox message types, especially for the frequent used messages, such as rpmsg or power-manage. Raw data (MBOX_ADDR_RAW) is usually chosen for the messages without any type.

Enumerator
MBOX_ADDR_INVALID 
MBOX_ADDR_RAW 
MBOX_ADDR_IPCC 
MBOX_ADDR_RPMSG 
MBOX_ADDR_PM 

◆ sdrv_mbox_error

mbox status error code.

Enumerator
SDRV_MBOX_STATUS_INVALID_MASTERID 
SDRV_MBOX_STATUS_LENGTH_ERROR 
SDRV_MBOX_STATUS_NO_CHANNEL 
SDRV_MBOX_STATUS_NO_MSG_BUFFER 
SDRV_MBOX_STATUS_TIMEOUT 

◆ sdrv_mbox_proc_id_t

Enumerator
MBOX_PROC_ID_SF 
MBOX_PROC_ID_SP0 
MBOX_PROC_ID_SP1 
MBOX_PROC_ID_SX0 
MBOX_PROC_ID_SX1 
MBOX_PROC_ID_NUM 

◆ sdrv_mbox_rproc_t

sdrv mbox remote processor bitmap

Multi remote processors can be combined by the symbol '|', for example, MBOX_RPROC_SF | MBOX_RPROC_SP0.

Enumerator
MBOX_RPROC_SF 
MBOX_RPROC_SP0 
MBOX_RPROC_SP1 
MBOX_RPROC_SX0 
MBOX_RPROC_SX1 

Function Documentation

◆ sdrv_mbox_alloc_buffer()

uint8_t * sdrv_mbox_alloc_buffer ( sdrv_mbox_chan_t sdrv_chan,
uint32_t  len 
)

sdrv mbox channel allocate buffer

This function allocates data buffers, and copy mailbox data to the buffers first. And then, another function (sdrv_mbox_send_nocopy) is called to send mailbox data.

Parameters
[in]chanmbox channel
[in]lendata length, unit: 2 bytes return buffer address

◆ sdrv_mbox_init()

status_t sdrv_mbox_init ( sdrv_mbox_t dev,
const sdrv_mbox_config_t cfg 
)

sdrv mbox init

This function initializes mailbox device.

Parameters
[in]devsdrv mbox device
[in]cfgsdrv mbox configuration

◆ sdrv_mbox_mtu()

uint32_t sdrv_mbox_mtu ( sdrv_mbox_t dev)

sdrv mbox get mtu

This function gets maximum transmission unit.

Parameters
[in]devsdrv mbox dev
Returns
mtu

◆ sdrv_mbox_received()

int sdrv_mbox_received ( sdrv_mbox_chan_t chan,
uint8_t *  data,
uint32_t  len 
)

sdrv mbox receive message

This function receives mailbox message data. It should be called before other core send mailbox data.

Parameters
[in]chansdrv mbox channel
[in]datamsg data
[in]msglen
Returns
receive result

◆ sdrv_mbox_release_channel()

status_t sdrv_mbox_release_channel ( sdrv_mbox_chan_t chan)

sdrv mbox release channel

Parameters
[in]chansdrv mbox chan
Returns
SDRV_STATUS_OK or error code

◆ sdrv_mbox_request_channel()

sdrv_mbox_chan_t * sdrv_mbox_request_channel ( sdrv_mbox_t dev,
sdrv_mbox_chan_req_t chan_req 
)

sdrv mbox client request channel

Parameters
[in]devmbox dev
[in]chan_reqmbox channel request param
Returns
mbox channel

◆ sdrv_mbox_send()

status_t sdrv_mbox_send ( sdrv_mbox_chan_t sdrv_chan,
uint8_t *  data,
uint32_t  len,
uint32_t  timeout 
)

sdrv mbox channel send data use message buf

This function is used to send mailbox data in standard flow:

  1. allocate data buffers
  2. copy data to the buffers
  3. send data from the buffers
Parameters
[in]chanmbox channel
[in]datadata ptr
[in]lendata length, unit: 2 bytes
[in]timeoutwait timeout(millisecond), timeout should not be too small. return send result

◆ sdrv_mbox_send_nobuf()

status_t sdrv_mbox_send_nobuf ( sdrv_mbox_chan_t sdrv_chan,
uint8_t *  data,
uint32_t  len,
uint32_t  timeout 
)

sdrv mbox channel send short data

This function is used to send mailbox data without buffers. The data length is not more than 4 bytes. The mailbox data will be saved in registers and send directly.

Parameters
[in]chanmbox channel
[in]datadata ptr
[in]lendata length, unit: 2 bytes
[in]timeoutwait timeout(millisecond), timeout should not be too small. return send result

◆ sdrv_mbox_send_nocopy()

status_t sdrv_mbox_send_nocopy ( sdrv_mbox_chan_t chan,
uint8_t *  data,
uint32_t  len,
uint32_t  timeout 
)

sdrv mbox channel send data no copy

This function is used to send mailbox data without repeating to copy data. This function is combined with the function sdrv_mbox_alloc_buffer, sending the data which have been stored in the buffer.

Parameters
[in]chanmbox channel
[in]datadata ptr
[in]lendata length, unit: 2 bytes
[in]timeoutwait timeout(millisecond), timeout should not be too small.
Returns
send result

◆ sdrv_mbox_set_callback()

status_t sdrv_mbox_set_callback ( sdrv_mbox_chan_t chan,
sdrv_mbox_rxcallback  callback,
void *  arg 
)

sdrv mbox set callback

This function sets mailbox callback function.

Parameters
[in]chansdrv mbox channel
[in]callbackcallback function
[in]argcallback argument
Returns
SDRV_STATUS_OK or error code