2b61f1614cec1053748b80457da4292d76ca2a6a
[apps/agl-service-unicens.git] / ucs2-interface / ucs_config.h
1 /*
2  * Unicens Integration Helper Component
3  *
4  * Copyright (C) 2017 Microchip Technology Germany II GmbH & Co. KG
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  * You may also obtain this software under a propriety license from Microchip.
20  * Please contact Microchip for further information.
21  *
22  */
23 #ifndef UNICENSINTEGRATION_H_
24 #define UNICENSINTEGRATION_H_
25
26 /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
27 /*                  USER ADJUSTABLE VALUES                              */
28 /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
29
30 #define ENABLE_INIC_WATCHDOG    (false)
31 #define ENABLE_AMS_LIB          (true)
32 #define DEBUG_XRM
33 #define BOARD_PMS_TX_SIZE       (72)
34 #define CMD_QUEUE_LEN           (4)
35
36 #include <string.h>
37 #include <stdarg.h>
38
39 #include "ucs_cfg.h"
40 #include "ucs_api.h"
41
42 /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
43 /*                          PRIVATE SECTION                             */
44 /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
45
46 /**
47  * \brief Internal enum for Unicens Integration
48  */
49 typedef enum
50 {
51     ///Result is OK and the processing is finished. Safe to dequeue this command.
52     UniCmdResult_OK_ProcessFinished,
53     ///Result is OK but the processing is ongoing. Must wait for callback.
54     UniCmdResult_OK_NeedToWaitForCB,
55     ///Result is error and the processing is finished. Safe to dequeue this command.
56     UniCmdResult_ERROR_ProcessFinished
57 } UnicensCmdResult_t;
58
59 /**
60  * \brief Internal enum for Unicens Integration
61  */
62 typedef enum
63 {
64     UnicensCmd_Unknown,
65     UnicensCmd_Init,
66     UnicensCmd_Stop,
67     UnicensCmd_RmSetRoute,
68     UnicensCmd_NsRun
69 } UnicensCmd_t;
70
71 /**
72  * \brief Internal struct for Unicens Integration
73  */
74 typedef struct
75 {
76     const Ucs_InitData_t *init_ptr;
77 } UnicensCmdInit_t;
78
79 /**
80  * \brief Internal struct for Unicens Integration
81  */
82 typedef struct
83 {
84     Ucs_Rm_Route_t *routePtr;
85     bool isActive;
86 } UnicensCmdRmSetRoute_t;
87
88 /**
89  * \brief Internal struct for Unicens Integration
90  */
91 typedef struct
92 {
93     Ucs_Rm_Node_t * node_ptr;
94 } UnicensCmdNsRun_t;
95
96 /**
97  * \brief Internal struct for Unicens Integration
98  */
99 typedef struct
100 {
101     UnicensCmd_t cmd;
102     union
103     {
104         UnicensCmdInit_t Init;
105         UnicensCmdRmSetRoute_t RmSetRoute;
106         UnicensCmdNsRun_t NsRun;
107     } val;
108 } UnicensCmdEntry_t;
109
110 /**
111  * \brief Internal variables for one instance of Unicens Integration
112  * \note Never touch any of this fields!
113  */
114 typedef struct {
115     volatile uint8_t *dataQueue;
116     volatile uint8_t *pRx;
117     volatile uint8_t *pTx;
118     volatile uint32_t amountOfEntries;
119     volatile uint32_t sizeOfEntry;
120     volatile uint32_t rxPos;
121     volatile uint32_t txPos;
122 } RB_t;
123
124 /**
125  * \brief Internal variables for one instance of Unicens Integration
126  * \note Allocate this structure for each instance (static or malloc)
127  *        and pass it to UCSI_Init()
128  * \note Never touch any of this fields!
129  */
130 typedef struct
131 {
132     uint32_t magic;
133     void *tag;
134     bool initialized;
135     RB_t rb;
136     uint8_t rbBuf[(CMD_QUEUE_LEN * sizeof(UnicensCmdEntry_t))];
137     Ucs_Inst_t *UNICENS;
138     Ucs_InitData_t uniInitData;
139     bool triggerService;
140     Ucs_Lld_Api_t *uniLld;
141     void *uniLldHPtr;
142     UnicensCmdEntry_t *currentCmd;
143 } UCSI_Data_t;
144
145 #endif /* UNICENSINTEGRATION_H_ */