Select one of the symbols to view example projects that use it.
 
Outline
...
...
...
...
#define UX_SOURCE_CODE
#define UX_HCD_STM32_SOURCE_CODE
#include "ux_api.h"
#include "ux_hcd_stm32.h"
#include "ux_host_stack.h"
...
...
_ux_hcd_stm32_initialize(UX_HCD *)
Files
loading...
CodeScopeSTM32 Libraries and Samplesusbxcommon/usbx_stm32_host_controllers/ux_hcd_stm32_initialize.c
 
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
141
142
143
144
145
146
147
148
149
150
151
152
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* Copyright (c) Microsoft Corporation. All rights reserved. */ /* */ /* This software is licensed under the Microsoft Software License */ /* Terms for Microsoft Azure RTOS. Full text of the license can be */ /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ /* and in the root directory of this software. */ /* */... /**************************************************************************/ ... /**************************************************************************/ /**************************************************************************/ /** */ /** USBX Component */ /** */ /** STM32 Controller Driver */ /** */... /**************************************************************************/ /**************************************************************************/ /* Include necessary system files. */ #define UX_SOURCE_CODE #define UX_HCD_STM32_SOURCE_CODE #include "ux_api.h" #include "ux_hcd_stm32.h" #include "ux_host_stack.h" ... /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_stm32_initialize PORTABLE C */ /* 6.0 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function initializes the STM32 HS USB host controller. This */ /* is not for the OTG mode. It forces the chip in Host mode only. */ /* For OTG support, the filex in the usbx_otg subdirectory must be */ /* used. */ /* */ /* INPUT */ /* */ /* HCD Pointer to HCD */ /* */ /* OUTPUT */ /* */ /* Completion Status */ /* */ /* CALLS */ /* */ /* _ux_utility_memory_allocate Allocate memory block */ /* */ /* CALLED BY */ /* */ /* Host Stack */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* */... /**************************************************************************/ UINT _ux_hcd_stm32_initialize(UX_HCD *hcd) { UX_HCD_STM32 *hcd_stm32; /* The controller initialized here is of STM32 type. */ hcd -> ux_hcd_controller_type = UX_HCD_STM32_CONTROLLER; /* Initialize the max bandwidth for periodic endpoints. On STM32, the spec says no more than 90% to be allocated for periodic. *//* ... */ #if UX_MAX_DEVICES > 1 hcd -> ux_hcd_available_bandwidth = UX_HCD_STM32_AVAILABLE_BANDWIDTH; #endif /* Allocate memory for this STM32 HCD instance. */ hcd_stm32 = _ux_utility_memory_allocate(UX_NO_ALIGN, UX_REGULAR_MEMORY, sizeof(UX_HCD_STM32)); if (hcd_stm32 == UX_NULL) return(UX_MEMORY_INSUFFICIENT); /* Set the pointer to the STM32 HCD. */ hcd -> ux_hcd_controller_hardware = (VOID *) hcd_stm32; /* Set the generic HCD owner for the STM32 HCD. */ hcd_stm32 -> ux_hcd_stm32_hcd_owner = hcd; /* Initialize the function collector for this HCD. */ hcd -> ux_hcd_entry_function = _ux_hcd_stm32_entry; /* Set the state of the controller to HALTED first. */ hcd -> ux_hcd_status = UX_HCD_STATUS_HALTED; /* Initialize the number of channels. */ hcd_stm32 -> ux_hcd_stm32_nb_channels = UX_HCD_STM32_MAX_NB_CHANNELS; /* Check if the parameter is null. */ if (hcd -> ux_hcd_irq == 0) { _ux_utility_memory_free(hcd_stm32); return(UX_ERROR); }if (hcd -> ux_hcd_irq == 0) { ... } /* Get HCD handle from parameter. */ hcd_stm32 -> hcd_handle = (HCD_HandleTypeDef*)hcd -> ux_hcd_irq; hcd_stm32 -> hcd_handle -> pData = hcd; /* Allocate the list of eds. */ hcd_stm32 -> ux_hcd_stm32_ed_list = _ux_utility_memory_allocate(UX_NO_ALIGN, UX_REGULAR_MEMORY, sizeof(UX_HCD_STM32_ED) *_ux_system_host -> ux_system_host_max_ed); if (hcd_stm32 -> ux_hcd_stm32_ed_list == UX_NULL) { _ux_utility_memory_free(hcd_stm32); return(UX_MEMORY_INSUFFICIENT); }if (hcd_stm32 -> ux_hcd_stm32_ed_list == UX_NULL) { ... } /* Since we know this is a high-speed controller, we can hardwire the version. */ #if UX_MAX_DEVICES > 1 hcd -> ux_hcd_version = 0x200; #endif /* The number of ports on the controller is fixed to 1. The number of ports needs to be reflected both for the generic HCD container and the local stm32 container. *//* ... */ hcd -> ux_hcd_nb_root_hubs = UX_HCD_STM32_NB_ROOT_PORTS; /* The root port must now be powered to pick up device insertion. */ _ux_hcd_stm32_power_on_port(hcd_stm32, 0); /* The asynchronous queues are empty for now. */ hcd_stm32 -> ux_hcd_stm32_queue_empty = UX_TRUE; /* The periodic scheduler is not active. */ hcd_stm32 -> ux_hcd_stm32_periodic_scheduler_active = 0; /* Set the host controller into the operational state. */ hcd -> ux_hcd_status = UX_HCD_STATUS_OPERATIONAL; /* Return successful completion. */ return(UX_SUCCESS); }{ ... }