mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-07-01 10:17:53 +00:00
Replaced debug serial routines
This commit is contained in:
parent
110378e3b4
commit
a3c2628359
@ -333,7 +333,7 @@ enum FailSafeMode {
|
|||||||
|
|
||||||
//Status messages
|
//Status messages
|
||||||
#if defined(STM32_BOARD) && defined (SERIAL_DEBUG)
|
#if defined(STM32_BOARD) && defined (SERIAL_DEBUG)
|
||||||
#define debug(msg, ...) {char buf[64]; sprintf(buf, msg "\r\n", ##__VA_ARGS__); for(int i=0;buf[i] !=0; i++) StatusSerial_write(buf[i]);}
|
#define debug(msg, ...) {char buf[64]; sprintf(buf, msg "\r\n", ##__VA_ARGS__); Serial1.write(buf);}
|
||||||
#else
|
#else
|
||||||
#define debug(...)
|
#define debug(...)
|
||||||
#undef SERIAL_DEBUG
|
#undef SERIAL_DEBUG
|
||||||
|
@ -61,9 +61,6 @@
|
|||||||
void ISR_COMPB();
|
void ISR_COMPB();
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#ifdef SERIAL_DEBUG
|
|
||||||
void __irq_usart1(void);
|
|
||||||
#endif
|
|
||||||
void __irq_usart2(void);
|
void __irq_usart2(void);
|
||||||
void __irq_usart3(void);
|
void __irq_usart3(void);
|
||||||
}
|
}
|
||||||
@ -190,11 +187,6 @@ uint8_t pkt[MAX_PKT];//telemetry receiving packets
|
|||||||
volatile uint8_t tx_head=0;
|
volatile uint8_t tx_head=0;
|
||||||
volatile uint8_t tx_tail=0;
|
volatile uint8_t tx_tail=0;
|
||||||
#endif // BASH_SERIAL
|
#endif // BASH_SERIAL
|
||||||
#ifdef SERIAL_DEBUG
|
|
||||||
volatile uint8_t tx_debug_buff[TXBUFFER_SIZE];
|
|
||||||
volatile uint8_t tx_debug_head=0;
|
|
||||||
volatile uint8_t tx_debug_tail=0;
|
|
||||||
#endif // SERIAL_DEBUG
|
|
||||||
uint8_t v_lipo1;
|
uint8_t v_lipo1;
|
||||||
uint8_t v_lipo2;
|
uint8_t v_lipo2;
|
||||||
uint8_t RX_RSSI;
|
uint8_t RX_RSSI;
|
||||||
@ -215,8 +207,7 @@ void setup()
|
|||||||
{
|
{
|
||||||
// Setup diagnostic uart before anything else
|
// Setup diagnostic uart before anything else
|
||||||
#ifdef SERIAL_DEBUG
|
#ifdef SERIAL_DEBUG
|
||||||
usart1_begin(115200,SERIAL_8N1);
|
Serial1.begin(115200,SERIAL_8N1);
|
||||||
tx_debug_resume();
|
|
||||||
debug("Multiprotocol version: %d.%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_PATCH_LEVEL);
|
debug("Multiprotocol version: %d.%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_PATCH_LEVEL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -701,18 +692,6 @@ inline void tx_resume()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SERIAL_DEBUG
|
|
||||||
inline void tx_debug_resume()
|
|
||||||
{
|
|
||||||
USART1_BASE->CR1 |= USART_CR1_TXEIE;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void tx_debug_pause()
|
|
||||||
{
|
|
||||||
USART1_BASE->CR1 &= ~ USART_CR1_TXEIE;
|
|
||||||
}
|
|
||||||
#endif // SERIAL_DEBUG
|
|
||||||
|
|
||||||
#ifdef STM32_BOARD
|
#ifdef STM32_BOARD
|
||||||
void start_timer2()
|
void start_timer2()
|
||||||
{
|
{
|
||||||
|
@ -732,19 +732,6 @@ void TelemetryUpdate()
|
|||||||
/**************************/
|
/**************************/
|
||||||
/**************************/
|
/**************************/
|
||||||
|
|
||||||
#ifdef SERIAL_DEBUG
|
|
||||||
void StatusSerial_write(uint8_t data)
|
|
||||||
{
|
|
||||||
uint8_t nextHead ;
|
|
||||||
nextHead = tx_debug_head + 1 ;
|
|
||||||
if ( nextHead >= TXBUFFER_SIZE )
|
|
||||||
nextHead = 0 ;
|
|
||||||
tx_debug_buff[nextHead]=data;
|
|
||||||
tx_debug_head = nextHead ;
|
|
||||||
tx_debug_resume();
|
|
||||||
}
|
|
||||||
#endif // SERIAL_DEBUG
|
|
||||||
|
|
||||||
#ifndef BASH_SERIAL
|
#ifndef BASH_SERIAL
|
||||||
// Routines for normal serial output
|
// Routines for normal serial output
|
||||||
void Serial_write(uint8_t data)
|
void Serial_write(uint8_t data)
|
||||||
@ -864,29 +851,6 @@ void TelemetryUpdate()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef STM32_BOARD
|
#ifdef STM32_BOARD
|
||||||
#if defined(SERIAL_DEBUG)
|
|
||||||
void __irq_usart1()
|
|
||||||
{ // Transmit interrupt
|
|
||||||
if(USART1_BASE->SR & USART_SR_TXE)
|
|
||||||
{
|
|
||||||
if(tx_debug_head!=tx_debug_tail)
|
|
||||||
{
|
|
||||||
if(++tx_debug_tail>=TXBUFFER_SIZE) //head
|
|
||||||
tx_debug_tail=0;
|
|
||||||
USART1_BASE->DR=tx_debug_buff[tx_debug_tail]; //clears TXE bit
|
|
||||||
}
|
|
||||||
if (tx_debug_tail == tx_debug_head)
|
|
||||||
tx_debug_pause(); // Check if all data is transmitted . if yes disable transmitter UDRE interrupt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void usart1_begin(uint32_t baud,uint32_t config )
|
|
||||||
{
|
|
||||||
usart_init(USART1);
|
|
||||||
usart_config_gpios_async(USART1,GPIOA,PIN_MAP[PA10].gpio_bit,GPIOA,PIN_MAP[PA9].gpio_bit,config);
|
|
||||||
usart_set_baud_rate(USART1, STM32_PCLK1, baud);
|
|
||||||
usart_enable(USART1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
void usart2_begin(uint32_t baud,uint32_t config )
|
void usart2_begin(uint32_t baud,uint32_t config )
|
||||||
{
|
{
|
||||||
usart_init(USART2);
|
usart_init(USART2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user