blob: 327abb47da8764d1e1bd7122401d82940970ee73 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
/**************************************************************************//**
* @file config.h
* @version V1.00
* @brief This header file defines the configuration of USB Host library.
* @note
* SPDX-License-Identifier: Apache-2.0
* Copyright (C) 2018 Nuvoton Technology Corp. All rights reserved.
*****************************************************************************/
#ifndef _USBH_CONFIG_H_
#define _USBH_CONFIG_H_
/// @cond HIDDEN_SYMBOLS
#include <rtthread.h>
#include "NuMicro.h"
#include "nu_sys.h"
#include "drv_sys.h"
/*----------------------------------------------------------------------------------------*/
/* Hardware settings */
/*----------------------------------------------------------------------------------------*/
#define HCLK_MHZ 700 /* used for loop-delay. must be larger than
true HCLK clock MHz */
static __inline void ENABLE_OHCI_IRQ(void)
{
rt_hw_interrupt_umask(USBH0_IRQn);
rt_hw_interrupt_umask(USBH1_IRQn);
}
static __inline void DISABLE_OHCI_IRQ(void)
{
rt_hw_interrupt_mask(USBH0_IRQn);
rt_hw_interrupt_mask(USBH1_IRQn);
}
static __inline void ENABLE_EHCI_IRQ(void)
{
rt_hw_interrupt_umask(HSUSBH0_IRQn);
rt_hw_interrupt_umask(HSUSBH1_IRQn);
}
static __inline void DISABLE_EHCI_IRQ(void)
{
rt_hw_interrupt_mask(HSUSBH0_IRQn);
rt_hw_interrupt_mask(HSUSBH1_IRQn);
}
#if defined(BSP_USING_HSUSBH0)
#define ENABLE_EHCI0
#define ENABLE_OHCI0
#endif
#if defined(BSP_USING_HSUSBH1)
#define ENABLE_EHCI1
#define ENABLE_OHCI1
#endif
#define EHCI_PORT_CNT 1 /* Number of EHCI roothub ports */
#define OHCI_PORT_CNT 1 /* Number of OHCI roothub ports */
#define OHCI_PER_PORT_POWER /* OHCI root hub per port powered */
#define OHCI_ISO_DELAY 4 /* preserved number frames while scheduling
OHCI isochronous transfer */
#define EHCI_ISO_DELAY 2 /* preserved number of frames while
scheduling EHCI isochronous transfer */
#define EHCI_ISO_RCLM_RANGE 32 /* When inspecting activated iTD/siTD,
unconditionally reclaim iTD/isTD scheduled
in just elapsed EHCI_ISO_RCLM_RANGE ms. */
#define MAX_DESC_BUFF_SIZE 4096 /* To hold the configuration descriptor, USB
core will allocate a buffer with this size
for each connected device. USB core does
not release it until device disconnected. */
/*----------------------------------------------------------------------------------------*/
/* Memory allocation settings */
/*----------------------------------------------------------------------------------------*/
#define STATIC_MEMORY_ALLOC 0 /* pre-allocate static memory blocks. No dynamic memory aloocation.
But the maximum number of connected devices and transfers are
limited. */
#define MAX_UDEV_DRIVER 8 /*!< Maximum number of registered drivers */
#define MAX_ALT_PER_IFACE 32 /*!< maximum number of alternative interfaces per interface */
#define MAX_EP_PER_IFACE 6 /*!< maximum number of endpoints per interface */
#define MAX_HUB_DEVICE 8 /*!< Maximum number of hub devices */
/* Host controller hardware transfer descriptors memory pool. ED/TD/ITD of OHCI and QH/QTD of EHCI
are all allocated from this pool. Allocated unit size is determined by MEM_POOL_UNIT_SIZE.
May allocate one or more units depend on hardware descriptor type. */
#define MEM_POOL_UNIT_SIZE 256 /*!< A fixed hard coding setting. Do not change it! */
#define MEM_POOL_UNIT_NUM 64 /*!< Increase this or heap size if memory allocate failed. */
/*----------------------------------------------------------------------------------------*/
/* Re-defined staff for various compiler */
/*----------------------------------------------------------------------------------------*/
#ifdef __ICCARM__
#define __inline inline
#endif
/*----------------------------------------------------------------------------------------*/
/* Debug settings */
/*----------------------------------------------------------------------------------------*/
//#define ENABLE_ERROR_MSG /* enable debug messages */
//#define ENABLE_DEBUG_MSG /* enable debug messages */
//#define ENABLE_VERBOSE_DEBUG /* verbos debug messages */
//#define DUMP_DESCRIPTOR /* dump descriptors */
#ifdef ENABLE_ERROR_MSG
#define USB_error rt_kprintf
#else
#define USB_error(...)
#endif
#ifdef ENABLE_DEBUG_MSG
#define USB_debug rt_kprintf
#ifdef ENABLE_VERBOSE_DEBUG
#define USB_vdebug rt_kprintf
#else
#define USB_vdebug(...)
#endif
#else
#define USB_debug(...)
#define USB_vdebug(...)
#endif
#define ptr_to_u32(x) ((uint32_t)(x))
/// @endcond HIDDEN_SYMBOLS
#endif /* _USBH_CONFIG_H_ */
/*** (C) COPYRIGHT 2018 Nuvoton Technology Corp. ***/
|