Changed update_serial_data

This commit is contained in:
pascallanger 2016-08-29 17:32:21 +02:00
parent 2588011524
commit 03640e6d37

View File

@ -202,8 +202,7 @@ void setup()
// Read status of mode select binary switch
// after this mode_select will be one of {0000, 0001, ..., 1111}
#ifdef XMEGA
mode_select=0x0F - ( PORTA.IN & 0x0F ) ; //encoder dip switches 1,2,4,8=>B2,B3,B4,C0
mode_select = MODE_SERIAL ;
mode_select = MODE_SERIAL ; // only serial mode
#else
mode_select=0x0F - ( ( (PINB>>2)&0x07 ) | ( (PINC<<3)&0x08) );//encoder dip switches 1,2,4,8=>B2,B3,B4,C0
#endif
@ -384,7 +383,7 @@ static void CheckTimer(uint16_t (*cb)(void))
while((TCC1.INTFLAGS & TC1_CCAIF_bm) == 0); // wait 2ms...
#else
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
sei(); // enable global int
while((TIFR1 & (1<<OCF1A)) == 0); // wait 2ms...
@ -626,21 +625,6 @@ static void protocol_init()
void update_serial_data()
{
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;
if(rx_ok_buff[0]&0x20) //check range
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%
}
RX_DONOTUPDTAE_off;
}
while(IS_RX_MISSED_BUFF_on); // We've just processed an old frame...
#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_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()