Skip to content

Commit

Permalink
TRICE_QUICK_AND_DIRTY_ONLY_PUTCHAR option added
Browse files Browse the repository at this point in the history
ASSERT renamed to TRICE_ASSERT
  • Loading branch information
rokath committed Mar 15, 2020
1 parent 9c245c3 commit ee7ab47
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 18 deletions.
2 changes: 1 addition & 1 deletion examples/triceDemoF030R8/Inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ extern "C" {

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */

#define TRICE_UART USART2
/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
Expand Down
8 changes: 4 additions & 4 deletions examples/triceDemoF030R8/Inc/trice.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ extern "C" {
#endif

#if NO_CODE == TRICE_CODE
#define ASSERT( flag )
#define TRICE_ASSERT( flag )
#else
#define ASSERT( flag ) do{ if(!(flag)) { TRICE_LOC; TRICE0( Id(37710), "ERR:ASSERT failed\n" ); } }while(0) //!< report if flag is not true
#define TRICE_ASSERT( flag ) do{ if(!(flag)) { TRICE_LOC; TRICE0( Id(37710), "ERR:ASSERT failed\n" ); } }while(0) //!< report if flag is not true
#endif

#define ASSERT_OR_RETURN( flag ) do{ ASSERT( flag ); if(!(flag)) { return; } }while(0) //!< report if flag is not true and return
#define ASSERT_OR_RETURN_RESULT( flag, r ) do{ ASSERT( flag ); if(!(flag)) { return r; } }while(0) //!< report if flag is not true and return
#define ASSERT_OR_RETURN( flag ) do{ TRICE_ASSERT( flag ); if(!(flag)) { return; } }while(0) //!< report if flag is not true and return
#define ASSERT_OR_RETURN_RESULT( flag, r ) do{ TRICE_ASSERT( flag ); if(!(flag)) { return r; } }while(0) //!< report if flag is not true and return

#if 0 == TRICE_PRINTF_ADAPTER || NO_CODE == TRICE_CODE
#define TRICE_P( s, ... )
Expand Down
10 changes: 5 additions & 5 deletions examples/triceDemoF030R8/Inc/triceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ extern "C" {

#ifdef TRICE_QUICK_AND_DIRTY_ONLY_PUTCHAR
TRICE_INLINE void tricePutchar( char c ){
LL_USART_TransmitData8( USART2, c); // put your putchar call here
LL_USART_TransmitData8( TRICE_UART, c); // put your putchar call here
}

#define TRICE_ENTER_CRITICAL_SECTION {
Expand Down Expand Up @@ -164,26 +164,26 @@ TRICE_INLINE void triceDisableTxEmptyInterrupt( void ){}
//! \retval !0 == empty
//! User must provide this function.
TRICE_INLINE uint32_t triceTxDataRegisterEmpty( void ){
return LL_USART_IsActiveFlag_TXE( USART2 );
return LL_USART_IsActiveFlag_TXE( TRICE_UART );
}

//! Write value d into trice transmit register.
//! \param d byte to transmit
//! User must provide this function.
TRICE_INLINE void triceTransmitData8( uint8_t d ){
LL_USART_TransmitData8( USART2, d);
LL_USART_TransmitData8( TRICE_UART, d);
}

//! Allow interrupt for empty trice data transmit register.
//! User must provide this function.
TRICE_INLINE void triceEableTxEmptyInterrupt( void ){
LL_USART_EnableIT_TXE( USART2 );
LL_USART_EnableIT_TXE( TRICE_UART );
}

//! Disallow interrupt for empty trice data transmit register.
//! User must provide this function.
TRICE_INLINE void triceDisableTxEmptyInterrupt( void ){
LL_USART_DisableIT_TXE( USART2 );
LL_USART_DisableIT_TXE( TRICE_UART );
}

#endif // #else // #ifdef TRICE_QUICK_AND_DIRTY_ONLY_PUTCHAR
Expand Down
2 changes: 1 addition & 1 deletion examples/triceDemoF030R8/MDK-ARM/triceDemoF030R8.uvoptx
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@
<GroupNumber>5</GroupNumber>
<FileNumber>13</FileNumber>
<FileType>1</FileType>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\Src\triceCheck.c</PathWithFileName>
Expand Down
4 changes: 2 additions & 2 deletions examples/triceDemoF030R8/Src/triceCheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ void triceCheckSet( void )
#endif
TRICE16_1( Id(46097), "dbg:12345 as 16bit is %#016b\n", 12345 );
TRICE0 (Id( 4316), "------------------------------------------------------------------------------------------\r\n\n" );
ASSERT(0==0);
TRICE_ASSERT(0==0);
TRICE0( Id(10084), "sig:This ASSERT error is just a demo and no real error: ");
ASSERT(0==1);
TRICE_ASSERT(0==1);
TRICE0 (Id(41390), "------------------------------------------------------------------------------------------\r\n\n" );

TRICE8_4( Id( 1750), "tst:TRICE8 %%03x -> %03x %03x %03x %03x\n", 1, 0x7f, 0x80, 0xff );
Expand Down
28 changes: 23 additions & 5 deletions src.C/triceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,22 @@ extern "C" {
// hardware specific interface functions tested on NUCLEO-STM32F030
//

//#define TRICE_QUICK_AND_DIRTY_ONLY_PUTCHAR // for a quick start you can enable this line and rely only putchar

#ifdef TRICE_QUICK_AND_DIRTY_ONLY_PUTCHAR
TRICE_INLINE void tricePutchar( char c ){
LL_USART_TransmitData8( TRICE_USART, c); // put your putchar call here
}

#define TRICE_ENTER_CRITICAL_SECTION {
#define TRICE_LEAVE_CRITICAL_SECTION }
TRICE_INLINE uint32_t triceTxDataRegisterEmpty( void ){ return 1; } // would be good to implement it for better performance, otherwise you need to use a time interval for the Tx calls
TRICE_INLINE void triceTransmitData8( uint8_t d ){ tricePutchar( d ); }
TRICE_INLINE void triceEableTxEmptyInterrupt( void ){}
TRICE_INLINE void triceDisableTxEmptyInterrupt( void ){}

#else // #ifdef TRICE_QUICK_AND_DIRTY_ONLY_PUTCHAR

//! Save interrupt state and disable Interrupts
//! \details Workaround for ARM Cortex M0 and M0+
//! \li __get_PRIMASK() is 0 when interrupts are enabled globally
Expand All @@ -145,31 +161,33 @@ extern "C" {

//! Check if a new byte can be written into trice transmit register.
//! \retval 0 == not empty
//! \retval !0 == epmty
//! \retval !0 == empty
//! User must provide this function.
TRICE_INLINE uint32_t triceTxDataRegisterEmpty( void ){
return LL_USART_IsActiveFlag_TXE( USART2 );
return LL_USART_IsActiveFlag_TXE( TRICE_UART );
}

//! Write value d into trice transmit register.
//! \param d byte to transmit
//! User must provide this function.
TRICE_INLINE void triceTransmitData8( uint8_t d ){
LL_USART_TransmitData8( USART2, d);
LL_USART_TransmitData8( TRICE_UART, d);
}

//! Allow interrupt for empty trice data transmit register.
//! User must provide this function.
TRICE_INLINE void triceEableTxEmptyInterrupt( void ){
LL_USART_EnableIT_TXE( USART2 );
LL_USART_EnableIT_TXE( TRICE_UART );
}

//! Disallow interrupt for empty trice data transmit register.
//! User must provide this function.
TRICE_INLINE void triceDisableTxEmptyInterrupt( void ){
LL_USART_DisableIT_TXE( USART2 );
LL_USART_DisableIT_TXE( TRICE_UART );
}

#endif // #else // #ifdef TRICE_QUICK_AND_DIRTY_ONLY_PUTCHAR

#define SYSTICKVAL16 SysTick->VAL //!< STM32 specific, set to 0 as starting point with nonSTM MCE

#ifdef __cplusplus
Expand Down

0 comments on commit ee7ab47

Please sign in to comment.