Merge pull request #258 from adafruit/develop

move and rename usb files
This commit is contained in:
hathach authored and GitHub committed 2019-04-29 21:05:57 +07:00
commit 446859444c
54 files changed
+66 -100

No files matched your search

+4 -3
View File
@@ -1,9 +1,10 @@
# Arduino Core for Adafruit Bluefruit nRF52 Boards
This repository contains the Arduino BSP for Adafruit nRF52 series:
This repository contains the Arduino BSP for Adafruit Bluefruit nRF52 series:
- [Bluefruit Feather nRF52832](https://www.adafruit.com/product/3406)
- [Bluefruit Feather nRF52840](https://www.adafruit.com/product/4062)
- [Adafruit Feather nRF52832](https://www.adafruit.com/product/3406)
- [Adafruit Feather nRF52840 Express](https://www.adafruit.com/product/4062)
- Adafruit Metro nRF52840 Express
Following boards are also included but are not officially supported:
@@ -25,14 +25,9 @@
#include "nrfx.h"
#include "nrfx_power.h"
#include "nrf_sdm.h"
#include "nrf_soc.h"
#include "nrf_usbd.h"
#include "tusb.h"
#include "usb.h"
#include "rtos.h"
#include "Arduino.h"
#include "Adafruit_TinyUSB_Core.h"
//--------------------------------------------------------------------+
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
@@ -43,7 +38,35 @@
// Serial is 64-bit DeviceID -> 16 chars len
uint16_t usb_desc_str_serial[1+16] = { TUD_DESC_STR_HEADER(16) };
static void usb_device_task(void* param);
/* 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)
{
(void) param;
// RTOS forever loop
while (1)
{
// tinyusb device task
tud_task();
}
}
// Init usb when starting up. Softdevice is not enabled yet
void usb_init(void)
@@ -85,36 +108,4 @@ void usb_init(void)
xTaskCreate( usb_device_task, "usbd", USBD_STACK_SZ, NULL, TASK_PRIO_HIGH, NULL);
}
// Must be called before sd_softdevice_enable()
// NRF_POWER is restricted prph used by Softdevice, must be release before enable SD
void usb_softdevice_pre_enable(void)
{
nrfx_power_usbevt_disable();
nrfx_power_usbevt_uninit();
nrfx_power_uninit();
}
// Must be called after sd_softdevice_enable()
// To re-enable USB
void usb_softdevice_post_enable(void)
{
sd_power_usbdetected_enable(true);
sd_power_usbpwrrdy_enable(true);
sd_power_usbremoved_enable(true);
}
// USB Device Driver task
// This top level thread process all usb events and invoke callbacks
static void usb_device_task(void* param)
{
(void) param;
// RTOS forever loop
while (1)
{
// tinyusb device task
tud_task();
}
}
#endif
@@ -32,4 +32,6 @@
#include "Adafruit_USBD_CDC.h"
#endif
void Adafruit_TinyUSB_Core_init(void);
#endif /* ADAFRUIT_TINYUSB_CORE_H_ */
File renamed without changes.
+1 -1
View File
@@ -68,7 +68,7 @@ void suspendLoop(void);
#include "utility/AdaCallback.h"
#ifdef NRF52840_XXAA
#include "Adafruit_TinyUSB_core.h"
#include "Adafruit_TinyUSB_Core.h"
#endif
// Include board variant
+1 -6
View File
@@ -16,8 +16,6 @@
#define ARDUINO_MAIN
#include "Arduino.h"
#include "usb.h"
// DEBUG Level 1
#if CFG_DEBUG
// weak function to avoid compilation error with
@@ -75,10 +73,7 @@ int main( void )
initVariant();
#ifdef NRF52840_XXAA
USBDevice.addInterface( (Adafruit_USBD_Interface&) Serial);
USBDevice.setID(USB_VID, USB_PID);
USBDevice.begin();
usb_init();
Adafruit_TinyUSB_Core_init();
#endif
#if CFG_DEBUG >= 3
-44
View File
@@ -1,44 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2018, hathach for Adafruit
*
* 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.
*/
#ifndef USB_H_
#define USB_H_
#ifdef __cplusplus
extern "C" {
#endif
void usb_init(void);
void usb_softdevice_pre_enable(void);
void usb_softdevice_post_enable(void);
/* 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. */
void tusb_hal_nrf_power_event(uint32_t event);
#ifdef __cplusplus
}
#endif
#endif /* USB_H_ */
+26 -5
View File
@@ -37,11 +37,6 @@
#include "bluefruit.h"
#include "utility/bonding.h"
#ifdef NRF52840_XXAA
#include "nrfx_power.h"
#include "usb/usb.h"
#endif
#ifndef CFG_BLE_TX_POWER_LEVEL
#define CFG_BLE_TX_POWER_LEVEL 0
#endif
@@ -59,6 +54,32 @@
#define CFG_SOC_TASK_STACKSIZE (200)
#endif
#ifdef NRF52840_XXAA
#include "nrfx_power.h"
/* 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);
// Must be called before sd_softdevice_enable()
// NRF_POWER is restricted prph used by Softdevice, must be release before enable SD
void usb_softdevice_pre_enable(void)
{
nrfx_power_usbevt_disable();
nrfx_power_usbevt_uninit();
nrfx_power_uninit();
}
// Must be called after sd_softdevice_enable()
// To re-enable USB
void usb_softdevice_post_enable(void)
{
sd_power_usbdetected_enable(true);
sd_power_usbpwrrdy_enable(true);
sd_power_usbremoved_enable(true);
}
#endif
AdafruitBluefruit Bluefruit;
+1 -1
View File
@@ -60,7 +60,7 @@ 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}/usb" "-I{build.core.path}/usb/Adafruit_TinyUSB_core" "-I{build.core.path}/usb/Adafruit_TinyUSB_core/tinyusb/src"
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"
# These can be overridden in platform.local.txt
compiler.c.extra_flags=