mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-21 15:25:36 +03:00
F7 VCP improvements
This commit is contained in:
parent
d53b6584a0
commit
2a91c807c0
5 changed files with 19 additions and 25 deletions
|
@ -84,9 +84,8 @@ static void usbVcpWriteBuf(serialPort_t *instance, void *data, int count)
|
|||
|
||||
uint32_t start = millis();
|
||||
uint8_t *p = data;
|
||||
uint32_t txed = 0;
|
||||
while (count > 0) {
|
||||
txed = vcpWrite(p, count);
|
||||
uint32_t txed = vcpWrite(p, count);
|
||||
count -= txed;
|
||||
p += txed;
|
||||
|
||||
|
@ -110,9 +109,8 @@ static bool usbVcpFlush(vcpPort_t *port)
|
|||
|
||||
uint32_t start = millis();
|
||||
uint8_t *p = port->txBuf;
|
||||
uint32_t txed = 0;
|
||||
while (count > 0) {
|
||||
txed = vcpWrite(p, count);
|
||||
uint32_t txed = vcpWrite(p, count);
|
||||
count -= txed;
|
||||
p += txed;
|
||||
|
||||
|
@ -141,8 +139,7 @@ static void usbVcpBeginWrite(serialPort_t *instance)
|
|||
|
||||
uint32_t usbTxBytesFree()
|
||||
{
|
||||
// Because we block upon transmit and don't buffer bytes, our "buffer" capacity is effectively unlimited.
|
||||
return 255;
|
||||
return CDC_Send_FreeBytes();
|
||||
}
|
||||
|
||||
static void usbVcpEndWrite(serialPort_t *instance)
|
||||
|
|
|
@ -638,23 +638,6 @@ int main(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_HAL_DRIVER
|
||||
/**
|
||||
* @brief CPU L1-Cache enable.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void CPU_CACHE_Enable(void)
|
||||
{
|
||||
/* Enable I-Cache */
|
||||
SCB_EnableICache();
|
||||
|
||||
/* Enable D-Cache */
|
||||
SCB_EnableDCache();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef DEBUG_HARDFAULTS
|
||||
//from: https://mcuoneclipse.com/2012/11/24/debugging-hard-faults-on-arm-cortex-m/
|
||||
/**
|
||||
|
|
|
@ -276,9 +276,9 @@ void SystemInit(void)
|
|||
/* Configure the system clock to 216 MHz */
|
||||
SystemClock_Config();
|
||||
|
||||
if(SystemCoreClock != 216000000)
|
||||
//if(SystemCoreClock != 260000000)
|
||||
{
|
||||
while(1)
|
||||
//while(1)
|
||||
{
|
||||
// There is a mismatch between the configured clock and the expected clock in portable.h
|
||||
}
|
||||
|
|
|
@ -336,6 +336,19 @@ uint8_t vcpAvailable()
|
|||
return rxAvailable;
|
||||
}
|
||||
|
||||
uint32_t CDC_Send_FreeBytes(void)
|
||||
{
|
||||
/*
|
||||
return the bytes free in the circular buffer
|
||||
|
||||
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_RX_DATA_SIZE)) - 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief vcpWrite
|
||||
* CDC received data to be send over USB IN endpoint are managed in
|
||||
|
|
|
@ -72,6 +72,7 @@ uint8_t vcpAvailable();
|
|||
uint32_t vcpWrite(uint8_t* Buf, uint32_t Len);
|
||||
uint32_t vcpBaudrate();
|
||||
uint8_t vcpIsConnected();
|
||||
uint32_t CDC_Send_FreeBytes(void);
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue