Merge pull request #1036 from hathach/fix_nrf52840_serial
Fix nrf52840 serial mentioned #1021
This commit is contained in:
commit
1fb81979b2
@ -1 +1 @@
|
|||||||
Subproject commit a0849fee9f4b268ccc9798c70c654a835f8e20c8
|
Subproject commit 421ae8fc82b884e087e99c8ab3fa25883a3dd623
|
@ -102,6 +102,7 @@ SRC_C += \
|
|||||||
tick.c \
|
tick.c \
|
||||||
background.c \
|
background.c \
|
||||||
internal_flash.c \
|
internal_flash.c \
|
||||||
|
interrupt_char.c \
|
||||||
drivers/bluetooth/ble_drv.c \
|
drivers/bluetooth/ble_drv.c \
|
||||||
drivers/bluetooth/ble_uart.c \
|
drivers/bluetooth/ble_uart.c \
|
||||||
boards/$(BOARD)/board.c \
|
boards/$(BOARD)/board.c \
|
||||||
@ -113,7 +114,6 @@ SRC_C += \
|
|||||||
lib/timeutils/timeutils.c \
|
lib/timeutils/timeutils.c \
|
||||||
lib/utils/buffer_helper.c \
|
lib/utils/buffer_helper.c \
|
||||||
lib/utils/context_manager_helpers.c \
|
lib/utils/context_manager_helpers.c \
|
||||||
lib/utils/interrupt_char.c \
|
|
||||||
lib/utils/pyexec.c \
|
lib/utils/pyexec.c \
|
||||||
lib/utils/stdout_helpers.c \
|
lib/utils/stdout_helpers.c \
|
||||||
lib/libc/string0.c \
|
lib/libc/string0.c \
|
||||||
@ -122,7 +122,7 @@ SRC_C += \
|
|||||||
ifeq ($(MCU_SUB_VARIANT),nrf52840)
|
ifeq ($(MCU_SUB_VARIANT),nrf52840)
|
||||||
|
|
||||||
SRC_C += \
|
SRC_C += \
|
||||||
usb/tusb_descriptors.c \
|
usb/usb.c \
|
||||||
usb/usb_msc_flash.c \
|
usb/usb_msc_flash.c \
|
||||||
lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c \
|
lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c \
|
||||||
lib/tinyusb/src/portable/nordic/nrf5x/hal_nrf5x.c \
|
lib/tinyusb/src/portable/nordic/nrf5x/hal_nrf5x.c \
|
||||||
|
@ -51,15 +51,10 @@ Prerequisite steps for building the nrf port:
|
|||||||
git submodule update --init
|
git submodule update --init
|
||||||
make -C mpy-cross
|
make -C mpy-cross
|
||||||
|
|
||||||
By default, the feather52832 is used as compile target. To build and flash issue the following command inside the ports/nrf/ folder:
|
To build and flash issue the following command inside the ports/nrf/ folder:
|
||||||
|
|
||||||
make
|
|
||||||
make flash
|
|
||||||
|
|
||||||
Alternatively the target board could be defined:
|
|
||||||
|
|
||||||
make BOARD=pca10056
|
make BOARD=pca10056
|
||||||
make flash
|
make BOARD=pca10056 flash
|
||||||
|
|
||||||
## Compile and Flash with Bluetooth Stack
|
## Compile and Flash with Bluetooth Stack
|
||||||
|
|
||||||
|
@ -29,6 +29,6 @@
|
|||||||
void run_background_tasks(void) {
|
void run_background_tasks(void) {
|
||||||
#ifdef NRF52840_XXAA
|
#ifdef NRF52840_XXAA
|
||||||
tusb_task();
|
tusb_task();
|
||||||
tud_cdc_flush();
|
tud_cdc_write_flush();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -26,13 +26,9 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "nrfx.h"
|
|
||||||
#include "nrfx_power.h"
|
|
||||||
#include "boards/board.h"
|
#include "boards/board.h"
|
||||||
|
#include "nrfx.h"
|
||||||
#include "tick.h"
|
#include "usb.h"
|
||||||
#include "tusb.h"
|
|
||||||
|
|
||||||
void board_init(void) {
|
void board_init(void) {
|
||||||
|
|
||||||
@ -40,27 +36,7 @@ void board_init(void) {
|
|||||||
NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk);
|
NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk);
|
||||||
NRF_CLOCK->TASKS_LFCLKSTART = 1UL;
|
NRF_CLOCK->TASKS_LFCLKSTART = 1UL;
|
||||||
|
|
||||||
// Init USB
|
usb_init();
|
||||||
|
|
||||||
#ifdef SOFTDEVICE_PRESENT
|
|
||||||
// TODO support Softdevice config
|
|
||||||
#else
|
|
||||||
// Softdevice is not present, init power module and register tusb power event function
|
|
||||||
// for vusb detect, ready, removed
|
|
||||||
extern void tusb_hal_nrf_power_event(uint32_t event);
|
|
||||||
|
|
||||||
// Power module init
|
|
||||||
const nrfx_power_config_t pwr_cfg = { 0 };
|
|
||||||
nrfx_power_init(&pwr_cfg);
|
|
||||||
|
|
||||||
// USB Power detection
|
|
||||||
const nrfx_power_usbevt_config_t config = { .handler = (nrfx_power_usb_event_handler_t) tusb_hal_nrf_power_event };
|
|
||||||
nrfx_power_usbevt_init(&config);
|
|
||||||
|
|
||||||
nrfx_power_usbevt_enable();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
tusb_init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool board_requests_safe_mode(void) {
|
bool board_requests_safe_mode(void) {
|
||||||
@ -72,21 +48,6 @@ void reset_board(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// tinyusb callbacks
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
void tud_mount_cb(uint8_t rhport) {
|
|
||||||
(void) rhport;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tud_umount_cb(uint8_t rhport) {
|
|
||||||
(void) rhport;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t tusb_hal_millis(void) {
|
|
||||||
uint64_t ms;
|
|
||||||
uint32_t us;
|
|
||||||
current_tick(&ms, &us);
|
|
||||||
return (uint32_t) ms;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
58
ports/nrf/interrupt_char.c
Normal file
58
ports/nrf/interrupt_char.c
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the MicroPython project, http://micropython.org/
|
||||||
|
*
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-2016 Damien P. George
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "py/obj.h"
|
||||||
|
#include "py/mpstate.h"
|
||||||
|
|
||||||
|
#ifdef NRF52840_XXAA
|
||||||
|
#include "usb.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MICROPY_KBD_EXCEPTION
|
||||||
|
|
||||||
|
int mp_interrupt_char;
|
||||||
|
|
||||||
|
void mp_hal_set_interrupt_char(int c) {
|
||||||
|
if (c != -1) {
|
||||||
|
mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)));
|
||||||
|
}
|
||||||
|
mp_interrupt_char = c;
|
||||||
|
|
||||||
|
#ifdef NRF52840_XXAA
|
||||||
|
tud_cdc_set_wanted_char(c);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void mp_keyboard_interrupt(void) {
|
||||||
|
MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception));
|
||||||
|
#if MICROPY_ENABLE_SCHEDULER
|
||||||
|
if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) {
|
||||||
|
MP_STATE_VM(sched_state) = MP_SCHED_PENDING;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -232,7 +232,7 @@ extern const struct _mp_obj_module_t mp_module_ubluepy;
|
|||||||
// We need to provide a declaration/definition of alloca()
|
// We need to provide a declaration/definition of alloca()
|
||||||
#include <alloca.h>
|
#include <alloca.h>
|
||||||
|
|
||||||
extern void run_background_tasks(void);
|
void run_background_tasks(void);
|
||||||
#define MICROPY_VM_HOOK_LOOP run_background_tasks();
|
#define MICROPY_VM_HOOK_LOOP run_background_tasks();
|
||||||
#define MICROPY_VM_HOOK_RETURN run_background_tasks();
|
#define MICROPY_VM_HOOK_RETURN run_background_tasks();
|
||||||
|
|
||||||
|
@ -1,78 +0,0 @@
|
|||||||
/**************************************************************************/
|
|
||||||
/*!
|
|
||||||
@file tusb_descriptors.c
|
|
||||||
@author hathach (tinyusb.org)
|
|
||||||
|
|
||||||
@section LICENSE
|
|
||||||
|
|
||||||
Software License Agreement (BSD License)
|
|
||||||
|
|
||||||
Copyright (c) 2013, hathach (tinyusb.org)
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
1. Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in the
|
|
||||||
documentation and/or other materials provided with the distribution.
|
|
||||||
3. Neither the name of the copyright holders nor the
|
|
||||||
names of its contributors may be used to endorse or promote products
|
|
||||||
derived from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
|
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
This file is part of the tinyusb stack.
|
|
||||||
*/
|
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
#include "tusb.h"
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// STRING DESCRIPTORS
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
|
|
||||||
// array of pointer to string descriptors
|
|
||||||
uint16_t const * const string_desc_arr [] =
|
|
||||||
{
|
|
||||||
// 0 index is supported language = English
|
|
||||||
TUD_DESC_STRCONV(0x0409),
|
|
||||||
|
|
||||||
// Manufacturer
|
|
||||||
TUD_DESC_STRCONV('A','d','a','f','r','u','i','t',' ','I','n','d','u','s','t','r','i','e','s'),
|
|
||||||
|
|
||||||
// Product
|
|
||||||
TUD_DESC_STRCONV('C','i','r','c','u','i','t','P','Y',' ','n','R','F','5','2'),
|
|
||||||
|
|
||||||
// Serials TODO use chip ID
|
|
||||||
TUD_DESC_STRCONV('1', '2', '3', '4', '5'),
|
|
||||||
|
|
||||||
// CDC Interface
|
|
||||||
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','S','e','r','i','a','l'),
|
|
||||||
|
|
||||||
// MSC Interface
|
|
||||||
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','S','t','o','r','a','g','e'),
|
|
||||||
|
|
||||||
// Custom Interface
|
|
||||||
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','C','u','s','t','o','m')
|
|
||||||
};
|
|
||||||
|
|
||||||
// tud_desc_set is required by tinyusb stack
|
|
||||||
// since CFG_TUD_DESC_AUTO is enabled, we only need to set string_arr
|
|
||||||
tud_desc_set_t tud_desc_set =
|
|
||||||
{
|
|
||||||
.device = NULL,
|
|
||||||
.config = NULL,
|
|
||||||
.string_arr = (uint8_t const **) string_desc_arr,
|
|
||||||
.hid_report = NULL
|
|
||||||
};
|
|
161
ports/nrf/usb/usb.c
Normal file
161
ports/nrf/usb/usb.c
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Micro Python project, http://micropython.org/
|
||||||
|
*
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018 hathach for Adafruit Industries
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "nrfx.h"
|
||||||
|
#include "nrfx_power.h"
|
||||||
|
#include "tick.h"
|
||||||
|
#include "usb.h"
|
||||||
|
#include "lib/utils/interrupt_char.h"
|
||||||
|
|
||||||
|
#ifdef SOFTDEVICE_PRESENT
|
||||||
|
#include "nrf_sdm.h"
|
||||||
|
#include "nrf_soc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// STRING DESCRIPTORS
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// array of pointer to string descriptors
|
||||||
|
uint16_t const * const string_desc_arr [] =
|
||||||
|
{
|
||||||
|
// 0 index is supported language = English
|
||||||
|
TUD_DESC_STRCONV(0x0409),
|
||||||
|
|
||||||
|
// Manufacturer
|
||||||
|
TUD_DESC_STRCONV('A','d','a','f','r','u','i','t',' ','I','n','d','u','s','t','r','i','e','s'),
|
||||||
|
|
||||||
|
// Product
|
||||||
|
TUD_DESC_STRCONV('C','i','r','c','u','i','t','P','Y',' ','n','R','F','5','2'),
|
||||||
|
|
||||||
|
// Serials TODO use chip ID
|
||||||
|
TUD_DESC_STRCONV('1', '2', '3', '4', '5'),
|
||||||
|
|
||||||
|
// CDC Interface
|
||||||
|
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','S','e','r','i','a','l'),
|
||||||
|
|
||||||
|
// MSC Interface
|
||||||
|
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','S','t','o','r','a','g','e'),
|
||||||
|
|
||||||
|
// Custom Interface
|
||||||
|
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','C','u','s','t','o','m')
|
||||||
|
};
|
||||||
|
|
||||||
|
// tud_desc_set is required by tinyusb stack
|
||||||
|
// since CFG_TUD_DESC_AUTO is enabled, we only need to set string_arr
|
||||||
|
tud_desc_set_t tud_desc_set =
|
||||||
|
{
|
||||||
|
.device = NULL,
|
||||||
|
.config = NULL,
|
||||||
|
.string_arr = (uint8_t const **) string_desc_arr,
|
||||||
|
.hid_report = NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* 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 void tusb_hal_nrf_power_event(uint32_t event);
|
||||||
|
|
||||||
|
void usb_init(void) {
|
||||||
|
|
||||||
|
// USB power may already be ready at this time -> no event generated
|
||||||
|
// We need to invoke the handler based on the status initially
|
||||||
|
uint32_t usb_reg;
|
||||||
|
|
||||||
|
#ifdef SOFTDEVICE_PRESENT
|
||||||
|
uint8_t sd_en = false;
|
||||||
|
(void) sd_softdevice_is_enabled(&sd_en);
|
||||||
|
|
||||||
|
if ( sd_en ) {
|
||||||
|
sd_power_usbdetected_enable(true);
|
||||||
|
sd_power_usbpwrrdy_enable(true);
|
||||||
|
sd_power_usbremoved_enable(true);
|
||||||
|
|
||||||
|
sd_power_usbregstatus_get(&usb_reg);
|
||||||
|
}else
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
// Power module init
|
||||||
|
const nrfx_power_config_t pwr_cfg = { 0 };
|
||||||
|
nrfx_power_init(&pwr_cfg);
|
||||||
|
|
||||||
|
// Register tusb function as USB power handler
|
||||||
|
const nrfx_power_usbevt_config_t config = { .handler = (nrfx_power_usb_event_handler_t) tusb_hal_nrf_power_event };
|
||||||
|
nrfx_power_usbevt_init(&config);
|
||||||
|
|
||||||
|
nrfx_power_usbevt_enable();
|
||||||
|
|
||||||
|
usb_reg = NRF_POWER->USBREGSTATUS;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
tusb_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// tinyusb callbacks
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
void tud_mount_cb(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void tud_umount_cb(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t tusb_hal_millis(void) {
|
||||||
|
uint64_t ms;
|
||||||
|
uint32_t us;
|
||||||
|
current_tick(&ms, &us);
|
||||||
|
return (uint32_t) ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if MICROPY_KBD_EXCEPTION
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback invoked when received an "wanted" char.
|
||||||
|
* @param itf Interface index (for multiple cdc interfaces)
|
||||||
|
* @param wanted_char The wanted char (set previously)
|
||||||
|
*/
|
||||||
|
void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char)
|
||||||
|
{
|
||||||
|
(void) itf; // not used
|
||||||
|
|
||||||
|
if (mp_interrupt_char == wanted_char) {
|
||||||
|
tud_cdc_read_flush(); // flush read fifo
|
||||||
|
mp_keyboard_interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
34
ports/nrf/usb/usb.h
Normal file
34
ports/nrf/usb/usb.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Micro Python project, http://micropython.org/
|
||||||
|
*
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018 hathach for Adafruit Industries
|
||||||
|
*
|
||||||
|
* 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 MICROPY_INCLUDED_NRF_USB_H
|
||||||
|
#define MICROPY_INCLUDED_NRF_USB_H
|
||||||
|
|
||||||
|
#include "tusb.h"
|
||||||
|
|
||||||
|
void usb_init(void);
|
||||||
|
|
||||||
|
#endif // MICROPY_INCLUDED_NRF_USB_H
|
Loading…
x
Reference in New Issue
Block a user