lufa: Add debug print support with UART
This commit is contained in:
parent
c41e48a0ab
commit
e23520662d
3 changed files with 38 additions and 12 deletions
|
|
@ -50,8 +50,12 @@ endif
|
||||||
ifeq (yes,$(strip $(CONSOLE_ENABLE)))
|
ifeq (yes,$(strip $(CONSOLE_ENABLE)))
|
||||||
OPT_DEFS += -DCONSOLE_ENABLE
|
OPT_DEFS += -DCONSOLE_ENABLE
|
||||||
else
|
else
|
||||||
OPT_DEFS += -DNO_PRINT
|
# Remove print functions when console is disabled and
|
||||||
OPT_DEFS += -DNO_DEBUG
|
# no other print method like UART is available
|
||||||
|
ifneq (yes, $(strip $(DEBUG_PRINT_AVAILABLE)))
|
||||||
|
OPT_DEFS += -DNO_PRINT
|
||||||
|
OPT_DEFS += -DNO_DEBUG
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq (yes,$(strip $(COMMAND_ENABLE)))
|
ifeq (yes,$(strip $(COMMAND_ENABLE)))
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,20 @@ OPT_DEFS += $(LUFA_OPTS)
|
||||||
# This indicates using LUFA stack
|
# This indicates using LUFA stack
|
||||||
OPT_DEFS += -DPROTOCOL_LUFA
|
OPT_DEFS += -DPROTOCOL_LUFA
|
||||||
|
|
||||||
|
ifeq (yes,$(strip $(LUFA_DEBUG)))
|
||||||
|
LUFA_OPTS += -DLUFA_DEBUG
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq (yes,$(strip $(LUFA_DEBUG_SUART)))
|
ifeq (yes,$(strip $(LUFA_DEBUG_SUART)))
|
||||||
SRC += common/avr/suart.S
|
SRC += common/avr/suart.S
|
||||||
LUFA_OPTS += -DLUFA_DEBUG_SUART
|
LUFA_OPTS += -DLUFA_DEBUG_SUART
|
||||||
|
# Keep print/debug lines when disabling HID console. See common.mk.
|
||||||
|
DEBUG_PRINT_AVAILABLE = yes
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq (yes,$(strip $(LUFA_DEBUG_UART)))
|
||||||
|
SRC += common/avr/uart.c
|
||||||
|
LUFA_OPTS += -DLUFA_DEBUG_UART
|
||||||
|
# Keep print/debug lines when disabling HID console. See common.mk.
|
||||||
|
DEBUG_PRINT_AVAILABLE = yes
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,10 @@
|
||||||
#include "avr/suart.h"
|
#include "avr/suart.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef LUFA_DEBUG_UART
|
||||||
|
#include "uart.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "matrix.h"
|
#include "matrix.h"
|
||||||
#include "descriptor.h"
|
#include "descriptor.h"
|
||||||
#include "lufa.h"
|
#include "lufa.h"
|
||||||
|
|
@ -218,7 +222,9 @@ static void console_task(void)
|
||||||
*/
|
*/
|
||||||
void EVENT_USB_Device_Connect(void)
|
void EVENT_USB_Device_Connect(void)
|
||||||
{
|
{
|
||||||
|
#ifdef LUFA_DEBUG
|
||||||
print("[C]");
|
print("[C]");
|
||||||
|
#endif
|
||||||
/* For battery powered device */
|
/* For battery powered device */
|
||||||
if (!USB_IsInitialized) {
|
if (!USB_IsInitialized) {
|
||||||
USB_Disable();
|
USB_Disable();
|
||||||
|
|
@ -229,7 +235,9 @@ void EVENT_USB_Device_Connect(void)
|
||||||
|
|
||||||
void EVENT_USB_Device_Disconnect(void)
|
void EVENT_USB_Device_Disconnect(void)
|
||||||
{
|
{
|
||||||
|
#ifdef LUFA_DEBUG
|
||||||
print("[D]");
|
print("[D]");
|
||||||
|
#endif
|
||||||
/* For battery powered device */
|
/* For battery powered device */
|
||||||
USB_IsInitialized = false;
|
USB_IsInitialized = false;
|
||||||
/* TODO: This doesn't work. After several plug in/outs can not be enumerated.
|
/* TODO: This doesn't work. After several plug in/outs can not be enumerated.
|
||||||
|
|
@ -575,25 +583,22 @@ static void send_consumer(uint16_t data)
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* sendchar
|
* sendchar
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
#ifdef CONSOLE_ENABLE
|
|
||||||
int8_t sendchar(uint8_t c)
|
int8_t sendchar(uint8_t c)
|
||||||
{
|
{
|
||||||
#ifdef LUFA_DEBUG_SUART
|
#ifdef LUFA_DEBUG_SUART
|
||||||
xmit(c);
|
xmit(c);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool r = console_putc(c);
|
#ifdef LUFA_DEBUG_UART
|
||||||
return (r ? 0 : -1);
|
uart_putchar(c);
|
||||||
}
|
|
||||||
#else
|
|
||||||
int8_t sendchar(uint8_t c)
|
|
||||||
{
|
|
||||||
#ifdef LUFA_DEBUG_SUART
|
|
||||||
xmit(c);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONSOLE_ENABLE
|
||||||
|
console_putc(c);
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
@ -629,6 +634,10 @@ int main(void)
|
||||||
SUART_OUT_PORT |= (1<<SUART_OUT_BIT);
|
SUART_OUT_PORT |= (1<<SUART_OUT_BIT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef LUFA_DEBUG_UART
|
||||||
|
uart_init(115200);
|
||||||
|
#endif
|
||||||
|
|
||||||
// setup sendchar: DO NOT USE print functions before this line
|
// setup sendchar: DO NOT USE print functions before this line
|
||||||
print_set_sendchar(sendchar);
|
print_set_sendchar(sendchar);
|
||||||
host_set_driver(&lufa_driver);
|
host_set_driver(&lufa_driver);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue