1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

Whitespace tidy

This commit is contained in:
Martin Budden 2017-07-05 06:36:22 +01:00
parent ee8763bbf1
commit 3d4f0bb137
97 changed files with 555 additions and 555 deletions

View file

@ -126,11 +126,11 @@ static void TIM_DeInit(TIM_TypeDef *tim)
void setTxSignalEsc(escSerial_t *escSerial, uint8_t state)
{
if(escSerial->mode == PROTOCOL_KISSALL)
if (escSerial->mode == PROTOCOL_KISSALL)
{
for (volatile uint8_t i = 0; i < escSerial->outputCount; i++) {
uint8_t state_temp = state;
if(escOutputs[i].inverted) {
if (escOutputs[i].inverted) {
state_temp ^= ENABLE;
}
@ -143,7 +143,7 @@ void setTxSignalEsc(escSerial_t *escSerial, uint8_t state)
}
else
{
if(escSerial->rxTimerHardware->output & TIMER_OUTPUT_INVERTED) {
if (escSerial->rxTimerHardware->output & TIMER_OUTPUT_INVERTED) {
state ^= ENABLE;
}
@ -262,7 +262,7 @@ serialPort_t *openEscSerial(escSerialPortIndex_e portIndex, serialReceiveCallbac
{
escSerial_t *escSerial = &(escSerialPorts[portIndex]);
if(mode != PROTOCOL_KISSALL){
if (mode != PROTOCOL_KISSALL) {
escSerial->rxTimerHardware = &(timerHardware[output]);
#ifdef USE_HAL_DRIVER
escSerial->rxTimerHandle = timerFindTimerHandle(escSerial->rxTimerHardware->tim);
@ -295,7 +295,7 @@ serialPort_t *openEscSerial(escSerialPortIndex_e portIndex, serialReceiveCallbac
escSerial->escSerialPortIndex = portIndex;
if(mode != PROTOCOL_KISSALL)
if (mode != PROTOCOL_KISSALL)
{
escSerial->txIO = IOGetByTag(escSerial->rxTimerHardware->tag);
escSerialInputPortConfig(escSerial->rxTimerHardware);
@ -303,19 +303,19 @@ serialPort_t *openEscSerial(escSerialPortIndex_e portIndex, serialReceiveCallbac
}
delay(50);
if(mode==PROTOCOL_SIMONK){
if (mode==PROTOCOL_SIMONK) {
escSerialTimerTxConfig(escSerial->txTimerHardware, portIndex);
escSerialTimerRxConfig(escSerial->rxTimerHardware, portIndex);
}
else if(mode==PROTOCOL_BLHELI){
else if (mode==PROTOCOL_BLHELI) {
serialTimerTxConfigBL(escSerial->txTimerHardware, portIndex, baud);
serialTimerRxConfigBL(escSerial->rxTimerHardware, portIndex, options);
}
else if(mode==PROTOCOL_KISS) {
else if (mode==PROTOCOL_KISS) {
escSerialOutputPortConfig(escSerial->rxTimerHardware); // rx is the pin used
serialTimerTxConfigBL(escSerial->txTimerHardware, portIndex, baud);
}
else if(mode==PROTOCOL_KISSALL) {
else if (mode==PROTOCOL_KISSALL) {
escSerial->outputCount = 0;
memset(&escOutputs, 0, sizeof(escOutputs));
pwmOutputPort_t *pwmMotors = pwmGetMotors();
@ -323,10 +323,10 @@ serialPort_t *openEscSerial(escSerialPortIndex_e portIndex, serialReceiveCallbac
if (pwmMotors[i].enabled) {
if (pwmMotors[i].io != IO_NONE) {
for (volatile uint8_t j = 0; j < USABLE_TIMER_CHANNEL_COUNT; j++) {
if(pwmMotors[i].io == IOGetByTag(timerHardware[j].tag))
if (pwmMotors[i].io == IOGetByTag(timerHardware[j].tag))
{
escSerialOutputPortConfig(&timerHardware[j]);
if(timerHardware[j].output & TIMER_OUTPUT_INVERTED) {
if (timerHardware[j].output & TIMER_OUTPUT_INVERTED) {
escOutputs[escSerial->outputCount].inverted = 1;
}
break;
@ -340,7 +340,7 @@ serialPort_t *openEscSerial(escSerialPortIndex_e portIndex, serialReceiveCallbac
setTxSignalEsc(escSerial, ENABLE);
serialTimerTxConfigBL(escSerial->txTimerHardware, portIndex, baud);
}
else if(mode == PROTOCOL_CASTLE){
else if (mode == PROTOCOL_CASTLE){
escSerialOutputPortConfig(escSerial->rxTimerHardware);
serialTimerTxConfigBL(escSerial->txTimerHardware, portIndex, baud);
serialTimerRxConfigBL(escSerial->rxTimerHardware, portIndex, options);
@ -361,7 +361,7 @@ void closeEscSerial(escSerialPortIndex_e portIndex, uint8_t mode)
{
escSerial_t *escSerial = &(escSerialPorts[portIndex]);
if(mode != PROTOCOL_KISSALL){
if (mode != PROTOCOL_KISSALL) {
escSerialInputPortDeConfig(escSerial->rxTimerHardware);
timerChConfigCallbacks(escSerial->rxTimerHardware,NULL,NULL);
TIM_DeInit(escSerial->rxTimerHardware->tim);
@ -381,7 +381,7 @@ void processTxStateEsc(escSerial_t *escSerial)
return;
}
if(transmitStart==0)
if (transmitStart==0)
{
setTxSignalEsc(escSerial, 1);
}
@ -394,13 +394,13 @@ reload:
return;
}
if(transmitStart<3)
if (transmitStart<3)
{
if(transmitStart==0)
if (transmitStart==0)
byteToSend = 0xff;
if(transmitStart==1)
if (transmitStart==1)
byteToSend = 0xff;
if(transmitStart==2)
if (transmitStart==2)
byteToSend = 0x7f;
transmitStart++;
}
@ -425,35 +425,35 @@ reload:
if (escSerial->bitsLeftToTransmit) {
mask = escSerial->internalTxBuffer & 1;
if(mask)
if (mask)
{
if(bitq==0 || bitq==1)
if (bitq==0 || bitq==1)
{
setTxSignalEsc(escSerial, 1);
}
if(bitq==2 || bitq==3)
if (bitq==2 || bitq==3)
{
setTxSignalEsc(escSerial, 0);
}
}
else
{
if(bitq==0 || bitq==2)
if (bitq==0 || bitq==2)
{
setTxSignalEsc(escSerial, 1);
}
if(bitq==1 ||bitq==3)
if (bitq==1 ||bitq==3)
{
setTxSignalEsc(escSerial, 0);
}
}
bitq++;
if(bitq>3)
if (bitq>3)
{
escSerial->internalTxBuffer >>= 1;
escSerial->bitsLeftToTransmit--;
bitq=0;
if(escSerial->bitsLeftToTransmit==0)
if (escSerial->bitsLeftToTransmit==0)
{
goto reload;
}
@ -497,7 +497,7 @@ void processTxStateBL(escSerial_t *escSerial)
//set output
if(escSerial->mode==PROTOCOL_BLHELI || escSerial->mode==PROTOCOL_CASTLE) {
if (escSerial->mode==PROTOCOL_BLHELI || escSerial->mode==PROTOCOL_CASTLE) {
escSerialOutputPortConfig(escSerial->rxTimerHardware);
}
return;
@ -514,7 +514,7 @@ void processTxStateBL(escSerial_t *escSerial)
escSerial->isTransmittingData = false;
if (isEscSerialTransmitBufferEmpty((serialPort_t *)escSerial)) {
if(escSerial->mode==PROTOCOL_BLHELI || escSerial->mode==PROTOCOL_CASTLE)
if (escSerial->mode==PROTOCOL_BLHELI || escSerial->mode==PROTOCOL_CASTLE)
{
escSerialInputPortConfig(escSerial->rxTimerHardware);
}
@ -683,10 +683,10 @@ void onSerialTimerEsc(timerCCHandlerRec_t *cbRec, captureCompare_t capture)
UNUSED(capture);
escSerial_t *escSerial = container_of(cbRec, escSerial_t, timerCb);
if(escSerial->isReceivingData)
if (escSerial->isReceivingData)
{
escSerial->receiveTimeout++;
if(escSerial->receiveTimeout>8)
if (escSerial->receiveTimeout>8)
{
escSerial->isReceivingData=0;
escSerial->receiveTimeout=0;
@ -714,17 +714,17 @@ void onSerialRxPinChangeEsc(timerCCHandlerRec_t *cbRec, captureCompare_t capture
TIM_SetCounter(escSerial->rxTimerHardware->tim,0);
#endif
if(capture > 40 && capture < 90)
if (capture > 40 && capture < 90)
{
zerofirst++;
if(zerofirst>1)
if (zerofirst>1)
{
zerofirst=0;
escSerial->internalRxBuffer = escSerial->internalRxBuffer>>1;
bits++;
}
}
else if(capture>90 && capture < 200)
else if (capture>90 && capture < 200)
{
zerofirst=0;
escSerial->internalRxBuffer = escSerial->internalRxBuffer>>1;
@ -733,7 +733,7 @@ void onSerialRxPinChangeEsc(timerCCHandlerRec_t *cbRec, captureCompare_t capture
}
else
{
if(!escSerial->isReceivingData)
if (!escSerial->isReceivingData)
{
//start
//lets reset
@ -749,11 +749,11 @@ void onSerialRxPinChangeEsc(timerCCHandlerRec_t *cbRec, captureCompare_t capture
}
escSerial->receiveTimeout = 0;
if(bits==8)
if (bits==8)
{
bits=0;
bytes++;
if(bytes>3)
if (bytes>3)
{
extractAndStoreRxByteEsc(escSerial);
}
@ -852,7 +852,7 @@ void escSerialInitialize()
for (volatile uint8_t i = 0; i < USABLE_TIMER_CHANNEL_COUNT; i++) {
// set outputs to pullup
if(timerHardware[i].output & TIMER_OUTPUT_ENABLED)
if (timerHardware[i].output & TIMER_OUTPUT_ENABLED)
{
escSerialGPIOConfig(&timerHardware[i], IOCFG_IPU); //GPIO_Mode_IPU
}
@ -916,7 +916,7 @@ static bool ProcessExitCommand(uint8_t c)
if (currentPort.checksum == c) {
currentPort.c_state = COMMAND_RECEIVED;
if((currentPort.cmdMSP == 0xF4) && (currentPort.dataSize==0))
if ((currentPort.cmdMSP == 0xF4) && (currentPort.dataSize==0))
{
currentPort.c_state = IDLE;
return true;
@ -953,14 +953,14 @@ void escEnablePassthrough(serialPort_t *escPassthroughPort, uint16_t output, uin
break;
}
if((mode == PROTOCOL_KISS) && (output == 255)){
if ((mode == PROTOCOL_KISS) && (output == 255)) {
motor_output = 255;
mode = PROTOCOL_KISSALL;
}
else {
uint8_t first_output = 0;
for (volatile uint8_t i = 0; i < USABLE_TIMER_CHANNEL_COUNT; i++) {
if(timerHardware[i].output & TIMER_OUTPUT_ENABLED)
if (timerHardware[i].output & TIMER_OUTPUT_ENABLED)
{
first_output=i;
break;
@ -969,18 +969,18 @@ void escEnablePassthrough(serialPort_t *escPassthroughPort, uint16_t output, uin
//doesn't work with messy timertable
motor_output=first_output+output-1;
if(motor_output >=USABLE_TIMER_CHANNEL_COUNT)
if (motor_output >=USABLE_TIMER_CHANNEL_COUNT)
return;
}
escPort = openEscSerial(ESCSERIAL1, NULL, motor_output, escBaudrate, 0, mode);
uint8_t ch;
while(1) {
if(mode!=2)
while (1) {
if (mode!=2)
{
if (serialRxBytesWaiting(escPort)) {
LED0_ON;
while(serialRxBytesWaiting(escPort))
while (serialRxBytesWaiting(escPort))
{
ch = serialRead(escPort);
serialWrite(escPassthroughPort, ch);
@ -990,11 +990,11 @@ void escEnablePassthrough(serialPort_t *escPassthroughPort, uint16_t output, uin
}
if (serialRxBytesWaiting(escPassthroughPort)) {
LED1_ON;
while(serialRxBytesWaiting(escPassthroughPort))
while (serialRxBytesWaiting(escPassthroughPort))
{
ch = serialRead(escPassthroughPort);
exitEsc = ProcessExitCommand(ch);
if(exitEsc)
if (exitEsc)
{
serialWrite(escPassthroughPort, 0x24);
serialWrite(escPassthroughPort, 0x4D);
@ -1005,14 +1005,14 @@ void escEnablePassthrough(serialPort_t *escPassthroughPort, uint16_t output, uin
closeEscSerial(ESCSERIAL1, mode);
return;
}
if(mode==PROTOCOL_BLHELI){
if (mode==PROTOCOL_BLHELI) {
serialWrite(escPassthroughPort, ch); // blheli loopback
}
serialWrite(escPort, ch);
}
LED1_OFF;
}
if(mode != PROTOCOL_CASTLE){
if (mode != PROTOCOL_CASTLE) {
delay(5);
}
}