1 // Copyright (C) 2022 Beken Corporation 2 // 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 #pragma once 16 #include <common/bk_include.h> 17 #include <common/bk_err.h> 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 /** 24 * @brief MAILBOX APIs 25 * @addtogroup bk_api_mailbox MAILBOX API group 26 * @{ 27 */ 28 29 /** 30 * @brief MAILBOX defines 31 * @defgroup bk_api_mailbox macos 32 * @ingroup bk_api_mailbox 33 * @{ 34 */ 35 36 #define BK_ERR_MAILBOX_SRC_DST (BK_ERR_MAILBOX_BASE - 1) /**< MAILBOX source address error*/ 37 #define BK_ERR_MAILBOX_ID (BK_ERR_MAILBOX_BASE - 2) /**< MAILBOX BOX number error */ 38 #define BK_ERR_MAILBOX_FLAG (BK_ERR_MAILBOX_BASE - 3) /**< MAILBOX flag error */ 39 #define BK_ERR_MAILBOX_CALLBACK (BK_ERR_MAILBOX_BASE - 4) /**< MAILBOX callback function error */ 40 #define BK_ERR_MAILBOX_TIMEOUT (BK_ERR_MAILBOX_BASE - 5) /**< MAILBOX waite timeout */ 41 #define BK_ERR_MAILBOX_NOT_INIT (BK_ERR_MAILBOX_BASE - 6) /**< MAILBOX isnt init */ 42 #define BK_ERR_MAILBOX_REPEAT_INIT (BK_ERR_MAILBOX_BASE - 7) /**< MAILBOX repeat init */ 43 44 45 /** 46 * @brief A MAILBOX has multiple boxes, one box has four spaces to fill in data 47 * Define the meaning of each space by user. 48 * 49 * |_____________________________| |_____________________________| 50 * |_____________________________| |_____________________________| 51 * | Mailbox0 | | Mailbox1 | 52 * |______________|______________| |______________|______________| 53 * | box0 | box1 | | box0 | box1 | 54 * | ____________ | ____________ | | ____________ | ____________ | 55 * | | param0 | | | param0 | | | | param0 | | | param0 | | 56 * | | param1 | | | param1 | | | | param1 | | | param1 | | 57 * | | param2 | | | param2 | | | | param2 | | | param2 | | 58 * | | param3 | | | param3 | | | | param3 | | | param3 | | 59 * | |__________| | |__________| | | |__________| | |__________| | 60 * | _____________|______________| |______________|______________| 61 * |_____________________________| |_____________________________| 62 */ 63 64 typedef struct 65 { 66 uint32_t param0; /**< MAILBOX Space 0 */ 67 uint32_t param1; /**< MAILBOX Space 1 */ 68 uint32_t param2; /**< MAILBOX Space 2 */ 69 uint32_t param3; /**< MAILBOX Space 3 */ 70 } mailbox_data_t; 71 72 typedef enum{ 73 MAILBOX_CPU0 = 0, /**< MAILBOX CPU0 endpoint */ 74 MAILBOX_CPU1, /**< MAILBOX CPU1 endpoint */ 75 MAILBOX_DSP, /**< MAILBOX DSP endpoint */ 76 MAILBOX_BT, /**< MAILBOX BT endpoint */ 77 MAILBOX_ENDPOINT_INVALID, /**< MAILBOX invalid endpoint*/ 78 } mailbox_endpoint_t; 79 80 /** 81 * @brief MAILBOX interrupt service routine 82 */ 83 84 typedef void (*mailbox_callback_t)(mailbox_data_t *data); 85 86 /** 87 * @} 88 */ 89 90 /** 91 * @} 92 */ 93 94 #ifdef __cplusplus 95 } 96 #endif 97