Merge pull request #263 from adafruit/develop
Update bootloader binaries to 0.2.11 for metro nrf52840 support
This commit is contained in:
68 files changed
+7048
-7188
No files matched your search
@@ -11,6 +11,7 @@ git:
|
||||
before_install:
|
||||
# - source <(curl -SLs https://raw.githubusercontent.com/hathach/travis-ci-arduino/test-nrf52/install.sh)
|
||||
script:
|
||||
- echo "test travis"
|
||||
# - build_platform adafruit:nrf52:feather52840
|
||||
|
||||
notifications:
|
||||
|
||||
+68
-88
@@ -16,13 +16,13 @@
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
menu.softdevice=Bootloader Version
|
||||
menu.debug=Debug Mode
|
||||
menu.softdevice=Bootloader
|
||||
menu.debug=Debug
|
||||
|
||||
#**********************************************
|
||||
# Bluefruit Feather nRF52832 Board
|
||||
#**********************************************
|
||||
feather52832.name=Adafruit Bluefruit nRF52832 Feather
|
||||
# ----------------------------------
|
||||
# Bluefruit Feather nRF52832
|
||||
# ----------------------------------
|
||||
feather52832.name=Adafruit Bluefruit Feather nRF52832
|
||||
feather52832.bootloader.tool=bootburn
|
||||
|
||||
# Upload
|
||||
@@ -31,6 +31,8 @@ feather52832.upload.protocol=nrfutil
|
||||
feather52832.upload.use_1200bps_touch=false
|
||||
feather52832.upload.wait_for_upload_port=false
|
||||
feather52832.upload.native_usb=false
|
||||
feather52832.upload.maximum_size=290816
|
||||
feather52832.upload.maximum_data_size=51072
|
||||
|
||||
# Build
|
||||
feather52832.build.mcu=cortex-m4
|
||||
@@ -39,58 +41,47 @@ feather52832.build.board=NRF52832_FEATHER
|
||||
feather52832.build.core=nRF5
|
||||
feather52832.build.variant=feather_nrf52832
|
||||
feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52 -DARDUINO_NRF52_FEATHER
|
||||
feather52832.build.ldscript=nrf52832_s132_v6.ld
|
||||
|
||||
# SofDevice Menu
|
||||
# Ram & ROM size varies depending on SoftDevice (check linker script)
|
||||
|
||||
feather52832.menu.softdevice.s132v6=0.2.9 (s132 6.1.1)
|
||||
feather52832.menu.softdevice.s132v6.build.sd_flags=-DS132
|
||||
feather52832.menu.softdevice.s132v6=0.2.11 SoftDevice s132 6.1.1
|
||||
feather52832.menu.softdevice.s132v6.build.sd_name=s132
|
||||
feather52832.menu.softdevice.s132v6.build.sd_version=6.1.1
|
||||
feather52832.menu.softdevice.s132v6.build.sd_fwid=0x00B7
|
||||
feather52832.menu.softdevice.s132v6.build.ldscript=nrf52832_s132_v6.ld
|
||||
feather52832.menu.softdevice.s132v6.upload.maximum_size=290816
|
||||
feather52832.menu.softdevice.s132v6.upload.maximum_data_size=51072
|
||||
|
||||
# Debug Menu
|
||||
feather52832.menu.debug.l0=Level 0 (Release)
|
||||
feather52832.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 -Os
|
||||
feather52832.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
feather52832.menu.debug.l1=Level 1 (Error Message)
|
||||
feather52832.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 -Os
|
||||
feather52832.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
|
||||
feather52832.menu.debug.l2=Level 2 (Full Debug)
|
||||
feather52832.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 -Os
|
||||
feather52832.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
|
||||
feather52832.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
feather52832.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 -Os
|
||||
feather52832.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
|
||||
# ----------------------------------
|
||||
# Bluefruit Feather nRF52840 Express
|
||||
# ----------------------------------
|
||||
feather52840.name=Adafruit Bluefruit Feather nRF52840 Express
|
||||
|
||||
#**********************************************
|
||||
# Bluefruit Feather nRF52840 Express Board
|
||||
#**********************************************
|
||||
feather52840.name=Adafruit Bluefruit nRF52840 Feather Express
|
||||
|
||||
# DFU Mode with CDC + MSC (UF2)
|
||||
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
|
||||
feather52840.vid.0=0x239A
|
||||
feather52840.pid.0=0x0029
|
||||
|
||||
# DFU Mode with CDC only
|
||||
feather52840.pid.0=0x8029
|
||||
feather52840.vid.1=0x239A
|
||||
feather52840.pid.1=0x002A
|
||||
|
||||
# Arduino Application
|
||||
feather52840.pid.1=0x0029
|
||||
feather52840.vid.2=0x239A
|
||||
feather52840.pid.2=0x8029
|
||||
|
||||
# CircuitPython
|
||||
feather52840.pid.2=0x002A
|
||||
feather52840.vid.3=0x239A
|
||||
feather52840.pid.3=0x802A
|
||||
|
||||
feather52840.bootloader.tool=bootburn
|
||||
|
||||
# Upload
|
||||
feather52840.bootloader.tool=bootburn
|
||||
feather52840.upload.tool=nrfutil
|
||||
feather52840.upload.protocol=nrfutil
|
||||
feather52840.upload.use_1200bps_touch=true
|
||||
feather52840.upload.wait_for_upload_port=true
|
||||
feather52840.upload.maximum_size=815104
|
||||
feather52840.upload.maximum_data_size=248832
|
||||
|
||||
# Build
|
||||
feather52840.build.mcu=cortex-m4
|
||||
@@ -98,57 +89,50 @@ feather52840.build.f_cpu=64000000
|
||||
feather52840.build.board=NRF52840_FEATHER
|
||||
feather52840.build.core=nRF5
|
||||
feather52840.build.variant=feather_nrf52840_express
|
||||
feather52840.build.extra_flags=-DNRF52840_XXAA -DARDUINO_NRF52_FEATHER
|
||||
feather52840.build.extra_flags=-DNRF52840_XXAA -DARDUINO_NRF52_FEATHER {build.flags.usb}
|
||||
feather52840.build.ldscript=nrf52840_s140_v6.ld
|
||||
feather52840.build.vid=0x239A
|
||||
feather52840.build.pid=0x8029
|
||||
|
||||
# SofDevice Menu
|
||||
# Ram & ROM size varies depending on SoftDevice (check linker script)
|
||||
|
||||
feather52840.menu.softdevice.s140v6=0.2.9 (s140 6.1.1)
|
||||
feather52840.menu.softdevice.s140v6.build.sd_flags=-DS140
|
||||
feather52840.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1
|
||||
feather52840.menu.softdevice.s140v6.build.sd_name=s140
|
||||
feather52840.menu.softdevice.s140v6.build.sd_version=6.1.1
|
||||
feather52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6
|
||||
feather52840.menu.softdevice.s140v6.build.ldscript=nrf52840_s140_v6.ld
|
||||
feather52840.menu.softdevice.s140v6.upload.maximum_size=815104
|
||||
feather52840.menu.softdevice.s140v6.upload.maximum_data_size=248832
|
||||
|
||||
# Debug Menu
|
||||
feather52840.menu.debug.l0=Level 0 (Release)
|
||||
feather52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 -Os
|
||||
feather52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
feather52840.menu.debug.l1=Level 1 (Error Message)
|
||||
feather52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 -Os
|
||||
feather52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
|
||||
feather52840.menu.debug.l2=Level 2 (Full Debug)
|
||||
feather52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 -Os
|
||||
feather52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
|
||||
feather52840.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 -Os
|
||||
feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
|
||||
#**********************************************
|
||||
# Bluefruit Metro nRF52840 Express Board
|
||||
#**********************************************
|
||||
metro52840.name=Adafruit Bluefruit nRF52840 Metro Express
|
||||
metro52840.bootloader.tool=bootburn
|
||||
# ----------------------------------
|
||||
# Bluefruit Metro nRF52840 Express
|
||||
# ----------------------------------
|
||||
metro52840.name=Adafruit Bluefruit Metro nRF52840 Express
|
||||
|
||||
# DFU Mode with CDC + MSC (UF2)
|
||||
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
|
||||
metro52840.vid.0=0x239A
|
||||
metro52840.pid.0=0x003F
|
||||
|
||||
# DFU Mode with CDC only
|
||||
metro52840.pid.0=0x803F
|
||||
metro52840.vid.1=0x239A
|
||||
metro52840.pid.1=0x0040
|
||||
|
||||
# Arduino Application
|
||||
metro52840.pid.1=0x003F
|
||||
metro52840.vid.2=0x239A
|
||||
metro52840.pid.2=0x803F
|
||||
|
||||
# CircuitPython
|
||||
metro52840.pid.2=0x0040
|
||||
metro52840.vid.3=0x239A
|
||||
metro52840.pid.3=0x8040
|
||||
|
||||
# Upload
|
||||
metro52840.bootloader.tool=bootburn
|
||||
metro52840.upload.tool=nrfutil
|
||||
metro52840.upload.protocol=nrfutil
|
||||
metro52840.upload.use_1200bps_touch=true
|
||||
metro52840.upload.wait_for_upload_port=true
|
||||
metro52840.upload.maximum_size=815104
|
||||
metro52840.upload.maximum_data_size=248832
|
||||
|
||||
# Build
|
||||
metro52840.build.mcu=cortex-m4
|
||||
@@ -156,34 +140,31 @@ metro52840.build.f_cpu=64000000
|
||||
metro52840.build.board=NRF52840_METRO
|
||||
metro52840.build.core=nRF5
|
||||
metro52840.build.variant=metro_nrf52840_express
|
||||
metro52840.build.extra_flags=-DNRF52840_XXAA -DARDUINO_NRF52_FEATHER
|
||||
metro52840.build.extra_flags=-DNRF52840_XXAA -DARDUINO_NRF52_FEATHER {build.flags.usb}
|
||||
metro52840.build.ldscript=nrf52840_s140_v6.ld
|
||||
metro52840.build.vid=0x239A
|
||||
metro52840.build.pid=0x803F
|
||||
|
||||
# SofDevice Menu
|
||||
# Ram & ROM size varies depending on SoftDevice (check linker script)
|
||||
|
||||
metro52840.menu.softdevice.s140v6=0.2.9 (s140 6.1.1)
|
||||
metro52840.menu.softdevice.s140v6.build.sd_flags=-DS140
|
||||
metro52840.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1
|
||||
metro52840.menu.softdevice.s140v6.build.sd_name=s140
|
||||
metro52840.menu.softdevice.s140v6.build.sd_version=6.1.1
|
||||
metro52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6
|
||||
metro52840.menu.softdevice.s140v6.build.ldscript=nrf52840_s140_v6.ld
|
||||
metro52840.menu.softdevice.s140v6.upload.maximum_size=815104
|
||||
metro52840.menu.softdevice.s140v6.upload.maximum_data_size=248832
|
||||
|
||||
# Debug Menu
|
||||
metro52840.menu.debug.l0=Level 0 (Release)
|
||||
metro52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 -Os
|
||||
metro52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
metro52840.menu.debug.l1=Level 1 (Error Message)
|
||||
metro52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 -Os
|
||||
metro52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
|
||||
metro52840.menu.debug.l2=Level 2 (Full Debug)
|
||||
metro52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 -Os
|
||||
metro52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
|
||||
metro52840.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 -Os
|
||||
metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
|
||||
#**********************************************
|
||||
# ----------------------------------
|
||||
# Nordic nRF52840DK (PCA10056)
|
||||
#**********************************************
|
||||
pca10056.name=Adafruit Bluefruit on nRF52840DK PCA10056
|
||||
# ----------------------------------
|
||||
pca10056.name=Noridc nRF52840DK (PCA10056)
|
||||
pca10056.bootloader.tool=bootburn
|
||||
|
||||
# Upload
|
||||
@@ -191,6 +172,8 @@ pca10056.upload.tool=nrfutil
|
||||
pca10056.upload.protocol=nrfutil
|
||||
pca10056.upload.use_1200bps_touch=true
|
||||
pca10056.upload.wait_for_upload_port=true
|
||||
pca10056.upload.maximum_size=815104
|
||||
pca10056.upload.maximum_data_size=248832
|
||||
|
||||
# Build
|
||||
pca10056.build.mcu=cortex-m4
|
||||
@@ -198,26 +181,23 @@ pca10056.build.f_cpu=64000000
|
||||
pca10056.build.board=NRF52840_PCA10056
|
||||
pca10056.build.core=nRF5
|
||||
pca10056.build.variant=pca10056
|
||||
pca10056.build.extra_flags=-DNRF52840_XXAA
|
||||
pca10056.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
|
||||
pca10056.build.ldscript=nrf52840_s140_v6.ld
|
||||
pca10056.build.vid=0x239A
|
||||
pca10056.build.pid=0x8029
|
||||
|
||||
# SofDevice Menu
|
||||
# Ram & ROM size varies depending on SoftDevice (check linker script)
|
||||
|
||||
pca10056.menu.softdevice.s140v6=0.2.9 (s140 6.1.1)
|
||||
pca10056.menu.softdevice.s140v6.build.sd_flags=-DS140
|
||||
pca10056.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1
|
||||
pca10056.menu.softdevice.s140v6.build.sd_name=s140
|
||||
pca10056.menu.softdevice.s140v6.build.sd_version=6.1.1
|
||||
pca10056.menu.softdevice.s140v6.build.sd_fwid=0x00B6
|
||||
pca10056.menu.softdevice.s140v6.build.ldscript=nrf52840_s140_v6.ld
|
||||
pca10056.menu.softdevice.s140v6.upload.maximum_size=815104
|
||||
pca10056.menu.softdevice.s140v6.upload.maximum_data_size=248832
|
||||
|
||||
# Debug Menu
|
||||
pca10056.menu.debug.l0=Level 0 (Release)
|
||||
pca10056.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 -Os
|
||||
pca10056.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
pca10056.menu.debug.l1=Level 1 (Error Message)
|
||||
pca10056.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 -Os
|
||||
pca10056.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
|
||||
pca10056.menu.debug.l2=Level 2 (Full Debug)
|
||||
pca10056.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 -Os
|
||||
pca10056.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
|
||||
pca10056.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
pca10056.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 -Os
|
||||
pca10056.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
+1231
-1375
File diff suppressed because it is too large.
Load diff
BIN
Binary file not shown.
+1794
-1788
File diff suppressed because it is too large.
Load diff
BIN
Binary file not shown.
+1790
-1786
File diff suppressed because it is too large.
Load diff
BIN
Binary file not shown.
+1770
-1761
File diff suppressed because it is too large.
Load diff
BIN
Binary file not shown.
@@ -2,6 +2,13 @@
|
||||
|
||||
# 0.10.5
|
||||
|
||||
- Fixed Feather nRF52840 Express's qspi driver to work with on-board flash device
|
||||
- Rework USB driver using Adafruit_TinyUSB library
|
||||
- Added Metro nRF52840 Express
|
||||
- Update bootloader binaries to 0.2.11
|
||||
|
||||
# 0.10.1
|
||||
|
||||
This release added multiple concurrent peripheral connections support, allow Bluefruit device to multiple central (phones/PC) simultaneously. It introduces new BLE class: BLEPeriph, BLEConnection, remove BLEGap, refactor/rename/move functions and callbacks.
|
||||
|
||||
- Fixed Servo detach issue
|
||||
|
||||
+21
-18
@@ -21,7 +21,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#ifdef NRF52840_XXAA
|
||||
#ifdef USBCON
|
||||
|
||||
#include "nrfx.h"
|
||||
#include "nrfx_power.h"
|
||||
@@ -38,22 +38,10 @@
|
||||
// Serial is 64-bit DeviceID -> 16 chars len
|
||||
uint16_t usb_desc_str_serial[1+16] = { TUD_DESC_STR_HEADER(16) };
|
||||
|
||||
/* tinyusb function that handles power event (detected, ready, removed)
|
||||
* We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled. */
|
||||
// tinyusb function that handles power event (detected, ready, removed)
|
||||
// We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled.
|
||||
extern "C" void tusb_hal_nrf_power_event(uint32_t event);
|
||||
|
||||
void usb_init(void);
|
||||
|
||||
void Adafruit_TinyUSB_Core_init(void)
|
||||
{
|
||||
USBDevice.addInterface( (Adafruit_USBD_Interface&) Serial);
|
||||
USBDevice.setID(USB_VID, USB_PID);
|
||||
USBDevice.begin();
|
||||
|
||||
usb_init();
|
||||
}
|
||||
|
||||
|
||||
// USB Device Driver task
|
||||
// This top level thread process all usb events and invoke callbacks
|
||||
static void usb_device_task(void* param)
|
||||
@@ -68,8 +56,8 @@ static void usb_device_task(void* param)
|
||||
}
|
||||
}
|
||||
|
||||
// Init usb when starting up. Softdevice is not enabled yet
|
||||
void usb_init(void)
|
||||
// Init usb hardware when starting up. Softdevice is not enabled yet
|
||||
static void usb_hardware_init(void)
|
||||
{
|
||||
// Power module init
|
||||
const nrfx_power_config_t pwr_cfg = { 0 };
|
||||
@@ -91,8 +79,10 @@ void usb_init(void)
|
||||
|
||||
if ( usb_reg & POWER_USBREGSTATUS_VBUSDETECT_Msk ) tusb_hal_nrf_power_event(NRFX_POWER_USB_EVT_DETECTED);
|
||||
if ( usb_reg & POWER_USBREGSTATUS_OUTPUTRDY_Msk ) tusb_hal_nrf_power_event(NRFX_POWER_USB_EVT_READY);
|
||||
}
|
||||
|
||||
// Create Serial string descriptor
|
||||
static void load_serial_number(void)
|
||||
{
|
||||
char tmp_serial[17];
|
||||
sprintf(tmp_serial, "%08lX%08lX", NRF_FICR->DEVICEID[1], NRF_FICR->DEVICEID[0]);
|
||||
|
||||
@@ -101,6 +91,19 @@ void usb_init(void)
|
||||
usb_desc_str_serial[1+i] = tmp_serial[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Adafruit_TinyUSB_Core_init(void)
|
||||
{
|
||||
// Create Serial string descriptor
|
||||
load_serial_number();
|
||||
|
||||
USBDevice.addInterface( (Adafruit_USBD_Interface&) Serial);
|
||||
USBDevice.setID(USB_VID, USB_PID);
|
||||
USBDevice.begin();
|
||||
|
||||
usb_hardware_init();
|
||||
|
||||
// Init tinyusb stack
|
||||
tusb_init();
|
||||
|
||||
+1
@@ -32,6 +32,7 @@
|
||||
#include "Adafruit_USBD_CDC.h"
|
||||
#endif
|
||||
|
||||
// Called by main.cpp to initialize usb device typically with CDC device for Serial
|
||||
void Adafruit_TinyUSB_Core_init(void);
|
||||
|
||||
#endif /* ADAFRUIT_TINYUSB_CORE_H_ */
|
||||
+2
-2
@@ -22,7 +22,7 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
#ifdef USBCON
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "Adafruit_USBD_CDC.h"
|
||||
@@ -137,4 +137,4 @@ void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts)
|
||||
|
||||
}
|
||||
|
||||
#endif // NRF52840_XXAA
|
||||
#endif // USBCON
|
||||
File renamed without changes.
+1
-1
@@ -22,7 +22,7 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
#ifdef USBCON
|
||||
|
||||
#include "Adafruit_USBD_Device.h"
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+4
-6
@@ -71,7 +71,7 @@ typedef struct
|
||||
//--------------------------------------------------------------------+
|
||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||
//--------------------------------------------------------------------+
|
||||
CFG_TUSB_MEM_SECTION static cdcd_interface_t _cdcd_itf[CFG_TUD_CDC] = { { 0 } };
|
||||
CFG_TUSB_MEM_SECTION static cdcd_interface_t _cdcd_itf[CFG_TUD_CDC];
|
||||
|
||||
// TODO will be replaced by dcd_edpt_busy()
|
||||
bool pending_read_from_host;
|
||||
@@ -289,14 +289,12 @@ bool cdcd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t
|
||||
(TUSB_CLASS_CDC_DATA == ((tusb_desc_interface_t const *) p_desc)->bInterfaceClass) )
|
||||
{
|
||||
// next to endpoint descriptor
|
||||
(*p_length) += tu_desc_len(p_desc);
|
||||
p_desc = tu_desc_next(p_desc);
|
||||
|
||||
// Open endpoint pair with usbd helper
|
||||
tusb_desc_endpoint_t const *p_desc_ep = (tusb_desc_endpoint_t const *) p_desc;
|
||||
TU_ASSERT( usbd_open_edpt_pair(rhport, p_desc_ep, TUSB_XFER_BULK, &p_cdc->ep_out, &p_cdc->ep_in) );
|
||||
// Open endpoint pair
|
||||
TU_ASSERT( usbd_open_edpt_pair(rhport, p_desc, 2, TUSB_XFER_BULK, &p_cdc->ep_out, &p_cdc->ep_in) );
|
||||
|
||||
(*p_length) += 2*sizeof(tusb_desc_endpoint_t);
|
||||
(*p_length) += sizeof(tusb_desc_interface_t) + 2*sizeof(tusb_desc_endpoint_t);
|
||||
}
|
||||
|
||||
// Prepare for incoming data
|
||||
+8
@@ -89,9 +89,17 @@ static inline bool tud_cdc_write_flush (void)
|
||||
//--------------------------------------------------------------------+
|
||||
// APPLICATION CALLBACK API (WEAK is optional)
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Invoked when received new data
|
||||
ATTR_WEAK void tud_cdc_rx_cb(uint8_t itf);
|
||||
|
||||
// Invoked when received `wanted_char`
|
||||
ATTR_WEAK void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char);
|
||||
|
||||
// Invoked when line state DTR & RTS are changed via SET_CONTROL_LINE_STATE
|
||||
ATTR_WEAK void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts);
|
||||
|
||||
// Invoked when line coding is change via SET_LINE_CODING
|
||||
ATTR_WEAK void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* p_line_coding);
|
||||
|
||||
/** @} */
|
||||
File renamed without changes.
File renamed without changes.
+56
-55
@@ -43,6 +43,20 @@
|
||||
/** \defgroup ClassDriver_HID_Common Common Definitions
|
||||
* @{ */
|
||||
|
||||
/// USB HID Descriptor
|
||||
typedef struct ATTR_PACKED
|
||||
{
|
||||
uint8_t bLength; /**< Numeric expression that is the total size of the HID descriptor */
|
||||
uint8_t bDescriptorType; /**< Constant name specifying type of HID descriptor. */
|
||||
|
||||
uint16_t bcdHID; /**< Numeric expression identifying the HID Class Specification release */
|
||||
uint8_t bCountryCode; /**< Numeric expression identifying country code of the localized hardware. */
|
||||
uint8_t bNumDescriptors; /**< Numeric expression specifying the number of class descriptors */
|
||||
|
||||
uint8_t bReportType; /**< Type of HID class report. */
|
||||
uint16_t wReportLength; /**< the total size of the Report descriptor. */
|
||||
} tusb_hid_descriptor_hid_t;
|
||||
|
||||
/// HID Subclass
|
||||
typedef enum
|
||||
{
|
||||
@@ -69,9 +83,10 @@ typedef enum
|
||||
/// HID Request Report Type
|
||||
typedef enum
|
||||
{
|
||||
HID_REPORT_TYPE_INPUT = 1, ///< Input
|
||||
HID_REPORT_TYPE_OUTPUT, ///< Output
|
||||
HID_REPORT_TYPE_FEATURE ///< Feature
|
||||
HID_REPORT_TYPE_INVALID = 0,
|
||||
HID_REPORT_TYPE_INPUT, ///< Input
|
||||
HID_REPORT_TYPE_OUTPUT, ///< Output
|
||||
HID_REPORT_TYPE_FEATURE ///< Feature
|
||||
}hid_report_type_t;
|
||||
|
||||
/// HID Class Specific Control Request
|
||||
@@ -85,59 +100,45 @@ typedef enum
|
||||
HID_REQ_CONTROL_SET_PROTOCOL = 0x0b ///< Set Protocol
|
||||
}hid_request_type_t;
|
||||
|
||||
/// USB HID Descriptor
|
||||
typedef struct ATTR_PACKED
|
||||
{
|
||||
uint8_t bLength; /**< Numeric expression that is the total size of the HID descriptor */
|
||||
uint8_t bDescriptorType; /**< Constant name specifying type of HID descriptor. */
|
||||
|
||||
uint16_t bcdHID; /**< Numeric expression identifying the HID Class Specification release */
|
||||
uint8_t bCountryCode; /**< Numeric expression identifying country code of the localized hardware. */
|
||||
uint8_t bNumDescriptors; /**< Numeric expression specifying the number of class descriptors */
|
||||
|
||||
uint8_t bReportType; /**< Type of HID class report. */
|
||||
uint16_t wReportLength; /**< the total size of the Report descriptor. */
|
||||
} tusb_hid_descriptor_hid_t;
|
||||
|
||||
/// HID Country Code
|
||||
typedef enum
|
||||
{
|
||||
HID_Local_NotSupported = 0 , ///< NotSupported
|
||||
HID_Local_Arabic , ///< Arabic
|
||||
HID_Local_Belgian , ///< Belgian
|
||||
HID_Local_Canadian_Bilingual , ///< Canadian_Bilingual
|
||||
HID_Local_Canadian_French , ///< Canadian_French
|
||||
HID_Local_Czech_Republic , ///< Czech_Republic
|
||||
HID_Local_Danish , ///< Danish
|
||||
HID_Local_Finnish , ///< Finnish
|
||||
HID_Local_French , ///< French
|
||||
HID_Local_German , ///< German
|
||||
HID_Local_Greek , ///< Greek
|
||||
HID_Local_Hebrew , ///< Hebrew
|
||||
HID_Local_Hungary , ///< Hungary
|
||||
HID_Local_International , ///< International
|
||||
HID_Local_Italian , ///< Italian
|
||||
HID_Local_Japan_Katakana , ///< Japan_Katakana
|
||||
HID_Local_Korean , ///< Korean
|
||||
HID_Local_Latin_American , ///< Latin_American
|
||||
HID_Local_Netherlands_Dutch , ///< Netherlands/Dutch
|
||||
HID_Local_Norwegian , ///< Norwegian
|
||||
HID_Local_Persian_Farsi , ///< Persian (Farsi)
|
||||
HID_Local_Poland , ///< Poland
|
||||
HID_Local_Portuguese , ///< Portuguese
|
||||
HID_Local_Russia , ///< Russia
|
||||
HID_Local_Slovakia , ///< Slovakia
|
||||
HID_Local_Spanish , ///< Spanish
|
||||
HID_Local_Swedish , ///< Swedish
|
||||
HID_Local_Swiss_French , ///< Swiss/French
|
||||
HID_Local_Swiss_German , ///< Swiss/German
|
||||
HID_Local_Switzerland , ///< Switzerland
|
||||
HID_Local_Taiwan , ///< Taiwan
|
||||
HID_Local_Turkish_Q , ///< Turkish-Q
|
||||
HID_Local_UK , ///< UK
|
||||
HID_Local_US , ///< US
|
||||
HID_Local_Yugoslavia , ///< Yugoslavia
|
||||
HID_Local_Turkish_F ///< Turkish-F
|
||||
HID_LOCAL_NotSupported = 0 , ///< NotSupported
|
||||
HID_LOCAL_Arabic , ///< Arabic
|
||||
HID_LOCAL_Belgian , ///< Belgian
|
||||
HID_LOCAL_Canadian_Bilingual , ///< Canadian_Bilingual
|
||||
HID_LOCAL_Canadian_French , ///< Canadian_French
|
||||
HID_LOCAL_Czech_Republic , ///< Czech_Republic
|
||||
HID_LOCAL_Danish , ///< Danish
|
||||
HID_LOCAL_Finnish , ///< Finnish
|
||||
HID_LOCAL_French , ///< French
|
||||
HID_LOCAL_German , ///< German
|
||||
HID_LOCAL_Greek , ///< Greek
|
||||
HID_LOCAL_Hebrew , ///< Hebrew
|
||||
HID_LOCAL_Hungary , ///< Hungary
|
||||
HID_LOCAL_International , ///< International
|
||||
HID_LOCAL_Italian , ///< Italian
|
||||
HID_LOCAL_Japan_Katakana , ///< Japan_Katakana
|
||||
HID_LOCAL_Korean , ///< Korean
|
||||
HID_LOCAL_Latin_American , ///< Latin_American
|
||||
HID_LOCAL_Netherlands_Dutch , ///< Netherlands/Dutch
|
||||
HID_LOCAL_Norwegian , ///< Norwegian
|
||||
HID_LOCAL_Persian_Farsi , ///< Persian (Farsi)
|
||||
HID_LOCAL_Poland , ///< Poland
|
||||
HID_LOCAL_Portuguese , ///< Portuguese
|
||||
HID_LOCAL_Russia , ///< Russia
|
||||
HID_LOCAL_Slovakia , ///< Slovakia
|
||||
HID_LOCAL_Spanish , ///< Spanish
|
||||
HID_LOCAL_Swedish , ///< Swedish
|
||||
HID_LOCAL_Swiss_French , ///< Swiss/French
|
||||
HID_LOCAL_Swiss_German , ///< Swiss/German
|
||||
HID_LOCAL_Switzerland , ///< Switzerland
|
||||
HID_LOCAL_Taiwan , ///< Taiwan
|
||||
HID_LOCAL_Turkish_Q , ///< Turkish-Q
|
||||
HID_LOCAL_UK , ///< UK
|
||||
HID_LOCAL_US , ///< US
|
||||
HID_LOCAL_Yugoslavia , ///< Yugoslavia
|
||||
HID_LOCAL_Turkish_F ///< Turkish-F
|
||||
} hid_country_code_t;
|
||||
|
||||
/** @} */
|
||||
@@ -155,7 +156,7 @@ typedef struct ATTR_PACKED
|
||||
int8_t x; /**< Current delta x movement of the mouse. */
|
||||
int8_t y; /**< Current delta y movement on the mouse. */
|
||||
int8_t wheel; /**< Current delta wheel movement on the mouse. */
|
||||
// int8_t pan;
|
||||
int8_t pan; // using AC Pan
|
||||
} hid_mouse_report_t;
|
||||
|
||||
/// Standard Mouse Buttons Bitmap
|
||||
@@ -461,7 +462,7 @@ enum {
|
||||
HID_USAGE_PAGE_MSR = 0x8e,
|
||||
HID_USAGE_PAGE_CAMERA = 0x90,
|
||||
HID_USAGE_PAGE_ARCADE = 0x91,
|
||||
HID_USAGE_PAGE_VENDOR = 0xFFFF // 0xFF00 - 0xFFFF
|
||||
HID_USAGE_PAGE_VENDOR = 0xFF00 // 0xFF00 - 0xFFFF
|
||||
};
|
||||
|
||||
/// HID Usage Table - Table 6: Generic Desktop Page
|
||||
+45
-61
@@ -38,24 +38,19 @@
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO CONSTANT TYPEDEF
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
#ifndef CFG_TUD_HID_BUFSIZE
|
||||
#define CFG_TUD_HID_BUFSIZE 16
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t itf_num;
|
||||
uint8_t ep_in;
|
||||
uint8_t ep_out; // optional Out endpoint
|
||||
uint8_t boot_protocol; // Boot mouse or keyboard
|
||||
bool boot_mode;
|
||||
|
||||
bool boot_mode; // default = false (Report)
|
||||
uint8_t idle_rate; // up to application to handle idle rate
|
||||
uint16_t reprot_desc_len;
|
||||
uint8_t idle_rate; // Idle Rate = 0 : only send report if there is changes, i.e skip duplication
|
||||
// Idle Rate > 0 : skip duplication, but send at least 1 report every idle rate (in unit of 4 ms).
|
||||
uint8_t mouse_button; // caching button for using with tud_hid_mouse_ API
|
||||
|
||||
CFG_TUSB_MEM_ALIGN uint8_t report_buf[CFG_TUD_HID_BUFSIZE];
|
||||
CFG_TUSB_MEM_ALIGN uint8_t epin_buf[CFG_TUD_HID_BUFSIZE];
|
||||
CFG_TUSB_MEM_ALIGN uint8_t epout_buf[CFG_TUD_HID_BUFSIZE];
|
||||
|
||||
}hidd_interface_t;
|
||||
|
||||
CFG_TUSB_MEM_SECTION static hidd_interface_t _hidd_itf[CFG_TUD_HID];
|
||||
@@ -91,15 +86,15 @@ bool tud_hid_report(uint8_t report_id, void const* report, uint8_t len)
|
||||
// If report id = 0, skip ID field
|
||||
if (report_id)
|
||||
{
|
||||
p_hid->report_buf[0] = report_id;
|
||||
memcpy(p_hid->report_buf+1, report, len);
|
||||
p_hid->epin_buf[0] = report_id;
|
||||
memcpy(p_hid->epin_buf+1, report, len);
|
||||
len++;
|
||||
}else
|
||||
{
|
||||
memcpy(p_hid->report_buf, report, len);
|
||||
memcpy(p_hid->epin_buf, report, len);
|
||||
}
|
||||
|
||||
// TODO skip duplication ? and or idle rate
|
||||
return dcd_edpt_xfer(TUD_OPT_RHPORT, p_hid->ep_in, p_hid->report_buf, len + (report_id ? 1 : 0) );
|
||||
return dcd_edpt_xfer(TUD_OPT_RHPORT, p_hid->ep_in, p_hid->epin_buf, len);
|
||||
}
|
||||
|
||||
bool tud_hid_boot_mode(void)
|
||||
@@ -125,47 +120,26 @@ bool tud_hid_keyboard_report(uint8_t report_id, uint8_t modifier, uint8_t keycod
|
||||
tu_memclr(report.keycode, 6);
|
||||
}
|
||||
|
||||
// TODO skip duplication ? and or idle rate
|
||||
return tud_hid_report(report_id, &report, sizeof(report));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MOUSE APPLICATION API
|
||||
//--------------------------------------------------------------------+
|
||||
bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8_t x, int8_t y, int8_t scroll, int8_t pan)
|
||||
bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8_t x, int8_t y, int8_t vertical, int8_t horizontal)
|
||||
{
|
||||
(void) pan;
|
||||
hid_mouse_report_t report =
|
||||
{
|
||||
.buttons = buttons,
|
||||
.x = x,
|
||||
.y = y,
|
||||
.wheel = scroll,
|
||||
//.pan = pan
|
||||
.wheel = vertical,
|
||||
.pan = horizontal
|
||||
};
|
||||
|
||||
uint8_t itf = 0;
|
||||
_hidd_itf[itf].mouse_button = buttons;
|
||||
|
||||
return tud_hid_report(report_id, &report, sizeof(report));
|
||||
}
|
||||
|
||||
bool tud_hid_mouse_move(uint8_t report_id, int8_t x, int8_t y)
|
||||
{
|
||||
uint8_t itf = 0;
|
||||
uint8_t const button = _hidd_itf[itf].mouse_button;
|
||||
|
||||
return tud_hid_mouse_report(report_id, button, x, y, 0, 0);
|
||||
}
|
||||
|
||||
bool tud_hid_mouse_scroll(uint8_t report_id, int8_t scroll, int8_t pan)
|
||||
{
|
||||
uint8_t itf = 0;
|
||||
uint8_t const button = _hidd_itf[itf].mouse_button;
|
||||
|
||||
return tud_hid_mouse_report(report_id, button, 0, 0, scroll, pan);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USBD-CLASS API
|
||||
//--------------------------------------------------------------------+
|
||||
@@ -184,6 +158,10 @@ bool hidd_open(uint8_t rhport, tusb_desc_interface_t const * desc_itf, uint16_t
|
||||
{
|
||||
uint8_t const *p_desc = (uint8_t const *) desc_itf;
|
||||
|
||||
// TODO support multiple HID interface
|
||||
uint8_t const itf = 0;
|
||||
hidd_interface_t * p_hid = &_hidd_itf[itf];
|
||||
|
||||
//------------- HID descriptor -------------//
|
||||
p_desc = tu_desc_next(p_desc);
|
||||
tusb_hid_descriptor_hid_t const *desc_hid = (tusb_hid_descriptor_hid_t const *) p_desc;
|
||||
@@ -191,24 +169,19 @@ bool hidd_open(uint8_t rhport, tusb_desc_interface_t const * desc_itf, uint16_t
|
||||
|
||||
//------------- Endpoint Descriptor -------------//
|
||||
p_desc = tu_desc_next(p_desc);
|
||||
tusb_desc_endpoint_t const *desc_edpt = (tusb_desc_endpoint_t const *) p_desc;
|
||||
TU_ASSERT(TUSB_DESC_ENDPOINT == desc_edpt->bDescriptorType);
|
||||
|
||||
TU_ASSERT(dcd_edpt_open(rhport, desc_edpt));
|
||||
|
||||
// TODO support multiple HID interface
|
||||
uint8_t itf = 0;
|
||||
hidd_interface_t * p_hid = &_hidd_itf[itf];
|
||||
TU_ASSERT(usbd_open_edpt_pair(rhport, p_desc, desc_itf->bNumEndpoints, TUSB_XFER_INTERRUPT, &p_hid->ep_out, &p_hid->ep_in));
|
||||
|
||||
if ( desc_itf->bInterfaceSubClass == HID_SUBCLASS_BOOT ) p_hid->boot_protocol = desc_itf->bInterfaceProtocol;
|
||||
|
||||
p_hid->boot_mode = false; // default mode is REPORT
|
||||
p_hid->itf_num = desc_itf->bInterfaceNumber;
|
||||
p_hid->ep_in = desc_edpt->bEndpointAddress;
|
||||
p_hid->reprot_desc_len = desc_hid->wReportLength;
|
||||
|
||||
*p_len = sizeof(tusb_desc_interface_t) + sizeof(tusb_hid_descriptor_hid_t) + desc_itf->bNumEndpoints*sizeof(tusb_desc_endpoint_t);
|
||||
|
||||
// Prepare for output endpoint
|
||||
if (p_hid->ep_out) TU_ASSERT(dcd_edpt_xfer(rhport, p_hid->ep_out, p_hid->epout_buf, sizeof(p_hid->epout_buf)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -245,20 +218,25 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * p_reque
|
||||
uint8_t const report_type = tu_u16_high(p_request->wValue);
|
||||
uint8_t const report_id = tu_u16_low(p_request->wValue);
|
||||
|
||||
uint16_t xferlen = tud_hid_get_report_cb(report_id, (hid_report_type_t) report_type, p_hid->report_buf, p_request->wLength);
|
||||
uint16_t xferlen = tud_hid_get_report_cb(report_id, (hid_report_type_t) report_type, p_hid->epin_buf, p_request->wLength);
|
||||
TU_ASSERT( xferlen > 0 );
|
||||
|
||||
usbd_control_xfer(rhport, p_request, p_hid->report_buf, xferlen);
|
||||
usbd_control_xfer(rhport, p_request, p_hid->epin_buf, xferlen);
|
||||
}
|
||||
break;
|
||||
|
||||
case HID_REQ_CONTROL_SET_REPORT:
|
||||
usbd_control_xfer(rhport, p_request, p_hid->report_buf, p_request->wLength);
|
||||
usbd_control_xfer(rhport, p_request, p_hid->epout_buf, p_request->wLength);
|
||||
break;
|
||||
|
||||
case HID_REQ_CONTROL_SET_IDLE:
|
||||
// TODO idle rate of report
|
||||
p_hid->idle_rate = tu_u16_high(p_request->wValue);
|
||||
if ( tud_hid_set_idle_cb )
|
||||
{
|
||||
// stall request if callback return false
|
||||
if ( !tud_hid_set_idle_cb(p_hid->idle_rate) ) return false;
|
||||
}
|
||||
|
||||
usbd_control_status(rhport, p_request);
|
||||
break;
|
||||
|
||||
@@ -277,7 +255,7 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * p_reque
|
||||
case HID_REQ_CONTROL_SET_PROTOCOL:
|
||||
p_hid->boot_mode = 1 - p_request->wValue; // 0 is Boot, 1 is Report protocol
|
||||
|
||||
if (tud_hid_mode_changed_cb) tud_hid_mode_changed_cb(p_hid->boot_mode);
|
||||
if (tud_hid_boot_mode_cb) tud_hid_boot_mode_cb(p_hid->boot_mode);
|
||||
|
||||
usbd_control_status(rhport, p_request);
|
||||
break;
|
||||
@@ -307,19 +285,25 @@ bool hidd_control_request_complete(uint8_t rhport, tusb_control_request_t const
|
||||
uint8_t const report_type = tu_u16_high(p_request->wValue);
|
||||
uint8_t const report_id = tu_u16_low(p_request->wValue);
|
||||
|
||||
tud_hid_set_report_cb(report_id, (hid_report_type_t) report_type, p_hid->report_buf, p_request->wLength);
|
||||
tud_hid_set_report_cb(report_id, (hid_report_type_t) report_type, p_hid->epout_buf, p_request->wLength);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hidd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes)
|
||||
bool hidd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes)
|
||||
{
|
||||
// nothing to do
|
||||
(void) rhport;
|
||||
(void) ep_addr;
|
||||
(void) event;
|
||||
(void) xferred_bytes;
|
||||
(void) result;
|
||||
|
||||
// TODO support multiple HID interface
|
||||
uint8_t const itf = 0;
|
||||
hidd_interface_t * p_hid = &_hidd_itf[itf];
|
||||
|
||||
if (ep_addr == p_hid->ep_out)
|
||||
{
|
||||
tud_hid_set_report_cb(0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, xferred_bytes);
|
||||
TU_ASSERT(dcd_edpt_xfer(rhport, p_hid->ep_out, p_hid->epout_buf, sizeof(p_hid->epout_buf)));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
+89
-65
@@ -39,6 +39,9 @@
|
||||
// Class Driver Default Configure & Validation
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
#ifndef CFG_TUD_HID_BUFSIZE
|
||||
#define CFG_TUD_HID_BUFSIZE 16
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Application API
|
||||
@@ -53,51 +56,34 @@ bool tud_hid_boot_mode(void);
|
||||
// Send report to host
|
||||
bool tud_hid_report(uint8_t report_id, void const* report, uint8_t len);
|
||||
|
||||
/*------------- Callbacks (Weak is optional) -------------*/
|
||||
// KEYBOARD: convenient helper to send keyboard report if application
|
||||
// use template layout report as defined by hid_keyboard_report_t
|
||||
bool tud_hid_keyboard_report(uint8_t report_id, uint8_t modifier, uint8_t keycode[6]);
|
||||
|
||||
// Invoked when receiving GET_REPORT control request
|
||||
// MOUSE: convenient helper to send mouse report if application
|
||||
// use template layout report as defined by hid_mouse_report_t
|
||||
bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8_t x, int8_t y, int8_t vertical, int8_t horizontal);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Callbacks (Weak is optional)
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Invoked when received GET_REPORT control request
|
||||
// Application must fill buffer report's content and return its length.
|
||||
// Return zero will cause the stack to STALL request
|
||||
ATTR_WEAK uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
|
||||
|
||||
// Invoked when receiving SET_REPORT control request
|
||||
// Invoked when received SET_REPORT control request or
|
||||
// received data on OUT endpoint ( Report ID = 0, Type = 0 )
|
||||
ATTR_WEAK void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
|
||||
|
||||
// Invoked when host switch mode Boot <-> Report via SET_PROTOCOL request
|
||||
ATTR_WEAK void tud_hid_mode_changed_cb(uint8_t boot_mode);
|
||||
// Invoked when received SET_PROTOCOL request ( mode switch Boot <-> Report )
|
||||
ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t boot_mode);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// KEYBOARD API
|
||||
// Convenient helper to send keyboard report if application use standard/boot
|
||||
// layout report as defined by hid_keyboard_report_t
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
bool tud_hid_keyboard_report(uint8_t report_id, uint8_t modifier, uint8_t keycode[6]);
|
||||
|
||||
static inline bool tud_hid_keyboard_key_release(uint8_t report_id)
|
||||
{
|
||||
return tud_hid_keyboard_report(report_id, 0, NULL);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MOUSE API
|
||||
// Convenient helper to send mouse report if application use standard/boot
|
||||
// layout report as defined by hid_mouse_report_t
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8_t x, int8_t y, int8_t scroll, int8_t pan);
|
||||
bool tud_hid_mouse_move(uint8_t report_id, int8_t x, int8_t y);
|
||||
bool tud_hid_mouse_scroll(uint8_t report_id, int8_t scroll, int8_t pan);
|
||||
|
||||
static inline bool tud_hid_mouse_button_press(uint8_t report_id, uint8_t buttons)
|
||||
{
|
||||
return tud_hid_mouse_report(report_id, buttons, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
static inline bool tud_hid_mouse_button_release(uint8_t report_id)
|
||||
{
|
||||
return tud_hid_mouse_report(report_id, 0, 0, 0, 0, 0);
|
||||
}
|
||||
// Invoked when received SET_IDLE request. return false will stall the request
|
||||
// - Idle Rate = 0 : only send report if there is changes, i.e skip duplication
|
||||
// - Idle Rate > 0 : skip duplication, but send at least 1 report every idle rate (in unit of 4 ms).
|
||||
ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t idle_rate);
|
||||
|
||||
/* --------------------------------------------------------------------+
|
||||
* HID Report Descriptor Template
|
||||
@@ -122,8 +108,9 @@ static inline bool tud_hid_mouse_button_release(uint8_t report_id)
|
||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
|
||||
HID_USAGE ( HID_USAGE_DESKTOP_KEYBOARD ) ,\
|
||||
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
|
||||
/* 8 bits Modifier Keys (Shfit, Control, Alt) */ \
|
||||
/* Report ID if any */\
|
||||
__VA_ARGS__ \
|
||||
/* 8 bits Modifier Keys (Shfit, Control, Alt) */ \
|
||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_KEYBOARD ) ,\
|
||||
HID_USAGE_MIN ( 224 ) ,\
|
||||
HID_USAGE_MAX ( 231 ) ,\
|
||||
@@ -160,42 +147,51 @@ static inline bool tud_hid_mouse_button_release(uint8_t report_id)
|
||||
|
||||
// Mouse Report Descriptor Template
|
||||
#define TUD_HID_REPORT_DESC_MOUSE(...) \
|
||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
|
||||
HID_USAGE ( HID_USAGE_DESKTOP_MOUSE ) ,\
|
||||
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
|
||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
|
||||
HID_USAGE ( HID_USAGE_DESKTOP_MOUSE ) ,\
|
||||
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
|
||||
/* Report ID if any */\
|
||||
__VA_ARGS__ \
|
||||
HID_USAGE ( HID_USAGE_DESKTOP_POINTER ) ,\
|
||||
HID_COLLECTION ( HID_COLLECTION_PHYSICAL ) ,\
|
||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_BUTTON ) ,\
|
||||
HID_USAGE_MIN ( 1 ) ,\
|
||||
HID_USAGE_MAX ( 3 ) ,\
|
||||
HID_LOGICAL_MIN ( 0 ) ,\
|
||||
HID_LOGICAL_MAX ( 1 ) ,\
|
||||
/* Left, Right, Middle, Backward, Forward mouse buttons */ \
|
||||
HID_REPORT_COUNT ( 3 ) ,\
|
||||
HID_REPORT_SIZE ( 1 ) ,\
|
||||
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
|
||||
HID_USAGE ( HID_USAGE_DESKTOP_POINTER ) ,\
|
||||
HID_COLLECTION ( HID_COLLECTION_PHYSICAL ) ,\
|
||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_BUTTON ) ,\
|
||||
HID_USAGE_MIN ( 1 ) ,\
|
||||
HID_USAGE_MAX ( 5 ) ,\
|
||||
HID_LOGICAL_MIN ( 0 ) ,\
|
||||
HID_LOGICAL_MAX ( 1 ) ,\
|
||||
/* Left, Right, Middle, Backward, Forward buttons */ \
|
||||
HID_REPORT_COUNT( 5 ) ,\
|
||||
HID_REPORT_SIZE ( 1 ) ,\
|
||||
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
|
||||
/* 3 bit padding */ \
|
||||
HID_REPORT_COUNT ( 1 ) ,\
|
||||
HID_REPORT_SIZE ( 5 ) ,\
|
||||
HID_INPUT ( HID_CONSTANT ) ,\
|
||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
|
||||
HID_REPORT_COUNT( 1 ) ,\
|
||||
HID_REPORT_SIZE ( 3 ) ,\
|
||||
HID_INPUT ( HID_CONSTANT ) ,\
|
||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
|
||||
/* X, Y position [-127, 127] */ \
|
||||
HID_USAGE ( HID_USAGE_DESKTOP_X ) ,\
|
||||
HID_USAGE ( HID_USAGE_DESKTOP_Y ) ,\
|
||||
HID_LOGICAL_MIN ( 0x81 ) ,\
|
||||
HID_LOGICAL_MAX ( 0x7f ) ,\
|
||||
HID_REPORT_COUNT ( 2 ) ,\
|
||||
HID_REPORT_SIZE ( 8 ) ,\
|
||||
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ) ,\
|
||||
/* Mouse scroll [-127, 127] */ \
|
||||
HID_USAGE ( HID_USAGE_DESKTOP_X ) ,\
|
||||
HID_USAGE ( HID_USAGE_DESKTOP_Y ) ,\
|
||||
HID_LOGICAL_MIN ( 0x81 ) ,\
|
||||
HID_LOGICAL_MAX ( 0x7f ) ,\
|
||||
HID_REPORT_COUNT( 2 ) ,\
|
||||
HID_REPORT_SIZE ( 8 ) ,\
|
||||
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ) ,\
|
||||
/* Verital wheel scroll [-127, 127] */ \
|
||||
HID_USAGE ( HID_USAGE_DESKTOP_WHEEL ) ,\
|
||||
HID_LOGICAL_MIN ( 0x81 ) ,\
|
||||
HID_LOGICAL_MAX ( 0x7f ) ,\
|
||||
HID_REPORT_COUNT( 1 ) ,\
|
||||
HID_REPORT_SIZE ( 8 ) ,\
|
||||
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ) ,\
|
||||
HID_COLLECTION_END ,\
|
||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_CONSUMER ), \
|
||||
/* Horizontal wheel scroll [-127, 127] */ \
|
||||
HID_USAGE_N ( HID_USAGE_CONSUMER_AC_PAN, 2 ), \
|
||||
HID_LOGICAL_MIN ( 0x81 ), \
|
||||
HID_LOGICAL_MAX ( 0x7f ), \
|
||||
HID_REPORT_COUNT( 1 ), \
|
||||
HID_REPORT_SIZE ( 8 ), \
|
||||
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ), \
|
||||
HID_COLLECTION_END , \
|
||||
HID_COLLECTION_END \
|
||||
|
||||
// Consumer Control Report Descriptor Template
|
||||
@@ -203,6 +199,7 @@ static inline bool tud_hid_mouse_button_release(uint8_t report_id)
|
||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_CONSUMER ) ,\
|
||||
HID_USAGE ( HID_USAGE_CONSUMER_CONTROL ) ,\
|
||||
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
|
||||
/* Report ID if any */\
|
||||
__VA_ARGS__ \
|
||||
HID_LOGICAL_MIN ( 0x00 ) ,\
|
||||
HID_LOGICAL_MAX_N( 0x03FF, 2 ) ,\
|
||||
@@ -223,6 +220,7 @@ static inline bool tud_hid_mouse_button_release(uint8_t report_id)
|
||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
|
||||
HID_USAGE ( HID_USAGE_DESKTOP_SYSTEM_CONTROL ) ,\
|
||||
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
|
||||
/* Report ID if any */\
|
||||
__VA_ARGS__ \
|
||||
/* 2 bit system power control */ \
|
||||
HID_LOGICAL_MIN ( 1 ) ,\
|
||||
@@ -246,6 +244,7 @@ static inline bool tud_hid_mouse_button_release(uint8_t report_id)
|
||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
|
||||
HID_USAGE ( HID_USAGE_DESKTOP_GAMEPAD ) ,\
|
||||
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
|
||||
/* Report ID if any */\
|
||||
__VA_ARGS__ \
|
||||
/* 16 bit Button Map */ \
|
||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_BUTTON ) ,\
|
||||
@@ -269,6 +268,31 @@ static inline bool tud_hid_mouse_button_release(uint8_t report_id)
|
||||
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
|
||||
HID_COLLECTION_END \
|
||||
|
||||
// HID Generic Input & Output
|
||||
// - 1st parameter is report size (mandatory)
|
||||
// - 2nd parameter is report id HID_REPORT_ID(n) (optional)
|
||||
#define TUD_HID_REPORT_DESC_GENERIC_INOUT(report_size, ...) \
|
||||
HID_USAGE_PAGE_N ( HID_USAGE_PAGE_VENDOR, 2 ),\
|
||||
HID_USAGE ( 0x01 ),\
|
||||
HID_COLLECTION ( HID_COLLECTION_APPLICATION ),\
|
||||
/* Report ID if any */\
|
||||
__VA_ARGS__ \
|
||||
/* Input */ \
|
||||
HID_USAGE ( 0x02 ),\
|
||||
HID_LOGICAL_MIN ( 0x00 ),\
|
||||
HID_LOGICAL_MAX ( 0xff ),\
|
||||
HID_REPORT_SIZE ( 8 ),\
|
||||
HID_REPORT_COUNT( report_size ),\
|
||||
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ),\
|
||||
/* Output */ \
|
||||
HID_USAGE ( 0x03 ),\
|
||||
HID_LOGICAL_MIN ( 0x00 ),\
|
||||
HID_LOGICAL_MAX ( 0xff ),\
|
||||
HID_REPORT_SIZE ( 8 ),\
|
||||
HID_REPORT_COUNT( report_size ),\
|
||||
HID_OUTPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ),\
|
||||
HID_COLLECTION_END \
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
* ASCII to KEYCODE Conversion
|
||||
* Expand to array of [128][2] (shift, keycode)
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+6
-11
@@ -42,13 +42,9 @@ enum
|
||||
MSC_STAGE_STATUS
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
CFG_TUSB_MEM_ALIGN msc_cbw_t cbw;
|
||||
|
||||
//#if defined (__ICCARM__) && (CFG_TUSB_MCU == OPT_MCU_LPC11UXX || CFG_TUSB_MCU == OPT_MCU_LPC13XX)
|
||||
// uint8_t padding1[64-sizeof(msc_cbw_t)]; // IAR cannot align struct's member
|
||||
//#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CFG_TUSB_MEM_ALIGN msc_cbw_t cbw;
|
||||
CFG_TUSB_MEM_ALIGN msc_csw_t csw;
|
||||
|
||||
uint8_t itf_num;
|
||||
@@ -66,7 +62,7 @@ typedef struct {
|
||||
uint8_t add_sense_qualifier;
|
||||
}mscd_interface_t;
|
||||
|
||||
CFG_TUSB_MEM_SECTION CFG_TUSB_MEM_ALIGN static mscd_interface_t _mscd_itf = { 0 };
|
||||
CFG_TUSB_MEM_SECTION CFG_TUSB_MEM_ALIGN static mscd_interface_t _mscd_itf;
|
||||
CFG_TUSB_MEM_SECTION CFG_TUSB_MEM_ALIGN static uint8_t _mscd_buf[CFG_TUD_MSC_BUFSIZE];
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
@@ -135,9 +131,8 @@ bool mscd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t
|
||||
|
||||
mscd_interface_t * p_msc = &_mscd_itf;
|
||||
|
||||
// Open endpoint pair with usbd helper
|
||||
tusb_desc_endpoint_t const *p_desc_ep = (tusb_desc_endpoint_t const *) tu_desc_next( itf_desc );
|
||||
TU_ASSERT( usbd_open_edpt_pair(rhport, p_desc_ep, TUSB_XFER_BULK, &p_msc->ep_out, &p_msc->ep_in) );
|
||||
// Open endpoint pair
|
||||
TU_ASSERT( usbd_open_edpt_pair(rhport, tu_desc_next(itf_desc), 2, TUSB_XFER_BULK, &p_msc->ep_out, &p_msc->ep_in) );
|
||||
|
||||
p_msc->itf_num = itf_desc->bInterfaceNumber;
|
||||
(*p_len) = sizeof(tusb_desc_interface_t) + 2*sizeof(tusb_desc_endpoint_t);
|
||||
+8
-6
@@ -64,10 +64,11 @@ TU_VERIFY_STATIC(CFG_TUD_MSC_BUFSIZE < UINT16_MAX, "Size is not correct");
|
||||
bool tud_msc_set_sense(uint8_t lun, uint8_t sense_key, uint8_t add_sense_code, uint8_t add_sense_qualifier);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// APPLICATION CALLBACK (WEAK is optional)
|
||||
// Application Callbacks (WEAK is optional)
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
/**
|
||||
* Callback invoked when received \ref SCSI_CMD_READ_10 command
|
||||
* Invoked when received \ref SCSI_CMD_READ_10 command
|
||||
* \param[in] lun Logical unit number
|
||||
* \param[in] lba Logical Block Address to be read
|
||||
* \param[in] offset Byte offset from LBA
|
||||
@@ -86,7 +87,7 @@ bool tud_msc_set_sense(uint8_t lun, uint8_t sense_key, uint8_t add_sense_code, u
|
||||
ATTR_WEAK int32_t tud_msc_read10_cb (uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize);
|
||||
|
||||
/**
|
||||
* Callback invoked when received \ref SCSI_CMD_WRITE_10 command
|
||||
* Invoked when received \ref SCSI_CMD_WRITE_10 command
|
||||
* \param[in] lun Logical unit number
|
||||
* \param[in] lba Logical Block Address to be write
|
||||
* \param[in] offset Byte offset from LBA
|
||||
@@ -104,7 +105,8 @@ ATTR_WEAK int32_t tud_msc_read10_cb (uint8_t lun, uint32_t lba, uint32_t offset,
|
||||
*/
|
||||
ATTR_WEAK int32_t tud_msc_write10_cb (uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize);
|
||||
|
||||
// Invoked to determine the disk size
|
||||
// Invoked when received SCSI_CMD_READ_CAPACITY_10 and SCSI_CMD_READ_FORMAT_CAPACITY to determine the disk size
|
||||
// Application update block count and block size
|
||||
ATTR_WEAK void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_size);
|
||||
|
||||
/**
|
||||
@@ -128,13 +130,13 @@ ATTR_WEAK int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void
|
||||
|
||||
/*------------- Optional callbacks -------------*/
|
||||
|
||||
// Invoked to determine max LUN
|
||||
// Invoked when received GET_MAX_LUN request
|
||||
ATTR_WEAK uint8_t tud_msc_maxlun_cb(void);
|
||||
|
||||
// Invoked when Read10 command is complete
|
||||
ATTR_WEAK void tud_msc_read10_complete_cb(uint8_t lun);
|
||||
|
||||
// Invoke when Write10 command is complete
|
||||
// Invoke when Write10 command is complete, can be used to flush flash caching
|
||||
ATTR_WEAK void tud_msc_write10_complete_cb(uint8_t lun);
|
||||
|
||||
// Invoked when command in tud_msc_scsi_cb is complete
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-2
@@ -169,7 +169,7 @@ enum {
|
||||
|
||||
#define TUSB_DESC_CONFIG_POWER_MA(x) ((x)/2)
|
||||
|
||||
/// Device State
|
||||
/// Device State TODO remove
|
||||
typedef enum
|
||||
{
|
||||
TUSB_DEVICE_STATE_UNPLUG = 0 ,
|
||||
@@ -184,7 +184,7 @@ typedef enum
|
||||
XFER_RESULT_STALLED,
|
||||
}xfer_result_t;
|
||||
|
||||
enum
|
||||
enum // TODO remove
|
||||
{
|
||||
DESC_OFFSET_LEN = 0,
|
||||
DESC_OFFSET_TYPE = 1
|
||||
File renamed without changes.
File renamed without changes.
+10
-10
@@ -702,25 +702,25 @@ void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_
|
||||
// Helper
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Helper to parse an pair of endpoint descriptors (IN & OUT)
|
||||
bool usbd_open_edpt_pair(uint8_t rhport, tusb_desc_endpoint_t const* ep_desc, uint8_t xfer_type, uint8_t* ep_out, uint8_t* ep_in)
|
||||
// Parse consecutive endpoint descriptors (IN & OUT)
|
||||
bool usbd_open_edpt_pair(uint8_t rhport, uint8_t const* p_desc, uint8_t ep_count, uint8_t xfer_type, uint8_t* ep_out, uint8_t* ep_in)
|
||||
{
|
||||
for(int i=0; i<2; i++)
|
||||
for(int i=0; i<ep_count; i++)
|
||||
{
|
||||
TU_ASSERT(TUSB_DESC_ENDPOINT == ep_desc->bDescriptorType &&
|
||||
xfer_type == ep_desc->bmAttributes.xfer );
|
||||
tusb_desc_endpoint_t const * desc_ep = (tusb_desc_endpoint_t const *) p_desc;
|
||||
|
||||
TU_ASSERT(dcd_edpt_open(rhport, ep_desc));
|
||||
TU_VERIFY(TUSB_DESC_ENDPOINT == desc_ep->bDescriptorType && xfer_type == desc_ep->bmAttributes.xfer);
|
||||
TU_ASSERT(dcd_edpt_open(rhport, desc_ep));
|
||||
|
||||
if ( tu_edpt_dir(ep_desc->bEndpointAddress) == TUSB_DIR_IN )
|
||||
if ( tu_edpt_dir(desc_ep->bEndpointAddress) == TUSB_DIR_IN )
|
||||
{
|
||||
(*ep_in) = ep_desc->bEndpointAddress;
|
||||
(*ep_in) = desc_ep->bEndpointAddress;
|
||||
}else
|
||||
{
|
||||
(*ep_out) = ep_desc->bEndpointAddress;
|
||||
(*ep_out) = desc_ep->bEndpointAddress;
|
||||
}
|
||||
|
||||
ep_desc = (tusb_desc_endpoint_t const *) tu_desc_next(ep_desc);
|
||||
p_desc = tu_desc_next(p_desc);
|
||||
}
|
||||
|
||||
return true;
|
||||
+18
-2
@@ -107,7 +107,7 @@ ATTR_WEAK void tud_resume_cb(void);
|
||||
#define TUD_CDC_DESC_LEN (8+9+5+5+4+5+7+9+7+7)
|
||||
|
||||
// CDC Descriptor Template
|
||||
// interface number, string index, EP notification address and size, EP data address (out,in) and size.
|
||||
// Interface number, string index, EP notification address and size, EP data address (out, in) and size.
|
||||
#define TUD_CDC_DESCRIPTOR(_itfnum, _stridx, _ep_notif, _ep_notif_size, _epout, _epin, _epsize) \
|
||||
/* Interface Associate */\
|
||||
8, TUSB_DESC_INTERFACE_ASSOCIATION, _itfnum, 2, TUSB_CLASS_CDC, CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL, CDC_COMM_PROTOCOL_ATCOMMAND, 0,\
|
||||
@@ -149,15 +149,31 @@ ATTR_WEAK void tud_resume_cb(void);
|
||||
// Length of template descriptor: 25 bytes
|
||||
#define TUD_HID_DESC_LEN (9 + 9 + 7)
|
||||
|
||||
// HID Input only descriptor
|
||||
// Interface number, string index, protocol, report descriptor len, EP In address, size & polling interval
|
||||
#define TUD_HID_DESCRIPTOR(_itfnum, _stridx, _boot_protocol, _report_desc_len, _epin, _epsize, _ep_interval) \
|
||||
/* Interface */\
|
||||
9, TUSB_DESC_INTERFACE, _itfnum, 0, 1, TUSB_CLASS_HID, (_boot_protocol) ? HID_SUBCLASS_BOOT : 0, _boot_protocol, _stridx,\
|
||||
/* HID descriptor */\
|
||||
9, HID_DESC_TYPE_HID, U16_TO_U8S_LE(0x0111), 0, 1, HID_DESC_TYPE_REPORT, U16_TO_U8S_LE(_report_desc_len),\
|
||||
/* Endpoint descriptor */\
|
||||
/* Endpoint In */\
|
||||
7, TUSB_DESC_ENDPOINT, _epin, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(_epsize), _ep_interval
|
||||
|
||||
// Length of template descriptor: 32 bytes
|
||||
#define TUD_HID_INOUT_DESC_LEN (9 + 9 + 7 + 7)
|
||||
|
||||
// HID Input & Output descriptor
|
||||
// Interface number, string index, protocol, report descriptor len, EP In & Out address, size & polling interval
|
||||
#define TUD_HID_INOUT_DESCRIPTOR(_itfnum, _stridx, _boot_protocol, _report_desc_len, _epin, _epout, _epsize, _ep_interval) \
|
||||
/* Interface */\
|
||||
9, TUSB_DESC_INTERFACE, _itfnum, 0, 2, TUSB_CLASS_HID, (_boot_protocol) ? HID_SUBCLASS_BOOT : 0, _boot_protocol, _stridx,\
|
||||
/* HID descriptor */\
|
||||
9, HID_DESC_TYPE_HID, U16_TO_U8S_LE(0x0111), 0, 1, HID_DESC_TYPE_REPORT, U16_TO_U8S_LE(_report_desc_len),\
|
||||
/* Endpoint In */\
|
||||
7, TUSB_DESC_ENDPOINT, _epin, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(_epsize), _ep_interval,\
|
||||
/* Endpoint Out */\
|
||||
7, TUSB_DESC_ENDPOINT, _epout, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(_epsize), _ep_interval
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
File renamed without changes.
+1
-2
@@ -53,9 +53,8 @@ bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr);
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Helper
|
||||
*------------------------------------------------------------------*/
|
||||
// helper to parse an pair of In and Out endpoint descriptors. They must be consecutive
|
||||
bool usbd_open_edpt_pair(uint8_t rhport, tusb_desc_endpoint_t const* p_desc_ep, uint8_t xfer_type, uint8_t* ep_out, uint8_t* ep_in);
|
||||
|
||||
bool usbd_open_edpt_pair(uint8_t rhport, uint8_t const* p_desc, uint8_t ep_count, uint8_t xfer_type, uint8_t* ep_out, uint8_t* ep_in);
|
||||
void usbd_defer_func( osal_task_func_t func, void* param, bool in_isr );
|
||||
|
||||
|
||||
+30
-37
@@ -47,56 +47,49 @@ enum
|
||||
|
||||
typedef void (*osal_task_func_t)( void * );
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
#include "osal_none.h"
|
||||
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
|
||||
#include "osal_freertos.h"
|
||||
#elif CFG_TUSB_OS == OPT_OS_MYNEWT
|
||||
#include "osal_mynewt.h"
|
||||
#else
|
||||
#error OS is not supported yet
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// OSAL Porting API
|
||||
//--------------------------------------------------------------------+
|
||||
#if 0
|
||||
void osal_task_delay(uint32_t msec);
|
||||
static inline void osal_task_delay(uint32_t msec);
|
||||
|
||||
//------------- Semaphore -------------//
|
||||
osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef);
|
||||
bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr);
|
||||
bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec);
|
||||
static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef);
|
||||
static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr);
|
||||
static inline bool osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec);
|
||||
|
||||
void osal_semaphore_reset(osal_semaphore_t sem_hdl); // TODO removed
|
||||
static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl); // TODO removed
|
||||
|
||||
//------------- Mutex -------------//
|
||||
osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef);
|
||||
bool osal_mutex_lock (osal_mutex_t sem_hdl, uint32_t msec);
|
||||
bool osal_mutex_unlock(osal_mutex_t mutex_hdl);
|
||||
static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef);
|
||||
static inline bool osal_mutex_lock (osal_mutex_t sem_hdl, uint32_t msec);
|
||||
static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl);
|
||||
|
||||
//------------- Queue -------------//
|
||||
osal_queue_t osal_queue_create(osal_queue_def_t* qdef);
|
||||
bool osal_queue_receive(osal_queue_t const qhdl, void* data);
|
||||
bool osal_queue_send(osal_queue_t const qhdl, void const * data, bool in_isr);
|
||||
#endif
|
||||
static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef);
|
||||
static inline bool osal_queue_receive(osal_queue_t const qhdl, void* data);
|
||||
static inline bool osal_queue_send(osal_queue_t const qhdl, void const * data, bool in_isr);
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
#include "osal_none.h"
|
||||
#else
|
||||
#if CFG_TUSB_OS == OPT_OS_FREERTOS
|
||||
#include "osal_freertos.h"
|
||||
#elif CFG_TUSB_OS == OPT_OS_MYNEWT
|
||||
#include "osal_mynewt.h"
|
||||
#else
|
||||
#error CFG_TUSB_OS is not defined or OS is not supported yet
|
||||
#endif
|
||||
#if 0 // TODO remove subtask related macros later
|
||||
// Sub Task
|
||||
#define OSAL_SUBTASK_BEGIN
|
||||
#define OSAL_SUBTASK_END return TUSB_ERROR_NONE;
|
||||
|
||||
// TODO remove subtask related macros later
|
||||
#define STASK_RETURN(_error) return _error;
|
||||
#define STASK_INVOKE(_subtask, _status) (_status) = _subtask
|
||||
|
||||
//------------- Sub Task -------------//
|
||||
#define OSAL_SUBTASK_BEGIN
|
||||
#define OSAL_SUBTASK_END return TUSB_ERROR_NONE;
|
||||
|
||||
#define STASK_RETURN(_error) return _error;
|
||||
#define STASK_INVOKE(_subtask, _status) (_status) = _subtask
|
||||
|
||||
//------------- Sub Task Assert -------------//
|
||||
#define STASK_ASSERT_ERR(_err) TU_VERIFY_ERR(_err)
|
||||
#define STASK_ASSERT_ERR_HDLR(_err, _func) TU_VERIFY_ERR_HDLR(_err, _func)
|
||||
|
||||
#define STASK_ASSERT(_cond) TU_VERIFY(_cond, TUSB_ERROR_OSAL_TASK_FAILED)
|
||||
#define STASK_ASSERT_HDLR(_cond, _func) TU_VERIFY_HDLR(_cond, _func)
|
||||
// Sub Task Assert
|
||||
#define STASK_ASSERT_ERR(_err) TU_VERIFY_ERR(_err)
|
||||
#define STASK_ASSERT(_cond) TU_VERIFY(_cond, TUSB_ERROR_OSAL_TASK_FAILED)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-2
@@ -489,7 +489,7 @@ void USBD_IRQHandler(void)
|
||||
{
|
||||
xfer->total_len = xfer->actual_len;
|
||||
|
||||
// BULK/INT OUT complete
|
||||
// CBI OUT complete
|
||||
dcd_event_xfer_complete(0, epnum, xfer->actual_len, XFER_RESULT_SUCCESS, true);
|
||||
}
|
||||
}
|
||||
@@ -524,7 +524,7 @@ void USBD_IRQHandler(void)
|
||||
xact_in_prepare(epnum);
|
||||
} else
|
||||
{
|
||||
// Bulk/Int IN complete
|
||||
// CBI IN complete
|
||||
dcd_event_xfer_complete(0, epnum | TUSB_DIR_IN_MASK, xfer->actual_len, XFER_RESULT_SUCCESS, true);
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
+32
-32
@@ -41,48 +41,48 @@
|
||||
//------------- HOST -------------//
|
||||
#if TUSB_OPT_HOST_ENABLED
|
||||
#include "host/usbh.h"
|
||||
|
||||
#if HOST_CLASS_HID
|
||||
#include "class/hid/hid_host.h"
|
||||
#endif
|
||||
|
||||
#if CFG_TUH_MSC
|
||||
#include "class/msc/msc_host.h"
|
||||
#endif
|
||||
|
||||
#if CFG_TUH_CDC
|
||||
#include "class/cdc/cdc_host.h"
|
||||
#endif
|
||||
|
||||
#if CFG_TUSB_HOST_CUSTOM_CLASS
|
||||
#include "class/custom_host.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if HOST_CLASS_HID
|
||||
#include "class/hid/hid_host.h"
|
||||
#endif
|
||||
|
||||
#if CFG_TUH_MSC
|
||||
#include "class/msc/msc_host.h"
|
||||
#endif
|
||||
|
||||
#if CFG_TUH_CDC
|
||||
#include "class/cdc/cdc_host.h"
|
||||
#endif
|
||||
|
||||
#if CFG_TUSB_HOST_CUSTOM_CLASS
|
||||
#include "class/custom_host.h"
|
||||
#endif
|
||||
|
||||
|
||||
//------------- DEVICE -------------//
|
||||
#if TUSB_OPT_DEVICE_ENABLED
|
||||
#include "device/usbd.h"
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_HID
|
||||
#include "class/hid/hid_device.h"
|
||||
#endif
|
||||
#if CFG_TUD_HID
|
||||
#include "class/hid/hid_device.h"
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_CDC
|
||||
#include "class/cdc/cdc_device.h"
|
||||
#endif
|
||||
#if CFG_TUD_CDC
|
||||
#include "class/cdc/cdc_device.h"
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_MSC
|
||||
#include "class/msc/msc_device.h"
|
||||
#endif
|
||||
#if CFG_TUD_MSC
|
||||
#include "class/msc/msc_device.h"
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_MIDI
|
||||
#include "class/midi/midi_device.h"
|
||||
#endif
|
||||
#if CFG_TUD_MIDI
|
||||
#include "class/midi/midi_device.h"
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_CUSTOM_CLASS
|
||||
#include "class/custom/custom_device.h"
|
||||
#endif
|
||||
#if CFG_TUD_CUSTOM_CLASS
|
||||
#include "class/custom/custom_device.h"
|
||||
#endif
|
||||
|
||||
|
||||
+23
-14
@@ -147,25 +147,34 @@
|
||||
//--------------------------------------------------------------------
|
||||
// DEVICE OPTIONS
|
||||
//--------------------------------------------------------------------
|
||||
#if TUSB_OPT_DEVICE_ENABLED
|
||||
#ifndef CFG_TUD_ENDOINT0_SIZE
|
||||
#define CFG_TUD_ENDOINT0_SIZE 64
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_ENDOINT0_SIZE
|
||||
#define CFG_TUD_ENDOINT0_SIZE 64
|
||||
#endif
|
||||
#ifndef CFG_TUD_CTRL_BUFSIZE
|
||||
#define CFG_TUD_CTRL_BUFSIZE 256
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_CTRL_BUFSIZE
|
||||
#define CFG_TUD_CTRL_BUFSIZE 256
|
||||
#endif
|
||||
#ifndef CFG_TUD_CDC
|
||||
#define CFG_TUD_CDC 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_CDC
|
||||
#define CFG_TUD_CDC 0
|
||||
#endif
|
||||
#ifndef CFG_TUD_MSC
|
||||
#define CFG_TUD_MSC 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_MSC
|
||||
#define CFG_TUD_MSC 0
|
||||
#endif
|
||||
#ifndef CFG_TUD_HID
|
||||
#define CFG_TUD_HID 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_MIDI
|
||||
#define CFG_TUD_MIDI 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_CUSTOM_CLASS
|
||||
#define CFG_TUD_CUSTOM_CLASS 0
|
||||
#endif
|
||||
|
||||
#endif // TUSB_OPT_DEVICE_ENABLED
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// HOST OPTIONS
|
||||
+7
-9
@@ -60,17 +60,13 @@
|
||||
#define CFG_TUD_MIDI 0
|
||||
#define CFG_TUD_CUSTOM_CLASS 0
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// CDC
|
||||
//--------------------------------------------------------------------
|
||||
//------------- CDC -------------//
|
||||
|
||||
// FIFO size of CDC TX and RX
|
||||
#define CFG_TUD_CDC_RX_BUFSIZE 256
|
||||
#define CFG_TUD_CDC_TX_BUFSIZE 256
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// MSC
|
||||
//--------------------------------------------------------------------
|
||||
//------------- MSC -------------//
|
||||
|
||||
// Buffer size of Device Mass storage
|
||||
#define CFG_TUD_MSC_BUFSIZE 512
|
||||
@@ -84,9 +80,11 @@
|
||||
// Product revision string included in Inquiry response, max 4 bytes
|
||||
#define CFG_TUD_MSC_PRODUCT_REV "1.0"
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// HID
|
||||
//--------------------------------------------------------------------
|
||||
//------------- HID -------------//
|
||||
|
||||
// Should be sufficient to hold ID (if any) + Data
|
||||
#define CFG_TUD_HID_BUFSIZE 64
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018, hathach (tinyusb.org)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -67,7 +67,7 @@ void suspendLoop(void);
|
||||
#include "utility/utilities.h"
|
||||
#include "utility/AdaCallback.h"
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
#ifdef USBCON
|
||||
#include "Adafruit_TinyUSB_Core.h"
|
||||
#endif
|
||||
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ void delay( uint32_t ms )
|
||||
{
|
||||
uint32_t ticks = ms2tick(ms);
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
#ifdef USBCON
|
||||
// Take chance to flush usb cdc
|
||||
uint32_t flush_tick = xTaskGetTickCount();
|
||||
tud_cdc_write_flush();
|
||||
|
||||
+2
-2
@@ -57,7 +57,7 @@ static void loop_task(void* arg)
|
||||
{
|
||||
loop();
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
#ifdef USBCON
|
||||
tud_cdc_write_flush();
|
||||
#endif
|
||||
|
||||
@@ -72,7 +72,7 @@ int main( void )
|
||||
init();
|
||||
initVariant();
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
#ifdef USBCON
|
||||
Adafruit_TinyUSB_Core_init();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ void dbgMemInfo(void)
|
||||
printf("| Name | Addr 0x2000xxxx | Usage |\n");
|
||||
printf("| ---------------------------------------------|\n");
|
||||
|
||||
// Pritn SRAM used for Stack executed by S132 and ISR
|
||||
// Pritn SRAM used for Stack executed by Softdevice and ISR
|
||||
printMemRegion("Stack", ((uint32_t) __StackTop), ((uint32_t) __StackLimit), dbgStackUsed() );
|
||||
|
||||
// Print Heap usage overall (including memory malloced to tasks)
|
||||
@@ -125,7 +125,7 @@ void dbgMemInfo(void)
|
||||
printMemRegion("Bss", ((uint32_t) __bss_end__), ((uint32_t) __data_start__), 0);
|
||||
|
||||
// Print SRAM Used by SoftDevice
|
||||
printMemRegion("S132", (uint32_t) __data_start__, 0x20000000, 0);
|
||||
printMemRegion("SD", (uint32_t) __data_start__, 0x20000000, 0);
|
||||
|
||||
printf("|______________________________________________|\n");
|
||||
printf("\n");
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
#define CFG_SOC_TASK_STACKSIZE (200)
|
||||
#endif
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
#ifdef USBCON
|
||||
#include "nrfx_power.h"
|
||||
|
||||
/* tinyusb function that handles power event (detected, ready, removed)
|
||||
@@ -290,7 +290,7 @@ bool AdafruitBluefruit::begin(uint8_t prph_count, uint8_t central_count)
|
||||
_prph_count = prph_count;
|
||||
_central_count = central_count;
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
#ifdef USBCON
|
||||
usb_softdevice_pre_enable();
|
||||
#endif
|
||||
|
||||
@@ -319,7 +319,7 @@ bool AdafruitBluefruit::begin(uint8_t prph_count, uint8_t central_count)
|
||||
|
||||
VERIFY_STATUS( sd_softdevice_enable(&clock_cfg, nrf_error_cb), false );
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
#ifdef USBCON
|
||||
usb_softdevice_post_enable();
|
||||
#endif
|
||||
|
||||
@@ -461,7 +461,7 @@ bool AdafruitBluefruit::begin(uint8_t prph_count, uint8_t central_count)
|
||||
VERIFY_STATUS(sd_ble_gap_device_name_set(&sec_mode, (uint8_t const *) CFG_DEFAULT_NAME, strlen(CFG_DEFAULT_NAME)), false);
|
||||
|
||||
//------------- USB -------------//
|
||||
#if NRF52840_XXAA
|
||||
#ifdef USBCON
|
||||
sd_power_usbdetected_enable(true);
|
||||
sd_power_usbpwrrdy_enable(true);
|
||||
sd_power_usbremoved_enable(true);
|
||||
@@ -713,7 +713,7 @@ void adafruit_soc_task(void* arg)
|
||||
if ( flash_nrf5x_event_cb ) flash_nrf5x_event_cb(soc_evt);
|
||||
break;
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
#ifdef USBCON
|
||||
/*------------- usb power event handler -------------*/
|
||||
case NRF_EVT_POWER_USB_DETECTED:
|
||||
case NRF_EVT_POWER_USB_POWER_READY:
|
||||
|
||||
+10
-8
@@ -30,7 +30,7 @@ compiler.warning_flags.all=-Wall -Wextra -Wno-unused-parameter -Wno-missing-fiel
|
||||
|
||||
compiler.path={runtime.tools.gcc-arm-none-eabi-5_2-2015q4.path}/bin/
|
||||
compiler.c.cmd=arm-none-eabi-gcc
|
||||
compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -DSOFTDEVICE_PRESENT
|
||||
compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD
|
||||
compiler.c.elf.cmd=arm-none-eabi-gcc
|
||||
compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps
|
||||
compiler.S.cmd=arm-none-eabi-gcc
|
||||
@@ -46,12 +46,11 @@ compiler.elf2bin.cmd=arm-none-eabi-objcopy
|
||||
compiler.elf2hex.flags=-O ihex
|
||||
compiler.elf2hex.cmd=arm-none-eabi-objcopy
|
||||
compiler.ldflags=-mcpu={build.mcu} -mthumb {build.float_flags} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align --specs=nano.specs --specs=nosys.specs
|
||||
|
||||
compiler.size.cmd=arm-none-eabi-size
|
||||
|
||||
# this can be overriden in boards.txt
|
||||
build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float
|
||||
build.debug_flags=-DCFG_DEBUG=0 -Os
|
||||
build.debug_flags=-DCFG_DEBUG=0
|
||||
|
||||
# common compiler for nrf
|
||||
rtos.path={build.core.path}/freertos
|
||||
@@ -60,7 +59,10 @@ nordic.path={build.core.path}/nordic
|
||||
# ARDUINO_FEATHER52 is defined for backward compatiable with other lib only
|
||||
# should be replaced by ARDUINO_NRF52_ADAFRUIT in the future
|
||||
|
||||
compiler.nrf.flags= -DARDUINO_FEATHER52 -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES {build.sd_flags} {build.debug_flags} "-I{build.core.path}/cmsis/include" "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{build.core.path}/Adafruit_TinyUSB_core" "-I{build.core.path}/Adafruit_TinyUSB_core/tinyusb/src"
|
||||
build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_FEATHER52 -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -Os {build.debug_flags} "-I{build.core.path}/cmsis/include" "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{build.core.path}/Adafruit_TinyUSB_Core" "-I{build.core.path}/Adafruit_TinyUSB_Core/tinyusb/src"
|
||||
|
||||
# usb flags
|
||||
build.flags.usb= -DUSBCON -DUSB_VID={build.vid} -DUSB_PID={build.pid}
|
||||
|
||||
# These can be overridden in platform.local.txt
|
||||
compiler.c.extra_flags=
|
||||
@@ -76,13 +78,13 @@ compiler.elf2hex.extra_flags=
|
||||
# ----------------
|
||||
|
||||
## Compile c files
|
||||
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BSP_VERSION="{version}" {compiler.c.extra_flags} {build.extra_flags} {compiler.nrf.flags} {includes} "{source_file}" -o "{object_file}"
|
||||
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BSP_VERSION="{version}" {compiler.c.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Compile c++ files
|
||||
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BSP_VERSION="{version}" {compiler.cpp.extra_flags} {build.extra_flags} {compiler.nrf.flags} {includes} "{source_file}" -o "{object_file}"
|
||||
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BSP_VERSION="{version}" {compiler.cpp.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Compile S files
|
||||
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {compiler.nrf.flags} {includes} "{source_file}" -o "{object_file}"
|
||||
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Create archives
|
||||
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
|
||||
@@ -137,7 +139,7 @@ tools.nrfutil.upload.pattern="{cmd}" {upload.verbose} dfu serial -pkg "{build.pa
|
||||
#***************************************************
|
||||
|
||||
# Bootloader version
|
||||
tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.2.9_{build.sd_name}_{build.sd_version}
|
||||
tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.2.11_{build.sd_name}_{build.sd_version}
|
||||
|
||||
tools.bootburn.bootloader.params.verbose=
|
||||
tools.bootburn.bootloader.params.quiet=
|
||||
|
||||
@@ -138,11 +138,6 @@ static const uint8_t SCK = PIN_SPI_SCK ;
|
||||
#define USB_MSC_BLOCK_SIZE 512
|
||||
#define USB_MSC_BLOCK_COUNT ((2*1024*1024) / USB_MSC_BLOCK_SIZE)
|
||||
|
||||
/* Note: different class combination e.g CDC and (CDC + MSC) should have different
|
||||
* PID since Host OS will "remembered" device driver after the first plug */
|
||||
#define USB_VID 0x239A
|
||||
#define USB_PID 0x8029
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -136,11 +136,6 @@ static const uint8_t SCK = PIN_SPI_SCK ;
|
||||
// If EXTERNAL_FLASH_DEVICES is not defined, all supported devices will be used
|
||||
#define EXTERNAL_FLASH_DEVICES GD25Q16C
|
||||
|
||||
/* Note: different class combination e.g CDC and (CDC + MSC) should have different
|
||||
* PID since Host OS will "remembered" device driver after the first plug */
|
||||
#define USB_VID 0x239A
|
||||
#define USB_PID 0x803F
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -131,11 +131,6 @@ static const uint8_t SCK = PIN_SPI_SCK ;
|
||||
#define USB_MSC_BLOCK_SIZE 512
|
||||
#define USB_MSC_BLOCK_COUNT ((8*1024*1024) / USB_MSC_BLOCK_SIZE)
|
||||
|
||||
/* Note: different class combination e.g CDC and (CDC + MSC) should have different
|
||||
* PID since Host OS will "remembered" device driver after the first plug */
|
||||
#define USB_VID 0x239A
|
||||
#define USB_PID 0x8029
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user