File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626 #else
2727 #define NVIC_PRIORITY_GROUPING NVIC_PriorityGroup_4
2828 #endif
29- #endif
29+ #endif
Original file line number Diff line number Diff line change 5454#include "usbd_cdc_interface.h"
5555#include "stdbool.h"
5656#include "drivers/time.h"
57+ #include "drivers/nvic.h"
58+ #include "build/atomic.h"
5759
5860/* Private typedef -----------------------------------------------------------*/
5961/* Private define ------------------------------------------------------------*/
@@ -366,14 +368,13 @@ uint32_t CDC_Receive_BytesAvailable(void)
366368
367369uint32_t CDC_Send_FreeBytes (void )
368370{
369- /*
370- return the bytes free in the circular buffer
371-
372- functionally equivalent to:
373- (APP_Rx_ptr_out > APP_Rx_ptr_in ? APP_Rx_ptr_out - APP_Rx_ptr_in : APP_RX_DATA_SIZE - APP_Rx_ptr_in + APP_Rx_ptr_in)
374- but without the impact of the condition check.
375- */
376- return ((UserTxBufPtrOut - UserTxBufPtrIn ) + (- ((int )(UserTxBufPtrOut <= UserTxBufPtrIn )) & APP_TX_DATA_SIZE )) - 1 ;
371+ uint32_t freeBytes ;
372+
373+ ATOMIC_BLOCK (NVIC_PRIO_VCP ) {
374+ freeBytes = ((UserTxBufPtrOut - UserTxBufPtrIn ) + (- ((int )(UserTxBufPtrOut <= UserTxBufPtrIn )) & APP_TX_DATA_SIZE )) - 1 ;
375+ }
376+
377+ return freeBytes ;
377378}
378379
379380/**
You can’t perform that action at this time.
0 commit comments