RT-USB-9AXIS-00
debug.c
1 /* ------------------------------------------------------------ *
2 File debug.c
3 
4 デバッグ用関数群
5 * ------------------------------------------------------------ */
6 
7 #include <stdarg.h>
8 #include <stdio.h>
9 
10 #include "LPC13xx.h"
11 #include "core_cm3.h"
12 #include "type.h"
13 
14 #include "uart.h"
15 #include "usbTransmission.h"
16 
17 /* ------------------------------------------------------------ *
18  Input *fmt, ... printf()と同じフォーマット
19  Output dat.num データ長
20 
21  printf()のフォーマットでUSBから文字列を出力
22 * ------------------------------------------------------------ */
23 int myPrintfUSB(const char *fmt, ...){
24  GETDAT_T dat;
25  volatile uint32_t dummy = 0;
26  va_list ap;
27  va_start(ap, fmt);
28 
29  dat.num = vsprintf(&dat.d[0], fmt, ap);
30  VCOM_SendData(dat);
31  VCOM_CheckState();
32 
33  va_end(ap);
34  //時間潰し
35 
36  while(1){
37  dummy ++;
38  if(dummy > 2000) break;
39  }
40 
41  return dat.num;
42 }
43 /* ------------------------------------------------------------ *
44  Input *fmt, ... printf()と同じフォーマット
45  Output dat.num データ長
46 
47  printf()のフォーマットでUARTで文字列を出力
48 * ------------------------------------------------------------ */
49 int myPrintfUART(const char *fmt, ...){
50  static char buffer[256];
51  int len;
52 
53  va_list ap;
54  va_start(ap, fmt);
55 
56  len = vsprintf(buffer, fmt, ap);
57 
58  UARTSend(buffer, len );
59 
60  va_end(ap);
61  return len;
62 }
63 
64 /******************************************************************************
65 ** End Of File
66 ******************************************************************************/
CMSIS Cortex-M3 Core Peripheral Access Layer Header File.