1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-22 15:55:40 +03:00

Potential fix for GCC 13 VCP broken on H7

This commit is contained in:
Pawel Spychalski (DzikuVx) 2024-04-02 11:23:07 +02:00
parent 005194e73a
commit 1e09f0d075
2 changed files with 12 additions and 8 deletions

View file

@ -23,7 +23,10 @@
// Use all available bits for priority and zero bits to sub-priority
#ifdef USE_HAL_DRIVER
#define NVIC_PRIORITY_GROUPING NVIC_PRIORITYGROUP_4
#define NVIC_BUILD_PRIORITY(base,sub) (((((base)<<(4-(7-(NVIC_PRIORITY_GROUPING))))|((sub)&(0x0f>>(7-(NVIC_PRIORITY_GROUPING)))))<<4)&0xf0)
#else
#define NVIC_PRIORITY_GROUPING NVIC_PriorityGroup_4
#endif
#endif
#endif

View file

@ -54,6 +54,8 @@
#include "usbd_cdc_interface.h"
#include "stdbool.h"
#include "drivers/time.h"
#include "drivers/nvic.h"
#include "build/atomic.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
@ -366,14 +368,13 @@ uint32_t CDC_Receive_BytesAvailable(void)
uint32_t CDC_Send_FreeBytes(void)
{
/*
return the bytes free in the circular buffer
uint32_t freeBytes;
functionally equivalent to:
(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)
but without the impact of the condition check.
*/
return ((UserTxBufPtrOut - UserTxBufPtrIn) + (-((int)(UserTxBufPtrOut <= UserTxBufPtrIn)) & APP_TX_DATA_SIZE)) - 1;
ATOMIC_BLOCK(NVIC_BUILD_PRIORITY(6, 0)) {
freeBytes = ((UserTxBufPtrOut - UserTxBufPtrIn) + (-((int)(UserTxBufPtrOut <= UserTxBufPtrIn)) & APP_TX_DATA_SIZE)) - 1;
}
return freeBytes;
}
/**