1
0
Fork 0
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:
Sami Korhonen 2016-09-30 13:23:44 +03:00
parent d53b6584a0
commit 2a91c807c0
5 changed files with 19 additions and 25 deletions

View file

@ -84,9 +84,8 @@ static void usbVcpWriteBuf(serialPort_t *instance, void *data, int count)
uint32_t start = millis(); uint32_t start = millis();
uint8_t *p = data; uint8_t *p = data;
uint32_t txed = 0;
while (count > 0) { while (count > 0) {
txed = vcpWrite(p, count); uint32_t txed = vcpWrite(p, count);
count -= txed; count -= txed;
p += txed; p += txed;
@ -110,9 +109,8 @@ static bool usbVcpFlush(vcpPort_t *port)
uint32_t start = millis(); uint32_t start = millis();
uint8_t *p = port->txBuf; uint8_t *p = port->txBuf;
uint32_t txed = 0;
while (count > 0) { while (count > 0) {
txed = vcpWrite(p, count); uint32_t txed = vcpWrite(p, count);
count -= txed; count -= txed;
p += txed; p += txed;
@ -141,8 +139,7 @@ static void usbVcpBeginWrite(serialPort_t *instance)
uint32_t usbTxBytesFree() uint32_t usbTxBytesFree()
{ {
// Because we block upon transmit and don't buffer bytes, our "buffer" capacity is effectively unlimited. return CDC_Send_FreeBytes();
return 255;
} }
static void usbVcpEndWrite(serialPort_t *instance) static void usbVcpEndWrite(serialPort_t *instance)

View file

@ -638,23 +638,6 @@ int main(void)
} }
#endif #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 #ifdef DEBUG_HARDFAULTS
//from: https://mcuoneclipse.com/2012/11/24/debugging-hard-faults-on-arm-cortex-m/ //from: https://mcuoneclipse.com/2012/11/24/debugging-hard-faults-on-arm-cortex-m/
/** /**

View file

@ -276,9 +276,9 @@ void SystemInit(void)
/* Configure the system clock to 216 MHz */ /* Configure the system clock to 216 MHz */
SystemClock_Config(); 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 // There is a mismatch between the configured clock and the expected clock in portable.h
} }

View file

@ -336,6 +336,19 @@ uint8_t vcpAvailable()
return rxAvailable; 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 * @brief vcpWrite
* CDC received data to be send over USB IN endpoint are managed in * CDC received data to be send over USB IN endpoint are managed in

View file

@ -72,6 +72,7 @@ uint8_t vcpAvailable();
uint32_t vcpWrite(uint8_t* Buf, uint32_t Len); uint32_t vcpWrite(uint8_t* Buf, uint32_t Len);
uint32_t vcpBaudrate(); uint32_t vcpBaudrate();
uint8_t vcpIsConnected(); uint8_t vcpIsConnected();
uint32_t CDC_Send_FreeBytes(void);
/* Exported macro ------------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */ /* Exported functions ------------------------------------------------------- */