1 /***************************************************************************//**
2 * \file cy_usbfs_dev_drv_reg.h
3 * \version 2.20.2
4 *
5 * Provides register access API implementation of the USBFS driver.
6 *
7 ********************************************************************************
8 * \copyright
9 * Copyright 2018-2020 Cypress Semiconductor Corporation
10 * SPDX-License-Identifier: Apache-2.0
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *******************************************************************************/
24
25
26 /** \cond INTERNAL */
27
28 /**
29 * \addtogroup group_usbfs_dev_drv_reg
30 * \{
31 *
32 * Register access API for the USBFS Device block.
33 *
34 * This is the API that provides an interface to the USBFS Device hardware.
35 * These API are intended to be used by the USBFS Device driver to access
36 * hardware. You can use these API to implement a custom driver based on
37 * the USBFS Device hardware.
38 *
39 * \defgroup group_usbfs_dev_drv_reg_macros Macros
40 * \{
41 * \defgroup group_usbfs_dev_drv_reg_macros_hardware Hardware-specific Constants
42 * \defgroup group_usbfs_dev_drv_reg_macros_sie_intr SIE Interrupt Sources
43 * \defgroup group_usbfs_dev_drv_reg_macros_sie_mode SIE Endpoint Modes
44 * \defgroup group_usbfs_dev_drv_reg_macros_arb_ep_intr Arbiter Endpoint Interrupt Sources
45 * \}
46 *
47 * \defgroup group_usbfs_drv_drv_reg_functions Functions
48 * \{
49 * \defgroup group_usbfs_drv_drv_reg_interrupt_sources SIE Interrupt Sources Registers Access
50 * \defgroup group_usbfs_drv_drv_reg_ep0_access Endpoint 0 Registers Access
51 * \defgroup group_usbfs_drv_drv_reg_sie_access SIE Data Endpoint Registers Access
52 * \defgroup group_usbfs_drv_drv_reg_arbiter Arbiter Endpoint Registers Access
53 * \defgroup group_usbfs_drv_drv_reg_arbiter_data Arbiter Endpoint Data Registers Access
54 * \defgroup group_usbfs_drv_drv_reg_misc Miscellaneous Functions
55 * \}
56 *
57 * \}
58 */
59
60
61 #if !defined(CY_USBFS_DEV_DRV_REG_H)
62 #define CY_USBFS_DEV_DRV_REG_H
63
64 #include "cy_device.h"
65
66 #if defined (CY_IP_MXUSBFS) && defined (CY_IP_MXPERI)
67
68 #include <stdint.h>
69 #include <stddef.h>
70 #include <stdbool.h>
71 #include "cy_syslib.h"
72
73 #if defined(__cplusplus)
74 extern "C" {
75 #endif
76
77 /*******************************************************************************
78 * Hardware-specific Constants
79 *******************************************************************************/
80
81 /**
82 * \addtogroup group_usbfs_dev_drv_reg_macros_hardware
83 * \{
84 */
85 /** Number of data endpoints supported by the hardware */
86 #define CY_USBFS_DEV_DRV_NUM_EPS_MAX (8U)
87
88 /** The hardware buffer size used for data endpoint buffers */
89 #define CY_USBFS_DEV_DRV_HW_BUFFER_SIZE (512U)
90
91 /** The hardware buffer for endpoint 0 */
92 #define CY_USBFS_DEV_DRV_EP0_BUFFER_SIZE (8U)
93 /** \} group_usbfs_dev_drv_reg_macros_hardware */
94
95
96 /*******************************************************************************
97 * Functions
98 *******************************************************************************/
99
100 /**
101 * \addtogroup group_usbfs_drv_drv_reg_interrupt_sources
102 * \{
103 */
104 /* Access to LPM SIE interrupt sources */
105 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieInterruptStatus(USBFS_Type const *base);
106 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetSieInterruptMask (USBFS_Type *base, uint32_t mask);
107 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieInterruptMask (USBFS_Type const *base);
108 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieInterruptStatusMasked(USBFS_Type const *base);
109 __STATIC_INLINE void Cy_USBFS_Dev_Drv_ClearSieInterrupt (USBFS_Type *base, uint32_t mask);
110 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetSieInterrupt (USBFS_Type *base, uint32_t mask);
111 /** \} group_usbfs_drv_drv_reg_interrupt_sources */
112
113
114 /**
115 * \addtogroup group_usbfs_drv_drv_reg_ep0_access
116 * \{
117 */
118 /* Access control endpoint CR0.Mode registers */
119 __STATIC_INLINE void Cy_USBFS_Dev_Drv_WriteEp0Mode(USBFS_Type *base, uint32_t mode);
120 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_ReadEp0Mode(USBFS_Type const *base);
121
122 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetEp0Count(USBFS_Type *base, uint32_t count, uint32_t toggle);
123 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetEp0Count(USBFS_Type const *base);
124
125 __STATIC_INLINE void Cy_USBFS_Dev_Drv_WriteEp0Data(USBFS_Type *base, uint32_t idx, uint32_t value);
126 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_ReadEp0Data(USBFS_Type const *base, uint32_t idx);
127 /** \} group_usbfs_drv_drv_reg_ep0_access */
128
129 /**
130 * \addtogroup group_usbfs_drv_drv_reg_sie_access
131 * \{
132 */
133 /* Access SIE data endpoints CR0.Mode registers */
134 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetSieEpMode (USBFS_Type *base, uint32_t endpoint, uint32_t mode);
135 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieEpMode (USBFS_Type const *base, uint32_t endpoint);
136 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetSieEpStall (USBFS_Type *base, bool inDirection, uint32_t endpoint);
137 __STATIC_INLINE void Cy_USBFS_Dev_Drv_ClearSieEpStall(USBFS_Type *base, uint32_t endpoint, uint32_t mode);
138 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieEpError (USBFS_Type const *base, uint32_t endpoint);
139
140 /* Access SIE data endpoints CNT0 and CNT1 registers */
141 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieEpToggle (USBFS_Type const *base, uint32_t endpoint);
142 __STATIC_INLINE void Cy_USBFS_Dev_Drv_ClearSieEpToggle(USBFS_Type *base, uint32_t endpoint);
143 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieEpCount(USBFS_Type const *base, uint32_t endpoint);
144 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetSieEpCount(USBFS_Type *base, uint32_t endpoint, uint32_t count, uint32_t toggle);
145
146 /* Access SIE data endpoints interrupt source registers */
147 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieAllEpsInterruptStatus(USBFS_Type const *base);
148 __STATIC_INLINE void Cy_USBFS_Dev_Drv_EnableSieEpInterrupt (USBFS_Type *base, uint32_t endpoint);
149 __STATIC_INLINE void Cy_USBFS_Dev_Drv_DisableSieEpInterrupt(USBFS_Type *base, uint32_t endpoint);
150 __STATIC_INLINE void Cy_USBFS_Dev_Drv_ClearSieEpInterrupt (USBFS_Type *base, uint32_t endpoint);
151 /** \} group_usbfs_drv_drv_reg_sie_access */
152
153 /**
154 * \addtogroup group_usbfs_drv_drv_reg_arbiter
155 * \{
156 */
157 /* Access Arbiter data endpoints interrupt sources registers */
158 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetArbAllEpsInterruptStatus(USBFS_Type const *base);
159 __STATIC_INLINE void Cy_USBFS_Dev_Drv_EnableArbEpInterrupt (USBFS_Type *base, uint32_t endpoint);
160 __STATIC_INLINE void Cy_USBFS_Dev_Drv_DisableArbEpInterrupt(USBFS_Type *base, uint32_t endpoint);
161 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetArbEpInterruptMask(USBFS_Type *base, uint32_t endpoint, uint32_t mask);
162 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetArbEpInterruptMask(USBFS_Type const *base, uint32_t endpoint);
163 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetArbEpInterruptStatusMasked(USBFS_Type const *base, uint32_t endpoint);
164 __STATIC_INLINE void Cy_USBFS_Dev_Drv_ClearArbEpInterrupt(USBFS_Type *base, uint32_t endpoint, uint32_t mask);
165
166 /* Access Arbiter data endpoints configuration register */
167 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetArbEpConfig (USBFS_Type *base, uint32_t endpoint, uint32_t cfg);
168 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetArbCfgEpInReady (USBFS_Type *base, uint32_t endpoint);
169 __STATIC_INLINE void Cy_USBFS_Dev_Drv_ClearArbCfgEpInReady (USBFS_Type *base, uint32_t endpoint);
170 __STATIC_INLINE void Cy_USBFS_Dev_Drv_TriggerArbCfgEpDmaReq(USBFS_Type *base, uint32_t endpoint);
171
172 /* Access Arbiter data endpoints WA (Write Address and RA(Read Address) registers */
173 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetArbWriteAddr(USBFS_Type *base, uint32_t endpoint, uint32_t wa);
174 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetArbReadAddr (USBFS_Type *base, uint32_t endpoint, uint32_t ra);
175 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetArbWriteAddr(USBFS_Type const *base, uint32_t endpoint);
176 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetArbReadAddr (USBFS_Type const *base, uint32_t endpoint);
177 /** \} group_usbfs_drv_drv_reg_arbiter */
178
179 /**
180 * \addtogroup group_usbfs_drv_drv_reg_arbiter_data
181 * \{
182 */
183 /* Access data endpoints data registers. Used to get/put data into endpoint buffer */
184 __STATIC_INLINE void Cy_USBFS_Dev_Drv_WriteData (USBFS_Type *base, uint32_t endpoint, uint8_t byte);
185 __STATIC_INLINE void Cy_USBFS_Dev_Drv_WriteData16(USBFS_Type *base, uint32_t endpoint, uint16_t halfword);
186 __STATIC_INLINE uint8_t Cy_USBFS_Dev_Drv_ReadData (USBFS_Type const *base, uint32_t endpoint);
187 __STATIC_INLINE uint16_t Cy_USBFS_Dev_Drv_ReadData16 (USBFS_Type const *base, uint32_t endpoint);
188 __STATIC_INLINE volatile uint32_t * Cy_USBFS_Dev_Drv_GetDataRegAddr (USBFS_Type *base, uint32_t endpoint);
189 __STATIC_INLINE volatile uint32_t * Cy_USBFS_Dev_Drv_GetDataReg16Addr(USBFS_Type *base, uint32_t endpoint);
190 __STATIC_INLINE void Cy_USBFS_Dev_Drv_FlushInBuffer (USBFS_Type *base, uint32_t endpoint);
191 /** \} group_usbfs_drv_drv_reg_arbiter_data */
192
193 /**
194 * \addtogroup group_usbfs_drv_drv_reg_misc
195 * \{
196 */
197 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetEpType (USBFS_Type *base, bool inDirection, uint32_t endpoint);
198 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSofNubmer(USBFS_Type const *base);
199 /** \} group_usbfs_drv_drv_reg_misc */
200
201
202 /*******************************************************************************
203 * API Constants
204 *******************************************************************************/
205
206 /** /cond INTERNAL */
207 /* Macro to access ODD offset registers: Cypress ID# 299773 */
208 #define CY_USBFS_DEV_DRV_WRITE_ODD(val) ( (val) | ((uint32_t) (val) << 8U) )
209 #define CY_USBFS_DEV_READ_ODD(reg) ( (uint32_t) (CY_LO8((reg) | ((reg) >> 8U))) )
210 /** /endcond */
211
212 /**
213 * \addtogroup group_usbfs_dev_drv_reg_macros_sie_intr
214 * \{
215 */
216 #define CY_USBFS_DEV_DRV_INTR_SIE_SOF USBFS_USBLPM_INTR_SIE_SOF_INTR_Msk /**< SOF frame detected */
217 #define CY_USBFS_DEV_DRV_INTR_SIE_BUS_RESET USBFS_USBLPM_INTR_SIE_BUS_RESET_INTR_Msk /**< Bus Reset detected */
218 #define CY_USBFS_DEV_DRV_INTR_SIE_EP0 USBFS_USBLPM_INTR_SIE_EP0_INTR_Msk /**< EP0 access detected */
219 #define CY_USBFS_DEV_DRV_INTR_SIE_LPM USBFS_USBLPM_INTR_SIE_LPM_INTR_Msk /**< Link Power Management request detected */
220 #define CY_USBFS_DEV_DRV_INTR_SIE_RESUME USBFS_USBLPM_INTR_SIE_RESUME_INTR_Msk /**< Resume condition detected */
221 /** \} group_usbfs_dev_drv_reg_macros_sie_intr */
222
223 /**
224 * \addtogroup group_usbfs_dev_drv_reg_macros_sie_mode
225 * \{
226 */
227 /* Modes for endpoint 0 (control endpoint) */
228 #define CY_USBFS_DEV_DRV_EP_CR_DISABLE (0U) /**< Data endpoint disabled */
229 #define CY_USBFS_DEV_DRV_EP_CR_NAK_INOUT (1U) /**< Data endpoint NAK IN and OUT requests */
230 #define CY_USBFS_DEV_DRV_EP_CR_STALL_INOUT (3U) /**< Data endpoint STALL IN and OUT requests */
231 #define CY_USBFS_DEV_DRV_EP_CR_STATUS_OUT_ONLY (2U) /**< Data endpoint ACK only Status OUT requests */
232 #define CY_USBFS_DEV_DRV_EP_CR_STATUS_IN_ONLY (6U) /**< Data endpoint ACK only Status IN requests */
233 #define CY_USBFS_DEV_DRV_EP_CR_ACK_OUT_STATUS_IN (11U) /**< Data endpoint ACK only Data and Status OUT requests */
234 #define CY_USBFS_DEV_DRV_EP_CR_ACK_IN_STATUS_OUT (15U) /**< Data endpoint ACK only Data and Status IN requests */
235
236 /* Modes for ISO data endpoints */
237 #define CY_USBFS_DEV_DRV_EP_CR_ISO_OUT (5U) /**< Data endpoint is ISO OUT */
238 #define CY_USBFS_DEV_DRV_EP_CR_ISO_IN (7U) /**< Data endpoint is ISO IN */
239
240 /* Modes for Control/Bulk/Interrupt OUT data endpoints */
241 #define CY_USBFS_DEV_DRV_EP_CR_NAK_OUT (8U) /**< Data endpoint NAK OUT requests */
242 #define CY_USBFS_DEV_DRV_EP_CR_ACK_OUT (9U) /**< Data endpoint ACK OUT requests */
243
244 /* Modes for Control/Bulk/Interrupt IN data endpoints */
245 #define CY_USBFS_DEV_DRV_EP_CR_NAK_IN (12U) /**< Data endpoint NAK IN requests */
246 #define CY_USBFS_DEV_DRV_EP_CR_ACK_IN (13U) /**< Data endpoint ACK IN requests */
247 /** \} group_usbfs_dev_drv_reg_macros_sie_mode */
248
249 /**
250 * \addtogroup group_usbfs_dev_drv_reg_macros_arb_ep_intr ARB_EP_SR/INT_EN 1-8 registers
251 * \{
252 */
253
254 /** Data endpoint IN buffer full interrupt source */
255 #define USBFS_USBDEV_ARB_EP_IN_BUF_FULL_Msk USBFS_USBDEV_ARB_EP1_INT_EN_IN_BUF_FULL_EN_Msk
256 /** Data endpoint grant interrupt source (DMA complete read/write) */
257 #define USBFS_USBDEV_ARB_EP_DMA_GNT_Msk USBFS_USBDEV_ARB_EP1_INT_EN_DMA_GNT_EN_Msk
258 /** Data endpoint overflow interrupt source (applicable only for Automatic DMA mode) */
259 #define USBFS_USBDEV_ARB_EP_BUF_OVER_Msk USBFS_USBDEV_ARB_EP1_INT_EN_BUF_OVER_EN_Msk
260 /** Data endpoint underflow interrupt source (applicable only for Automatic DMA mode) */
261 #define USBFS_USBDEV_ARB_EP_BUF_UNDER_Msk USBFS_USBDEV_ARB_EP1_INT_EN_BUF_UNDER_EN_Msk
262 /** Endpoint Error in Transaction interrupt source */
263 #define USBFS_USBDEV_ARB_EP_ERR_Msk USBFS_USBDEV_ARB_EP1_INT_EN_ERR_INT_EN_Msk
264 /** Data endpoint terminate interrupt source (DMA complete reading) */
265 #define USBFS_USBDEV_ARB_EP_DMA_TERMIN_Msk USBFS_USBDEV_ARB_EP1_SR_DMA_TERMIN_Msk
266 /** \} group_usbfs_dev_drv_reg_macros_arb_ep_intr */
267
268 /**
269 * \addtogroup group_usbfs_dev_drv_reg_macros
270 * \{
271 */
272 /** Data toggle mask in CNT0 register */
273 #define USBFS_USBDEV_SIE_EP_DATA_TOGGLE_Msk USBFS_USBDEV_SIE_EP1_CNT0_DATA_TOGGLE_Msk
274 /** \} group_usbfs_dev_drv_reg_macros */
275
276 /** /cond INTERNAL */
277
278 /* Extended cyip_usbfs.h */
279
280 /* Count registers includes CRC size (2 bytes) */
281 #define CY_USBFS_DEV_DRV_EP_CRC_SIZE (2U)
282
283 /* DYN_RECONFIG register */
284 #define USBFS_USBDEV_DYN_RECONFIG_EN_Msk USBFS_USBDEV_DYN_RECONFIG_DYN_CONFIG_EN_Msk
285 #define USBFS_USBDEV_DYN_RECONFIG_EPNO_Pos USBFS_USBDEV_DYN_RECONFIG_DYN_RECONFIG_EPNO_Pos
286 #define USBFS_USBDEV_DYN_RECONFIG_EPNO_Msk USBFS_USBDEV_DYN_RECONFIG_DYN_RECONFIG_EPNO_Msk
287 #define USBFS_USBDEV_DYN_RECONFIG_RDY_STS_Msk USBFS_USBDEV_DYN_RECONFIG_DYN_RECONFIG_RDY_STS_Msk
288
289 /* LPM_CTL register */
290 #define USBFS_USBLPM_LPM_CTL_LPM_RESP_Pos (USBFS_USBLPM_LPM_CTL_LPM_ACK_RESP_Pos)
291 #define USBFS_USBLPM_LPM_CTL_LPM_RESP_Msk (USBFS_USBLPM_LPM_CTL_LPM_ACK_RESP_Msk | \
292 USBFS_USBLPM_LPM_CTL_NYET_EN_Msk)
293
294 /* ARB_EP_CFG 1-8 registers (default configuration) */
295 #define USBFS_USBDEV_ARB_EP_CFG_CRC_BYPASS_Msk USBFS_USBDEV_ARB_EP1_CFG_CRC_BYPASS_Msk
296 #define USBFS_USBDEV_ARB_EP_CFG_RESET_PTR_Msk USBFS_USBDEV_ARB_EP1_CFG_CRC_BYPASS_Msk
297 /** /endcond */
298
299
300 /*******************************************************************************
301 * In-line Function Implementation
302 *******************************************************************************/
303
304 /**
305 * \addtogroup group_usbfs_drv_drv_reg_interrupt_sources
306 * \{
307 */
308
309 /*******************************************************************************
310 * Function Name: Cy_USBFS_Dev_Drv_GetSieInterruptStatus
311 ****************************************************************************//**
312 *
313 * Returns the SIE interrupt request register.
314 * This register contains the current status of the SIE interrupt sources.
315 *
316 * \param base
317 * The pointer to the USBFS instance.
318 *
319 * \return
320 * The current status of the SIE interrupt sources.
321 * Each constant is a bit field value. The value returned may have multiple
322 * bits set to indicate the current status.
323 * See \ref group_usbfs_dev_drv_reg_macros_sie_intr for the set of constants.
324 *
325 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetSieInterruptStatus(USBFS_Type const * base)326 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieInterruptStatus(USBFS_Type const *base)
327 {
328 return USBFS_DEV_LPM_INTR_SIE(base);
329 }
330
331
332 /*******************************************************************************
333 * Function Name: Cy_USBFS_Dev_Drv_SetSieInterruptMask
334 ****************************************************************************//**
335 *
336 * Writes the SIE interrupt mask register.
337 * This register configures which bits from the SIE interrupt request register
338 * can trigger an interrupt event.
339 *
340 * \param base
341 * The pointer to the USBFS instance.
342 *
343 * \param mask
344 * Enabled SIE interrupt sources.
345 * See \ref group_usbfs_dev_drv_reg_macros_sie_intr for the set of constants.
346 *
347 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetSieInterruptMask(USBFS_Type * base,uint32_t mask)348 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetSieInterruptMask(USBFS_Type *base, uint32_t mask)
349 {
350 USBFS_DEV_LPM_INTR_SIE_MASK(base) = mask;
351 }
352
353
354 /*******************************************************************************
355 * Function Name: Cy_USBFS_Dev_Drv_GetSieInterruptMask
356 ****************************************************************************//**
357 *
358 * Returns the SIE interrupt mask register.
359 * This register specifies which bits from the SIE interrupt request register
360 * trigger can an interrupt event.
361 *
362 * \param base
363 * The pointer to the USBFS instance.
364 *
365 * \return
366 * Enabled SIE interrupt sources.
367 * See \ref group_usbfs_dev_drv_reg_macros_sie_intr for the set of constants.
368 *
369 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetSieInterruptMask(USBFS_Type const * base)370 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieInterruptMask(USBFS_Type const *base)
371 {
372 return USBFS_DEV_LPM_INTR_SIE_MASK(base);
373 }
374
375
376 /*******************************************************************************
377 * Function Name: Cy_USBFS_Dev_Drv_GetSieInterruptStatusMasked
378 ****************************************************************************//**
379 *
380 * Returns the SIE interrupt masked request register.
381 * This register contains a logical AND of corresponding bits from the SIE
382 * interrupt request and mask registers.
383 * This function is intended to be used in the interrupt service routine to
384 * identify which of the enabled SIE interrupt sources caused the interrupt
385 * event.
386 *
387 * \param base
388 * The pointer to the USBFS instance.
389 *
390 * \return
391 * The current status of enabled SIE interrupt sources.
392 * See \ref group_usbfs_dev_drv_reg_macros_sie_intr for the set of constants.
393 *
394 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetSieInterruptStatusMasked(USBFS_Type const * base)395 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieInterruptStatusMasked(USBFS_Type const *base)
396 {
397 return USBFS_DEV_LPM_INTR_SIE_MASKED(base);
398 }
399
400
401 /*******************************************************************************
402 * Function Name: Cy_USBFS_Dev_Drv_ClearSieInterrupt
403 ****************************************************************************//**
404 *
405 * Clears the SIE interrupt sources in the interrupt request register.
406 *
407 * \param base
408 * The pointer to the USBFS instance.
409 *
410 * \param mask
411 * The SIE interrupt sources to be cleared.
412 * See \ref group_usbfs_dev_drv_reg_macros_sie_intr for the set of constants.
413 *
414 *******************************************************************************/
Cy_USBFS_Dev_Drv_ClearSieInterrupt(USBFS_Type * base,uint32_t mask)415 __STATIC_INLINE void Cy_USBFS_Dev_Drv_ClearSieInterrupt(USBFS_Type *base, uint32_t mask)
416 {
417 USBFS_DEV_LPM_INTR_SIE(base) = mask;
418 (void) USBFS_DEV_LPM_INTR_SIE(base);
419 }
420
421
422 /*******************************************************************************
423 * Function Name: Cy_USBFS_Dev_Drv_SetSieInterrupt
424 ****************************************************************************//**
425 *
426 * Sets the SIE interrupt sources in the interrupt request register.
427 *
428 * \param base
429 * The pointer to the USBFS instance.
430 *
431 * \param mask
432 * The SIE interrupt sources to be set in the SIE interrupt request register.
433 * See \ref group_usbfs_dev_drv_reg_macros_sie_intr for the set of constants.
434 *
435 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetSieInterrupt(USBFS_Type * base,uint32_t mask)436 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetSieInterrupt(USBFS_Type *base, uint32_t mask)
437 {
438 USBFS_DEV_LPM_INTR_SIE_SET(base) = mask;
439 }
440 /** \} group_usbfs_drv_drv_reg_interrupt_sources */
441
442
443 /**
444 * \addtogroup group_usbfs_drv_drv_reg_ep0_access
445 * \{
446 */
447 /*******************************************************************************
448 * Function Name: Cy_USBFS_Dev_Drv_WriteEp0Mode
449 ****************************************************************************//**
450 *
451 * Sets a mode in the CR0 register of endpoint 0 (clears all other bits in the
452 * register).
453 *
454 * \param base
455 * The pointer to the USBFS instance.
456 *
457 * \param mode
458 * SIE mode defines the data endpoint 0 response to a host request.
459 * See \ref group_usbfs_dev_drv_reg_macros_sie_mode for the set of constants.
460 *
461 *******************************************************************************/
Cy_USBFS_Dev_Drv_WriteEp0Mode(USBFS_Type * base,uint32_t mode)462 __STATIC_INLINE void Cy_USBFS_Dev_Drv_WriteEp0Mode(USBFS_Type *base, uint32_t mode)
463 {
464 USBFS_DEV_EP0_CR(base) = mode;
465 (void) USBFS_DEV_EP0_CR(base);
466 }
467
468 /*******************************************************************************
469 * Function Name: Cy_USBFS_Dev_Drv_ReadEp0Mode
470 ****************************************************************************//**
471 *
472 * Returns a mode in the CR0 register of endpoint 0.
473 *
474 * \param base
475 * The pointer to the USBFS instance.
476 *
477 * \return
478 * SIE mode (defines the endpoint 0 response to a host request).
479 * See \ref group_usbfs_dev_drv_reg_macros_sie_mode for the set of constants.
480 *
481 *******************************************************************************/
Cy_USBFS_Dev_Drv_ReadEp0Mode(USBFS_Type const * base)482 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_ReadEp0Mode(USBFS_Type const *base)
483 {
484 return USBFS_DEV_EP0_CR(base);
485 }
486
487
488 /*******************************************************************************
489 * Function Name: Cy_USBFS_Dev_Drv_SetSieEpCount
490 ****************************************************************************//**
491 *
492 * Configures the number of bytes and toggle bit to return to a host read request
493 * to endpoint 0.
494 *
495 * \param base
496 * The pointer to the USBFS instance.
497 *
498 * \param count
499 * The number of bytes to return to a host read request.
500 *
501 * \param toggle
502 * The data toggle bit.
503 * The range of valid values: 0 and \ref USBFS_USBDEV_SIE_EP_DATA_TOGGLE_Msk.
504 *
505 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetEp0Count(USBFS_Type * base,uint32_t count,uint32_t toggle)506 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetEp0Count(USBFS_Type *base, uint32_t count, uint32_t toggle)
507 {
508 count = _VAL2FLD(USBFS_USBDEV_EP0_CNT_BYTE_COUNT, count);
509 USBFS_DEV_EP0_CNT(base) = CY_USBFS_DEV_DRV_WRITE_ODD(count | toggle);
510 }
511
512
513 /*******************************************************************************
514 * Function Name: Cy_USBFS_Dev_Drv_GetEp0Count
515 ****************************************************************************//**
516 *
517 * Returns the number of data bytes written into endpoint 0 by the host.
518 *
519 * \param base
520 * The pointer to the USBFS instance.
521 *
522 * \return
523 * The number of bytes written by the host into the endpoint.
524 *
525 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetEp0Count(USBFS_Type const * base)526 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetEp0Count(USBFS_Type const *base)
527 {
528 uint32_t ep0Cnt = CY_USBFS_DEV_READ_ODD(USBFS_DEV_EP0_CNT(base));
529
530 /* Excludes the CRC size */
531 return (_FLD2VAL(USBFS_USBDEV_EP0_CNT_BYTE_COUNT, ep0Cnt) - CY_USBFS_DEV_DRV_EP_CRC_SIZE);
532 }
533
534
535 /*******************************************************************************
536 * Function Name: Cy_USBFS_Dev_Drv_WriteEp0Data
537 ****************************************************************************//**
538 *
539 * Writes an 8-bit byte into the endpoint 0 hardware buffer.
540 *
541 * \param base
542 * The pointer to the USBFS instance.
543 *
544 * \param idx
545 * The index of the endpoint 0 hardware buffer entry.
546 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_EP0_BUFFER_SIZE - 1 ).
547 *
548 * \param value
549 * The value to be written into the endpoint 0 hardware buffer.
550 *
551 *******************************************************************************/
Cy_USBFS_Dev_Drv_WriteEp0Data(USBFS_Type * base,uint32_t idx,uint32_t value)552 __STATIC_INLINE void Cy_USBFS_Dev_Drv_WriteEp0Data(USBFS_Type *base, uint32_t idx, uint32_t value)
553 {
554 if (0U == (idx & 0x1U))
555 {
556 USBFS_DEV_EP0_DR(base, idx) = value;
557 }
558 else
559 {
560 /* Applies a special write for odd offset registers */
561 USBFS_DEV_EP0_DR(base, idx) = CY_USBFS_DEV_DRV_WRITE_ODD(value);
562 }
563 }
564
565
566 /*******************************************************************************
567 * Function Name: Cy_USBFS_Dev_Drv_ReadEp0Data
568 ****************************************************************************//**
569 *
570 * Reads an 8-bit byte from the endpoint 0 hardware buffer.
571 *
572 * \param base
573 * The pointer to the USBFS instance.
574 *
575 * \param idx
576 * The index of the endpoint 0 hardware buffer entry.
577 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_EP0_BUFFER_SIZE - 1 ).
578 *
579 * \return
580 * The byte of data to read from the hardware buffer.
581 *
582 *******************************************************************************/
Cy_USBFS_Dev_Drv_ReadEp0Data(USBFS_Type const * base,uint32_t idx)583 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_ReadEp0Data(USBFS_Type const *base, uint32_t idx)
584 {
585 uint32_t value;
586
587 if (0U == (idx & 0x1U))
588 {
589 value = USBFS_DEV_EP0_DR(base, idx);
590 }
591 else
592 {
593 /* Applies a special write for odd offset registers */
594 value = CY_USBFS_DEV_READ_ODD(USBFS_DEV_EP0_DR(base, idx));
595 }
596
597 return (value);
598 }
599 /** \} group_usbfs_drv_drv_reg_ep0_access */
600
601
602 /**
603 * \addtogroup group_usbfs_drv_drv_reg_sie_access
604 * \{
605 */
606
607 /*******************************************************************************
608 * Function Name: Cy_USBFS_Dev_Drv_SetSieEpMode
609 ****************************************************************************//**
610 *
611 * Sets SIE mode in the CR0 register of the endpoint (does not touch other bits).
612 * All other bits except NAK_INT_EN are cleared by the hardware on any write
613 * in the register.
614 *
615 * \param base
616 * The pointer to the USBFS instance.
617 *
618 * \param endpoint
619 * Physical endpoint number.
620 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
621 *
622 * \param mode
623 * SIE mode defines data endpoint response to host request.
624 * See \ref group_usbfs_dev_drv_reg_macros_sie_mode for the set of constants.
625 *
626 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetSieEpMode(USBFS_Type * base,uint32_t endpoint,uint32_t mode)627 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetSieEpMode(USBFS_Type *base, uint32_t endpoint, uint32_t mode)
628 {
629 USBFS_DEV_SIE_EP_CR0(base, endpoint) = _CLR_SET_FLD32U(USBFS_DEV_SIE_EP_CR0(base, endpoint),
630 USBFS_USBDEV_SIE_EP1_CR0_MODE, mode);
631 (void) USBFS_DEV_SIE_EP_CR0(base, endpoint);
632 }
633
634
635 /*******************************************************************************
636 * Function Name: Cy_USBFS_Dev_Drv_GetSieEpMode
637 ****************************************************************************//**
638 *
639 * Returns SIE mode in the CR0 register of the endpoint.
640 *
641 * \param base
642 * The pointer to the USBFS instance.
643 *
644 * \param endpoint
645 * Physical endpoint number.
646 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
647 *
648 * \return
649 * SIE mode (defines data endpoint response to host request).
650 * See \ref group_usbfs_dev_drv_reg_macros_sie_mode for the set of constants.
651 *
652 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetSieEpMode(USBFS_Type const * base,uint32_t endpoint)653 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieEpMode(USBFS_Type const *base, uint32_t endpoint)
654 {
655 return (USBFS_DEV_SIE_EP_CR0(base, endpoint) & USBFS_USBDEV_SIE_EP1_CR0_MODE_Msk);
656 }
657
658
659 /*******************************************************************************
660 * Function Name: Cy_USBFS_Dev_Drv_SetSieEpStall
661 ****************************************************************************//**
662 *
663 * Configures endpoint to STALL requests.
664 *
665 * \param base
666 * The pointer to the USBFS instance.
667 *
668 * \param inDirection
669 * Defines whether endpoint direction is IN (true) or OUT (false).
670 *
671 * \param endpoint
672 * Physical endpoint number.
673 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
674 *
675 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetSieEpStall(USBFS_Type * base,bool inDirection,uint32_t endpoint)676 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetSieEpStall(USBFS_Type *base, bool inDirection, uint32_t endpoint)
677 {
678 /* STALL endpoint */
679 USBFS_DEV_SIE_EP_CR0(base, endpoint) = USBFS_USBDEV_SIE_EP1_CR0_STALL_Msk |
680 (inDirection ? CY_USBFS_DEV_DRV_EP_CR_ACK_IN :
681 CY_USBFS_DEV_DRV_EP_CR_ACK_OUT);
682 (void) USBFS_DEV_SIE_EP_CR0(base, endpoint);
683 }
684
685
686 /*******************************************************************************
687 * Function Name: Cy_USBFS_Dev_Drv_ClearSieEpStall
688 ****************************************************************************//**
689 *
690 * Writes SIE mode register of the data endpoint and clears other bits in this
691 * register.
692 *
693 * \param base
694 * The pointer to the USBFS instance.
695 *
696 * \param endpoint
697 * Physical endpoint number.
698 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
699 *
700 * \param mode
701 * SIE mode defines data endpoint response to host request.
702 * See \ref group_usbfs_dev_drv_reg_macros_sie_mode for the set of constants.
703 *
704 *******************************************************************************/
Cy_USBFS_Dev_Drv_ClearSieEpStall(USBFS_Type * base,uint32_t endpoint,uint32_t mode)705 __STATIC_INLINE void Cy_USBFS_Dev_Drv_ClearSieEpStall(USBFS_Type *base, uint32_t endpoint, uint32_t mode)
706 {
707 /* Set mode bits */
708 uint32_t regVal = _CLR_SET_FLD32U(USBFS_DEV_SIE_EP_CR0(base, endpoint),
709 USBFS_USBDEV_SIE_EP1_CR0_MODE, mode);
710
711 /* Clear STALL condition */
712 regVal &= ~USBFS_USBDEV_SIE_EP1_CR0_STALL_Msk;
713
714 /* Clear STALL condition and set mode */
715 USBFS_DEV_SIE_EP_CR0(base, endpoint) = regVal;
716 (void) USBFS_DEV_SIE_EP_CR0(base, endpoint);
717 }
718
719
720 /*******************************************************************************
721 * Function Name: Cy_USBFS_Dev_Drv_GetSieEpError
722 ****************************************************************************//**
723 *
724 * Returns value of data endpoint error in transaction bit.
725 *
726 * \param base
727 * The pointer to the USBFS instance.
728 *
729 * \param endpoint
730 * Physical endpoint number.
731 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
732 *
733 * \return
734 * Value of data endpoint error in transaction bit.
735 *
736 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetSieEpError(USBFS_Type const * base,uint32_t endpoint)737 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieEpError(USBFS_Type const *base, uint32_t endpoint)
738 {
739 return (USBFS_DEV_SIE_EP_CR0(base, endpoint) & USBFS_USBDEV_SIE_EP1_CR0_ERR_IN_TXN_Msk);
740 }
741
742
743 /*******************************************************************************
744 * Function Name: Cy_USBFS_Dev_Drv_GetSieEpToggle
745 ****************************************************************************//**
746 *
747 * Returns current value of data endpoint toggle bit.
748 *
749 * \param base
750 * The pointer to the USBFS instance.
751 *
752 * \param endpoint
753 * Physical endpoint number.
754 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
755 *
756 * \return
757 * Value of data endpoint toggle bit.
758 *
759 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetSieEpToggle(USBFS_Type const * base,uint32_t endpoint)760 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieEpToggle(USBFS_Type const *base, uint32_t endpoint)
761 {
762 /* Return data toggle bit */
763 return (USBFS_DEV_SIE_EP_CNT0(base, endpoint) & USBFS_USBDEV_SIE_EP1_CNT0_DATA_TOGGLE_Msk);
764 }
765
766
767 /*******************************************************************************
768 * Function Name: Cy_USBFS_Dev_Drv_ClearSieEpToggle
769 ****************************************************************************//**
770 *
771 * Resets to zero data endpoint toggle bit.
772 *
773 * \param base
774 * The pointer to the USBFS instance.
775 *
776 * \param endpoint
777 * Physical endpoint number.
778 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
779 *
780 * \return
781 * Number of bytes written by the host into the endpoint.
782 *
783 *******************************************************************************/
Cy_USBFS_Dev_Drv_ClearSieEpToggle(USBFS_Type * base,uint32_t endpoint)784 __STATIC_INLINE void Cy_USBFS_Dev_Drv_ClearSieEpToggle(USBFS_Type *base, uint32_t endpoint)
785 {
786 /* Clear data toggle bit */
787 USBFS_DEV_SIE_EP_CNT0(base, endpoint) &= ~USBFS_USBDEV_SIE_EP1_CNT0_DATA_TOGGLE_Msk;
788 }
789
790
791 /*******************************************************************************
792 * Function Name: Cy_USBFS_Dev_Drv_GetSieEpCount
793 ****************************************************************************//**
794 *
795 * Returns the number of data bytes written into the OUT data endpoint
796 * by the host.
797 *
798 * \param base
799 * The pointer to the USBFS instance.
800 *
801 * \param endpoint
802 * Physical endpoint number.
803 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
804 *
805 * \return
806 * Number of bytes written by the host into the endpoint.
807 *
808 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetSieEpCount(USBFS_Type const * base,uint32_t endpoint)809 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieEpCount(USBFS_Type const *base, uint32_t endpoint)
810 {
811 uint32_t size;
812
813 /* Get number of bytes transmitted or received by SIE */
814 size = _FLD2VAL(USBFS_USBDEV_SIE_EP1_CNT0_DATA_COUNT_MSB, USBFS_DEV_SIE_EP_CNT0(base, endpoint));
815 size = (size << 8U) | CY_USBFS_DEV_READ_ODD(USBFS_DEV_SIE_EP_CNT1(base, endpoint));
816
817 /* Exclude CRC size */
818 return (size - CY_USBFS_DEV_DRV_EP_CRC_SIZE);
819 }
820
821
822 /*******************************************************************************
823 * Function Name: Cy_USBFS_Dev_Drv_SetSieEpCount
824 ****************************************************************************//**
825 *
826 * Configures number of bytes and toggle bit to return on the host read request
827 * to the IN data endpoint.
828 *
829 * \param base
830 * The pointer to the USBFS instance.
831 *
832 * \param endpoint
833 * Physical endpoint number.
834 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
835 *
836 * \param count
837 * The number of bytes to return on the host read request.
838 *
839 * \param toggle
840 * The data toggle bit.
841 * The range of valid values: 0 and \ref USBFS_USBDEV_SIE_EP_DATA_TOGGLE_Msk.
842 *
843 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetSieEpCount(USBFS_Type * base,uint32_t endpoint,uint32_t count,uint32_t toggle)844 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetSieEpCount(USBFS_Type *base, uint32_t endpoint,
845 uint32_t count, uint32_t toggle)
846 {
847 USBFS_DEV_SIE_EP_CNT1(base, endpoint) = (uint32_t) CY_USBFS_DEV_DRV_WRITE_ODD(CY_LO8(count));
848 USBFS_DEV_SIE_EP_CNT0(base, endpoint) = (uint32_t) CY_HI8(count) | toggle;
849 }
850
851
852 /*******************************************************************************
853 * Function Name: Cy_USBFS_Dev_Drv_GetSieAllEpsInterruptStatus
854 ****************************************************************************//**
855 *
856 * Returns the SIE data endpoints interrupt request register.
857 * This register contains the current status of the SIE data endpoints transfer
858 * completion interrupt.
859 *
860 * \param base
861 * The pointer to the USBFS instance.
862 *
863 * \return
864 * The current status of the SIE interrupt sources.
865 * The returned status specifies for which endpoint interrupt is active as
866 * follows: bit 0 corresponds to data endpoint 1, bit 1 data endpoint 2 and so
867 * on up to \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX.
868 *
869 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetSieAllEpsInterruptStatus(USBFS_Type const * base)870 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieAllEpsInterruptStatus(USBFS_Type const *base)
871 {
872 return USBFS_DEV_SIE_EP_INT_SR(base);
873 }
874
875
876 /*******************************************************************************
877 * Function Name: Cy_USBFS_Dev_Drv_EnableSieEpInterrupt
878 ****************************************************************************//**
879 *
880 * Enables SIE data endpoint transfer completion interrupt.
881 *
882 * \param base
883 * The pointer to the USBFS instance.
884 *
885 * \param endpoint
886 * Physical endpoint number.
887 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
888 *
889 *******************************************************************************/
Cy_USBFS_Dev_Drv_EnableSieEpInterrupt(USBFS_Type * base,uint32_t endpoint)890 __STATIC_INLINE void Cy_USBFS_Dev_Drv_EnableSieEpInterrupt(USBFS_Type *base, uint32_t endpoint)
891 {
892 USBFS_DEV_SIE_EP_INT_EN(base) |= (uint32_t)(1UL << endpoint);
893 }
894
895
896 /*******************************************************************************
897 * Function Name: Cy_USBFS_Dev_Drv_DisableSieEpInterrupt
898 ****************************************************************************//**
899 *
900 * Disables SIE data endpoint transfer completion interrupt.
901 *
902 * \param base
903 * The pointer to the USBFS instance.
904 *
905 * \param endpoint
906 * Physical endpoint number.
907 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
908 *
909 *******************************************************************************/
Cy_USBFS_Dev_Drv_DisableSieEpInterrupt(USBFS_Type * base,uint32_t endpoint)910 __STATIC_INLINE void Cy_USBFS_Dev_Drv_DisableSieEpInterrupt(USBFS_Type *base, uint32_t endpoint)
911 {
912 USBFS_DEV_SIE_EP_INT_EN(base) &= ~ (uint32_t)(1UL << endpoint);
913 }
914
915
916 /*******************************************************************************
917 * Function Name: Cy_USBFS_Dev_Drv_ClearSieEpInterrupt
918 ****************************************************************************//**
919 *
920 * Clears the SIE EP interrupt sources in the interrupt request register.
921 *
922 * \param base
923 * The pointer to the USBFS instance.
924 *
925 * \param endpoint
926 * Physical endpoint number.
927 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
928 *
929 *******************************************************************************/
Cy_USBFS_Dev_Drv_ClearSieEpInterrupt(USBFS_Type * base,uint32_t endpoint)930 __STATIC_INLINE void Cy_USBFS_Dev_Drv_ClearSieEpInterrupt(USBFS_Type *base, uint32_t endpoint)
931 {
932 USBFS_DEV_SIE_EP_INT_SR(base) = (uint32_t)(1UL << endpoint);
933 (void) USBFS_DEV_SIE_EP_INT_SR(base);
934 }
935 /** \} group_usbfs_drv_drv_reg_sie_access */
936
937
938 /**
939 * \addtogroup group_usbfs_drv_drv_reg_arbiter
940 * \{
941 */
942
943 /*******************************************************************************
944 * Function Name: Cy_USBFS_Dev_Drv_GetArbAllEpsInterruptStatus
945 ****************************************************************************//**
946 *
947 * Returns the arbiter interrupt request register.
948 * This register contains the current status of the data endpoints arbiter
949 * interrupt.
950 *
951 * \param base
952 * The pointer to the USBFS instance.
953 *
954 * \return
955 * The current status of the SIE interrupt sources.
956 * The returned status specifies for which endpoint interrupt is active as
957 * follows: bit 0 corresponds to data endpoint 1, bit 1 data endpoint 2, and so
958 * on up to \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX.
959 *
960 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetArbAllEpsInterruptStatus(USBFS_Type const * base)961 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetArbAllEpsInterruptStatus(USBFS_Type const *base)
962 {
963 return CY_USBFS_DEV_READ_ODD(USBFS_DEV_ARB_INT_SR(base));
964 }
965
966
967 /*******************************************************************************
968 * Function Name: Cy_USBFS_Dev_Drv_EnableArbEpInterrupt
969 ****************************************************************************//**
970 *
971 * Enables the arbiter interrupt for the specified data endpoint.
972 *
973 * \param base
974 * The pointer to the USBFS instance.
975 *
976 * \param endpoint
977 * Physical endpoint number.
978 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
979 *
980 *******************************************************************************/
Cy_USBFS_Dev_Drv_EnableArbEpInterrupt(USBFS_Type * base,uint32_t endpoint)981 __STATIC_INLINE void Cy_USBFS_Dev_Drv_EnableArbEpInterrupt(USBFS_Type *base, uint32_t endpoint)
982 {
983 USBFS_DEV_ARB_INT_EN(base) |= (uint32_t)(1UL << endpoint);
984 }
985
986
987 /*******************************************************************************
988 * Function Name: Cy_USBFS_Dev_Drv_DisableArbEpInterrupt
989 ****************************************************************************//**
990 *
991 * Disabled arbiter interrupt for the specified data endpoint.
992 *
993 * \param base
994 * The pointer to the USBFS instance.
995 *
996 * \param endpoint
997 * Physical endpoint number.
998 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
999 *
1000 *******************************************************************************/
Cy_USBFS_Dev_Drv_DisableArbEpInterrupt(USBFS_Type * base,uint32_t endpoint)1001 __STATIC_INLINE void Cy_USBFS_Dev_Drv_DisableArbEpInterrupt(USBFS_Type *base, uint32_t endpoint)
1002 {
1003 USBFS_DEV_ARB_INT_EN(base) &= ~(uint32_t)(1UL << endpoint);
1004 }
1005
1006
1007 /*******************************************************************************
1008 * Function Name: Cy_USBFS_Dev_Drv_SetArbEpInterruptMask
1009 ****************************************************************************//**
1010 *
1011 * Enables the arbiter interrupt sources which trigger the arbiter interrupt for
1012 * the specified data endpoint.
1013 *
1014 * \param base
1015 * The pointer to the USBFS instance.
1016 *
1017 * \param endpoint
1018 * Physical endpoint number.
1019 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1020 *
1021 * \param mask
1022 * The arbiter interrupt sources.
1023 * See \ref group_usbfs_dev_drv_reg_macros_arb_ep_intr for the set of constants.
1024 *
1025 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetArbEpInterruptMask(USBFS_Type * base,uint32_t endpoint,uint32_t mask)1026 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetArbEpInterruptMask(USBFS_Type *base, uint32_t endpoint, uint32_t mask)
1027 {
1028 USBFS_DEV_ARB_EP_INT_EN(base, endpoint) = mask;
1029 }
1030
1031
1032 /*******************************************************************************
1033 * Function Name: Cy_USBFS_Dev_Drv_GetArbEpInterruptMask
1034 ****************************************************************************//**
1035 *
1036 * Returns the arbiter interrupt sources which trigger the arbiter interrupt for
1037 * the specified data endpoint.
1038 *
1039 * \param base
1040 * The pointer to the USBFS instance.
1041 *
1042 * \param endpoint
1043 * Physical endpoint number.
1044 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1045 *
1046 * \return
1047 * The arbiter interrupt sources.
1048 * See \ref group_usbfs_dev_drv_reg_macros_arb_ep_intr for the set of constants.
1049 *
1050 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetArbEpInterruptMask(USBFS_Type const * base,uint32_t endpoint)1051 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetArbEpInterruptMask(USBFS_Type const *base, uint32_t endpoint)
1052 {
1053 return USBFS_DEV_ARB_EP_INT_EN(base, endpoint);
1054 }
1055
1056
1057 /*******************************************************************************
1058 * Function Name: Cy_USBFS_Dev_Drv_GetArbEpInterruptStatusMasked
1059 ****************************************************************************//**
1060 *
1061 * Returns the current status of the enabled arbiter interrupt sources for
1062 * the specified data endpoint.
1063 *
1064 * \param base
1065 * The pointer to the USBFS instance.
1066 *
1067 * \param endpoint
1068 * Physical endpoint number.
1069 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1070 *
1071 * \return
1072 * The current status of the enabled arbiter interrupt sources
1073 * See \ref group_usbfs_dev_drv_reg_macros_arb_ep_intr for the set of constants.
1074 *
1075 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetArbEpInterruptStatusMasked(USBFS_Type const * base,uint32_t endpoint)1076 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetArbEpInterruptStatusMasked(USBFS_Type const *base, uint32_t endpoint)
1077 {
1078 uint32_t mask = CY_USBFS_DEV_READ_ODD(USBFS_DEV_ARB_EP_INT_EN(base, endpoint));
1079 return (USBFS_DEV_ARB_EP_SR(base, endpoint) & mask);
1080 }
1081
1082
1083 /*******************************************************************************
1084 * Function Name: Cy_USBFS_Dev_Drv_ClearArbEpInterrupt
1085 ****************************************************************************//**
1086 *
1087 * Clears the current status of the arbiter interrupt sources for the specified
1088 * data endpoint.
1089 *
1090 * \param base
1091 * The pointer to the USBFS instance.
1092 *
1093 * \param endpoint
1094 * Physical endpoint number.
1095 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1096 *
1097 * \param mask
1098 * The arbiter interrupt sources to be cleared.
1099 * See \ref group_usbfs_dev_drv_reg_macros_arb_ep_intr for the set of constants.
1100 *
1101 *******************************************************************************/
Cy_USBFS_Dev_Drv_ClearArbEpInterrupt(USBFS_Type * base,uint32_t endpoint,uint32_t mask)1102 __STATIC_INLINE void Cy_USBFS_Dev_Drv_ClearArbEpInterrupt(USBFS_Type *base, uint32_t endpoint, uint32_t mask)
1103 {
1104 USBFS_DEV_ARB_EP_SR(base, endpoint) = mask;
1105 (void) USBFS_DEV_ARB_EP_SR(base, endpoint);
1106 }
1107
1108
1109 /*******************************************************************************
1110 * Function Name: Cy_USBFS_Dev_Drv_SetArbEpConfig
1111 ****************************************************************************//**
1112 *
1113 * Writes the configuration register for the specified data endpoint.
1114 *
1115 * \param base
1116 * The pointer to the USBFS instance.
1117 *
1118 * \param endpoint
1119 * Physical endpoint number.
1120 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1121 *
1122 * \param cfg
1123 * The value written into the data endpoint configuration register.
1124 *
1125 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetArbEpConfig(USBFS_Type * base,uint32_t endpoint,uint32_t cfg)1126 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetArbEpConfig(USBFS_Type *base, uint32_t endpoint, uint32_t cfg)
1127 {
1128 USBFS_DEV_ARB_EP_CFG(base, endpoint) = cfg;
1129 }
1130
1131
1132 /*******************************************************************************
1133 * Function Name: Cy_USBFS_Dev_Drv_SetArbCfgEpInReady
1134 ****************************************************************************//**
1135 *
1136 * Notifies hardware that IN endpoint data buffer is read to be loaded in
1137 * the hardware buffer.
1138 *
1139 * \param base
1140 * The pointer to the USBFS instance.
1141 *
1142 * \param endpoint
1143 * Physical endpoint number.
1144 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1145 *
1146 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetArbCfgEpInReady(USBFS_Type * base,uint32_t endpoint)1147 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetArbCfgEpInReady(USBFS_Type *base, uint32_t endpoint)
1148 {
1149 USBFS_DEV_ARB_EP_CFG(base, endpoint) |= USBFS_USBDEV_ARB_EP1_CFG_IN_DATA_RDY_Msk;
1150 }
1151
1152
1153 /*******************************************************************************
1154 * Function Name: Cy_USBFS_Dev_Drv_ClearArbCfgEpInReady
1155 ****************************************************************************//**
1156 *
1157 * Clears hardware notification that IN endpoint data buffer is read to be loaded
1158 * in the hardware buffer. This function needs to be called after buffer was
1159 * copied into the hardware buffer.
1160 *
1161 * \param base
1162 * The pointer to the USBFS instance.
1163 *
1164 * \param endpoint
1165 * Physical endpoint number.
1166 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1167
1168 *
1169 *******************************************************************************/
Cy_USBFS_Dev_Drv_ClearArbCfgEpInReady(USBFS_Type * base,uint32_t endpoint)1170 __STATIC_INLINE void Cy_USBFS_Dev_Drv_ClearArbCfgEpInReady(USBFS_Type *base, uint32_t endpoint)
1171 {
1172 USBFS_DEV_ARB_EP_CFG(base, endpoint) &= ~USBFS_USBDEV_ARB_EP1_CFG_IN_DATA_RDY_Msk;
1173 }
1174
1175
1176 /*******************************************************************************
1177 * Function Name: Cy_USBFS_Dev_Drv_TriggerArbCfgEpDmaReq
1178 ****************************************************************************//**
1179 *
1180 * Triggers a DMA request to read from or write data into the hardware buffer.
1181 *
1182 * \param base
1183 * The pointer to the USBFS instance.
1184 *
1185 * \param endpoint
1186 * Physical endpoint number.
1187 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1188 *
1189 *******************************************************************************/
Cy_USBFS_Dev_Drv_TriggerArbCfgEpDmaReq(USBFS_Type * base,uint32_t endpoint)1190 __STATIC_INLINE void Cy_USBFS_Dev_Drv_TriggerArbCfgEpDmaReq(USBFS_Type *base, uint32_t endpoint)
1191 {
1192 /* Generates DMA request */
1193 USBFS_DEV_ARB_EP_CFG(base, endpoint) |= USBFS_USBDEV_ARB_EP1_CFG_DMA_REQ_Msk;
1194 (void) USBFS_DEV_ARB_EP_CFG(base, endpoint);
1195 USBFS_DEV_ARB_EP_CFG(base, endpoint) &= ~USBFS_USBDEV_ARB_EP1_CFG_DMA_REQ_Msk;
1196 (void) USBFS_DEV_ARB_EP_CFG(base, endpoint);
1197 }
1198
1199
1200 /*******************************************************************************
1201 * Function Name: Cy_USBFS_Dev_Drv_SetArbWriteAddr
1202 ****************************************************************************//**
1203 *
1204 * Sets write address in the hardware buffer for the specified endpoint.
1205 * This is the start address of the endpoint buffer.
1206 *
1207 * \param base
1208 * The pointer to the USBFS instance.
1209 *
1210 * \param endpoint
1211 * Physical endpoint number.
1212 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1213 *
1214 * \param wa
1215 * Write address value.
1216 *
1217 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetArbWriteAddr(USBFS_Type * base,uint32_t endpoint,uint32_t wa)1218 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetArbWriteAddr(USBFS_Type *base, uint32_t endpoint, uint32_t wa)
1219 {
1220 USBFS_DEV_ARB_RW_WA16(base, endpoint) = wa;
1221 }
1222
1223
1224 /*******************************************************************************
1225 * Function Name: Cy_USBFS_Dev_Drv_SetArbReadAddr
1226 ****************************************************************************//**
1227 *
1228 * Sets read address in the hardware buffer for the specified endpoint.
1229 * This is the start address of the endpoint buffer.
1230 *
1231 * \param base
1232 * The pointer to the USBFS instance.
1233 *
1234 * \param endpoint
1235 * Physical endpoint number.
1236 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1237 *
1238 * \param ra
1239 * Read address value.
1240 *
1241 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetArbReadAddr(USBFS_Type * base,uint32_t endpoint,uint32_t ra)1242 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetArbReadAddr(USBFS_Type *base, uint32_t endpoint, uint32_t ra)
1243 {
1244 USBFS_DEV_ARB_RW_RA16(base, endpoint) = ra;
1245 }
1246
1247
1248 /*******************************************************************************
1249 * Function Name: Cy_USBFS_Dev_Drv_GetArbWriteAddr
1250 ****************************************************************************//**
1251 *
1252 * Returns write address in the hardware buffer for the specified endpoint.
1253 * This is the start address of the endpoint buffer.
1254 *
1255 * \param base
1256 * The pointer to the USBFS instance.
1257 *
1258 * \param endpoint
1259 * Physical endpoint number.
1260 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1261 *
1262 * \return
1263 * Write address in the hardware buffer for the specified endpoint.
1264 *
1265 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetArbWriteAddr(USBFS_Type const * base,uint32_t endpoint)1266 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetArbWriteAddr(USBFS_Type const *base, uint32_t endpoint)
1267 {
1268 return (USBFS_DEV_ARB_RW_WA16(base, endpoint));
1269 }
1270
1271
1272 /*******************************************************************************
1273 * Function Name: Cy_USBFS_Dev_Drv_GetArbReadAddr
1274 ****************************************************************************//**
1275 *
1276 * Returns read address in the hardware buffer for the specified endpoint.
1277 * This is the start address of the endpoint buffer.
1278 *
1279 * \param base
1280 * The pointer to the USBFS instance.
1281 *
1282 * \param endpoint
1283 * Physical endpoint number.
1284 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1285 *
1286 * \return
1287 * Read address in the hardware buffer for the specified endpoint.
1288 *
1289 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetArbReadAddr(USBFS_Type const * base,uint32_t endpoint)1290 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetArbReadAddr(USBFS_Type const *base, uint32_t endpoint)
1291 {
1292 return (USBFS_DEV_ARB_RW_RA16(base, endpoint));
1293 }
1294 /** \} group_usbfs_drv_drv_reg_arbiter */
1295
1296
1297 /**
1298 * \addtogroup group_usbfs_drv_drv_reg_arbiter_data
1299 * \{
1300 */
1301
1302 /*******************************************************************************
1303 * Function Name: Cy_USBFS_Dev_Drv_WriteData
1304 ****************************************************************************//**
1305 *
1306 * Writes a byte (8-bit) into the hardware buffer.
1307 *
1308 * \param base
1309 * The pointer to the USBFS instance.
1310 *
1311 * \param endpoint
1312 * Physical endpoint number.
1313 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1314 *
1315 * \param byte
1316 * The byte of data to be written into the hardware buffer.
1317 *
1318 *******************************************************************************/
Cy_USBFS_Dev_Drv_WriteData(USBFS_Type * base,uint32_t endpoint,uint8_t byte)1319 __STATIC_INLINE void Cy_USBFS_Dev_Drv_WriteData(USBFS_Type *base, uint32_t endpoint, uint8_t byte)
1320 {
1321 USBFS_DEV_ARB_RW_DR(base, endpoint) = (uint32_t) byte;
1322 }
1323
1324
1325 /*******************************************************************************
1326 * Function Name: Cy_USBFS_Dev_Drv_WriteData16
1327 ****************************************************************************//**
1328 *
1329 * Writes a half-word (16-bit) into the hardware buffer.
1330 *
1331 * \param base
1332 * The pointer to the USBFS instance.
1333 *
1334 * \param endpoint
1335 * Physical endpoint number.
1336 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1337 *
1338 * \param halfword
1339 * The half-word of data to be written into the hardware buffer.
1340 *
1341 *******************************************************************************/
Cy_USBFS_Dev_Drv_WriteData16(USBFS_Type * base,uint32_t endpoint,uint16_t halfword)1342 __STATIC_INLINE void Cy_USBFS_Dev_Drv_WriteData16(USBFS_Type *base, uint32_t endpoint, uint16_t halfword)
1343 {
1344 USBFS_DEV_ARB_RW_DR16(base, endpoint) = (uint32_t) halfword;
1345 }
1346
1347
1348 /*******************************************************************************
1349 * Function Name: Cy_USBFS_Dev_Drv_ReadData
1350 ****************************************************************************//**
1351 *
1352 * Reads a byte (8-bit) from the hardware buffer.
1353 *
1354 * \param base
1355 * The pointer to the USBFS instance.
1356 *
1357 * \param endpoint
1358 * Physical endpoint number.
1359 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1360 *
1361 * \return
1362 * The byte of data to be read from the hardware buffer.
1363 *
1364 *******************************************************************************/
Cy_USBFS_Dev_Drv_ReadData(USBFS_Type const * base,uint32_t endpoint)1365 __STATIC_INLINE uint8_t Cy_USBFS_Dev_Drv_ReadData(USBFS_Type const *base, uint32_t endpoint)
1366 {
1367 return ((uint8_t) USBFS_DEV_ARB_RW_DR(base, endpoint));
1368 }
1369
1370
1371 /*******************************************************************************
1372 * Function Name: Cy_USBFS_Dev_Drv_ReadData16
1373 ****************************************************************************//**
1374 *
1375 * Reads a half-word (16-bit) from the hardware buffer.
1376 *
1377 * \param base
1378 * The pointer to the USBFS instance.
1379 *
1380 * \param endpoint
1381 * Physical endpoint number.
1382 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1383 *
1384 * \return
1385 * The half-word of data to be read from the hardware buffer.
1386 *
1387 *******************************************************************************/
Cy_USBFS_Dev_Drv_ReadData16(USBFS_Type const * base,uint32_t endpoint)1388 __STATIC_INLINE uint16_t Cy_USBFS_Dev_Drv_ReadData16(USBFS_Type const *base, uint32_t endpoint)
1389 {
1390 return ((uint16_t) USBFS_DEV_ARB_RW_DR16(base, endpoint));
1391 }
1392
1393
1394 /*******************************************************************************
1395 * Function Name: Cy_USBFS_Dev_Drv_GetDataRegAddr
1396 ****************************************************************************//**
1397 *
1398 * Returns pointer to the 8-bit data register for the specified endpoint.
1399 *
1400 * \param base
1401 * The pointer to the USBFS instance.
1402 *
1403 * \param endpoint
1404 * Physical endpoint number.
1405 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1406 *
1407 * \return
1408 * The pointer to the 8-bit data register for the specified endpoint.
1409 *
1410 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetDataRegAddr(USBFS_Type * base,uint32_t endpoint)1411 __STATIC_INLINE volatile uint32_t * Cy_USBFS_Dev_Drv_GetDataRegAddr(USBFS_Type *base, uint32_t endpoint)
1412 {
1413 return (&USBFS_DEV_ARB_RW_DR(base, endpoint));
1414 }
1415
1416
1417 /*******************************************************************************
1418 * Function Name: Cy_USBFS_Dev_Drv_GetDataReg16Addr
1419 ****************************************************************************//**
1420 *
1421 * Returns pointer to the 16-bit data register for the specified endpoint.
1422 *
1423 * \param base
1424 * The pointer to the USBFS instance.
1425 *
1426 * \param endpoint
1427 * Physical endpoint number.
1428 * Valid range (0 - \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1).
1429 *
1430 * \return
1431 * The pointer to the 16-bit data register for the specified endpoint.
1432 *
1433 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetDataReg16Addr(USBFS_Type * base,uint32_t endpoint)1434 __STATIC_INLINE volatile uint32_t * Cy_USBFS_Dev_Drv_GetDataReg16Addr(USBFS_Type *base, uint32_t endpoint)
1435 {
1436 return (&USBFS_DEV_ARB_RW_DR16(base, endpoint));
1437 }
1438
1439
1440 /*******************************************************************************
1441 * Function Name: Cy_USBFS_Dev_Drv_FlushInBuffer
1442 ****************************************************************************//**
1443 *
1444 * Flushes IN endpoint buffer: sets WA pointer (controlled by CPU/DMA) to equal
1445 * RA (controlled by SIE; gets automatically reset on transfer completion).
1446 *
1447 * \param base
1448 * The pointer to the USBFS instance.
1449 *
1450 * \param endpoint
1451 * Physical endpoint number.
1452 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1453 *
1454 *******************************************************************************/
Cy_USBFS_Dev_Drv_FlushInBuffer(USBFS_Type * base,uint32_t endpoint)1455 __STATIC_INLINE void Cy_USBFS_Dev_Drv_FlushInBuffer(USBFS_Type *base, uint32_t endpoint)
1456 {
1457 Cy_USBFS_Dev_Drv_SetArbWriteAddr(base, endpoint,
1458 Cy_USBFS_Dev_Drv_GetArbReadAddr(base, endpoint));
1459 }
1460 /** \} group_usbfs_drv_drv_reg_arbiter_data */
1461
1462
1463 /**
1464 * \addtogroup group_usbfs_drv_drv_reg_misc
1465 * \{
1466 */
1467
1468 /*******************************************************************************
1469 * Function Name: Cy_USBFS_Dev_Drv_SetEpType
1470 ****************************************************************************//**
1471 *
1472 * Sets the data endpoint direction.
1473 *
1474 * \param base
1475 * The pointer to the USBFS instance.
1476 *
1477 * \param inDirection
1478 * Defines whether endpoint direction is IN (true) or OUT (false).
1479 *
1480 * \param endpoint
1481 * Physical endpoint number.
1482 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1483 *
1484 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetEpType(USBFS_Type * base,bool inDirection,uint32_t endpoint)1485 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetEpType(USBFS_Type *base, bool inDirection, uint32_t endpoint)
1486 {
1487 uint32_t mask = (uint32_t) (0x1UL << endpoint);
1488 uint32_t regValue = CY_USBFS_DEV_READ_ODD(USBFS_DEV_EP_TYPE(base));
1489
1490 if (inDirection)
1491 {
1492 /* IN direction: clear bit */
1493 regValue &= ~mask;
1494 }
1495 else
1496 {
1497 /* OUT direction: set bit */
1498 regValue |= mask;
1499 }
1500
1501 USBFS_DEV_EP_TYPE(base) = CY_USBFS_DEV_DRV_WRITE_ODD(regValue);
1502 }
1503
1504
1505 /*******************************************************************************
1506 * Function Name: Cy_USBFS_Dev_Drv_GetSofNubmer
1507 ****************************************************************************//**
1508 *
1509 * Returns the SOF frame number.
1510 *
1511 * \param base
1512 * The pointer to the USBFS instance.
1513 *
1514 * \return
1515 * The SOF frame number.
1516 *
1517 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetSofNubmer(USBFS_Type const * base)1518 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSofNubmer(USBFS_Type const *base)
1519 {
1520 return _FLD2VAL(USBFS_USBDEV_SOF16_FRAME_NUMBER16, USBFS_DEV_SOF16(base));
1521 }
1522 /** \} group_usbfs_drv_drv_reg_misc */
1523
1524 #if defined(__cplusplus)
1525 }
1526 #endif
1527
1528 #endif /* CY_IP_MXUSBFS */
1529
1530 #endif /* (CY_USBFS_DEV_DRV_REG_H) */
1531
1532 /** \endcond */
1533
1534
1535 /* [] END OF FILE */
1536