Adding CLI and CDC Serial support for Teensy 2.0 and Teensy 2.0++
- Includes serial putchar and getchar cleanup (overall) - Moved avr-capsense to DPH (renaming) - Basic cleanup for including CLI on the avr architecture
This commit is contained in:
parent
b2e237f368
commit
15ec4ff71c
27 changed files with 1596 additions and 933 deletions
|
@ -31,24 +31,8 @@
|
|||
|
||||
// ----- Functions -----
|
||||
|
||||
// USB HID String Output
|
||||
void usb_debug_putstr( char* s )
|
||||
{
|
||||
#if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) // AVR
|
||||
while ( *s != '\0' )
|
||||
usb_debug_putchar( *s++ );
|
||||
#elif defined(_mk20dx128_) || defined(_mk20dx256_) // ARM
|
||||
// Count characters until NULL character, then send the amount counted
|
||||
uint32_t count = 0;
|
||||
while ( s[count] != '\0' )
|
||||
count++;
|
||||
|
||||
usb_serial_write( s, count );
|
||||
#endif
|
||||
}
|
||||
|
||||
// Multiple string Output
|
||||
void usb_debug_putstrs( char* first, ... )
|
||||
void printstrs( char* first, ... )
|
||||
{
|
||||
// Initialize the variadic function parameter list
|
||||
va_list ap;
|
||||
|
@ -61,7 +45,7 @@ void usb_debug_putstrs( char* first, ... )
|
|||
while ( !( cur[0] == '\0' && cur[1] == '\0' && cur[2] == '\0' ) )
|
||||
{
|
||||
// Print out the given string
|
||||
usb_debug_putstr( cur );
|
||||
output_putstr( cur );
|
||||
|
||||
// Get the next argument ready
|
||||
cur = va_arg( ap, char* );
|
||||
|
@ -71,21 +55,17 @@ void usb_debug_putstrs( char* first, ... )
|
|||
}
|
||||
|
||||
// Print a constant string
|
||||
void _print(const char *s)
|
||||
void _print( const char* s )
|
||||
{
|
||||
#if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) // AVR
|
||||
// Pull string out of flash
|
||||
char c;
|
||||
|
||||
// Acquire the character from flash, and print it, as long as it's not NULL
|
||||
// Also, if a newline is found, print a carrige return as well
|
||||
while ( ( c = pgm_read_byte(s++) ) != '\0' )
|
||||
while ( ( c = pgm_read_byte( s++ ) ) != '\0' )
|
||||
{
|
||||
if ( c == '\n' )
|
||||
usb_debug_putchar('\r');
|
||||
usb_debug_putchar(c);
|
||||
output_putchar( c );
|
||||
}
|
||||
#elif defined(_mk20dx128_) || defined(_mk20dx256_) // ARM
|
||||
usb_debug_putstr( (char*)s );
|
||||
output_putstr( (char*)s );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -26,16 +26,12 @@
|
|||
|
||||
// Compiler Includes
|
||||
#if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_)
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
#include "avr/usb_keyboard_debug.h"
|
||||
|
||||
#elif defined(_mk20dx128_) || defined(_mk20dx256_)
|
||||
|
||||
#include "arm/usb_serial.h"
|
||||
|
||||
#endif
|
||||
|
||||
// Project Includes
|
||||
#include <output_com.h>
|
||||
|
||||
|
||||
|
||||
// ----- Defines -----
|
||||
|
@ -50,15 +46,15 @@
|
|||
*/
|
||||
|
||||
// Function Aliases
|
||||
#define dPrint(c) usb_debug_putstr(c)
|
||||
#define dPrintStr(c) usb_debug_putstr(c)
|
||||
#define dPrintStrs(...) usb_debug_putstrs(__VA_ARGS__, "\0\0\0") // Convenience Variadic Macro
|
||||
#define dPrintStrNL(c) dPrintStrs (c, NL) // Appends New Line Macro
|
||||
#define dPrintStrsNL(...) usb_debug_putstrs(__VA_ARGS__, NL, "\0\0\0") // Appends New Line Macro
|
||||
#define dPrint(c) output_putstr(c)
|
||||
#define dPrintStr(c) output_putstr(c)
|
||||
#define dPrintStrs(...) printstrs(__VA_ARGS__, "\0\0\0") // Convenience Variadic Macro
|
||||
#define dPrintStrNL(c) dPrintStrs (c, NL) // Appends New Line Macro
|
||||
#define dPrintStrsNL(...) printstrs(__VA_ARGS__, NL, "\0\0\0") // Appends New Line Macro
|
||||
|
||||
// Special Msg Constructs (Uses VT100 tags)
|
||||
#define dPrintMsg(colour_code_str,msg,...) \
|
||||
usb_debug_putstrs("\033[", colour_code_str, "m", msg, "\033[0m - ", __VA_ARGS__, NL, "\0\0\0")
|
||||
printstrs("\033[", colour_code_str, "m", msg, "\033[0m - ", __VA_ARGS__, NL, "\0\0\0")
|
||||
#define printMsgNL(colour_code_str,msg,str) \
|
||||
print("\033[" colour_code_str "m" msg "\033[0m - " str NL)
|
||||
#define printMsg(colour_code_str,msg,str) \
|
||||
|
@ -89,8 +85,7 @@
|
|||
#define print(s) _print(PSTR(s))
|
||||
|
||||
void _print(const char *s);
|
||||
void usb_debug_putstr( char* s );
|
||||
void usb_debug_putstrs( char* first, ... );
|
||||
void printstrs( char* first, ... );
|
||||
|
||||
|
||||
// Printing numbers
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue