1 /*------------------------------------------------------------------------------------------------*/
2 /* UNICENS Integration Helper Component */
3 /* Copyright 2017, Microchip Technology Inc. and its subsidiaries. */
5 /* Redistribution and use in source and binary forms, with or without */
6 /* modification, are permitted provided that the following conditions are met: */
8 /* 1. Redistributions of source code must retain the above copyright notice, this */
9 /* list of conditions and the following disclaimer. */
11 /* 2. Redistributions in binary form must reproduce the above copyright notice, */
12 /* this list of conditions and the following disclaimer in the documentation */
13 /* and/or other materials provided with the distribution. */
15 /* 3. Neither the name of the copyright holder nor the names of its */
16 /* contributors may be used to endorse or promote products derived from */
17 /* this software without specific prior written permission. */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" */
20 /* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE */
21 /* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE */
23 /* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL */
24 /* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR */
25 /* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
26 /* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
27 /* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */
28 /* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /*------------------------------------------------------------------------------------------------*/
30 #ifndef UNICENSINTEGRATION_H_
31 #define UNICENSINTEGRATION_H_
33 /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
34 /* USER ADJUSTABLE VALUES */
35 /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
37 #define ENABLE_INIC_WATCHDOG (true)
38 #define ENABLE_AMS_LIB (true)
40 #define BOARD_PMS_TX_SIZE (72)
41 #define CMD_QUEUE_LEN (40)
42 #define I2C_WRITE_MAX_LEN (32)
50 /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
52 /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
55 * \brief Internal enum for UNICENS Integration
59 /**Result is OK and the processing is finished. Safe to dequeue this command.*/
60 UniCmdResult_OK_ProcessFinished,
61 /**Result is OK but the processing is ongoing. Must wait for callback.*/
62 UniCmdResult_OK_NeedToWaitForCB,
63 /**Result is error and the processing is finished. Safe to dequeue this command.*/
64 UniCmdResult_ERROR_ProcessFinished
68 * \brief Asynchronous callback notifiying a command result
69 * \param result_ptr The asynchronous result of the command
70 * \param request_ptr User reference, typically points to the afb_req
73 typedef void (*Ucsi_ResultCb_t)(void *result_ptr, void *request_ptr);
76 * \brief Internal enum for UNICENS Integration
83 UnicensCmd_RmSetRoute,
85 UnicensCmd_GpioCreatePort,
86 UnicensCmd_GpioWritePort,
91 * \brief Internal struct for UNICENS Integration
95 const Ucs_InitData_t *init_ptr;
99 * \brief Internal struct for UNICENS Integration
103 Ucs_Rm_Route_t *routePtr;
105 } UnicensCmdRmSetRoute_t;
108 * \brief Internal struct for UNICENS Integration
112 Ucs_Rm_Node_t * node_ptr;
116 * \brief Internal struct for UNICENS Integration
120 uint16_t destination;
121 uint16_t debounceTime;
122 } UnicensCmdGpioCreatePort_t;
125 * \brief Internal struct for UNICENS Integration
129 uint16_t destination;
132 } UnicensCmdGpioWritePort_t;
135 * \brief Internal struct for UNICENS Integration
139 uint16_t destination;
145 uint8_t data[I2C_WRITE_MAX_LEN];
147 Ucsi_ResultCb_t result_fptr;
150 } UnicensCmdI2CWrite_t;
153 * \brief Internal struct for Unicens Integration
160 UnicensCmdInit_t Init;
161 UnicensCmdRmSetRoute_t RmSetRoute;
162 UnicensCmdNsRun_t NsRun;
163 UnicensCmdGpioCreatePort_t GpioCreatePort;
164 UnicensCmdGpioWritePort_t GpioWritePort;
165 UnicensCmdI2CWrite_t I2CWrite;
170 * \brief Internal variables for one instance of UNICENS Integration
171 * \note Never touch any of this fields!
174 volatile uint8_t *dataQueue;
175 volatile uint8_t *pRx;
176 volatile uint8_t *pTx;
177 volatile uint32_t amountOfEntries;
178 volatile uint32_t sizeOfEntry;
179 volatile uint32_t rxPos;
180 volatile uint32_t txPos;
184 * \brief Internal variables for one instance of UNICENS Integration
185 * \note Allocate this structure for each instance (static or malloc)
186 * and pass it to UCSI_Init()
187 * \note Never touch any of this fields!
195 uint8_t rbBuf[(CMD_QUEUE_LEN * sizeof(UnicensCmdEntry_t))];
197 Ucs_InitData_t uniInitData;
199 Ucs_Lld_Api_t *uniLld;
201 UnicensCmdEntry_t *currentCmd;
204 #endif /* UNICENSINTEGRATION_H_ */