1 /***************************************************************************//**
2 * \file cy_usbfs_dev_drv_reg.h
3 * \version 2.30
4 *
5 * Provides register access API implementation of the USBFS driver.
6 *
7 ********************************************************************************
8 * \copyright
9 * Copyright 2018-2023 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 /* This dummy reading is necessary here. It provides a guarantee that interrupt is cleared at returning from this function. */
419 (void) USBFS_DEV_LPM_INTR_SIE(base);
420 }
421
422
423 /*******************************************************************************
424 * Function Name: Cy_USBFS_Dev_Drv_SetSieInterrupt
425 ****************************************************************************//**
426 *
427 * Sets the SIE interrupt sources in the interrupt request register.
428 *
429 * \param base
430 * The pointer to the USBFS instance.
431 *
432 * \param mask
433 * The SIE interrupt sources to be set in the SIE interrupt request register.
434 * See \ref group_usbfs_dev_drv_reg_macros_sie_intr for the set of constants.
435 *
436 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetSieInterrupt(USBFS_Type * base,uint32_t mask)437 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetSieInterrupt(USBFS_Type *base, uint32_t mask)
438 {
439 USBFS_DEV_LPM_INTR_SIE_SET(base) = mask;
440 }
441 /** \} group_usbfs_drv_drv_reg_interrupt_sources */
442
443
444 /**
445 * \addtogroup group_usbfs_drv_drv_reg_ep0_access
446 * \{
447 */
448 /*******************************************************************************
449 * Function Name: Cy_USBFS_Dev_Drv_WriteEp0Mode
450 ****************************************************************************//**
451 *
452 * Sets a mode in the CR0 register of endpoint 0 (clears all other bits in the
453 * register).
454 *
455 * \param base
456 * The pointer to the USBFS instance.
457 *
458 * \param mode
459 * SIE mode defines the data endpoint 0 response to a host request.
460 * See \ref group_usbfs_dev_drv_reg_macros_sie_mode for the set of constants.
461 *
462 *******************************************************************************/
Cy_USBFS_Dev_Drv_WriteEp0Mode(USBFS_Type * base,uint32_t mode)463 __STATIC_INLINE void Cy_USBFS_Dev_Drv_WriteEp0Mode(USBFS_Type *base, uint32_t mode)
464 {
465 USBFS_DEV_EP0_CR(base) = mode;
466 /* This dummy reading is necessary here. It provides a guarantee that interrupt is cleared at returning from this function. */
467 (void) USBFS_DEV_EP0_CR(base);
468 }
469
470 /*******************************************************************************
471 * Function Name: Cy_USBFS_Dev_Drv_ReadEp0Mode
472 ****************************************************************************//**
473 *
474 * Returns a mode in the CR0 register of endpoint 0.
475 *
476 * \param base
477 * The pointer to the USBFS instance.
478 *
479 * \return
480 * SIE mode (defines the endpoint 0 response to a host request).
481 * See \ref group_usbfs_dev_drv_reg_macros_sie_mode for the set of constants.
482 *
483 *******************************************************************************/
Cy_USBFS_Dev_Drv_ReadEp0Mode(USBFS_Type const * base)484 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_ReadEp0Mode(USBFS_Type const *base)
485 {
486 return USBFS_DEV_EP0_CR(base);
487 }
488
489
490 /*******************************************************************************
491 * Function Name: Cy_USBFS_Dev_Drv_SetSieEpCount
492 ****************************************************************************//**
493 *
494 * Configures the number of bytes and toggle bit to return to a host read request
495 * to endpoint 0.
496 *
497 * \param base
498 * The pointer to the USBFS instance.
499 *
500 * \param count
501 * The number of bytes to return to a host read request.
502 *
503 * \param toggle
504 * The data toggle bit.
505 * The range of valid values: 0 and \ref USBFS_USBDEV_SIE_EP_DATA_TOGGLE_Msk.
506 *
507 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetEp0Count(USBFS_Type * base,uint32_t count,uint32_t toggle)508 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetEp0Count(USBFS_Type *base, uint32_t count, uint32_t toggle)
509 {
510 count = _VAL2FLD(USBFS_USBDEV_EP0_CNT_BYTE_COUNT, count);
511 USBFS_DEV_EP0_CNT(base) = CY_USBFS_DEV_DRV_WRITE_ODD(count | toggle);
512 }
513
514
515 /*******************************************************************************
516 * Function Name: Cy_USBFS_Dev_Drv_GetEp0Count
517 ****************************************************************************//**
518 *
519 * Returns the number of data bytes written into endpoint 0 by the host.
520 *
521 * \param base
522 * The pointer to the USBFS instance.
523 *
524 * \return
525 * The number of bytes written by the host into the endpoint.
526 *
527 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetEp0Count(USBFS_Type const * base)528 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetEp0Count(USBFS_Type const *base)
529 {
530 uint32_t ep0Cnt = CY_USBFS_DEV_READ_ODD(USBFS_DEV_EP0_CNT(base));
531
532 /* Excludes the CRC size */
533 return (_FLD2VAL(USBFS_USBDEV_EP0_CNT_BYTE_COUNT, ep0Cnt) - CY_USBFS_DEV_DRV_EP_CRC_SIZE);
534 }
535
536
537 /*******************************************************************************
538 * Function Name: Cy_USBFS_Dev_Drv_WriteEp0Data
539 ****************************************************************************//**
540 *
541 * Writes an 8-bit byte into the endpoint 0 hardware buffer.
542 *
543 * \param base
544 * The pointer to the USBFS instance.
545 *
546 * \param idx
547 * The index of the endpoint 0 hardware buffer entry.
548 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_EP0_BUFFER_SIZE - 1 ).
549 *
550 * \param value
551 * The value to be written into the endpoint 0 hardware buffer.
552 *
553 *******************************************************************************/
Cy_USBFS_Dev_Drv_WriteEp0Data(USBFS_Type * base,uint32_t idx,uint32_t value)554 __STATIC_INLINE void Cy_USBFS_Dev_Drv_WriteEp0Data(USBFS_Type *base, uint32_t idx, uint32_t value)
555 {
556 if (0U == (idx & 0x1U))
557 {
558 USBFS_DEV_EP0_DR(base, idx) = value;
559 }
560 else
561 {
562 /* Applies a special write for odd offset registers */
563 USBFS_DEV_EP0_DR(base, idx) = CY_USBFS_DEV_DRV_WRITE_ODD(value);
564 }
565 }
566
567
568 /*******************************************************************************
569 * Function Name: Cy_USBFS_Dev_Drv_ReadEp0Data
570 ****************************************************************************//**
571 *
572 * Reads an 8-bit byte from the endpoint 0 hardware buffer.
573 *
574 * \param base
575 * The pointer to the USBFS instance.
576 *
577 * \param idx
578 * The index of the endpoint 0 hardware buffer entry.
579 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_EP0_BUFFER_SIZE - 1 ).
580 *
581 * \return
582 * The byte of data to read from the hardware buffer.
583 *
584 *******************************************************************************/
Cy_USBFS_Dev_Drv_ReadEp0Data(USBFS_Type const * base,uint32_t idx)585 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_ReadEp0Data(USBFS_Type const *base, uint32_t idx)
586 {
587 uint32_t value;
588
589 if (0U == (idx & 0x1U))
590 {
591 value = USBFS_DEV_EP0_DR(base, idx);
592 }
593 else
594 {
595 /* Applies a special write for odd offset registers */
596 value = CY_USBFS_DEV_READ_ODD(USBFS_DEV_EP0_DR(base, idx));
597 }
598
599 return (value);
600 }
601 /** \} group_usbfs_drv_drv_reg_ep0_access */
602
603
604 /**
605 * \addtogroup group_usbfs_drv_drv_reg_sie_access
606 * \{
607 */
608
609 /*******************************************************************************
610 * Function Name: Cy_USBFS_Dev_Drv_SetSieEpMode
611 ****************************************************************************//**
612 *
613 * Sets SIE mode in the CR0 register of the endpoint (does not touch other bits).
614 * All other bits except NAK_INT_EN are cleared by the hardware on any write
615 * in the register.
616 *
617 * \param base
618 * The pointer to the USBFS instance.
619 *
620 * \param endpoint
621 * Physical endpoint number.
622 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
623 *
624 * \param mode
625 * SIE mode defines data endpoint response to host request.
626 * See \ref group_usbfs_dev_drv_reg_macros_sie_mode for the set of constants.
627 *
628 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetSieEpMode(USBFS_Type * base,uint32_t endpoint,uint32_t mode)629 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetSieEpMode(USBFS_Type *base, uint32_t endpoint, uint32_t mode)
630 {
631 USBFS_DEV_SIE_EP_CR0(base, endpoint) = _CLR_SET_FLD32U(USBFS_DEV_SIE_EP_CR0(base, endpoint),
632 USBFS_USBDEV_SIE_EP1_CR0_MODE, mode);
633 /* This dummy reading is necessary here. It provides a guarantee that interrupt is cleared at returning from this function. */
634 (void) USBFS_DEV_SIE_EP_CR0(base, endpoint);
635 }
636
637
638 /*******************************************************************************
639 * Function Name: Cy_USBFS_Dev_Drv_GetSieEpMode
640 ****************************************************************************//**
641 *
642 * Returns SIE mode in the CR0 register of the endpoint.
643 *
644 * \param base
645 * The pointer to the USBFS instance.
646 *
647 * \param endpoint
648 * Physical endpoint number.
649 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
650 *
651 * \return
652 * SIE mode (defines data endpoint response to host request).
653 * See \ref group_usbfs_dev_drv_reg_macros_sie_mode for the set of constants.
654 *
655 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetSieEpMode(USBFS_Type const * base,uint32_t endpoint)656 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieEpMode(USBFS_Type const *base, uint32_t endpoint)
657 {
658 return (USBFS_DEV_SIE_EP_CR0(base, endpoint) & USBFS_USBDEV_SIE_EP1_CR0_MODE_Msk);
659 }
660
661
662 /*******************************************************************************
663 * Function Name: Cy_USBFS_Dev_Drv_SetSieEpStall
664 ****************************************************************************//**
665 *
666 * Configures endpoint to STALL requests.
667 *
668 * \param base
669 * The pointer to the USBFS instance.
670 *
671 * \param inDirection
672 * Defines whether endpoint direction is IN (true) or OUT (false).
673 *
674 * \param endpoint
675 * Physical endpoint number.
676 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
677 *
678 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetSieEpStall(USBFS_Type * base,bool inDirection,uint32_t endpoint)679 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetSieEpStall(USBFS_Type *base, bool inDirection, uint32_t endpoint)
680 {
681 /* STALL endpoint */
682 USBFS_DEV_SIE_EP_CR0(base, endpoint) = USBFS_USBDEV_SIE_EP1_CR0_STALL_Msk |
683 (inDirection ? CY_USBFS_DEV_DRV_EP_CR_ACK_IN :
684 CY_USBFS_DEV_DRV_EP_CR_ACK_OUT);
685 /* This dummy reading is necessary here. It provides a guarantee that interrupt is cleared at returning from this function. */
686 (void) USBFS_DEV_SIE_EP_CR0(base, endpoint);
687 }
688
689
690 /*******************************************************************************
691 * Function Name: Cy_USBFS_Dev_Drv_ClearSieEpStall
692 ****************************************************************************//**
693 *
694 * Writes SIE mode register of the data endpoint and clears other bits in this
695 * register.
696 *
697 * \param base
698 * The pointer to the USBFS instance.
699 *
700 * \param endpoint
701 * Physical endpoint number.
702 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
703 *
704 * \param mode
705 * SIE mode defines data endpoint response to host request.
706 * See \ref group_usbfs_dev_drv_reg_macros_sie_mode for the set of constants.
707 *
708 *******************************************************************************/
Cy_USBFS_Dev_Drv_ClearSieEpStall(USBFS_Type * base,uint32_t endpoint,uint32_t mode)709 __STATIC_INLINE void Cy_USBFS_Dev_Drv_ClearSieEpStall(USBFS_Type *base, uint32_t endpoint, uint32_t mode)
710 {
711 /* Set mode bits */
712 uint32_t regVal = _CLR_SET_FLD32U(USBFS_DEV_SIE_EP_CR0(base, endpoint),
713 USBFS_USBDEV_SIE_EP1_CR0_MODE, mode);
714
715 /* Clear STALL condition */
716 regVal &= ~USBFS_USBDEV_SIE_EP1_CR0_STALL_Msk;
717
718 /* Clear STALL condition and set mode */
719 USBFS_DEV_SIE_EP_CR0(base, endpoint) = regVal;
720 /* This dummy reading is necessary here. It provides a guarantee that interrupt is cleared at returning from this function. */
721 (void) USBFS_DEV_SIE_EP_CR0(base, endpoint);
722 }
723
724
725 /*******************************************************************************
726 * Function Name: Cy_USBFS_Dev_Drv_GetSieEpError
727 ****************************************************************************//**
728 *
729 * Returns value of data endpoint error in transaction bit.
730 *
731 * \param base
732 * The pointer to the USBFS instance.
733 *
734 * \param endpoint
735 * Physical endpoint number.
736 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
737 *
738 * \return
739 * Value of data endpoint error in transaction bit.
740 *
741 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetSieEpError(USBFS_Type const * base,uint32_t endpoint)742 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieEpError(USBFS_Type const *base, uint32_t endpoint)
743 {
744 return (USBFS_DEV_SIE_EP_CR0(base, endpoint) & USBFS_USBDEV_SIE_EP1_CR0_ERR_IN_TXN_Msk);
745 }
746
747
748 /*******************************************************************************
749 * Function Name: Cy_USBFS_Dev_Drv_GetSieEpToggle
750 ****************************************************************************//**
751 *
752 * Returns current value of data endpoint toggle bit.
753 *
754 * \param base
755 * The pointer to the USBFS instance.
756 *
757 * \param endpoint
758 * Physical endpoint number.
759 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
760 *
761 * \return
762 * Value of data endpoint toggle bit.
763 *
764 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetSieEpToggle(USBFS_Type const * base,uint32_t endpoint)765 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieEpToggle(USBFS_Type const *base, uint32_t endpoint)
766 {
767 /* Return data toggle bit */
768 return (USBFS_DEV_SIE_EP_CNT0(base, endpoint) & USBFS_USBDEV_SIE_EP1_CNT0_DATA_TOGGLE_Msk);
769 }
770
771
772 /*******************************************************************************
773 * Function Name: Cy_USBFS_Dev_Drv_ClearSieEpToggle
774 ****************************************************************************//**
775 *
776 * Resets to zero data endpoint toggle bit.
777 *
778 * \param base
779 * The pointer to the USBFS instance.
780 *
781 * \param endpoint
782 * Physical endpoint number.
783 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
784 *
785 * \return
786 * Number of bytes written by the host into the endpoint.
787 *
788 *******************************************************************************/
Cy_USBFS_Dev_Drv_ClearSieEpToggle(USBFS_Type * base,uint32_t endpoint)789 __STATIC_INLINE void Cy_USBFS_Dev_Drv_ClearSieEpToggle(USBFS_Type *base, uint32_t endpoint)
790 {
791 /* Clear data toggle bit */
792 USBFS_DEV_SIE_EP_CNT0(base, endpoint) &= ~USBFS_USBDEV_SIE_EP1_CNT0_DATA_TOGGLE_Msk;
793 }
794
795
796 /*******************************************************************************
797 * Function Name: Cy_USBFS_Dev_Drv_GetSieEpCount
798 ****************************************************************************//**
799 *
800 * Returns the number of data bytes written into the OUT data endpoint
801 * by the host.
802 *
803 * \param base
804 * The pointer to the USBFS instance.
805 *
806 * \param endpoint
807 * Physical endpoint number.
808 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
809 *
810 * \return
811 * Number of bytes written by the host into the endpoint.
812 *
813 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetSieEpCount(USBFS_Type const * base,uint32_t endpoint)814 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieEpCount(USBFS_Type const *base, uint32_t endpoint)
815 {
816 uint32_t size;
817
818 /* Get number of bytes transmitted or received by SIE */
819 size = _FLD2VAL(USBFS_USBDEV_SIE_EP1_CNT0_DATA_COUNT_MSB, USBFS_DEV_SIE_EP_CNT0(base, endpoint));
820 size = (size << 8U) | CY_USBFS_DEV_READ_ODD(USBFS_DEV_SIE_EP_CNT1(base, endpoint));
821
822 /* Exclude CRC size */
823 return (size - CY_USBFS_DEV_DRV_EP_CRC_SIZE);
824 }
825
826
827 /*******************************************************************************
828 * Function Name: Cy_USBFS_Dev_Drv_SetSieEpCount
829 ****************************************************************************//**
830 *
831 * Configures number of bytes and toggle bit to return on the host read request
832 * to the IN data endpoint.
833 *
834 * \param base
835 * The pointer to the USBFS instance.
836 *
837 * \param endpoint
838 * Physical endpoint number.
839 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
840 *
841 * \param count
842 * The number of bytes to return on the host read request.
843 *
844 * \param toggle
845 * The data toggle bit.
846 * The range of valid values: 0 and \ref USBFS_USBDEV_SIE_EP_DATA_TOGGLE_Msk.
847 *
848 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetSieEpCount(USBFS_Type * base,uint32_t endpoint,uint32_t count,uint32_t toggle)849 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetSieEpCount(USBFS_Type *base, uint32_t endpoint,
850 uint32_t count, uint32_t toggle)
851 {
852 USBFS_DEV_SIE_EP_CNT1(base, endpoint) = (uint32_t) CY_USBFS_DEV_DRV_WRITE_ODD(CY_LO8(count));
853 USBFS_DEV_SIE_EP_CNT0(base, endpoint) = (uint32_t) CY_HI8(count) | toggle;
854 }
855
856
857 /*******************************************************************************
858 * Function Name: Cy_USBFS_Dev_Drv_GetSieAllEpsInterruptStatus
859 ****************************************************************************//**
860 *
861 * Returns the SIE data endpoints interrupt request register.
862 * This register contains the current status of the SIE data endpoints transfer
863 * completion interrupt.
864 *
865 * \param base
866 * The pointer to the USBFS instance.
867 *
868 * \return
869 * The current status of the SIE interrupt sources.
870 * The returned status specifies for which endpoint interrupt is active as
871 * follows: bit 0 corresponds to data endpoint 1, bit 1 data endpoint 2 and so
872 * on up to \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX.
873 *
874 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetSieAllEpsInterruptStatus(USBFS_Type const * base)875 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSieAllEpsInterruptStatus(USBFS_Type const *base)
876 {
877 return USBFS_DEV_SIE_EP_INT_SR(base);
878 }
879
880
881 /*******************************************************************************
882 * Function Name: Cy_USBFS_Dev_Drv_EnableSieEpInterrupt
883 ****************************************************************************//**
884 *
885 * Enables SIE data endpoint transfer completion interrupt.
886 *
887 * \param base
888 * The pointer to the USBFS instance.
889 *
890 * \param endpoint
891 * Physical endpoint number.
892 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
893 *
894 *******************************************************************************/
Cy_USBFS_Dev_Drv_EnableSieEpInterrupt(USBFS_Type * base,uint32_t endpoint)895 __STATIC_INLINE void Cy_USBFS_Dev_Drv_EnableSieEpInterrupt(USBFS_Type *base, uint32_t endpoint)
896 {
897 USBFS_DEV_SIE_EP_INT_EN(base) |= (uint32_t)(1UL << endpoint);
898 }
899
900
901 /*******************************************************************************
902 * Function Name: Cy_USBFS_Dev_Drv_DisableSieEpInterrupt
903 ****************************************************************************//**
904 *
905 * Disables SIE data endpoint transfer completion interrupt.
906 *
907 * \param base
908 * The pointer to the USBFS instance.
909 *
910 * \param endpoint
911 * Physical endpoint number.
912 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
913 *
914 *******************************************************************************/
Cy_USBFS_Dev_Drv_DisableSieEpInterrupt(USBFS_Type * base,uint32_t endpoint)915 __STATIC_INLINE void Cy_USBFS_Dev_Drv_DisableSieEpInterrupt(USBFS_Type *base, uint32_t endpoint)
916 {
917 USBFS_DEV_SIE_EP_INT_EN(base) &= ~ (uint32_t)(1UL << endpoint);
918 }
919
920
921 /*******************************************************************************
922 * Function Name: Cy_USBFS_Dev_Drv_ClearSieEpInterrupt
923 ****************************************************************************//**
924 *
925 * Clears the SIE EP interrupt sources in the interrupt request register.
926 *
927 * \param base
928 * The pointer to the USBFS instance.
929 *
930 * \param endpoint
931 * Physical endpoint number.
932 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
933 *
934 *******************************************************************************/
Cy_USBFS_Dev_Drv_ClearSieEpInterrupt(USBFS_Type * base,uint32_t endpoint)935 __STATIC_INLINE void Cy_USBFS_Dev_Drv_ClearSieEpInterrupt(USBFS_Type *base, uint32_t endpoint)
936 {
937 USBFS_DEV_SIE_EP_INT_SR(base) = (uint32_t)(1UL << endpoint);
938 /* This dummy reading is necessary here. It provides a guarantee that interrupt is cleared at returning from this function. */
939 (void) USBFS_DEV_SIE_EP_INT_SR(base);
940 }
941 /** \} group_usbfs_drv_drv_reg_sie_access */
942
943
944 /**
945 * \addtogroup group_usbfs_drv_drv_reg_arbiter
946 * \{
947 */
948
949 /*******************************************************************************
950 * Function Name: Cy_USBFS_Dev_Drv_GetArbAllEpsInterruptStatus
951 ****************************************************************************//**
952 *
953 * Returns the arbiter interrupt request register.
954 * This register contains the current status of the data endpoints arbiter
955 * interrupt.
956 *
957 * \param base
958 * The pointer to the USBFS instance.
959 *
960 * \return
961 * The current status of the SIE interrupt sources.
962 * The returned status specifies for which endpoint interrupt is active as
963 * follows: bit 0 corresponds to data endpoint 1, bit 1 data endpoint 2, and so
964 * on up to \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX.
965 *
966 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetArbAllEpsInterruptStatus(USBFS_Type const * base)967 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetArbAllEpsInterruptStatus(USBFS_Type const *base)
968 {
969 return CY_USBFS_DEV_READ_ODD(USBFS_DEV_ARB_INT_SR(base));
970 }
971
972
973 /*******************************************************************************
974 * Function Name: Cy_USBFS_Dev_Drv_EnableArbEpInterrupt
975 ****************************************************************************//**
976 *
977 * Enables the arbiter interrupt for the specified data endpoint.
978 *
979 * \param base
980 * The pointer to the USBFS instance.
981 *
982 * \param endpoint
983 * Physical endpoint number.
984 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
985 *
986 *******************************************************************************/
Cy_USBFS_Dev_Drv_EnableArbEpInterrupt(USBFS_Type * base,uint32_t endpoint)987 __STATIC_INLINE void Cy_USBFS_Dev_Drv_EnableArbEpInterrupt(USBFS_Type *base, uint32_t endpoint)
988 {
989 USBFS_DEV_ARB_INT_EN(base) |= (uint32_t)(1UL << endpoint);
990 }
991
992
993 /*******************************************************************************
994 * Function Name: Cy_USBFS_Dev_Drv_DisableArbEpInterrupt
995 ****************************************************************************//**
996 *
997 * Disabled arbiter interrupt for the specified data endpoint.
998 *
999 * \param base
1000 * The pointer to the USBFS instance.
1001 *
1002 * \param endpoint
1003 * Physical endpoint number.
1004 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1005 *
1006 *******************************************************************************/
Cy_USBFS_Dev_Drv_DisableArbEpInterrupt(USBFS_Type * base,uint32_t endpoint)1007 __STATIC_INLINE void Cy_USBFS_Dev_Drv_DisableArbEpInterrupt(USBFS_Type *base, uint32_t endpoint)
1008 {
1009 USBFS_DEV_ARB_INT_EN(base) &= ~(uint32_t)(1UL << endpoint);
1010 }
1011
1012
1013 /*******************************************************************************
1014 * Function Name: Cy_USBFS_Dev_Drv_SetArbEpInterruptMask
1015 ****************************************************************************//**
1016 *
1017 * Enables the arbiter interrupt sources which trigger the arbiter interrupt for
1018 * the specified data endpoint.
1019 *
1020 * \param base
1021 * The pointer to the USBFS instance.
1022 *
1023 * \param endpoint
1024 * Physical endpoint number.
1025 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1026 *
1027 * \param mask
1028 * The arbiter interrupt sources.
1029 * See \ref group_usbfs_dev_drv_reg_macros_arb_ep_intr for the set of constants.
1030 *
1031 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetArbEpInterruptMask(USBFS_Type * base,uint32_t endpoint,uint32_t mask)1032 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetArbEpInterruptMask(USBFS_Type *base, uint32_t endpoint, uint32_t mask)
1033 {
1034 USBFS_DEV_ARB_EP_INT_EN(base, endpoint) = mask;
1035 }
1036
1037
1038 /*******************************************************************************
1039 * Function Name: Cy_USBFS_Dev_Drv_GetArbEpInterruptMask
1040 ****************************************************************************//**
1041 *
1042 * Returns the arbiter interrupt sources which trigger the arbiter interrupt for
1043 * the specified data endpoint.
1044 *
1045 * \param base
1046 * The pointer to the USBFS instance.
1047 *
1048 * \param endpoint
1049 * Physical endpoint number.
1050 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1051 *
1052 * \return
1053 * The arbiter interrupt sources.
1054 * See \ref group_usbfs_dev_drv_reg_macros_arb_ep_intr for the set of constants.
1055 *
1056 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetArbEpInterruptMask(USBFS_Type const * base,uint32_t endpoint)1057 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetArbEpInterruptMask(USBFS_Type const *base, uint32_t endpoint)
1058 {
1059 return USBFS_DEV_ARB_EP_INT_EN(base, endpoint);
1060 }
1061
1062
1063 /*******************************************************************************
1064 * Function Name: Cy_USBFS_Dev_Drv_GetArbEpInterruptStatusMasked
1065 ****************************************************************************//**
1066 *
1067 * Returns the current status of the enabled arbiter interrupt sources for
1068 * the specified data endpoint.
1069 *
1070 * \param base
1071 * The pointer to the USBFS instance.
1072 *
1073 * \param endpoint
1074 * Physical endpoint number.
1075 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1076 *
1077 * \return
1078 * The current status of the enabled arbiter interrupt sources
1079 * See \ref group_usbfs_dev_drv_reg_macros_arb_ep_intr for the set of constants.
1080 *
1081 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetArbEpInterruptStatusMasked(USBFS_Type const * base,uint32_t endpoint)1082 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetArbEpInterruptStatusMasked(USBFS_Type const *base, uint32_t endpoint)
1083 {
1084 uint32_t mask = CY_USBFS_DEV_READ_ODD(USBFS_DEV_ARB_EP_INT_EN(base, endpoint));
1085 return (USBFS_DEV_ARB_EP_SR(base, endpoint) & mask);
1086 }
1087
1088
1089 /*******************************************************************************
1090 * Function Name: Cy_USBFS_Dev_Drv_ClearArbEpInterrupt
1091 ****************************************************************************//**
1092 *
1093 * Clears the current status of the arbiter interrupt sources for the specified
1094 * data endpoint.
1095 *
1096 * \param base
1097 * The pointer to the USBFS instance.
1098 *
1099 * \param endpoint
1100 * Physical endpoint number.
1101 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1102 *
1103 * \param mask
1104 * The arbiter interrupt sources to be cleared.
1105 * See \ref group_usbfs_dev_drv_reg_macros_arb_ep_intr for the set of constants.
1106 *
1107 *******************************************************************************/
Cy_USBFS_Dev_Drv_ClearArbEpInterrupt(USBFS_Type * base,uint32_t endpoint,uint32_t mask)1108 __STATIC_INLINE void Cy_USBFS_Dev_Drv_ClearArbEpInterrupt(USBFS_Type *base, uint32_t endpoint, uint32_t mask)
1109 {
1110 USBFS_DEV_ARB_EP_SR(base, endpoint) = mask;
1111 /* This dummy reading is necessary here. It provides a guarantee that interrupt is cleared at returning from this function. */
1112 (void) USBFS_DEV_ARB_EP_SR(base, endpoint);
1113 }
1114
1115
1116 /*******************************************************************************
1117 * Function Name: Cy_USBFS_Dev_Drv_SetArbEpConfig
1118 ****************************************************************************//**
1119 *
1120 * Writes the configuration register for the specified data endpoint.
1121 *
1122 * \param base
1123 * The pointer to the USBFS instance.
1124 *
1125 * \param endpoint
1126 * Physical endpoint number.
1127 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1128 *
1129 * \param cfg
1130 * The value written into the data endpoint configuration register.
1131 *
1132 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetArbEpConfig(USBFS_Type * base,uint32_t endpoint,uint32_t cfg)1133 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetArbEpConfig(USBFS_Type *base, uint32_t endpoint, uint32_t cfg)
1134 {
1135 USBFS_DEV_ARB_EP_CFG(base, endpoint) = cfg;
1136 }
1137
1138
1139 /*******************************************************************************
1140 * Function Name: Cy_USBFS_Dev_Drv_SetArbCfgEpInReady
1141 ****************************************************************************//**
1142 *
1143 * Notifies hardware that IN endpoint data buffer is read to be loaded in
1144 * the hardware buffer.
1145 *
1146 * \param base
1147 * The pointer to the USBFS instance.
1148 *
1149 * \param endpoint
1150 * Physical endpoint number.
1151 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1152 *
1153 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetArbCfgEpInReady(USBFS_Type * base,uint32_t endpoint)1154 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetArbCfgEpInReady(USBFS_Type *base, uint32_t endpoint)
1155 {
1156 USBFS_DEV_ARB_EP_CFG(base, endpoint) |= USBFS_USBDEV_ARB_EP1_CFG_IN_DATA_RDY_Msk;
1157 }
1158
1159
1160 /*******************************************************************************
1161 * Function Name: Cy_USBFS_Dev_Drv_ClearArbCfgEpInReady
1162 ****************************************************************************//**
1163 *
1164 * Clears hardware notification that IN endpoint data buffer is read to be loaded
1165 * in the hardware buffer. This function needs to be called after buffer was
1166 * copied into the hardware buffer.
1167 *
1168 * \param base
1169 * The pointer to the USBFS instance.
1170 *
1171 * \param endpoint
1172 * Physical endpoint number.
1173 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1174
1175 *
1176 *******************************************************************************/
Cy_USBFS_Dev_Drv_ClearArbCfgEpInReady(USBFS_Type * base,uint32_t endpoint)1177 __STATIC_INLINE void Cy_USBFS_Dev_Drv_ClearArbCfgEpInReady(USBFS_Type *base, uint32_t endpoint)
1178 {
1179 USBFS_DEV_ARB_EP_CFG(base, endpoint) &= ~USBFS_USBDEV_ARB_EP1_CFG_IN_DATA_RDY_Msk;
1180 }
1181
1182
1183 /*******************************************************************************
1184 * Function Name: Cy_USBFS_Dev_Drv_TriggerArbCfgEpDmaReq
1185 ****************************************************************************//**
1186 *
1187 * Triggers a DMA request to read from or write data into the hardware buffer.
1188 *
1189 * \param base
1190 * The pointer to the USBFS instance.
1191 *
1192 * \param endpoint
1193 * Physical endpoint number.
1194 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1195 *
1196 *******************************************************************************/
Cy_USBFS_Dev_Drv_TriggerArbCfgEpDmaReq(USBFS_Type * base,uint32_t endpoint)1197 __STATIC_INLINE void Cy_USBFS_Dev_Drv_TriggerArbCfgEpDmaReq(USBFS_Type *base, uint32_t endpoint)
1198 {
1199 /* Generates DMA request */
1200 USBFS_DEV_ARB_EP_CFG(base, endpoint) |= USBFS_USBDEV_ARB_EP1_CFG_DMA_REQ_Msk;
1201 (void) USBFS_DEV_ARB_EP_CFG(base, endpoint);
1202 USBFS_DEV_ARB_EP_CFG(base, endpoint) &= ~USBFS_USBDEV_ARB_EP1_CFG_DMA_REQ_Msk;
1203 (void) USBFS_DEV_ARB_EP_CFG(base, endpoint);
1204 }
1205
1206
1207 /*******************************************************************************
1208 * Function Name: Cy_USBFS_Dev_Drv_SetArbWriteAddr
1209 ****************************************************************************//**
1210 *
1211 * Sets write address in the hardware buffer for the specified endpoint.
1212 * This is the start address of the endpoint buffer.
1213 *
1214 * \param base
1215 * The pointer to the USBFS instance.
1216 *
1217 * \param endpoint
1218 * Physical endpoint number.
1219 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1220 *
1221 * \param wa
1222 * Write address value.
1223 *
1224 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetArbWriteAddr(USBFS_Type * base,uint32_t endpoint,uint32_t wa)1225 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetArbWriteAddr(USBFS_Type *base, uint32_t endpoint, uint32_t wa)
1226 {
1227 USBFS_DEV_ARB_RW_WA16(base, endpoint) = wa;
1228 }
1229
1230
1231 /*******************************************************************************
1232 * Function Name: Cy_USBFS_Dev_Drv_SetArbReadAddr
1233 ****************************************************************************//**
1234 *
1235 * Sets read address in the hardware buffer for the specified endpoint.
1236 * This is the start address of the endpoint buffer.
1237 *
1238 * \param base
1239 * The pointer to the USBFS instance.
1240 *
1241 * \param endpoint
1242 * Physical endpoint number.
1243 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1244 *
1245 * \param ra
1246 * Read address value.
1247 *
1248 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetArbReadAddr(USBFS_Type * base,uint32_t endpoint,uint32_t ra)1249 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetArbReadAddr(USBFS_Type *base, uint32_t endpoint, uint32_t ra)
1250 {
1251 USBFS_DEV_ARB_RW_RA16(base, endpoint) = ra;
1252 }
1253
1254
1255 /*******************************************************************************
1256 * Function Name: Cy_USBFS_Dev_Drv_GetArbWriteAddr
1257 ****************************************************************************//**
1258 *
1259 * Returns write address in the hardware buffer for the specified endpoint.
1260 * This is the start address of the endpoint buffer.
1261 *
1262 * \param base
1263 * The pointer to the USBFS instance.
1264 *
1265 * \param endpoint
1266 * Physical endpoint number.
1267 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1268 *
1269 * \return
1270 * Write address in the hardware buffer for the specified endpoint.
1271 *
1272 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetArbWriteAddr(USBFS_Type const * base,uint32_t endpoint)1273 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetArbWriteAddr(USBFS_Type const *base, uint32_t endpoint)
1274 {
1275 return (USBFS_DEV_ARB_RW_WA16(base, endpoint));
1276 }
1277
1278
1279 /*******************************************************************************
1280 * Function Name: Cy_USBFS_Dev_Drv_GetArbReadAddr
1281 ****************************************************************************//**
1282 *
1283 * Returns read address in the hardware buffer for the specified endpoint.
1284 * This is the start address of the endpoint buffer.
1285 *
1286 * \param base
1287 * The pointer to the USBFS instance.
1288 *
1289 * \param endpoint
1290 * Physical endpoint number.
1291 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1292 *
1293 * \return
1294 * Read address in the hardware buffer for the specified endpoint.
1295 *
1296 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetArbReadAddr(USBFS_Type const * base,uint32_t endpoint)1297 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetArbReadAddr(USBFS_Type const *base, uint32_t endpoint)
1298 {
1299 return (USBFS_DEV_ARB_RW_RA16(base, endpoint));
1300 }
1301 /** \} group_usbfs_drv_drv_reg_arbiter */
1302
1303
1304 /**
1305 * \addtogroup group_usbfs_drv_drv_reg_arbiter_data
1306 * \{
1307 */
1308
1309 /*******************************************************************************
1310 * Function Name: Cy_USBFS_Dev_Drv_WriteData
1311 ****************************************************************************//**
1312 *
1313 * Writes a byte (8-bit) into the hardware buffer.
1314 *
1315 * \param base
1316 * The pointer to the USBFS instance.
1317 *
1318 * \param endpoint
1319 * Physical endpoint number.
1320 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1321 *
1322 * \param byte
1323 * The byte of data to be written into the hardware buffer.
1324 *
1325 *******************************************************************************/
Cy_USBFS_Dev_Drv_WriteData(USBFS_Type * base,uint32_t endpoint,uint8_t byte)1326 __STATIC_INLINE void Cy_USBFS_Dev_Drv_WriteData(USBFS_Type *base, uint32_t endpoint, uint8_t byte)
1327 {
1328 USBFS_DEV_ARB_RW_DR(base, endpoint) = (uint32_t) byte;
1329 }
1330
1331
1332 /*******************************************************************************
1333 * Function Name: Cy_USBFS_Dev_Drv_WriteData16
1334 ****************************************************************************//**
1335 *
1336 * Writes a half-word (16-bit) into the hardware buffer.
1337 *
1338 * \param base
1339 * The pointer to the USBFS instance.
1340 *
1341 * \param endpoint
1342 * Physical endpoint number.
1343 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1344 *
1345 * \param halfword
1346 * The half-word of data to be written into the hardware buffer.
1347 *
1348 *******************************************************************************/
Cy_USBFS_Dev_Drv_WriteData16(USBFS_Type * base,uint32_t endpoint,uint16_t halfword)1349 __STATIC_INLINE void Cy_USBFS_Dev_Drv_WriteData16(USBFS_Type *base, uint32_t endpoint, uint16_t halfword)
1350 {
1351 USBFS_DEV_ARB_RW_DR16(base, endpoint) = (uint32_t) halfword;
1352 }
1353
1354
1355 /*******************************************************************************
1356 * Function Name: Cy_USBFS_Dev_Drv_ReadData
1357 ****************************************************************************//**
1358 *
1359 * Reads a byte (8-bit) from the hardware buffer.
1360 *
1361 * \param base
1362 * The pointer to the USBFS instance.
1363 *
1364 * \param endpoint
1365 * Physical endpoint number.
1366 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1367 *
1368 * \return
1369 * The byte of data to be read from the hardware buffer.
1370 *
1371 *******************************************************************************/
Cy_USBFS_Dev_Drv_ReadData(USBFS_Type const * base,uint32_t endpoint)1372 __STATIC_INLINE uint8_t Cy_USBFS_Dev_Drv_ReadData(USBFS_Type const *base, uint32_t endpoint)
1373 {
1374 return ((uint8_t) USBFS_DEV_ARB_RW_DR(base, endpoint));
1375 }
1376
1377
1378 /*******************************************************************************
1379 * Function Name: Cy_USBFS_Dev_Drv_ReadData16
1380 ****************************************************************************//**
1381 *
1382 * Reads a half-word (16-bit) from the hardware buffer.
1383 *
1384 * \param base
1385 * The pointer to the USBFS instance.
1386 *
1387 * \param endpoint
1388 * Physical endpoint number.
1389 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1390 *
1391 * \return
1392 * The half-word of data to be read from the hardware buffer.
1393 *
1394 *******************************************************************************/
Cy_USBFS_Dev_Drv_ReadData16(USBFS_Type const * base,uint32_t endpoint)1395 __STATIC_INLINE uint16_t Cy_USBFS_Dev_Drv_ReadData16(USBFS_Type const *base, uint32_t endpoint)
1396 {
1397 return ((uint16_t) USBFS_DEV_ARB_RW_DR16(base, endpoint));
1398 }
1399
1400
1401 /*******************************************************************************
1402 * Function Name: Cy_USBFS_Dev_Drv_GetDataRegAddr
1403 ****************************************************************************//**
1404 *
1405 * Returns pointer to the 8-bit data register for the specified endpoint.
1406 *
1407 * \param base
1408 * The pointer to the USBFS instance.
1409 *
1410 * \param endpoint
1411 * Physical endpoint number.
1412 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1413 *
1414 * \return
1415 * The pointer to the 8-bit data register for the specified endpoint.
1416 *
1417 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetDataRegAddr(USBFS_Type * base,uint32_t endpoint)1418 __STATIC_INLINE volatile uint32_t * Cy_USBFS_Dev_Drv_GetDataRegAddr(USBFS_Type *base, uint32_t endpoint)
1419 {
1420 return (&USBFS_DEV_ARB_RW_DR(base, endpoint));
1421 }
1422
1423
1424 /*******************************************************************************
1425 * Function Name: Cy_USBFS_Dev_Drv_GetDataReg16Addr
1426 ****************************************************************************//**
1427 *
1428 * Returns pointer to the 16-bit data register for the specified endpoint.
1429 *
1430 * \param base
1431 * The pointer to the USBFS instance.
1432 *
1433 * \param endpoint
1434 * Physical endpoint number.
1435 * Valid range (0 - \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1).
1436 *
1437 * \return
1438 * The pointer to the 16-bit data register for the specified endpoint.
1439 *
1440 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetDataReg16Addr(USBFS_Type * base,uint32_t endpoint)1441 __STATIC_INLINE volatile uint32_t * Cy_USBFS_Dev_Drv_GetDataReg16Addr(USBFS_Type *base, uint32_t endpoint)
1442 {
1443 return (&USBFS_DEV_ARB_RW_DR16(base, endpoint));
1444 }
1445
1446
1447 /*******************************************************************************
1448 * Function Name: Cy_USBFS_Dev_Drv_FlushInBuffer
1449 ****************************************************************************//**
1450 *
1451 * Flushes IN endpoint buffer: sets WA pointer (controlled by CPU/DMA) to equal
1452 * RA (controlled by SIE; gets automatically reset on transfer completion).
1453 *
1454 * \param base
1455 * The pointer to the USBFS instance.
1456 *
1457 * \param endpoint
1458 * Physical endpoint number.
1459 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1460 *
1461 *******************************************************************************/
Cy_USBFS_Dev_Drv_FlushInBuffer(USBFS_Type * base,uint32_t endpoint)1462 __STATIC_INLINE void Cy_USBFS_Dev_Drv_FlushInBuffer(USBFS_Type *base, uint32_t endpoint)
1463 {
1464 Cy_USBFS_Dev_Drv_SetArbWriteAddr(base, endpoint,
1465 Cy_USBFS_Dev_Drv_GetArbReadAddr(base, endpoint));
1466 }
1467 /** \} group_usbfs_drv_drv_reg_arbiter_data */
1468
1469
1470 /**
1471 * \addtogroup group_usbfs_drv_drv_reg_misc
1472 * \{
1473 */
1474
1475 /*******************************************************************************
1476 * Function Name: Cy_USBFS_Dev_Drv_SetEpType
1477 ****************************************************************************//**
1478 *
1479 * Sets the data endpoint direction.
1480 *
1481 * \param base
1482 * The pointer to the USBFS instance.
1483 *
1484 * \param inDirection
1485 * Defines whether endpoint direction is IN (true) or OUT (false).
1486 *
1487 * \param endpoint
1488 * Physical endpoint number.
1489 * Valid range: 0 - ( \ref CY_USBFS_DEV_DRV_NUM_EPS_MAX - 1 ).
1490 *
1491 *******************************************************************************/
Cy_USBFS_Dev_Drv_SetEpType(USBFS_Type * base,bool inDirection,uint32_t endpoint)1492 __STATIC_INLINE void Cy_USBFS_Dev_Drv_SetEpType(USBFS_Type *base, bool inDirection, uint32_t endpoint)
1493 {
1494 uint32_t mask = (uint32_t) (0x1UL << endpoint);
1495 uint32_t regValue = CY_USBFS_DEV_READ_ODD(USBFS_DEV_EP_TYPE(base));
1496
1497 if (inDirection)
1498 {
1499 /* IN direction: clear bit */
1500 regValue &= ~mask;
1501 }
1502 else
1503 {
1504 /* OUT direction: set bit */
1505 regValue |= mask;
1506 }
1507
1508 USBFS_DEV_EP_TYPE(base) = CY_USBFS_DEV_DRV_WRITE_ODD(regValue);
1509 }
1510
1511
1512 /*******************************************************************************
1513 * Function Name: Cy_USBFS_Dev_Drv_GetSofNubmer
1514 ****************************************************************************//**
1515 *
1516 * Returns the SOF frame number.
1517 *
1518 * \param base
1519 * The pointer to the USBFS instance.
1520 *
1521 * \return
1522 * The SOF frame number.
1523 *
1524 *******************************************************************************/
Cy_USBFS_Dev_Drv_GetSofNubmer(USBFS_Type const * base)1525 __STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetSofNubmer(USBFS_Type const *base)
1526 {
1527 return _FLD2VAL(USBFS_USBDEV_SOF16_FRAME_NUMBER16, USBFS_DEV_SOF16(base));
1528 }
1529 /** \} group_usbfs_drv_drv_reg_misc */
1530
1531 #if defined(__cplusplus)
1532 }
1533 #endif
1534
1535 #endif /* CY_IP_MXUSBFS */
1536
1537 #endif /* (CY_USBFS_DEV_DRV_REG_H) */
1538
1539 /** \endcond */
1540
1541
1542 /* [] END OF FILE */
1543