![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
dac controller for EE300 project
log/log.cpp@1:4bd950ab8756, 2014-04-04 (annotated)
- Committer:
- dzl5187
- Date:
- Fri Apr 04 18:48:23 2014 +0000
- Revision:
- 1:4bd950ab8756
dac sub-system;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dzl5187 | 1:4bd950ab8756 | 1 | #include "log.h" |
dzl5187 | 1:4bd950ab8756 | 2 | #include "stdio.h" |
dzl5187 | 1:4bd950ab8756 | 3 | #include "mbed.h" |
dzl5187 | 1:4bd950ab8756 | 4 | #include "stdarg.h" |
dzl5187 | 1:4bd950ab8756 | 5 | Serial pc(USBTX, USBRX); |
dzl5187 | 1:4bd950ab8756 | 6 | void vlogMessage(const char *,va_list); |
dzl5187 | 1:4bd950ab8756 | 7 | /** |
dzl5187 | 1:4bd950ab8756 | 8 | Function: logMessage |
dzl5187 | 1:4bd950ab8756 | 9 | Description: output the message(can be formatted string) to PC |
dzl5187 | 1:4bd950ab8756 | 10 | */ |
dzl5187 | 1:4bd950ab8756 | 11 | void logMessage(const char *fmt,...){ |
dzl5187 | 1:4bd950ab8756 | 12 | va_list args; |
dzl5187 | 1:4bd950ab8756 | 13 | va_start(args, fmt); |
dzl5187 | 1:4bd950ab8756 | 14 | vlogMessage( fmt, args ); |
dzl5187 | 1:4bd950ab8756 | 15 | va_end(args); |
dzl5187 | 1:4bd950ab8756 | 16 | } |
dzl5187 | 1:4bd950ab8756 | 17 | |
dzl5187 | 1:4bd950ab8756 | 18 | void vlogMessage(const char *fmt,va_list args){ |
dzl5187 | 1:4bd950ab8756 | 19 | char buffer[255]; |
dzl5187 | 1:4bd950ab8756 | 20 | char msg[255]; |
dzl5187 | 1:4bd950ab8756 | 21 | //get time stamp |
dzl5187 | 1:4bd950ab8756 | 22 | sprintf(buffer, "Time[seconds]: %.3f : ", programTimer.read_ms()/1000.0); |
dzl5187 | 1:4bd950ab8756 | 23 | |
dzl5187 | 1:4bd950ab8756 | 24 | vsprintf( msg, fmt, args ); |
dzl5187 | 1:4bd950ab8756 | 25 | strcat( buffer, msg); |
dzl5187 | 1:4bd950ab8756 | 26 | pc.printf("%s \n", buffer); |
dzl5187 | 1:4bd950ab8756 | 27 | } |