mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-04 18:38:13 +00:00
Corona bind timing
This commit is contained in:
parent
5cc49a8862
commit
11287cb9c0
@ -104,6 +104,12 @@ static void __attribute__((unused)) CORONA_init()
|
|||||||
// 8 Channels with direct values from PPM
|
// 8 Channels with direct values from PPM
|
||||||
static void __attribute__((unused)) CORONA_send_packet()
|
static void __attribute__((unused)) CORONA_send_packet()
|
||||||
{
|
{
|
||||||
|
// Tune frequency if it has been changed
|
||||||
|
if ( prev_option != option )
|
||||||
|
{
|
||||||
|
CC2500_WriteReg(CC2500_0C_FSCTRL0, option);
|
||||||
|
prev_option = option ;
|
||||||
|
}
|
||||||
if(IS_BIND_DONE)
|
if(IS_BIND_DONE)
|
||||||
{
|
{
|
||||||
if(state==0 || sub_protocol==COR_V1)
|
if(state==0 || sub_protocol==COR_V1)
|
||||||
@ -124,12 +130,6 @@ static void __attribute__((unused)) CORONA_send_packet()
|
|||||||
|
|
||||||
packet[17] = 0x00;
|
packet[17] = 0x00;
|
||||||
|
|
||||||
// Tune frequency if it has been changed
|
|
||||||
if ( prev_option != option )
|
|
||||||
{
|
|
||||||
CC2500_WriteReg(CC2500_0C_FSCTRL0, option);
|
|
||||||
prev_option = option ;
|
|
||||||
}
|
|
||||||
// Packet period is based on hopping
|
// Packet period is based on hopping
|
||||||
switch(hopping_frequency_no)
|
switch(hopping_frequency_no)
|
||||||
{
|
{
|
||||||
@ -217,7 +217,7 @@ uint16_t ReadCORONA()
|
|||||||
uint16_t initCORONA()
|
uint16_t initCORONA()
|
||||||
{
|
{
|
||||||
if(sub_protocol==COR_V1)
|
if(sub_protocol==COR_V1)
|
||||||
bind_counter=700; // Stay in bind mode for 5s
|
bind_counter=1400; // Stay in bind mode for 5s
|
||||||
else
|
else
|
||||||
bind_counter=187; // Stay in bind mode for 5s
|
bind_counter=187; // Stay in bind mode for 5s
|
||||||
state=400; // Used by V2 to send RF channels + ID for 2.65s at startup
|
state=400; // Used by V2 to send RF channels + ID for 2.65s at startup
|
||||||
|
@ -137,8 +137,11 @@ const uint8_t CH_EATR[]={ELEVATOR, AILERON, THROTTLE, RUDDER, AUX1, AUX2, AUX3,
|
|||||||
uint8_t mode_select;
|
uint8_t mode_select;
|
||||||
uint8_t protocol_flags=0,protocol_flags2=0;
|
uint8_t protocol_flags=0,protocol_flags2=0;
|
||||||
|
|
||||||
|
#ifdef ENABLE_PPM
|
||||||
// PPM variable
|
// PPM variable
|
||||||
volatile uint16_t PPM_data[NUM_CHN];
|
volatile uint16_t PPM_data[NUM_CHN];
|
||||||
|
volatile uint8_t PPM_chan_max=0;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if not defined (ORANGE_TX) && not defined (STM32_BOARD)
|
#if not defined (ORANGE_TX) && not defined (STM32_BOARD)
|
||||||
//Random variable
|
//Random variable
|
||||||
@ -363,12 +366,17 @@ void setup()
|
|||||||
|
|
||||||
// Set default channels' value
|
// Set default channels' value
|
||||||
for(uint8_t i=0;i<NUM_CHN;i++)
|
for(uint8_t i=0;i<NUM_CHN;i++)
|
||||||
|
{
|
||||||
Servo_data[i]=1500;
|
Servo_data[i]=1500;
|
||||||
|
#ifdef ENABLE_PPM
|
||||||
|
PPM_data[i]=PPM_MAX_100+PPM_MIN_100;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
Servo_data[THROTTLE]=servo_min_100;
|
Servo_data[THROTTLE]=servo_min_100;
|
||||||
InitChannel();
|
|
||||||
#ifdef ENABLE_PPM
|
#ifdef ENABLE_PPM
|
||||||
memcpy((void *)PPM_data,Servo_data, sizeof(Servo_data));
|
PPM_data[THROTTLE]=PPM_MIN_100*2;
|
||||||
#endif
|
#endif
|
||||||
|
InitChannel();
|
||||||
|
|
||||||
// Update LED
|
// Update LED
|
||||||
LED_off;
|
LED_off;
|
||||||
@ -584,14 +592,22 @@ uint8_t Update_All()
|
|||||||
#ifdef ENABLE_PPM
|
#ifdef ENABLE_PPM
|
||||||
if(mode_select!=MODE_SERIAL && IS_PPM_FLAG_on) // PPM mode and a full frame has been received
|
if(mode_select!=MODE_SERIAL && IS_PPM_FLAG_on) // PPM mode and a full frame has been received
|
||||||
{
|
{
|
||||||
for(uint8_t i=0;i<MAX_PPM_CHANNELS;i++)
|
for(uint8_t i=0;i<PPM_chan_max;i++)
|
||||||
{ // update servo data without interrupts to prevent bad read in protocols
|
{ // update servo data without interrupts to prevent bad read
|
||||||
uint16_t temp_ppm ;
|
uint16_t temp_ppm ;
|
||||||
cli(); // disable global int
|
cli(); // disable global int
|
||||||
temp_ppm = PPM_data[i] ;
|
temp_ppm = PPM_data[i];
|
||||||
sei(); // enable global int
|
sei(); // enable global int
|
||||||
if(temp_ppm<PPM_MIN_125) temp_ppm=PPM_MIN_125;
|
|
||||||
else if(temp_ppm>PPM_MAX_125) temp_ppm=PPM_MAX_125;
|
uint16_t temp_ppm2;
|
||||||
|
temp_ppm2=map(temp_ppm,PPM_MIN_100,PPM_MAX_100,CHANNEL_MIN_100,CHANNEL_MAX_100);
|
||||||
|
if(temp_ppm2&0x8000) temp_ppm2=CHANNEL_MIN_125;
|
||||||
|
else if(temp_ppm2>CHANNEL_MAX_125) temp_ppm2=CHANNEL_MAX_125;
|
||||||
|
Channel_data[i]=temp_ppm2;
|
||||||
|
|
||||||
|
temp_ppm>>=1;
|
||||||
|
if(temp_ppm<PPM_MIN_125) temp_ppm=PPM_MIN_125;
|
||||||
|
else if(temp_ppm>PPM_MAX_125) temp_ppm=PPM_MAX_125;
|
||||||
Servo_data[i]= temp_ppm ;
|
Servo_data[i]= temp_ppm ;
|
||||||
}
|
}
|
||||||
PPM_FLAG_off; // wait for next frame before update
|
PPM_FLAG_off; // wait for next frame before update
|
||||||
@ -1525,20 +1541,23 @@ static uint32_t random_id(uint16_t address, uint8_t create_new)
|
|||||||
uint16_t Cur_TCNT1;
|
uint16_t Cur_TCNT1;
|
||||||
|
|
||||||
Cur_TCNT1 = TCNT1 - Prev_TCNT1 ; // Capture current Timer1 value
|
Cur_TCNT1 = TCNT1 - Prev_TCNT1 ; // Capture current Timer1 value
|
||||||
if(Cur_TCNT1<1000)
|
if(Cur_TCNT1<1600)
|
||||||
bad_frame=1; // bad frame
|
bad_frame=1; // bad frame
|
||||||
else
|
else
|
||||||
if(Cur_TCNT1>4840)
|
if(Cur_TCNT1>4400)
|
||||||
{ //start of frame
|
{ //start of frame
|
||||||
if(chan>=MIN_PPM_CHANNELS)
|
if(chan>=MIN_PPM_CHANNELS)
|
||||||
|
{
|
||||||
PPM_FLAG_on; // good frame received if at least 4 channels have been seen
|
PPM_FLAG_on; // good frame received if at least 4 channels have been seen
|
||||||
|
if(chan>PPM_chan_max) PPM_chan_max=chan; // Saving the number of channels received
|
||||||
|
}
|
||||||
chan=0; // reset channel counter
|
chan=0; // reset channel counter
|
||||||
bad_frame=0;
|
bad_frame=0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if(bad_frame==0) // need to wait for start of frame
|
if(bad_frame==0) // need to wait for start of frame
|
||||||
{ //servo values between 500us and 2420us will end up here
|
{ //servo values between 800us and 2200us will end up here
|
||||||
PPM_data[chan]= Cur_TCNT1>>1;;
|
PPM_data[chan]=Cur_TCNT1;
|
||||||
if(chan++>=MAX_PPM_CHANNELS)
|
if(chan++>=MAX_PPM_CHANNELS)
|
||||||
bad_frame=1; // don't accept any new channels
|
bad_frame=1; // don't accept any new channels
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user