1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
#include "msgbox_sx.h"
#include "FreeRTOS.h"
#include "hal_msgbox.h"
#include "../platform-msgbox.h"
struct msgbox_adapt {
struct messagebox *msgbox;
struct msg_channel *msg_ch_send;
struct msg_channel *msg_ch_rec;
struct msg_endpoint *edp;
};
uint32_t hal_msgbox_init(void)
{
return messagebox_init_sx();
}
static int func_cb_tx(unsigned long i, void *d)
{
struct msgbox_adapt *adp = d;
struct msg_endpoint *edp = adp->edp;
if (edp->tx_done)
edp->tx_done(edp->data);
return 0;
}
static int func_cb_rec(unsigned long i, void *d)
{
struct msgbox_adapt *adp = d;
struct msg_endpoint *edp = adp->edp;
if (edp->rec)
edp->rec(i, edp->data);
return 0;
}
uint32_t hal_msgbox_alloc_channel(struct msg_endpoint *edp, uint32_t remote,
uint32_t read, uint32_t write)
{
struct msgbox_adapt *adp;
struct messagebox *msg;
struct msg_channel *chl;
if (edp->remote_amp == ARM_MSG_CORE)
msg = msgbox_cpu;
else
msg = msgbox_dsp;
adp = pvPortMalloc(sizeof(struct msgbox_adapt));
adp->msgbox = msg;
adp->edp = edp;
edp->private = adp;
chl = msgbox_alloc_channel_sx(msg, read, MSGBOX_CHANNEL_RECEIVE,
func_cb_rec, adp);
adp->msg_ch_rec = chl;
chl = msgbox_alloc_channel_sx(msg, write, MSGBOX_CHANNEL_SEND,
func_cb_tx, adp);
adp->msg_ch_send = chl;
return 0;
}
uint32_t hal_msgbox_channel_send(struct msg_endpoint *edp, uint8_t *bf,
uint32_t len)
{
struct msgbox_adapt *adp = edp->private;
return msgbox_channel_send_data_sx(adp->msg_ch_send, bf, len);
}
void hal_msgbox_free_channel(struct msg_endpoint *edp)
{
struct msgbox_adapt *adp = edp->private;
msgbox_free_channel_sx(adp->msgbox, adp->msg_ch_rec);
msgbox_free_channel_sx(adp->msgbox, adp->msg_ch_send);
vPortFree(adp);
}
|