Developer World
Spresense Arduino Library v3.2.0-77d75a4
MPClass Class Reference

This is the interface for MP (Multi-Processor). More...

#include <MP.h>

Public Member Functions

int begin (int subid)
 Start communication with the other processor. More...
 
int end (int subid)
 End communication with the other processor. More...
 
int Send (int8_t msgid, uint32_t msgdata, int subid)
 Send any 32bit-data to the other processor. More...
 
int Recv (int8_t *msgid, uint32_t *msgdata, int subid)
 Receive any 32bit-data from the other processor. More...
 
int Send (int8_t msgid, void *msgaddr, int subid)
 Send the address of any message to the other processor. More...
 
int Recv (int8_t *msgid, void *msgaddr, int subid)
 Receive the address of any message from the other processor. More...
 
template<typename T >
int SendObject (T &t, int subid)
 Send any object to the other processor. More...
 
template<typename T >
int RecvObject (T &t, int subid)
 Receive any object from the other processor. More...
 
int SendWaitComplete (int subid)
 Wait for the object to be sent. More...
 
void RecvTimeout (uint32_t timeout)
 Set timeout of receiver. More...
 
uint32_t GetRecvTimeout ()
 Get timeout of receiver. More...
 
uint32_t Virt2Phys (void *virt)
 Convert virtual address to physical address. More...
 
void GetMemoryInfo (int &usedMem, int &freeMem, int &largestFreeMem)
 Get memory information. More...
 
void EnableConsole ()
 Enable console. More...
 
void DisableConsole ()
 Disable console. More...
 
void * AllocSharedMemory (size_t size)
 Allocate memory from shared memory. More...
 
void FreeSharedMemory (void *addr)
 Free memory from shared memory. More...
 

Detailed Description

This is the interface for MP (Multi-Processor).

Member Function Documentation

◆ begin()

int MPClass::begin ( int  subid)

Start communication with the other processor.

Parameters
[in]subid- SubCore number(1~5) launched from MainCore. If core is SubCore, call without this argument.
Returns
error code. It returns minus value on failure.
Return values
-22(-EINVAL)Invalid argument
-2(-ENOENT)No such SubCore program
-116(-ETIMEDOUT)No response of boot completion from SubCore

MainCore boots the specified SubCore. On the other hand, the launched SubCore notifies MainCore to boot completion by calling this API.

◆ end()

int MPClass::end ( int  subid)

End communication with the other processor.

Parameters
[in]subid- SubCore number(1~5) finalized from MainCore. If core is SubCore, this API does nothing.
Returns
error code. It returns minus value on failure.
Return values
-22(-EINVAL)Invalid argument
-19(-ENODEV)No such SubCore program

MainCore finalizes the specified SubCore.

◆ Send() [1/2]

int MPClass::Send ( int8_t  msgid,
uint32_t  msgdata,
int  subid 
)

Send any 32bit-data to the other processor.

Parameters
[in]msgid- user-defined message ID (0~127) It must be zero or positive value.
[in]msgdata- user-defined message data (32bit)
[in]subid- SubCore number(1~5) to send any message. If core is SubCore, send to MainCore by default.
Returns
error code. It returns minus value on failure.
Return values
-22(-EINVAL)Invalid argument
-19(-ENODEV)No such SubCore program

◆ Recv() [1/2]

int MPClass::Recv ( int8_t *  msgid,
uint32_t *  msgdata,
int  subid 
)

Receive any 32bit-data from the other processor.

Parameters
[out]msgid- pointer to user-defined message ID
[out]msgdata- pointer to user-defined message data (32bit)
[in]subid- SubCore number(1~5) to receive any message. If core is SubCore, receive from MainCore by default.
Returns
msgid or error code. It returns minus value on failure.
Return values
-22(-EINVAL)Invalid argument
-19(-ENODEV)No such SubCore program
-116(-ETIMEDOUT)Timeout to receive from other core

◆ Send() [2/2]

int MPClass::Send ( int8_t  msgid,
void *  msgaddr,
int  subid 
)

Send the address of any message to the other processor.

Parameters
[in]msgid- user-defined message ID (0~127) It must be zero or positive value.
[in]msgaddr- pointer to user-defined message address
[in]subid- SubCore number(1~5) to send any message. If core is SubCore, send to MainCore by default.
Returns
error code. It returns minus value on failure.
Return values
-22(-EINVAL)Invalid argument
-19(-ENODEV)No such SubCore program

◆ Recv() [2/2]

int MPClass::Recv ( int8_t *  msgid,
void *  msgaddr,
int  subid 
)

Receive the address of any message from the other processor.

Parameters
[out]msgid- pointer to user-defined message ID
[out]msgaddr- pointer to user-defined message address
[in]subid- SubCore number(1~5) to receive any message. If core is SubCore, receive from MainCore by default.
Returns
msgid or error code. It returns minus value on failure.
Return values
-22(-EINVAL)Invalid argument
-19(-ENODEV)No such SubCore program
-116(-ETIMEDOUT)Timeout to receive from other core

◆ SendWaitComplete()

int MPClass::SendWaitComplete ( int  subid)

Wait for the object to be sent.

Parameters
[in]subid- SubCore number(1~5) to send any message. If core is SubCore, send to MainCore by default.
Returns
error code. It returns minus value on failure.
Return values
-22(-EINVAL)Invalid argument
-19(-ENODEV)No such SubCore program
-116(-ETIMEDOUT)Timeout to receive from other core

Please call after SendObject().

◆ RecvTimeout()

void MPClass::RecvTimeout ( uint32_t  timeout)

Set timeout of receiver.

Parameters
[in]timeout- waiting time [msec] for reception. If MP_RECV_BLOCKING is specified, wait forever to receive. If MP_RECV_POLLING is specified, polling the received data without blocking.

◆ GetRecvTimeout()

uint32_t MPClass::GetRecvTimeout ( )

Get timeout of receiver.

Returns
timeout value

◆ Virt2Phys()

uint32_t MPClass::Virt2Phys ( void *  virt)

Convert virtual address to physical address.

Parameters
[in]virt- virtual address
Returns
physical address

◆ GetMemoryInfo()

void MPClass::GetMemoryInfo ( int &  usedMem,
int &  freeMem,
int &  largestFreeMem 
)

Get memory information.

Parameters
[out]usedMem- Total size of used memory [byte]
[out]freeMem- Total size of free memory [byte]
[out]largestFreeMem- Size of the largest continuous free memory [byte]

◆ EnableConsole()

void MPClass::EnableConsole ( )

Enable console.

This core uses console

◆ DisableConsole()

void MPClass::DisableConsole ( )

Disable console.

This core does not use console

◆ AllocSharedMemory()

void * MPClass::AllocSharedMemory ( size_t  size)

Allocate memory from shared memory.

Parameters
[in]size- size. This is align up to 128KByte.
Returns
memory allocated physical address If it fails to allocate memory, returns NULL.

◆ FreeSharedMemory()

void MPClass::FreeSharedMemory ( void *  addr)

Free memory from shared memory.

Parameters
[in]addr- address allocated by AllocSharedMemory().

The documentation for this class was generated from the following file: