• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 ASR Microelectronics (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 
16 /**
17  ****************************************************************************************
18  *
19  * @file sonata_api_task.h
20  *
21  * @brief header file - asr api task
22  *
23  ****************************************************************************************
24  */
25 
26 #ifndef _SONATA_API_TASK_H_
27 #define _SONATA_API_TASK_H_
28 
29 /*
30  * INCLUDE FILES
31  ****************************************************************************************
32  */
33 
34 #include "sonata_utils_api.h"
35 
36 #include "sonata_config.h"
37 /*
38  * MACRO DEFINITIONS
39  ****************************************************************************************
40  */
41 /// Number of ASR API Task Instances
42 #define SONATA_API_TASK_IDX_MAX                 (1)
43 
44 /// debug trace
45 #define SONATA_API_TASK_DBG        0
46 #if SONATA_API_TASK_DBG
47 #define SONATA_API_TASK_TRC    printf
48 #else
49 #define SONATA_API_TASK_TRC(...)
50 #endif // SONATA_API_TASK_DBG
51 
52 /*
53  * ENUM DEFINITIONS
54  ****************************************************************************************
55  */
56 /// states of asr api task
57 typedef enum {
58     /// initialization state
59     SONATA_API_TASK_INIT,
60     /// idle state
61     SONATA_API_TASK_IDLE,
62     /// busy state
63     SONATA_API_TASK_BUSY,
64 
65     /// Number of defined states.
66     SONATA_API_TASK_STATE_MAX
67 } sonata_api_task_state_t;
68 
69 /// asr api task messages
70 typedef enum {
71     SONATA_API_DUMMY_MSG = STACK_TASK_FIRST_MSG(SONATA_TASK_ID_APP),
72     /// message from application
73     SONATA_API_APP_MSG,
74 
75     SONATA_API_LAST_MSG,
76 } sonata_api_task_msg_id;
77 
78 /*
79  * Type Definition
80  ****************************************************************************************
81  */
82 /// Structure containing information about the handlers for an application subtask
83 typedef struct sonata_api_subtask_handlers {
84     /// Pointer to the message handler table
85     const struct ke_msg_handler *p_msg_handler_tab;
86     /// Number of messages handled
87     uint16_t msg_cnt;
88 } sonata_api_subtask_handlers_t;
89 
90 typedef struct sonata_app_timer_callback {
91     uint8_t (*timeout)(uint16_t id);
92 
93 } sonata_app_timer_callback_t;
94 /*
95  * FUNCTION DECLARATIONS
96  ****************************************************************************************
97  */
98 /*!
99  * @brief
100  */
101 
102 void sonata_api_task_init(void);
103 uint16_t sonata_api_register_app_timer_callback(sonata_app_timer_callback_t *cb);
104 
105 extern const sonata_api_subtask_handlers_t *p_app_mesh_handlers;
106 extern const sonata_api_subtask_handlers_t *p_prf_diss_api_ke_msg_handlers;
107 extern const sonata_api_subtask_handlers_t *p_prf_bass_api_ke_msg_handlers;
108 extern const sonata_api_subtask_handlers_t *p_prf_otas_api_ke_msg_handlers;
109 extern const sonata_api_subtask_handlers_t *p_prf_hogpd_api_ke_msg_handlers;
110 extern const sonata_api_subtask_handlers_t *p_prf_hogprh_api_ke_msg_handlers;
111 
112 #endif // _SONATA_API_TASK_H_
113 
114