60 lines
858 B
C
60 lines
858 B
C
|
/*
|
|||
|
<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>Բ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|||
|
|
|||
|
<EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʢԴ<EFBFBD><EFBFBD><EFBFBD>Ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˾
|
|||
|
<EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>2016/7/8
|
|||
|
*/
|
|||
|
#include "debug.h"
|
|||
|
#include "uart.h"
|
|||
|
#include <stdarg.h>
|
|||
|
#include <stdio.h>
|
|||
|
|
|||
|
#ifdef _DEBUG_
|
|||
|
|
|||
|
#define MAX_FORMAT_BUFFER_SIZE (128)
|
|||
|
static uint8_t s_formatBuffer[MAX_FORMAT_BUFFER_SIZE];
|
|||
|
|
|||
|
void dbg_init(void)
|
|||
|
{
|
|||
|
uart_0_init();
|
|||
|
}
|
|||
|
|
|||
|
void dbg_printf(char *format,...)
|
|||
|
{
|
|||
|
uint8_t iWriteNum = 0,i=0;
|
|||
|
va_list ap;
|
|||
|
|
|||
|
if(!format)
|
|||
|
return;
|
|||
|
|
|||
|
va_start(ap,format);
|
|||
|
|
|||
|
iWriteNum = vsprintf((char *)s_formatBuffer,format,ap);
|
|||
|
|
|||
|
va_end(ap);
|
|||
|
|
|||
|
if(iWriteNum > MAX_FORMAT_BUFFER_SIZE)
|
|||
|
iWriteNum = MAX_FORMAT_BUFFER_SIZE;
|
|||
|
|
|||
|
for(i=0;i<iWriteNum;i++){
|
|||
|
uart_0_write(s_formatBuffer[i]);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void dbg_hexdump(char *title, uint8_t *buf, uint16_t sz)
|
|||
|
{
|
|||
|
int i = 0;
|
|||
|
|
|||
|
if (title)
|
|||
|
dbg_printf((title));
|
|||
|
|
|||
|
for(i = 0; i < sz; i++)
|
|||
|
{
|
|||
|
dbg_printf("%02x ",(uint16_t)buf[i]);
|
|||
|
}
|
|||
|
|
|||
|
dbg_printf("\r\n");
|
|||
|
}
|
|||
|
|
|||
|
#endif
|