• 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 __APP_THREAD_H__
16 #define __APP_THREAD_H__
17 
18 #include "stdbool.h"
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #define APP_MAILBOX_MAX (50)
25 
26 enum APP_MODUAL_ID_T {
27     APP_MODUAL_KEY = 0,
28     APP_MODUAL_AUDIO,
29     APP_MODUAL_BATTERY,
30     APP_MODUAL_BT,
31     APP_MODUAL_FM,
32     APP_MODUAL_SD,
33     APP_MODUAL_LINEIN,
34     APP_MODUAL_USBHOST,
35     APP_MODUAL_USBDEVICE,
36     APP_MODUAL_WATCHDOG,
37     APP_MODUAL_AUDIO_MANAGE,
38     APP_MODUAL_ANC,
39     APP_MODUAL_VOICE_ASSIST,
40     APP_MODUAL_SMART_MIC,
41 #ifdef __PC_CMD_UART__
42     APP_MODUAL_CMD,
43 #endif
44 #ifdef TILE_DATAPATH
45     APP_MODUAL_TILE,
46 #endif
47     APP_MODUAL_MIC,
48 #ifdef VOICE_DETECTOR_EN
49     APP_MODUAL_VOICE_DETECTOR,
50 #endif
51 #ifdef AUDIO_HEARING_COMPSATN
52     APP_MODUAL_HEAR_COMP,
53 #endif
54     APP_MODUAL_OHTER,
55 
56     APP_MODUAL_NUM
57 };
58 
59 typedef struct {
60     uint32_t message_id;
61     uint32_t message_ptr;
62     uint32_t message_Param0;
63     uint32_t message_Param1;
64     uint32_t message_Param2;
65 } APP_MESSAGE_BODY;
66 
67 typedef struct {
68     uint32_t src_thread;
69     uint32_t dest_thread;
70     uint32_t system_time;
71     uint32_t mod_id;
72     APP_MESSAGE_BODY msg_body;
73 } APP_MESSAGE_BLOCK;
74 
75 typedef int (*APP_MOD_HANDLER_T)(APP_MESSAGE_BODY *);
76 
77 int app_mailbox_put(APP_MESSAGE_BLOCK* msg_src);
78 
79 int app_mailbox_free(APP_MESSAGE_BLOCK* msg_p);
80 
81 int app_mailbox_get(APP_MESSAGE_BLOCK** msg_p);
82 
83 int app_os_init(void);
84 
85 int app_set_threadhandle(enum APP_MODUAL_ID_T mod_id, APP_MOD_HANDLER_T handler);
86 
87 void * app_os_tid_get(void);
88 
89 bool app_is_module_registered(enum APP_MODUAL_ID_T mod_id);
90 
91 #ifdef __cplusplus
92     }
93 #endif
94 
95 #endif//__FMDEC_H__
96