• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef __HAL_MCU2CP_H__
16 #define __HAL_MCU2CP_H__
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 #include "stdbool.h"
23 
24 enum HAL_MCU2CP_ID_T {
25     HAL_MCU2CP_ID_0,
26     HAL_MCU2CP_ID_1,
27     HAL_MCU2CP_ID_QTY
28 };
29 
30 typedef unsigned int (*HAL_MCU2CP_RX_IRQ_HANDLER)(const unsigned char *data, unsigned int len);
31 typedef void (*HAL_MCU2CP_TX_IRQ_HANDLER)(const unsigned char *data, unsigned int len);
32 
33 int hal_mcu2cp_open_mcu(enum HAL_MCU2CP_ID_T id,
34                         HAL_MCU2CP_RX_IRQ_HANDLER rxhandler, HAL_MCU2CP_TX_IRQ_HANDLER txhandler, bool rx_flowctrl);
35 int hal_mcu2cp_open_cp (enum HAL_MCU2CP_ID_T id,
36                         HAL_MCU2CP_RX_IRQ_HANDLER rxhandler, HAL_MCU2CP_TX_IRQ_HANDLER txhandler, bool rx_flowctrl);
37 
38 int hal_mcu2cp_close_mcu(enum HAL_MCU2CP_ID_T id);
39 int hal_mcu2cp_close_cp (enum HAL_MCU2CP_ID_T id);
40 
41 int hal_mcu2cp_start_recv_mcu(enum HAL_MCU2CP_ID_T id);
42 int hal_mcu2cp_start_recv_cp (enum HAL_MCU2CP_ID_T id);
43 
44 int hal_mcu2cp_stop_recv_mcu(enum HAL_MCU2CP_ID_T id);
45 int hal_mcu2cp_stop_recv_cp (enum HAL_MCU2CP_ID_T id);
46 
47 int hal_mcu2cp_send_mcu(enum HAL_MCU2CP_ID_T id,
48                     const unsigned char *data, unsigned int len);
49 int hal_mcu2cp_send_cp (enum HAL_MCU2CP_ID_T id,
50                     const unsigned char *data, unsigned int len);
51 
52 void hal_mcu2cp_rx_done_mcu(enum HAL_MCU2CP_ID_T id);
53 void hal_mcu2cp_rx_done_cp (enum HAL_MCU2CP_ID_T id);
54 
55 int hal_mcu2cp_opened_mcu(enum HAL_MCU2CP_ID_T id);
56 int hal_mcu2cp_opened_cp(enum HAL_MCU2CP_ID_T id);
57 
58 int hal_mcu2cp_local_irq_pending_mcu(enum HAL_MCU2CP_ID_T id);
59 int hal_mcu2cp_local_irq_pending_cp(enum HAL_MCU2CP_ID_T id);
60 
61 void hal_mcu2cp_poll_tx_irq_mcu(enum HAL_MCU2CP_ID_T id);
62 void hal_mcu2cp_poll_tx_irq_cp(enum HAL_MCU2CP_ID_T id);
63 void hal_mcu2cp_irq_ack_mcu(enum HAL_MCU2CP_ID_T id);
64 void hal_mcu2cp_irq_ack_cp(enum HAL_MCU2CP_ID_T id);
65 
66 const struct HAL_MCU2CP_MSG_T ** hal_mcu2cp_get_send_msg_list_cp(void);
67 const struct HAL_MCU2CP_MSG_T ** hal_mcu2cp_get_send_msg_list_mcu(void);
68 
69 void hal_mcu2cp_set_send_msg_list_mcu(void);
70 void hal_mcu2cp_set_send_msg_list_cp(void);
71 
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif
77 
78