📄 debug.h
字号:
//! @file debug.h
//!
//! Copyright (c) 2004
//!
//! Use of this program is subject to Atmel's End User License Agreement.
//! Please read file license.txt for copyright notice.
//!
//! @brief This file holds definitions to help software designers in debugging
//! their applications.
//!
//! @version 1.1 (c5131-usb-generic-1_2_0)
//!
//! @todo
//! @bug
#ifndef _DEBUG_H_
#define _DEBUG_H_
//_____ I N C L U D E S ____________________________________________________
#include "conf/conf_clock.h"
//_____ M A C R O S ________________________________________________________
//! This is Compilation switches definition
//#define SOFT_OCD // when OCD dongle is not used, only VT100 or hyperterminal
#ifndef _TRACE_
// Disable this switch to remove the Trace code from the compilation
// Enable it to add Traces code on compilation
#define _TRACE_ (DISABLE) // default value
#endif
#ifndef _ASSERT_
// Disable this switch to remove the Assert code from the compilation
// Enable it to add the Assert code from the compilation
#define _ASSERT_ (DISABLE) // default value
#endif
#define OCD_BAUDRATE 19200
//! This is initialization of OCD_BRL_VALUE is used to insert OCD software entry sequence
#ifndef FOSC
#error You must define FOSC in config.h
#elif FOSC == 12000 // Fosc = 12 MHz
# if OCD_BAUDRATE == 4800
# define OCD_BRL_VALUE 155 // error <1%
# elif OCD_BAUDRATE == 9600
# define Ocd_BRL_value 77 // error <1%
# elif OCD_BAUDRATE == 19200
# define OCD_BRL_VALUE 38 // error <1%
# elif OCD_BAUDRATE == 57600
# define Ocd_BRL_value 12 // error <1%
# else
# error Only these baudrates are available : 4800, 9600, 19200, 57600
# endif
#elif FOSC == 16000 // Fosc = 16 MHz
# if OCD_BAUDRATE == 4800
# define OCD_BRL_VALUE 207 // error <1%
# elif OCD_BAUDRATE == 9600
# define OCD_BRL_VALUE 103 // error <1%
# elif OCD_BAUDRATE == 19200
# define OCD_BRL_VALUE 51 // error <1%
# elif OCD_BAUDRATE == 19200
# define OCD_BRL_VALUE 51 // error <1%
# elif OCD_BAUDRATE == 38400
# define OCD_BRL_VALUE 25 // error <1%
# else
# error Only these baudrates are available : 4800, 9600, 19200, 38400
# endif
#elif FOSC == 20000 // Fosc = 20 MHz
# if OCD_BAUDRATE == 9600
# define OCD_BRL_VALUE 129 // error <1%
# elif OCD_BAUDRATE == 19200
# define OCD_BRL_VALUE 64 // error <1%
# elif OCD_BAUDRATE == 38400
# define OCD_BRL_VALUE 32 // 5% error
# else
# error Only these baudrates are available : 9600, 19200, 38400
# endif
#elif FOSC == 24000 // Fosc = 24 MHz
# if OCD_BAUDRATE == 9600
# define OCD_BRL_VALUE 155 // error <1%
# elif OCD_BAUDRATE == 19200
# define OCD_BRL_VALUE 77 // error <1%
# elif OCD_BAUDRATE == 38400
# define OCD_BRL_VALUE 38 // error <1%
# elif OCD_BAUDRATE == 57600
# define OCD_BRL_VALUE 25 // error <1%
# elif OCD_BAUDRATE == 115200
# define OCD_BRL_VALUE 12 // 1.84% error
# else
# error Only these baudrates are available : 9600, 19200, 38400, 57600, 115200
# endif
#endif
//! This macro is used to insert OCD software entry sequence
#define Ocd_soft_entry() (OACTIV=0x55,OACTIV=0xAA)
//! Trace control characters definition : start & stop
#define TRACE_START_CHAR ('#')
#define TRACE_STOP_CHAR ( 0 )
//! This macro is used to test fatal errors which may be caused by
//! software or hardware bugs.
//!
//! The macro tests if the expression is TRUE. If it is not, a fatal error
//! is detected and the application hangs.
//!
//! @param expr expression which is supposed to be TRUE.
#if (_ASSERT_==ENABLE)
# define Assert( expr ) \
{ \
if( !(expr) ) \
{ \
trace("\n\r"); \
trace(__FILE__); \
trace(":"); \
trace_u16(__LINE__); \
while(1) { \
} \
} \
}
#else
# define Assert( expr )
#endif
extern U8 _MEM_TYPE_SLOW_ g_trace_en;
#if (_TRACE_==ENABLE)
# define Trace_ptwo( hex ) (P2 = (hex))
void trace( const U8* str );
void trace_hex( U8 val );
void trace_u8( U16 val );
void trace_u16( U16 val );
void trace_u32( U32 val );
#define Trace_nl() \
trace("\n\r");
#define Trace_hex16(u16) \
trace("0x"); \
trace_hex(MSB(u16)); \
trace_hex(LSB(u16));
#define Trace_hex32(u32) \
trace("0x"); \
trace_hex(MSB0(u32)); \
trace_hex(MSB1(u32)); \
trace_hex(MSB2(u32)); \
trace_hex(MSB3(u32));
#else
# define Trace_ptwo( hex )
# define trace( str )
# define trace_hex( val )
# define trace_u16( val )
# define trace_u32( val )
# define Trace_hex16(u16)
# define Trace_hex32(u32)
# define Trace_nl()
# define Traces_u8(expr)
# define Traces_u16(expr)
# define Traces_u32(expr)
#endif
#if (_TRACE_!=ENABLE) && (_TRACE_!=DISABLE)
# error _TRACE_ can only be defined to ENABLE or DISABLE
#endif
#if (_ASSERT_!=ENABLE) && (_ASSERT_!=DISABLE)
# error _ASSERT_ can only be defined to ENABLE or DISABLE
#endif
//_____ D E C L A R A T I O N S ____________________________________________
void ocd_enable(Bool ocd_activ);
#endif // _DEBUG_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -