mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-25 10:43:44 +00:00
commit
074898099d
22
README.md
22
README.md
@ -2,7 +2,7 @@
|
||||
|
||||
[](https://travis-ci.org/hathach/tinyusb) [](https://opensource.org/licenses/MIT)
|
||||
|
||||
TinyUSB is an open-source cross-platform USB Host/Device stack for embedded system.
|
||||
TinyUSB is an open-source cross-platform USB Host/Device stack for embedded system. It is designed to be memory-safe with no dynamic allocation and thread-safe with all interrupt events are deferred then handled in the stack's task function.
|
||||
|
||||

|
||||
|
||||
@ -21,8 +21,10 @@ TinyUSB is an open-source cross-platform USB Host/Device stack for embedded syst
|
||||
|
||||
## Device Stack
|
||||
|
||||
- Human Interface Device (HID): Keyboard, Mouse, Generic
|
||||
Support multiple device configurations by dynamically changing usb descriptors. Low power functions such as suspend, resume and remote wakeup. Following device classes are supported:
|
||||
|
||||
- Communication Class (CDC)
|
||||
- Human Interface Device (HID): Keyboard, Mouse, Generic
|
||||
- Mass Storage Class (MSC)
|
||||
- Musical Instrument Digital Interface (MIDI)
|
||||
|
||||
@ -61,6 +63,14 @@ The stack is developed with GCC compiler, and should be compilable with others.
|
||||
|
||||
[Here is the details for getting started](docs/getting_started.md) with the stack.
|
||||
|
||||
## Porting
|
||||
|
||||
Want to help add TinyUSB support for a new MCU? Read [here](docs/porting.md) for an explanation on the low-level API needed by TinyUSB.
|
||||
|
||||
## License
|
||||
|
||||
MIT license for all TinyUSB sources `src` folder, [Full license is here](LICENSE). However each file is individually licensed especially those in `lib` and `hw/mcu` folder. Please make sure you understand all the license term for files you use in your project.
|
||||
|
||||
## Uses
|
||||
|
||||
TinyUSB is currently used by these other projects:
|
||||
@ -69,10 +79,4 @@ TinyUSB is currently used by these other projects:
|
||||
* [Adafruit nRF52 Bootloader](https://github.com/adafruit/Adafruit_nRF52_Bootloader)
|
||||
* [CircuitPython](https://github.com/adafruit/circuitpython)
|
||||
|
||||
## Porting
|
||||
|
||||
Want to help add TinyUSB support for a new MCU? Read [here](docs/porting.md) for an explanation on the low-level API needed by TinyUSB.
|
||||
|
||||
## License
|
||||
|
||||
MIT license for all tinyusb sources [Full license is here](tinyusb/license.md) and most of the code base. However each file/folder is individually licensed especially those in `lib` and `hw/mcu` folder. Please make sure you understand all the license term for files you use in your project.
|
||||
If your project also uses TinyUSB and want to share, feel free to create a pull request.
|
||||
|
@ -1,14 +1,19 @@
|
||||
# Boards #
|
||||
# Boards
|
||||
|
||||
## Supported Boards ##
|
||||
The board support code is only used for self-contained examples and testing. It is not used when TinyUSB is part of a larger project. It is responsible for getting the MCU started and the USB peripheral clocked withminimal of on-board devices
|
||||
- One LED for status with different blink pattern
|
||||
- One Button to get input from user
|
||||
- One UART optionally, mostly for host examples
|
||||
|
||||
## Supported Boards
|
||||
|
||||
This code base already had supported for a handful of following boards
|
||||
|
||||
### Nordic nRF5x ###
|
||||
### Nordic nRF5x
|
||||
|
||||
- [nRF52840-DK (aka pca10056)](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-DK)
|
||||
|
||||
### NXP LPC ###
|
||||
### NXP LPC
|
||||
|
||||
- [LPCXpresso 11U68](https://www.nxp.com/support/developer-resources/evaluation-and-development-boards/lpcxpresso-boards/lpcxpresso-board-for-lpc11u68:OM13058)
|
||||
- [LPCXpresso 1347](https://www.nxp.com/support/developer-resources/evaluation-and-development-boards/lpcxpresso-boards/lpcxpresso-board-for-lpc1347:OM13045)
|
||||
@ -17,17 +22,46 @@ This code base already had supported for a handful of following boards
|
||||
- [Embedded Artists LPC4088 Quick Start board](https://www.embeddedartists.com/products/lpc4088-quickstart-board)
|
||||
- [Embedded Artists LPC4357 Developer Kit](http://www.embeddedartists.com/products/kits/lpc4357_kit.php)
|
||||
|
||||
### MicroChip SAMD ###
|
||||
### MicroChip SAMD
|
||||
|
||||
- [Adafruit Metro M0 Express](https://www.adafruit.com/product/3505)
|
||||
- [Adafruit Metro M4 Express](https://www.adafruit.com/product/3382)
|
||||
|
||||
### ST STM32 ###
|
||||
### ST STM32
|
||||
|
||||
- [STM32F4 Discovery](https://www.st.com/en/evaluation-tools/stm32f4discovery.html)
|
||||
|
||||
## Add your own board ##
|
||||
## Add your own board
|
||||
|
||||
If you don't possess any of supported board above. Don't worry you can easily implemented your own one by following this guide as long as the mcu is supported.
|
||||
|
||||
**Guide to implement a new board is coming soon** ...
|
||||
- Create new makefile for your board at `hw/bsp/<board name>/board.mk` and linker file as well if needed.
|
||||
- Create new source file for your board at `hw/bsp/<board name>/board_<board name>.c` and implement following APIs
|
||||
|
||||
### Board APIs
|
||||
|
||||
#### board_init()
|
||||
|
||||
Is responsible for starting the MCU, setting up the USB clock and USB pins. It is also responsible for initializing LED and button pins.
|
||||
One useful clock debugging technique is to set up a PWM output at a known value such as 500hz based on the USB clock so that you can verify it is correct with a logic probe or oscilloscope.
|
||||
Setup your USB in a crystal-less mode when available. That makes the code easier to port across boards.
|
||||
|
||||
#### board_led_write()
|
||||
|
||||
Set the pin corresponding to the led to output a value that lights the LED when `state` is true.
|
||||
|
||||
#### board_button_read()
|
||||
|
||||
Return current state of button, a `1` means active (pressed), a `0` means inactive.
|
||||
|
||||
#### board_millis()
|
||||
|
||||
The function returns the elapsed number of milliseconds since startup. On ARM this is commonly done with SysTick or Timer. This provide examples a way to measure time to blink LED or delay properly. It is only required when run examples without RTOS `CFG_TUSB_OS == OPT_OS_NONE`.
|
||||
|
||||
#### board_uart_read()
|
||||
|
||||
Get characters from UART peripheral.
|
||||
|
||||
#### board_uart_write()
|
||||
|
||||
Send characters to UART peripheral.
|
||||
|
@ -44,7 +44,7 @@ One useful clock debugging technique is to set up a PWM output at a known value
|
||||
|
||||
Setup your USB in a crystal-less mode when available. That makes the code easier to port across boards.
|
||||
|
||||
#### board_led_control
|
||||
#### board_led_write
|
||||
Feel free to skip this until you want to verify your demo code is running. To implement, set the pin corresponding to the led to output a value that lights the LED when `state` is true.
|
||||
|
||||
### OS Abstraction Layer (OSAL)
|
||||
|
@ -20,7 +20,7 @@
|
||||
arm_target_interface_type="SWD"
|
||||
build_treat_warnings_as_errors="Yes"
|
||||
c_preprocessor_definitions="NRF52840_XXAA;__nRF_FAMILY;ARM_MATH_CM4;FLASH_PLACEMENT=1;CFG_TUSB_MCU=OPT_MCU_NRF5X"
|
||||
c_user_include_directories="../../src;$(rootDir)/hw/cmsis/Include;$(rootDir)/hw;$(rootDir)/src;$(nrfxDir)/..;$(nrfxDir);$(nrfxDir)/mdk;$(nrfxDir)/hal;$(nrfxDir)/drivers/include"
|
||||
c_user_include_directories="../../src;$(rootDir)/hw/cmsis/Include;$(rootDir)/hw;$(rootDir)/src;$(nrfxDir)/..;$(nrfxDir);$(nrfxDir)/mdk;$(nrfxDir)/hal;$(nrfxDir)/drivers/include;$(nrfxDir)/drivers/src"
|
||||
debug_register_definition_file="nrf52840_Registers.xml"
|
||||
debug_target_connection="J-Link"
|
||||
gcc_enable_all_warnings="Yes"
|
||||
|
@ -245,6 +245,6 @@ void led_blinking_task(void)
|
||||
if ( board_millis() < start_ms + blink_interval_ms) return; // not enough time
|
||||
start_ms += blink_interval_ms;
|
||||
|
||||
board_led_control(led_state);
|
||||
board_led_write(led_state);
|
||||
led_state = 1 - led_state; // toggle
|
||||
}
|
||||
|
@ -230,6 +230,6 @@ void led_blinky_cb(TimerHandle_t xTimer)
|
||||
(void) xTimer;
|
||||
static bool led_state = false;
|
||||
|
||||
board_led_control(led_state);
|
||||
board_led_write(led_state);
|
||||
led_state = 1 - led_state; // toggle
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ void led_blinking_task(void)
|
||||
if ( board_millis() < start_ms + interval_ms) return; // not enough time
|
||||
start_ms += interval_ms;
|
||||
|
||||
board_led_control(led_state);
|
||||
board_led_write(led_state);
|
||||
led_state = 1 - led_state; // toggle
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@
|
||||
void board_init(void);
|
||||
|
||||
// Turn LED on or off
|
||||
void board_led_control(bool state);
|
||||
void board_led_write(bool state);
|
||||
|
||||
// Get the current state of button
|
||||
// a '1' means active (pressed), a '0' means inactive.
|
||||
@ -87,12 +87,12 @@ int board_uart_write(void const * buf, int len);
|
||||
//--------------------------------------------------------------------+
|
||||
static inline void board_led_on(void)
|
||||
{
|
||||
board_led_control(true);
|
||||
board_led_write(true);
|
||||
}
|
||||
|
||||
static inline void board_led_off(void)
|
||||
{
|
||||
board_led_control(false);
|
||||
board_led_write(false);
|
||||
}
|
||||
|
||||
static inline int8_t board_uart_getchar(void)
|
||||
|
@ -114,7 +114,7 @@ void board_init(void)
|
||||
|
||||
|
||||
//------------- LED -------------//
|
||||
void board_led_control(bool state)
|
||||
void board_led_write(bool state)
|
||||
{
|
||||
Chip_GPIO_SetPinState(LPC_GPIO, LED_PORT, LED_PIN, state);
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ void board_init(void)
|
||||
}
|
||||
|
||||
// LED
|
||||
void board_led_control(bool state)
|
||||
void board_led_write(bool state)
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ uint32_t board_millis(void)
|
||||
//--------------------------------------------------------------------+
|
||||
// LEDS
|
||||
//--------------------------------------------------------------------+
|
||||
void board_led_control(bool state)
|
||||
void board_led_write(bool state)
|
||||
{
|
||||
Chip_GPIO_SetPinState(LPC_GPIO, LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ uint32_t board_millis(void)
|
||||
//--------------------------------------------------------------------+
|
||||
// LEDS
|
||||
//--------------------------------------------------------------------+
|
||||
void board_led_control(bool state)
|
||||
void board_led_write(bool state)
|
||||
{
|
||||
Chip_GPIO_SetPinState(LPC_GPIO_PORT, LED_PORT, LED_PIN, state);
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ uint32_t board_millis(void)
|
||||
//--------------------------------------------------------------------+
|
||||
// LEDS
|
||||
//--------------------------------------------------------------------+
|
||||
void board_led_control(bool state)
|
||||
void board_led_write(bool state)
|
||||
{
|
||||
Chip_GPIO_SetPinState(LPC_GPIO, LED_PORT, LED_PIN, state);
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ void board_init(void)
|
||||
}
|
||||
|
||||
//------------- LED -------------//
|
||||
void board_led_control(bool state)
|
||||
void board_led_write(bool state)
|
||||
{
|
||||
Chip_GPIO_SetPinState(LPC_GPIO_PORT, LED_PORT, LED_PIN, state);
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ void board_init(void)
|
||||
_gclk_enable_channel(TCC0_GCLK_ID, GCLK_CLKCTRL_GEN_GCLK0_Val);
|
||||
}
|
||||
|
||||
void board_led_control(bool state)
|
||||
void board_led_write(bool state)
|
||||
{
|
||||
gpio_set_pin_level(LED_PIN, state);
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ void board_init(void)
|
||||
gpio_set_pin_function(PIN_PA25, PINMUX_PA25H_USB_DP);
|
||||
}
|
||||
|
||||
void board_led_control(bool state)
|
||||
void board_led_write(bool state)
|
||||
{
|
||||
gpio_set_pin_level(LED_PIN, state);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ INC += \
|
||||
-I$(TOP)/hw/mcu/nordic/nrfx/mdk \
|
||||
-I$(TOP)/hw/mcu/nordic/nrfx/hal \
|
||||
-I$(TOP)/hw/mcu/nordic/nrfx/drivers/include \
|
||||
-I$(TOP)/hw/mcu/nordic/nrfx/drivers/src \
|
||||
|
||||
SRC_S += hw/mcu/nordic/nrfx/mdk/gcc_startup_nrf52840.S
|
||||
|
||||
|
@ -78,7 +78,7 @@ void board_init(void)
|
||||
|
||||
// LED
|
||||
nrf_gpio_cfg_output(LED_PIN);
|
||||
board_led_control(false);
|
||||
board_led_write(false);
|
||||
|
||||
// Button
|
||||
nrf_gpio_cfg_input(BUTTON_PIN, NRF_GPIO_PIN_PULLUP);
|
||||
@ -126,7 +126,7 @@ void board_init(void)
|
||||
if ( usb_reg & POWER_USBREGSTATUS_OUTPUTRDY_Msk ) tusb_hal_nrf_power_event(NRFX_POWER_USB_EVT_READY);
|
||||
}
|
||||
|
||||
void board_led_control(bool state)
|
||||
void board_led_write(bool state)
|
||||
{
|
||||
nrf_gpio_pin_write(LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ void board_init(void)
|
||||
}
|
||||
|
||||
|
||||
void board_led_control(bool state)
|
||||
void board_led_write(bool state)
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_9, state);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ void board_init(void)
|
||||
}
|
||||
|
||||
|
||||
void board_led_control(bool state)
|
||||
void board_led_write(bool state)
|
||||
{
|
||||
if (!state) {
|
||||
GPIOD->BSRR = GPIO_BSRR_BR14;
|
||||
|
@ -34,7 +34,6 @@
|
||||
/** \addtogroup group_osal
|
||||
* @{ */
|
||||
|
||||
#include "tusb_option.h"
|
||||
#include "common/tusb_common.h"
|
||||
|
||||
enum
|
||||
@ -48,34 +47,33 @@ enum
|
||||
|
||||
typedef void (*osal_task_func_t)( void * );
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// OSAL Porting API
|
||||
//--------------------------------------------------------------------+
|
||||
#if 0
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
//------------- 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
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
#include "osal_none.h"
|
||||
#else
|
||||
/* RTOS Porting API
|
||||
*
|
||||
* Task
|
||||
* void osal_task_delay(uint32_t msec)
|
||||
*
|
||||
* Queue
|
||||
* osal_queue_def_t, osal_queue_t
|
||||
* osal_queue_t osal_queue_create(osal_queue_def_t* qdef)
|
||||
* osal_queue_receive (osal_queue_t const queue_hdl, void *p_data, uint32_t msec, uint32_t *p_error)
|
||||
* bool osal_queue_send(osal_queue_t const queue_hdl, void const * data, bool in_isr)
|
||||
*
|
||||
* Semaphore
|
||||
* osal_semaphore_def_t, osal_semaphore_t
|
||||
* 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)
|
||||
* void osal_semaphore_reset(osal_semaphore_t const sem_hdl)
|
||||
*
|
||||
* Mutex
|
||||
* osal_mutex_t
|
||||
* osal_mutex_create(osal_mutex_def_t* mdef)
|
||||
* bool osal_mutex_unlock(osal_mutex_t mutex_hdl)
|
||||
* void osal_mutex_lock(osal_mutex_t mutex_hdl, uint32_t msec, uint32_t *p_error)
|
||||
*/
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_FREERTOS
|
||||
#include "osal_freertos.h"
|
||||
#elif CFG_TUSB_OS == OPT_OS_MYNEWT
|
||||
|
@ -83,7 +83,10 @@ static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef)
|
||||
return xSemaphoreCreateMutexStatic(mdef);
|
||||
}
|
||||
|
||||
#define osal_mutex_lock osal_semaphore_wait
|
||||
static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec)
|
||||
{
|
||||
return osal_semaphore_wait(mutex_hdl, msec);
|
||||
}
|
||||
|
||||
static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl)
|
||||
{
|
||||
|
@ -95,8 +95,15 @@ static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef)
|
||||
return mdef;
|
||||
}
|
||||
|
||||
#define osal_mutex_lock osal_semaphore_wait
|
||||
#define osal_mutex_unlock(_mutex_hdl) osal_semaphore_post(_mutex_hdl, false)
|
||||
static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec)
|
||||
{
|
||||
return osal_semaphore_wait(mutex_hdl, msec);
|
||||
}
|
||||
|
||||
static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl)
|
||||
{
|
||||
return osal_semaphore_post(mutex_hdl, false);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// QUEUE API
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "nrf_gpio.h"
|
||||
#include "nrf_clock.h"
|
||||
#include "nrf_usbd.h"
|
||||
#include "nrf_drv_usbd_errata.h"
|
||||
#include "nrfx_usbd_errata.h"
|
||||
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
#include "nrf_sdm.h"
|
||||
@ -122,7 +122,7 @@ void tusb_hal_nrf_power_event (uint32_t event)
|
||||
/* Enable the peripheral */
|
||||
// ERRATA 171, 187, 166
|
||||
|
||||
if ( nrf_drv_usbd_errata_187() )
|
||||
if ( nrfx_usbd_errata_187() )
|
||||
{
|
||||
// CRITICAL_REGION_ENTER();
|
||||
if ( *((volatile uint32_t *) (0x4006EC00)) == 0x00000000 )
|
||||
@ -138,7 +138,7 @@ void tusb_hal_nrf_power_event (uint32_t event)
|
||||
// CRITICAL_REGION_EXIT();
|
||||
}
|
||||
|
||||
if ( nrf_drv_usbd_errata_171() )
|
||||
if ( nrfx_usbd_errata_171() )
|
||||
{
|
||||
// CRITICAL_REGION_ENTER();
|
||||
if ( *((volatile uint32_t *) (0x4006EC00)) == 0x00000000 )
|
||||
@ -168,7 +168,7 @@ void tusb_hal_nrf_power_event (uint32_t event)
|
||||
nrf_usbd_eventcause_clear(USBD_EVENTCAUSE_READY_Msk);
|
||||
nrf_usbd_event_clear(USBD_EVENTCAUSE_READY_Msk);
|
||||
|
||||
if ( nrf_drv_usbd_errata_171() )
|
||||
if ( nrfx_usbd_errata_171() )
|
||||
{
|
||||
// CRITICAL_REGION_ENTER();
|
||||
if ( *((volatile uint32_t *) (0x4006EC00)) == 0x00000000 )
|
||||
@ -185,7 +185,7 @@ void tusb_hal_nrf_power_event (uint32_t event)
|
||||
// CRITICAL_REGION_EXIT();
|
||||
}
|
||||
|
||||
if ( nrf_drv_usbd_errata_187() )
|
||||
if ( nrfx_usbd_errata_187() )
|
||||
{
|
||||
// CRITICAL_REGION_ENTER();
|
||||
if ( *((volatile uint32_t *) (0x4006EC00)) == 0x00000000 )
|
||||
@ -201,7 +201,7 @@ void tusb_hal_nrf_power_event (uint32_t event)
|
||||
// CRITICAL_REGION_EXIT();
|
||||
}
|
||||
|
||||
if ( nrf_drv_usbd_errata_166() )
|
||||
if ( nrfx_usbd_errata_166() )
|
||||
{
|
||||
*((volatile uint32_t *) (NRF_USBD_BASE + 0x800)) = 0x7E3;
|
||||
*((volatile uint32_t *) (NRF_USBD_BASE + 0x804)) = 0x40;
|
||||
|
@ -1,210 +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 <stdbool.h>
|
||||
/**
|
||||
* @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 *)0x10000130UL == 0x8UL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Internal auxiliary function to check if the program is running on Engineering A revision
|
||||
* @retval true It is NRF52480 chip and it is Engineering A revision
|
||||
* @retval false It is other chip
|
||||
*/
|
||||
static inline bool nrf_drv_usbd_errata_type_52840_eng_a(void)
|
||||
{
|
||||
return (nrf_drv_usbd_errata_type_52840() && (*(uint32_t *)0x10000134UL == 0x0UL));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Internal auxiliary function to check if the program is running on Engineering B revision
|
||||
* @retval true It is NRF52480 chip and it is Engineering B revision
|
||||
* @retval false It is other chip
|
||||
*/
|
||||
static inline bool nrf_drv_usbd_errata_type_52840_eng_b(void)
|
||||
{
|
||||
return (nrf_drv_usbd_errata_type_52840() && (*(uint32_t *)0x10000134UL == 0x1UL));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Internal auxiliary function to check if the program is running on Engineering C revision
|
||||
* @retval true It is NRF52480 chip and it is Engineering C revision
|
||||
* @retval false It is other chip
|
||||
*/
|
||||
static inline bool nrf_drv_usbd_errata_type_52840_eng_c(void)
|
||||
{
|
||||
return (nrf_drv_usbd_errata_type_52840() && (*(uint32_t *)0x10000134UL == 0x2UL));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Internal auxiliary function to check if the program is running on Engineering D revision
|
||||
* @retval true It is NRF52480 chip and it is Engineering D revision
|
||||
* @retval false It is other chip
|
||||
*/
|
||||
static inline bool nrf_drv_usbd_errata_type_52840_eng_d(void)
|
||||
{
|
||||
return (nrf_drv_usbd_errata_type_52840() && (*(uint32_t *)0x10000134UL == 0x3UL));
|
||||
}
|
||||
|
||||
/**
|
||||
* @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_eng_a());
|
||||
}
|
||||
|
||||
/**
|
||||
* @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_eng_a());
|
||||
}
|
||||
|
||||
/**
|
||||
* @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_eng_b() ||
|
||||
nrf_drv_usbd_errata_type_52840_eng_c() ||
|
||||
nrf_drv_usbd_errata_type_52840_eng_d())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function to check if chip requires errata 200
|
||||
*
|
||||
* 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_200(void)
|
||||
{
|
||||
return (NRF_DRV_USBD_ERRATA_ENABLE && nrf_drv_usbd_errata_type_52840_eng_a());
|
||||
}
|
||||
|
||||
/** @} */
|
||||
#endif /* NRF_DRV_USBD_ERRATA_H__ */
|
Loading…
x
Reference in New Issue
Block a user