Orange DSM module update

This commit is contained in:
pascallanger 2016-08-29 09:51:27 +02:00
parent 0c16a6804a
commit 2588011524
3 changed files with 28 additions and 14 deletions

View File

@ -17,7 +17,8 @@ static void module_reset(void) ;
static void update_led_status(void) ; static void update_led_status(void) ;
static void set_rx_tx_addr(uint32_t id) ; static void set_rx_tx_addr(uint32_t id) ;
uint16_t limit_channel_100(uint8_t ch) ; uint16_t limit_channel_100(uint8_t ch) ;
void initTXSerial( uint8_t speed);
void Serial_write(uint8_t data);
extern void NRF24L01_Reset(void ) ; extern void NRF24L01_Reset(void ) ;
extern void A7105_Reset(void ) ; extern void A7105_Reset(void ) ;

View File

@ -628,11 +628,19 @@ void update_serial_data()
RX_FLAG_off; //data has been processed RX_FLAG_off; //data has been processed
do do
{ {
cli(); #ifdef XMEGA
cli();
#else
UCSR0B &= ~(1<<RXCIE0); // RX interrupt disable
#endif
if(IS_RX_MISSED_BUFF_on) // If the buffer is still valid 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 memcpy((void*)rx_ok_buff,(const void*)rx_buff,RXBUFFER_SIZE);// Duplicate the buffer
sei();
RX_MISSED_BUFF_off; 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;
@ -787,6 +795,9 @@ void Mprotocol_serial_init()
USARTC0.CTRLA = (USARTC0.CTRLA & 0xCF) | 0x10 ; USARTC0.CTRLA = (USARTC0.CTRLA & 0xCF) | 0x10 ;
USARTC0.CTRLC = 0x2B ; USARTC0.CTRLC = 0x2B ;
USARTC0.DATA ; USARTC0.DATA ;
#ifdef INVERT_TELEMETRY
PORTC.PIN3CTRL |= 0x40 ;
#endif
#else #else
#include <util/setbaud.h> #include <util/setbaud.h>
UBRR0H = UBRRH_VALUE; UBRR0H = UBRRH_VALUE;
@ -898,6 +909,7 @@ uint8_t SPI_Read(void)
// replacement millis() and micros() // replacement millis() and micros()
// These work polled, no interrupts // These work polled, no interrupts
// micros() MUST be called at least once every 32 milliseconds // micros() MUST be called at least once every 32 milliseconds
#ifndef XMEGA
uint16_t MillisPrecount ; uint16_t MillisPrecount ;
uint16_t lastTimerValue ; uint16_t lastTimerValue ;
uint32_t TotalMicros ; uint32_t TotalMicros ;
@ -997,6 +1009,7 @@ void init()
// this needs to be called before setup() or some functions won't work there // this needs to be called before setup() or some functions won't work there
sei(); sei();
} }
#endif //XMEGA
/**************************/ /**************************/
/**************************/ /**************************/
@ -1053,7 +1066,7 @@ ISR(USART_RX_vect)
if((USARTC0.STATUS & 0x1C)==0) // Check frame error, data overrun and parity error if((USARTC0.STATUS & 0x1C)==0) // Check frame error, data overrun and parity error
#else #else
UCSR0B &= ~(1<<RXCIE0) ; //rx interrupt disable UCSR0B &= ~(1<<RXCIE0) ; // RX interrupt disable
sei() ; sei() ;
if((UCSR0A&0x1C)==0) // Check frame error, data overrun and parity error if((UCSR0A&0x1C)==0) // Check frame error, data overrun and parity error
@ -1118,7 +1131,7 @@ ISR(USART_RX_vect)
#ifndef XMEGA #ifndef XMEGA
cli() ; cli() ;
UCSR0B |= (1<<RXCIE0) ; // RX enable interrupt UCSR0B |= (1<<RXCIE0) ; // RX interrupt enable
#endif #endif
} }

View File

@ -497,16 +497,17 @@ void frskyUpdate()
// Routines for normal serial output // Routines for normal serial output
void Serial_write(uint8_t data) void Serial_write(uint8_t data)
{ {
cli(); // disable global int uint8_t nextHead ;
if(++tx_head>=TXBUFFER_SIZE) nextHead = tx_head + 1 ;
tx_head=0; if ( nextHead >= TXBUFFER_SIZE )
tx_buff[tx_head]=data; nextHead = 0 ;
tx_buff[nextHead]=data;
tx_head = nextHead ;
#ifdef XMEGA #ifdef XMEGA
USARTC0.CTRLA = (USARTC0.CTRLA & 0xFC) | 0x01 ; USARTC0.CTRLA = (USARTC0.CTRLA & 0xFC) | 0x01 ;
#else #else
UCSR0B |= (1<<UDRIE0);//enable UDRE interrupt UCSR0B |= (1<<UDRIE0);//enable UDRE interrupt
#endif #endif
sei(); // enable global int
} }
// Speed is 0 for 100K and 1 for 9600 // Speed is 0 for 100K and 1 for 9600
@ -521,6 +522,7 @@ void initTXSerial( uint8_t speed)
USARTC0.CTRLB = 0x18 ; USARTC0.CTRLB = 0x18 ;
USARTC0.CTRLA = (USARTC0.CTRLA & 0xCF) | 0x10 ; USARTC0.CTRLA = (USARTC0.CTRLA & 0xCF) | 0x10 ;
USARTC0.CTRLC = 0x03 ; USARTC0.CTRLC = 0x03 ;
}
#else #else
//9600 bauds //9600 bauds
UBRR0H = 0x00; UBRR0H = 0x00;
@ -528,11 +530,9 @@ void initTXSerial( uint8_t speed)
UCSR0A = 0 ; // Clear X2 bit UCSR0A = 0 ; // Clear X2 bit
//Set frame format to 8 data bits, none, 1 stop bit //Set frame format to 8 data bits, none, 1 stop bit
UCSR0C = (1<<UCSZ01)|(1<<UCSZ00); UCSR0C = (1<<UCSZ01)|(1<<UCSZ00);
UCSR0B = (1<<TXEN0);//tx enable
#endif
} }
else UCSR0B |= (1<<TXEN0);//tx enable
UCSR0B |= (1<<TXEN0);//tx enable #endif
} }
#ifdef XMEGA #ifdef XMEGA