Enable double buffered mode in USB

remotes/github/bad-doublebuf
Ondřej Hruška 7 years ago
parent da330b4b73
commit c4efa5ddaa
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 1
      FreeRTOSConfig.h
  2. 4
      TinyFrame/TF_Integration.c
  3. 2
      USB/usbd_cdc_if.c
  4. 12
      USB/usbd_conf.c
  5. 2
      USB/usbd_conf.h
  6. 2
      freertos.c
  7. 2
      platform/plat_compat.h

@ -109,6 +109,7 @@ extern uint32_t SystemCoreClock;
#define configQUEUE_REGISTRY_SIZE 0 #define configQUEUE_REGISTRY_SIZE 0
#define configCHECK_FOR_STACK_OVERFLOW 2 #define configCHECK_FOR_STACK_OVERFLOW 2
#define configENABLE_BACKWARD_COMPATIBILITY 0 #define configENABLE_BACKWARD_COMPATIBILITY 0
#define configUSE_COUNTING_SEMAPHORES 0
#define configUSE_TIMERS 0 #define configUSE_TIMERS 0
#define configTIMER_TASK_PRIORITY TSK_TIMERS_PRIO // above normal #define configTIMER_TASK_PRIORITY TSK_TIMERS_PRIO // above normal

@ -29,10 +29,10 @@ void TF_WriteImpl(TinyFrame *tf, const uint8_t *buff, uint32_t len)
const uint16_t chunksize = (uint16_t) MIN(total, CHUNK); const uint16_t chunksize = (uint16_t) MIN(total, CHUNK);
// this is an attempt to speed it up a little by removing a couple levels of indirection // this is an attempt to speed it up a little by removing a couple levels of indirection
assert_param(HAL_OK == HAL_PCD_EP_Transmit(hUsbDeviceFS.pData, CDC_IN_EP, (uint8_t *) buff, chunksize)); // assert_param(HAL_OK == HAL_PCD_EP_Transmit(hUsbDeviceFS.pData, CDC_IN_EP, (uint8_t *) buff, chunksize));
// USBD_LL_Transmit(&hUsbDeviceFS, CDC_IN_EP, (uint8_t *) buff, chunksize); // USBD_LL_Transmit(&hUsbDeviceFS, CDC_IN_EP, (uint8_t *) buff, chunksize);
// assert_param(USBD_OK == CDC_Transmit_FS((uint8_t *) buff, chunksize)); assert_param(USBD_OK == CDC_Transmit_FS((uint8_t *) buff, chunksize));
buff += chunksize; buff += chunksize;
total -= chunksize; total -= chunksize;

@ -313,6 +313,8 @@ void USBD_CDC_TransmitDone(USBD_HandleTypeDef *pdev)
assert_param(semVcomTxReadyHandle != NULL); assert_param(semVcomTxReadyHandle != NULL);
assert_param(inIRQ()); assert_param(inIRQ());
if (uxSemaphoreGetCount(semVcomTxReadyHandle) == 1) return;
portBASE_TYPE taskWoken = pdFALSE; portBASE_TYPE taskWoken = pdFALSE;
assert_param(xSemaphoreGiveFromISR(semVcomTxReadyHandle, &taskWoken) == pdTRUE); assert_param(xSemaphoreGiveFromISR(semVcomTxReadyHandle, &taskWoken) == pdTRUE);
portYIELD_FROM_ISR(taskWoken); portYIELD_FROM_ISR(taskWoken);

@ -397,8 +397,16 @@ USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev)
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , MSC_EPOUT_ADDR , PCD_SNG_BUF, ptr += 64); // 64 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , MSC_EPOUT_ADDR , PCD_SNG_BUF, ptr += 64); // 64
// CDC endpoints, EP2 two-way and EP3 in-only // CDC endpoints, EP2 two-way and EP3 in-only
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , CDC_IN_EP , PCD_SNG_BUF, ptr += 64); // 64 uint32_t buf1addr, buf2addr;
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , CDC_OUT_EP , PCD_SNG_BUF, ptr += 64); // 64
buf1addr = (ptr += 64);
buf2addr = (ptr += 64);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , CDC_IN_EP , PCD_DBL_BUF, buf1addr | (buf2addr << 16)); // 64
buf1addr = (ptr += 64);
buf2addr = (ptr += 64);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , CDC_OUT_EP , PCD_DBL_BUF, buf1addr | (buf2addr << 16)); // 64
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , CDC_CMD_EP , PCD_SNG_BUF, ptr += 16); // 16 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , CDC_CMD_EP , PCD_SNG_BUF, ptr += 16); // 16
(void)ptr; (void)ptr;
#endif #endif

@ -99,7 +99,7 @@
#define CDC_CUSTOM_EPS #define CDC_CUSTOM_EPS
#define CDC_IN_EP 0x82 /* EP1 for data IN */ #define CDC_IN_EP 0x82 /* EP1 for data IN */
#define CDC_OUT_EP 0x02 /* EP1 for data OUT */ #define CDC_OUT_EP 0x04 /* EP1 for data OUT */
#define CDC_CMD_EP 0x83 /* EP2 for CDC commands */ #define CDC_CMD_EP 0x83 /* EP2 for CDC commands */
/** @defgroup USBD_Exported_Macros /** @defgroup USBD_Exported_Macros

@ -169,7 +169,7 @@ void MX_FREERTOS_Init(void) {
/* USER CODE BEGIN RTOS_SEMAPHORES */ /* USER CODE BEGIN RTOS_SEMAPHORES */
/* add semaphores, ... */ /* add semaphores, ... */
xSemaphoreGive(semVcomTxReadyHandle); assert_param(pdTRUE == xSemaphoreGive(semVcomTxReadyHandle));
/* USER CODE END RTOS_SEMAPHORES */ /* USER CODE END RTOS_SEMAPHORES */
/* USER CODE BEGIN RTOS_TIMERS */ /* USER CODE BEGIN RTOS_TIMERS */

@ -21,7 +21,7 @@
#endif #endif
// 180 is normally enough if not doing extensive debug logging // 180 is normally enough if not doing extensive debug logging
#define TSK_STACK_MSG 220 // TF message handler task stack size (all unit commands run on this thread) #define TSK_STACK_MSG 260 // TF message handler task stack size (all unit commands run on this thread)
#define TSK_STACK_IDLE 64 //configMINIMAL_STACK_SIZE #define TSK_STACK_IDLE 64 //configMINIMAL_STACK_SIZE
#define TSK_STACK_TIMERS 64 //configTIMER_TASK_STACK_DEPTH #define TSK_STACK_TIMERS 64 //configTIMER_TASK_STACK_DEPTH

Loading…
Cancel
Save