mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 09:45:21 +03:00
Add debug read, Add PXX preamble, Add Taranis no_pulses drivers
This commit is contained in:
parent
ea1a07dbfa
commit
53cbfd5d8f
4 changed files with 260 additions and 1 deletions
137
src/debug.cpp
137
src/debug.cpp
|
@ -74,13 +74,147 @@ void dump(unsigned char *data, unsigned int size)
|
|||
debugPuts("\n\r");
|
||||
}
|
||||
|
||||
uint32_t Mem_address ;
|
||||
uint32_t Next_mem_address ;
|
||||
uint32_t Memaddmode ;
|
||||
|
||||
void txmit( uint8_t chr )
|
||||
{
|
||||
debugTxFifo.push( chr) ;
|
||||
}
|
||||
|
||||
void crlf()
|
||||
{
|
||||
txmit( 13 ) ;
|
||||
txmit( 10 ) ;
|
||||
}
|
||||
|
||||
// Send a single 4 bit value to the RS232 port as a hex digit
|
||||
void hex_digit_send( unsigned char c )
|
||||
{
|
||||
c &= 0x0F ;
|
||||
if ( c > 9 )
|
||||
{
|
||||
c += 7 ;
|
||||
}
|
||||
c += '0' ;
|
||||
txmit( c ) ;
|
||||
}
|
||||
|
||||
// Send the 8 bit value to the RS232 port as 2 hex digits
|
||||
void p2hex( unsigned char c )
|
||||
{
|
||||
// asm("swap %c") ;
|
||||
hex_digit_send( c >> 4 ) ;
|
||||
// asm("swap %c") ;
|
||||
hex_digit_send( c ) ;
|
||||
}
|
||||
|
||||
// Send the 16 bit value to the RS232 port as 4 hex digits
|
||||
void p4hex( uint16_t value )
|
||||
{
|
||||
p2hex( value >> 8 ) ;
|
||||
p2hex( value ) ;
|
||||
}
|
||||
|
||||
// Send the 32 bit value to the RS232 port as 8 hex digits
|
||||
void p8hex( uint32_t value )
|
||||
{
|
||||
p4hex( value >> 16 ) ;
|
||||
p4hex( value ) ;
|
||||
}
|
||||
|
||||
|
||||
static void dispw_256( register uint32_t address, register uint32_t lines )
|
||||
{
|
||||
register uint32_t i ;
|
||||
register uint32_t j ;
|
||||
address &= 0xFFFFFFFC ;
|
||||
for ( i = 0 ; i < lines ; i += 1 )
|
||||
{
|
||||
p8hex( address ) ;
|
||||
for ( j = 0 ; j < 4 ; j += 1 )
|
||||
{
|
||||
txmit(' ') ;
|
||||
p8hex( *( (uint32_t *)address ) ) ;
|
||||
address += 4 ;
|
||||
}
|
||||
crlf() ;
|
||||
}
|
||||
}
|
||||
|
||||
void debugTask(void* pdata)
|
||||
{
|
||||
uint8_t rxchar ;
|
||||
crlf() ;
|
||||
dispw_256( (uint32_t)USART3, 4 ) ;
|
||||
|
||||
for (;;) {
|
||||
while (!debugRxFifo.pop(rxchar))
|
||||
|
||||
|
||||
while ( (USART3->SR & USART_SR_RXNE) == 0 )
|
||||
CoTickDelay(5); // 10ms
|
||||
|
||||
rxchar = USART3->DR ;
|
||||
|
||||
if ( Memaddmode )
|
||||
{
|
||||
if ( ( rxchar >= 'a' ) && ( rxchar <= 'f' ) )
|
||||
{
|
||||
rxchar -= 0x20 ; // toupper!
|
||||
}
|
||||
if ( ( ( rxchar >= '0' ) && ( rxchar <= '9' ) ) || ( ( rxchar >= 'A' ) && ( rxchar <= 'F' ) ) )
|
||||
{
|
||||
txmit( rxchar ) ;
|
||||
rxchar -= '0' ;
|
||||
if ( rxchar > 9 )
|
||||
{
|
||||
rxchar -= 7 ;
|
||||
}
|
||||
Mem_address <<= 4 ;
|
||||
Mem_address |= rxchar ;
|
||||
}
|
||||
else if ( rxchar == 13 )
|
||||
{
|
||||
crlf() ;
|
||||
if ( Mem_address == 0 )
|
||||
{
|
||||
Mem_address = Next_mem_address ;
|
||||
}
|
||||
dispw_256( Mem_address, 4 ) ;
|
||||
Next_mem_address = Mem_address + 64 ;
|
||||
Memaddmode = 0 ;
|
||||
}
|
||||
else if ( rxchar == 8 )
|
||||
{
|
||||
txmit( rxchar ) ;
|
||||
txmit( rxchar ) ;
|
||||
txmit( rxchar ) ;
|
||||
Mem_address >>= 4 ;
|
||||
}
|
||||
else if ( rxchar == 27 )
|
||||
{
|
||||
crlf() ;
|
||||
Memaddmode = 0 ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( rxchar == '?' )
|
||||
{
|
||||
Memaddmode = 1 ;
|
||||
Mem_address = 0 ;
|
||||
txmit( '>' ) ;
|
||||
}
|
||||
|
||||
if ( rxchar == 'm' )
|
||||
{
|
||||
crlf() ;
|
||||
p8hex( (uint32_t) &g_model.moduleData[0] ) ;
|
||||
txmit( ' ' ) ;
|
||||
p8hex( (uint32_t) &g_model.moduleData[1] ) ;
|
||||
crlf() ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -92,4 +226,5 @@ void debugTx(void)
|
|||
if (debugTxFifo.pop(txchar))
|
||||
debugPutc(txchar);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue