From 52ebfd07a51749d996e149eccc104a2cc0fd294e Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 17 May 2018 15:20:07 +0700 Subject: update nrfutil to 0.5.2d with singlebank option --- lib/nrfutil | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/nrfutil b/lib/nrfutil index d48561b07..9e7dfb28a 160000 --- a/lib/nrfutil +++ b/lib/nrfutil @@ -1 +1 @@ -Subproject commit d48561b07386132b849d0125b0ff6a532d833d8b +Subproject commit 9e7dfb28a5c6f3d7a19340971b32e0c2b4128ecf -- cgit v1.2.3 From 46c453cf0a4d6f8cc1999acc0e98fc95d8b6c078 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 3 Jul 2018 17:46:08 +0700 Subject: add tinyusb as submodule --- .gitmodules | 4 ++++ lib/tinyusb | 1 + ports/nrf/boards/bluefruit_nrf52840_s140_6.0.0.ld | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) create mode 160000 lib/tinyusb (limited to 'lib') diff --git a/.gitmodules b/.gitmodules index d687c6cf3..32f30f761 100644 --- a/.gitmodules +++ b/.gitmodules @@ -73,3 +73,7 @@ [submodule "ports/nrf/nrfx"] path = ports/nrf/nrfx url = https://github.com/NordicSemiconductor/nrfx.git +[submodule "lib/tinyusb"] + path = lib/tinyusb + url = git@github.com:hathach/tinyusb.git + branch = develop diff --git a/lib/tinyusb b/lib/tinyusb new file mode 160000 index 000000000..1faf0a81e --- /dev/null +++ b/lib/tinyusb @@ -0,0 +1 @@ +Subproject commit 1faf0a81e4ef7176f152165fe46ff65b598d09ce diff --git a/ports/nrf/boards/bluefruit_nrf52840_s140_6.0.0.ld b/ports/nrf/boards/bluefruit_nrf52840_s140_6.0.0.ld index 186509285..fbc87801f 100644 --- a/ports/nrf/boards/bluefruit_nrf52840_s140_6.0.0.ld +++ b/ports/nrf/boards/bluefruit_nrf52840_s140_6.0.0.ld @@ -7,7 +7,7 @@ ---------- ---------- ------- ----------------------------------------- 0x000FF000..0x000FFFFF ( 4KB) Bootloader Settings 0x000FE000..0x000FEFFF ( 4KB) Master Boot Record Params - 0x000F4000..0x000FDFFF ( 40KB) Serial + OTA Bootloader + 0x000F4000..0x000FDFFF ( 40KB) Bootloader (UF2 + CDC + OTA) 0x000ED000..0x000F3FFF (28KB ) Private Config Data (Bonding, Keys, etc.) 0x000AD000..0x000ECFFF (256KB) User Filesystem -- cgit v1.2.3 From 36e2f389331f2d961583a3fb748e780e8ca421bf Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 3 Jul 2018 17:49:59 +0700 Subject: update tools/uf2 to have family support --- lib/tinyusb | 2 +- tools/uf2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/tinyusb b/lib/tinyusb index 1faf0a81e..ec3227b22 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit 1faf0a81e4ef7176f152165fe46ff65b598d09ce +Subproject commit ec3227b2202b007da1b76c20394b6f4d774f68b6 diff --git a/tools/uf2 b/tools/uf2 index bedbc4fc9..6c37e7234 160000 --- a/tools/uf2 +++ b/tools/uf2 @@ -1 +1 @@ -Subproject commit bedbc4fc9f7b1d7b63a949b0ef1530a7f04b51a4 +Subproject commit 6c37e72342d814079bc9b760e2840dc0d766f94f -- cgit v1.2.3 From a73effa5b676fc5e7e37b23c02a5a90ae7259229 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 4 Jul 2018 00:28:43 +0700 Subject: update tusb --- lib/tinyusb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/tinyusb b/lib/tinyusb index ec3227b22..3e66d2d31 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit ec3227b2202b007da1b76c20394b6f4d774f68b6 +Subproject commit 3e66d2d31e21d1ce91bcc4728c929b9bdf3421e8 -- cgit v1.2.3 From 7fff7f5e70c652ccffce2a598a4e3b7df92ad67b Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 4 Jul 2018 16:40:53 +0700 Subject: add usb msc support for nrf52840 --- lib/tinyusb | 2 +- ports/nrf/Makefile | 13 +++ ports/nrf/boards/pca10056/board.c | 51 +++++++++- ports/nrf/nrfx_config.h | 3 + ports/nrf/tick.c | 3 +- ports/nrf/usb/msc_flash.c | 163 ++++++++++++++++++++++++++++++ ports/nrf/usb/nrf_drv_usbd_errata.h | 193 ++++++++++++++++++++++++++++++++++++ ports/nrf/usb/tusb_config.h | 125 +++++++++++++++++++++++ ports/nrf/usb/tusb_descriptors.c | 78 +++++++++++++++ 9 files changed, 626 insertions(+), 5 deletions(-) create mode 100644 ports/nrf/usb/msc_flash.c create mode 100644 ports/nrf/usb/nrf_drv_usbd_errata.h create mode 100644 ports/nrf/usb/tusb_config.h create mode 100644 ports/nrf/usb/tusb_descriptors.c (limited to 'lib') diff --git a/lib/tinyusb b/lib/tinyusb index 3e66d2d31..fc139b009 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit 3e66d2d31e21d1ce91bcc4728c929b9bdf3421e8 +Subproject commit fc139b009f4c49d4fdbf1b80097c94c8dabb1ee1 diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 250c2d5c8..a40cbd58e 100644 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -54,6 +54,8 @@ INC += -I./nrfx/drivers/include INC += -I../../lib/mp-readline INC += -I./drivers/bluetooth INC += -I./drivers +INC += -I../../lib/tinyusb/src +INC += -I./usb NRF_DEFINES += -DCONFIG_GPIO_AS_PINRESET @@ -98,6 +100,7 @@ SRC_HAL = $(addprefix hal/,\ SRC_NRFX = $(addprefix nrfx/,\ drivers/src/nrfx_spim.c \ drivers/src/nrfx_twim.c \ + drivers/src/nrfx_power.c \ ) SRC_C += \ @@ -113,6 +116,8 @@ SRC_C += \ boards/$(BOARD)/board.c \ nrfx/mdk/system_$(MCU_SUB_VARIANT).c \ device/$(MCU_VARIANT)/startup_$(MCU_SUB_VARIANT).c \ + usb/tusb_descriptors.c \ + usb/msc_flash.c \ lib/oofatfs/ff.c \ lib/oofatfs/option/ccsbcs.c \ lib/timeutils/timeutils.c \ @@ -122,6 +127,14 @@ SRC_C += \ lib/utils/pyexec.c \ lib/libc/string0.c \ lib/mp-readline/readline.c \ + lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c \ + lib/tinyusb/src/portable/nordic/nrf5x/hal_nrf5x.c \ + lib/tinyusb/src/common/tusb_fifo.c \ + lib/tinyusb/src/device/usbd.c \ + lib/tinyusb/src/device/usbd_desc.c \ + lib/tinyusb/src/class/msc/msc_device.c \ + lib/tinyusb/src/class/cdc/cdc_device.c \ + lib/tinyusb/src/tusb.c \ internal_flash.c \ diff --git a/ports/nrf/boards/pca10056/board.c b/ports/nrf/boards/pca10056/board.c index 5ad81c21d..52bc5c92c 100644 --- a/ports/nrf/boards/pca10056/board.c +++ b/ports/nrf/boards/pca10056/board.c @@ -27,12 +27,38 @@ #include #include -#include "nrf.h" - +#include "nrfx.h" +#include "nrfx_power.h" #include "boards/board.h" +#include "tick.h" +#include "tusb.h" + void board_init(void) { + // Init USB + NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk); + NRF_CLOCK->TASKS_LFCLKSTART = 1UL; + +#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) { @@ -42,3 +68,24 @@ bool board_requests_safe_mode(void) { 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; +} + diff --git a/ports/nrf/nrfx_config.h b/ports/nrf/nrfx_config.h index 818931236..a30fb343f 100644 --- a/ports/nrf/nrfx_config.h +++ b/ports/nrf/nrfx_config.h @@ -21,4 +21,7 @@ #define NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY NRF_TWIM_FREQ_400K #define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#define NRFX_POWER_ENABLED 1 +#define NRFX_POWER_CONFIG_IRQ_PRIORITY 7 + #endif diff --git a/ports/nrf/tick.c b/ports/nrf/tick.c index fccc8181d..cdd329f71 100644 --- a/ports/nrf/tick.c +++ b/ports/nrf/tick.c @@ -51,8 +51,7 @@ void SysTick_Handler(void) { void tick_init() { uint32_t ticks_per_ms = common_hal_mcu_processor_get_frequency() / 1000; - SysTick_Config(ticks_per_ms); -// NVIC_EnableIRQ(SysTick_IRQn); + SysTick_Config(ticks_per_ms); // interrupt is enabled } void tick_delay(uint32_t us) { diff --git a/ports/nrf/usb/msc_flash.c b/ports/nrf/usb/msc_flash.c new file mode 100644 index 000000000..48600d052 --- /dev/null +++ b/ports/nrf/usb/msc_flash.c @@ -0,0 +1,163 @@ +/**************************************************************************/ +/*! + @file msc_flash.c + @author hathach (tinyusb.org) + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2018, Adafruit Industries (adafruit.com) + 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. +*/ +/**************************************************************************/ + +#ifdef NRF52840_XXAA + +#include "tusb.h" + +#if CFG_TUD_MSC + +/*------------------------------------------------------------------*/ +/* MACRO TYPEDEF CONSTANT ENUM + *------------------------------------------------------------------*/ +#define MSC_FLASH_ADDR_START 0xAD000 +#define MSC_FLASH_SIZE (256*1024) +#define MSC_FLASH_BLOCK_SIZE 512 + +/*------------------------------------------------------------------*/ +/* VARIABLES + *------------------------------------------------------------------*/ +static scsi_sense_fixed_data_t mscd_sense_data = +{ + .response_code = 0x70, + .sense_key = 0, // no errors + .additional_sense_len = sizeof(scsi_sense_fixed_data_t) - 8 +}; + +static scsi_mode_parameters_t const msc_dev_mode_para = +{ + .mode_data_length = 3, + .medium_type = 0, + .device_specific_para = 0, + .block_descriptor_length = 0 +}; + +/*------------------------------------------------------------------*/ +/* + *------------------------------------------------------------------*/ + +static inline uint32_t lba2addr(uint32_t lba) +{ + return MSC_FLASH_ADDR_START + lba*MSC_FLASH_BLOCK_SIZE; +} + +//--------------------------------------------------------------------+ +// tinyusb callbacks +//--------------------------------------------------------------------+ +int32_t tud_msc_scsi_cb (uint8_t rhport, uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize) +{ + // read10 & write10 has their own callback and MUST not be handled here + + void const* ptr = NULL; + uint16_t len = 0; + + // most scsi handled is input + bool in_xfer = true; + + switch (scsi_cmd[0]) + { + case SCSI_CMD_REQUEST_SENSE: + ptr = &mscd_sense_data; + len = sizeof(scsi_sense_fixed_data_t); + break; + + case SCSI_CMD_MODE_SENSE_6: + ptr = &msc_dev_mode_para; + len = sizeof(msc_dev_mode_para); + break; + + case SCSI_CMD_TEST_UNIT_READY: + ptr = NULL; + len = 0; + break; + + case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL: + ptr = NULL; + len = 0; + break; + + default: + // negative is error -> Data stage is STALL, status = failed + return -1; + } + + // return len must not larger than bufsize + TU_ASSERT( bufsize >= len ); + + if ( ptr && len ) + { + if(in_xfer) + { + memcpy(buffer, ptr, len); + }else + { + // SCSI output + } + } + + //------------- clear sense data if it is not request sense command -------------// + if ( SCSI_CMD_REQUEST_SENSE != scsi_cmd[0] ) + { + mscd_sense_data.sense_key = SCSI_SENSEKEY_NONE; + mscd_sense_data.additional_sense_code = 0; + mscd_sense_data.additional_sense_qualifier = 0; + } + + return len; +} + +/*------------------------------------------------------------------*/ +/* Tinyusb Flash READ10 & WRITE10 + *------------------------------------------------------------------*/ +int32_t tud_msc_read10_cb (uint8_t rhport, uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) +{ + (void) rhport; (void) lun; + + uint32_t addr = lba2addr(lba) + offset; + memcpy(buffer, (uint8_t*) addr, bufsize); + + return bufsize; +} + +int32_t tud_msc_write10_cb (uint8_t rhport, uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) +{ + (void) rhport; (void) lun; + + return bufsize; +} + +#endif +#endif diff --git a/ports/nrf/usb/nrf_drv_usbd_errata.h b/ports/nrf/usb/nrf_drv_usbd_errata.h new file mode 100644 index 000000000..f8c554f08 --- /dev/null +++ b/ports/nrf/usb/nrf_drv_usbd_errata.h @@ -0,0 +1,193 @@ +/** + * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * + * 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS 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. + * + */ + +#ifndef NRF_DRV_USBD_ERRATA_H__ +#define NRF_DRV_USBD_ERRATA_H__ + +#include +/** + * @defgroup nrf_drv_usbd_errata Functions to check if selected PAN is present in current chip + * @{ + * @ingroup nrf_drv_usbd + * + * Functions here are checking the presence of an error in current chip. + * The checking is done at runtime based on the microcontroller version. + * This file is subject to removal when nRF51840 prototype support is removed. + */ + +#ifndef NRF_DRV_USBD_ERRATA_ENABLE +/** + * @brief The constant that informs if errata should be enabled at all + * + * If this constant is set to 0, all the Errata bug fixes will be automatically disabled. + */ +#define NRF_DRV_USBD_ERRATA_ENABLE 1 +#endif + +/** + * @brief Internal auxiliary function to check if the program is running on NRF52840 chip + * @retval true It is NRF52480 chip + * @retval false It is other chip + */ +static inline bool nrf_drv_usbd_errata_type_52840(void) +{ + return ((((*(uint32_t *)0xF0000FE0) & 0xFF) == 0x08) && + (((*(uint32_t *)0xF0000FE4) & 0x0F) == 0x0)); +} + +/** + * @brief Internal auxiliary function to check if the program is running on first sample of + * NRF52840 chip + * @retval true It is NRF52480 chip and it is first sample version + * @retval false It is other chip + */ +static inline bool nrf_drv_usbd_errata_type_52840_proto1(void) +{ + return ( nrf_drv_usbd_errata_type_52840() && + ( ((*(uint32_t *)0xF0000FE8) & 0xF0) == 0x00 ) && + ( ((*(uint32_t *)0xF0000FEC) & 0xF0) == 0x00 ) ); +} + +/** + * @brief Internal auxiliary function to check if the program is running on first final product of + * NRF52840 chip + * @retval true It is NRF52480 chip and it is first final product + * @retval false It is other chip + */ +static inline bool nrf_drv_usbd_errata_type_52840_fp1(void) +{ + return ( nrf_drv_usbd_errata_type_52840() && + ( ((*(uint32_t *)0xF0000FE8) & 0xF0) == 0x20 ) && + ( ((*(uint32_t *)0xF0000FEC) & 0xF0) == 0x00 ) ); +} + +/** + * @brief Function to check if chip requires errata 104 + * + * Errata: USBD: EPDATA event is not always generated. + * + * @retval true Errata should be implemented + * @retval false Errata should not be implemented + */ +static inline bool nrf_drv_usbd_errata_104(void) +{ + return NRF_DRV_USBD_ERRATA_ENABLE && nrf_drv_usbd_errata_type_52840_proto1(); +} + +/** + * @brief Function to check if chip requires errata 154 + * + * Errata: During setup read/write transfer USBD acknowledges setup stage without SETUP task. + * + * @retval true Errata should be implemented + * @retval false Errata should not be implemented + */ +static inline bool nrf_drv_usbd_errata_154(void) +{ + return NRF_DRV_USBD_ERRATA_ENABLE && nrf_drv_usbd_errata_type_52840_proto1(); +} + +/** + * @brief Function to check if chip requires errata 166 + * + * Errata: ISO double buffering not functional + * + * @retval true Errata should be implemented + * @retval false Errata should not be implemented + */ +static inline bool nrf_drv_usbd_errata_166(void) +{ + return NRF_DRV_USBD_ERRATA_ENABLE && true; +} + +/** + * @brief Function to check if chip requires errata 171 + * + * Errata: USBD might not reach its active state. + * + * @retval true Errata should be implemented + * @retval false Errata should not be implemented + */ +static inline bool nrf_drv_usbd_errata_171(void) +{ + return NRF_DRV_USBD_ERRATA_ENABLE && true; +} + +/** + * @brief Function to check if chip requires errata 187 + * + * Errata: USB cannot be enabled + * + * @retval true Errata should be implemented + * @retval false Errata should not be implemented + */ +static inline bool nrf_drv_usbd_errata_187(void) +{ + return NRF_DRV_USBD_ERRATA_ENABLE && nrf_drv_usbd_errata_type_52840_fp1(); +} + +/** + * @brief Function to check if chip requires errata ??? + * + * Errata: SIZE.EPOUT not writable + * + * @retval true Errata should be implemented + * @retval false Errata should not be implemented + */ +static inline bool nrf_drv_usbd_errata_sizeepout_rw(void) +{ + return NRF_DRV_USBD_ERRATA_ENABLE && nrf_drv_usbd_errata_type_52840_proto1(); +} + +/** + * @brief Function to check if chip requires errata 199 + * + * Errata: USBD cannot receive tasks during DMA + * + * @retval true Errata should be implemented + * @retval false Errata should not be implemented + */ +static inline bool nrf_drv_usb_errata_199(void) +{ + return NRF_DRV_USBD_ERRATA_ENABLE && true; +} + +/** @} */ +#endif /* NRF_DRV_USBD_ERRATA_H__ */ diff --git a/ports/nrf/usb/tusb_config.h b/ports/nrf/usb/tusb_config.h new file mode 100644 index 000000000..f4f7dc04d --- /dev/null +++ b/ports/nrf/usb/tusb_config.h @@ -0,0 +1,125 @@ +/**************************************************************************/ +/*! + @file tusb_config.h + @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. + +*/ +/**************************************************************************/ + +#ifndef _TUSB_CONFIG_H_ +#define _TUSB_CONFIG_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +//--------------------------------------------------------------------+ +// COMMON CONFIGURATION +//--------------------------------------------------------------------+ +#define CFG_TUSB_MCU OPT_MCU_NRF5X +#define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE + +#define CFG_TUSB_DEBUG 0 + +/*------------- RTOS -------------*/ +#define CFG_TUSB_OS OPT_OS_NONE +//#define CFG_TUD_TASK_PRIO 0 +//#define CFG_TUD_TASK_QUEUE_SZ 16 +//#define CFG_TUD_TASK_STACK_SZ 150 + +//--------------------------------------------------------------------+ +// DEVICE CONFIGURATION +//--------------------------------------------------------------------+ + +/*------------- Core -------------*/ +#define CFG_TUD_DESC_AUTO 1 +#define CFG_TUD_DESC_VID 0x239A +#define CFG_TUD_DESC_PID 0x802A + +#define CFG_TUD_ENDOINT0_SIZE 64 + +//------------- CLASS -------------// +#define CFG_TUD_CDC 0 +#define CFG_TUD_MSC 1 +#define CFG_TUD_HID_KEYBOARD 0 +#define CFG_TUD_HID_MOUSE 0 +#define CFG_TUD_HID_GENERIC 0 + +/*------------------------------------------------------------------*/ +/* CLASS DRIVER + *------------------------------------------------------------------*/ + +// FIFO size of CDC TX and RX +#define CFG_TUD_CDC_RX_BUFSIZE 1024 +#define CFG_TUD_CDC_TX_BUFSIZE 1024 + +/* TX is sent automatically on every Start of Frame event ~ 1ms. + * If not enabled, application must call tud_cdc_flush() periodically + * Note: Enabled this could overflow device task, if it does, define + * CFG_TUD_TASK_QUEUE_SZ with large value + */ +#define CFG_TUD_CDC_FLUSH_ON_SOF 0 + +// Number of supported Logical Unit Number (At least 1) +#define CFG_TUD_MSC_MAXLUN 1 + +// Number of Blocks +#define CFG_TUD_MSC_BLOCK_NUM (256*1024)/512 + +// Block size +#define CFG_TUD_MSC_BLOCK_SZ 512 + +// Buffer size for each read/write transfer, the more the better +#define CFG_TUD_MSC_BUFSIZE (4*1024) + +// Vendor name included in Inquiry response, max 8 bytes +#define CFG_TUD_MSC_VENDOR "Adafruit" + +// Product name included in Inquiry response, max 16 bytes +#define CFG_TUD_MSC_PRODUCT "CircuitPY nRF52" + +// Product revision string included in Inquiry response, max 4 bytes +#define CFG_TUD_MSC_PRODUCT_REV "1.0" + + +//--------------------------------------------------------------------+ +// USB RAM PLACEMENT +//--------------------------------------------------------------------+ +#define CFG_TUSB_ATTR_USBRAM +#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4) + + +#ifdef __cplusplus + } +#endif + +#endif /* _TUSB_CONFIG_H_ */ diff --git a/ports/nrf/usb/tusb_descriptors.c b/ports/nrf/usb/tusb_descriptors.c new file mode 100644 index 000000000..80b847d68 --- /dev/null +++ b/ports/nrf/usb/tusb_descriptors.c @@ -0,0 +1,78 @@ +/**************************************************************************/ +/*! + @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 +}; -- cgit v1.2.3 From 0365912e28ed4da8b8bca65ea68be1324ab441cb Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 5 Jul 2018 16:19:04 +0700 Subject: implement msc with internal_flash api Note: only work with SD is disabled. --- lib/tinyusb | 2 +- main.c | 5 -- ports/nrf/internal_flash.c | 142 +++++++++++++++++++----------------------- ports/nrf/internal_flash.h | 2 - ports/nrf/usb/usb_msc_flash.c | 71 ++++----------------- 5 files changed, 76 insertions(+), 146 deletions(-) (limited to 'lib') diff --git a/lib/tinyusb b/lib/tinyusb index fc139b009..40de723d4 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit fc139b009f4c49d4fdbf1b80097c94c8dabb1ee1 +Subproject commit 40de723d417e253e3346b58cd2ce8b5dbf60d0ac diff --git a/main.c b/main.c index 868a7b752..cbc0b093c 100644 --- a/main.c +++ b/main.c @@ -230,11 +230,6 @@ bool start_mp(safe_mode_t safe_mode) { serial_connected_before_animation = serial_connected(); tick_rgb_status_animation(&animation); - - #ifdef NRF52840_XXAA - extern void tusb_task(void); - tusb_task(); - #endif } } diff --git a/ports/nrf/internal_flash.c b/ports/nrf/internal_flash.c index 2f069a2f9..56377c973 100644 --- a/ports/nrf/internal_flash.c +++ b/ports/nrf/internal_flash.c @@ -36,16 +36,34 @@ #include "lib/oofatfs/ff.h" #include "supervisor/shared/rgb_led_status.h" -#include "nrf.h" +#include "nrf_nvmc.h" #ifdef BLUETOOTH_SD #include "nrf_sdm.h" #endif +/*------------------------------------------------------------------*/ +/* VARIABLES + *------------------------------------------------------------------*/ + // defined in linker extern uint32_t __fatfs_flash_start_addr[]; extern uint32_t __fatfs_flash_length[]; +#define NO_CACHE 0xffffffff +#define FL_PAGE_SZ 4096 + +uint8_t _fl_cache[FL_PAGE_SZ] __attribute__((aligned(4))); +uint32_t _fl_pg_addr = NO_CACHE; + + +/*------------------------------------------------------------------*/ +/* Internal Flash API + *------------------------------------------------------------------*/ +static inline uint32_t lba2addr(uint32_t block) { + return ((uint32_t)__fatfs_flash_start_addr) + block * FILESYSTEM_BLOCK_SIZE; +} + void internal_flash_init(void) { // Activity LED for flash writes. #ifdef MICROPY_HW_LED_MSC @@ -67,101 +85,63 @@ uint32_t internal_flash_get_block_count(void) { return ((uint32_t) __fatfs_flash_length) / FILESYSTEM_BLOCK_SIZE ; } +// TODO support flashing with SD enabled void internal_flash_flush(void) { -} + if (_fl_pg_addr == NO_CACHE) return; -void flash_flush(void) { - internal_flash_flush(); -} + // Skip if data is the same + if (memcmp(_fl_cache, (void *)_fl_pg_addr, FL_PAGE_SZ) != 0) { +// _is_flashing = true; + nrf_nvmc_page_erase(_fl_pg_addr); + nrf_nvmc_write_words(_fl_pg_addr, (uint32_t *)_fl_cache, FL_PAGE_SZ / sizeof(uint32_t)); + } -static uint32_t convert_block_to_flash_addr(uint32_t block) { - return ((uint32_t)__fatfs_flash_start_addr) + block * FILESYSTEM_BLOCK_SIZE; + _fl_pg_addr = NO_CACHE; } -bool internal_flash_write_block(const uint8_t *src, uint32_t block) { - uint8_t sd_en = 0; - -#ifdef MICROPY_HW_LED_MSC - port_pin_set_output_level(MICROPY_HW_LED_MSC, true); -#endif - temp_status_color(ACTIVE_WRITE); - // non-MBR block, copy to cache - - uint32_t dest = convert_block_to_flash_addr(block); - - uint32_t pagenum = dest / FLASH_PAGE_SIZE; - uint32_t* flash_align = (uint32_t*) (pagenum*FLASH_PAGE_SIZE); - - // Read back current page to update only 512 portion - __ALIGN(4) uint8_t buf[FLASH_PAGE_SIZE]; - memcpy(buf, flash_align, FLASH_PAGE_SIZE); - memcpy(buf + (dest%FLASH_PAGE_SIZE), src, FILESYSTEM_BLOCK_SIZE); - -#ifdef BLUETOOTH_SD - (void) sd_softdevice_is_enabled(&sd_en); - - if (sd_en) { - if (NRF_SUCCESS != sd_flash_page_erase(pagenum)) { - return false; - } - - if (NRF_SUCCESS != sd_flash_write(flash_align, (uint32_t*) buf, FLASH_PAGE_SIZE / sizeof(uint32_t))) { - return false; - } - } -#endif +mp_uint_t internal_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num_blocks) { + uint32_t src = lba2addr(block); + memcpy(dest, (uint8_t*) src, FILESYSTEM_BLOCK_SIZE*num_blocks); + return 0; // success +} - if (!sd_en) { - // Erase - NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Een << NVMC_CONFIG_WEN_Pos); - while (NRF_NVMC->READY == NVMC_READY_READY_Busy); +mp_uint_t internal_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32_t num_blocks) { - NRF_NVMC->ERASEPAGE = dest; - while (NRF_NVMC->READY == NVMC_READY_READY_Busy); + #ifdef MICROPY_HW_LED_MSC + port_pin_set_output_level(MICROPY_HW_LED_MSC, true); + #endif - NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos); - while (NRF_NVMC->READY == NVMC_READY_READY_Busy); + while (num_blocks) { + uint32_t const addr = lba2addr(lba); + uint32_t const page_addr = addr & ~(FL_PAGE_SZ - 1); - // Write - uint32_t *p_src = (uint32_t*) buf; - uint32_t *p_dest = flash_align; - uint32_t i = 0; + uint32_t count = 8 - (lba%8); // up to page boundary + count = MIN(num_blocks, count); - while (i < (FLASH_PAGE_SIZE / sizeof(uint32_t))) { - NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos); - while (NRF_NVMC->READY == NVMC_READY_READY_Busy); + if (page_addr != _fl_pg_addr) { + internal_flash_flush(); - *p_dest++ = *p_src++; + // writing previous cached data, skip current data until flashing is done + // tinyusb stack will invoke write_block() with the same parameters later on + // if ( _is_flashing ) return; - while (NRF_NVMC->READY == NVMC_READY_READY_Busy); + _fl_pg_addr = page_addr; + memcpy(_fl_cache, (void *)page_addr, FL_PAGE_SZ); + } - NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos); - while (NRF_NVMC->READY == NVMC_READY_READY_Busy); + memcpy(_fl_cache + (addr & (FL_PAGE_SZ - 1)), src, count*FILESYSTEM_BLOCK_SIZE); - ++i; + // adjust for next run + lba += count; + src += count*FILESYSTEM_BLOCK_SIZE; + num_blocks -= count; } - } - - clear_temp_status(); -#ifdef MICROPY_HW_LED_MSC - port_pin_set_output_level(MICROPY_HW_LED_MSC, false); -#endif - return true; -} -mp_uint_t internal_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num_blocks) { - uint32_t src = convert_block_to_flash_addr(block); - memcpy(dest, (uint8_t*) src, FILESYSTEM_BLOCK_SIZE*num_blocks); - return 0; // success -} + #ifdef MICROPY_HW_LED_MSC + port_pin_set_output_level(MICROPY_HW_LED_MSC, false); + #endif -mp_uint_t internal_flash_write_blocks(const uint8_t *src, uint32_t block_num, uint32_t num_blocks) { - for (size_t i = 0; i < num_blocks; i++) { - if (!internal_flash_write_block(src + i * FILESYSTEM_BLOCK_SIZE, block_num + i)) { - return 1; // error - } - } - return 0; // success + return 0; // success } /******************************************************************************/ @@ -241,3 +221,7 @@ void flash_init_vfs(fs_user_mount_t *vfs) { vfs->u.ioctl[0] = (mp_obj_t)&internal_flash_obj_ioctl_obj; vfs->u.ioctl[1] = (mp_obj_t)&internal_flash_obj; } + +void flash_flush(void) { + internal_flash_flush(); +} diff --git a/ports/nrf/internal_flash.h b/ports/nrf/internal_flash.h index 79b786555..e83b39d57 100644 --- a/ports/nrf/internal_flash.h +++ b/ports/nrf/internal_flash.h @@ -44,8 +44,6 @@ uint32_t internal_flash_get_block_size(void); uint32_t internal_flash_get_block_count(void); void internal_flash_irq_handler(void); void internal_flash_flush(void); -bool internal_flash_read_block(uint8_t *dest, uint32_t block); -bool internal_flash_write_block(const uint8_t *src, uint32_t block); // these return 0 on success, non-zero on error mp_uint_t internal_flash_read_blocks(uint8_t *dest, uint32_t block_num, uint32_t num_blocks); diff --git a/ports/nrf/usb/usb_msc_flash.c b/ports/nrf/usb/usb_msc_flash.c index 22cc68988..dc88d031c 100644 --- a/ports/nrf/usb/usb_msc_flash.c +++ b/ports/nrf/usb/usb_msc_flash.c @@ -37,7 +37,7 @@ #ifdef NRF52840_XXAA #include "tusb.h" -#include "nrf_nvmc.h" +#include "internal_flash.h" /*------------------------------------------------------------------*/ /* MACRO TYPEDEF CONSTANT ENUM @@ -71,11 +71,6 @@ static scsi_mode_parameters_t const msc_dev_mode_para = /* *------------------------------------------------------------------*/ -static inline uint32_t lba2addr(uint32_t lba) -{ - return MSC_FLASH_ADDR_START + lba*MSC_FLASH_BLOCK_SIZE; -} - //--------------------------------------------------------------------+ // tinyusb callbacks //--------------------------------------------------------------------+ @@ -141,72 +136,30 @@ int32_t tud_msc_scsi_cb (uint8_t rhport, uint8_t lun, uint8_t const scsi_cmd[16] return len; } -/*------------------------------------------------------------------*/ -/* Internal Flash - *------------------------------------------------------------------*/ -#define NO_CACHE 0xffffffff - -uint8_t _fl_cache[FL_PAGE_SZ] ATTR_ALIGNED(4); -uint32_t _fl_addr = NO_CACHE; - - -static void fl_flush() { - if (_fl_addr == NO_CACHE) return; - - // Skip if data is the same - if (memcmp(_fl_cache, (void *)_fl_addr, FL_PAGE_SZ) != 0) { -// _is_flashing = true; - nrf_nvmc_page_erase(_fl_addr); - nrf_nvmc_write_words(_fl_addr, (uint32_t *)_fl_cache, FL_PAGE_SZ / sizeof(uint32_t)); - } - - _fl_addr = NO_CACHE; -} - -static bool fl_write(uint32_t addr, uint8_t* buf, uint16_t bufsize) -{ - uint32_t new_addr = addr & ~(FL_PAGE_SZ - 1); - - if (new_addr != _fl_addr) { - fl_flush(); - - // writing previous cached data, skip current data until flashing is done - // tinyusb stack will invoke write_block() with the same parameters later on -// if ( _is_flashing ) return; - - _fl_addr = new_addr; - memcpy(_fl_cache, (void *)new_addr, FL_PAGE_SZ); - } - - memcpy(_fl_cache + (addr & (FL_PAGE_SZ - 1)), buf, bufsize); - - return true; -} - - /*------------------------------------------------------------------*/ /* Tinyusb Flash READ10 & WRITE10 *------------------------------------------------------------------*/ int32_t tud_msc_read10_cb (uint8_t rhport, uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) { - (void) rhport; - (void) lun; + (void) rhport; (void) lun; (void) offset; - uint32_t addr = lba2addr(lba) + offset; - memcpy(buffer, (uint8_t*) addr, bufsize); + uint32_t const block_count = bufsize/MSC_FLASH_BLOCK_SIZE; - return bufsize; + internal_flash_read_blocks(buffer, lba, block_count); + + return block_count*MSC_FLASH_BLOCK_SIZE; } int32_t tud_msc_write10_cb (uint8_t rhport, uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) { - (void) rhport; (void) lun; - uint32_t addr = lba2addr(lba) + offset; + (void) rhport; (void) lun; (void) offset; + + uint32_t const block_count = bufsize/MSC_FLASH_BLOCK_SIZE; // bufsize <= CFG_TUD_MSC_BUFSIZE (4096) - fl_write(addr, buffer, bufsize); + internal_flash_write_blocks(buffer, lba, block_count); - return bufsize; + return block_count*MSC_FLASH_BLOCK_SIZE; } void tud_msc_write10_complete_cb(uint8_t rhport, uint8_t lun) @@ -214,7 +167,7 @@ void tud_msc_write10_complete_cb(uint8_t rhport, uint8_t lun) (void) rhport; (void) lun; // flush pending cache when write10 is complete - fl_flush(); + internal_flash_flush(); } #endif -- cgit v1.2.3 From c5089d7274fe3518cc2bd41874120d33c8fc7079 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 10 Jul 2018 01:02:33 +0700 Subject: generate uf2 by default update tusb --- lib/tinyusb | 2 +- ports/nrf/Makefile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/tinyusb b/lib/tinyusb index 40de723d4..5d8cf5cf8 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit 40de723d417e253e3346b58cd2ce8b5dbf60d0ac +Subproject commit 5d8cf5cf8fc30cb8fbb7553b0f949d8f3298c602 diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index b2b837eb5..11f6bb153 100644 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -249,7 +249,7 @@ $(filter $(PY_BUILD)/../extmod/vfs_fat_%.o, $(PY_O)): COPT += -Os .phony: all flash sd binary hex bootloader -all: binary hex +all: binary hex uf2 OUTPUT_FILENAME = firmware @@ -305,7 +305,7 @@ endif ##################### # Flash with DFU ##################### -.phony: dfu-gen dfu-flash dfu-bootloader uf2 +.phony: dfu-gen dfu-flash dfu-bootloader ifeq ($(OS),Windows_NT) NRFUTIL = ../../lib/nrfutil/binaries/win32/nrfutil.exe -- cgit v1.2.3 From ce01496d44fb532cf861b2c5dab4b449f6c2c626 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 10 Jul 2018 12:06:54 +0700 Subject: try to fix travis build error --- lib/tinyusb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/tinyusb b/lib/tinyusb index 5d8cf5cf8..f5652a014 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit 5d8cf5cf8fc30cb8fbb7553b0f949d8f3298c602 +Subproject commit f5652a0146606151c83f7af25f9779718a65f097 -- cgit v1.2.3 From a53b1c7cf170e2fe71a12a861cbdca6d1942decf Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 10 Jul 2018 22:49:51 +0700 Subject: code format --- lib/tinyusb | 2 +- ports/nrf/Makefile | 26 ++-- ports/nrf/background.c | 62 ++++------ ports/nrf/boards/pca10056/board.c | 3 +- ports/nrf/boards/pca10056/mpconfigboard.h | 1 - ports/nrf/drivers/bluetooth/ble_uart.c | 4 - ports/nrf/internal_flash.c | 62 +++++----- ports/nrf/mphalport.c | 79 +----------- ports/nrf/mphalport.h | 2 + ports/nrf/usb/nrf_drv_usbd_errata.h | 193 ------------------------------ 10 files changed, 71 insertions(+), 363 deletions(-) delete mode 100644 ports/nrf/usb/nrf_drv_usbd_errata.h (limited to 'lib') diff --git a/lib/tinyusb b/lib/tinyusb index f5652a014..a0849fee9 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit f5652a0146606151c83f7af25f9779718a65f097 +Subproject commit a0849fee9f4b268ccc9798c70c654a835f8e20c8 diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 36778ba22..aa7921587 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -107,6 +107,8 @@ SRC_C += \ fatfs_port.c \ fifo.c \ tick.c \ + background.c \ + internal_flash.c \ drivers/softpwm.c \ drivers/ticker.c \ drivers/bluetooth/ble_drv.c \ @@ -115,7 +117,6 @@ SRC_C += \ nrfx/mdk/system_$(MCU_SUB_VARIANT).c \ nrfx/hal/nrf_nvmc.c \ device/$(MCU_VARIANT)/startup_$(MCU_SUB_VARIANT).c \ - background.c \ lib/oofatfs/ff.c \ lib/oofatfs/option/ccsbcs.c \ lib/timeutils/timeutils.c \ @@ -126,25 +127,23 @@ SRC_C += \ lib/utils/stdout_helpers.c \ lib/libc/string0.c \ lib/mp-readline/readline.c \ - internal_flash.c \ ifeq ($(MCU_SUB_VARIANT),nrf52840) SRC_C += \ usb/tusb_descriptors.c \ usb/usb_msc_flash.c \ - lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c \ - lib/tinyusb/src/portable/nordic/nrf5x/hal_nrf5x.c \ - lib/tinyusb/src/common/tusb_fifo.c \ - lib/tinyusb/src/device/usbd.c \ - lib/tinyusb/src/device/usbd_desc.c \ - lib/tinyusb/src/class/msc/msc_device.c \ - lib/tinyusb/src/class/cdc/cdc_device.c \ - lib/tinyusb/src/tusb.c \ + lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c \ + lib/tinyusb/src/portable/nordic/nrf5x/hal_nrf5x.c \ + lib/tinyusb/src/common/tusb_fifo.c \ + lib/tinyusb/src/device/usbd.c \ + lib/tinyusb/src/device/usbd_desc.c \ + lib/tinyusb/src/class/msc/msc_device.c \ + lib/tinyusb/src/class/cdc/cdc_device.c \ + lib/tinyusb/src/tusb.c \ endif - DRIVERS_SRC_C += $(addprefix modules/,\ ubluepy/modubluepy.c \ ubluepy/ubluepy_peripheral.c \ @@ -264,7 +263,6 @@ hex: $(BUILD)/$(OUTPUT_FILENAME).hex $(BUILD)/$(OUTPUT_FILENAME).hex: $(BUILD)/$(OUTPUT_FILENAME).elf $(OBJCOPY) -O ihex $< $@ - ##################### # Flash with debugger ##################### @@ -300,7 +298,6 @@ sd: $(BUILD)/$(OUTPUT_FILENAME).hex endif - ##################### # Flash with DFU ##################### @@ -312,7 +309,6 @@ else NRFUTIL = nrfutil endif - check_defined = \ $(strip $(foreach 1,$1, \ $(call __check_defined,$1,$(strip $(value 2))))) @@ -335,8 +331,6 @@ uf2: $(BUILD)/$(OUTPUT_FILENAME).hex $(ECHO) "Create $(OUTPUT_FILENAME).uf2" $(PYTHON2) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xADA52840 -c -o "$(BUILD)/$(OUTPUT_FILENAME).uf2" $^ - - $(BUILD)/dfu-package.zip: dfu-gen $(BUILD)/$(OUTPUT_FILENAME).elf: $(OBJ) diff --git a/ports/nrf/background.c b/ports/nrf/background.c index 094da5d9c..9f8c8b34b 100644 --- a/ports/nrf/background.c +++ b/ports/nrf/background.c @@ -1,44 +1,32 @@ -/**************************************************************************/ -/*! - @file background.c - @author hathach (tinyusb.org) - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2018, Adafruit Industries (adafruit.com) - 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 MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft 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 "tusb.h" - void run_background_tasks(void) { - #ifdef NRF52840_XXAA tusb_task(); tud_cdc_flush(); diff --git a/ports/nrf/boards/pca10056/board.c b/ports/nrf/boards/pca10056/board.c index cee269ee6..f97be0748 100644 --- a/ports/nrf/boards/pca10056/board.c +++ b/ports/nrf/boards/pca10056/board.c @@ -83,8 +83,7 @@ void tud_umount_cb(uint8_t rhport) { (void) rhport; } -uint32_t tusb_hal_millis(void) -{ +uint32_t tusb_hal_millis(void) { uint64_t ms; uint32_t us; current_tick(&ms, &us); diff --git a/ports/nrf/boards/pca10056/mpconfigboard.h b/ports/nrf/boards/pca10056/mpconfigboard.h index b85a2fc9b..8195e1947 100644 --- a/ports/nrf/boards/pca10056/mpconfigboard.h +++ b/ports/nrf/boards/pca10056/mpconfigboard.h @@ -35,7 +35,6 @@ #define PORT_HEAP_SIZE (128 * 1024) #define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - // Temp (could be removed) 0: usb cdc (default), 1 : hwuart (jlink) #define CFG_HWUART_FOR_SERIAL 0 diff --git a/ports/nrf/drivers/bluetooth/ble_uart.c b/ports/nrf/drivers/bluetooth/ble_uart.c index e3501aa14..52c042f7b 100644 --- a/ports/nrf/drivers/bluetooth/ble_uart.c +++ b/ports/nrf/drivers/bluetooth/ble_uart.c @@ -34,10 +34,6 @@ #if MICROPY_PY_BLE_NUS -#if BLUETOOTH_WEBBLUETOOTH_REPL -//#include "hal_time.h" -#endif // BLUETOOTH_WEBBLUETOOTH_REPL - static ubluepy_uuid_obj_t uuid_obj_service = { .base.type = &ubluepy_uuid_type, .type = UBLUEPY_UUID_128_BIT, diff --git a/ports/nrf/internal_flash.c b/ports/nrf/internal_flash.c index 35e0ae8b7..75c114a5c 100644 --- a/ports/nrf/internal_flash.c +++ b/ports/nrf/internal_flash.c @@ -42,19 +42,15 @@ #include "nrf_sdm.h" #endif -/*------------------------------------------------------------------*/ -/* VARIABLES - *------------------------------------------------------------------*/ - // defined in linker extern uint32_t __fatfs_flash_start_addr[]; extern uint32_t __fatfs_flash_length[]; -#define NO_CACHE 0xffffffff -#define FL_PAGE_SZ 4096 +#define NO_CACHE 0xffffffff +#define FL_PAGE_SZ 4096 -uint8_t _fl_cache[FL_PAGE_SZ] __attribute__((aligned(4))); -uint32_t _fl_pg_addr = NO_CACHE; +uint8_t _flash_cache[FL_PAGE_SZ] __attribute__((aligned(4))); +uint32_t _flash_page_addr = NO_CACHE; /*------------------------------------------------------------------*/ @@ -66,14 +62,14 @@ static inline uint32_t lba2addr(uint32_t block) { void internal_flash_init(void) { // Activity LED for flash writes. - #ifdef MICROPY_HW_LED_MSC - struct port_config pin_conf; - port_get_config_defaults(&pin_conf); - - pin_conf.direction = PORT_PIN_DIR_OUTPUT; - port_pin_set_config(MICROPY_HW_LED_MSC, &pin_conf); - port_pin_set_output_level(MICROPY_HW_LED_MSC, false); - #endif +#ifdef MICROPY_HW_LED_MSC + struct port_config pin_conf; + port_get_config_defaults(&pin_conf); + + pin_conf.direction = PORT_PIN_DIR_OUTPUT; + port_pin_set_config(MICROPY_HW_LED_MSC, &pin_conf); + port_pin_set_output_level(MICROPY_HW_LED_MSC, false); +#endif } uint32_t internal_flash_get_block_size(void) { @@ -86,16 +82,16 @@ uint32_t internal_flash_get_block_count(void) { // TODO support flashing with SD enabled void internal_flash_flush(void) { - if (_fl_pg_addr == NO_CACHE) return; + if (_flash_page_addr == NO_CACHE) return; // Skip if data is the same - if (memcmp(_fl_cache, (void *)_fl_pg_addr, FL_PAGE_SZ) != 0) { + if (memcmp(_flash_cache, (void *)_flash_page_addr, FL_PAGE_SZ) != 0) { // _is_flashing = true; - nrf_nvmc_page_erase(_fl_pg_addr); - nrf_nvmc_write_words(_fl_pg_addr, (uint32_t *)_fl_cache, FL_PAGE_SZ / sizeof(uint32_t)); + nrf_nvmc_page_erase(_flash_page_addr); + nrf_nvmc_write_words(_flash_page_addr, (uint32_t *)_flash_cache, FL_PAGE_SZ / sizeof(uint32_t)); } - _fl_pg_addr = NO_CACHE; + _flash_page_addr = NO_CACHE; } mp_uint_t internal_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num_blocks) { @@ -106,39 +102,39 @@ mp_uint_t internal_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num mp_uint_t internal_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32_t num_blocks) { - #ifdef MICROPY_HW_LED_MSC +#ifdef MICROPY_HW_LED_MSC port_pin_set_output_level(MICROPY_HW_LED_MSC, true); - #endif +#endif while (num_blocks) { uint32_t const addr = lba2addr(lba); uint32_t const page_addr = addr & ~(FL_PAGE_SZ - 1); - uint32_t count = 8 - (lba%8); // up to page boundary + uint32_t count = 8 - (lba % 8); // up to page boundary count = MIN(num_blocks, count); - if (page_addr != _fl_pg_addr) { + if (page_addr != _flash_page_addr) { internal_flash_flush(); // writing previous cached data, skip current data until flashing is done // tinyusb stack will invoke write_block() with the same parameters later on // if ( _is_flashing ) return; - _fl_pg_addr = page_addr; - memcpy(_fl_cache, (void *)page_addr, FL_PAGE_SZ); + _flash_page_addr = page_addr; + memcpy(_flash_cache, (void *)page_addr, FL_PAGE_SZ); } - memcpy(_fl_cache + (addr & (FL_PAGE_SZ - 1)), src, count*FILESYSTEM_BLOCK_SIZE); + memcpy(_flash_cache + (addr & (FL_PAGE_SZ - 1)), src, count * FILESYSTEM_BLOCK_SIZE); // adjust for next run lba += count; - src += count*FILESYSTEM_BLOCK_SIZE; + src += count * FILESYSTEM_BLOCK_SIZE; num_blocks -= count; } - #ifdef MICROPY_HW_LED_MSC +#ifdef MICROPY_HW_LED_MSC port_pin_set_output_level(MICROPY_HW_LED_MSC, false); - #endif +#endif return 0; // success } @@ -203,6 +199,10 @@ const mp_obj_type_t internal_flash_type = { .locals_dict = (mp_obj_t)&internal_flash_obj_locals_dict, }; +/*------------------------------------------------------------------*/ +/* Flash API + *------------------------------------------------------------------*/ + void flash_init_vfs(fs_user_mount_t *vfs) { vfs->base.type = &mp_fat_vfs_type; vfs->flags |= FSUSER_NATIVE | FSUSER_HAVE_IOCTL; diff --git a/ports/nrf/mphalport.c b/ports/nrf/mphalport.c index 2266f84a2..c9d141b26 100644 --- a/ports/nrf/mphalport.c +++ b/ports/nrf/mphalport.c @@ -85,7 +85,7 @@ int mp_hal_stdin_rx_chr(void) { } bool mp_hal_stdin_any(void) { - return tud_cdc_available() > 0; + return tud_cdc_available() > 0; } void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) { @@ -128,80 +128,3 @@ void mp_hal_delay_ms(mp_uint_t delay) { } } -void mp_hal_delay_us(mp_uint_t us) -{ - register uint32_t delay __ASM ("r0") = us; - __ASM volatile ( -#ifdef NRF51 - ".syntax unified\n" -#endif - "1:\n" - " SUBS %0, %0, #1\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" -#ifdef NRF52 - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" - " NOP\n" -#endif - " BNE 1b\n" -#ifdef NRF51 - ".syntax divided\n" -#endif - : "+r" (delay)); -} - - diff --git a/ports/nrf/mphalport.h b/ports/nrf/mphalport.h index a217d8896..fe43cec16 100644 --- a/ports/nrf/mphalport.h +++ b/ports/nrf/mphalport.h @@ -50,5 +50,7 @@ int mp_hal_stdin_rx_chr(void); void mp_hal_stdout_tx_str(const char *str); bool mp_hal_stdin_any(void); +#define mp_hal_delay_us(us) NRFX_DELAY_US((uint32_t) us) + #endif diff --git a/ports/nrf/usb/nrf_drv_usbd_errata.h b/ports/nrf/usb/nrf_drv_usbd_errata.h deleted file mode 100644 index f8c554f08..000000000 --- a/ports/nrf/usb/nrf_drv_usbd_errata.h +++ /dev/null @@ -1,193 +0,0 @@ -/** - * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA - * - * 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, except as embedded into a Nordic - * Semiconductor ASA integrated circuit in a product or a software update for - * such product, 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 Nordic Semiconductor ASA nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * 4. This software, with or without modification, must only be used with a - * Nordic Semiconductor ASA integrated circuit. - * - * 5. Any software provided in binary form under this license must not be reverse - * engineered, decompiled, modified and/or disassembled. - * - * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS 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. - * - */ - -#ifndef NRF_DRV_USBD_ERRATA_H__ -#define NRF_DRV_USBD_ERRATA_H__ - -#include -/** - * @defgroup nrf_drv_usbd_errata Functions to check if selected PAN is present in current chip - * @{ - * @ingroup nrf_drv_usbd - * - * Functions here are checking the presence of an error in current chip. - * The checking is done at runtime based on the microcontroller version. - * This file is subject to removal when nRF51840 prototype support is removed. - */ - -#ifndef NRF_DRV_USBD_ERRATA_ENABLE -/** - * @brief The constant that informs if errata should be enabled at all - * - * If this constant is set to 0, all the Errata bug fixes will be automatically disabled. - */ -#define NRF_DRV_USBD_ERRATA_ENABLE 1 -#endif - -/** - * @brief Internal auxiliary function to check if the program is running on NRF52840 chip - * @retval true It is NRF52480 chip - * @retval false It is other chip - */ -static inline bool nrf_drv_usbd_errata_type_52840(void) -{ - return ((((*(uint32_t *)0xF0000FE0) & 0xFF) == 0x08) && - (((*(uint32_t *)0xF0000FE4) & 0x0F) == 0x0)); -} - -/** - * @brief Internal auxiliary function to check if the program is running on first sample of - * NRF52840 chip - * @retval true It is NRF52480 chip and it is first sample version - * @retval false It is other chip - */ -static inline bool nrf_drv_usbd_errata_type_52840_proto1(void) -{ - return ( nrf_drv_usbd_errata_type_52840() && - ( ((*(uint32_t *)0xF0000FE8) & 0xF0) == 0x00 ) && - ( ((*(uint32_t *)0xF0000FEC) & 0xF0) == 0x00 ) ); -} - -/** - * @brief Internal auxiliary function to check if the program is running on first final product of - * NRF52840 chip - * @retval true It is NRF52480 chip and it is first final product - * @retval false It is other chip - */ -static inline bool nrf_drv_usbd_errata_type_52840_fp1(void) -{ - return ( nrf_drv_usbd_errata_type_52840() && - ( ((*(uint32_t *)0xF0000FE8) & 0xF0) == 0x20 ) && - ( ((*(uint32_t *)0xF0000FEC) & 0xF0) == 0x00 ) ); -} - -/** - * @brief Function to check if chip requires errata 104 - * - * Errata: USBD: EPDATA event is not always generated. - * - * @retval true Errata should be implemented - * @retval false Errata should not be implemented - */ -static inline bool nrf_drv_usbd_errata_104(void) -{ - return NRF_DRV_USBD_ERRATA_ENABLE && nrf_drv_usbd_errata_type_52840_proto1(); -} - -/** - * @brief Function to check if chip requires errata 154 - * - * Errata: During setup read/write transfer USBD acknowledges setup stage without SETUP task. - * - * @retval true Errata should be implemented - * @retval false Errata should not be implemented - */ -static inline bool nrf_drv_usbd_errata_154(void) -{ - return NRF_DRV_USBD_ERRATA_ENABLE && nrf_drv_usbd_errata_type_52840_proto1(); -} - -/** - * @brief Function to check if chip requires errata 166 - * - * Errata: ISO double buffering not functional - * - * @retval true Errata should be implemented - * @retval false Errata should not be implemented - */ -static inline bool nrf_drv_usbd_errata_166(void) -{ - return NRF_DRV_USBD_ERRATA_ENABLE && true; -} - -/** - * @brief Function to check if chip requires errata 171 - * - * Errata: USBD might not reach its active state. - * - * @retval true Errata should be implemented - * @retval false Errata should not be implemented - */ -static inline bool nrf_drv_usbd_errata_171(void) -{ - return NRF_DRV_USBD_ERRATA_ENABLE && true; -} - -/** - * @brief Function to check if chip requires errata 187 - * - * Errata: USB cannot be enabled - * - * @retval true Errata should be implemented - * @retval false Errata should not be implemented - */ -static inline bool nrf_drv_usbd_errata_187(void) -{ - return NRF_DRV_USBD_ERRATA_ENABLE && nrf_drv_usbd_errata_type_52840_fp1(); -} - -/** - * @brief Function to check if chip requires errata ??? - * - * Errata: SIZE.EPOUT not writable - * - * @retval true Errata should be implemented - * @retval false Errata should not be implemented - */ -static inline bool nrf_drv_usbd_errata_sizeepout_rw(void) -{ - return NRF_DRV_USBD_ERRATA_ENABLE && nrf_drv_usbd_errata_type_52840_proto1(); -} - -/** - * @brief Function to check if chip requires errata 199 - * - * Errata: USBD cannot receive tasks during DMA - * - * @retval true Errata should be implemented - * @retval false Errata should not be implemented - */ -static inline bool nrf_drv_usb_errata_199(void) -{ - return NRF_DRV_USBD_ERRATA_ENABLE && true; -} - -/** @} */ -#endif /* NRF_DRV_USBD_ERRATA_H__ */ -- cgit v1.2.3