mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-09 23:28:12 +00:00
STM32: align STM32 code with other platforms for tx_pause/tx_resume
This commit is contained in:
parent
909fb2eb2b
commit
f56ca6318a
@ -11,6 +11,7 @@ if exist .dep (make clean)
|
|||||||
md .dep
|
md .dep
|
||||||
make
|
make
|
||||||
if exist MultiOrange.hex (
|
if exist MultiOrange.hex (
|
||||||
|
objcopy -I ihex MultiOrange.hex -O binary MultiOrange.bin
|
||||||
echo.
|
echo.
|
||||||
echo Compilation OK.
|
echo Compilation OK.
|
||||||
echo Use MultiOrange.hex to program your OrangeTX module.
|
echo Use MultiOrange.hex to program your OrangeTX module.
|
||||||
|
@ -523,13 +523,16 @@ static void update_led_status(void)
|
|||||||
|
|
||||||
inline void tx_pause()
|
inline void tx_pause()
|
||||||
{
|
{
|
||||||
#ifndef STM32_BOARD
|
#ifdef TELEMETRY
|
||||||
#ifdef TELEMETRY
|
// Pause telemetry by disabling transmitter interrupt
|
||||||
#ifdef ORANGE_TX
|
#ifdef ORANGE_TX
|
||||||
USARTC0.CTRLA &= ~0x03 ; // Pause telemetry by disabling transmitter interrupt
|
USARTC0.CTRLA &= ~0x03 ;
|
||||||
#else
|
#else
|
||||||
#ifndef BASH_SERIAL
|
#ifndef BASH_SERIAL
|
||||||
UCSR0B &= ~_BV(UDRIE0); // Pause telemetry by disabling transmitter interrupt
|
#ifdef STM32_BOARD
|
||||||
|
USART3_BASE->CR1 &= ~ USART_CR1_TXEIE;
|
||||||
|
#else
|
||||||
|
UCSR0B &= ~_BV(UDRIE0);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@ -538,23 +541,26 @@ inline void tx_pause()
|
|||||||
|
|
||||||
inline void tx_resume()
|
inline void tx_resume()
|
||||||
{
|
{
|
||||||
#ifndef STM32_BOARD
|
#ifdef TELEMETRY
|
||||||
#ifdef TELEMETRY
|
// Resume telemetry by enabling transmitter interrupt
|
||||||
if(!IS_TX_PAUSE_on)
|
if(!IS_TX_PAUSE_on)
|
||||||
{
|
{
|
||||||
#ifdef ORANGE_TX
|
#ifdef ORANGE_TX
|
||||||
cli() ;
|
cli() ;
|
||||||
USARTC0.CTRLA = (USARTC0.CTRLA & 0xFC) | 0x01 ; // Resume telemetry by enabling transmitter interrupt
|
USARTC0.CTRLA = (USARTC0.CTRLA & 0xFC) | 0x01 ;
|
||||||
sei() ;
|
sei() ;
|
||||||
#else
|
#else
|
||||||
#ifndef BASH_SERIAL
|
#ifndef BASH_SERIAL
|
||||||
UCSR0B |= _BV(UDRIE0); // Resume telemetry by enabling transmitter interrupt
|
#ifdef STM32_BOARD
|
||||||
|
USART3_BASE->CR1 |= USART_CR1_TXEIE;
|
||||||
#else
|
#else
|
||||||
resumeBashSerial() ;
|
UCSR0B |= _BV(UDRIE0);
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
resumeBashSerial();
|
||||||
#endif
|
#endif
|
||||||
}
|
#endif
|
||||||
#endif
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,6 +595,8 @@ static void protocol_init()
|
|||||||
tx_tail=0;
|
tx_tail=0;
|
||||||
tx_head=0;
|
tx_head=0;
|
||||||
#endif
|
#endif
|
||||||
|
TX_RX_PAUSE_off;
|
||||||
|
TX_MAIN_PAUSE_off;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
blink=millis();
|
blink=millis();
|
||||||
@ -958,7 +966,7 @@ void Mprotocol_serial_init()
|
|||||||
#if defined(TELEMETRY)
|
#if defined(TELEMETRY)
|
||||||
void PPM_Telemetry_serial_init()
|
void PPM_Telemetry_serial_init()
|
||||||
{
|
{
|
||||||
if( (protocol==MODE_FRSKYD) || (protocol==MODE_HUBSAN))
|
if( (protocol==MODE_FRSKYD) || (protocol==MODE_HUBSAN) || (protocol==MODE_AFHDS2A) )
|
||||||
initTXSerial( SPEED_9600 ) ;
|
initTXSerial( SPEED_9600 ) ;
|
||||||
if(protocol==MODE_FRSKYX)
|
if(protocol==MODE_FRSKYX)
|
||||||
initTXSerial( SPEED_57600 ) ;
|
initTXSerial( SPEED_57600 ) ;
|
||||||
@ -1095,14 +1103,14 @@ static uint32_t random_id(uint16_t adress, uint8_t create_new)
|
|||||||
rx_buff[0]=UDR0;
|
rx_buff[0]=UDR0;
|
||||||
if((rx_buff[0]&0xFE)==0x54) // If 1st byte is 0x54 or 0x55 it looks ok
|
if((rx_buff[0]&0xFE)==0x54) // If 1st byte is 0x54 or 0x55 it looks ok
|
||||||
{
|
{
|
||||||
|
TX_RX_PAUSE_on;
|
||||||
|
tx_pause();
|
||||||
#if defined STM32_BOARD
|
#if defined STM32_BOARD
|
||||||
uint16_t OCR1B;
|
uint16_t OCR1B;
|
||||||
OCR1B =TCNT1+(6500L);
|
OCR1B =TCNT1+(6500L);
|
||||||
timer.setCompare(TIMER_CH2,OCR1B);
|
timer.setCompare(TIMER_CH2,OCR1B);
|
||||||
timer.attachCompare2Interrupt(ISR_COMPB);
|
timer.attachCompare2Interrupt(ISR_COMPB);
|
||||||
#else
|
#else
|
||||||
TX_RX_PAUSE_on;
|
|
||||||
tx_pause();
|
|
||||||
OCR1B = TCNT1+(6500L) ; // Full message should be received within timer of 3250us
|
OCR1B = TCNT1+(6500L) ; // Full message should be received within timer of 3250us
|
||||||
TIFR1 = OCF1B_bm ; // clear OCR1B match flag
|
TIFR1 = OCF1B_bm ; // clear OCR1B match flag
|
||||||
SET_TIMSK1_OCIE1B ; // enable interrupt on compare B match
|
SET_TIMSK1_OCIE1B ; // enable interrupt on compare B match
|
||||||
@ -1137,9 +1145,9 @@ static uint32_t random_id(uint16_t adress, uint8_t create_new)
|
|||||||
detachInterrupt(2); // Disable interrupt on ch2
|
detachInterrupt(2); // Disable interrupt on ch2
|
||||||
#else
|
#else
|
||||||
CLR_TIMSK1_OCIE1B; // Disable interrupt on compare B match
|
CLR_TIMSK1_OCIE1B; // Disable interrupt on compare B match
|
||||||
TX_RX_PAUSE_off;
|
|
||||||
tx_resume();
|
|
||||||
#endif
|
#endif
|
||||||
|
TX_RX_PAUSE_off;
|
||||||
|
tx_resume();
|
||||||
}
|
}
|
||||||
#if not defined (ORANGE_TX) && not defined (STM32_BOARD)
|
#if not defined (ORANGE_TX) && not defined (STM32_BOARD)
|
||||||
cli() ;
|
cli() ;
|
||||||
@ -1161,8 +1169,8 @@ static uint32_t random_id(uint16_t adress, uint8_t create_new)
|
|||||||
detachInterrupt(2); // Disable interrupt on ch2
|
detachInterrupt(2); // Disable interrupt on ch2
|
||||||
#else
|
#else
|
||||||
CLR_TIMSK1_OCIE1B; // Disable interrupt on compare B match
|
CLR_TIMSK1_OCIE1B; // Disable interrupt on compare B match
|
||||||
tx_resume();
|
|
||||||
#endif
|
#endif
|
||||||
|
tx_resume();
|
||||||
}
|
}
|
||||||
#endif //ENABLE_SERIAL
|
#endif //ENABLE_SERIAL
|
||||||
|
|
||||||
|
@ -290,21 +290,6 @@
|
|||||||
#define cli() noInterrupts()
|
#define cli() noInterrupts()
|
||||||
#define sei() interrupts()
|
#define sei() interrupts()
|
||||||
#define delayMilliseconds(x) delay(x)
|
#define delayMilliseconds(x) delay(x)
|
||||||
//TX Pause
|
|
||||||
#undef TX_MAIN_PAUSE_off
|
|
||||||
#undef TX_MAIN_PAUSE_on
|
|
||||||
#undef IS_TX_MAIN_PAUSE_on
|
|
||||||
#undef TX_RX_PAUSE_off
|
|
||||||
#undef TX_RX_PAUSE_on
|
|
||||||
#undef IS_TX_RX_PAUSE_on
|
|
||||||
#undef IS_TX_PAUSE_on
|
|
||||||
#define TX_MAIN_PAUSE_off
|
|
||||||
#define TX_MAIN_PAUSE_on
|
|
||||||
#define IS_TX_MAIN_PAUSE_on
|
|
||||||
#define TX_RX_PAUSE_off
|
|
||||||
#define TX_RX_PAUSE_on
|
|
||||||
#define IS_TX_RX_PAUSE_on
|
|
||||||
#define IS_TX_PAUSE_on
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//*******************
|
//*******************
|
||||||
|
@ -620,12 +620,10 @@ void TelemetryUpdate()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (tx_tail == tx_head)
|
if (tx_tail == tx_head)
|
||||||
#ifdef STM32_BOARD
|
|
||||||
USART3_BASE->CR1 &= ~USART_CR1_TXEIE;//disable interrupt
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
tx_pause(); // Check if all data is transmitted . if yes disable transmitter UDRE interrupt
|
tx_pause(); // Check if all data is transmitted . if yes disable transmitter UDRE interrupt
|
||||||
#endif
|
#ifdef STM32_BOARD
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#else //BASH_SERIAL
|
#else //BASH_SERIAL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user