mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-05 00:58:11 +00:00
Changed update_serial_data
This commit is contained in:
parent
2588011524
commit
03640e6d37
@ -202,8 +202,7 @@ void setup()
|
|||||||
// Read status of mode select binary switch
|
// Read status of mode select binary switch
|
||||||
// after this mode_select will be one of {0000, 0001, ..., 1111}
|
// after this mode_select will be one of {0000, 0001, ..., 1111}
|
||||||
#ifdef XMEGA
|
#ifdef XMEGA
|
||||||
mode_select=0x0F - ( PORTA.IN & 0x0F ) ; //encoder dip switches 1,2,4,8=>B2,B3,B4,C0
|
mode_select = MODE_SERIAL ; // only serial mode
|
||||||
mode_select = MODE_SERIAL ;
|
|
||||||
#else
|
#else
|
||||||
mode_select=0x0F - ( ( (PINB>>2)&0x07 ) | ( (PINC<<3)&0x08) );//encoder dip switches 1,2,4,8=>B2,B3,B4,C0
|
mode_select=0x0F - ( ( (PINB>>2)&0x07 ) | ( (PINC<<3)&0x08) );//encoder dip switches 1,2,4,8=>B2,B3,B4,C0
|
||||||
#endif
|
#endif
|
||||||
@ -384,7 +383,7 @@ static void CheckTimer(uint16_t (*cb)(void))
|
|||||||
while((TCC1.INTFLAGS & TC1_CCAIF_bm) == 0); // wait 2ms...
|
while((TCC1.INTFLAGS & TC1_CCAIF_bm) == 0); // wait 2ms...
|
||||||
#else
|
#else
|
||||||
cli(); // Disable global int due to RW of 16 bits registers
|
cli(); // Disable global int due to RW of 16 bits registers
|
||||||
OCR1A = OCR1A + 2000*2 ; // set compare A for callback
|
OCR1A += 2000*2 ; // set compare A for callback
|
||||||
TIFR1=(1<<OCF1A); // clear compare A=callback flag
|
TIFR1=(1<<OCF1A); // clear compare A=callback flag
|
||||||
sei(); // enable global int
|
sei(); // enable global int
|
||||||
while((TIFR1 & (1<<OCF1A)) == 0); // wait 2ms...
|
while((TIFR1 & (1<<OCF1A)) == 0); // wait 2ms...
|
||||||
@ -626,21 +625,6 @@ static void protocol_init()
|
|||||||
void update_serial_data()
|
void update_serial_data()
|
||||||
{
|
{
|
||||||
RX_FLAG_off; //data has been processed
|
RX_FLAG_off; //data has been processed
|
||||||
do
|
|
||||||
{
|
|
||||||
#ifdef XMEGA
|
|
||||||
cli();
|
|
||||||
#else
|
|
||||||
UCSR0B &= ~(1<<RXCIE0); // RX interrupt disable
|
|
||||||
#endif
|
|
||||||
if(IS_RX_MISSED_BUFF_on) // If the buffer is still valid
|
|
||||||
memcpy((void*)rx_ok_buff,(const void*)rx_buff,RXBUFFER_SIZE);// Duplicate the buffer
|
|
||||||
RX_MISSED_BUFF_off;
|
|
||||||
#ifdef XMEGA
|
|
||||||
sei();
|
|
||||||
#else
|
|
||||||
UCSR0B |= (1<<RXCIE0) ; // RX interrupt enable
|
|
||||||
#endif
|
|
||||||
RX_DONOTUPDTAE_on;
|
RX_DONOTUPDTAE_on;
|
||||||
if(rx_ok_buff[0]&0x20) //check range
|
if(rx_ok_buff[0]&0x20) //check range
|
||||||
RANGE_FLAG_on;
|
RANGE_FLAG_on;
|
||||||
@ -686,8 +670,20 @@ void update_serial_data()
|
|||||||
Servo_data[i]=((((*((uint32_t *)p))>>dec)&0x7FF)*5)/8+860; //value range 860<->2140 -125%<->+125%
|
Servo_data[i]=((((*((uint32_t *)p))>>dec)&0x7FF)*5)/8+860; //value range 860<->2140 -125%<->+125%
|
||||||
}
|
}
|
||||||
RX_DONOTUPDTAE_off;
|
RX_DONOTUPDTAE_off;
|
||||||
}
|
#ifdef XMEGA
|
||||||
while(IS_RX_MISSED_BUFF_on); // We've just processed an old frame...
|
cli();
|
||||||
|
#else
|
||||||
|
UCSR0B &= ~(1<<RXCIE0); // RX interrupt disable
|
||||||
|
#endif
|
||||||
|
if(IS_RX_MISSED_BUFF_on) // If the buffer is still valid
|
||||||
|
memcpy((void*)rx_ok_buff,(const void*)rx_buff,RXBUFFER_SIZE);// Duplicate the buffer
|
||||||
|
RX_FLAG_on; // data to be processed next time...
|
||||||
|
RX_MISSED_BUFF_off;
|
||||||
|
#ifdef XMEGA
|
||||||
|
sei();
|
||||||
|
#else
|
||||||
|
UCSR0B |= (1<<RXCIE0) ; // RX interrupt enable
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void module_reset()
|
void module_reset()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user