Skip to content

Commit c972c60

Browse files
committed
stmhal: Clean up USB CDC/MSC files and remove commented-out code.
1 parent cadbd7f commit c972c60

File tree

2 files changed

+13
-114
lines changed

2 files changed

+13
-114
lines changed

stmhal/usbd_cdc_interface.c

Lines changed: 9 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
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/
33
*
44
* Taken from ST Cube library and heavily modified. See below for original
55
* copyright header.
@@ -23,8 +23,8 @@
2323
*
2424
* http://www.st.com/software_license_agreement_liberty_v2
2525
*
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,
2828
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2929
* See the License for the specific language governing permissions and
3030
* limitations under the License.
@@ -102,52 +102,14 @@ const USBD_CDC_ItfTypeDef USBD_CDC_fops = {
102102
* @param None
103103
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
104104
*/
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) {
144106
USBD_CDC_SetTxBuffer(pdev, UserTxBuffer, 0);
145107
USBD_CDC_SetRxBuffer(pdev, cdc_rx_packet_buf);
146108

147109
cdc_rx_buf_put = 0;
148110
cdc_rx_buf_get = 0;
149-
150-
return (USBD_OK);
111+
112+
return USBD_OK;
151113
}
152114

153115
/**
@@ -156,22 +118,14 @@ static int8_t CDC_Itf_Init(USBD_HandleTypeDef *pdev)
156118
* @param None
157119
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
158120
*/
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;
169123
}
170124

171125
/**
172126
* @brief CDC_Itf_Control
173127
* Manage the CDC class requests
174-
* @param Cmd: Command code
128+
* @param Cmd: Command code
175129
* @param Buf: Buffer containing command data (request parameters)
176130
* @param Len: Number of data to be sent (in bytes)
177131
* @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) {
210164
break;
211165

212166
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-
223167
/* Add your code here */
224168
pbuf[0] = (uint8_t)(115200);
225169
pbuf[1] = (uint8_t)(115200 >> 8);
@@ -318,11 +262,6 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {
318262
* free to modify it.
319263
*/
320264
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-
326265
// copy the incoming data into the circular buffer
327266
for (uint8_t *src = Buf, *top = Buf + *Len; src < top; ++src) {
328267
if (mp_interrupt_char != -1 && *src == mp_interrupt_char) {

stmhal/usbd_msc_storage.c

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
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/
33
*/
44

55
/**
@@ -20,13 +20,13 @@
2020
*
2121
* http://www.st.com/software_license_agreement_liberty_v2
2222
*
23-
* Unless required by applicable law or agreed to in writing, software
24-
* distributed under the License is distributed on an "AS IS" BASIS,
23+
* Unless required by applicable law or agreed to in writing, software
24+
* distributed under the License is distributed on an "AS IS" BASIS,
2525
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2626
* See the License for the specific language governing permissions and
2727
* limitations under the License.
2828
*
29-
* Heavily modified by dpgeorge for Micro Python.
29+
* Heavily modified by dpgeorge for MicroPython.
3030
*
3131
******************************************************************************
3232
*/
@@ -134,13 +134,6 @@ int8_t FLASH_STORAGE_PreventAllowMediumRemoval(uint8_t lun, uint8_t param) {
134134
*/
135135
int8_t FLASH_STORAGE_Read(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) {
136136
storage_read_blocks(buf, blk_addr, blk_len);
137-
/*
138-
for (int i = 0; i < blk_len; i++) {
139-
if (!storage_read_block(buf + i * FLASH_BLOCK_SIZE, blk_addr + i)) {
140-
return -1;
141-
}
142-
}
143-
*/
144137
return 0;
145138
}
146139

@@ -154,13 +147,6 @@ int8_t FLASH_STORAGE_Read(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t
154147
*/
155148
int8_t FLASH_STORAGE_Write (uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) {
156149
storage_write_blocks(buf, blk_addr, blk_len);
157-
/*
158-
for (int i = 0; i < blk_len; i++) {
159-
if (!storage_write_block(buf + i * FLASH_BLOCK_SIZE, blk_addr + i)) {
160-
return -1;
161-
}
162-
}
163-
*/
164150
return 0;
165151
}
166152

@@ -213,20 +199,6 @@ static const int8_t SDCARD_STORAGE_Inquirydata[] = { // 36 bytes
213199
* @retval Status
214200
*/
215201
int8_t SDCARD_STORAGE_Init(uint8_t lun) {
216-
/*
217-
#ifndef USE_STM3210C_EVAL
218-
NVIC_InitTypeDef NVIC_InitStructure;
219-
NVIC_InitStructure.NVIC_IRQChannel = SDIO_IRQn;
220-
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority =0;
221-
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
222-
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
223-
NVIC_Init(&NVIC_InitStructure);
224-
#endif
225-
if( SD_Init() != 0)
226-
{
227-
return (-1);
228-
}
229-
*/
230202
if (!sdcard_power_on()) {
231203
return -1;
232204
}
@@ -243,20 +215,8 @@ int8_t SDCARD_STORAGE_Init(uint8_t lun) {
243215
* @retval Status
244216
*/
245217
int8_t SDCARD_STORAGE_GetCapacity(uint8_t lun, uint32_t *block_num, uint16_t *block_size) {
246-
/*
247-
#ifdef USE_STM3210C_EVAL
248-
SD_CardInfo SDCardInfo;
249-
SD_GetCardInfo(&SDCardInfo);
250-
#else
251-
if(SD_GetStatus() != 0 ) {
252-
return (-1);
253-
}
254-
#endif
255-
*/
256-
257218
*block_size = SDCARD_BLOCK_SIZE;
258219
*block_num = sdcard_get_capacity_in_bytes() / SDCARD_BLOCK_SIZE;
259-
260220
return 0;
261221
}
262222

0 commit comments

Comments
 (0)