mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 05:15:25 +03:00
Some more comments and a little formatting clean up
This commit is contained in:
parent
9c303d6669
commit
414e02d9fe
4 changed files with 70 additions and 57 deletions
|
@ -2483,8 +2483,9 @@ static void printConfig(char *cmdline, bool doDiff)
|
||||||
|
|
||||||
uint8_t currentRateIndex = currentProfile->activeRateProfile;
|
uint8_t currentRateIndex = currentProfile->activeRateProfile;
|
||||||
uint8_t rateCount;
|
uint8_t rateCount;
|
||||||
for (rateCount=0; rateCount<MAX_RATEPROFILES; rateCount++)
|
for (rateCount = 0; rateCount < MAX_RATEPROFILES; rateCount++) {
|
||||||
cliDumpRateProfile(rateCount, dumpMask, &defaultConfig);
|
cliDumpRateProfile(rateCount, dumpMask, &defaultConfig);
|
||||||
|
}
|
||||||
|
|
||||||
cliPrint("\r\n# restore original rateprofile selection\r\n");
|
cliPrint("\r\n# restore original rateprofile selection\r\n");
|
||||||
changeControlRateProfile(currentRateIndex);
|
changeControlRateProfile(currentRateIndex);
|
||||||
|
@ -2513,8 +2514,10 @@ static void printConfig(char *cmdline, bool doDiff)
|
||||||
|
|
||||||
static void cliDumpProfile(uint8_t profileIndex, uint8_t dumpMask, master_t *defaultConfig)
|
static void cliDumpProfile(uint8_t profileIndex, uint8_t dumpMask, master_t *defaultConfig)
|
||||||
{
|
{
|
||||||
if (profileIndex >= MAX_PROFILE_COUNT) // Faulty values
|
if (profileIndex >= MAX_PROFILE_COUNT) {
|
||||||
|
// Faulty values
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
changeProfile(profileIndex);
|
changeProfile(profileIndex);
|
||||||
cliPrint("\r\n# profile\r\n");
|
cliPrint("\r\n# profile\r\n");
|
||||||
cliProfile("");
|
cliProfile("");
|
||||||
|
@ -2523,8 +2526,10 @@ static void cliDumpProfile(uint8_t profileIndex, uint8_t dumpMask, master_t *def
|
||||||
|
|
||||||
static void cliDumpRateProfile(uint8_t rateProfileIndex, uint8_t dumpMask, master_t *defaultConfig)
|
static void cliDumpRateProfile(uint8_t rateProfileIndex, uint8_t dumpMask, master_t *defaultConfig)
|
||||||
{
|
{
|
||||||
if (rateProfileIndex >= MAX_RATEPROFILES) // Faulty values
|
if (rateProfileIndex >= MAX_RATEPROFILES) {
|
||||||
|
// Faulty values
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
changeControlRateProfile(rateProfileIndex);
|
changeControlRateProfile(rateProfileIndex);
|
||||||
cliPrint("\r\n# rateprofile\r\n");
|
cliPrint("\r\n# rateprofile\r\n");
|
||||||
cliRateProfile("");
|
cliRateProfile("");
|
||||||
|
@ -2744,8 +2749,9 @@ static void cliMap(char *cmdline)
|
||||||
|
|
||||||
if (len == 8) {
|
if (len == 8) {
|
||||||
// uppercase it
|
// uppercase it
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++) {
|
||||||
cmdline[i] = toupper((unsigned char)cmdline[i]);
|
cmdline[i] = toupper((unsigned char)cmdline[i]);
|
||||||
|
}
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
if (strchr(rcChannelLetters, cmdline[i]) && !strchr(cmdline + i + 1, cmdline[i]))
|
if (strchr(rcChannelLetters, cmdline[i]) && !strchr(cmdline + i + 1, cmdline[i]))
|
||||||
continue;
|
continue;
|
||||||
|
@ -2755,8 +2761,9 @@ static void cliMap(char *cmdline)
|
||||||
parseRcChannels(cmdline, &masterConfig.rxConfig);
|
parseRcChannels(cmdline, &masterConfig.rxConfig);
|
||||||
}
|
}
|
||||||
cliPrint("Map: ");
|
cliPrint("Map: ");
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++) {
|
||||||
out[masterConfig.rxConfig.rcmap[i]] = rcChannelLetters[i];
|
out[masterConfig.rxConfig.rcmap[i]] = rcChannelLetters[i];
|
||||||
|
}
|
||||||
out[i] = '\0';
|
out[i] = '\0';
|
||||||
cliPrintf("%s\r\n", out);
|
cliPrintf("%s\r\n", out);
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,7 +165,13 @@ uint32_t CDC_Send_DATA(uint8_t *ptrBuffer, uint8_t sendLength)
|
||||||
|
|
||||||
uint32_t CDC_Send_FreeBytes(void)
|
uint32_t CDC_Send_FreeBytes(void)
|
||||||
{
|
{
|
||||||
/* return the bytes free in the circular buffer */
|
/*
|
||||||
|
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 ((APP_Rx_ptr_out - APP_Rx_ptr_in) + (-((int)(APP_Rx_ptr_out <= APP_Rx_ptr_in)) & APP_RX_DATA_SIZE)) - 1;
|
return ((APP_Rx_ptr_out - APP_Rx_ptr_in) + (-((int)(APP_Rx_ptr_out <= APP_Rx_ptr_in)) & APP_RX_DATA_SIZE)) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,13 +189,13 @@ static uint16_t VCP_DataTx(uint8_t* Buf, uint32_t Len)
|
||||||
could just check for: USB_CDC_ZLP, but better to be safe
|
could just check for: USB_CDC_ZLP, but better to be safe
|
||||||
and wait for any existing transmission to complete.
|
and wait for any existing transmission to complete.
|
||||||
*/
|
*/
|
||||||
while (USB_Tx_State);
|
while (USB_Tx_State != 0);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < Len; i++) {
|
for (uint32_t i = 0; i < Len; i++) {
|
||||||
APP_Rx_Buffer[APP_Rx_ptr_in] = Buf[i];
|
APP_Rx_Buffer[APP_Rx_ptr_in] = Buf[i];
|
||||||
APP_Rx_ptr_in = (APP_Rx_ptr_in + 1) % APP_RX_DATA_SIZE;
|
APP_Rx_ptr_in = (APP_Rx_ptr_in + 1) % APP_RX_DATA_SIZE;
|
||||||
|
|
||||||
while (!CDC_Send_FreeBytes());
|
while (CDC_Send_FreeBytes() <= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return USBD_OK;
|
return USBD_OK;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue