stmhal: Clean up USB CDC/MSC files and remove commented-out code.
This commit is contained in:
parent
cadbd7f3e6
commit
c972c60dbe
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Micro Python project, http://micropython.org/
|
* This file is part of the MicroPython project, http://micropython.org/
|
||||||
*
|
*
|
||||||
* Taken from ST Cube library and heavily modified. See below for original
|
* Taken from ST Cube library and heavily modified. See below for original
|
||||||
* copyright header.
|
* copyright header.
|
||||||
|
@ -102,52 +102,14 @@ const USBD_CDC_ItfTypeDef USBD_CDC_fops = {
|
||||||
* @param None
|
* @param None
|
||||||
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
|
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
|
||||||
*/
|
*/
|
||||||
static int8_t CDC_Itf_Init(USBD_HandleTypeDef *pdev)
|
static int8_t CDC_Itf_Init(USBD_HandleTypeDef *pdev) {
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
/*##-1- Configure the UART peripheral ######################################*/
|
|
||||||
/* Put the USART peripheral in the Asynchronous mode (UART Mode) */
|
|
||||||
/* USART configured as follow:
|
|
||||||
- Word Length = 8 Bits
|
|
||||||
- Stop Bit = One Stop bit
|
|
||||||
- Parity = No parity
|
|
||||||
- BaudRate = 115200 baud
|
|
||||||
- Hardware flow control disabled (RTS and CTS signals) */
|
|
||||||
UartHandle.Instance = USARTx;
|
|
||||||
UartHandle.Init.BaudRate = 115200;
|
|
||||||
UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
|
|
||||||
UartHandle.Init.StopBits = UART_STOPBITS_1;
|
|
||||||
UartHandle.Init.Parity = UART_PARITY_NONE;
|
|
||||||
UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
|
||||||
UartHandle.Init.Mode = UART_MODE_TX_RX;
|
|
||||||
|
|
||||||
if(HAL_UART_Init(&UartHandle) != HAL_OK)
|
|
||||||
{
|
|
||||||
/* Initialization Error */
|
|
||||||
Error_Handler();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*##-2- Put UART peripheral in IT reception process ########################*/
|
|
||||||
/* Any data received will be stored in "UserTxBuffer" buffer */
|
|
||||||
if(HAL_UART_Receive_IT(&UartHandle, (uint8_t *)UserTxBuffer, 1) != HAL_OK)
|
|
||||||
{
|
|
||||||
/* Transfer error in reception process */
|
|
||||||
Error_Handler();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*##-3- Configure the TIM Base generation #################################*/
|
|
||||||
now done in HAL_MspInit
|
|
||||||
TIM_Config();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*##-5- Set Application Buffers ############################################*/
|
|
||||||
USBD_CDC_SetTxBuffer(pdev, UserTxBuffer, 0);
|
USBD_CDC_SetTxBuffer(pdev, UserTxBuffer, 0);
|
||||||
USBD_CDC_SetRxBuffer(pdev, cdc_rx_packet_buf);
|
USBD_CDC_SetRxBuffer(pdev, cdc_rx_packet_buf);
|
||||||
|
|
||||||
cdc_rx_buf_put = 0;
|
cdc_rx_buf_put = 0;
|
||||||
cdc_rx_buf_get = 0;
|
cdc_rx_buf_get = 0;
|
||||||
|
|
||||||
return (USBD_OK);
|
return USBD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,16 +118,8 @@ static int8_t CDC_Itf_Init(USBD_HandleTypeDef *pdev)
|
||||||
* @param None
|
* @param None
|
||||||
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
|
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
|
||||||
*/
|
*/
|
||||||
static int8_t CDC_Itf_DeInit(void)
|
static int8_t CDC_Itf_DeInit(void) {
|
||||||
{
|
return USBD_OK;
|
||||||
#if 0
|
|
||||||
/* DeInitialize the UART peripheral */
|
|
||||||
if(HAL_UART_DeInit(&UartHandle) != HAL_OK)
|
|
||||||
{
|
|
||||||
/* Initialization Error */
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return (USBD_OK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -210,16 +164,6 @@ static int8_t CDC_Itf_Control(uint8_t cmd, uint8_t* pbuf, uint16_t length) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CDC_GET_LINE_CODING:
|
case CDC_GET_LINE_CODING:
|
||||||
#if 0
|
|
||||||
pbuf[0] = (uint8_t)(LineCoding.bitrate);
|
|
||||||
pbuf[1] = (uint8_t)(LineCoding.bitrate >> 8);
|
|
||||||
pbuf[2] = (uint8_t)(LineCoding.bitrate >> 16);
|
|
||||||
pbuf[3] = (uint8_t)(LineCoding.bitrate >> 24);
|
|
||||||
pbuf[4] = LineCoding.format;
|
|
||||||
pbuf[5] = LineCoding.paritytype;
|
|
||||||
pbuf[6] = LineCoding.datatype;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Add your code here */
|
/* Add your code here */
|
||||||
pbuf[0] = (uint8_t)(115200);
|
pbuf[0] = (uint8_t)(115200);
|
||||||
pbuf[1] = (uint8_t)(115200 >> 8);
|
pbuf[1] = (uint8_t)(115200 >> 8);
|
||||||
|
@ -318,11 +262,6 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {
|
||||||
* free to modify it.
|
* free to modify it.
|
||||||
*/
|
*/
|
||||||
static int8_t CDC_Itf_Receive(USBD_HandleTypeDef *pdev, uint8_t* Buf, uint32_t *Len) {
|
static int8_t CDC_Itf_Receive(USBD_HandleTypeDef *pdev, uint8_t* Buf, uint32_t *Len) {
|
||||||
#if 0
|
|
||||||
// this sends the data over the UART using DMA
|
|
||||||
HAL_UART_Transmit_DMA(&UartHandle, Buf, *Len);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// copy the incoming data into the circular buffer
|
// copy the incoming data into the circular buffer
|
||||||
for (uint8_t *src = Buf, *top = Buf + *Len; src < top; ++src) {
|
for (uint8_t *src = Buf, *top = Buf + *Len; src < top; ++src) {
|
||||||
if (mp_interrupt_char != -1 && *src == mp_interrupt_char) {
|
if (mp_interrupt_char != -1 && *src == mp_interrupt_char) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Micro Python project, http://micropython.org/
|
* This file is part of the MicroPython project, http://micropython.org/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
*
|
||||||
* Heavily modified by dpgeorge for Micro Python.
|
* Heavily modified by dpgeorge for MicroPython.
|
||||||
*
|
*
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
@ -134,13 +134,6 @@ int8_t FLASH_STORAGE_PreventAllowMediumRemoval(uint8_t lun, uint8_t param) {
|
||||||
*/
|
*/
|
||||||
int8_t FLASH_STORAGE_Read(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) {
|
int8_t FLASH_STORAGE_Read(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) {
|
||||||
storage_read_blocks(buf, blk_addr, blk_len);
|
storage_read_blocks(buf, blk_addr, blk_len);
|
||||||
/*
|
|
||||||
for (int i = 0; i < blk_len; i++) {
|
|
||||||
if (!storage_read_block(buf + i * FLASH_BLOCK_SIZE, blk_addr + i)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,13 +147,6 @@ int8_t FLASH_STORAGE_Read(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t
|
||||||
*/
|
*/
|
||||||
int8_t FLASH_STORAGE_Write (uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) {
|
int8_t FLASH_STORAGE_Write (uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) {
|
||||||
storage_write_blocks(buf, blk_addr, blk_len);
|
storage_write_blocks(buf, blk_addr, blk_len);
|
||||||
/*
|
|
||||||
for (int i = 0; i < blk_len; i++) {
|
|
||||||
if (!storage_write_block(buf + i * FLASH_BLOCK_SIZE, blk_addr + i)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,20 +199,6 @@ static const int8_t SDCARD_STORAGE_Inquirydata[] = { // 36 bytes
|
||||||
* @retval Status
|
* @retval Status
|
||||||
*/
|
*/
|
||||||
int8_t SDCARD_STORAGE_Init(uint8_t lun) {
|
int8_t SDCARD_STORAGE_Init(uint8_t lun) {
|
||||||
/*
|
|
||||||
#ifndef USE_STM3210C_EVAL
|
|
||||||
NVIC_InitTypeDef NVIC_InitStructure;
|
|
||||||
NVIC_InitStructure.NVIC_IRQChannel = SDIO_IRQn;
|
|
||||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority =0;
|
|
||||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
|
|
||||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
|
||||||
NVIC_Init(&NVIC_InitStructure);
|
|
||||||
#endif
|
|
||||||
if( SD_Init() != 0)
|
|
||||||
{
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (!sdcard_power_on()) {
|
if (!sdcard_power_on()) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -243,20 +215,8 @@ int8_t SDCARD_STORAGE_Init(uint8_t lun) {
|
||||||
* @retval Status
|
* @retval Status
|
||||||
*/
|
*/
|
||||||
int8_t SDCARD_STORAGE_GetCapacity(uint8_t lun, uint32_t *block_num, uint16_t *block_size) {
|
int8_t SDCARD_STORAGE_GetCapacity(uint8_t lun, uint32_t *block_num, uint16_t *block_size) {
|
||||||
/*
|
|
||||||
#ifdef USE_STM3210C_EVAL
|
|
||||||
SD_CardInfo SDCardInfo;
|
|
||||||
SD_GetCardInfo(&SDCardInfo);
|
|
||||||
#else
|
|
||||||
if(SD_GetStatus() != 0 ) {
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
|
|
||||||
*block_size = SDCARD_BLOCK_SIZE;
|
*block_size = SDCARD_BLOCK_SIZE;
|
||||||
*block_num = sdcard_get_capacity_in_bytes() / SDCARD_BLOCK_SIZE;
|
*block_num = sdcard_get_capacity_in_bytes() / SDCARD_BLOCK_SIZE;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue