Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

Other Technologies General Forum Discussions

Not applicable
Hallo,

der Code von Infineon der den Satelliten ausliest ist sehr Statisch ...

ich habe die Funktion RemoteControl_RX_ISR im Ordner "_Quad .../RCReceive" etwas adaptiert:
void RemoteControl_RX_ISR(){
int throttleRaw;
int rudderRaw;
int elevatorRaw;
int aileronRaw;
int AUX1Raw;
int AUX2Raw;
int start = 0; //Index of start byte (contains 0x30)
int i = 0; //Index of start byte (contains 0x30)
int j; // For index
uint8_t ReadBufRC[32]; //Readbuffer
uint8_t channels[32];
int values[6];
uint8_t WriteBufRC[32];

for(j = 0; j < 32; j++){
channels = 254;
}

//Read data from UART buffer
UART_ReadDataBytes(&RemoteControl_Handle, ReadBufRC, 32);



//Search for start byte
while (ReadBufRC[start] != 0x00 && ReadBufRC[start + 1] != 0xa2) //0x12 oder 0xa2 oder 0xb2 je nach verwendeter Funke!
{
start++;
if (start > 16)
{
//Communication check bytes not in buffer
return;
}
}

//search for channel ID
i = start + 2;
while(i < 32){
if(ReadBufRC != 0x00 && ReadBufRC != 0xa2){ //0x12 oder 0xa2 oder 0xb2 je nach verwendeter Funke!
channels = ((ReadBufRC & 0x78) >> 3);
}
i = i + 2;
}

//write RAW values to Array
for(j = 0; j < 32; j++){
if (channels != 254){
values[channels] = mergeBytes(ReadBufRC, ReadBufRC[j + 1]) & 0x07FF;
}
}



//remap raw values to control values */
PWMDuty = (uint32_t) map(values[0], 340, 1955, 0, 10000);



PWM_CCU4_SetDutyCycle(&LED_PWM, PWMDuty);

g_joystick_values.throttle = map(values[0], 0, 2048, 903, 2097);
g_joystick_values.aileron = map(values[1], 0, 2048, 903, 2097);
g_joystick_values.elevator = map(values[2], 0, 2048, 903, 2097);
g_joystick_values.rudder = map(values[3], 0, 2048, 903, 2097);
g_joystick_values.AUX1 = map(values[4], 0, 2048, 903, 2097);
g_joystick_values.AUX2 = map(values[5], 0, 2048, 903, 2097);
//Set values for RC Timeout check
RCTimeOut = 0;
connected = 1;
RCCount++;
}
0 Likes
1 Reply
Not applicable
Kannst du das auf GitHub als Pull-Request einreichen?
0 Likes