1 /***************************************************************************//**
2 * \file cy_smartio.c
3 * \version 1.0.3
4 *
5 * \brief
6 * Provides an API implementation of the Smart I/O driver
7 *
8 ********************************************************************************
9 * \copyright
10 * Copyright 2018-2020 Cypress Semiconductor Corporation
11 * SPDX-License-Identifier: Apache-2.0
12 *
13 * Licensed under the Apache License, Version 2.0 (the "License");
14 * you may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 *     http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 *******************************************************************************/
25 
26 #include "cy_device.h"
27 
28 #if (defined (CY_IP_MXS40IOSS) || defined(CY_IP_MXS40SIOSS) || defined(CY_IP_MXS22IOSS))
29 
30 #include "cy_smartio.h"
31 
32 #if defined(__cplusplus)
33 extern "C" {
34 #endif
35 
36 CY_MISRA_DEVIATE_BLOCK_START('MISRA C-2012 Rule 10.8', 12, \
37 'Value extracted from _FLD2VAL macro will not exceed enum range.')
38 
39 /*******************************************************************************
40 * Function Name: Cy_SmartIO_Init
41 ****************************************************************************//**
42 *
43 * \brief Initializes the Smart I/O.
44 *
45 * \param base
46 * Pointer to the Smart I/O base address
47 *
48 * \param config
49 * Pointer to the Smart I/O configuration structure
50 *
51 * \return
52 * Status of the initialization operation
53 *
54 * \funcusage
55 * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_Init
56 *
57 *******************************************************************************/
Cy_SmartIO_Init(SMARTIO_PRT_Type * base,const cy_stc_smartio_config_t * config)58 cy_en_smartio_status_t Cy_SmartIO_Init(SMARTIO_PRT_Type* base, const cy_stc_smartio_config_t* config)
59 {
60     cy_en_smartio_status_t status = CY_SMARTIO_SUCCESS;
61 
62     if(NULL != config)
63     {
64         SMARTIO_PRT_CTL(base) = _VAL2FLD(SMARTIO_PRT_CTL_BYPASS, config->bypassMask)
65                                 | _VAL2FLD(SMARTIO_PRT_CTL_CLOCK_SRC, config->clkSrc)
66                                 | _VAL2FLD(SMARTIO_PRT_CTL_HLD_OVR, config->hldOvr)
67                                 | _VAL2FLD(SMARTIO_PRT_CTL_PIPELINE_EN, CY_SMARTIO_ENABLE)
68                                 | _VAL2FLD(SMARTIO_PRT_CTL_ENABLED, CY_SMARTIO_DISABLE);
69         SMARTIO_PRT_SYNC_CTL(base) = _VAL2FLD(SMARTIO_PRT_SYNC_CTL_IO_SYNC_EN, config->ioSyncEn)
70                                 | _VAL2FLD(SMARTIO_PRT_SYNC_CTL_CHIP_SYNC_EN, config->chipSyncEn);
71 
72         /* LUT configurations - skip if lutCfg is a NULL pointer */
73         if(NULL != config->lutCfg0)
74         {
75             SMARTIO_PRT_LUT_SEL(base, 0) = _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR0_SEL, config->lutCfg0->tr0)
76                                             | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR1_SEL, config->lutCfg0->tr1)
77                                             | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR2_SEL, config->lutCfg0->tr2);
78             SMARTIO_PRT_LUT_CTL(base, 0) = _VAL2FLD(SMARTIO_PRT_LUT_CTL_LUT, config->lutCfg0->lutMap)
79                                             | _VAL2FLD(SMARTIO_PRT_LUT_CTL_LUT_OPC, config->lutCfg0->opcode);
80         }
81         if(NULL != config->lutCfg1)
82         {
83             SMARTIO_PRT_LUT_SEL(base, 1) = _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR0_SEL, config->lutCfg1->tr0)
84                                             | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR1_SEL, config->lutCfg1->tr1)
85                                             | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR2_SEL, config->lutCfg1->tr2);
86             SMARTIO_PRT_LUT_CTL(base, 1) = _VAL2FLD(SMARTIO_PRT_LUT_CTL_LUT, config->lutCfg1->lutMap)
87                                             | _VAL2FLD(SMARTIO_PRT_LUT_CTL_LUT_OPC, config->lutCfg1->opcode);
88         }
89         if(NULL != config->lutCfg2)
90         {
91             SMARTIO_PRT_LUT_SEL(base, 2) = _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR0_SEL, config->lutCfg2->tr0)
92                                             | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR1_SEL, config->lutCfg2->tr1)
93                                             | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR2_SEL, config->lutCfg2->tr2);
94             SMARTIO_PRT_LUT_CTL(base, 2) = _VAL2FLD(SMARTIO_PRT_LUT_CTL_LUT, config->lutCfg2->lutMap)
95                                             | _VAL2FLD(SMARTIO_PRT_LUT_CTL_LUT_OPC, config->lutCfg2->opcode);
96         }
97         if(NULL != config->lutCfg3)
98         {
99             SMARTIO_PRT_LUT_SEL(base, 3) = _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR0_SEL, config->lutCfg3->tr0)
100                                             | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR1_SEL, config->lutCfg3->tr1)
101                                             | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR2_SEL, config->lutCfg3->tr2);
102             SMARTIO_PRT_LUT_CTL(base, 3) = _VAL2FLD(SMARTIO_PRT_LUT_CTL_LUT, config->lutCfg3->lutMap)
103                                             | _VAL2FLD(SMARTIO_PRT_LUT_CTL_LUT_OPC, config->lutCfg3->opcode);
104         }
105         if(NULL != config->lutCfg4)
106         {
107             SMARTIO_PRT_LUT_SEL(base, 4) = _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR0_SEL, config->lutCfg4->tr0)
108                                             | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR1_SEL, config->lutCfg4->tr1)
109                                             | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR2_SEL, config->lutCfg4->tr2);
110             SMARTIO_PRT_LUT_CTL(base, 4) = _VAL2FLD(SMARTIO_PRT_LUT_CTL_LUT, config->lutCfg4->lutMap)
111                                             | _VAL2FLD(SMARTIO_PRT_LUT_CTL_LUT_OPC, config->lutCfg4->opcode);
112         }
113         if(NULL != config->lutCfg5)
114         {
115             SMARTIO_PRT_LUT_SEL(base, 5) = _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR0_SEL, config->lutCfg5->tr0)
116                                             | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR1_SEL, config->lutCfg5->tr1)
117                                             | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR2_SEL, config->lutCfg5->tr2);
118             SMARTIO_PRT_LUT_CTL(base, 5) = _VAL2FLD(SMARTIO_PRT_LUT_CTL_LUT, config->lutCfg5->lutMap)
119                                             | _VAL2FLD(SMARTIO_PRT_LUT_CTL_LUT_OPC, config->lutCfg5->opcode);
120         }
121         if(NULL != config->lutCfg6)
122         {
123             SMARTIO_PRT_LUT_SEL(base, 6) = _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR0_SEL, config->lutCfg6->tr0)
124                                             | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR1_SEL, config->lutCfg6->tr1)
125                                             | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR2_SEL, config->lutCfg6->tr2);
126             SMARTIO_PRT_LUT_CTL(base, 6) = _VAL2FLD(SMARTIO_PRT_LUT_CTL_LUT, config->lutCfg6->lutMap)
127                                             | _VAL2FLD(SMARTIO_PRT_LUT_CTL_LUT_OPC, config->lutCfg6->opcode);
128         }
129         if(NULL != config->lutCfg7)
130         {
131             SMARTIO_PRT_LUT_SEL(base, 7) = _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR0_SEL, config->lutCfg7->tr0)
132                                             | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR1_SEL, config->lutCfg7->tr1)
133                                             | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR2_SEL, config->lutCfg7->tr2);
134             SMARTIO_PRT_LUT_CTL(base, 7) = _VAL2FLD(SMARTIO_PRT_LUT_CTL_LUT, config->lutCfg7->lutMap)
135                                             | _VAL2FLD(SMARTIO_PRT_LUT_CTL_LUT_OPC, config->lutCfg7->opcode);
136         }
137 
138         /* DU Configuration - skip if duCfg is a NULL pointer */
139         if(NULL != config->duCfg)
140         {
141             SMARTIO_PRT_DU_SEL(base) = _VAL2FLD(SMARTIO_PRT_DU_SEL_DU_TR0_SEL, config->duCfg->tr0)
142                                         | _VAL2FLD(SMARTIO_PRT_DU_SEL_DU_TR1_SEL, config->duCfg->tr1)
143                                         | _VAL2FLD(SMARTIO_PRT_DU_SEL_DU_TR2_SEL, config->duCfg->tr2)
144                                         | _VAL2FLD(SMARTIO_PRT_DU_SEL_DU_DATA0_SEL, config->duCfg->data0)
145                                         | _VAL2FLD(SMARTIO_PRT_DU_SEL_DU_DATA1_SEL, config->duCfg->data1);
146             SMARTIO_PRT_DU_CTL(base) = _VAL2FLD(SMARTIO_PRT_DU_CTL_DU_SIZE, config->duCfg->size)
147                                         | _VAL2FLD(SMARTIO_PRT_DU_CTL_DU_OPC, config->duCfg->opcode);
148             SMARTIO_PRT_DATA(base) = _VAL2FLD(SMARTIO_PRT_DATA_DATA, config->duCfg->dataReg);
149         }
150     }
151     else
152     {
153         status = CY_SMARTIO_BAD_PARAM;
154     }
155 
156     return(status);
157 }
158 
159 
160 /*******************************************************************************
161 * Function Name: Cy_SmartIO_Deinit
162 ****************************************************************************//**
163 *
164 * \brief Resets the Smart I/O to default values.
165 *
166 * \param base
167 * Pointer to the Smart I/O base address
168 *
169 * \funcusage
170 * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_Deinit
171 *
172 *******************************************************************************/
Cy_SmartIO_Deinit(SMARTIO_PRT_Type * base)173 void Cy_SmartIO_Deinit(SMARTIO_PRT_Type* base)
174 {
175     SMARTIO_PRT_CTL(base) = _VAL2FLD(SMARTIO_PRT_CTL_BYPASS, CY_SMARTIO_CHANNEL_ALL)
176                             | _VAL2FLD(SMARTIO_PRT_CTL_CLOCK_SRC, CY_SMARTIO_CLK_GATED)
177                             | _VAL2FLD(SMARTIO_PRT_CTL_PIPELINE_EN, CY_SMARTIO_ENABLE)
178                             | _VAL2FLD(SMARTIO_PRT_CTL_ENABLED, CY_SMARTIO_DISABLE);
179     SMARTIO_PRT_SYNC_CTL(base) = CY_SMARTIO_DEINIT;
180     for(uint8_t idx = 0u; idx < CY_SMARTIO_LUTMAX; idx++)
181     {
182         SMARTIO_PRT_LUT_SEL(base, idx) = CY_SMARTIO_DEINIT;
183         SMARTIO_PRT_LUT_CTL(base, idx) = CY_SMARTIO_DEINIT;
184     }
185     SMARTIO_PRT_DU_SEL(base) = CY_SMARTIO_DEINIT;
186     SMARTIO_PRT_DU_CTL(base) = CY_SMARTIO_DEINIT;
187     SMARTIO_PRT_DATA(base) = CY_SMARTIO_DEINIT;
188 }
189 
190 
191 /*******************************************************************************
192 * Function Name: Cy_SmartIO_Enable
193 ****************************************************************************//**
194 *
195 * \brief Enables the Smart I/O.
196 *
197 * \param base
198 * Pointer to the Smart I/O base address
199 *
200 * \funcusage
201 * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_Enable
202 *
203 *******************************************************************************/
Cy_SmartIO_Enable(SMARTIO_PRT_Type * base)204 void Cy_SmartIO_Enable(SMARTIO_PRT_Type* base)
205 {
206     uint32_t tempReg;
207 
208     tempReg = (SMARTIO_PRT_CTL(base) & (~(SMARTIO_PRT_CTL_PIPELINE_EN_Msk | SMARTIO_PRT_CTL_ENABLED_Msk)));
209     SMARTIO_PRT_CTL(base) = tempReg
210                 | _VAL2FLD(SMARTIO_PRT_CTL_PIPELINE_EN, CY_SMARTIO_DISABLE)
211                 | _VAL2FLD(SMARTIO_PRT_CTL_ENABLED, CY_SMARTIO_ENABLE);
212 }
213 
214 
215 /*******************************************************************************
216 * Function Name: Cy_SmartIO_Disable
217 ****************************************************************************//**
218 *
219 * \brief Disables the Smart I/O.
220 *
221 * \param base
222 * Pointer to the Smart I/O base address
223 *
224 * \funcusage
225 * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_Disable
226 *
227 *******************************************************************************/
Cy_SmartIO_Disable(SMARTIO_PRT_Type * base)228 void Cy_SmartIO_Disable(SMARTIO_PRT_Type* base)
229 {
230     uint32_t tempReg;
231 
232     tempReg = (SMARTIO_PRT_CTL(base) & (~(SMARTIO_PRT_CTL_PIPELINE_EN_Msk | SMARTIO_PRT_CTL_ENABLED_Msk)));
233     SMARTIO_PRT_CTL(base) = tempReg
234                 | _VAL2FLD(SMARTIO_PRT_CTL_PIPELINE_EN, CY_SMARTIO_ENABLE)
235                 | _VAL2FLD(SMARTIO_PRT_CTL_ENABLED, CY_SMARTIO_DISABLE);
236 }
237 
238 
239 /*******************************************************************************
240 * Function Name: Cy_SmartIO_SetChBypass
241 ****************************************************************************//**
242 *
243 * \brief Sets the bypass/route state of all 8 channels in the Smart I/O
244 *
245 * <table class="doxtable">
246 *   <tr><th>Bypass bit</th><th>    Channel  </th></tr>
247 *   <tr><td>     0    </td><td> io0<->chip0 </td></tr>
248 *   <tr><td>     1    </td><td> io1<->chip1 </td></tr>
249 *   <tr><td>     2    </td><td> io2<->chip2 </td></tr>
250 *   <tr><td>     3    </td><td> io3<->chip3 </td></tr>
251 *   <tr><td>     4    </td><td> io4<->chip4 </td></tr>
252 *   <tr><td>     5    </td><td> io5<->chip5 </td></tr>
253 *   <tr><td>     6    </td><td> io6<->chip6 </td></tr>
254 *   <tr><td>     7    </td><td> io7<->chip7 </td></tr>
255 * </table>
256 *
257 * \param base
258 * Pointer to the Smart I/O base address
259 *
260 * \param bypassMask
261 * Bypass/Route state of 8 io<->chip channels (bits [7:0]): 1=bypass, 0=routed.
262 *
263 * \return
264 * Status of the operation
265 *
266 * \note The Smart I/O block must be disabled before calling this function.
267 *
268 * \funcusage
269 * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_SetChBypass
270 *
271 *******************************************************************************/
Cy_SmartIO_SetChBypass(SMARTIO_PRT_Type * base,uint8_t bypassMask)272 cy_en_smartio_status_t Cy_SmartIO_SetChBypass(SMARTIO_PRT_Type* base, uint8_t bypassMask)
273 {
274     cy_en_smartio_status_t status = CY_SMARTIO_LOCKED;
275     uint32_t tempReg;
276 
277     if(CY_SMARTIO_DISABLE == _FLD2VAL(SMARTIO_PRT_CTL_ENABLED, SMARTIO_PRT_CTL(base)))
278     {
279         tempReg = (SMARTIO_PRT_CTL(base) & (~SMARTIO_PRT_CTL_BYPASS_Msk));
280         SMARTIO_PRT_CTL(base) = tempReg | _VAL2FLD(SMARTIO_PRT_CTL_BYPASS, bypassMask);
281         status = CY_SMARTIO_SUCCESS;
282     }
283 
284     return(status);
285 }
286 
287 
288 /*******************************************************************************
289 * Function Name: Cy_SmartIO_SetClock
290 ****************************************************************************//**
291 *
292 * \brief Sets the clock source of the Smart I/O.
293 *
294 * \param base
295 * Pointer to the Smart I/O base address
296 *
297 * \param clkSrc
298 * Pointer to the Smart I/O base address
299 *
300 * \return
301 * Status of the operation
302 *
303 * \note The Smart I/O block must be disabled before calling this function.
304 *
305 * \funcusage
306 * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_SetClock
307 *
308 *******************************************************************************/
Cy_SmartIO_SetClock(SMARTIO_PRT_Type * base,cy_en_smartio_clksrc_t clkSrc)309 cy_en_smartio_status_t Cy_SmartIO_SetClock(SMARTIO_PRT_Type* base, cy_en_smartio_clksrc_t clkSrc)
310 {
311     cy_en_smartio_status_t status = CY_SMARTIO_LOCKED;
312     uint32_t tempReg;
313 
314     if(CY_SMARTIO_DISABLE == _FLD2VAL(SMARTIO_PRT_CTL_ENABLED, SMARTIO_PRT_CTL(base)))
315     {
316         tempReg = (SMARTIO_PRT_CTL(base) & (~SMARTIO_PRT_CTL_CLOCK_SRC_Msk));
317         SMARTIO_PRT_CTL(base) = tempReg | _VAL2FLD(SMARTIO_PRT_CTL_CLOCK_SRC, clkSrc);
318         status = CY_SMARTIO_SUCCESS;
319     }
320 
321     return(status);
322 }
323 
324 
325 /*******************************************************************************
326 * Function Name: Cy_SmartIO_SetIoSync
327 ****************************************************************************//**
328 *
329 * \brief Sets the synchronization mode of the 8 I/O terminals.
330 *
331 * <table class="doxtable">
332 *   <tr><th> Sync bit </th><th> I/O terminal </th></tr>
333 *   <tr><td>     0    </td><td>     io0      </td></tr>
334 *   <tr><td>     1    </td><td>     io1      </td></tr>
335 *   <tr><td>     2    </td><td>     io2      </td></tr>
336 *   <tr><td>     3    </td><td>     io3      </td></tr>
337 *   <tr><td>     4    </td><td>     io4      </td></tr>
338 *   <tr><td>     5    </td><td>     io5      </td></tr>
339 *   <tr><td>     6    </td><td>     io6      </td></tr>
340 *   <tr><td>     7    </td><td>     io7      </td></tr>
341 * </table>
342 *
343 * \param base
344 * Pointer to the Smart I/O base address
345 *
346 * \param ioSyncEn
347 * Sync mode of 8 I/O terminals (bits [7:0]): 1=sync, 0=no sync.
348 *
349 * \return
350 * Status of the operation
351 *
352 * \note The Smart I/O block must be disabled before calling this function.
353 *
354 * \funcusage
355 * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_SetIoSync
356 *
357 *******************************************************************************/
Cy_SmartIO_SetIoSync(SMARTIO_PRT_Type * base,uint8_t ioSyncEn)358 cy_en_smartio_status_t Cy_SmartIO_SetIoSync(SMARTIO_PRT_Type* base, uint8_t ioSyncEn)
359 {
360     cy_en_smartio_status_t status = CY_SMARTIO_LOCKED;
361     uint32_t tempReg;
362 
363     if(CY_SMARTIO_DISABLE == _FLD2VAL(SMARTIO_PRT_CTL_ENABLED, SMARTIO_PRT_CTL(base)))
364     {
365         tempReg = (SMARTIO_PRT_SYNC_CTL(base) & (~SMARTIO_PRT_SYNC_CTL_IO_SYNC_EN_Msk));
366         SMARTIO_PRT_SYNC_CTL(base) = tempReg | _VAL2FLD(SMARTIO_PRT_SYNC_CTL_IO_SYNC_EN, ioSyncEn);
367         status = CY_SMARTIO_SUCCESS;
368     }
369 
370     return(status);
371 }
372 
373 
374 /*******************************************************************************
375 * Function Name: Cy_SmartIO_SetChipSync
376 ****************************************************************************//**
377 *
378 * \brief Sets the synchronization mode of the 8 chip-side terminals.
379 *
380 * <table class="doxtable">
381 *   <tr><th> Sync bit </th><th> chip terminal </th></tr>
382 *   <tr><td>     0    </td><td>     chip0     </td></tr>
383 *   <tr><td>     1    </td><td>     chip1     </td></tr>
384 *   <tr><td>     2    </td><td>     chip2     </td></tr>
385 *   <tr><td>     3    </td><td>     chip3     </td></tr>
386 *   <tr><td>     4    </td><td>     chip4     </td></tr>
387 *   <tr><td>     5    </td><td>     chip5     </td></tr>
388 *   <tr><td>     6    </td><td>     chip6     </td></tr>
389 *   <tr><td>     7    </td><td>     chip7     </td></tr>
390 * </table>
391 *
392 * \param base
393 * Pointer to the Smart I/O base address
394 *
395 * \param chipSyncEn
396 * Sync mode of 8 chip-side terminals (bits [7:0]): 1=sync, 0=no sync.
397 *
398 * \return
399 * Status of the operation
400 *
401 * \note The Smart I/O block must be disabled before calling this function.
402 *
403 * \funcusage
404 * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_SetChipSync
405 *
406 *******************************************************************************/
Cy_SmartIO_SetChipSync(SMARTIO_PRT_Type * base,uint8_t chipSyncEn)407 cy_en_smartio_status_t Cy_SmartIO_SetChipSync(SMARTIO_PRT_Type* base, uint8_t chipSyncEn)
408 {
409     cy_en_smartio_status_t status = CY_SMARTIO_LOCKED;
410     uint32_t tempReg;
411 
412     if(CY_SMARTIO_DISABLE == _FLD2VAL(SMARTIO_PRT_CTL_ENABLED, SMARTIO_PRT_CTL(base)))
413     {
414         tempReg = (SMARTIO_PRT_SYNC_CTL(base) & (~SMARTIO_PRT_SYNC_CTL_CHIP_SYNC_EN_Msk));
415         SMARTIO_PRT_SYNC_CTL(base) = tempReg | _VAL2FLD(SMARTIO_PRT_SYNC_CTL_CHIP_SYNC_EN, chipSyncEn);
416         status = CY_SMARTIO_SUCCESS;
417     }
418 
419     return(status);
420 }
421 
422 
423 /*******************************************************************************
424 * Function Name: Cy_SmartIO_HoldOverride
425 ****************************************************************************//**
426 *
427 * \brief Configures the hold override mode.
428 *
429 * In Deep-Sleep power mode, the HSIOM holds the GPIO output and output enable
430 * signals for all signals that operate in chip active domain. Enabling the hold
431 * override allows the Smart I/O to deliver Deep-Sleep output functionality
432 * on these GPIO terminals. If the Smart I/O should not drive any of the GPIO
433 * outputs, the hold override should be disabled.
434 *
435 * \param base
436 * Pointer to the Smart I/O base address
437 *
438 * \param hldOvr
439 * true = Enabled: Smart I/O controls the port I/Os
440 * false = Disabled: HSIOM controls the port I/Os
441 *
442 * \return
443 * Status of the operation
444 *
445 * \note The Smart I/O block must be disabled before calling this function.
446 *
447 * \funcusage
448 * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_HoldOverride
449 *
450 *******************************************************************************/
Cy_SmartIO_HoldOverride(SMARTIO_PRT_Type * base,bool hldOvr)451 cy_en_smartio_status_t Cy_SmartIO_HoldOverride(SMARTIO_PRT_Type* base, bool hldOvr)
452 {
453     cy_en_smartio_status_t status = CY_SMARTIO_LOCKED;
454     uint32_t tempReg;
455 
456     if(CY_SMARTIO_DISABLE == _FLD2VAL(SMARTIO_PRT_CTL_ENABLED, SMARTIO_PRT_CTL(base)))
457     {
458         tempReg = (SMARTIO_PRT_CTL(base) & (~SMARTIO_PRT_CTL_HLD_OVR_Msk));
459         SMARTIO_PRT_CTL(base) = tempReg | _VAL2FLD(SMARTIO_PRT_CTL_HLD_OVR, hldOvr);
460         status = CY_SMARTIO_SUCCESS;
461     }
462 
463     return(status);
464 }
465 
466 
467 /*******************************************************************************
468 * Function Name: Cy_SmartIO_GetLutTr
469 ****************************************************************************//**
470 *
471 * \brief Gets the specified LUT input trigger source.
472 *
473 * \param base
474 * Pointer to the Smart I/O base address
475 *
476 * \param lutNum
477 * LUT index number
478 *
479 * \param trNum
480 * Input trigger number
481 *
482 * \return
483 * LUT input trigger source
484 *
485 * \funcusage
486 * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_GetLutTr
487 *
488 *******************************************************************************/
Cy_SmartIO_GetLutTr(SMARTIO_PRT_Type * base,cy_en_smartio_lutnum_t lutNum,cy_en_smartio_trnum_t trNum)489 cy_en_smartio_luttr_t Cy_SmartIO_GetLutTr(SMARTIO_PRT_Type* base, cy_en_smartio_lutnum_t lutNum, cy_en_smartio_trnum_t trNum)
490 {
491     cy_en_smartio_luttr_t trSrc;
492 
493     switch(trNum)
494     {
495         case(CY_SMARTIO_TR0):
496         {
497             trSrc = (cy_en_smartio_luttr_t)_FLD2VAL(SMARTIO_PRT_LUT_SEL_LUT_TR0_SEL, SMARTIO_PRT_LUT_SEL(base, lutNum));
498             break;
499         }
500         case(CY_SMARTIO_TR1):
501         {
502             trSrc = (cy_en_smartio_luttr_t)_FLD2VAL(SMARTIO_PRT_LUT_SEL_LUT_TR1_SEL, SMARTIO_PRT_LUT_SEL(base, lutNum));
503             break;
504         }
505         case(CY_SMARTIO_TR2):
506         {
507             trSrc = (cy_en_smartio_luttr_t)_FLD2VAL(SMARTIO_PRT_LUT_SEL_LUT_TR2_SEL, SMARTIO_PRT_LUT_SEL(base, lutNum));
508             break;
509         }
510         default:
511         {
512             trSrc = CY_SMARTIO_LUTTR_INVALID;
513             break;
514         }
515     }
516 
517     return(trSrc);
518 }
519 
520 
521 /*******************************************************************************
522 * Function Name: Cy_SmartIO_SetLutTr
523 ****************************************************************************//**
524 *
525 * \brief Sets the specified LUT input trigger source.
526 *
527 * \param base
528 * Pointer to the Smart I/O base address
529 *
530 * \param lutNum
531 * LUT index number
532 *
533 * \param trNum
534 * Input trigger number
535 *
536 * \param trSrc
537 * Input trigger source
538 *
539 * \return
540 * Status of the operation
541 *
542 * \note The Smart I/O block must be disabled before calling this function.
543 *
544 * \funcusage
545 * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_SetLutTr
546 *
547 *******************************************************************************/
Cy_SmartIO_SetLutTr(SMARTIO_PRT_Type * base,cy_en_smartio_lutnum_t lutNum,cy_en_smartio_trnum_t trNum,cy_en_smartio_luttr_t trSrc)548 cy_en_smartio_status_t Cy_SmartIO_SetLutTr(SMARTIO_PRT_Type* base, cy_en_smartio_lutnum_t lutNum, cy_en_smartio_trnum_t trNum, cy_en_smartio_luttr_t trSrc)
549 {
550     cy_en_smartio_status_t status = CY_SMARTIO_LOCKED;
551     uint32_t tempReg;
552 
553     if(CY_SMARTIO_DISABLE == _FLD2VAL(SMARTIO_PRT_CTL_ENABLED, SMARTIO_PRT_CTL(base)))
554     {
555         status = CY_SMARTIO_SUCCESS;
556         switch(trNum)
557         {
558             case(CY_SMARTIO_TR0):
559             {
560                 tempReg = (SMARTIO_PRT_LUT_SEL(base, lutNum) & (~SMARTIO_PRT_LUT_SEL_LUT_TR0_SEL_Msk));
561                 SMARTIO_PRT_LUT_SEL(base, lutNum) = tempReg | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR0_SEL, trSrc);
562                 break;
563             }
564             case(CY_SMARTIO_TR1):
565             {
566                 tempReg = (SMARTIO_PRT_LUT_SEL(base, lutNum) & (~SMARTIO_PRT_LUT_SEL_LUT_TR1_SEL_Msk));
567                 SMARTIO_PRT_LUT_SEL(base, lutNum) = tempReg | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR1_SEL, trSrc);
568                 break;
569             }
570             case(CY_SMARTIO_TR2):
571             {
572                 tempReg = (SMARTIO_PRT_LUT_SEL(base, lutNum) & (~SMARTIO_PRT_LUT_SEL_LUT_TR2_SEL_Msk));
573                 SMARTIO_PRT_LUT_SEL(base, lutNum) = tempReg | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR2_SEL, trSrc);
574                 break;
575             }
576             default:
577             {
578                 status = CY_SMARTIO_BAD_PARAM;
579                 break;
580             }
581         }
582     }
583 
584     return(status);
585 }
586 
587 
588 /*******************************************************************************
589 * Function Name: Cy_SmartIO_SetLutTrAll
590 ****************************************************************************//**
591 *
592 * \brief Sets all LUT input triggers to the same source.
593 *
594 * \param base
595 * Pointer to the Smart I/O base address
596 *
597 * \param lutNum
598 * LUT index number
599 *
600 * \param trSrc
601 * Input trigger source
602 *
603 * \return
604 * Status of the operation
605 *
606 * \note The Smart I/O block must be disabled before calling this function.
607 *
608 * \funcusage
609 * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_SetLutTrAll
610 *
611 *******************************************************************************/
Cy_SmartIO_SetLutTrAll(SMARTIO_PRT_Type * base,cy_en_smartio_lutnum_t lutNum,cy_en_smartio_luttr_t trSrc)612 cy_en_smartio_status_t Cy_SmartIO_SetLutTrAll(SMARTIO_PRT_Type* base, cy_en_smartio_lutnum_t lutNum, cy_en_smartio_luttr_t trSrc)
613 {
614     cy_en_smartio_status_t status = CY_SMARTIO_LOCKED;
615     uint32_t tempReg;
616 
617     if(CY_SMARTIO_DISABLE == _FLD2VAL(SMARTIO_PRT_CTL_ENABLED, SMARTIO_PRT_CTL(base)))
618     {
619         tempReg = (SMARTIO_PRT_LUT_SEL(base, lutNum)
620                     & (~(SMARTIO_PRT_LUT_SEL_LUT_TR0_SEL_Msk
621                         | SMARTIO_PRT_LUT_SEL_LUT_TR1_SEL_Msk
622                         | SMARTIO_PRT_LUT_SEL_LUT_TR2_SEL_Msk)));
623         SMARTIO_PRT_LUT_SEL(base, lutNum) = tempReg
624                                 | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR0_SEL, trSrc)
625                                 | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR1_SEL, trSrc)
626                                 | _VAL2FLD(SMARTIO_PRT_LUT_SEL_LUT_TR2_SEL, trSrc);
627         status = CY_SMARTIO_SUCCESS;
628     }
629 
630     return(status);
631 }
632 
633 
634 /*******************************************************************************
635 * Function Name: Cy_SmartIO_SetLutOpcode
636 ****************************************************************************//**
637 *
638 * \brief Sets the opcode of the specified LUT.
639 *
640 * \param base
641 * Pointer to the Smart I/O base address
642 *
643 * \param lutNum
644 * LUT index number
645 *
646 * \param opcode
647 * LUT opcode
648 *
649 * \return
650 * Status of the operation
651 *
652 * \note The Smart I/O block must be disabled before calling this function.
653 *
654 * \funcusage
655 * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_SetLutOpcode
656 *
657 *******************************************************************************/
Cy_SmartIO_SetLutOpcode(SMARTIO_PRT_Type * base,cy_en_smartio_lutnum_t lutNum,cy_en_smartio_lutopc_t opcode)658 cy_en_smartio_status_t Cy_SmartIO_SetLutOpcode(SMARTIO_PRT_Type* base, cy_en_smartio_lutnum_t lutNum, cy_en_smartio_lutopc_t opcode)
659 {
660     cy_en_smartio_status_t status = CY_SMARTIO_LOCKED;
661     uint32_t tempReg;
662 
663     if(CY_SMARTIO_DISABLE == _FLD2VAL(SMARTIO_PRT_CTL_ENABLED, SMARTIO_PRT_CTL(base)))
664     {
665         tempReg = (SMARTIO_PRT_LUT_CTL(base, lutNum) & (~SMARTIO_PRT_LUT_CTL_LUT_OPC_Msk));
666         SMARTIO_PRT_LUT_CTL(base, lutNum) = tempReg | _VAL2FLD(SMARTIO_PRT_LUT_CTL_LUT_OPC, opcode);
667         status = CY_SMARTIO_SUCCESS;
668     }
669 
670     return(status);
671 }
672 
673 
674 /*******************************************************************************
675 * Function Name: Cy_SmartIO_SetLutMap
676 ****************************************************************************//**
677 *
678 * \brief Sets the 3 bit input to 1 bit output mapping of the specified LUT.
679 *
680 * <table class="doxtable">
681 *   <tr><th>tr2</th><th>tr1</th><th>tr0</th><th>lutMap</th></tr>
682 *   <tr><td> 0 </td><td> 0 </td><td> 0 </td><td> bit 0 </td></tr>
683 *   <tr><td> 0 </td><td> 0 </td><td> 1 </td><td> bit 1 </td></tr>
684 *   <tr><td> 0 </td><td> 1 </td><td> 0 </td><td> bit 2 </td></tr>
685 *   <tr><td> 0 </td><td> 1 </td><td> 1 </td><td> bit 3 </td></tr>
686 *   <tr><td> 1 </td><td> 0 </td><td> 0 </td><td> bit 4 </td></tr>
687 *   <tr><td> 1 </td><td> 0 </td><td> 1 </td><td> bit 5 </td></tr>
688 *   <tr><td> 1 </td><td> 1 </td><td> 0 </td><td> bit 6 </td></tr>
689 *   <tr><td> 1 </td><td> 1 </td><td> 1 </td><td> bit 7 </td></tr>
690 * </table>
691 *
692 * \param base
693 * Pointer to the Smart I/O base address
694 *
695 * \param lutNum
696 * LUT index number
697 *
698 * \param lutMap
699 * Bitfield [7:0] mapping of the 3:1 LUT
700 *
701 * \return
702 * Status of the operation
703 *
704 * \note The Smart I/O block must be disabled before calling this function.
705 *
706 * \funcusage
707 * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_SetLutMap
708 *
709 *******************************************************************************/
Cy_SmartIO_SetLutMap(SMARTIO_PRT_Type * base,cy_en_smartio_lutnum_t lutNum,uint8_t lutMap)710 cy_en_smartio_status_t Cy_SmartIO_SetLutMap(SMARTIO_PRT_Type* base, cy_en_smartio_lutnum_t lutNum, uint8_t lutMap)
711 {
712     cy_en_smartio_status_t status = CY_SMARTIO_LOCKED;
713     uint32_t tempReg;
714 
715     if(CY_SMARTIO_DISABLE == _FLD2VAL(SMARTIO_PRT_CTL_ENABLED, SMARTIO_PRT_CTL(base)))
716     {
717         tempReg = (SMARTIO_PRT_LUT_CTL(base, lutNum) & (~SMARTIO_PRT_LUT_CTL_LUT_Msk));
718         SMARTIO_PRT_LUT_CTL(base, lutNum) = tempReg | _VAL2FLD(SMARTIO_PRT_LUT_CTL_LUT, lutMap);
719         status = CY_SMARTIO_SUCCESS;
720     }
721 
722     return(status);
723 }
724 
725 
726 /*******************************************************************************
727 * Function Name: Cy_SmartIO_GetDuTr
728 ****************************************************************************//**
729 *
730 * \brief Gets the data unit input trigger source.
731 *
732 * \param base
733 * Pointer to the Smart I/O base address
734 *
735 * \param trNum
736 * Input trigger number
737 *
738 * \return
739 * Data unit input trigger source
740 *
741 * \funcusage
742 * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_GetDuTr
743 *
744 *******************************************************************************/
Cy_SmartIO_GetDuTr(SMARTIO_PRT_Type * base,cy_en_smartio_trnum_t trNum)745 cy_en_smartio_dutr_t Cy_SmartIO_GetDuTr(SMARTIO_PRT_Type* base, cy_en_smartio_trnum_t trNum)
746 {
747     cy_en_smartio_dutr_t trSrc;
748 
749     switch(trNum)
750     {
751         case(CY_SMARTIO_TR0):
752         {
753             trSrc = (cy_en_smartio_dutr_t)_FLD2VAL(SMARTIO_PRT_DU_SEL_DU_TR0_SEL, SMARTIO_PRT_DU_SEL(base));
754             break;
755         }
756         case(CY_SMARTIO_TR1):
757         {
758             trSrc = (cy_en_smartio_dutr_t)_FLD2VAL(SMARTIO_PRT_DU_SEL_DU_TR1_SEL, SMARTIO_PRT_DU_SEL(base));
759             break;
760         }
761         case(CY_SMARTIO_TR2):
762         {
763             trSrc = (cy_en_smartio_dutr_t)_FLD2VAL(SMARTIO_PRT_DU_SEL_DU_TR2_SEL, SMARTIO_PRT_DU_SEL(base));
764             break;
765         }
766         default:
767         {
768             trSrc = CY_SMARTIO_DUTR_INVALID;
769             break;
770         }
771     }
772 
773     return(trSrc);
774 }
775 
776 
777 /*******************************************************************************
778 * Function Name: Cy_SmartIO_SetDuTr
779 ****************************************************************************//**
780 *
781 * \brief Sets the data unit input trigger source.
782 *
783 * \param base
784 * Pointer to the Smart I/O base address
785 *
786 * \param trNum
787 * Input trigger number
788 *
789 * \param trSrc
790 * Input trigger source
791 *
792 * \return
793 * Status of the operation
794 *
795 * \note The Smart I/O block must be disabled before calling this function.
796 *
797 * \funcusage
798 * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_SetDuTr
799 *
800 *******************************************************************************/
Cy_SmartIO_SetDuTr(SMARTIO_PRT_Type * base,cy_en_smartio_trnum_t trNum,cy_en_smartio_dutr_t trSrc)801 cy_en_smartio_status_t Cy_SmartIO_SetDuTr(SMARTIO_PRT_Type* base, cy_en_smartio_trnum_t trNum, cy_en_smartio_dutr_t trSrc)
802 {
803     cy_en_smartio_status_t status = CY_SMARTIO_LOCKED;
804     uint32_t tempReg;
805 
806     if(CY_SMARTIO_DISABLE == _FLD2VAL(SMARTIO_PRT_CTL_ENABLED, SMARTIO_PRT_CTL(base)))
807     {
808         status = CY_SMARTIO_SUCCESS;
809         switch(trNum)
810         {
811             case(CY_SMARTIO_TR0):
812             {
813                 tempReg = (SMARTIO_PRT_DU_SEL(base) & (~SMARTIO_PRT_DU_SEL_DU_TR0_SEL_Msk));
814                 SMARTIO_PRT_DU_SEL(base) = tempReg | _VAL2FLD(SMARTIO_PRT_DU_SEL_DU_TR0_SEL, trSrc);
815                 break;
816             }
817             case(CY_SMARTIO_TR1):
818             {
819                 tempReg = (SMARTIO_PRT_DU_SEL(base) & (~SMARTIO_PRT_DU_SEL_DU_TR1_SEL_Msk));
820                 SMARTIO_PRT_DU_SEL(base) = tempReg | _VAL2FLD(SMARTIO_PRT_DU_SEL_DU_TR1_SEL, trSrc);
821                 break;
822             }
823             case(CY_SMARTIO_TR2):
824             {
825                 tempReg = (SMARTIO_PRT_DU_SEL(base) & (~SMARTIO_PRT_DU_SEL_DU_TR2_SEL_Msk));
826                 SMARTIO_PRT_DU_SEL(base) = tempReg | _VAL2FLD(SMARTIO_PRT_DU_SEL_DU_TR2_SEL, trSrc);
827                 break;
828             }
829             default:
830             {
831                 status = CY_SMARTIO_BAD_PARAM;
832                 break;
833             }
834         }
835     }
836 
837     return status;
838 }
839 
840 
841 /*******************************************************************************
842 * Function Name: Cy_SmartIO_SetDuTrAll
843 ****************************************************************************//**
844 *
845 * \brief Sets all the data unit input trigger sources.
846 *
847 * \param base
848 * Pointer to the Smart I/O base address
849 *
850 * \param trSrc
851 * Input trigger source
852 *
853 * \return
854 * Status of the operation
855 *
856 * \note The Smart I/O block must be disabled before calling this function.
857 *
858 * \funcusage
859 * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_SetDuTrAll
860 *
861 *******************************************************************************/
Cy_SmartIO_SetDuTrAll(SMARTIO_PRT_Type * base,cy_en_smartio_dutr_t trSrc)862 cy_en_smartio_status_t Cy_SmartIO_SetDuTrAll(SMARTIO_PRT_Type* base, cy_en_smartio_dutr_t trSrc)
863 {
864     cy_en_smartio_status_t status = CY_SMARTIO_LOCKED;
865     uint32_t tempReg;
866 
867     if(CY_SMARTIO_DISABLE == _FLD2VAL(SMARTIO_PRT_CTL_ENABLED, SMARTIO_PRT_CTL(base)))
868     {
869         tempReg = (SMARTIO_PRT_DU_SEL(base)
870                     & (~(SMARTIO_PRT_DU_SEL_DU_TR0_SEL_Msk
871                         | SMARTIO_PRT_DU_SEL_DU_TR1_SEL_Msk
872                         | SMARTIO_PRT_DU_SEL_DU_TR2_SEL_Msk)));
873         SMARTIO_PRT_DU_SEL(base) = tempReg
874                         | _VAL2FLD(SMARTIO_PRT_DU_SEL_DU_TR0_SEL, trSrc)
875                         | _VAL2FLD(SMARTIO_PRT_DU_SEL_DU_TR1_SEL, trSrc)
876                         | _VAL2FLD(SMARTIO_PRT_DU_SEL_DU_TR2_SEL, trSrc);
877         status = CY_SMARTIO_SUCCESS;
878     }
879 
880     return status;
881 }
882 
883 
884 /*******************************************************************************
885 * Function Name: Cy_SmartIO_SetDuData
886 ****************************************************************************//**
887 *
888 * \brief Sets the data unit's input "data" source.
889 *
890 * \param base
891 * Pointer to the Smart I/O base address
892 *
893 * \param dataNum
894 * Input data number
895 *
896 * \param dataSrc
897 * Data unit input trigger source
898 *
899 * \return
900 * Status of the operation
901 *
902 * \note The Smart I/O block must be disabled before calling this function.
903 *
904 * \funcusage
905 * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_SetDuData
906 *
907 *******************************************************************************/
Cy_SmartIO_SetDuData(SMARTIO_PRT_Type * base,cy_en_smartio_datanum_t dataNum,cy_en_smartio_dudata_t dataSrc)908 cy_en_smartio_status_t Cy_SmartIO_SetDuData(SMARTIO_PRT_Type* base, cy_en_smartio_datanum_t dataNum, cy_en_smartio_dudata_t dataSrc)
909 {
910     cy_en_smartio_status_t status = CY_SMARTIO_LOCKED;
911     uint32_t tempReg;
912 
913     if(CY_SMARTIO_DISABLE == _FLD2VAL(SMARTIO_PRT_CTL_ENABLED, SMARTIO_PRT_CTL(base)))
914     {
915         if(dataNum == CY_SMARTIO_DATA0)
916         {
917             tempReg = (SMARTIO_PRT_DU_SEL(base) & (~SMARTIO_PRT_DU_SEL_DU_DATA0_SEL_Msk));
918             SMARTIO_PRT_DU_SEL(base) = tempReg | _VAL2FLD(SMARTIO_PRT_DU_SEL_DU_DATA0_SEL, dataSrc);
919         }
920         else
921         {
922             tempReg = (SMARTIO_PRT_DU_SEL(base) & (~SMARTIO_PRT_DU_SEL_DU_DATA1_SEL_Msk));
923             SMARTIO_PRT_DU_SEL(base) = tempReg | _VAL2FLD(SMARTIO_PRT_DU_SEL_DU_DATA1_SEL, dataSrc);
924         }
925         status = CY_SMARTIO_SUCCESS;
926     }
927 
928     return status;
929 }
930 
931 
932 /*******************************************************************************
933 * Function Name: Cy_SmartIO_SetDuOperation
934 ****************************************************************************//**
935 *
936 * \brief Sets the data unit's opcode and operand bit-width.
937 *
938 * \param base
939 * Pointer to the Smart I/O base address
940 *
941 * \param opcode
942 * Data Unit opcode
943 *
944 * \param size
945 * Data unit operand bit-width
946 *
947 * \return
948 * Status of the operation
949 *
950 * \note The Smart I/O block must be disabled before calling this function.
951 *
952 * \funcusage
953 * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_SetDuOperation
954 *
955 *******************************************************************************/
Cy_SmartIO_SetDuOperation(SMARTIO_PRT_Type * base,cy_en_smartio_duopc_t opcode,cy_en_smartio_dusize_t size)956 cy_en_smartio_status_t Cy_SmartIO_SetDuOperation(SMARTIO_PRT_Type* base, cy_en_smartio_duopc_t opcode, cy_en_smartio_dusize_t size)
957 {
958     cy_en_smartio_status_t status = CY_SMARTIO_LOCKED;
959 
960     if(CY_SMARTIO_DISABLE == _FLD2VAL(SMARTIO_PRT_CTL_ENABLED, SMARTIO_PRT_CTL(base)))
961     {
962         SMARTIO_PRT_DU_CTL(base) = _VAL2FLD(SMARTIO_PRT_DU_CTL_DU_SIZE, size)
963                                     | _VAL2FLD(SMARTIO_PRT_DU_CTL_DU_OPC, opcode);
964         status = CY_SMARTIO_SUCCESS;
965     }
966 
967     return status;
968 }
969 
970 
971 /*******************************************************************************
972 * Function Name: Cy_SmartIO_SetDataReg
973 ****************************************************************************//**
974 *
975 * \brief Sets the data unit's DATA register value.
976 *
977 * \param base
978 * Pointer to the Smart I/O base address
979 *
980 * \param dataReg
981 * DATA register value
982 *
983 * \return
984 * Status of the operation
985 *
986 * \note The Smart I/O block must be disabled before calling this function.
987 *
988 * \funcusage
989 * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_SetDataReg
990 *
991 *******************************************************************************/
Cy_SmartIO_SetDataReg(SMARTIO_PRT_Type * base,uint8_t dataReg)992 cy_en_smartio_status_t Cy_SmartIO_SetDataReg(SMARTIO_PRT_Type* base, uint8_t dataReg)
993 {
994     cy_en_smartio_status_t status = CY_SMARTIO_LOCKED;
995 
996     if(CY_SMARTIO_DISABLE == _FLD2VAL(SMARTIO_PRT_CTL_ENABLED, SMARTIO_PRT_CTL(base)))
997     {
998         SMARTIO_PRT_DATA(base) = dataReg;
999         status = CY_SMARTIO_SUCCESS;
1000     }
1001 
1002     return status;
1003 }
1004 
1005 CY_MISRA_BLOCK_END('MISRA C-2012 Rule 10.8')
1006 
1007 #if defined(__cplusplus)
1008 }
1009 #endif
1010 
1011 #endif /* (defined (CY_IP_MXS40IOSS) || defined(CY_IP_MXS40SIOSS) || defined(CY_IP_MXS22IOSS)) */
1012 
1013 /* [] END OF FILE */
1014