1
1
/*
2
- * This file is part of the Micro Python project, http://micropython.org/
2
+ * This file is part of the MicroPython project, http://micropython.org/
3
3
*
4
4
* Taken from ST Cube library and heavily modified. See below for original
5
5
* copyright header.
23
23
*
24
24
* http://www.st.com/software_license_agreement_liberty_v2
25
25
*
26
- * Unless required by applicable law or agreed to in writing, software
27
- * distributed under the License is distributed on an "AS IS" BASIS,
26
+ * Unless required by applicable law or agreed to in writing, software
27
+ * distributed under the License is distributed on an "AS IS" BASIS,
28
28
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29
29
* See the License for the specific language governing permissions and
30
30
* limitations under the License.
@@ -102,52 +102,14 @@ const USBD_CDC_ItfTypeDef USBD_CDC_fops = {
102
102
* @param None
103
103
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
104
104
*/
105
- static int8_t CDC_Itf_Init (USBD_HandleTypeDef * pdev )
106
- {
107
- #if 0
108
- /*##-1- Configure the UART peripheral ######################################*/
109
- /* Put the USART peripheral in the Asynchronous mode (UART Mode) */
110
- /* USART configured as follow:
111
- - Word Length = 8 Bits
112
- - Stop Bit = One Stop bit
113
- - Parity = No parity
114
- - BaudRate = 115200 baud
115
- - Hardware flow control disabled (RTS and CTS signals) */
116
- UartHandle .Instance = USARTx ;
117
- UartHandle .Init .BaudRate = 115200 ;
118
- UartHandle .Init .WordLength = UART_WORDLENGTH_8B ;
119
- UartHandle .Init .StopBits = UART_STOPBITS_1 ;
120
- UartHandle .Init .Parity = UART_PARITY_NONE ;
121
- UartHandle .Init .HwFlowCtl = UART_HWCONTROL_NONE ;
122
- UartHandle .Init .Mode = UART_MODE_TX_RX ;
123
-
124
- if (HAL_UART_Init (& UartHandle ) != HAL_OK )
125
- {
126
- /* Initialization Error */
127
- Error_Handler ();
128
- }
129
-
130
- /*##-2- Put UART peripheral in IT reception process ########################*/
131
- /* Any data received will be stored in "UserTxBuffer" buffer */
132
- if (HAL_UART_Receive_IT (& UartHandle , (uint8_t * )UserTxBuffer , 1 ) != HAL_OK )
133
- {
134
- /* Transfer error in reception process */
135
- Error_Handler ();
136
- }
137
-
138
- /*##-3- Configure the TIM Base generation #################################*/
139
- now done in HAL_MspInit
140
- TIM_Config ();
141
- #endif
142
-
143
- /*##-5- Set Application Buffers ############################################*/
105
+ static int8_t CDC_Itf_Init (USBD_HandleTypeDef * pdev ) {
144
106
USBD_CDC_SetTxBuffer (pdev , UserTxBuffer , 0 );
145
107
USBD_CDC_SetRxBuffer (pdev , cdc_rx_packet_buf );
146
108
147
109
cdc_rx_buf_put = 0 ;
148
110
cdc_rx_buf_get = 0 ;
149
-
150
- return ( USBD_OK ) ;
111
+
112
+ return USBD_OK ;
151
113
}
152
114
153
115
/**
@@ -156,22 +118,14 @@ static int8_t CDC_Itf_Init(USBD_HandleTypeDef *pdev)
156
118
* @param None
157
119
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
158
120
*/
159
- static int8_t CDC_Itf_DeInit (void )
160
- {
161
- #if 0
162
- /* DeInitialize the UART peripheral */
163
- if (HAL_UART_DeInit (& UartHandle ) != HAL_OK )
164
- {
165
- /* Initialization Error */
166
- }
167
- #endif
168
- return (USBD_OK );
121
+ static int8_t CDC_Itf_DeInit (void ) {
122
+ return USBD_OK ;
169
123
}
170
124
171
125
/**
172
126
* @brief CDC_Itf_Control
173
127
* Manage the CDC class requests
174
- * @param Cmd: Command code
128
+ * @param Cmd: Command code
175
129
* @param Buf: Buffer containing command data (request parameters)
176
130
* @param Len: Number of data to be sent (in bytes)
177
131
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
@@ -210,16 +164,6 @@ static int8_t CDC_Itf_Control(uint8_t cmd, uint8_t* pbuf, uint16_t length) {
210
164
break ;
211
165
212
166
case CDC_GET_LINE_CODING :
213
- #if 0
214
- pbuf [0 ] = (uint8_t )(LineCoding .bitrate );
215
- pbuf [1 ] = (uint8_t )(LineCoding .bitrate >> 8 );
216
- pbuf [2 ] = (uint8_t )(LineCoding .bitrate >> 16 );
217
- pbuf [3 ] = (uint8_t )(LineCoding .bitrate >> 24 );
218
- pbuf [4 ] = LineCoding .format ;
219
- pbuf [5 ] = LineCoding .paritytype ;
220
- pbuf [6 ] = LineCoding .datatype ;
221
- #endif
222
-
223
167
/* Add your code here */
224
168
pbuf [0 ] = (uint8_t )(115200 );
225
169
pbuf [1 ] = (uint8_t )(115200 >> 8 );
@@ -318,11 +262,6 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {
318
262
* free to modify it.
319
263
*/
320
264
static int8_t CDC_Itf_Receive (USBD_HandleTypeDef * pdev , uint8_t * Buf , uint32_t * Len ) {
321
- #if 0
322
- // this sends the data over the UART using DMA
323
- HAL_UART_Transmit_DMA (& UartHandle , Buf , * Len );
324
- #endif
325
-
326
265
// copy the incoming data into the circular buffer
327
266
for (uint8_t * src = Buf , * top = Buf + * Len ; src < top ; ++ src ) {
328
267
if (mp_interrupt_char != -1 && * src == mp_interrupt_char ) {
0 commit comments