ipc_queue.h
Sifli ipc_queue library interface.
- Author
Sifli software development team
Unnamed Group
-
IPC_QUEUE_INVALID_HANDLE
Invalid queue handle
-
typedef int32_t ipc_queue_handle_t
IPC queue handle type
-
typedef int32_t (*ipc_queue_rx_ind_t)(ipc_queue_handle_t handle, size_t size)
IPC queue rx callback type
-
ipc_queue_handle_t ipc_queue_init(ipc_queue_cfg_t *q_cfg)
Initialize one IPC queue according to the q_cfg
A valid queue handle is returned if queue is intialized succesfully. The queue with same queue id cannot be initialized twice.
- 参数:
q_cfg – [in] queue configuration
- 返回:
queue handle, IPC_QUEUE_INVALID_HANDLE denotes initialization failure
-
int32_t ipc_queue_get_user_data(ipc_queue_handle_t handle, uint32_t *user_data)
Get user data
- 参数:
handle – [in] queue handle
user_data – [inout] user data is saved in the memory pointed by user_data pointer
- 返回:
status, 0: success, otherwise: error
-
int32_t ipc_queue_set_user_data(ipc_queue_handle_t handle, uint32_t user_data)
Set user data
- 参数:
handle – [in] queue handle
user_data – [in] user data
- 返回:
status, 0: success, otherwise: error
-
int32_t ipc_queue_open(ipc_queue_handle_t handle)
Open the IPC queue
After opened, the queue is ready to receive and send data. As all queues share the same IRQ, receiver side may see the interrupt even if it has not opened the queue, it means the registered callback is not called when interrupt is triggered.
- 参数:
handle – [in] queue handle
- 返回:
status, 0: success, otherwise: error
-
int32_t ipc_queue_open2(ipc_queue_handle_t handle)
New implementation for opening the IPC queue to solve rx callback loss issue.
After opened, the queue is ready to receive and send data. If receiver has not opened the queue, it would not receive interrupt even if sender has opened the queue and send the data.
- 参数:
handle – [in] queue handle
- 返回:
status, 0: success, otherwise: error
-
bool ipc_queue_is_open(ipc_queue_handle_t handle)
Check whether the IPC queue is open
- 参数:
handle – [in] queue handle
- 返回:
true: open, false: not open
-
int32_t ipc_queue_close(ipc_queue_handle_t handle)
Close the IPC queue
After closing the queue, it cannot receive and send data. The interrupt might still be received if sender doesn’t close the queue and send data.
- 参数:
handle – [in] queue handle
- 返回:
status, 0: success, otherwise: error
-
int32_t ipc_queue_close2(ipc_queue_handle_t handle)
New implementation for closing the IPC queue to solve unexpected interrupt issue
After closing the queue, it cannot receive and send data.
- 参数:
handle – [in] queue handle
- 返回:
status, 0: success, otherwise: error
-
int32_t ipc_queue_deinit(ipc_queue_handle_t handle)
Deinitialize the IPC queue
After deinitializatio the queue with same queue id can be intialized again.
- 参数:
handle – [in] queue handle
- 返回:
status, 0: success, otherwise: error
-
size_t ipc_queue_read(ipc_queue_handle_t handle, void *buffer, size_t size)
Read data from IPC queue
Data is read from rx buffer to saved in buffer
- 参数:
handle – [in] queue handle
buffer – [in] point to the buffer to save read data
size – [in] size of data to be read
- 返回:
actual size of data that has been read
-
size_t ipc_queue_write(ipc_queue_handle_t handle, const void *buffer, size_t size, uint32_t timeout)
Write data to IPC queue and inform the receiver to read
Data is written to tx buffer, interrupt is triggered to inform the receiver. The API is not thread-safe. It should be avoided to write the same queue in different threads.
- 参数:
handle – [in] queue handle
buffer – [in] data buffer
size – [in] size of data to be written
timeout – [in] time to wait if tx buffer is full, the unit is HAL_GetTick
- 返回:
actual size of data that has been written
-
bool ipc_queue_check_idle(void)
Check whether ipc queue is idle from sender perspective
If all tx_buffer are empty, it’s idle, even though rx_buffer is not empty
- 返回:
true: idle, false: not idle
-
bool ipc_queue_check_idle_rom(void)
ipc_queue_check_idle ROM implementation placeholder
Weak function, can be replaced by ROM symbol. If not use ROM symbol, it’s same as ipc_queue_check_idle.
- 返回:
true: idle, false: not idle
-
void ipc_queue_restore_all(void)
Restore IPC queue hardware setting
HW setting may get lost if the power domain is powered off, if the software configuration is present, this function can be used to restore the hw setting after power domain is powered on.
- 返回:
void
-
void ipc_queue_restore_all_rom(void)
ipc_queue_restore_all ROM implementation placeholder
Weak function, can be replaced by ROM symbol. If not use ROM symbol, it’s same as ipc_queue_restore_all.
- 返回:
void
-
size_t ipc_queue_get_rx_size(ipc_queue_handle_t handle)
Get available data size in rx buffer
- 参数:
handle – [in] queue handle
- 返回:
data size in rx buffer
-
struct ipc_queue_cfg_t
- #include <ipc_queue.h>
IPC queue configuration
Public Members
-
uint8_t qid
queue id, starting from 0, numbering across all queues in all channels,
参见
ipc_hw_port.h
-
uint32_t rx_buf_addr
rx buffer address from the view of receiver side
-
uint32_t tx_buf_addr
tx buffer address from the view of sender side
-
uint32_t tx_buf_addr_alias
tx buffer address from the view of receiver side
-
uint32_t tx_buf_size
tx buffer size in byte
-
ipc_queue_rx_ind_t rx_ind
rx notification callback
-
uint32_t user_data
user data
-
uint8_t qid