diff --git a/tinyusb/.cproject b/tinyusb/.cproject
index 9ad0f808..fdb4d73d 100644
--- a/tinyusb/.cproject
+++ b/tinyusb/.cproject
@@ -631,6 +631,7 @@
+
@@ -1260,6 +1261,7 @@
+
@@ -1890,6 +1892,7 @@
+
diff --git a/tinyusb/class/cdc.c b/tinyusb/class/cdc.c
index de08eeed..ea761330 100644
--- a/tinyusb/class/cdc.c
+++ b/tinyusb/class/cdc.c
@@ -38,7 +38,7 @@
#include "cdc.h"
#include "common/fifo.h"
-#if defined CFG_CLASS_CDC && defined CFG_TUSB_DEVICE
+#if defined TUSB_CFG_DEVICE_CDC && defined TUSB_CFG_DEVICE
static USBD_HANDLE_T g_hCdc;
static CDC_LINE_CODING line_coding;
diff --git a/tinyusb/class/hid.c b/tinyusb/class/hid.c
index 659765c1..b5416faa 100644
--- a/tinyusb/class/hid.c
+++ b/tinyusb/class/hid.c
@@ -37,14 +37,14 @@
#include "hid.h"
-#if defined TUSB_CLASS_HID && defined CFG_TUSB_DEVICE
+#if defined DEVICE_CLASS_HID && defined TUSB_CFG_DEVICE
-#ifdef CFG_CLASS_HID_KEYBOARD
+#ifdef TUSB_CFG_DEVICE_HID_KEYBOARD
USB_HID_KeyboardReport_t hid_keyboard_report;
volatile static bool bKeyChanged = false;
#endif
-#ifdef CFG_CLASS_HID_MOUSE
+#ifdef TUSB_CFG_DEVICE_HID_MOUSE
USB_HID_MouseReport_t hid_mouse_report;
volatile static bool bMouseChanged = false;
#endif
@@ -64,7 +64,7 @@ ErrorCode_t HID_GetReport( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t
switch (pHidCtrl->protocol)
{
- #ifdef CFG_CLASS_HID_KEYBOARD
+ #ifdef TUSB_CFG_DEVICE_HID_KEYBOARD
case HID_PROTOCOL_KEYBOARD:
*pBuffer = (uint8_t*) &hid_keyboard_report;
*plength = sizeof(USB_HID_KeyboardReport_t);
@@ -77,7 +77,7 @@ ErrorCode_t HID_GetReport( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t
break;
#endif
- #ifdef CFG_CLASS_HID_MOUSE
+ #ifdef TUSB_CFG_DEVICE_HID_MOUSE
case HID_PROTOCOL_MOUSE:
*pBuffer = (uint8_t*) &hid_mouse_report;
*plength = sizeof(USB_HID_MouseReport_t);
@@ -127,7 +127,7 @@ ErrorCode_t HID_EpIn_Hdlr (USBD_HANDLE_T hUsb, void* data, uint32_t event)
USB_HID_CTRL_T* pHidCtrl = (USB_HID_CTRL_T*)data;
switch(pHidCtrl->protocol)
{
- #ifdef CFG_CLASS_HID_KEYBOARD
+ #ifdef TUSB_CFG_DEVICE_HID_KEYBOARD
case HID_PROTOCOL_KEYBOARD:
if (!bKeyChanged)
{
@@ -138,7 +138,7 @@ ErrorCode_t HID_EpIn_Hdlr (USBD_HANDLE_T hUsb, void* data, uint32_t event)
break;
#endif
- #ifdef CFG_CLASS_HID_MOUSE
+ #ifdef TUSB_CFG_DEVICE_HID_MOUSE
case HID_PROTOCOL_MOUSE:
if (!bMouseChanged)
{
@@ -222,18 +222,18 @@ TUSB_Error_t tusb_hid_init(USBD_HANDLE_T hUsb, USB_INTERFACE_DESCRIPTOR const *c
/**************************************************************************/
TUSB_Error_t tusb_hid_configured(USBD_HANDLE_T hUsb)
{
- #ifdef CFG_CLASS_HID_KEYBOARD
+ #ifdef TUSB_CFG_DEVICE_HID_KEYBOARD
USBD_API->hw->WriteEP(hUsb , HID_KEYBOARD_EP_IN , (uint8_t* ) &hid_keyboard_report , sizeof(USB_HID_KeyboardReport_t) ); // initial packet for IN endpoint , will not work if omitted
#endif
- #ifdef CFG_CLASS_HID_MOUSE
+ #ifdef TUSB_CFG_DEVICE_HID_MOUSE
USBD_API->hw->WriteEP(hUsb , HID_MOUSE_EP_IN , (uint8_t* ) &hid_mouse_report , sizeof(USB_HID_MouseReport_t) ); // initial packet for IN endpoint, will not work if omitted
#endif
return tERROR_NONE;
}
-#ifdef CFG_CLASS_HID_KEYBOARD
+#ifdef TUSB_CFG_DEVICE_HID_KEYBOARD
/**************************************************************************/
/*!
@brief Send the supplied key codes out via HID USB keyboard emulation
@@ -295,7 +295,7 @@ TUSB_Error_t tusb_hid_keyboard_sendKeys(uint8_t modifier, uint8_t keycodes[], ui
}
#endif
-#ifdef CFG_CLASS_HID_MOUSE
+#ifdef TUSB_CFG_DEVICE_HID_MOUSE
/**************************************************************************/
/*!
@brief Send the supplied mouse event out via HID USB mouse emulation
diff --git a/tinyusb/class/hid.h b/tinyusb/class/hid.h
index b5516e25..4779e9e8 100644
--- a/tinyusb/class/hid.h
+++ b/tinyusb/class/hid.h
@@ -57,8 +57,14 @@
// TODO refractor
#include "common/common.h"
-#include "device/dcd.h"
+#ifdef TUSB_CFG_DEVICE
+#include "device/dcd.h"
+#endif
+
+#ifdef TUSB_CFG_HOST
+#include "device/hcd.h"
+#endif
/** \struct USB_HID_MouseReport_t
* \brief Standard HID Boot Protocol Mouse Report.
@@ -160,7 +166,7 @@ enum USB_HID_LOCAL_CODE
* \return Error Code of the \ref TUSB_ERROR enum
* \note
*/
-TUSB_Error_t tusb_hid_init(USBD_HANDLE_T hUsb, USB_INTERFACE_DESCRIPTOR const *const pIntfDesc, uint8_t const * const pHIDReportDesc, uint32_t ReportDescLength, uint32_t* mem_base, uint32_t* mem_size) ATTR_NON_NULL;
+TUSB_Error_t tusb_hid_init(USBD_HANDLE_T hUsb, USB_INTERFACE_DESCRIPTOR const *const pIntfDesc, uint8_t const * const pHIDReportDesc, uint32_t ReportDescLength, uint32_t* mem_base, uint32_t* mem_size);
/** \brief Notify HID class that usb is configured
*
@@ -178,7 +184,7 @@ TUSB_Error_t tusb_hid_configured(USBD_HANDLE_T hUsb);
* \return Error Code of the \ref TUSB_ERROR enum
* \note
*/
-TUSB_Error_t tusb_hid_keyboard_sendKeys(uint8_t modifier, uint8_t keycodes[], uint8_t numkey) ATTR_NON_NULL;
+TUSB_Error_t tusb_hid_keyboard_sendKeys(uint8_t modifier, uint8_t keycodes[], uint8_t numkey);
/** \brief
*
@@ -190,6 +196,10 @@ TUSB_Error_t tusb_hid_keyboard_sendKeys(uint8_t modifier, uint8_t keycodes[], ui
TUSB_Error_t tusb_hid_mouse_send(uint8_t buttons, int8_t x, int8_t y);
#endif
+
+#ifdef TUSB_CFG_HOST
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/tinyusb/common/common.h b/tinyusb/common/common.h
index 91b18ee2..e63747d6 100644
--- a/tinyusb/common/common.h
+++ b/tinyusb/common/common.h
@@ -109,7 +109,7 @@
//#if ( defined CFG_PRINTF_UART || defined CFG_PRINTF_USBCDC || defined CFG_PRINTF_DEBUG )
-#if CFG_TUSB_DEBUG_LEVEL
+#if TUSB_CFG_DEBUG
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
diff --git a/tinyusb/common/errors.c b/tinyusb/common/errors.c
index db93d5d8..4c60e5e4 100644
--- a/tinyusb/common/errors.c
+++ b/tinyusb/common/errors.c
@@ -35,9 +35,15 @@
* This file is part of the tinyUSB stack.
*/
+#include "errors.h"
+
+#if TUSB_CFG_DEBUG == 3
+
char const* const TUSB_ErrorStr[] = {
# define ERROR_ENUM(x) #x,
# include "errors_def"
# undef ERROR_ENUM
0
};
+
+#endif
diff --git a/tinyusb/common/errors.h b/tinyusb/common/errors.h
index 22db0721..53c9379c 100644
--- a/tinyusb/common/errors.h
+++ b/tinyusb/common/errors.h
@@ -49,6 +49,8 @@
#ifndef _TUSB_ERRORS_H_
#define _TUSB_ERRORS_H_
+#include "../tusb_cfg.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -64,8 +66,10 @@ typedef enum {
ERROR_COUNT
}TUSB_Error_t;
-/// Enum to String for debugging purposes. Only available if \ref CFG_TUSB_DEBUG_LEVEL > 0
+#if TUSB_CFG_DEBUG == 3
+/// Enum to String for debugging purposes. Only available if \ref TUSB_CFG_DEBUG > 0
extern char const* const TUSB_ErrorStr[];
+#endif
#ifdef __cplusplus
}
diff --git a/tinyusb/device/dcd.c b/tinyusb/device/dcd.c
index ee4ce361..2913fdab 100644
--- a/tinyusb/device/dcd.c
+++ b/tinyusb/device/dcd.c
@@ -37,7 +37,7 @@
#include "dcd.h"
-#ifdef CFG_TUSB_DEVICE
+#ifdef TUSB_CFG_DEVICE
// TODO refractor later
#include "descriptors.h"
@@ -59,11 +59,11 @@ ErrorCode_t USB_Configure_Event (USBD_HANDLE_T hUsb)
USB_CORE_CTRL_T* pCtrl = (USB_CORE_CTRL_T*)hUsb;
if (pCtrl->config_value)
{
- #if defined(TUSB_CLASS_HID)
+ #if defined(DEVICE_CLASS_HID)
ASSERT( tERROR_NONE == tusb_hid_configured(hUsb), ERR_FAILED );
#endif
- #ifdef CFG_CLASS_CDC
+ #ifdef TUSB_CFG_DEVICE_CDC
ASSERT( tERROR_NONE == tusb_cdc_configured(hUsb), ERR_FAILED );
#endif
}
@@ -118,18 +118,18 @@ TUSB_Error_t dcd_init(uint8_t coreid)
memsize = usb_param.mem_size;
/* Initialise the class driver(s) */
- #ifdef CFG_CLASS_CDC
+ #ifdef TUSB_CFG_DEVICE_CDC
ASSERT_ERROR( tusb_cdc_init(g_hUsb, &USB_FsConfigDescriptor.CDC_CCI_Interface,
&USB_FsConfigDescriptor.CDC_DCI_Interface, &membase, &memsize) );
#endif
- #ifdef CFG_CLASS_HID_KEYBOARD
+ #ifdef TUSB_CFG_DEVICE_HID_KEYBOARD
ASSERT_ERROR( tusb_hid_init(g_hUsb , &USB_FsConfigDescriptor.HID_KeyboardInterface ,
HID_KeyboardReportDescriptor, USB_FsConfigDescriptor.HID_KeyboardHID.DescriptorList[0].wDescriptorLength,
&membase , &memsize) );
#endif
- #ifdef CFG_CLASS_HID_MOUSE
+ #ifdef TUSB_CFG_DEVICE_HID_MOUSE
ASSERT_ERROR( tusb_hid_init(g_hUsb , &USB_FsConfigDescriptor.HID_MouseInterface ,
HID_MouseReportDescriptor, USB_FsConfigDescriptor.HID_MouseHID.DescriptorList[0].wDescriptorLength,
&membase , &memsize) );
diff --git a/tinyusb/host/hcd.c b/tinyusb/host/hcd.c
index 9ff96d5c..28fe7008 100644
--- a/tinyusb/host/hcd.c
+++ b/tinyusb/host/hcd.c
@@ -37,7 +37,7 @@
#include "hcd.h"
-#ifdef CFG_TUSB_HOST
+#ifdef TUSB_CFG_HOST
TUSB_Error_t hcd_init(uint8_t coreid)
{
diff --git a/tinyusb/tusb.c b/tinyusb/tusb.c
index 8a9bd543..82a2a791 100644
--- a/tinyusb/tusb.c
+++ b/tinyusb/tusb.c
@@ -41,11 +41,11 @@ TUSB_Error_t tusb_init(void)
{
ASSERT_ERROR( hal_init() ) ; /* HARDWARE INIT */
-#ifdef CFG_TUSB_HOST
+#ifdef TUSB_CFG_HOST
ASSERT_ERROR( hcd_init(0) );
#endif
-#ifdef CFG_TUSB_DEVICE
+#ifdef TUSB_CFG_DEVICE
ASSERT_ERROR( dcd_init(0) );
#endif
diff --git a/tinyusb/tusb.h b/tinyusb/tusb.h
index 2bfefbd9..a706e9c3 100644
--- a/tinyusb/tusb.h
+++ b/tinyusb/tusb.h
@@ -50,19 +50,19 @@
#include "common/common.h"
-#ifdef CFG_TUSB_HOST
+#ifdef TUSB_CFG_HOST
#include "host/hcd.h"
#endif
-#ifdef CFG_TUSB_DEVICE
+#ifdef TUSB_CFG_DEVICE
#include "device/dcd.h"
#endif
-#if TUSB_CLASS_HID
+#if DEVICE_CLASS_HID
#include "class/hid.h"
#endif
-#ifdef CFG_CLASS_CDC
+#ifdef TUSB_CFG_DEVICE_CDC
#include "class/cdc.h"
#endif
diff --git a/tinyusb/tusb_cfg.h b/tinyusb/tusb_cfg.h
index d36cddb2..c3841d3d 100644
--- a/tinyusb/tusb_cfg.h
+++ b/tinyusb/tusb_cfg.h
@@ -59,27 +59,27 @@
#endif
/// 0: no debug infor 3: most debug infor provided
-#ifndef CFG_TUSB_DEBUG_LEVEL
-#define CFG_TUSB_DEBUG_LEVEL 3
+#ifndef TUSB_CFG_DEBUG
+#define TUSB_CFG_DEBUG 3
#endif
/// Enable Host Support
-#define CFG_TUSB_HOST
+//#define TUSB_CFG_HOST
/// Enable Device Support
-//#define CFG_TUSB_DEVICE
+#define TUSB_CFG_DEVICE
/// Enable CDC Support
-#define CFG_CLASS_CDC
+#define TUSB_CFG_DEVICE_CDC
/// Enable HID Keyboard support
-#define CFG_CLASS_HID_KEYBOARD
+#define TUSB_CFG_DEVICE_HID_KEYBOARD
/// Enable HID Mouse support
-#define CFG_CLASS_HID_MOUSE
+#define TUSB_CFG_DEVICE_HID_MOUSE
-#define TUSB_CLASS_HID ( (defined CFG_CLASS_HID_KEYBOARD) || (defined CFG_CLASS_HID_MOUSE) )
-#define TUSB_EHCI
+#define DEVICE_CLASS_HID ( (defined TUSB_CFG_DEVICE_HID_KEYBOARD) || (defined TUSB_CFG_DEVICE_HID_MOUSE) )
+#define HOST_EHCI