mirror of
https://github.com/espressif/openthread.git
synced 2026-09-05 16:50:05 +00:00
[nrf52840] update drivers to SDK 15.1.0 (#3003)
This commit is contained in:
@@ -61,10 +61,12 @@ COMMONCPPFLAGS
|
||||
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/app_error \
|
||||
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/atfifo \
|
||||
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/atomic \
|
||||
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/delay \
|
||||
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb \
|
||||
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/config \
|
||||
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc \
|
||||
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm \
|
||||
-I$(top_srcdir)/third_party/NordicSemiconductor/libraries/utf_converter \
|
||||
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx \
|
||||
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/hal \
|
||||
-I$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers \
|
||||
@@ -175,6 +177,7 @@ NORDICSEMI_SOURCES
|
||||
@top_builddir@/third_party/NordicSemiconductor/libraries/usb/app_usbd_string_desc.c \
|
||||
@top_builddir@/third_party/NordicSemiconductor/libraries/usb/app_usbd_serial_num.c \
|
||||
@top_builddir@/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm.c \
|
||||
@top_builddir@/third_party/NordicSemiconductor/libraries/utf_converter/utf.c \
|
||||
@top_builddir@/third_party/NordicSemiconductor/nrfx/drivers/src/nrfx_clock.c \
|
||||
@top_builddir@/third_party/NordicSemiconductor/nrfx/drivers/src/nrfx_power.c \
|
||||
@top_builddir@/third_party/NordicSemiconductor/nrfx/drivers/src/nrfx_systick.c \
|
||||
@@ -306,6 +309,7 @@ noinst_HEADERS
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/atfifo/nrf_atfifo.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic_internal.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/delay/nrf_delay.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_class_base.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_core.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_descriptor.h \
|
||||
@@ -320,6 +324,7 @@ noinst_HEADERS
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm_internal.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/config/app_usbd_string_config.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/utf_converter/utf.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/nrfx_common.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/nrfx_errors.h \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/nrfx/drivers/include/nrfx_clock.h \
|
||||
|
||||
@@ -30,17 +30,17 @@
|
||||
# nrf52840 platform-specific Makefile
|
||||
#
|
||||
|
||||
LDADD_COMMON += \
|
||||
$(top_builddir)/examples/platforms/nrf52840/libopenthread-nrf52840.a \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/nrf_cc310/lib/libnrf_cc310_0.9.9.a \
|
||||
LDADD_COMMON += \
|
||||
$(top_builddir)/examples/platforms/nrf52840/libopenthread-nrf52840.a \
|
||||
$(top_srcdir)/third_party/NordicSemiconductor/libraries/nrf_cc310/lib/libnrf_cc310_0.9.10.a \
|
||||
$(NULL)
|
||||
|
||||
if OPENTHREAD_ENABLE_CUSTOM_LINKER_FILE
|
||||
LDFLAGS_COMMON += \
|
||||
-T $(OPENTHREAD_CUSTOM_LINKER_FILE) \
|
||||
LDFLAGS_COMMON += \
|
||||
-T $(OPENTHREAD_CUSTOM_LINKER_FILE) \
|
||||
$(NULL)
|
||||
else
|
||||
LDFLAGS_COMMON += \
|
||||
-T $(top_srcdir)/examples/platforms/nrf52840/nrf52840.ld \
|
||||
LDFLAGS_COMMON += \
|
||||
-T $(top_srcdir)/examples/platforms/nrf52840/nrf52840.ld \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
+124
-18
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2012 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
/** @file
|
||||
*
|
||||
@@ -96,12 +96,12 @@ extern uint32_t __StackLimit;
|
||||
#define CODE_SIZE (0x1000) // Arbitrary value.
|
||||
|
||||
#elif defined ( __CC_ARM )
|
||||
extern char Image$$ER_IROM1$$Base;
|
||||
extern char Image$$ER_IROM1$$Length;
|
||||
extern char Image$$ER_IROM1$$Limit;
|
||||
#define CODE_START ((uint32_t)&Image$$ER_IROM1$$Base)
|
||||
#define CODE_END ((uint32_t)&Image$$ER_IROM1$$Limit)
|
||||
#define CODE_SIZE ((uint32_t)&Image$$ER_IROM1$$Length)
|
||||
extern char Load$$LR$$LR_IROM1$$Base;
|
||||
extern char Load$$LR$$LR_IROM1$$Length;
|
||||
extern char Load$$LR$$LR_IROM1$$Limit;
|
||||
#define CODE_START ((uint32_t)&Load$$LR$$LR_IROM1$$Base)
|
||||
#define CODE_END ((uint32_t)&Load$$LR$$LR_IROM1$$Limit)
|
||||
#define CODE_SIZE ((uint32_t)&Load$$LR$$LR_IROM1$$Length)
|
||||
|
||||
#elif defined ( __ICCARM__ )
|
||||
extern void * __vector_table;
|
||||
@@ -225,7 +225,7 @@ enum
|
||||
#endif
|
||||
|
||||
|
||||
#define _SELECT_ASSERT_FUNC(x, EXPR, MSG, ASSERT_MACRO) ASSERT_MACRO
|
||||
#define _SELECT_ASSERT_FUNC(x, EXPR, MSG, ASSERT_MACRO, ...) ASSERT_MACRO
|
||||
|
||||
/**
|
||||
* @brief Static (i.e. compile time) assert macro.
|
||||
@@ -432,7 +432,7 @@ typedef struct
|
||||
*
|
||||
* Macro that extracts selected bit-field from provided value
|
||||
*
|
||||
* @param[in] val Value from witch selected bit-field would be extracted
|
||||
* @param[in] val Value from which selected bit-field would be extracted
|
||||
* @param[in] bcnt Number of bits in the bit-field
|
||||
* @param[in] boff Lowest bit number
|
||||
*
|
||||
@@ -526,7 +526,7 @@ typedef struct
|
||||
* @sa BF_CX
|
||||
* @sa BF_GET
|
||||
*
|
||||
* @param[in] val Value from witch selected bit-field would be extracted
|
||||
* @param[in] val Value from which selected bit-field would be extracted
|
||||
* @param[in] bf_cx Complex bit-field
|
||||
*
|
||||
* @return Value of the selected bits.
|
||||
@@ -710,6 +710,24 @@ typedef struct
|
||||
#define MACRO_MAP_13(macro, a, ...) macro(a) MACRO_MAP_12(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_14(macro, a, ...) macro(a) MACRO_MAP_13(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_15(macro, a, ...) macro(a) MACRO_MAP_14(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_16(macro, a, ...) macro(a) MACRO_MAP_15(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_17(macro, a, ...) macro(a) MACRO_MAP_16(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_18(macro, a, ...) macro(a) MACRO_MAP_17(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_19(macro, a, ...) macro(a) MACRO_MAP_18(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_20(macro, a, ...) macro(a) MACRO_MAP_19(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_21(macro, a, ...) macro(a) MACRO_MAP_20(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_22(macro, a, ...) macro(a) MACRO_MAP_21(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_23(macro, a, ...) macro(a) MACRO_MAP_22(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_24(macro, a, ...) macro(a) MACRO_MAP_23(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_25(macro, a, ...) macro(a) MACRO_MAP_24(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_26(macro, a, ...) macro(a) MACRO_MAP_25(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_27(macro, a, ...) macro(a) MACRO_MAP_26(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_28(macro, a, ...) macro(a) MACRO_MAP_27(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_29(macro, a, ...) macro(a) MACRO_MAP_28(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_30(macro, a, ...) macro(a) MACRO_MAP_29(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_31(macro, a, ...) macro(a) MACRO_MAP_30(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_32(macro, a, ...) macro(a) MACRO_MAP_31(macro, __VA_ARGS__, )
|
||||
|
||||
|
||||
#define MACRO_MAP_REC_0( ...)
|
||||
#define MACRO_MAP_REC_1( macro, a, ...) macro(a)
|
||||
@@ -727,6 +745,24 @@ typedef struct
|
||||
#define MACRO_MAP_REC_13(macro, a, ...) macro(a) MACRO_MAP_REC_12(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_REC_14(macro, a, ...) macro(a) MACRO_MAP_REC_13(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_REC_15(macro, a, ...) macro(a) MACRO_MAP_REC_14(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_REC_16(macro, a, ...) macro(a) MACRO_MAP_REC_15(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_REC_17(macro, a, ...) macro(a) MACRO_MAP_REC_16(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_REC_18(macro, a, ...) macro(a) MACRO_MAP_REC_17(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_REC_19(macro, a, ...) macro(a) MACRO_MAP_REC_18(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_REC_20(macro, a, ...) macro(a) MACRO_MAP_REC_19(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_REC_21(macro, a, ...) macro(a) MACRO_MAP_REC_20(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_REC_22(macro, a, ...) macro(a) MACRO_MAP_REC_21(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_REC_23(macro, a, ...) macro(a) MACRO_MAP_REC_22(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_REC_24(macro, a, ...) macro(a) MACRO_MAP_REC_23(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_REC_25(macro, a, ...) macro(a) MACRO_MAP_REC_24(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_REC_26(macro, a, ...) macro(a) MACRO_MAP_REC_25(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_REC_27(macro, a, ...) macro(a) MACRO_MAP_REC_26(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_REC_28(macro, a, ...) macro(a) MACRO_MAP_REC_27(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_REC_29(macro, a, ...) macro(a) MACRO_MAP_REC_28(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_REC_30(macro, a, ...) macro(a) MACRO_MAP_REC_29(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_REC_31(macro, a, ...) macro(a) MACRO_MAP_REC_30(macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_REC_32(macro, a, ...) macro(a) MACRO_MAP_REC_31(macro, __VA_ARGS__, )
|
||||
|
||||
|
||||
/**
|
||||
* @brief Mapping macro with current index
|
||||
@@ -773,6 +809,23 @@ typedef struct
|
||||
#define MACRO_MAP_FOR_13(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_12((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_14(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_13((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_15(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_14((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_16(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_15((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_17(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_16((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_18(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_17((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_19(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_18((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_20(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_19((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_21(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_20((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_22(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_21((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_23(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_22((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_24(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_23((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_25(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_24((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_26(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_25((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_27(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_26((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_28(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_27((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_29(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_28((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_30(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_29((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_31(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_30((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_32(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_31((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, )
|
||||
|
||||
|
||||
/**
|
||||
@@ -819,6 +872,24 @@ typedef struct
|
||||
#define MACRO_MAP_FOR_PARAM_13(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_12((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_PARAM_14(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_13((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_PARAM_15(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_14((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_PARAM_16(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_15((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_PARAM_17(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_16((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_PARAM_18(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_17((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_PARAM_19(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_18((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_PARAM_20(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_19((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_PARAM_21(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_20((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_PARAM_22(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_21((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_PARAM_23(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_22((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_PARAM_24(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_23((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_PARAM_25(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_24((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_PARAM_26(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_25((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_PARAM_27(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_26((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_PARAM_28(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_27((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_PARAM_29(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_28((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_PARAM_30(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_29((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_PARAM_31(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_30((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, )
|
||||
#define MACRO_MAP_FOR_PARAM_32(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_31((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, )
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -849,6 +920,23 @@ typedef struct
|
||||
#define MACRO_REPEAT_13(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_12(macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_14(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_13(macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_15(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_14(macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_16(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_15(macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_17(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_16(macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_18(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_17(macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_19(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_18(macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_20(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_19(macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_21(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_20(macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_22(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_21(macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_23(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_22(macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_24(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_23(macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_25(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_24(macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_26(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_25(macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_27(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_26(macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_28(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_27(macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_29(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_28(macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_30(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_29(macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_31(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_30(macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_32(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_31(macro, __VA_ARGS__)
|
||||
|
||||
|
||||
/**
|
||||
@@ -882,6 +970,24 @@ typedef struct
|
||||
#define MACRO_REPEAT_FOR_13(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_12((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_FOR_14(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_13((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_FOR_15(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_14((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_FOR_16(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_15((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_FOR_17(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_16((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_FOR_18(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_17((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_FOR_19(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_18((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_FOR_20(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_19((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_FOR_21(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_20((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_FOR_22(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_21((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_FOR_23(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_22((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_FOR_24(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_23((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_FOR_25(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_24((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_FOR_26(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_25((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_FOR_27(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_26((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_FOR_28(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_27((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_FOR_29(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_28((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_FOR_30(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_29((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_FOR_31(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_30((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
|
||||
#define MACRO_REPEAT_FOR_32(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_31((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__)
|
||||
|
||||
|
||||
/**@brief Adding curly brace to the macro parameter.
|
||||
*
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2014 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
#include "app_util_platform.h"
|
||||
|
||||
@@ -86,8 +86,8 @@ void app_util_critical_region_exit(uint8_t nested)
|
||||
/* return value can be safely ignored */
|
||||
(void) sd_nvic_critical_region_exit(nested);
|
||||
#else
|
||||
(void)nested;
|
||||
app_util_enable_irq();
|
||||
(void)nested;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2014 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
/**@file
|
||||
*
|
||||
|
||||
+14
-10
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2008 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
/** @file
|
||||
* @brief Common defines and macros for firmware developed by Nordic Semiconductor.
|
||||
@@ -73,9 +73,13 @@ extern "C" {
|
||||
* without evaluating its value.
|
||||
*/
|
||||
//lint -emacro(491,NRF_MODULE_ENABLED) // Suppers warning 491 "non-standard use of 'defined' preprocessor operator"
|
||||
#ifdef NRF_MODULE_ENABLE_ALL
|
||||
#warning "Do not use NRF_MODULE_ENABLE_ALL for real builds."
|
||||
#define NRF_MODULE_ENABLED(module) 1
|
||||
#else
|
||||
#define NRF_MODULE_ENABLED(module) \
|
||||
((defined(module ## _ENABLED) && (module ## _ENABLED)) ? 1 : 0)
|
||||
|
||||
#endif
|
||||
/** The upper 8 bits of a 32 bit value */
|
||||
//lint -emacro(572,MSB_32) // Suppress warning 572 "Excessive shift value"
|
||||
#define MSB_32(a) (((a) & 0xFF000000) >> 24)
|
||||
|
||||
+122
-52
@@ -1,52 +1,122 @@
|
||||
/* Copyright (c) 2016, 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 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @file
|
||||
* @brief Utilities for verifying program logic
|
||||
*/
|
||||
|
||||
#ifndef NRF_ASSERT_H_
|
||||
#define NRF_ASSERT_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ASSERT(expr) \
|
||||
if (!(expr)) \
|
||||
{ \
|
||||
while(1); \
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NRF_ASSERT_H_ */
|
||||
/**
|
||||
* Copyright (c) 2006 - 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.
|
||||
*
|
||||
*/
|
||||
/** @file
|
||||
* @brief Utilities for verifying program logic
|
||||
*/
|
||||
|
||||
#ifndef NRF_ASSERT_H_
|
||||
#define NRF_ASSERT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "nrf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @brief Function for handling assertions.
|
||||
*
|
||||
*
|
||||
* @note
|
||||
* This function is called when an assertion has triggered.
|
||||
*
|
||||
* @note
|
||||
* This function is deprecated and will be removed in future releases.
|
||||
* Use app_error_fault_handler instead.
|
||||
*
|
||||
*
|
||||
* @post
|
||||
* All hardware is put into an idle non-emitting state (in particular the radio is highly
|
||||
* important to switch off since the radio might be in a state that makes it send
|
||||
* packets continiously while a typical final infinit ASSERT loop is executing).
|
||||
*
|
||||
*
|
||||
* @param line_num The line number where the assertion is called
|
||||
* @param file_name Pointer to the file name
|
||||
*/
|
||||
//lint -save -esym(14, assert_nrf_callback)
|
||||
void assert_nrf_callback(uint16_t line_num, const uint8_t *file_name);
|
||||
//lint -restore
|
||||
|
||||
#if (defined(DEBUG_NRF) || defined(DEBUG_NRF_USER))
|
||||
#define NRF_ASSERT_PRESENT 1
|
||||
#else
|
||||
#define NRF_ASSERT_PRESENT 0
|
||||
#endif
|
||||
|
||||
//#if defined(DEBUG_NRF) || defined(DEBUG_NRF_USER)
|
||||
|
||||
/*lint -emacro(506, ASSERT) */ /* Suppress "Constant value Boolean */
|
||||
/*lint -emacro(774, ASSERT) */ /* Suppress "Boolean within 'if' always evaluates to True" */ \
|
||||
|
||||
/** @brief Function for checking intended for production code.
|
||||
*
|
||||
* Check passes if "expr" evaluates to true. */
|
||||
|
||||
#ifdef _lint
|
||||
#define ASSERT(expr) \
|
||||
if (expr) \
|
||||
{ \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
while (1); \
|
||||
}
|
||||
#else //_lint
|
||||
#define ASSERT(expr) \
|
||||
if (NRF_ASSERT_PRESENT) \
|
||||
{ \
|
||||
if (expr) \
|
||||
{ \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
assert_nrf_callback((uint16_t)__LINE__, (uint8_t *)__FILE__); \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NRF_ASSERT_H_ */
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2013 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
/** @cond */
|
||||
/**@file
|
||||
|
||||
@@ -61,6 +61,13 @@
|
||||
#define APP_USBD_CONFIG_SELF_POWERED 1
|
||||
#endif
|
||||
|
||||
// <o> APP_USBD_CONFIG_MAX_POWER - MaxPower field in configuration descriptor in milliamps. <0-500>
|
||||
|
||||
|
||||
#ifndef APP_USBD_CONFIG_MAX_POWER
|
||||
#define APP_USBD_CONFIG_MAX_POWER 500
|
||||
#endif
|
||||
|
||||
// <q> APP_USBD_CONFIG_POWER_EVENTS_PROCESS - Process power events
|
||||
|
||||
|
||||
@@ -119,6 +126,156 @@
|
||||
#define APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE 0
|
||||
#endif
|
||||
|
||||
// <o> APP_USBD_CONFIG_DESC_STRING_SIZE - Maximum size of the NULL-terminated string of the string descriptor. <31-254>
|
||||
|
||||
|
||||
// <i> 31 characters can be stored in the internal USB buffer used for transfers.
|
||||
// <i> Any value higher than 31 creates an additional buffer just for descriptor strings.
|
||||
|
||||
#ifndef APP_USBD_CONFIG_DESC_STRING_SIZE
|
||||
#define APP_USBD_CONFIG_DESC_STRING_SIZE 31
|
||||
#endif
|
||||
|
||||
// <q> APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED - Enable UTF8 conversion.
|
||||
|
||||
|
||||
// <i> Enable UTF8-encoded characters. In normal processing, only ASCII characters are available.
|
||||
|
||||
#ifndef APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED
|
||||
#define APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED 0
|
||||
#endif
|
||||
|
||||
// <s> APP_USBD_STRINGS_LANGIDS - Supported languages identifiers.
|
||||
|
||||
// <i> Note: This value is not editable in Configuration Wizard.
|
||||
// <i> Comma-separated list of supported languages.
|
||||
#ifndef APP_USBD_STRINGS_LANGIDS
|
||||
#define APP_USBD_STRINGS_LANGIDS APP_USBD_LANG_AND_SUBLANG(APP_USBD_LANG_ENGLISH, APP_USBD_SUBLANG_ENGLISH_US)
|
||||
#endif
|
||||
|
||||
// <e> APP_USBD_STRING_ID_MANUFACTURER - Define manufacturer string ID.
|
||||
|
||||
// <i> Setting ID to 0 disables the string.
|
||||
//==========================================================
|
||||
#ifndef APP_USBD_STRING_ID_MANUFACTURER
|
||||
#define APP_USBD_STRING_ID_MANUFACTURER 1
|
||||
#endif
|
||||
// <q> APP_USBD_STRINGS_MANUFACTURER_EXTERN - Define whether @ref APP_USBD_STRINGS_MANUFACTURER is created by macro or declared as a global variable.
|
||||
|
||||
|
||||
#ifndef APP_USBD_STRINGS_MANUFACTURER_EXTERN
|
||||
#define APP_USBD_STRINGS_MANUFACTURER_EXTERN 0
|
||||
#endif
|
||||
|
||||
// <s> APP_USBD_STRINGS_MANUFACTURER - String descriptor for the manufacturer name.
|
||||
|
||||
// <i> Note: This value is not editable in Configuration Wizard.
|
||||
// <i> Comma-separated list of manufacturer names for each defined language.
|
||||
// <i> Use @ref APP_USBD_STRING_DESC macro to create string descriptor from a NULL-terminated string.
|
||||
// <i> Use @ref APP_USBD_STRING_RAW8_DESC macro to create string descriptor from comma-separated uint8_t values.
|
||||
// <i> Use @ref APP_USBD_STRING_RAW16_DESC macro to create string descriptor from comma-separated uint16_t values.
|
||||
// <i> Alternatively, configure the macro to point to any internal variable pointer that already contains the descriptor.
|
||||
// <i> Setting string to NULL disables that string.
|
||||
// <i> The order of manufacturer names must be the same like in @ref APP_USBD_STRINGS_LANGIDS.
|
||||
#ifndef APP_USBD_STRINGS_MANUFACTURER
|
||||
#define APP_USBD_STRINGS_MANUFACTURER APP_USBD_STRING_DESC("Nordic Semiconductor")
|
||||
#endif
|
||||
|
||||
// </e>
|
||||
|
||||
// <e> APP_USBD_STRING_ID_PRODUCT - Define product string ID.
|
||||
|
||||
// <i> Setting ID to 0 disables the string.
|
||||
//==========================================================
|
||||
#ifndef APP_USBD_STRING_ID_PRODUCT
|
||||
#define APP_USBD_STRING_ID_PRODUCT 2
|
||||
#endif
|
||||
// <q> APP_USBD_STRINGS_PRODUCT_EXTERN - Define whether @ref APP_USBD_STRINGS_PRODUCT is created by macro or declared as a global variable.
|
||||
|
||||
|
||||
#ifndef APP_USBD_STRINGS_PRODUCT_EXTERN
|
||||
#define APP_USBD_STRINGS_PRODUCT_EXTERN 0
|
||||
#endif
|
||||
|
||||
// <s> APP_USBD_STRINGS_PRODUCT - String descriptor for the product name.
|
||||
|
||||
// <i> Note: This value is not editable in Configuration Wizard.
|
||||
// <i> List of product names that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER.
|
||||
#ifndef APP_USBD_STRINGS_PRODUCT
|
||||
#define APP_USBD_STRINGS_PRODUCT APP_USBD_STRING_DESC("nRF52840 OpenThread Device")
|
||||
#endif
|
||||
|
||||
// </e>
|
||||
|
||||
// <e> APP_USBD_STRING_ID_SERIAL - Define serial number string ID.
|
||||
|
||||
// <i> Setting ID to 0 disables the string.
|
||||
//==========================================================
|
||||
#ifndef APP_USBD_STRING_ID_SERIAL
|
||||
#define APP_USBD_STRING_ID_SERIAL 3
|
||||
#endif
|
||||
// <q> APP_USBD_STRING_SERIAL_EXTERN - Define whether @ref APP_USBD_STRING_SERIAL is created by macro or declared as a global variable.
|
||||
|
||||
|
||||
#ifndef APP_USBD_STRING_SERIAL_EXTERN
|
||||
#define APP_USBD_STRING_SERIAL_EXTERN 1
|
||||
#endif
|
||||
|
||||
// <s> APP_USBD_STRING_SERIAL - String descriptor for the serial number.
|
||||
|
||||
// <i> Note: This value is not editable in Configuration Wizard.
|
||||
// <i> Serial number that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER.
|
||||
#ifndef APP_USBD_STRING_SERIAL
|
||||
#define APP_USBD_STRING_SERIAL g_extern_serial_number
|
||||
#endif
|
||||
|
||||
// </e>
|
||||
|
||||
// <e> APP_USBD_STRING_ID_CONFIGURATION - Define configuration string ID.
|
||||
|
||||
// <i> Setting ID to 0 disables the string.
|
||||
//==========================================================
|
||||
#ifndef APP_USBD_STRING_ID_CONFIGURATION
|
||||
#define APP_USBD_STRING_ID_CONFIGURATION 4
|
||||
#endif
|
||||
// <q> APP_USBD_STRING_CONFIGURATION_EXTERN - Define whether @ref APP_USBD_STRINGS_CONFIGURATION is created by macro or declared as global variable.
|
||||
|
||||
|
||||
#ifndef APP_USBD_STRING_CONFIGURATION_EXTERN
|
||||
#define APP_USBD_STRING_CONFIGURATION_EXTERN 0
|
||||
#endif
|
||||
|
||||
// <s> APP_USBD_STRINGS_CONFIGURATION - String descriptor for the device configuration.
|
||||
|
||||
// <i> Note: This value is not editable in Configuration Wizard.
|
||||
// <i> Configuration string that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER.
|
||||
#ifndef APP_USBD_STRINGS_CONFIGURATION
|
||||
#define APP_USBD_STRINGS_CONFIGURATION APP_USBD_STRING_DESC("Default configuration")
|
||||
#endif
|
||||
|
||||
// </e>
|
||||
|
||||
// <s> APP_USBD_STRINGS_USER - Default values for user strings.
|
||||
|
||||
// <i> Note: This value is not editable in Configuration Wizard.
|
||||
// <i> This value stores all application specific user strings with the default initialization.
|
||||
// <i> The setup is done by X-macros.
|
||||
// <i> Expected macro parameters:
|
||||
// <i> @code
|
||||
// <i> X(mnemonic, [=str_idx], ...)
|
||||
// <i> @endcode
|
||||
// <i> - @c mnemonic: Mnemonic of the string descriptor that would be added to
|
||||
// <i> @ref app_usbd_string_desc_idx_t enumerator.
|
||||
// <i> - @c str_idx : String index value, can be set or left empty.
|
||||
// <i> For example, WinUSB driver requires descriptor to be present on 0xEE index.
|
||||
// <i> Then use X(USBD_STRING_WINUSB, =0xEE, (APP_USBD_STRING_DESC(...)))
|
||||
// <i> - @c ... : List of string descriptors for each defined language.
|
||||
#ifndef APP_USBD_STRINGS_USER
|
||||
#define APP_USBD_STRINGS_USER X(APP_USER_1, , APP_USBD_STRING_DESC("User 1"))
|
||||
#endif
|
||||
|
||||
// </e>
|
||||
|
||||
// <e> APP_USBD_CONFIG_LOG_ENABLED - Enable logging in the module
|
||||
//==========================================================
|
||||
#ifndef APP_USBD_CONFIG_LOG_ENABLED
|
||||
@@ -165,6 +322,29 @@
|
||||
#define USBD_CONFIG_DMASCHEDULER_MODE 0
|
||||
#endif
|
||||
|
||||
// <q> USBD_CONFIG_DMASCHEDULER_ISO_BOOST - Give priority to isochronous transfers
|
||||
|
||||
|
||||
// <i> This option gives priority to isochronous transfers.
|
||||
// <i> Enabling it assures that isochronous transfers are always processed,
|
||||
// <i> even if multiple other transfers are pending.
|
||||
// <i> Isochronous endpoints are prioritized before the usbd_dma_scheduler_algorithm
|
||||
// <i> function is called, so the option is independent of the algorithm chosen.
|
||||
|
||||
#ifndef USBD_CONFIG_DMASCHEDULER_ISO_BOOST
|
||||
#define USBD_CONFIG_DMASCHEDULER_ISO_BOOST 1
|
||||
#endif
|
||||
|
||||
// <q> USBD_CONFIG_ISO_IN_ZLP - Respond to an IN token on ISO IN endpoint with ZLP when no data is ready
|
||||
|
||||
|
||||
// <i> If set, ISO IN endpoint will respond to an IN token with ZLP when no data is ready to be sent.
|
||||
// <i> Else, there will be no response.
|
||||
|
||||
#ifndef USBD_CONFIG_ISO_IN_ZLP
|
||||
#define USBD_CONFIG_ISO_IN_ZLP 0
|
||||
#endif
|
||||
|
||||
// </e>
|
||||
|
||||
// <h> app_usbd_cdc_acm - USB CDC ACM class
|
||||
@@ -177,6 +357,16 @@
|
||||
#define APP_USBD_CDC_ACM_ENABLED 1
|
||||
#endif
|
||||
|
||||
// <q> APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE - Send ZLP on write with same size as endpoint
|
||||
|
||||
|
||||
// <i> If enabled, CDC ACM class will automatically send a zero length packet after transfer which has the same size as endpoint.
|
||||
// <i> This may limit throughput if a lot of binary data is sent, but in terminal mode operation it makes sure that the data is always displayed right after it is sent.
|
||||
|
||||
#ifndef APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE
|
||||
#define APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE 1
|
||||
#endif
|
||||
|
||||
// </h>
|
||||
//==========================================================
|
||||
|
||||
|
||||
+10
-10
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2013 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
/**@file
|
||||
*
|
||||
@@ -109,7 +109,7 @@ extern "C" {
|
||||
* @defgroup sdk_common_errors Codes reserved as identification for common errors.
|
||||
* @{
|
||||
*/
|
||||
#define NRF_ERROR_MODULE_NOT_INITIALZED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0000) ///< Module not initialized
|
||||
#define NRF_ERROR_MODULE_NOT_INITIALIZED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0000) ///< Module not initialized
|
||||
#define NRF_ERROR_MUTEX_INIT_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0001) ///< Mutex initialization failed
|
||||
#define NRF_ERROR_MUTEX_LOCK_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0002) ///< Mutex lock failed
|
||||
#define NRF_ERROR_MUTEX_UNLOCK_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0003) ///< Mutex unlock failed
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2013 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
/**@file
|
||||
*
|
||||
|
||||
+9
-9
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2013 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
/** @cond */
|
||||
/**@file
|
||||
|
||||
+86
-86
@@ -1,86 +1,86 @@
|
||||
/**
|
||||
* Copyright (c) 2015 - 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.
|
||||
*
|
||||
*/
|
||||
/** @file
|
||||
* @brief Definition file for resource usage by SoftDevice, ESB and Gazell.
|
||||
*/
|
||||
|
||||
#ifndef SDK_RESOURCES_H__
|
||||
#define SDK_RESOURCES_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(SOFTDEVICE_PRESENT) || defined (BLE_STACK_SUPPORT_REQD) || defined (ANT_STACK_SUPPORT_REQD)
|
||||
#include "nrf_sd_def.h"
|
||||
#else
|
||||
#define SD_PPI_RESTRICTED 0uL /**< 1 if PPI peripheral is restricted, 0 otherwise. */
|
||||
#define SD_PPI_CHANNELS_USED 0uL /**< PPI channels utilized by SotfDevice (not available to th spplication). */
|
||||
#define SD_PPI_GROUPS_USED 0uL /**< PPI groups utilized by SotfDevice (not available to th spplication). */
|
||||
#define SD_TIMERS_USED 0uL /**< Timers used by SoftDevice. */
|
||||
#define SD_SWI_USED 0uL /**< Software interrupts used by SoftDevice. */
|
||||
#endif
|
||||
|
||||
#ifdef GAZELL_PRESENT
|
||||
#include "nrf_gzll_resources.h"
|
||||
#else
|
||||
#define GZLL_PPI_CHANNELS_USED 0uL /**< PPI channels utilized by Gazell (not available to th spplication). */
|
||||
#define GZLL_TIMERS_USED 0uL /**< Timers used by Gazell. */
|
||||
#define GZLL_SWI_USED 0uL /**< Software interrupts used by Gazell */
|
||||
#endif
|
||||
|
||||
#ifdef ESB_PRESENT
|
||||
#include "nrf_esb_resources.h"
|
||||
#else
|
||||
#define ESB_PPI_CHANNELS_USED 0uL /**< PPI channels utilized by ESB (not available to th spplication). */
|
||||
#define ESB_TIMERS_USED 0uL /**< Timers used by ESB. */
|
||||
#define ESB_SWI_USED 0uL /**< Software interrupts used by ESB */
|
||||
#endif
|
||||
|
||||
#define NRF_PPI_CHANNELS_USED (SD_PPI_CHANNELS_USED | GZLL_PPI_CHANNELS_USED | ESB_PPI_CHANNELS_USED)
|
||||
#define NRF_PPI_GROUPS_USED (SD_PPI_GROUPS_USED)
|
||||
#define NRF_SWI_USED (SD_SWI_USED | GZLL_SWI_USED | ESB_SWI_USED)
|
||||
#define NRF_TIMERS_USED (SD_TIMERS_USED | GZLL_TIMERS_USED | ESB_TIMERS_USED)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // SDK_RESOURCES_H__
|
||||
/**
|
||||
* Copyright (c) 2015 - 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.
|
||||
*
|
||||
*/
|
||||
/** @file
|
||||
* @brief Definition file for resource usage by SoftDevice, ESB and Gazell.
|
||||
*/
|
||||
|
||||
#ifndef SDK_RESOURCES_H__
|
||||
#define SDK_RESOURCES_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(SOFTDEVICE_PRESENT) || defined (BLE_STACK_SUPPORT_REQD) || defined (ANT_STACK_SUPPORT_REQD)
|
||||
#include "nrf_sd_def.h"
|
||||
#else
|
||||
#define SD_PPI_RESTRICTED 0uL /**< 1 if PPI peripheral is restricted, 0 otherwise. */
|
||||
#define SD_PPI_CHANNELS_USED 0uL /**< PPI channels utilized by SotfDevice (not available to th spplication). */
|
||||
#define SD_PPI_GROUPS_USED 0uL /**< PPI groups utilized by SotfDevice (not available to th spplication). */
|
||||
#define SD_TIMERS_USED 0uL /**< Timers used by SoftDevice. */
|
||||
#define SD_SWI_USED 0uL /**< Software interrupts used by SoftDevice. */
|
||||
#endif
|
||||
|
||||
#ifdef GAZELL_PRESENT
|
||||
#include "nrf_gzll_resources.h"
|
||||
#else
|
||||
#define GZLL_PPI_CHANNELS_USED 0uL /**< PPI channels utilized by Gazell (not available to th spplication). */
|
||||
#define GZLL_TIMERS_USED 0uL /**< Timers used by Gazell. */
|
||||
#define GZLL_SWI_USED 0uL /**< Software interrupts used by Gazell */
|
||||
#endif
|
||||
|
||||
#ifdef ESB_PRESENT
|
||||
#include "nrf_esb_resources.h"
|
||||
#else
|
||||
#define ESB_PPI_CHANNELS_USED 0uL /**< PPI channels utilized by ESB (not available to th spplication). */
|
||||
#define ESB_TIMERS_USED 0uL /**< Timers used by ESB. */
|
||||
#define ESB_SWI_USED 0uL /**< Software interrupts used by ESB */
|
||||
#endif
|
||||
|
||||
#define NRF_PPI_CHANNELS_USED (SD_PPI_CHANNELS_USED | GZLL_PPI_CHANNELS_USED | ESB_PPI_CHANNELS_USED)
|
||||
#define NRF_PPI_GROUPS_USED (SD_PPI_GROUPS_USED)
|
||||
#define NRF_SWI_USED (SD_SWI_USED | GZLL_SWI_USED | ESB_SWI_USED)
|
||||
#define NRF_TIMERS_USED (SD_TIMERS_USED | GZLL_TIMERS_USED | ESB_TIMERS_USED)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // SDK_RESOURCES_H__
|
||||
|
||||
+17
-13
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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
|
||||
@@ -35,20 +35,25 @@
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <nordic_common.h>
|
||||
#include "nrf_drv_clock.h"
|
||||
|
||||
#if NRF_MODULE_ENABLED(CLOCK)
|
||||
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
#include "nrf_sdh.h"
|
||||
#include "nrf_sdh_soc.h"
|
||||
#endif
|
||||
|
||||
#define NRF_LOG_MODULE_NAME clock
|
||||
#if CLOCK_CONFIG_LOG_ENABLED
|
||||
#define NRF_LOG_LEVEL CLOCK_CONFIG_LOG_LEVEL
|
||||
#define NRF_LOG_INFO_COLOR CLOCK_CONFIG_INFO_COLOR
|
||||
#define NRF_LOG_DEBUG_COLOR CLOCK_CONFIG_DEBUG_COLOR
|
||||
#else //CLOCK_CONFIG_LOG_ENABLED
|
||||
#define NRF_LOG_LEVEL 0
|
||||
#endif //CLOCK_CONFIG_LOG_ENABLED
|
||||
#include "nrf_log.h"
|
||||
NRF_LOG_MODULE_REGISTER();
|
||||
|
||||
@@ -190,6 +195,7 @@ void nrf_drv_clock_uninit(void)
|
||||
ASSERT(m_clock_cb.module_initialized);
|
||||
nrfx_clock_disable();
|
||||
nrfx_clock_uninit();
|
||||
|
||||
m_clock_cb.module_initialized = false;
|
||||
}
|
||||
|
||||
@@ -593,5 +599,3 @@ NRF_SDH_STATE_OBSERVER(m_sd_state_observer, CLOCK_CONFIG_STATE_OBSERVER_PRIO) =
|
||||
#undef NRF_CLOCK_LFCLK_RC
|
||||
#undef NRF_CLOCK_LFCLK_Xtal
|
||||
#undef NRF_CLOCK_LFCLK_Synth
|
||||
|
||||
#endif // NRF_MODULE_ENABLED(CLOCK)
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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_CLOCK_H__
|
||||
#define NRF_DRV_CLOCK_H__
|
||||
|
||||
+63
-63
@@ -1,63 +1,63 @@
|
||||
/**
|
||||
* Copyright (c) 2015 - 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_COMMON_H__
|
||||
#define NRF_DRV_COMMON_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INTERRUPT_PRIORITY_VALIDATION(pri) STATIC_ASSERT(INTERRUPT_PRIORITY_IS_VALID((pri)))
|
||||
#define INTERRUPT_PRIORITY_ASSERT(pri) ASSERT(INTERRUPT_PRIORITY_IS_VALID((pri)))
|
||||
|
||||
#define nrf_drv_irq_handler_t nrfx_irq_handler_t
|
||||
#define nrf_drv_bitpos_to_event nrfx_bitpos_to_event
|
||||
#define nrf_drv_event_to_bitpos nrfx_event_to_bitpos
|
||||
#define nrf_drv_get_IRQn nrfx_get_irq_number
|
||||
#define nrf_drv_is_in_RAM nrfx_is_in_ram
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_DRV_COMMON_H__
|
||||
/**
|
||||
* Copyright (c) 2015 - 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_COMMON_H__
|
||||
#define NRF_DRV_COMMON_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INTERRUPT_PRIORITY_VALIDATION(pri) STATIC_ASSERT(INTERRUPT_PRIORITY_IS_VALID((pri)))
|
||||
#define INTERRUPT_PRIORITY_ASSERT(pri) ASSERT(INTERRUPT_PRIORITY_IS_VALID((pri)))
|
||||
|
||||
#define nrf_drv_irq_handler_t nrfx_irq_handler_t
|
||||
#define nrf_drv_bitpos_to_event nrfx_bitpos_to_event
|
||||
#define nrf_drv_event_to_bitpos nrfx_event_to_bitpos
|
||||
#define nrf_drv_get_IRQn nrfx_get_irq_number
|
||||
#define nrf_drv_is_in_RAM nrfx_is_in_ram
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_DRV_COMMON_H__
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
@startuml
|
||||
|
||||
skinparam state {
|
||||
BackgroundColor<< locked >> red
|
||||
BackgroundColor<< unlocked >> green
|
||||
}
|
||||
|
||||
|
||||
[*] --> Sleep << unlocked >>
|
||||
|
||||
Sleep -down-> Receive : API: Receive()
|
||||
Receive -up-> Sleep : API: Sleep() / MUTEX: Lock; TASK: STOP; TASK: DISABLE\nEV: DISABLED / MUTEX: Unlock
|
||||
|
||||
state Receive {
|
||||
state WaitingRxFrame << unlocked >>
|
||||
|
||||
state RxHeader << locked >>
|
||||
state RxFrame << locked >>
|
||||
state TxAck << locked >>
|
||||
state ShortAckTx << locked >>
|
||||
|
||||
Enter -down-> WaitingRxFrame : EV: DISABLED / TASK: RXEN; MUTEX: Unlock
|
||||
WaitingRxFrame --> WaitingRxFrame : EV: READY / AutoACK: enable; TASK: START
|
||||
|
||||
WaitingRxFrame -down-> RxHeader : EV: FRAMESTART / MUTEX: Lock
|
||||
|
||||
RxHeader -down-> RxFrame : EV: BCMATCH, Frame type and address ok
|
||||
RxHeader -up-> Enter : EV: BCMATCH, Frame type invalid or dst address mismatch
|
||||
|
||||
RxFrame -down-> TxAck : EV: END, CRC: OK, ACK: requested
|
||||
RxFrame -up-> Enter : EV: END, CRC: invalid / TASK: DISABLE
|
||||
RxFrame -up-> Enter : EV: END, CRC: OK, ACK: not requested / TASK: DISABLE; received()
|
||||
|
||||
TxAck -up-> Enter : EV: END / AutoACK: disable; TASK: DISABLE; received()
|
||||
|
||||
RxFrame -left-> ShortAckTx : EV: END; AutoACK: enabled / SHORT: DISABLE
|
||||
ShortAckTx -left-> ShortAckTx : EV: DISABLED; AutoACK: enabled / SHORT: TXEN
|
||||
ShortAckTx -right-> ShortAckTx : EV: READY; AutoACK:enabled / AutoACK: disable; SHORT: START
|
||||
}
|
||||
|
||||
state Transmit << locked >>{
|
||||
[*] --> CCA : EV: DISABLED / TASK: RXEN
|
||||
CCA --> CCA : EV: READY / TASK: CCA_START
|
||||
CCA -up-> Receive : EV: CCABUSY / TransmitFailure(); TASK: DISABLE
|
||||
CCA --> TxFrame : EV: CCAIDLE / SHORT: TXEN
|
||||
TxFrame --> TxFrame : EV: READY / SHORT: START
|
||||
|
||||
state RxAck {
|
||||
[*] --> EnablingAckRx : TASK: RXEN
|
||||
EnablingAckRx --> ReceivingAck : EV: READY / TASK: START
|
||||
|
||||
ReceivingAck --> ReceivingAck : EV: END (CRCERR) / TASK: START
|
||||
ReceivingAck --> ReceivingAck : EV: END (CRCOK, Not valid ACK) / TASK: START
|
||||
ReceivingAck --> WaitingRxFrame : EV: END (CRCOK, Valid ACK) / MUTEX: Unlock; TASK: START; transmitted()
|
||||
}
|
||||
|
||||
TxFrame --> RxAck : EV: END (ACK)
|
||||
TxFrame -up-> Receive : EV: END (NOACK) / transmitted(OK); SHORT: DISABLE
|
||||
}
|
||||
|
||||
state ShortAckTx {
|
||||
}
|
||||
|
||||
state EnergyDetection << locked >> {
|
||||
[*] --> ED : EV: DISABLED / TASK: RXEN
|
||||
ED --> ED : EV: READY / TASK: EDSTART
|
||||
ED -right-> Receive : EV: EDEND / energy_detected(); TASK: DISABLE
|
||||
}
|
||||
|
||||
|
||||
Receive -down-> Transmit : API: Transmit() / MUTEX:Lock; AutoACK: disable; TASK: DISABLE
|
||||
Transmit -up-> Receive : API: Receive() / TASK: CCASTOP; TASK: STOP; TASK: DISABLE
|
||||
Receive --> Receive : API: Receive()
|
||||
Receive -left-> EnergyDetection : API: EnergyDetection() / MUTEX: Lock; AutoACK: disable; TASK: DISABLE
|
||||
|
||||
@enduml
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
@startuml
|
||||
|
||||
participant RADIO
|
||||
participant Driver
|
||||
|
||||
-> State: WaitingRxFrame
|
||||
|
||||
activate RADIO
|
||||
RADIO -> Driver: EV: END
|
||||
deactivate RADIO
|
||||
Driver -> Mutex: lock
|
||||
activate Mutex
|
||||
|
||||
Driver -> Driver: stopSendingAck(WaitingRxFrame)
|
||||
|
||||
RADIO -> Driver: EV: DISABLED
|
||||
Driver -> RADIO: TASK: RXEN
|
||||
Driver -> Mutex: unlock
|
||||
deactivate Mutex
|
||||
Driver -> RADIO: clear_event(DISABLED)
|
||||
|
||||
|
||||
@enduml
|
||||
@@ -1,27 +0,0 @@
|
||||
@startuml
|
||||
|
||||
participant RADIO
|
||||
participant Driver
|
||||
|
||||
-> State: WaitingRxFrame
|
||||
|
||||
RADIO -> Driver: EV: FRAMESTART
|
||||
activate RADIO
|
||||
Driver -> Mutex: lock
|
||||
activate Mutex
|
||||
Driver -> State: RxHeader
|
||||
|
||||
RADIO -> Driver: EV: BCMATCH
|
||||
Driver -->> RADIO: get_bcc()
|
||||
RADIO --> Driver: BCC_INIT
|
||||
Driver -> Driver: Check frame type: ACK
|
||||
Driver -> Driver: stopSendingAck(WaitingRxFrame)
|
||||
|
||||
RADIO -> Driver: EV: DISABLED
|
||||
Driver -> RADIO: TASK: RXEN
|
||||
Driver -> Mutex: unlock
|
||||
deactivate Mutex
|
||||
Driver -> RADIO: clear_event(DISABLED)
|
||||
|
||||
|
||||
@enduml
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
@startuml
|
||||
|
||||
participant RADIO
|
||||
participant Driver
|
||||
|
||||
-> State: WaitingRxFrame
|
||||
|
||||
RADIO -> Driver: EV: FRAMESTART
|
||||
activate RADIO
|
||||
Driver -> Mutex: lock
|
||||
activate Mutex
|
||||
Driver -> State: RxHeader
|
||||
|
||||
RADIO -> Driver: EV: BCMATCH
|
||||
Driver -->> RADIO: get_bcc()
|
||||
RADIO --> Driver: BCC_INIT
|
||||
Driver -> Driver: Check frame type: Data
|
||||
Driver -> Driver: Check dest address: short
|
||||
Driver -> RADIO: set_bcc(BCC_SHORT_ADDR)
|
||||
|
||||
RADIO -> Driver: EV: BCMATCH
|
||||
Driver -->> RADIO: get_bcc()
|
||||
RADIO --> Driver: BCC_SHORT_ADDR
|
||||
Driver -> Driver: Check dest addr: Broadcast
|
||||
Driver -> Flags: ReceivingBroadcastFrame = true
|
||||
Driver -> State: RxFrame
|
||||
|
||||
RADIO -> Driver: EV: END
|
||||
deactivate RADIO
|
||||
Driver -> Driver: Check CRC: OK
|
||||
Driver -> Driver: Prepare ACK
|
||||
Driver -->> Flags: receivigBroadcastFrame?
|
||||
Flags --> Driver: true
|
||||
|
||||
Driver -> Driver: stopSendingAck(WaitingRxFrame)
|
||||
|
||||
RADIO -> Driver: EV: DISABLED
|
||||
Driver -> RADIO: TASK: RXEN
|
||||
Driver -> Mutex: unlock
|
||||
deactivate Mutex
|
||||
Driver -> RADIO: clear_event(DISABLED)
|
||||
|
||||
Driver -> Higher_Layer: received()
|
||||
|
||||
@enduml
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
@startuml
|
||||
|
||||
participant RADIO
|
||||
participant Driver
|
||||
|
||||
-> State: WaitingRxFrame
|
||||
|
||||
RADIO -> Driver: EV: FRAMESTART
|
||||
activate RADIO
|
||||
Driver -> Mutex: lock
|
||||
activate Mutex
|
||||
Driver -> State: RxHeader
|
||||
Driver -> Driver: Check frame length: < ACK_LENGTH
|
||||
|
||||
Driver -> Driver: stopSendingAck(WaitingRxFrame)
|
||||
|
||||
RADIO -> Driver: EV: DISABLED
|
||||
Driver -> RADIO: TASK: RXEN
|
||||
Driver -> Mutex: unlock
|
||||
deactivate Mutex
|
||||
Driver -> RADIO: clear_event(DISABLED)
|
||||
|
||||
|
||||
@enduml
|
||||
@@ -1,80 +0,0 @@
|
||||
@startuml
|
||||
|
||||
participant RADIO
|
||||
participant Driver
|
||||
|
||||
-> State: WaitingRxFrame
|
||||
|
||||
RADIO -> Driver: EV: FRAMESTART
|
||||
activate Driver
|
||||
activate RADIO
|
||||
Driver -> Mutex: lock
|
||||
activate Mutex
|
||||
Driver -> State: RxHeader
|
||||
deactivate Driver
|
||||
|
||||
RADIO -> Driver: EV: BCMATCH
|
||||
activate Driver
|
||||
Driver -->> RADIO: get_bcc()
|
||||
RADIO --> Driver: BCC_INIT
|
||||
Driver -> Driver: Check frame type: Data
|
||||
Driver -> Driver: Check dest address: short
|
||||
Driver -> RADIO: set_bcc(BCC_SHORT_ADDR)
|
||||
deactivate Driver
|
||||
|
||||
RADIO -> Driver: EV: BCMATCH
|
||||
activate Driver
|
||||
Driver -->> RADIO: get_bcc()
|
||||
RADIO --> Driver: BCC_SHORT_ADDR
|
||||
Driver -> Driver: Check dest addr: Matched unicast
|
||||
Driver -> Flags: ReceivingBroadcastFrame = false
|
||||
Driver -> State: RxFrame
|
||||
deactivate Driver
|
||||
|
||||
RADIO -> RADIO: EV: END / TASK: DISABLE
|
||||
deactivate RADIO
|
||||
RADIO -> Driver: EV: END
|
||||
activate Driver
|
||||
Driver -> Driver: Check CRC: OK
|
||||
RADIO -> RADIO: EV: DISABLED / TASK: TXEN
|
||||
Driver -> Driver: Prepare ACK
|
||||
Driver -->> Flags: receivigBroadcastFrame?
|
||||
Flags --> Driver: false
|
||||
Driver -> Driver: Check if ACK requested: true
|
||||
|
||||
Driver -> State: TxAck
|
||||
Driver -> Driver: set pending bit in ACK()
|
||||
deactivate Driver
|
||||
|
||||
RADIO -> Driver: EV: DISABLED
|
||||
|
||||
RADIO -> RADIO: EV: READY / TASK: START
|
||||
activate RADIO
|
||||
|
||||
RADIO -> Driver: EV: READY
|
||||
activate Driver
|
||||
Driver -> RADIO: disable_tifs_shorts_ack()
|
||||
deactivate Driver
|
||||
|
||||
RADIO -> Driver: EV: FRAMESTART
|
||||
RADIO -> RADIO: EV: END / TASK: DISABLE
|
||||
deactivate RADIO
|
||||
|
||||
RADIO -> Driver: EV: END
|
||||
activate Driver
|
||||
Driver -> RADIO: disable_tifs_shorts_all()
|
||||
Driver -> State: WaitingRxFrame
|
||||
deactivate Driver
|
||||
|
||||
|
||||
RADIO -> Driver: EV: DISABLED
|
||||
activate Driver
|
||||
Driver -> RADIO: TASK: RXEN
|
||||
Driver -> Mutex: unlock
|
||||
deactivate Mutex
|
||||
Driver -> RADIO: clear_event(DISABLED)
|
||||
deactivate Driver
|
||||
|
||||
Driver -> Higher_Layer: received()
|
||||
|
||||
@enduml
|
||||
Vendored
-34
@@ -1,34 +0,0 @@
|
||||
@startuml
|
||||
|
||||
participant RADIO
|
||||
participant Driver
|
||||
|
||||
-> State: WaitingRxFrame
|
||||
|
||||
RADIO -> Driver: EV: FRAMESTART
|
||||
activate RADIO
|
||||
Driver -> Mutex: lock
|
||||
activate Mutex
|
||||
Driver -> State: RxHeader
|
||||
|
||||
RADIO -> Driver: EV: BCMATCH
|
||||
Driver -->> RADIO: get_bcc()
|
||||
RADIO --> Driver: BCC_INIT
|
||||
Driver -> Driver: Check frame type: Data
|
||||
Driver -> Driver: Check dest address: short
|
||||
Driver -> RADIO: set_bcc(BCC_SHORT_ADDR)
|
||||
|
||||
RADIO -> Driver: EV: BCMATCH
|
||||
Driver -->> RADIO: get_bcc()
|
||||
RADIO --> Driver: BCC_SHORT_ADDR
|
||||
Driver -> Driver: Check dest addr: Missed unicast
|
||||
Driver -> Driver: stopSendingAck(WaitingRxFrame)
|
||||
|
||||
RADIO -> Driver: EV: DISABLED
|
||||
Driver -> RADIO: TASK: RXEN
|
||||
Driver -> Mutex: unlock
|
||||
deactivate Mutex
|
||||
Driver -> RADIO: clear_event(DISABLED)
|
||||
|
||||
|
||||
@enduml
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
@startuml
|
||||
|
||||
participant RADIO
|
||||
participant Driver
|
||||
participant State
|
||||
participant Mutex
|
||||
|
||||
-> State: WaitingRxFrame
|
||||
|
||||
Higher_Layer -> Driver: transmit()
|
||||
|
||||
Driver -> Mutex: lock
|
||||
activate Mutex
|
||||
Driver -> RADIO: TASK: STOP
|
||||
Driver -> RADIO: set_channel(tx_channel)
|
||||
Driver -> Driver: stopSendingAck(Cca)
|
||||
Driver -> RADIO: set_tx_power(tx_power)
|
||||
Driver -> RADIO: clear_event(END)
|
||||
Driver -> RADIO: clear_event(READY)
|
||||
|
||||
RADIO -> Driver: EV: DISABLED
|
||||
Driver -> RADIO: TASK: RXEN
|
||||
|
||||
RADIO -> Driver: EV: READY
|
||||
Driver -> State: TxFrame
|
||||
Driver -> RADIO: enable_txframe_shorts()
|
||||
Driver -> RADIO: TASK: CCASTART
|
||||
|
||||
RADIO -> RADIO: EV: CCAIDLE / TASK: TXEN
|
||||
RADIO -> RADIO: EV: READY / TASK: START
|
||||
activate RADIO
|
||||
|
||||
RADIO -> Driver: EV: FRAMESTART
|
||||
|
||||
RADIO -> RADIO: EV: END / TASK: DISABLE
|
||||
deactivate RADIO
|
||||
RADIO -> Driver: EV: END
|
||||
Driver -> RADIO: disable_txframe_shorts()
|
||||
Driver -> Driver: Ack requested? false
|
||||
Driver -> State: WaitingRxFrame
|
||||
|
||||
Driver -> Higher_Layer: transmitted()
|
||||
|
||||
RADIO -> Driver: EV: DISABLED
|
||||
Driver -> RADIO: TASK: RXEN
|
||||
Driver -> Mutex: unlock
|
||||
deactivate Mutex
|
||||
Driver -> RADIO: clear_event(DISABLED)
|
||||
|
||||
|
||||
@enduml
|
||||
@@ -1,68 +0,0 @@
|
||||
@startuml
|
||||
|
||||
participant RADIO
|
||||
participant Driver
|
||||
participant State
|
||||
participant Mutex
|
||||
|
||||
-> State: WaitingRxFrame
|
||||
|
||||
Higher_Layer -> Driver: transmit()
|
||||
|
||||
Driver -> Mutex: lock
|
||||
activate Mutex
|
||||
Driver -> RADIO: TASK: STOP
|
||||
Driver -> RADIO: set_channel(tx_channel)
|
||||
Driver -> Driver: stopSendingAck(Cca)
|
||||
Driver -> RADIO: set_tx_power(tx_power)
|
||||
Driver -> RADIO: clear_event(END)
|
||||
Driver -> RADIO: clear_event(READY)
|
||||
|
||||
RADIO -> Driver: EV: DISABLED
|
||||
Driver -> RADIO: TASK: RXEN
|
||||
|
||||
RADIO -> Driver: EV: READY
|
||||
Driver -> State: TxFrame
|
||||
Driver -> RADIO: enable_txframe_shorts()
|
||||
Driver -> RADIO: TASK: CCASTART
|
||||
|
||||
RADIO -> RADIO: EV: CCAIDLE / TASK: TXEN
|
||||
RADIO -> RADIO: EV: READY / TASK: START
|
||||
activate RADIO
|
||||
|
||||
RADIO -> Driver: EV: FRAMESTART
|
||||
|
||||
RADIO -> RADIO: EV: END / TASK: DISABLE
|
||||
deactivate RADIO
|
||||
RADIO -> Driver: EV: END
|
||||
Driver -> RADIO: disable_txframe_shorts()
|
||||
Driver -> Driver: Ack requested? true
|
||||
Driver -> State: RxAck
|
||||
|
||||
RADIO -> Driver: EV: DISABLED
|
||||
Driver -> RADIO: TASK: RXEN
|
||||
|
||||
RADIO -> Driver: EV: READY
|
||||
Driver -> RADIO: TASK: START
|
||||
|
||||
RADIO -> Driver: EV: FRAMESTART
|
||||
activate RADIO
|
||||
RADIO -> Driver: EV: END
|
||||
deactivate RADIO
|
||||
Driver -> Driver: ACK matched? false
|
||||
Driver -> RADIO: TASK: START
|
||||
|
||||
RADIO -> Driver: EV: FRAMESTART
|
||||
activate RADIO
|
||||
RADIO -> Driver: EV: END
|
||||
deactivate RADIO
|
||||
Driver -> Driver: ACK matched? true
|
||||
Driver -> State: WainingRxFrame
|
||||
Driver -> RADIO: enable_tifs_shorts()
|
||||
Driver -> RADIO: TASK: START
|
||||
Driver -> Mutex: unlock
|
||||
deactivate Mutex
|
||||
|
||||
Driver -> Higher_Layer: transmitted()
|
||||
|
||||
@enduml
|
||||
-62
@@ -1,62 +0,0 @@
|
||||
@startuml
|
||||
|
||||
participant RADIO
|
||||
participant Driver
|
||||
participant State
|
||||
participant Mutex
|
||||
|
||||
-> State: WaitingRxFrame
|
||||
|
||||
Higher_Layer -> Driver: transmit()
|
||||
|
||||
Driver -> Mutex: lock
|
||||
activate Mutex
|
||||
Driver -> RADIO: TASK: STOP
|
||||
Driver -> RADIO: set_channel(tx_channel)
|
||||
Driver -> Driver: stopSendingAck(Cca)
|
||||
Driver -> RADIO: set_tx_power(tx_power)
|
||||
Driver -> RADIO: clear_event(END)
|
||||
Driver -> RADIO: clear_event(READY)
|
||||
|
||||
RADIO -> Driver: EV: DISABLED
|
||||
Driver -> RADIO: TASK: RXEN
|
||||
|
||||
RADIO -> Driver: EV: READY
|
||||
Driver -> State: TxFrame
|
||||
Driver -> RADIO: enable_txframe_shorts()
|
||||
Driver -> RADIO: TASK: CCASTART
|
||||
|
||||
RADIO -> RADIO: EV: CCAIDLE / TASK: TXEN
|
||||
RADIO -> RADIO: EV: READY / TASK: START
|
||||
activate RADIO
|
||||
|
||||
RADIO -> Driver: EV: FRAMESTART
|
||||
|
||||
RADIO -> RADIO: EV: END / TASK: DISABLE
|
||||
deactivate RADIO
|
||||
RADIO -> Driver: EV: END
|
||||
Driver -> RADIO: disable_txframe_shorts()
|
||||
Driver -> Driver: Ack requested? true
|
||||
Driver -> State: RxAck
|
||||
|
||||
RADIO -> Driver: EV: DISABLED
|
||||
Driver -> RADIO: TASK: RXEN
|
||||
|
||||
RADIO -> Driver: EV: READY
|
||||
Driver -> RADIO: TASK: START
|
||||
|
||||
== Timeout ==
|
||||
|
||||
Higher_Layer -> Driver: receive()
|
||||
Driver -> RADIO: TASK: STOP
|
||||
Driver -> State: WaitingRxFrame
|
||||
Driver -> RADIO: TASK: DISABLE
|
||||
Driver -> RADIO: clear_event(END)
|
||||
|
||||
RADIO -> Driver: EV: DISABLED
|
||||
Driver -> RADIO: TASK: RXEN
|
||||
Driver -> Mutex: unlock
|
||||
deactivate Mutex
|
||||
Driver -> RADIO: clear_event(DISABLED)
|
||||
|
||||
@enduml
|
||||
Binary file not shown.
Binary file not shown.
+16
-11
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* 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
|
||||
@@ -35,9 +35,11 @@
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "sdk_common.h"
|
||||
#if NRF_MODULE_ENABLED(POWER)
|
||||
#include "nrf_drv_power.h"
|
||||
#include <nrf_drv_clock.h>
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
@@ -66,6 +68,10 @@ bool nrf_drv_power_init_check(void)
|
||||
ret_code_t nrf_drv_power_init(nrf_drv_power_config_t const * p_config)
|
||||
{
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
if (m_initialized)
|
||||
{
|
||||
return NRF_ERROR_MODULE_ALREADY_INITIALIZED;
|
||||
}
|
||||
if (nrf_sdh_is_enabled())
|
||||
{
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
@@ -406,6 +412,5 @@ static void nrf_drv_power_sdh_state_evt_handler(nrf_sdh_state_evt_t state, void
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // SOFTDEVICE_PRESENT
|
||||
#endif //POWER_ENABLED
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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_POWER_H__
|
||||
|
||||
@@ -1,80 +1,80 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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_SYSTICK_H__
|
||||
#define NRF_DRV_SYSTICK_H__
|
||||
|
||||
#include <nrfx_systick.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_drv_systick ARM(R) SysTick driver - legacy layer
|
||||
* @{
|
||||
* @ingroup nrf_systick
|
||||
*
|
||||
* @brief Layer providing compatibility with the former API.
|
||||
*/
|
||||
|
||||
/** @brief Type definition for forwarding the new implementation. */
|
||||
typedef nrfx_systick_state_t nrf_drv_systick_state_t;
|
||||
|
||||
/** @brief Macro for forwarding the new implementation. */
|
||||
#define nrf_drv_systick_init nrfx_systick_init
|
||||
/** @brief Macro for forwarding the new implementation. */
|
||||
#define nrf_drv_systick_get nrfx_systick_get
|
||||
/** @brief Macro for forwarding the new implementation. */
|
||||
#define nrf_drv_systick_test nrfx_systick_test
|
||||
/** @brief Macro for forwarding the new implementation. */
|
||||
#define nrf_drv_systick_delay_ticks nrfx_systick_delay_ticks
|
||||
/** @brief Macro for forwarding the new implementation. */
|
||||
#define nrf_drv_systick_delay_us nrfx_systick_delay_us
|
||||
/** @brief Macro for forwarding the new implementation. */
|
||||
#define nrf_drv_systick_delay_ms nrfx_systick_delay_ms
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_DRV_SYSTICK_H__
|
||||
/**
|
||||
* Copyright (c) 2016 - 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_SYSTICK_H__
|
||||
#define NRF_DRV_SYSTICK_H__
|
||||
|
||||
#include <nrfx_systick.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_drv_systick ARM(R) SysTick driver - legacy layer
|
||||
* @{
|
||||
* @ingroup nrf_systick
|
||||
*
|
||||
* @brief Layer providing compatibility with the former API.
|
||||
*/
|
||||
|
||||
/** @brief Type definition for forwarding the new implementation. */
|
||||
typedef nrfx_systick_state_t nrf_drv_systick_state_t;
|
||||
|
||||
/** @brief Macro for forwarding the new implementation. */
|
||||
#define nrf_drv_systick_init nrfx_systick_init
|
||||
/** @brief Macro for forwarding the new implementation. */
|
||||
#define nrf_drv_systick_get nrfx_systick_get
|
||||
/** @brief Macro for forwarding the new implementation. */
|
||||
#define nrf_drv_systick_test nrfx_systick_test
|
||||
/** @brief Macro for forwarding the new implementation. */
|
||||
#define nrf_drv_systick_delay_ticks nrfx_systick_delay_ticks
|
||||
/** @brief Macro for forwarding the new implementation. */
|
||||
#define nrf_drv_systick_delay_us nrfx_systick_delay_us
|
||||
/** @brief Macro for forwarding the new implementation. */
|
||||
#define nrf_drv_systick_delay_ms nrfx_systick_delay_ms
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_DRV_SYSTICK_H__
|
||||
|
||||
+170
-63
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
#include "sdk_common.h"
|
||||
#if NRF_MODULE_ENABLED(USBD)
|
||||
@@ -44,8 +44,9 @@
|
||||
#include "nrf.h"
|
||||
#include "nrf_atomic.h"
|
||||
#include "app_util_platform.h"
|
||||
#include "nrf_drv_systick.h" /* Marker to delete when not required anymore: >> NRF_DRV_USBD_ERRATA_ENABLE << */
|
||||
#include "nrf_delay.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
@@ -81,7 +82,11 @@ NRF_LOG_MODULE_REGISTER();
|
||||
} while (0)
|
||||
|
||||
#ifndef NRF_DRV_USBD_STARTED_EV_ENABLE
|
||||
#define NRF_DRV_USBD_STARTED_EV_ENABLE 1
|
||||
#define NRF_DRV_USBD_STARTED_EV_ENABLE 0
|
||||
#endif
|
||||
|
||||
#ifndef USBD_CONFIG_ISO_IN_ZLP
|
||||
#define USBD_CONFIG_ISO_IN_ZLP 0
|
||||
#endif
|
||||
|
||||
#ifndef NRF_USBD_ISO_DEBUG
|
||||
@@ -157,6 +162,12 @@ NRF_LOG_MODULE_REGISTER();
|
||||
*/
|
||||
#define USBD_EPOUT_BIT_MASK (0xFFFFU << USBD_EPOUT_BITPOS_0)
|
||||
|
||||
/**
|
||||
* @brief Isochronous endpoint bit mask
|
||||
*/
|
||||
#define USBD_EPISO_BIT_MASK \
|
||||
((1U << USBD_EP_BITPOS(NRF_DRV_USBD_EPOUT8)) | (1U << USBD_EP_BITPOS(NRF_DRV_USBD_EPIN8)))
|
||||
|
||||
/**
|
||||
* @brief Auxiliary macro to change EP number into bit position
|
||||
*
|
||||
@@ -299,7 +310,7 @@ static uint32_t m_ep_dma_waiting;
|
||||
* In USBD there is only one DMA channel working in background, and new transfer
|
||||
* cannot be started when there is ongoing transfer on any other channel.
|
||||
*/
|
||||
static uint8_t m_dma_pending;
|
||||
static bool m_dma_pending;
|
||||
|
||||
/**
|
||||
* @brief Simulated data EP status bits required for errata 104
|
||||
@@ -738,6 +749,36 @@ static inline nrf_drv_usbd_ep_t bit2ep(uint8_t bitpos)
|
||||
NRF_USBD_EPOUT(bitpos - USBD_EPOUT_BITPOS_0) : NRF_USBD_EPIN(bitpos));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Mark that EasyDMA is working
|
||||
*
|
||||
* Internal function to set the flag informing about EasyDMA transfer pending.
|
||||
* This function is called always just after the EasyDMA transfer is started.
|
||||
*/
|
||||
static inline void usbd_dma_pending_set(void)
|
||||
{
|
||||
if (nrf_drv_usb_errata_199())
|
||||
{
|
||||
*((volatile uint32_t *)0x40027C1C) = 0x00000082;
|
||||
}
|
||||
m_dma_pending = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Mark that EasyDMA is free
|
||||
*
|
||||
* Internal function to clear the flag informing about EasyDMA transfer pending.
|
||||
* This function is called always just after the finished EasyDMA transfer is detected.
|
||||
*/
|
||||
static inline void usbd_dma_pending_clear(void)
|
||||
{
|
||||
if (nrf_drv_usb_errata_199())
|
||||
{
|
||||
*((volatile uint32_t *)0x40027C1C) = 0x00000000;
|
||||
}
|
||||
m_dma_pending = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Start selected EasyDMA transmission
|
||||
*
|
||||
@@ -753,6 +794,19 @@ static inline void usbd_dma_start(nrf_drv_usbd_ep_t ep)
|
||||
nrf_usbd_task_trigger(task_start_ep(ep));
|
||||
}
|
||||
|
||||
|
||||
void nrf_drv_usbd_isoinconfig_set(nrf_usbd_isoinconfig_t config)
|
||||
{
|
||||
ASSERT(!nrf_drv_usbd_errata_type_52840_eng_a());
|
||||
nrf_usbd_isoinconfig_set(config);
|
||||
}
|
||||
|
||||
nrf_usbd_isoinconfig_t nrf_drv_usbd_isoinconfig_get(void)
|
||||
{
|
||||
ASSERT(!nrf_drv_usbd_errata_type_52840_eng_a());
|
||||
return nrf_usbd_isoinconfig_get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Abort pending transfer on selected endpoint
|
||||
*
|
||||
@@ -792,6 +846,26 @@ static inline void usbd_ep_abort(nrf_drv_usbd_ep_t ep)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!NRF_USBD_EPISO_CHECK(ep))
|
||||
{
|
||||
if(ep != NRF_DRV_USBD_EPIN0)
|
||||
{
|
||||
*((volatile uint32_t *)(NRF_USBD_BASE + 0x800)) = 0x7B6 + (2u * (NRF_USBD_EP_NR_GET(ep) - 1)); //inxbsy
|
||||
uint8_t temp = *((volatile uint32_t *)(NRF_USBD_BASE + 0x804));
|
||||
temp |= (1U << 1);
|
||||
*((volatile uint32_t *)(NRF_USBD_BASE + 0x804)) |= temp;
|
||||
UNUSED_VARIABLE(*((volatile uint32_t *)(NRF_USBD_BASE + 0x804)));
|
||||
}
|
||||
else
|
||||
{
|
||||
*((volatile uint32_t *)(NRF_USBD_BASE + 0x800)) = 0x7B4;
|
||||
uint8_t temp = *((volatile uint32_t *)(NRF_USBD_BASE + 0x804));
|
||||
temp |= (1U << 2);
|
||||
*((volatile uint32_t *)(NRF_USBD_BASE + 0x804)) |= temp;
|
||||
UNUSED_VARIABLE(*((volatile uint32_t *)(NRF_USBD_BASE + 0x804)));
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_ep_dma_waiting | (~m_ep_ready)) & (1U << ep2bit(ep)))
|
||||
{
|
||||
/* Device -> Host */
|
||||
@@ -896,7 +970,7 @@ static inline void nrf_usbd_ep0in_dma_handler(void)
|
||||
{
|
||||
const nrf_drv_usbd_ep_t ep = NRF_DRV_USBD_EPIN0;
|
||||
NRF_LOG_DEBUG("USB event: DMA ready IN0");
|
||||
m_dma_pending = 0;
|
||||
usbd_dma_pending_clear();
|
||||
|
||||
usbd_drv_ep_state_t * p_state = ep_state_access(ep);
|
||||
if (NRF_USBD_EP_ABORTED == p_state->status)
|
||||
@@ -930,7 +1004,7 @@ static inline void nrf_usbd_epin_dma_handler(nrf_drv_usbd_ep_t ep)
|
||||
ASSERT(NRF_USBD_EPIN_CHECK(ep));
|
||||
ASSERT(!NRF_USBD_EPISO_CHECK(ep));
|
||||
ASSERT(NRF_USBD_EP_NR_GET(ep) > 0);
|
||||
m_dma_pending = 0;
|
||||
usbd_dma_pending_clear();
|
||||
|
||||
usbd_drv_ep_state_t * p_state = ep_state_access(ep);
|
||||
if (NRF_USBD_EP_ABORTED == p_state->status)
|
||||
@@ -961,7 +1035,7 @@ static inline void nrf_usbd_epiniso_dma_handler(nrf_drv_usbd_ep_t ep)
|
||||
}
|
||||
ASSERT(NRF_USBD_EPIN_CHECK(ep));
|
||||
ASSERT(NRF_USBD_EPISO_CHECK(ep));
|
||||
m_dma_pending = 0;
|
||||
usbd_dma_pending_clear();
|
||||
|
||||
usbd_drv_ep_state_t * p_state = ep_state_access(ep);
|
||||
if (NRF_USBD_EP_ABORTED == p_state->status)
|
||||
@@ -992,7 +1066,7 @@ static inline void nrf_usbd_ep0out_dma_handler(void)
|
||||
{
|
||||
const nrf_drv_usbd_ep_t ep = NRF_DRV_USBD_EPOUT0;
|
||||
NRF_LOG_DEBUG("USB event: DMA ready OUT0");
|
||||
m_dma_pending = 0;
|
||||
usbd_dma_pending_clear();
|
||||
|
||||
usbd_drv_ep_state_t * p_state = ep_state_access(ep);
|
||||
if (NRF_USBD_EP_ABORTED == p_state->status)
|
||||
@@ -1027,7 +1101,7 @@ static inline void nrf_usbd_epout_dma_handler(nrf_drv_usbd_ep_t ep)
|
||||
ASSERT(NRF_USBD_EPOUT_CHECK(ep));
|
||||
ASSERT(!NRF_USBD_EPISO_CHECK(ep));
|
||||
ASSERT(NRF_USBD_EP_NR_GET(ep) > 0);
|
||||
m_dma_pending = 0;
|
||||
usbd_dma_pending_clear();
|
||||
|
||||
usbd_drv_ep_state_t * p_state = ep_state_access(ep);
|
||||
if (NRF_USBD_EP_ABORTED == p_state->status)
|
||||
@@ -1066,8 +1140,7 @@ static inline void nrf_usbd_epoutiso_dma_handler(nrf_drv_usbd_ep_t ep)
|
||||
NRF_LOG_DEBUG("USB drv: DMA ready ISOOUT: %x", ep);
|
||||
}
|
||||
ASSERT(NRF_USBD_EPISO_CHECK(ep));
|
||||
|
||||
m_dma_pending = 0;
|
||||
usbd_dma_pending_clear();
|
||||
|
||||
usbd_drv_ep_state_t * p_state = ep_state_access(ep);
|
||||
if (NRF_USBD_EP_ABORTED == p_state->status)
|
||||
@@ -1116,9 +1189,12 @@ static void ev_sof_handler(void)
|
||||
};
|
||||
|
||||
/* Process isochronous endpoints */
|
||||
m_ep_ready |=
|
||||
(1U << ep2bit(NRF_DRV_USBD_EPIN8 )) |
|
||||
(1U << ep2bit(NRF_DRV_USBD_EPOUT8));
|
||||
uint32_t iso_ready_mask = (1U << ep2bit(NRF_DRV_USBD_EPIN8));
|
||||
if (nrf_usbd_episoout_size_get(NRF_DRV_USBD_EPOUT8) != NRF_USBD_EPISOOUT_NO_DATA)
|
||||
{
|
||||
iso_ready_mask |= (1U << ep2bit(NRF_DRV_USBD_EPOUT8));
|
||||
}
|
||||
m_ep_ready |= iso_ready_mask;
|
||||
|
||||
m_event_handler(&evt);
|
||||
}
|
||||
@@ -1167,7 +1243,6 @@ static void ev_setup_data_handler(void)
|
||||
|
||||
static void ev_setup_handler(void)
|
||||
{
|
||||
nrf_usbd_shorts_disable(NRF_USBD_SHORT_EP0DATADONE_EP0STATUS_MASK);
|
||||
NRF_LOG_DEBUG("USBD event: Setup (rt:%.2x r:%.2x v:%.4x i:%.4x l:%u )",
|
||||
nrf_usbd_setup_bmrequesttype_get(),
|
||||
nrf_usbd_setup_brequest_get(),
|
||||
@@ -1205,10 +1280,12 @@ static void ev_usbevent_handler(void)
|
||||
|
||||
if (event & NRF_USBD_EVENTCAUSE_ISOOUTCRC_MASK)
|
||||
{
|
||||
NRF_LOG_DEBUG("USBD event: ISOOUTCRC");
|
||||
/* Currently no support */
|
||||
}
|
||||
if (event & NRF_USBD_EVENTCAUSE_SUSPEND_MASK)
|
||||
{
|
||||
NRF_LOG_DEBUG("USBD event: SUSPEND");
|
||||
m_bus_suspend = true;
|
||||
const nrf_drv_usbd_evt_t evt = {
|
||||
.type = NRF_DRV_USBD_EVT_SUSPEND
|
||||
@@ -1217,6 +1294,7 @@ static void ev_usbevent_handler(void)
|
||||
}
|
||||
if (event & NRF_USBD_EVENTCAUSE_RESUME_MASK)
|
||||
{
|
||||
NRF_LOG_DEBUG("USBD event: RESUME");
|
||||
m_bus_suspend = false;
|
||||
const nrf_drv_usbd_evt_t evt = {
|
||||
.type = NRF_DRV_USBD_EVT_RESUME
|
||||
@@ -1225,6 +1303,7 @@ static void ev_usbevent_handler(void)
|
||||
}
|
||||
if (event & NRF_USBD_EVENTCAUSE_WUREQ_MASK)
|
||||
{
|
||||
NRF_LOG_DEBUG("USBD event: WUREQ (%s)", m_bus_suspend ? "In Suspend" : "Active");
|
||||
if (m_bus_suspend)
|
||||
{
|
||||
ASSERT(!nrf_usbd_lowpower_check());
|
||||
@@ -1321,12 +1400,20 @@ static inline size_t usbd_ep_iso_capacity(nrf_drv_usbd_ep_t ep)
|
||||
*/
|
||||
static void usbd_dmareq_process(void)
|
||||
{
|
||||
if (0 == m_dma_pending)
|
||||
if (!m_dma_pending)
|
||||
{
|
||||
uint32_t req;
|
||||
while (0 != (req = m_ep_dma_waiting & m_ep_ready))
|
||||
{
|
||||
uint8_t pos = usbd_dma_scheduler_algorithm(req);
|
||||
uint8_t pos;
|
||||
if (USBD_CONFIG_DMASCHEDULER_ISO_BOOST && ((req & USBD_EPISO_BIT_MASK) != 0))
|
||||
{
|
||||
pos = usbd_dma_scheduler_algorithm(req & USBD_EPISO_BIT_MASK);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = usbd_dma_scheduler_algorithm(req);
|
||||
}
|
||||
nrf_drv_usbd_ep_t ep = bit2ep(pos);
|
||||
usbd_drv_ep_state_t * p_state = ep_state_access(ep);
|
||||
|
||||
@@ -1348,13 +1435,6 @@ static void usbd_dmareq_process(void)
|
||||
if (!continue_transfer)
|
||||
{
|
||||
p_state->handler.feeder = NULL;
|
||||
if (ep == NRF_DRV_USBD_EPIN0)
|
||||
{
|
||||
/** Configure short right now - now if the last data is transferred,
|
||||
* when host tries another data transfer, the endpoint will stall. */
|
||||
NRF_LOG_DEBUG("USB DMA process: Enable status short");
|
||||
nrf_usbd_shorts_enable(NRF_USBD_SHORT_EP0DATADONE_EP0STATUS_MASK);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1394,7 +1474,7 @@ static void usbd_dmareq_process(void)
|
||||
}
|
||||
}
|
||||
|
||||
m_dma_pending = 1;
|
||||
usbd_dma_pending_set();
|
||||
m_ep_ready &= ~(1U << pos);
|
||||
if (NRF_USBD_ISO_DEBUG || (!NRF_USBD_EPISO_CHECK(ep)))
|
||||
{
|
||||
@@ -1418,7 +1498,7 @@ static void usbd_dmareq_process(void)
|
||||
{
|
||||
nrf_usbd_event_clear(NRF_USBD_EVENT_STARTED);
|
||||
usbd_dma_start(ep);
|
||||
nrf_drv_systick_delay_us(2);
|
||||
nrf_delay_us(2);
|
||||
++cnt;
|
||||
}while (!nrf_usbd_event_check(NRF_USBD_EVENT_STARTED));
|
||||
if (cnt)
|
||||
@@ -1426,12 +1506,12 @@ static void usbd_dmareq_process(void)
|
||||
NRF_DRV_USBD_LOG_PROTO1_FIX_PRINTF(" DMA restarted: %u times", cnt);
|
||||
}
|
||||
|
||||
nrf_drv_systick_delay_us(30);
|
||||
nrf_delay_us(30);
|
||||
while (0 == (0x20 & *((volatile uint32_t *)(NRF_USBD_BASE + 0x474))))
|
||||
{
|
||||
nrf_drv_systick_delay_us(2);
|
||||
nrf_delay_us(2);
|
||||
}
|
||||
nrf_drv_systick_delay_us(1);
|
||||
nrf_delay_us(1);
|
||||
|
||||
++cnt_end;
|
||||
} while (!nrf_usbd_event_check(nrf_drv_usbd_ep_to_endevent(ep)));
|
||||
@@ -1443,6 +1523,13 @@ static void usbd_dmareq_process(void)
|
||||
else
|
||||
{
|
||||
usbd_dma_start(ep);
|
||||
/* There is a lot of USBD registers that cannot be accessed during EasyDMA transfer.
|
||||
* This is quick fix to maintain stability of the stack.
|
||||
* It cost some performance but makes stack stable. */
|
||||
while (!nrf_usbd_event_check(nrf_drv_usbd_ep_to_endevent(ep)))
|
||||
{
|
||||
/* Empty */
|
||||
}
|
||||
}
|
||||
|
||||
if (NRF_USBD_DMAREQ_PROCESS_DEBUG)
|
||||
@@ -1523,7 +1610,7 @@ void USBD_IRQHandler(void)
|
||||
if (nrf_drv_usbd_errata_104())
|
||||
{
|
||||
/* Event correcting */
|
||||
if ((0 == m_dma_pending) && (0 != (active & (USBD_INTEN_SOF_Msk))))
|
||||
if ((!m_dma_pending) && (0 != (active & (USBD_INTEN_SOF_Msk))))
|
||||
{
|
||||
uint8_t usbi, uoi, uii;
|
||||
/* Testing */
|
||||
@@ -1631,10 +1718,12 @@ void USBD_IRQHandler(void)
|
||||
|
||||
ret_code_t nrf_drv_usbd_init(nrf_drv_usbd_event_handler_t const event_handler)
|
||||
{
|
||||
if (nrf_drv_usbd_errata_104())
|
||||
{
|
||||
nrf_drv_systick_init();
|
||||
}
|
||||
ASSERT((nrf_drv_usbd_errata_type_52840_eng_a() ||
|
||||
nrf_drv_usbd_errata_type_52840_eng_b() ||
|
||||
nrf_drv_usbd_errata_type_52840_eng_c() ||
|
||||
nrf_drv_usbd_errata_type_52840_eng_d())
|
||||
);
|
||||
|
||||
if (NULL == event_handler)
|
||||
{
|
||||
return NRF_ERROR_INVALID_PARAM;
|
||||
@@ -1749,22 +1838,6 @@ void nrf_drv_usbd_enable(void)
|
||||
CRITICAL_REGION_EXIT();
|
||||
}
|
||||
|
||||
if (nrf_drv_usbd_errata_187())
|
||||
{
|
||||
CRITICAL_REGION_ENTER();
|
||||
if (*((volatile uint32_t *)(0x4006EC00)) == 0x00000000)
|
||||
{
|
||||
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
|
||||
*((volatile uint32_t *)(0x4006ED14)) = 0x00000000;
|
||||
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
|
||||
}
|
||||
else
|
||||
{
|
||||
*((volatile uint32_t *)(0x4006ED14)) = 0x00000000;
|
||||
}
|
||||
CRITICAL_REGION_EXIT();
|
||||
}
|
||||
|
||||
if (nrf_drv_usbd_errata_166())
|
||||
{
|
||||
*((volatile uint32_t *)(NRF_USBD_BASE + 0x800)) = 0x7E3;
|
||||
@@ -1775,9 +1848,18 @@ void nrf_drv_usbd_enable(void)
|
||||
|
||||
nrf_usbd_isosplit_set(NRF_USBD_ISOSPLIT_Half);
|
||||
|
||||
if (USBD_CONFIG_ISO_IN_ZLP)
|
||||
{
|
||||
nrf_drv_usbd_isoinconfig_set(NRF_USBD_ISOINCONFIG_ZERODATA);
|
||||
}
|
||||
else
|
||||
{
|
||||
nrf_drv_usbd_isoinconfig_set(NRF_USBD_ISOINCONFIG_NORESP);
|
||||
}
|
||||
|
||||
m_ep_ready = (((1U << NRF_USBD_EPIN_CNT) - 1U) << USBD_EPIN_BITPOS_0);
|
||||
m_ep_dma_waiting = 0;
|
||||
m_dma_pending = 0;
|
||||
usbd_dma_pending_clear();
|
||||
m_last_setup_dir = NRF_DRV_USBD_EPOUT0;
|
||||
|
||||
m_drv_state = NRFX_DRV_STATE_POWERED_ON;
|
||||
@@ -1793,8 +1875,24 @@ void nrf_drv_usbd_disable(void)
|
||||
/* Disable all parts */
|
||||
nrf_usbd_int_disable(nrf_usbd_int_enable_get());
|
||||
nrf_usbd_disable();
|
||||
m_dma_pending = 0;
|
||||
usbd_dma_pending_clear();
|
||||
m_drv_state = NRFX_DRV_STATE_INITIALIZED;
|
||||
|
||||
if (nrf_drv_usbd_errata_187())
|
||||
{
|
||||
CRITICAL_REGION_ENTER();
|
||||
if (*((volatile uint32_t *)(0x4006EC00)) == 0x00000000)
|
||||
{
|
||||
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
|
||||
*((volatile uint32_t *)(0x4006ED14)) = 0x00000000;
|
||||
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
|
||||
}
|
||||
else
|
||||
{
|
||||
*((volatile uint32_t *)(0x4006ED14)) = 0x00000000;
|
||||
}
|
||||
CRITICAL_REGION_EXIT();
|
||||
}
|
||||
}
|
||||
|
||||
void nrf_drv_usbd_start(bool enable_sof)
|
||||
@@ -1954,6 +2052,11 @@ bool nrf_drv_usbd_bus_suspend_check(void)
|
||||
return m_bus_suspend;
|
||||
}
|
||||
|
||||
void nrf_drv_usbd_force_bus_wakeup(void)
|
||||
{
|
||||
m_bus_suspend = false;
|
||||
}
|
||||
|
||||
void nrf_drv_usbd_ep_max_packet_size_set(nrf_drv_usbd_ep_t ep, uint16_t size)
|
||||
{
|
||||
/* Only power of 2 size allowed */
|
||||
@@ -2211,7 +2314,7 @@ size_t nrf_drv_usbd_epout_size_get(nrf_drv_usbd_ep_t ep)
|
||||
|
||||
bool nrf_drv_usbd_ep_is_busy(nrf_drv_usbd_ep_t ep)
|
||||
{
|
||||
return (0 != (m_ep_dma_waiting & (1UL << ep2bit(ep))));
|
||||
return (0 != ((m_ep_dma_waiting | ((~m_ep_ready) & USBD_EPIN_BIT_MASK)) & (1U << ep2bit(ep))));
|
||||
}
|
||||
|
||||
void nrf_drv_usbd_ep_stall(nrf_drv_usbd_ep_t ep)
|
||||
@@ -2222,6 +2325,10 @@ void nrf_drv_usbd_ep_stall(nrf_drv_usbd_ep_t ep)
|
||||
|
||||
void nrf_drv_usbd_ep_stall_clear(nrf_drv_usbd_ep_t ep)
|
||||
{
|
||||
if (NRF_USBD_EPOUT_CHECK(ep) && nrf_drv_usbd_ep_stall_check(ep))
|
||||
{
|
||||
nrf_drv_usbd_transfer_out_drop(ep);
|
||||
}
|
||||
nrf_usbd_ep_unstall(ep_to_hal(ep));
|
||||
}
|
||||
|
||||
@@ -2284,13 +2391,13 @@ void nrf_drv_usbd_transfer_out_drop(nrf_drv_usbd_ep_t ep)
|
||||
{
|
||||
ASSERT(NRF_USBD_EPOUT_CHECK(ep));
|
||||
|
||||
if (nrf_drv_usbd_errata_sizeepout_rw())
|
||||
if (nrf_drv_usbd_errata_200())
|
||||
{
|
||||
CRITICAL_REGION_ENTER();
|
||||
m_ep_ready &= ~(1U << ep2bit(ep));
|
||||
*((volatile uint32_t *)(NRF_USBD_BASE + 0x800)) = 0x7C5 + (2u * NRF_USBD_EP_NR_GET(ep));
|
||||
*((volatile uint32_t *)(NRF_USBD_BASE + 0x804)) = 0;
|
||||
UNUSED_VARIABLE(((volatile uint32_t *)(NRF_USBD_BASE + 0x804)));
|
||||
UNUSED_VARIABLE(*((volatile uint32_t *)(NRF_USBD_BASE + 0x804)));
|
||||
CRITICAL_REGION_EXIT();
|
||||
}
|
||||
else
|
||||
|
||||
+14
-12
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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_H__
|
||||
@@ -658,6 +658,11 @@ void nrf_drv_usbd_active_irq_config(void);
|
||||
*/
|
||||
bool nrf_drv_usbd_bus_suspend_check(void);
|
||||
|
||||
/**
|
||||
* @brief Force the bus state to active
|
||||
*/
|
||||
void nrf_drv_usbd_force_bus_wakeup(void);
|
||||
|
||||
/**
|
||||
* @brief Configure packet size that should be supported by the endpoint
|
||||
*
|
||||
@@ -897,9 +902,6 @@ void nrf_drv_usbd_setup_data_clear(void);
|
||||
*
|
||||
* This function acknowledges setup when SETUP command was received and processed.
|
||||
* It has to be called if no data respond for the SETUP command is sent.
|
||||
*
|
||||
* When there is any data transmission after SETUP command the data transmission
|
||||
* itself would clear the endpoint.
|
||||
*/
|
||||
void nrf_drv_usbd_setup_clear(void);
|
||||
|
||||
|
||||
+210
-180
@@ -1,180 +1,210 @@
|
||||
/**
|
||||
* 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 *)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) == 0x10 ) &&
|
||||
( ((*(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();
|
||||
}
|
||||
|
||||
/** @} */
|
||||
#endif /* NRF_DRV_USBD_ERRATA_H__ */
|
||||
/**
|
||||
* 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__ */
|
||||
|
||||
+125
-125
@@ -1,125 +1,125 @@
|
||||
/**
|
||||
* Copyright (c) 2014 - 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.
|
||||
*
|
||||
*/
|
||||
/** @file
|
||||
*
|
||||
* @defgroup app_error Common application error handler
|
||||
* @{
|
||||
* @ingroup app_common
|
||||
*
|
||||
* @brief Common application error handler.
|
||||
*/
|
||||
|
||||
#include "nrf.h"
|
||||
#include <stdio.h>
|
||||
#include "app_error.h"
|
||||
#include "nordic_common.h"
|
||||
#include "sdk_errors.h"
|
||||
|
||||
/**@brief Function for error handling, which is called when an error has occurred.
|
||||
*
|
||||
* @warning This handler is an example only and does not fit a final product. You need to analyze
|
||||
* how your product is supposed to react in case of error.
|
||||
*
|
||||
* @param[in] error_code Error code supplied to the handler.
|
||||
* @param[in] line_num Line number where the handler is called.
|
||||
* @param[in] p_file_name Pointer to the file name.
|
||||
*/
|
||||
void app_error_handler_bare(ret_code_t error_code)
|
||||
{
|
||||
error_info_t error_info =
|
||||
{
|
||||
.line_num = 0,
|
||||
.p_file_name = NULL,
|
||||
.err_code = error_code,
|
||||
};
|
||||
|
||||
app_error_fault_handler(NRF_FAULT_ID_SDK_ERROR, 0, (uint32_t)(&error_info));
|
||||
|
||||
UNUSED_VARIABLE(error_info);
|
||||
}
|
||||
|
||||
void app_error_save_and_stop(uint32_t id, uint32_t pc, uint32_t info)
|
||||
{
|
||||
/* static error variables - in order to prevent removal by optimizers */
|
||||
static volatile struct
|
||||
{
|
||||
uint32_t fault_id;
|
||||
uint32_t pc;
|
||||
uint32_t error_info;
|
||||
assert_info_t * p_assert_info;
|
||||
error_info_t * p_error_info;
|
||||
ret_code_t err_code;
|
||||
uint32_t line_num;
|
||||
const uint8_t * p_file_name;
|
||||
} m_error_data = {0};
|
||||
|
||||
// The following variable helps Keil keep the call stack visible, in addition, it can be set to
|
||||
// 0 in the debugger to continue executing code after the error check.
|
||||
volatile bool loop = true;
|
||||
UNUSED_VARIABLE(loop);
|
||||
|
||||
m_error_data.fault_id = id;
|
||||
m_error_data.pc = pc;
|
||||
m_error_data.error_info = info;
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case NRF_FAULT_ID_SDK_ASSERT:
|
||||
m_error_data.p_assert_info = (assert_info_t *)info;
|
||||
m_error_data.line_num = m_error_data.p_assert_info->line_num;
|
||||
m_error_data.p_file_name = m_error_data.p_assert_info->p_file_name;
|
||||
break;
|
||||
|
||||
case NRF_FAULT_ID_SDK_ERROR:
|
||||
m_error_data.p_error_info = (error_info_t *)info;
|
||||
m_error_data.err_code = m_error_data.p_error_info->err_code;
|
||||
m_error_data.line_num = m_error_data.p_error_info->line_num;
|
||||
m_error_data.p_file_name = m_error_data.p_error_info->p_file_name;
|
||||
break;
|
||||
}
|
||||
|
||||
UNUSED_VARIABLE(m_error_data);
|
||||
|
||||
// If printing is disrupted, remove the irq calls, or set the loop variable to 0 in the debugger.
|
||||
__disable_irq();
|
||||
while (loop);
|
||||
|
||||
__enable_irq();
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2014 - 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.
|
||||
*
|
||||
*/
|
||||
/** @file
|
||||
*
|
||||
* @defgroup app_error Common application error handler
|
||||
* @{
|
||||
* @ingroup app_common
|
||||
*
|
||||
* @brief Common application error handler.
|
||||
*/
|
||||
|
||||
#include "nrf.h"
|
||||
#include <stdio.h>
|
||||
#include "app_error.h"
|
||||
#include "nordic_common.h"
|
||||
#include "sdk_errors.h"
|
||||
|
||||
/**@brief Function for error handling, which is called when an error has occurred.
|
||||
*
|
||||
* @warning This handler is an example only and does not fit a final product. You need to analyze
|
||||
* how your product is supposed to react in case of error.
|
||||
*
|
||||
* @param[in] error_code Error code supplied to the handler.
|
||||
* @param[in] line_num Line number where the handler is called.
|
||||
* @param[in] p_file_name Pointer to the file name.
|
||||
*/
|
||||
void app_error_handler_bare(ret_code_t error_code)
|
||||
{
|
||||
error_info_t error_info =
|
||||
{
|
||||
.line_num = 0,
|
||||
.p_file_name = NULL,
|
||||
.err_code = error_code,
|
||||
};
|
||||
|
||||
app_error_fault_handler(NRF_FAULT_ID_SDK_ERROR, 0, (uint32_t)(&error_info));
|
||||
|
||||
UNUSED_VARIABLE(error_info);
|
||||
}
|
||||
|
||||
void app_error_save_and_stop(uint32_t id, uint32_t pc, uint32_t info)
|
||||
{
|
||||
/* static error variables - in order to prevent removal by optimizers */
|
||||
static volatile struct
|
||||
{
|
||||
uint32_t fault_id;
|
||||
uint32_t pc;
|
||||
uint32_t error_info;
|
||||
assert_info_t * p_assert_info;
|
||||
error_info_t * p_error_info;
|
||||
ret_code_t err_code;
|
||||
uint32_t line_num;
|
||||
const uint8_t * p_file_name;
|
||||
} m_error_data = {0};
|
||||
|
||||
// The following variable helps Keil keep the call stack visible, in addition, it can be set to
|
||||
// 0 in the debugger to continue executing code after the error check.
|
||||
volatile bool loop = true;
|
||||
UNUSED_VARIABLE(loop);
|
||||
|
||||
m_error_data.fault_id = id;
|
||||
m_error_data.pc = pc;
|
||||
m_error_data.error_info = info;
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case NRF_FAULT_ID_SDK_ASSERT:
|
||||
m_error_data.p_assert_info = (assert_info_t *)info;
|
||||
m_error_data.line_num = m_error_data.p_assert_info->line_num;
|
||||
m_error_data.p_file_name = m_error_data.p_assert_info->p_file_name;
|
||||
break;
|
||||
|
||||
case NRF_FAULT_ID_SDK_ERROR:
|
||||
m_error_data.p_error_info = (error_info_t *)info;
|
||||
m_error_data.err_code = m_error_data.p_error_info->err_code;
|
||||
m_error_data.line_num = m_error_data.p_error_info->line_num;
|
||||
m_error_data.p_file_name = m_error_data.p_error_info->p_file_name;
|
||||
break;
|
||||
}
|
||||
|
||||
UNUSED_VARIABLE(m_error_data);
|
||||
|
||||
// If printing is disrupted, remove the irq calls, or set the loop variable to 0 in the debugger.
|
||||
__disable_irq();
|
||||
while (loop);
|
||||
|
||||
__enable_irq();
|
||||
}
|
||||
|
||||
+192
-192
@@ -1,192 +1,192 @@
|
||||
/**
|
||||
* Copyright (c) 2013 - 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.
|
||||
*
|
||||
*/
|
||||
/** @file
|
||||
*
|
||||
* @defgroup app_error Common application error handler
|
||||
* @{
|
||||
* @ingroup app_common
|
||||
*
|
||||
* @brief Common application error handler and macros for utilizing a common error handler.
|
||||
*/
|
||||
|
||||
#ifndef APP_ERROR_H__
|
||||
#define APP_ERROR_H__
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include "nrf.h"
|
||||
#include "sdk_errors.h"
|
||||
#include "nordic_common.h"
|
||||
#include "app_error_weak.h"
|
||||
#ifdef ANT_STACK_SUPPORT_REQD
|
||||
#include "ant_error.h"
|
||||
#endif // ANT_STACK_SUPPORT_REQD
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define NRF_FAULT_ID_SDK_RANGE_START (0x00004000) /**< The start of the range of error IDs defined in the SDK. */
|
||||
|
||||
/**@defgroup APP_ERROR_FAULT_IDS Fault ID types
|
||||
* @{ */
|
||||
#define NRF_FAULT_ID_SDK_ERROR (NRF_FAULT_ID_SDK_RANGE_START + 1) /**< An error stemming from a call to @ref APP_ERROR_CHECK or @ref APP_ERROR_CHECK_BOOL. The info parameter is a pointer to an @ref error_info_t variable. */
|
||||
#define NRF_FAULT_ID_SDK_ASSERT (NRF_FAULT_ID_SDK_RANGE_START + 2) /**< An error stemming from a call to ASSERT (nrf_assert.h). The info parameter is a pointer to an @ref assert_info_t variable. */
|
||||
/**@} */
|
||||
|
||||
/**@brief Structure containing info about an error of the type @ref NRF_FAULT_ID_SDK_ERROR.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t line_num; /**< The line number where the error occurred. */
|
||||
uint8_t const * p_file_name; /**< The file in which the error occurred. */
|
||||
uint32_t err_code; /**< The error code representing the error that occurred. */
|
||||
} error_info_t;
|
||||
|
||||
/**@brief Structure containing info about an error of the type @ref NRF_FAULT_ID_SDK_ASSERT.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t line_num; /**< The line number where the error occurred. */
|
||||
uint8_t const * p_file_name; /**< The file in which the error occurred. */
|
||||
} assert_info_t;
|
||||
|
||||
/**@brief Defines required by app_error_handler assembler intructions.
|
||||
*/
|
||||
#define APP_ERROR_ERROR_INFO_OFFSET_LINE_NUM (offsetof(error_info_t, line_num))
|
||||
#define APP_ERROR_ERROR_INFO_OFFSET_P_FILE_NAME (offsetof(error_info_t, p_file_name))
|
||||
#define APP_ERROR_ERROR_INFO_OFFSET_ERR_CODE (offsetof(error_info_t, err_code))
|
||||
#define APP_ERROR_ERROR_INFO_SIZE (sizeof(error_info_t))
|
||||
#define APP_ERROR_ERROR_INFO_SIZE_ALIGNED_8BYTE \
|
||||
ALIGN_NUM(APP_ERROR_ERROR_INFO_SIZE, sizeof(uint64_t))
|
||||
|
||||
|
||||
/**@brief Function for error handling, which is called when an error has occurred.
|
||||
*
|
||||
* @param[in] error_code Error code supplied to the handler.
|
||||
* @param[in] line_num Line number where the handler is called.
|
||||
* @param[in] p_file_name Pointer to the file name.
|
||||
*/
|
||||
void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name);
|
||||
|
||||
/**@brief Function for error handling, which is called when an error has occurred.
|
||||
*
|
||||
* @param[in] error_code Error code supplied to the handler.
|
||||
*/
|
||||
void app_error_handler_bare(ret_code_t error_code);
|
||||
|
||||
/**@brief Function for saving the parameters and entering an eternal loop, for debug purposes.
|
||||
*
|
||||
* @param[in] id Fault identifier. See @ref NRF_FAULT_IDS.
|
||||
* @param[in] pc The program counter of the instruction that triggered the fault, or 0 if
|
||||
* unavailable.
|
||||
* @param[in] info Optional additional information regarding the fault. Refer to each fault
|
||||
* identifier for details.
|
||||
*/
|
||||
void app_error_save_and_stop(uint32_t id, uint32_t pc, uint32_t info);
|
||||
|
||||
/**@brief Function for logging details of error and flushing logs.
|
||||
*
|
||||
* @param[in] id Fault identifier. See @ref NRF_FAULT_IDS.
|
||||
* @param[in] pc The program counter of the instruction that triggered the fault, or 0 if
|
||||
* unavailable.
|
||||
* @param[in] info Optional additional information regarding the fault. Refer to each fault
|
||||
* identifier for details.
|
||||
*/
|
||||
void app_error_log_handle(uint32_t id, uint32_t pc, uint32_t info);
|
||||
|
||||
|
||||
/**@brief Macro for calling error handler function.
|
||||
*
|
||||
* @param[in] ERR_CODE Error code supplied to the error handler.
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
#define APP_ERROR_HANDLER(ERR_CODE) \
|
||||
do \
|
||||
{ \
|
||||
app_error_handler((ERR_CODE), __LINE__, (uint8_t*) __FILE__); \
|
||||
} while (0)
|
||||
#else
|
||||
#define APP_ERROR_HANDLER(ERR_CODE) \
|
||||
do \
|
||||
{ \
|
||||
app_error_handler_bare((ERR_CODE)); \
|
||||
} while (0)
|
||||
#endif
|
||||
/**@brief Macro for calling error handler function if supplied error code any other than NRF_SUCCESS.
|
||||
*
|
||||
* @param[in] ERR_CODE Error code supplied to the error handler.
|
||||
*/
|
||||
#define APP_ERROR_CHECK(ERR_CODE) \
|
||||
do \
|
||||
{ \
|
||||
const uint32_t LOCAL_ERR_CODE = (ERR_CODE); \
|
||||
if (LOCAL_ERR_CODE != NRF_SUCCESS) \
|
||||
{ \
|
||||
APP_ERROR_HANDLER(LOCAL_ERR_CODE); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**@brief Macro for calling error handler function if supplied boolean value is false.
|
||||
*
|
||||
* @param[in] BOOLEAN_VALUE Boolean value to be evaluated.
|
||||
*/
|
||||
#define APP_ERROR_CHECK_BOOL(BOOLEAN_VALUE) \
|
||||
do \
|
||||
{ \
|
||||
const uint32_t LOCAL_BOOLEAN_VALUE = (BOOLEAN_VALUE); \
|
||||
if (!LOCAL_BOOLEAN_VALUE) \
|
||||
{ \
|
||||
APP_ERROR_HANDLER(0); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // APP_ERROR_H__
|
||||
|
||||
/** @} */
|
||||
/**
|
||||
* Copyright (c) 2013 - 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.
|
||||
*
|
||||
*/
|
||||
/** @file
|
||||
*
|
||||
* @defgroup app_error Common application error handler
|
||||
* @{
|
||||
* @ingroup app_common
|
||||
*
|
||||
* @brief Common application error handler and macros for utilizing a common error handler.
|
||||
*/
|
||||
|
||||
#ifndef APP_ERROR_H__
|
||||
#define APP_ERROR_H__
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include "nrf.h"
|
||||
#include "sdk_errors.h"
|
||||
#include "nordic_common.h"
|
||||
#include "app_error_weak.h"
|
||||
#ifdef ANT_STACK_SUPPORT_REQD
|
||||
#include "ant_error.h"
|
||||
#endif // ANT_STACK_SUPPORT_REQD
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define NRF_FAULT_ID_SDK_RANGE_START (0x00004000) /**< The start of the range of error IDs defined in the SDK. */
|
||||
|
||||
/**@defgroup APP_ERROR_FAULT_IDS Fault ID types
|
||||
* @{ */
|
||||
#define NRF_FAULT_ID_SDK_ERROR (NRF_FAULT_ID_SDK_RANGE_START + 1) /**< An error stemming from a call to @ref APP_ERROR_CHECK or @ref APP_ERROR_CHECK_BOOL. The info parameter is a pointer to an @ref error_info_t variable. */
|
||||
#define NRF_FAULT_ID_SDK_ASSERT (NRF_FAULT_ID_SDK_RANGE_START + 2) /**< An error stemming from a call to ASSERT (nrf_assert.h). The info parameter is a pointer to an @ref assert_info_t variable. */
|
||||
/**@} */
|
||||
|
||||
/**@brief Structure containing info about an error of the type @ref NRF_FAULT_ID_SDK_ERROR.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t line_num; /**< The line number where the error occurred. */
|
||||
uint8_t const * p_file_name; /**< The file in which the error occurred. */
|
||||
uint32_t err_code; /**< The error code representing the error that occurred. */
|
||||
} error_info_t;
|
||||
|
||||
/**@brief Structure containing info about an error of the type @ref NRF_FAULT_ID_SDK_ASSERT.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t line_num; /**< The line number where the error occurred. */
|
||||
uint8_t const * p_file_name; /**< The file in which the error occurred. */
|
||||
} assert_info_t;
|
||||
|
||||
/**@brief Defines required by app_error_handler assembler intructions.
|
||||
*/
|
||||
#define APP_ERROR_ERROR_INFO_OFFSET_LINE_NUM (offsetof(error_info_t, line_num))
|
||||
#define APP_ERROR_ERROR_INFO_OFFSET_P_FILE_NAME (offsetof(error_info_t, p_file_name))
|
||||
#define APP_ERROR_ERROR_INFO_OFFSET_ERR_CODE (offsetof(error_info_t, err_code))
|
||||
#define APP_ERROR_ERROR_INFO_SIZE (sizeof(error_info_t))
|
||||
#define APP_ERROR_ERROR_INFO_SIZE_ALIGNED_8BYTE \
|
||||
ALIGN_NUM(APP_ERROR_ERROR_INFO_SIZE, sizeof(uint64_t))
|
||||
|
||||
|
||||
/**@brief Function for error handling, which is called when an error has occurred.
|
||||
*
|
||||
* @param[in] error_code Error code supplied to the handler.
|
||||
* @param[in] line_num Line number where the handler is called.
|
||||
* @param[in] p_file_name Pointer to the file name.
|
||||
*/
|
||||
void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name);
|
||||
|
||||
/**@brief Function for error handling, which is called when an error has occurred.
|
||||
*
|
||||
* @param[in] error_code Error code supplied to the handler.
|
||||
*/
|
||||
void app_error_handler_bare(ret_code_t error_code);
|
||||
|
||||
/**@brief Function for saving the parameters and entering an eternal loop, for debug purposes.
|
||||
*
|
||||
* @param[in] id Fault identifier. See @ref NRF_FAULT_IDS.
|
||||
* @param[in] pc The program counter of the instruction that triggered the fault, or 0 if
|
||||
* unavailable.
|
||||
* @param[in] info Optional additional information regarding the fault. Refer to each fault
|
||||
* identifier for details.
|
||||
*/
|
||||
void app_error_save_and_stop(uint32_t id, uint32_t pc, uint32_t info);
|
||||
|
||||
/**@brief Function for logging details of error and flushing logs.
|
||||
*
|
||||
* @param[in] id Fault identifier. See @ref NRF_FAULT_IDS.
|
||||
* @param[in] pc The program counter of the instruction that triggered the fault, or 0 if
|
||||
* unavailable.
|
||||
* @param[in] info Optional additional information regarding the fault. Refer to each fault
|
||||
* identifier for details.
|
||||
*/
|
||||
void app_error_log_handle(uint32_t id, uint32_t pc, uint32_t info);
|
||||
|
||||
|
||||
/**@brief Macro for calling error handler function.
|
||||
*
|
||||
* @param[in] ERR_CODE Error code supplied to the error handler.
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
#define APP_ERROR_HANDLER(ERR_CODE) \
|
||||
do \
|
||||
{ \
|
||||
app_error_handler((ERR_CODE), __LINE__, (uint8_t*) __FILE__); \
|
||||
} while (0)
|
||||
#else
|
||||
#define APP_ERROR_HANDLER(ERR_CODE) \
|
||||
do \
|
||||
{ \
|
||||
app_error_handler_bare((ERR_CODE)); \
|
||||
} while (0)
|
||||
#endif
|
||||
/**@brief Macro for calling error handler function if supplied error code any other than NRF_SUCCESS.
|
||||
*
|
||||
* @param[in] ERR_CODE Error code supplied to the error handler.
|
||||
*/
|
||||
#define APP_ERROR_CHECK(ERR_CODE) \
|
||||
do \
|
||||
{ \
|
||||
const uint32_t LOCAL_ERR_CODE = (ERR_CODE); \
|
||||
if (LOCAL_ERR_CODE != NRF_SUCCESS) \
|
||||
{ \
|
||||
APP_ERROR_HANDLER(LOCAL_ERR_CODE); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**@brief Macro for calling error handler function if supplied boolean value is false.
|
||||
*
|
||||
* @param[in] BOOLEAN_VALUE Boolean value to be evaluated.
|
||||
*/
|
||||
#define APP_ERROR_CHECK_BOOL(BOOLEAN_VALUE) \
|
||||
do \
|
||||
{ \
|
||||
const uint32_t LOCAL_BOOLEAN_VALUE = (BOOLEAN_VALUE); \
|
||||
if (!LOCAL_BOOLEAN_VALUE) \
|
||||
{ \
|
||||
APP_ERROR_HANDLER(0); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // APP_ERROR_H__
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -1,59 +1,58 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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.
|
||||
*
|
||||
*/
|
||||
#include "app_error.h"
|
||||
#include <assert.h>
|
||||
|
||||
/*lint -save -e14 */
|
||||
/**
|
||||
* Function is implemented as weak so that it can be overwritten by custom application error handler
|
||||
* when needed.
|
||||
*/
|
||||
__WEAK void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
|
||||
{
|
||||
(void)id;
|
||||
(void)pc;
|
||||
(void)info;
|
||||
#ifndef DEBUG
|
||||
NVIC_SystemReset();
|
||||
#else
|
||||
assert(false);
|
||||
#endif // DEBUG
|
||||
}
|
||||
/*lint -restore */
|
||||
/**
|
||||
* Copyright (c) 2016 - 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.
|
||||
*
|
||||
*/
|
||||
#include "app_error.h"
|
||||
|
||||
/*lint -save -e14 */
|
||||
/**
|
||||
* Function is implemented as weak so that it can be overwritten by custom application error handler
|
||||
* when needed.
|
||||
*/
|
||||
__WEAK void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
|
||||
{
|
||||
(void)id;
|
||||
(void)pc;
|
||||
(void)info;
|
||||
#ifndef DEBUG
|
||||
NVIC_SystemReset();
|
||||
#else
|
||||
assert(false);
|
||||
#endif // DEBUG
|
||||
}
|
||||
/*lint -restore */
|
||||
|
||||
@@ -1,87 +1,87 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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 APP_ERROR_WEAK_H__
|
||||
#define APP_ERROR_WEAK_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @file
|
||||
*
|
||||
* @defgroup app_error Common application error handler
|
||||
* @{
|
||||
* @ingroup app_common
|
||||
*
|
||||
* @brief Common application error handler.
|
||||
*/
|
||||
|
||||
/**@brief Callback function for errors, asserts, and faults.
|
||||
*
|
||||
* @details This function is called every time an error is raised in app_error, nrf_assert, or
|
||||
* in the SoftDevice. Information about the error can be found in the @p info
|
||||
* parameter.
|
||||
*
|
||||
* See also @ref nrf_fault_handler_t for more details.
|
||||
*
|
||||
* @note The function is implemented as weak so that it can be redefined by a custom error
|
||||
* handler when needed.
|
||||
*
|
||||
* @param[in] id Fault identifier. See @ref NRF_FAULT_IDS.
|
||||
* @param[in] pc The program counter of the instruction that triggered the fault, or 0 if
|
||||
* unavailable.
|
||||
* @param[in] info Optional additional information regarding the fault. The value of the @p id
|
||||
* parameter dictates how to interpret this parameter. Refer to the documentation
|
||||
* for each fault identifier (@ref NRF_FAULT_IDS and @ref APP_ERROR_FAULT_IDS) for
|
||||
* details about interpreting @p info.
|
||||
*/
|
||||
void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info);
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // APP_ERROR_WEAK_H__
|
||||
/**
|
||||
* Copyright (c) 2016 - 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 APP_ERROR_WEAK_H__
|
||||
#define APP_ERROR_WEAK_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @file
|
||||
*
|
||||
* @defgroup app_error Common application error handler
|
||||
* @{
|
||||
* @ingroup app_common
|
||||
*
|
||||
* @brief Common application error handler.
|
||||
*/
|
||||
|
||||
/**@brief Callback function for errors, asserts, and faults.
|
||||
*
|
||||
* @details This function is called every time an error is raised in app_error, nrf_assert, or
|
||||
* in the SoftDevice. Information about the error can be found in the @p info
|
||||
* parameter.
|
||||
*
|
||||
* See also @ref nrf_fault_handler_t for more details.
|
||||
*
|
||||
* @note The function is implemented as weak so that it can be redefined by a custom error
|
||||
* handler when needed.
|
||||
*
|
||||
* @param[in] id Fault identifier. See @ref NRF_FAULT_IDS.
|
||||
* @param[in] pc The program counter of the instruction that triggered the fault, or 0 if
|
||||
* unavailable.
|
||||
* @param[in] info Optional additional information regarding the fault. The value of the @p id
|
||||
* parameter dictates how to interpret this parameter. Refer to the documentation
|
||||
* for each fault identifier (@ref NRF_FAULT_IDS and @ref APP_ERROR_FAULT_IDS) for
|
||||
* details about interpreting @p info.
|
||||
*/
|
||||
void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info);
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // APP_ERROR_WEAK_H__
|
||||
|
||||
+189
-187
@@ -1,187 +1,189 @@
|
||||
/**
|
||||
* Copyright (c) 2011 - 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "app_util.h"
|
||||
#include "nrf_atfifo.h"
|
||||
#include "nrf_atfifo_internal.h"
|
||||
|
||||
#if NRF_ATFIFO_CONFIG_LOG_ENABLED
|
||||
#define NRF_LOG_LEVEL NRF_ATFIFO_CONFIG_LOG_LEVEL
|
||||
#define NRF_LOG_INIT_FILTER_LEVEL NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL
|
||||
#define NRF_LOG_INFO_COLOR NRF_ATFIFO_CONFIG_INFO_COLOR
|
||||
#define NRF_LOG_DEBUG_COLOR NRF_ATFIFO_CONFIG_DEBUG_COLOR
|
||||
#else
|
||||
#define NRF_LOG_LEVEL 0
|
||||
#endif // NRF_ATFIFO_CONFIG_LOG_ENABLED
|
||||
#include "nrf_log.h"
|
||||
|
||||
/* Unions testing */
|
||||
STATIC_ASSERT(sizeof(nrf_atfifo_postag_t) == sizeof(uint32_t));
|
||||
|
||||
|
||||
ret_code_t nrf_atfifo_init(nrf_atfifo_t * const p_fifo, void * p_buf, uint16_t buf_size, uint16_t item_size)
|
||||
{
|
||||
if (NULL == p_buf)
|
||||
{
|
||||
NRF_LOG_INST_ERROR(p_fifo->p_log, "Initialization failed. p_buf == NULL");
|
||||
return NRF_ERROR_NULL;
|
||||
}
|
||||
if (0 != (buf_size % item_size))
|
||||
{
|
||||
NRF_LOG_INST_ERROR(p_fifo->p_log, "Initialization failed. Buf_size not multiple of item_size");
|
||||
return NRF_ERROR_INVALID_LENGTH;
|
||||
}
|
||||
|
||||
p_fifo->p_buf = p_buf;
|
||||
p_fifo->tail.tag = 0;
|
||||
p_fifo->head.tag = 0;
|
||||
p_fifo->buf_size = buf_size;
|
||||
p_fifo->item_size = item_size;
|
||||
|
||||
NRF_LOG_INST_INFO(p_fifo->p_log, "Initialized.");
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ret_code_t nrf_atfifo_clear(nrf_atfifo_t * const p_fifo)
|
||||
{
|
||||
bool released = nrf_atfifo_space_clear(p_fifo);
|
||||
NRF_LOG_INST_INFO(p_fifo->p_log, "Cleared result:%s", released ? "success" : "busy");
|
||||
return released ? NRF_SUCCESS : NRF_ERROR_BUSY;
|
||||
}
|
||||
|
||||
|
||||
ret_code_t nrf_atfifo_alloc_put(nrf_atfifo_t * const p_fifo, void const * p_var, size_t size, bool * const p_visible)
|
||||
{
|
||||
nrf_atfifo_item_put_t context;
|
||||
bool visible;
|
||||
void * p_data = nrf_atfifo_item_alloc(p_fifo, &context);
|
||||
if (NULL == p_data)
|
||||
{
|
||||
NRF_LOG_INST_WARNING(p_fifo->p_log, "Copying in element (0x%08X) failed - no space.", p_var);
|
||||
return NRF_ERROR_NO_MEM;
|
||||
}
|
||||
|
||||
memcpy(p_data, p_var, size);
|
||||
|
||||
visible = nrf_atfifo_item_put(p_fifo, &context);
|
||||
if (NULL != p_visible)
|
||||
{
|
||||
*p_visible = visible;
|
||||
}
|
||||
NRF_LOG_INST_DEBUG(p_fifo->p_log, "Element (0x%08X) copied in.", p_var);
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void * nrf_atfifo_item_alloc(nrf_atfifo_t * const p_fifo, nrf_atfifo_item_put_t * p_context)
|
||||
{
|
||||
if (nrf_atfifo_wspace_req(p_fifo, &(p_context->last_tail)))
|
||||
{
|
||||
void * p_item = ((uint8_t*)(p_fifo->p_buf)) + p_context->last_tail.pos.wr;
|
||||
NRF_LOG_INST_DEBUG(p_fifo->p_log, "Allocated element (0x%08X).", p_item);
|
||||
return p_item;
|
||||
}
|
||||
NRF_LOG_INST_WARNING(p_fifo->p_log, "Allocation failed - no space.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
bool nrf_atfifo_item_put(nrf_atfifo_t * const p_fifo, nrf_atfifo_item_put_t * p_context)
|
||||
{
|
||||
if ((p_context->last_tail.pos.wr) == (p_context->last_tail.pos.rd))
|
||||
{
|
||||
NRF_LOG_INST_DEBUG(p_fifo->p_log, "Put (uninterrupted)");
|
||||
nrf_atfifo_wspace_close(p_fifo);
|
||||
return true;
|
||||
}
|
||||
NRF_LOG_INST_DEBUG(p_fifo->p_log, "Put (interrupted!)");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
ret_code_t nrf_atfifo_get_free(nrf_atfifo_t * const p_fifo, void * const p_var, size_t size, bool * p_released)
|
||||
{
|
||||
nrf_atfifo_item_get_t context;
|
||||
bool released;
|
||||
void const * p_s = nrf_atfifo_item_get(p_fifo, &context);
|
||||
if (NULL == p_s)
|
||||
{
|
||||
NRF_LOG_INST_WARNING(p_fifo->p_log, "Copying out failed - no item in the FIFO.");
|
||||
return NRF_ERROR_NOT_FOUND;
|
||||
}
|
||||
|
||||
memcpy(p_var, p_s, size);
|
||||
|
||||
released = nrf_atfifo_item_free(p_fifo, &context);
|
||||
if (NULL != p_released)
|
||||
{
|
||||
*p_released = released;
|
||||
}
|
||||
NRF_LOG_INST_DEBUG(p_fifo->p_log, "Element (0x%08X) copied out.", p_var);
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void * nrf_atfifo_item_get(nrf_atfifo_t * const p_fifo, nrf_atfifo_item_get_t * p_context)
|
||||
{
|
||||
if (nrf_atfifo_rspace_req(p_fifo, &(p_context->last_head)))
|
||||
{
|
||||
void * p_item = ((uint8_t*)(p_fifo->p_buf)) + p_context->last_head.pos.rd;
|
||||
NRF_LOG_INST_DEBUG(p_fifo->p_log, "Get element: 0x%08X", p_item);
|
||||
return p_item;
|
||||
}
|
||||
NRF_LOG_INST_WARNING(p_fifo->p_log, "Get failed - no item in the FIFO.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
bool nrf_atfifo_item_free(nrf_atfifo_t * const p_fifo, nrf_atfifo_item_get_t * p_context)
|
||||
{
|
||||
if ((p_context->last_head.pos.wr) == (p_context->last_head.pos.rd))
|
||||
{
|
||||
NRF_LOG_INST_DEBUG(p_fifo->p_log, "Free (uninterrupted)");
|
||||
nrf_atfifo_rspace_close(p_fifo);
|
||||
return true;
|
||||
}
|
||||
NRF_LOG_INST_DEBUG(p_fifo->p_log, "Free (interrupted)");
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2011 - 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "app_util.h"
|
||||
#include "nrf_atfifo.h"
|
||||
#include "nrf_atfifo_internal.h"
|
||||
|
||||
#if NRF_ATFIFO_CONFIG_LOG_ENABLED
|
||||
#define NRF_LOG_LEVEL NRF_ATFIFO_CONFIG_LOG_LEVEL
|
||||
#define NRF_LOG_INIT_FILTER_LEVEL NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL
|
||||
#define NRF_LOG_INFO_COLOR NRF_ATFIFO_CONFIG_INFO_COLOR
|
||||
#define NRF_LOG_DEBUG_COLOR NRF_ATFIFO_CONFIG_DEBUG_COLOR
|
||||
#else
|
||||
#define NRF_LOG_LEVEL 0
|
||||
#endif // NRF_ATFIFO_CONFIG_LOG_ENABLED
|
||||
#include "nrf_log.h"
|
||||
|
||||
/* Unions testing */
|
||||
STATIC_ASSERT(sizeof(nrf_atfifo_postag_t) == sizeof(uint32_t));
|
||||
|
||||
|
||||
ret_code_t nrf_atfifo_init(nrf_atfifo_t * const p_fifo, void * p_buf, uint16_t buf_size, uint16_t item_size)
|
||||
{
|
||||
if (NULL == p_buf)
|
||||
{
|
||||
NRF_LOG_INST_ERROR(p_fifo->p_log, "Initialization failed. p_buf == NULL");
|
||||
return NRF_ERROR_NULL;
|
||||
}
|
||||
if (0 != (buf_size % item_size))
|
||||
{
|
||||
NRF_LOG_INST_ERROR(p_fifo->p_log, "Initialization failed. Buf_size not multiple of item_size");
|
||||
return NRF_ERROR_INVALID_LENGTH;
|
||||
}
|
||||
|
||||
p_fifo->p_buf = p_buf;
|
||||
p_fifo->tail.tag = 0;
|
||||
p_fifo->head.tag = 0;
|
||||
p_fifo->buf_size = buf_size;
|
||||
p_fifo->item_size = item_size;
|
||||
|
||||
NRF_LOG_INST_INFO(p_fifo->p_log, "Initialized.");
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ret_code_t nrf_atfifo_clear(nrf_atfifo_t * const p_fifo)
|
||||
{
|
||||
bool released = nrf_atfifo_space_clear(p_fifo);
|
||||
NRF_LOG_INST_INFO(p_fifo->p_log, "Cleared result:%s", released ? "success" : "busy");
|
||||
return released ? NRF_SUCCESS : NRF_ERROR_BUSY;
|
||||
}
|
||||
|
||||
|
||||
ret_code_t nrf_atfifo_alloc_put(nrf_atfifo_t * const p_fifo, void const * p_var, size_t size, bool * const p_visible)
|
||||
{
|
||||
nrf_atfifo_item_put_t context;
|
||||
bool visible;
|
||||
void * p_data = nrf_atfifo_item_alloc(p_fifo, &context);
|
||||
if (NULL == p_data)
|
||||
{
|
||||
NRF_LOG_INST_WARNING(p_fifo->p_log, "Copying in element (0x%08X) failed - no space.", p_var);
|
||||
return NRF_ERROR_NO_MEM;
|
||||
}
|
||||
|
||||
memcpy(p_data, p_var, size);
|
||||
|
||||
visible = nrf_atfifo_item_put(p_fifo, &context);
|
||||
if (NULL != p_visible)
|
||||
{
|
||||
*p_visible = visible;
|
||||
}
|
||||
NRF_LOG_INST_DEBUG(p_fifo->p_log, "Element (0x%08X) copied in.", p_var);
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void * nrf_atfifo_item_alloc(nrf_atfifo_t * const p_fifo, nrf_atfifo_item_put_t * p_context)
|
||||
{
|
||||
if (nrf_atfifo_wspace_req(p_fifo, &(p_context->last_tail)))
|
||||
{
|
||||
void * p_item = ((uint8_t*)(p_fifo->p_buf)) + p_context->last_tail.pos.wr;
|
||||
NRF_LOG_INST_DEBUG(p_fifo->p_log, "Allocated element (0x%08X).", p_item);
|
||||
return p_item;
|
||||
}
|
||||
NRF_LOG_INST_WARNING(p_fifo->p_log, "Allocation failed - no space.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
bool nrf_atfifo_item_put(nrf_atfifo_t * const p_fifo, nrf_atfifo_item_put_t * p_context)
|
||||
{
|
||||
if ((p_context->last_tail.pos.wr) == (p_context->last_tail.pos.rd))
|
||||
{
|
||||
NRF_LOG_INST_DEBUG(p_fifo->p_log, "Put (uninterrupted)");
|
||||
nrf_atfifo_wspace_close(p_fifo);
|
||||
return true;
|
||||
}
|
||||
NRF_LOG_INST_DEBUG(p_fifo->p_log, "Put (interrupted!)");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
ret_code_t nrf_atfifo_get_free(nrf_atfifo_t * const p_fifo, void * const p_var, size_t size, bool * p_released)
|
||||
{
|
||||
nrf_atfifo_item_get_t context;
|
||||
bool released;
|
||||
void const * p_s = nrf_atfifo_item_get(p_fifo, &context);
|
||||
if (NULL == p_s)
|
||||
{
|
||||
NRF_LOG_INST_WARNING(p_fifo->p_log, "Copying out failed - no item in the FIFO.");
|
||||
return NRF_ERROR_NOT_FOUND;
|
||||
}
|
||||
|
||||
memcpy(p_var, p_s, size);
|
||||
|
||||
released = nrf_atfifo_item_free(p_fifo, &context);
|
||||
if (NULL != p_released)
|
||||
{
|
||||
*p_released = released;
|
||||
}
|
||||
NRF_LOG_INST_DEBUG(p_fifo->p_log, "Element (0x%08X) copied out.", p_var);
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void * nrf_atfifo_item_get(nrf_atfifo_t * const p_fifo, nrf_atfifo_item_get_t * p_context)
|
||||
{
|
||||
if (nrf_atfifo_rspace_req(p_fifo, &(p_context->last_head)))
|
||||
{
|
||||
void * p_item = ((uint8_t*)(p_fifo->p_buf)) + p_context->last_head.pos.rd;
|
||||
NRF_LOG_INST_DEBUG(p_fifo->p_log, "Get element: 0x%08X", p_item);
|
||||
return p_item;
|
||||
}
|
||||
NRF_LOG_INST_WARNING(p_fifo->p_log, "Get failed - no item in the FIFO.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
bool nrf_atfifo_item_free(nrf_atfifo_t * const p_fifo, nrf_atfifo_item_get_t * p_context)
|
||||
{
|
||||
if ((p_context->last_head.pos.wr) == (p_context->last_head.pos.rd))
|
||||
{
|
||||
NRF_LOG_INST_DEBUG(p_fifo->p_log, "Free (uninterrupted)");
|
||||
nrf_atfifo_rspace_close(p_fifo);
|
||||
return true;
|
||||
}
|
||||
NRF_LOG_INST_DEBUG(p_fifo->p_log, "Free (interrupted)");
|
||||
return false;
|
||||
}
|
||||
|
||||
+424
-422
@@ -1,422 +1,424 @@
|
||||
/**
|
||||
* Copyright (c) 2011 - 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_ATFIFO_H__
|
||||
#define NRF_ATFIFO_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "sdk_config.h"
|
||||
#include "nordic_common.h"
|
||||
#include "nrf_assert.h"
|
||||
#include "sdk_errors.h"
|
||||
#include "nrf_log_instance.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_atfifo Atomic FIFO
|
||||
* @ingroup app_common
|
||||
*
|
||||
* @brief @tagAPI52 FIFO implementation that allows for making atomic transactions without
|
||||
* locking interrupts.
|
||||
*
|
||||
* @details There are two types of functions to prepare the FIFO writing:
|
||||
* - Single function for simple access:
|
||||
* @code
|
||||
* if (NRF_SUCCESS != nrf_atfifo_simple_put(my_fifo, &data, NULL))
|
||||
* {
|
||||
* // Error handling
|
||||
* }
|
||||
* @endcode
|
||||
* - Function pair to limit data copying:
|
||||
* @code
|
||||
* struct point3d
|
||||
* {
|
||||
* int x, y, z;
|
||||
* }point3d_t;
|
||||
* nrf_atfifo_context_t context;
|
||||
* point3d_t * point;
|
||||
*
|
||||
* if (NULL != (point = nrf_atfifo_item_alloc(my_fifo, &context)))
|
||||
* {
|
||||
* point->x = a;
|
||||
* point->y = b;
|
||||
* point->z = c;
|
||||
* if (nrf_atfifo_item_put(my_fifo, &context))
|
||||
* {
|
||||
* // Send information to the rest of the system
|
||||
* // that there is new data in the FIFO available for reading.
|
||||
* }
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // Error handling
|
||||
* }
|
||||
*
|
||||
* @endcode
|
||||
* @note
|
||||
* This atomic FIFO implementation requires that the operation that is
|
||||
* opened last is finished (committed/flushed) first.
|
||||
* This is typical for operations performed from the interrupt runtime
|
||||
* when the other operation is performed from the main thread.
|
||||
*
|
||||
* This implementation does not support typical multithreading operating system
|
||||
* access where operations can be started and finished in totally unrelated order.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Read and write position structure.
|
||||
*
|
||||
* A structure that holds the read and write position used by the FIFO head and tail.
|
||||
*/
|
||||
typedef struct nrf_atfifo_postag_pos_s
|
||||
{
|
||||
uint16_t wr; //!< First free space to write the data
|
||||
uint16_t rd; //!< A place after the last data to read
|
||||
}nrf_atfifo_postag_pos_t;
|
||||
|
||||
/**
|
||||
* @brief End data index tag.
|
||||
*
|
||||
* A tag used to mark the end of data.
|
||||
* To properly realize atomic data committing, the whole variable has to be
|
||||
* accessed atomically.
|
||||
*/
|
||||
typedef union nrf_atfifo_postag_u
|
||||
{
|
||||
uint32_t tag; //!< Whole tag, used for atomic, 32-bit access
|
||||
nrf_atfifo_postag_pos_t pos; //!< Structure that holds reading and writing position separately
|
||||
}nrf_atfifo_postag_t;
|
||||
|
||||
/**
|
||||
* @brief The FIFO instance.
|
||||
*
|
||||
* The instance of atomic FIFO.
|
||||
* Used with all FIFO functions.
|
||||
*/
|
||||
typedef struct nrf_atfifo_s
|
||||
{
|
||||
void * p_buf; //!< Pointer to the data buffer
|
||||
nrf_atfifo_postag_t tail; //!< Read and write tail position tag
|
||||
nrf_atfifo_postag_t head; //!< Read and write head position tag
|
||||
uint16_t buf_size; //!< FIFO size in number of bytes (has to be divisible by @c item_size)
|
||||
uint16_t item_size; //!< Size of a single FIFO item
|
||||
NRF_LOG_INSTANCE_PTR_DECLARE(p_log) //!< Pointer to instance of the logger object (Conditionally compiled).
|
||||
}nrf_atfifo_t;
|
||||
|
||||
/**
|
||||
* @brief FIFO write operation item context.
|
||||
*
|
||||
* Context structure used to mark an allocated space in FIFO that is ready for put.
|
||||
* All the data required to properly put allocated and written data.
|
||||
*/
|
||||
typedef struct nrf_atfifo_item_put_s
|
||||
{
|
||||
nrf_atfifo_postag_t last_tail; //!< Tail tag value that was here when opening the FIFO to write
|
||||
}nrf_atfifo_item_put_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief FIFO read operation item context.
|
||||
*
|
||||
* Context structure used to mark an opened get operation to properly free an item after reading.
|
||||
*/
|
||||
typedef struct nrf_atfifo_rcontext_s
|
||||
{
|
||||
nrf_atfifo_postag_t last_head; //!< Head tag value that was here when opening the FIFO to read
|
||||
}nrf_atfifo_item_get_t;
|
||||
|
||||
|
||||
/** @brief Name of the module used for logger messaging.
|
||||
*/
|
||||
#define NRF_ATFIFO_LOG_NAME atfifo
|
||||
|
||||
/**
|
||||
* @defgroup nrf_atfifo_instmacros FIFO instance macros
|
||||
*
|
||||
* A group of macros helpful for FIFO instance creation and initialization.
|
||||
* They may be used to create and initialize instances for most use cases.
|
||||
*
|
||||
* FIFO may also be created and initialized directly using
|
||||
* @ref nrf_atfifo_init function.
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Macro for generating the name for a data buffer.
|
||||
*
|
||||
* The name of the data buffer that would be created by
|
||||
* @ref NRF_ATFIFO_DEF macro.
|
||||
*
|
||||
* @param[in] fifo_id Identifier of the FIFO object.
|
||||
*
|
||||
* @return Name of the buffer variable.
|
||||
*
|
||||
* @note This is auxiliary internal macro and in normal usage
|
||||
* it should not be called.
|
||||
*/
|
||||
#define NRF_ATFIFO_BUF_NAME(fifo_id) CONCAT_2(fifo_id, _data)
|
||||
|
||||
/**
|
||||
* @brief Macro for generating the name for a FIFO instance.
|
||||
*
|
||||
* The name of the instance variable that will be created by the
|
||||
* @ref NRF_ATFIFO_DEF macro.
|
||||
*
|
||||
* @param[in] fifo_id Identifier of the FIFO object.
|
||||
*
|
||||
* @return Name of the instance variable.
|
||||
*
|
||||
* @note This is auxiliary internal macro and in normal usage
|
||||
* it should not be called.
|
||||
*/
|
||||
#define NRF_ATFIFO_INST_NAME(fifo_id) CONCAT_2(fifo_id, _inst)
|
||||
|
||||
/**
|
||||
* @brief Macro for creating an instance.
|
||||
*
|
||||
* Creates the FIFO object variable itself.
|
||||
*
|
||||
* Usage example:
|
||||
* @code
|
||||
* NRF_ATFIFO_DEF(my_fifo, uint16_t, 12);
|
||||
* NRF_ATFIFO_INIT(my_fifo);
|
||||
*
|
||||
* uint16_t some_val = 45;
|
||||
* nrf_atfifo_item_put(my_fifo, &some_val, sizeof(some_val), NULL);
|
||||
* nrf_atfifo_item_get(my_fifo, &some_val, sizeof(some_val), NULL);
|
||||
* @endcode
|
||||
*
|
||||
* @param[in] fifo_id Identifier of a FIFO object.
|
||||
* This identifier will be a pointer to the instance.
|
||||
* It makes it possible to use this directly for the functions
|
||||
* that operate on the FIFO.
|
||||
* Because it is a static const object, it should be optimized by the compiler.
|
||||
* @param[in] storage_type Type of data that will be stored in the FIFO.
|
||||
* @param[in] item_cnt Capacity of the created FIFO in maximum number of items that may be stored.
|
||||
* The phisical size of the buffer will be 1 element bigger.
|
||||
*/
|
||||
#define NRF_ATFIFO_DEF(fifo_id, storage_type, item_cnt) \
|
||||
static storage_type NRF_ATFIFO_BUF_NAME(fifo_id)[(item_cnt)+1]; \
|
||||
NRF_LOG_INSTANCE_REGISTER(NRF_ATFIFO_LOG_NAME, fifo_id, \
|
||||
NRF_ATFIFO_CONFIG_INFO_COLOR, \
|
||||
NRF_ATFIFO_CONFIG_DEBUG_COLOR, \
|
||||
NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL, \
|
||||
NRF_ATFIFO_CONFIG_LOG_LEVEL); \
|
||||
static nrf_atfifo_t NRF_ATFIFO_INST_NAME(fifo_id) = { \
|
||||
.p_buf = NULL, \
|
||||
NRF_LOG_INSTANCE_PTR_INIT(p_log, NRF_ATFIFO_LOG_NAME, fifo_id) \
|
||||
}; \
|
||||
static nrf_atfifo_t * const fifo_id = &NRF_ATFIFO_INST_NAME(fifo_id)
|
||||
|
||||
/**
|
||||
* @brief Macro for initializing the FIFO that was previously declared by the macro.
|
||||
*
|
||||
* Use this macro to simplify FIFO initialization.
|
||||
*
|
||||
* @note
|
||||
* This macro can be only used on a FIFO object defined by @ref NRF_ATFIFO_DEF macro.
|
||||
*
|
||||
* @param[in] fifo_id Identifier of the FIFO object.
|
||||
*
|
||||
* @return Value from the @ref nrf_atfifo_init function.
|
||||
*/
|
||||
#define NRF_ATFIFO_INIT(fifo_id) \
|
||||
nrf_atfifo_init( \
|
||||
fifo_id, \
|
||||
NRF_ATFIFO_BUF_NAME(fifo_id), \
|
||||
sizeof(NRF_ATFIFO_BUF_NAME(fifo_id)), \
|
||||
sizeof(NRF_ATFIFO_BUF_NAME(fifo_id)[0]) \
|
||||
)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the FIFO.
|
||||
*
|
||||
* Preparing the FIFO instance to work.
|
||||
*
|
||||
* @param[out] p_fifo FIFO object to initialize.
|
||||
* @param[in,out] p_buf FIFO buffer for storing data.
|
||||
* @param[in] buf_size Total buffer size (has to be divisible by @c item_size).
|
||||
* @param[in] item_size Size of a single item held inside the FIFO.
|
||||
*
|
||||
* @retval NRF_SUCCESS If initialization was successful.
|
||||
* @retval NRF_ERROR_NULL If a NULL pointer is provided as the buffer.
|
||||
* @retval NRF_ERROR_INVALID_LENGTH If size of the buffer provided is not divisible by @c item_size.
|
||||
*
|
||||
* @note
|
||||
* Buffer size must be able to hold one element more than the designed FIFO capacity.
|
||||
* This one, empty element is used for overflow checking.
|
||||
*/
|
||||
ret_code_t nrf_atfifo_init(nrf_atfifo_t * const p_fifo, void * p_buf, uint16_t buf_size, uint16_t item_size);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the FIFO.
|
||||
*
|
||||
* Function for clearing the FIFO.
|
||||
*
|
||||
* If this function is called during an opened and uncommitted write operation,
|
||||
* the FIFO is cleared up to the currently ongoing commit.
|
||||
* There is no possibility to cancel an ongoing commit.
|
||||
*
|
||||
* If this function is called during an opened and unflushed read operation,
|
||||
* the read position in the head is set, but copying it into the write head position
|
||||
* is left to read closing operation.
|
||||
*
|
||||
* This way, there is no more data to read, but the memory is released
|
||||
* in the moment when it is safe.
|
||||
*
|
||||
* @param[in,out] p_fifo FIFO object.
|
||||
*
|
||||
* @retval NRF_SUCCESS FIFO totally cleared.
|
||||
* @retval NRF_ERROR_BUSY Function called in the middle of writing or reading operation.
|
||||
* If it is called in the middle of writing operation,
|
||||
* FIFO was cleared up to the already started and uncommitted write.
|
||||
* If it is called in the middle of reading operation,
|
||||
* write head was only moved. It will be copied into read tail when the reading operation
|
||||
* is flushed.
|
||||
*/
|
||||
ret_code_t nrf_atfifo_clear(nrf_atfifo_t * const p_fifo);
|
||||
|
||||
/**
|
||||
* @brief Function for atomically putting data into the FIFO.
|
||||
*
|
||||
* It uses memcpy function inside and in most situations, it is more suitable to
|
||||
* use @ref nrf_atfifo_item_alloc, write the data, and @ref nrf_atfifo_item_put to store a new value
|
||||
* in a FIFO.
|
||||
*
|
||||
* @param[in,out] p_fifo FIFO object.
|
||||
* @param[in] p_var Variable to copy.
|
||||
* @param[in] size Size of the variable to copy.
|
||||
* Can be smaller or equal to the FIFO item size.
|
||||
* @param[out] p_visible See value returned by @ref nrf_atfifo_item_put.
|
||||
* It may be NULL if the caller does not require the current operation status.
|
||||
*
|
||||
* @retval NRF_SUCCESS If an element has been successfully added to the FIFO.
|
||||
* @retval NRF_ERROR_NO_MEM If the FIFO is full.
|
||||
*
|
||||
* @note
|
||||
* To avoid data copying, you can use the @ref nrf_atfifo_item_alloc and @ref nrf_atfifo_item_put
|
||||
* functions pair.
|
||||
*/
|
||||
ret_code_t nrf_atfifo_alloc_put(nrf_atfifo_t * const p_fifo, void const * const p_var, size_t size, bool * const p_visible);
|
||||
|
||||
/**
|
||||
* @brief Function for opening the FIFO for writing.
|
||||
*
|
||||
* Function called to start the FIFO write operation and access the given FIFO buffer directly.
|
||||
*
|
||||
* @param[in,out] p_fifo FIFO object.
|
||||
* @param[out] p_context Operation context, required by @ref nrf_atfifo_item_put.
|
||||
*
|
||||
* @return Pointer to the space where variable data can be stored.
|
||||
* NULL if there is no space in the buffer.
|
||||
*/
|
||||
void * nrf_atfifo_item_alloc(nrf_atfifo_t * const p_fifo, nrf_atfifo_item_put_t * p_context);
|
||||
|
||||
/**
|
||||
* @brief Function for closing the writing operation.
|
||||
*
|
||||
* Puts a previously allocated context into FIFO.
|
||||
* This function must be called to commit an opened write operation.
|
||||
* It sets all the buffers and marks the data, so that it is visible to read.
|
||||
*
|
||||
* @param[in,out] p_fifo FIFO object.
|
||||
* @param[in] p_context Operation context, filled by the @ref nrf_atfifo_item_alloc function.
|
||||
*
|
||||
* @retval true Data is currently ready and will be visible to read.
|
||||
* @retval false The internal commit was marked, but the writing operation interrupted another writing operation.
|
||||
* The data will be available to read when the interrupted operation is committed.
|
||||
*/
|
||||
bool nrf_atfifo_item_put(nrf_atfifo_t * const p_fifo, nrf_atfifo_item_put_t * p_context);
|
||||
|
||||
/**
|
||||
* @brief Function for getting a single value from the FIFO.
|
||||
*
|
||||
* This function gets the value from the top of the FIFO.
|
||||
* The value is removed from the FIFO memory.
|
||||
*
|
||||
* @param[in,out] p_fifo FIFO object.
|
||||
* @param[out] p_var Pointer to the variable to store the data.
|
||||
* @param[in] size Size of the data to be loaded.
|
||||
* @param[out] p_released See the values returned by @ref nrf_atfifo_item_free.
|
||||
*
|
||||
* @retval NRF_SUCCESS Element was successfully copied from the FIFO memory.
|
||||
* @retval NRF_ERROR_NOT_FOUND No data in the FIFO.
|
||||
*/
|
||||
ret_code_t nrf_atfifo_get_free(nrf_atfifo_t * const p_fifo, void * const p_var, size_t size, bool * p_released);
|
||||
|
||||
/**
|
||||
* @brief Function for opening the FIFO for reading.
|
||||
*
|
||||
* Function called to start the FIFO read operation and access the given FIFO buffer directly.
|
||||
*
|
||||
* @param[in,out] p_fifo FIFO object.
|
||||
* @param[out] p_context The operation context, required by @ref nrf_atfifo_item_free
|
||||
*
|
||||
* @return Pointer to data buffer or NULL if there is no data in the FIFO.
|
||||
*/
|
||||
void * nrf_atfifo_item_get(nrf_atfifo_t * const p_fifo, nrf_atfifo_item_get_t * p_context);
|
||||
|
||||
/**
|
||||
* @brief Function for closing the reading operation.
|
||||
*
|
||||
* Function used to finish the reading operation.
|
||||
* If this reading operation does not interrupt another reading operation, the head write buffer is moved.
|
||||
* If this reading operation is placed in the middle of another reading, only the new read pointer is written.
|
||||
*
|
||||
* @param[in,out] p_fifo FIFO object.
|
||||
* @param[in] p_context Context of the reading operation to be closed.
|
||||
*
|
||||
* @retval true This operation is not generated in the middle of another read operation and the write head will be updated to the read head (space is released).
|
||||
* @retval false This operation was performed in the middle of another read operation and the write buffer head was not moved (no space is released).
|
||||
*/
|
||||
bool nrf_atfifo_item_free(nrf_atfifo_t * const p_fifo, nrf_atfifo_item_get_t * p_context);
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NRF_ATFIFO_H__ */
|
||||
/**
|
||||
* Copyright (c) 2011 - 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_ATFIFO_H__
|
||||
#define NRF_ATFIFO_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "sdk_config.h"
|
||||
#include "nordic_common.h"
|
||||
#include "nrf_assert.h"
|
||||
#include "sdk_errors.h"
|
||||
#include "nrf_log_instance.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_atfifo Atomic FIFO
|
||||
* @ingroup app_common
|
||||
*
|
||||
* @brief @tagAPI52 FIFO implementation that allows for making atomic transactions without
|
||||
* locking interrupts.
|
||||
*
|
||||
* @details There are two types of functions to prepare the FIFO writing:
|
||||
* - Single function for simple access:
|
||||
* @code
|
||||
* if (NRF_SUCCESS != nrf_atfifo_simple_put(my_fifo, &data, NULL))
|
||||
* {
|
||||
* // Error handling
|
||||
* }
|
||||
* @endcode
|
||||
* - Function pair to limit data copying:
|
||||
* @code
|
||||
* struct point3d
|
||||
* {
|
||||
* int x, y, z;
|
||||
* }point3d_t;
|
||||
* nrf_atfifo_context_t context;
|
||||
* point3d_t * point;
|
||||
*
|
||||
* if (NULL != (point = nrf_atfifo_item_alloc(my_fifo, &context)))
|
||||
* {
|
||||
* point->x = a;
|
||||
* point->y = b;
|
||||
* point->z = c;
|
||||
* if (nrf_atfifo_item_put(my_fifo, &context))
|
||||
* {
|
||||
* // Send information to the rest of the system
|
||||
* // that there is new data in the FIFO available for reading.
|
||||
* }
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // Error handling
|
||||
* }
|
||||
*
|
||||
* @endcode
|
||||
* @note
|
||||
* This atomic FIFO implementation requires that the operation that is
|
||||
* opened last is finished (committed/flushed) first.
|
||||
* This is typical for operations performed from the interrupt runtime
|
||||
* when the other operation is performed from the main thread.
|
||||
*
|
||||
* This implementation does not support typical multithreading operating system
|
||||
* access where operations can be started and finished in totally unrelated order.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Read and write position structure.
|
||||
*
|
||||
* A structure that holds the read and write position used by the FIFO head and tail.
|
||||
*/
|
||||
typedef struct nrf_atfifo_postag_pos_s
|
||||
{
|
||||
uint16_t wr; //!< First free space to write the data
|
||||
uint16_t rd; //!< A place after the last data to read
|
||||
}nrf_atfifo_postag_pos_t;
|
||||
|
||||
/**
|
||||
* @brief End data index tag.
|
||||
*
|
||||
* A tag used to mark the end of data.
|
||||
* To properly realize atomic data committing, the whole variable has to be
|
||||
* accessed atomically.
|
||||
*/
|
||||
typedef union nrf_atfifo_postag_u
|
||||
{
|
||||
uint32_t tag; //!< Whole tag, used for atomic, 32-bit access
|
||||
nrf_atfifo_postag_pos_t pos; //!< Structure that holds reading and writing position separately
|
||||
}nrf_atfifo_postag_t;
|
||||
|
||||
/**
|
||||
* @brief The FIFO instance.
|
||||
*
|
||||
* The instance of atomic FIFO.
|
||||
* Used with all FIFO functions.
|
||||
*/
|
||||
typedef struct nrf_atfifo_s
|
||||
{
|
||||
void * p_buf; //!< Pointer to the data buffer
|
||||
nrf_atfifo_postag_t tail; //!< Read and write tail position tag
|
||||
nrf_atfifo_postag_t head; //!< Read and write head position tag
|
||||
uint16_t buf_size; //!< FIFO size in number of bytes (has to be divisible by @c item_size)
|
||||
uint16_t item_size; //!< Size of a single FIFO item
|
||||
NRF_LOG_INSTANCE_PTR_DECLARE(p_log) //!< Pointer to instance of the logger object (Conditionally compiled).
|
||||
}nrf_atfifo_t;
|
||||
|
||||
/**
|
||||
* @brief FIFO write operation item context.
|
||||
*
|
||||
* Context structure used to mark an allocated space in FIFO that is ready for put.
|
||||
* All the data required to properly put allocated and written data.
|
||||
*/
|
||||
typedef struct nrf_atfifo_item_put_s
|
||||
{
|
||||
nrf_atfifo_postag_t last_tail; //!< Tail tag value that was here when opening the FIFO to write
|
||||
}nrf_atfifo_item_put_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief FIFO read operation item context.
|
||||
*
|
||||
* Context structure used to mark an opened get operation to properly free an item after reading.
|
||||
*/
|
||||
typedef struct nrf_atfifo_rcontext_s
|
||||
{
|
||||
nrf_atfifo_postag_t last_head; //!< Head tag value that was here when opening the FIFO to read
|
||||
}nrf_atfifo_item_get_t;
|
||||
|
||||
|
||||
/** @brief Name of the module used for logger messaging.
|
||||
*/
|
||||
#define NRF_ATFIFO_LOG_NAME atfifo
|
||||
|
||||
/**
|
||||
* @defgroup nrf_atfifo_instmacros FIFO instance macros
|
||||
*
|
||||
* A group of macros helpful for FIFO instance creation and initialization.
|
||||
* They may be used to create and initialize instances for most use cases.
|
||||
*
|
||||
* FIFO may also be created and initialized directly using
|
||||
* @ref nrf_atfifo_init function.
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Macro for generating the name for a data buffer.
|
||||
*
|
||||
* The name of the data buffer that would be created by
|
||||
* @ref NRF_ATFIFO_DEF macro.
|
||||
*
|
||||
* @param[in] fifo_id Identifier of the FIFO object.
|
||||
*
|
||||
* @return Name of the buffer variable.
|
||||
*
|
||||
* @note This is auxiliary internal macro and in normal usage
|
||||
* it should not be called.
|
||||
*/
|
||||
#define NRF_ATFIFO_BUF_NAME(fifo_id) CONCAT_2(fifo_id, _data)
|
||||
|
||||
/**
|
||||
* @brief Macro for generating the name for a FIFO instance.
|
||||
*
|
||||
* The name of the instance variable that will be created by the
|
||||
* @ref NRF_ATFIFO_DEF macro.
|
||||
*
|
||||
* @param[in] fifo_id Identifier of the FIFO object.
|
||||
*
|
||||
* @return Name of the instance variable.
|
||||
*
|
||||
* @note This is auxiliary internal macro and in normal usage
|
||||
* it should not be called.
|
||||
*/
|
||||
#define NRF_ATFIFO_INST_NAME(fifo_id) CONCAT_2(fifo_id, _inst)
|
||||
|
||||
/**
|
||||
* @brief Macro for creating an instance.
|
||||
*
|
||||
* Creates the FIFO object variable itself.
|
||||
*
|
||||
* Usage example:
|
||||
* @code
|
||||
* NRF_ATFIFO_DEF(my_fifo, uint16_t, 12);
|
||||
* NRF_ATFIFO_INIT(my_fifo);
|
||||
*
|
||||
* uint16_t some_val = 45;
|
||||
* nrf_atfifo_item_put(my_fifo, &some_val, sizeof(some_val), NULL);
|
||||
* nrf_atfifo_item_get(my_fifo, &some_val, sizeof(some_val), NULL);
|
||||
* @endcode
|
||||
*
|
||||
* @param[in] fifo_id Identifier of a FIFO object.
|
||||
* This identifier will be a pointer to the instance.
|
||||
* It makes it possible to use this directly for the functions
|
||||
* that operate on the FIFO.
|
||||
* Because it is a static const object, it should be optimized by the compiler.
|
||||
* @param[in] storage_type Type of data that will be stored in the FIFO.
|
||||
* @param[in] item_cnt Capacity of the created FIFO in maximum number of items that may be stored.
|
||||
* The phisical size of the buffer will be 1 element bigger.
|
||||
*/
|
||||
#define NRF_ATFIFO_DEF(fifo_id, storage_type, item_cnt) \
|
||||
static storage_type NRF_ATFIFO_BUF_NAME(fifo_id)[(item_cnt)+1]; \
|
||||
NRF_LOG_INSTANCE_REGISTER(NRF_ATFIFO_LOG_NAME, fifo_id, \
|
||||
NRF_ATFIFO_CONFIG_INFO_COLOR, \
|
||||
NRF_ATFIFO_CONFIG_DEBUG_COLOR, \
|
||||
NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL, \
|
||||
NRF_ATFIFO_CONFIG_LOG_ENABLED ? \
|
||||
NRF_ATFIFO_CONFIG_LOG_LEVEL : NRF_LOG_SEVERITY_NONE); \
|
||||
static nrf_atfifo_t NRF_ATFIFO_INST_NAME(fifo_id) = { \
|
||||
.p_buf = NULL, \
|
||||
NRF_LOG_INSTANCE_PTR_INIT(p_log, NRF_ATFIFO_LOG_NAME, fifo_id) \
|
||||
}; \
|
||||
static nrf_atfifo_t * const fifo_id = &NRF_ATFIFO_INST_NAME(fifo_id)
|
||||
|
||||
/**
|
||||
* @brief Macro for initializing the FIFO that was previously declared by the macro.
|
||||
*
|
||||
* Use this macro to simplify FIFO initialization.
|
||||
*
|
||||
* @note
|
||||
* This macro can be only used on a FIFO object defined by @ref NRF_ATFIFO_DEF macro.
|
||||
*
|
||||
* @param[in] fifo_id Identifier of the FIFO object.
|
||||
*
|
||||
* @return Value from the @ref nrf_atfifo_init function.
|
||||
*/
|
||||
#define NRF_ATFIFO_INIT(fifo_id) \
|
||||
nrf_atfifo_init( \
|
||||
fifo_id, \
|
||||
NRF_ATFIFO_BUF_NAME(fifo_id), \
|
||||
sizeof(NRF_ATFIFO_BUF_NAME(fifo_id)), \
|
||||
sizeof(NRF_ATFIFO_BUF_NAME(fifo_id)[0]) \
|
||||
)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the FIFO.
|
||||
*
|
||||
* Preparing the FIFO instance to work.
|
||||
*
|
||||
* @param[out] p_fifo FIFO object to initialize.
|
||||
* @param[in,out] p_buf FIFO buffer for storing data.
|
||||
* @param[in] buf_size Total buffer size (has to be divisible by @c item_size).
|
||||
* @param[in] item_size Size of a single item held inside the FIFO.
|
||||
*
|
||||
* @retval NRF_SUCCESS If initialization was successful.
|
||||
* @retval NRF_ERROR_NULL If a NULL pointer is provided as the buffer.
|
||||
* @retval NRF_ERROR_INVALID_LENGTH If size of the buffer provided is not divisible by @c item_size.
|
||||
*
|
||||
* @note
|
||||
* Buffer size must be able to hold one element more than the designed FIFO capacity.
|
||||
* This one, empty element is used for overflow checking.
|
||||
*/
|
||||
ret_code_t nrf_atfifo_init(nrf_atfifo_t * const p_fifo, void * p_buf, uint16_t buf_size, uint16_t item_size);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing the FIFO.
|
||||
*
|
||||
* Function for clearing the FIFO.
|
||||
*
|
||||
* If this function is called during an opened and uncommitted write operation,
|
||||
* the FIFO is cleared up to the currently ongoing commit.
|
||||
* There is no possibility to cancel an ongoing commit.
|
||||
*
|
||||
* If this function is called during an opened and unflushed read operation,
|
||||
* the read position in the head is set, but copying it into the write head position
|
||||
* is left to read closing operation.
|
||||
*
|
||||
* This way, there is no more data to read, but the memory is released
|
||||
* in the moment when it is safe.
|
||||
*
|
||||
* @param[in,out] p_fifo FIFO object.
|
||||
*
|
||||
* @retval NRF_SUCCESS FIFO totally cleared.
|
||||
* @retval NRF_ERROR_BUSY Function called in the middle of writing or reading operation.
|
||||
* If it is called in the middle of writing operation,
|
||||
* FIFO was cleared up to the already started and uncommitted write.
|
||||
* If it is called in the middle of reading operation,
|
||||
* write head was only moved. It will be copied into read tail when the reading operation
|
||||
* is flushed.
|
||||
*/
|
||||
ret_code_t nrf_atfifo_clear(nrf_atfifo_t * const p_fifo);
|
||||
|
||||
/**
|
||||
* @brief Function for atomically putting data into the FIFO.
|
||||
*
|
||||
* It uses memcpy function inside and in most situations, it is more suitable to
|
||||
* use @ref nrf_atfifo_item_alloc, write the data, and @ref nrf_atfifo_item_put to store a new value
|
||||
* in a FIFO.
|
||||
*
|
||||
* @param[in,out] p_fifo FIFO object.
|
||||
* @param[in] p_var Variable to copy.
|
||||
* @param[in] size Size of the variable to copy.
|
||||
* Can be smaller or equal to the FIFO item size.
|
||||
* @param[out] p_visible See value returned by @ref nrf_atfifo_item_put.
|
||||
* It may be NULL if the caller does not require the current operation status.
|
||||
*
|
||||
* @retval NRF_SUCCESS If an element has been successfully added to the FIFO.
|
||||
* @retval NRF_ERROR_NO_MEM If the FIFO is full.
|
||||
*
|
||||
* @note
|
||||
* To avoid data copying, you can use the @ref nrf_atfifo_item_alloc and @ref nrf_atfifo_item_put
|
||||
* functions pair.
|
||||
*/
|
||||
ret_code_t nrf_atfifo_alloc_put(nrf_atfifo_t * const p_fifo, void const * const p_var, size_t size, bool * const p_visible);
|
||||
|
||||
/**
|
||||
* @brief Function for opening the FIFO for writing.
|
||||
*
|
||||
* Function called to start the FIFO write operation and access the given FIFO buffer directly.
|
||||
*
|
||||
* @param[in,out] p_fifo FIFO object.
|
||||
* @param[out] p_context Operation context, required by @ref nrf_atfifo_item_put.
|
||||
*
|
||||
* @return Pointer to the space where variable data can be stored.
|
||||
* NULL if there is no space in the buffer.
|
||||
*/
|
||||
void * nrf_atfifo_item_alloc(nrf_atfifo_t * const p_fifo, nrf_atfifo_item_put_t * p_context);
|
||||
|
||||
/**
|
||||
* @brief Function for closing the writing operation.
|
||||
*
|
||||
* Puts a previously allocated context into FIFO.
|
||||
* This function must be called to commit an opened write operation.
|
||||
* It sets all the buffers and marks the data, so that it is visible to read.
|
||||
*
|
||||
* @param[in,out] p_fifo FIFO object.
|
||||
* @param[in] p_context Operation context, filled by the @ref nrf_atfifo_item_alloc function.
|
||||
*
|
||||
* @retval true Data is currently ready and will be visible to read.
|
||||
* @retval false The internal commit was marked, but the writing operation interrupted another writing operation.
|
||||
* The data will be available to read when the interrupted operation is committed.
|
||||
*/
|
||||
bool nrf_atfifo_item_put(nrf_atfifo_t * const p_fifo, nrf_atfifo_item_put_t * p_context);
|
||||
|
||||
/**
|
||||
* @brief Function for getting a single value from the FIFO.
|
||||
*
|
||||
* This function gets the value from the top of the FIFO.
|
||||
* The value is removed from the FIFO memory.
|
||||
*
|
||||
* @param[in,out] p_fifo FIFO object.
|
||||
* @param[out] p_var Pointer to the variable to store the data.
|
||||
* @param[in] size Size of the data to be loaded.
|
||||
* @param[out] p_released See the values returned by @ref nrf_atfifo_item_free.
|
||||
*
|
||||
* @retval NRF_SUCCESS Element was successfully copied from the FIFO memory.
|
||||
* @retval NRF_ERROR_NOT_FOUND No data in the FIFO.
|
||||
*/
|
||||
ret_code_t nrf_atfifo_get_free(nrf_atfifo_t * const p_fifo, void * const p_var, size_t size, bool * p_released);
|
||||
|
||||
/**
|
||||
* @brief Function for opening the FIFO for reading.
|
||||
*
|
||||
* Function called to start the FIFO read operation and access the given FIFO buffer directly.
|
||||
*
|
||||
* @param[in,out] p_fifo FIFO object.
|
||||
* @param[out] p_context The operation context, required by @ref nrf_atfifo_item_free
|
||||
*
|
||||
* @return Pointer to data buffer or NULL if there is no data in the FIFO.
|
||||
*/
|
||||
void * nrf_atfifo_item_get(nrf_atfifo_t * const p_fifo, nrf_atfifo_item_get_t * p_context);
|
||||
|
||||
/**
|
||||
* @brief Function for closing the reading operation.
|
||||
*
|
||||
* Function used to finish the reading operation.
|
||||
* If this reading operation does not interrupt another reading operation, the head write buffer is moved.
|
||||
* If this reading operation is placed in the middle of another reading, only the new read pointer is written.
|
||||
*
|
||||
* @param[in,out] p_fifo FIFO object.
|
||||
* @param[in] p_context Context of the reading operation to be closed.
|
||||
*
|
||||
* @retval true This operation is not generated in the middle of another read operation and the write head will be updated to the read head (space is released).
|
||||
* @retval false This operation was performed in the middle of another read operation and the write buffer head was not moved (no space is released).
|
||||
*/
|
||||
bool nrf_atfifo_item_free(nrf_atfifo_t * const p_fifo, nrf_atfifo_item_get_t * p_context);
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NRF_ATFIFO_H__ */
|
||||
|
||||
+577
-577
File diff suppressed because it is too large
Load Diff
+449
-447
@@ -1,447 +1,449 @@
|
||||
/**
|
||||
* Copyright (c) 2018 - 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.
|
||||
*
|
||||
*/
|
||||
#include "nrf_atomic.h"
|
||||
|
||||
#ifndef NRF_ATOMIC_USE_BUILD_IN
|
||||
#if (defined(__GNUC__) && defined(WIN32))
|
||||
#define NRF_ATOMIC_USE_BUILD_IN 1
|
||||
#else
|
||||
#define NRF_ATOMIC_USE_BUILD_IN 0
|
||||
#endif
|
||||
#endif // NRF_ATOMIC_USE_BUILD_IN
|
||||
|
||||
#if ((__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U))
|
||||
#define STREX_LDREX_PRESENT
|
||||
#else
|
||||
#include "app_util_platform.h"
|
||||
#endif
|
||||
|
||||
|
||||
#if (NRF_ATOMIC_USE_BUILD_IN == 0) && defined(STREX_LDREX_PRESENT)
|
||||
#include "nrf_atomic_internal.h"
|
||||
#endif
|
||||
|
||||
uint32_t nrf_atomic_u32_fetch_store(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_exchange_n(p_data, value, __ATOMIC_SEQ_CST);
|
||||
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
NRF_ATOMIC_OP(mov, old_val, new_val, p_data, value);
|
||||
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return old_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
uint32_t old_val = *p_data;
|
||||
*p_data = value;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return old_val;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_store(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
__atomic_store_n(p_data, value, __ATOMIC_SEQ_CST);
|
||||
return value;
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(mov, old_val, new_val, p_data, value);
|
||||
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return new_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
*p_data = value;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return value;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_fetch_or(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_fetch_or(p_data, value, __ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(orr, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return old_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
uint32_t old_val = *p_data;
|
||||
*p_data |= value;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return old_val;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_or(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_or_fetch(p_data, value, __ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(orr, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return new_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
*p_data |= value;
|
||||
uint32_t new_value = *p_data;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return new_value;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_fetch_and(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_fetch_and(p_data, value, __ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(and, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return old_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
uint32_t old_val = *p_data;
|
||||
*p_data &= value;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return old_val;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_and(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_and_fetch(p_data, value, __ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(and, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return new_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
*p_data &= value;
|
||||
uint32_t new_value = *p_data;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return new_value;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_fetch_xor(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_fetch_xor(p_data, value, __ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(eor, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return old_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
uint32_t old_val = *p_data;
|
||||
*p_data ^= value;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return old_val;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_xor(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_xor_fetch(p_data, value, __ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(eor, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return new_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
*p_data ^= value;
|
||||
uint32_t new_value = *p_data;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return new_value;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_fetch_add(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_fetch_add(p_data, value, __ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(add, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return old_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
uint32_t old_val = *p_data;
|
||||
*p_data += value;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return old_val;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_add(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_add_fetch(p_data, value, __ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(add, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return new_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
*p_data += value;
|
||||
uint32_t new_value = *p_data;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return new_value;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_fetch_sub(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_fetch_sub(p_data, value, __ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(sub, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return old_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
uint32_t old_val = *p_data;
|
||||
*p_data -= value;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return old_val;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_sub(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_sub_fetch(p_data, value, __ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(sub, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return new_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
*p_data -= value;
|
||||
uint32_t new_value = *p_data;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return new_value;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
bool nrf_atomic_u32_cmp_exch(nrf_atomic_u32_t * p_data,
|
||||
uint32_t * p_expected,
|
||||
uint32_t desired)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_compare_exchange(p_data,
|
||||
p_expected,
|
||||
&desired,
|
||||
1,
|
||||
__ATOMIC_SEQ_CST,
|
||||
__ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
return nrf_atomic_internal_cmp_exch(p_data, p_expected, desired);
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
if(*p_data == *p_expected)
|
||||
{
|
||||
*p_data = desired;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
*p_expected = *p_data;
|
||||
return false;
|
||||
}
|
||||
CRITICAL_REGION_EXIT();
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_fetch_sub_hs(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
uint32_t expected = *p_data;
|
||||
uint32_t new_val;
|
||||
bool success;
|
||||
|
||||
do
|
||||
{
|
||||
if (expected >= value)
|
||||
{
|
||||
new_val = expected - value;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_val = expected;
|
||||
}
|
||||
success = __atomic_compare_exchange(p_data,
|
||||
&expected,
|
||||
&new_val,
|
||||
1,
|
||||
__ATOMIC_SEQ_CST,
|
||||
__ATOMIC_SEQ_CST);
|
||||
} while(!success);
|
||||
return expected;
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(sub_hs, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return old_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
uint32_t old_val = *p_data;
|
||||
*p_data -= value;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return old_val;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_sub_hs(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
uint32_t expected = *p_data;
|
||||
uint32_t new_val;
|
||||
bool success;
|
||||
|
||||
do
|
||||
{
|
||||
if (expected >= value)
|
||||
{
|
||||
new_val = expected - value;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_val = expected;
|
||||
}
|
||||
success = __atomic_compare_exchange(p_data,
|
||||
&expected,
|
||||
&new_val,
|
||||
1,
|
||||
__ATOMIC_SEQ_CST,
|
||||
__ATOMIC_SEQ_CST);
|
||||
} while(!success);
|
||||
return new_val;
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(sub_hs, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return new_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
*p_data -= value;
|
||||
uint32_t new_value = *p_data;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return new_value;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_flag_set_fetch(nrf_atomic_flag_t * p_data)
|
||||
{
|
||||
return nrf_atomic_u32_fetch_or(p_data, 1);
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_flag_set(nrf_atomic_flag_t * p_data)
|
||||
{
|
||||
return nrf_atomic_u32_or(p_data, 1);
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_flag_clear_fetch(nrf_atomic_flag_t * p_data)
|
||||
{
|
||||
return nrf_atomic_u32_fetch_and(p_data, 0);
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_flag_clear(nrf_atomic_flag_t * p_data)
|
||||
{
|
||||
return nrf_atomic_u32_and(p_data, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
*/
|
||||
#include "nrf_atomic.h"
|
||||
|
||||
#ifndef NRF_ATOMIC_USE_BUILD_IN
|
||||
#if (defined(__GNUC__) && defined(WIN32))
|
||||
#define NRF_ATOMIC_USE_BUILD_IN 1
|
||||
#else
|
||||
#define NRF_ATOMIC_USE_BUILD_IN 0
|
||||
#endif
|
||||
#endif // NRF_ATOMIC_USE_BUILD_IN
|
||||
|
||||
#if ((__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U))
|
||||
#define STREX_LDREX_PRESENT
|
||||
#else
|
||||
#include "app_util_platform.h"
|
||||
#endif
|
||||
|
||||
|
||||
#if (NRF_ATOMIC_USE_BUILD_IN == 0) && defined(STREX_LDREX_PRESENT)
|
||||
#include "nrf_atomic_internal.h"
|
||||
#endif
|
||||
|
||||
uint32_t nrf_atomic_u32_fetch_store(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_exchange_n(p_data, value, __ATOMIC_SEQ_CST);
|
||||
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
NRF_ATOMIC_OP(mov, old_val, new_val, p_data, value);
|
||||
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return old_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
uint32_t old_val = *p_data;
|
||||
*p_data = value;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return old_val;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_store(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
__atomic_store_n(p_data, value, __ATOMIC_SEQ_CST);
|
||||
return value;
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(mov, old_val, new_val, p_data, value);
|
||||
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return new_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
*p_data = value;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return value;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_fetch_or(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_fetch_or(p_data, value, __ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(orr, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return old_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
uint32_t old_val = *p_data;
|
||||
*p_data |= value;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return old_val;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_or(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_or_fetch(p_data, value, __ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(orr, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return new_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
*p_data |= value;
|
||||
uint32_t new_value = *p_data;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return new_value;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_fetch_and(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_fetch_and(p_data, value, __ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(and, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return old_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
uint32_t old_val = *p_data;
|
||||
*p_data &= value;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return old_val;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_and(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_and_fetch(p_data, value, __ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(and, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return new_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
*p_data &= value;
|
||||
uint32_t new_value = *p_data;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return new_value;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_fetch_xor(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_fetch_xor(p_data, value, __ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(eor, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return old_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
uint32_t old_val = *p_data;
|
||||
*p_data ^= value;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return old_val;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_xor(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_xor_fetch(p_data, value, __ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(eor, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return new_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
*p_data ^= value;
|
||||
uint32_t new_value = *p_data;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return new_value;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_fetch_add(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_fetch_add(p_data, value, __ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(add, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return old_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
uint32_t old_val = *p_data;
|
||||
*p_data += value;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return old_val;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_add(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_add_fetch(p_data, value, __ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(add, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return new_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
*p_data += value;
|
||||
uint32_t new_value = *p_data;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return new_value;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_fetch_sub(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_fetch_sub(p_data, value, __ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(sub, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return old_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
uint32_t old_val = *p_data;
|
||||
*p_data -= value;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return old_val;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_sub(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_sub_fetch(p_data, value, __ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(sub, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return new_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
*p_data -= value;
|
||||
uint32_t new_value = *p_data;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return new_value;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
bool nrf_atomic_u32_cmp_exch(nrf_atomic_u32_t * p_data,
|
||||
uint32_t * p_expected,
|
||||
uint32_t desired)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
return __atomic_compare_exchange(p_data,
|
||||
p_expected,
|
||||
&desired,
|
||||
1,
|
||||
__ATOMIC_SEQ_CST,
|
||||
__ATOMIC_SEQ_CST);
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
return nrf_atomic_internal_cmp_exch(p_data, p_expected, desired);
|
||||
#else
|
||||
bool ret;
|
||||
CRITICAL_REGION_ENTER();
|
||||
if (*p_data == *p_expected)
|
||||
{
|
||||
*p_data = desired;
|
||||
ret = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
*p_expected = *p_data;
|
||||
ret = false;
|
||||
}
|
||||
CRITICAL_REGION_EXIT();
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_fetch_sub_hs(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
uint32_t expected = *p_data;
|
||||
uint32_t new_val;
|
||||
bool success;
|
||||
|
||||
do
|
||||
{
|
||||
if (expected >= value)
|
||||
{
|
||||
new_val = expected - value;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_val = expected;
|
||||
}
|
||||
success = __atomic_compare_exchange(p_data,
|
||||
&expected,
|
||||
&new_val,
|
||||
1,
|
||||
__ATOMIC_SEQ_CST,
|
||||
__ATOMIC_SEQ_CST);
|
||||
} while(!success);
|
||||
return expected;
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(sub_hs, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return old_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
uint32_t old_val = *p_data;
|
||||
*p_data -= value;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return old_val;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_u32_sub_hs(nrf_atomic_u32_t * p_data, uint32_t value)
|
||||
{
|
||||
#if NRF_ATOMIC_USE_BUILD_IN
|
||||
uint32_t expected = *p_data;
|
||||
uint32_t new_val;
|
||||
bool success;
|
||||
|
||||
do
|
||||
{
|
||||
if (expected >= value)
|
||||
{
|
||||
new_val = expected - value;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_val = expected;
|
||||
}
|
||||
success = __atomic_compare_exchange(p_data,
|
||||
&expected,
|
||||
&new_val,
|
||||
1,
|
||||
__ATOMIC_SEQ_CST,
|
||||
__ATOMIC_SEQ_CST);
|
||||
} while(!success);
|
||||
return new_val;
|
||||
#elif defined(STREX_LDREX_PRESENT)
|
||||
uint32_t old_val;
|
||||
uint32_t new_val;
|
||||
|
||||
NRF_ATOMIC_OP(sub_hs, old_val, new_val, p_data, value);
|
||||
UNUSED_PARAMETER(old_val);
|
||||
UNUSED_PARAMETER(new_val);
|
||||
return new_val;
|
||||
#else
|
||||
CRITICAL_REGION_ENTER();
|
||||
*p_data -= value;
|
||||
uint32_t new_value = *p_data;
|
||||
CRITICAL_REGION_EXIT();
|
||||
return new_value;
|
||||
#endif //NRF_ATOMIC_USE_BUILD_IN
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_flag_set_fetch(nrf_atomic_flag_t * p_data)
|
||||
{
|
||||
return nrf_atomic_u32_fetch_or(p_data, 1);
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_flag_set(nrf_atomic_flag_t * p_data)
|
||||
{
|
||||
return nrf_atomic_u32_or(p_data, 1);
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_flag_clear_fetch(nrf_atomic_flag_t * p_data)
|
||||
{
|
||||
return nrf_atomic_u32_fetch_and(p_data, 0);
|
||||
}
|
||||
|
||||
uint32_t nrf_atomic_flag_clear(nrf_atomic_flag_t * p_data)
|
||||
{
|
||||
return nrf_atomic_u32_and(p_data, 0);
|
||||
}
|
||||
|
||||
|
||||
+274
-274
@@ -1,274 +1,274 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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.
|
||||
*
|
||||
*/
|
||||
/**@file
|
||||
*
|
||||
* @defgroup nrf_atomic Atomic operations API
|
||||
* @ingroup app_common
|
||||
* @{
|
||||
*
|
||||
* @brief @tagAPI52 This module implements C11 stdatomic.h simplified API.
|
||||
At this point only Cortex-M3/M4 cores are supported (LDREX/STREX instructions).
|
||||
* Atomic types are limited to @ref nrf_atomic_u32_t and @ref nrf_atomic_flag_t.
|
||||
*/
|
||||
|
||||
#ifndef NRF_ATOMIC_H__
|
||||
#define NRF_ATOMIC_H__
|
||||
|
||||
#include "sdk_common.h"
|
||||
|
||||
/**
|
||||
* @brief Atomic 32 bit unsigned type
|
||||
* */
|
||||
typedef volatile uint32_t nrf_atomic_u32_t;
|
||||
|
||||
/**
|
||||
* @brief Atomic 1 bit flag type (technically 32 bit)
|
||||
* */
|
||||
typedef volatile uint32_t nrf_atomic_flag_t;
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Stores value to an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value to store
|
||||
*
|
||||
* @return Old value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_fetch_store(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Stores value to an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value to store
|
||||
*
|
||||
* @return New value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_store(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Logical OR operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand OR operation
|
||||
*
|
||||
* @return Old value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_fetch_or(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Logical OR operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand OR operation
|
||||
*
|
||||
* @return New value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_or(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Logical AND operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand AND operation
|
||||
*
|
||||
* @return Old value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_fetch_and(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Logical AND operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand AND operation
|
||||
*
|
||||
* @return New value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_and(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Logical XOR operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand XOR operation
|
||||
*
|
||||
* @return Old value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_fetch_xor(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Logical XOR operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand XOR operation
|
||||
*
|
||||
* @return New value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_xor(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Arithmetic ADD operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand ADD operation
|
||||
*
|
||||
* @return Old value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_fetch_add(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Arithmetic ADD operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand ADD operation
|
||||
*
|
||||
* @return New value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_add(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Arithmetic SUB operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand SUB operation
|
||||
*
|
||||
* @return Old value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_fetch_sub(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Arithmetic SUB operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand SUB operation
|
||||
*
|
||||
* @return New value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_sub(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief If value at pointer is equal to expected value, changes value at pointer to desired
|
||||
*
|
||||
* Atomically compares the value pointed to by p_data with the value pointed to by p_expected,
|
||||
* and if those are equal, replaces the former with desired. Otherwise, loads the actual value
|
||||
* pointed to by p_data into *p_expected.
|
||||
*
|
||||
* @param p_data Atomic memory pointer to test and modify.
|
||||
* @param p_expected Pointer to test value.
|
||||
* @param desired Value to be stored to atomic memory.
|
||||
*
|
||||
* @retval true *p_data was equal to *p_expected
|
||||
* @retval false *p_data was not equal to *p_expected
|
||||
*/
|
||||
bool nrf_atomic_u32_cmp_exch(nrf_atomic_u32_t * p_data,
|
||||
uint32_t * p_expected,
|
||||
uint32_t desired);
|
||||
|
||||
/**
|
||||
* @brief Arithmetic SUB operation on an atomic object performed if object >= value.
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand SUB operation
|
||||
*
|
||||
* @return Old value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_fetch_sub_hs(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Arithmetic SUB operation on an atomic object performed if object >= value.
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand SUB operation
|
||||
*
|
||||
* @return New value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_sub_hs(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**************************************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief Logic one bit flag set operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic flag memory pointer
|
||||
*
|
||||
* @return Old flag value
|
||||
* */
|
||||
uint32_t nrf_atomic_flag_set_fetch(nrf_atomic_flag_t * p_data);
|
||||
|
||||
/**
|
||||
* @brief Logic one bit flag set operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic flag memory pointer
|
||||
*
|
||||
* @return New flag value
|
||||
* */
|
||||
uint32_t nrf_atomic_flag_set(nrf_atomic_flag_t * p_data);
|
||||
|
||||
/**
|
||||
* @brief Logic one bit flag clear operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic flag memory pointer
|
||||
*
|
||||
* @return Old flag value
|
||||
* */
|
||||
uint32_t nrf_atomic_flag_clear_fetch(nrf_atomic_flag_t * p_data);
|
||||
|
||||
/**
|
||||
* @brief Logic one bit flag clear operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic flag memory pointer
|
||||
*
|
||||
* @return New flag value
|
||||
* */
|
||||
uint32_t nrf_atomic_flag_clear(nrf_atomic_flag_t * p_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NRF_ATOMIC_H__ */
|
||||
|
||||
/** @} */
|
||||
/**
|
||||
* Copyright (c) 2016 - 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.
|
||||
*
|
||||
*/
|
||||
/**@file
|
||||
*
|
||||
* @defgroup nrf_atomic Atomic operations API
|
||||
* @ingroup app_common
|
||||
* @{
|
||||
*
|
||||
* @brief @tagAPI52 This module implements C11 stdatomic.h simplified API.
|
||||
At this point only Cortex-M3/M4 cores are supported (LDREX/STREX instructions).
|
||||
* Atomic types are limited to @ref nrf_atomic_u32_t and @ref nrf_atomic_flag_t.
|
||||
*/
|
||||
|
||||
#ifndef NRF_ATOMIC_H__
|
||||
#define NRF_ATOMIC_H__
|
||||
|
||||
#include "sdk_common.h"
|
||||
|
||||
/**
|
||||
* @brief Atomic 32 bit unsigned type
|
||||
* */
|
||||
typedef volatile uint32_t nrf_atomic_u32_t;
|
||||
|
||||
/**
|
||||
* @brief Atomic 1 bit flag type (technically 32 bit)
|
||||
* */
|
||||
typedef volatile uint32_t nrf_atomic_flag_t;
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Stores value to an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value to store
|
||||
*
|
||||
* @return Old value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_fetch_store(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Stores value to an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value to store
|
||||
*
|
||||
* @return New value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_store(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Logical OR operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand OR operation
|
||||
*
|
||||
* @return Old value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_fetch_or(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Logical OR operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand OR operation
|
||||
*
|
||||
* @return New value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_or(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Logical AND operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand AND operation
|
||||
*
|
||||
* @return Old value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_fetch_and(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Logical AND operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand AND operation
|
||||
*
|
||||
* @return New value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_and(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Logical XOR operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand XOR operation
|
||||
*
|
||||
* @return Old value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_fetch_xor(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Logical XOR operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand XOR operation
|
||||
*
|
||||
* @return New value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_xor(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Arithmetic ADD operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand ADD operation
|
||||
*
|
||||
* @return Old value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_fetch_add(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Arithmetic ADD operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand ADD operation
|
||||
*
|
||||
* @return New value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_add(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Arithmetic SUB operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand SUB operation
|
||||
*
|
||||
* @return Old value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_fetch_sub(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Arithmetic SUB operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand SUB operation
|
||||
*
|
||||
* @return New value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_sub(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief If value at pointer is equal to expected value, changes value at pointer to desired
|
||||
*
|
||||
* Atomically compares the value pointed to by p_data with the value pointed to by p_expected,
|
||||
* and if those are equal, replaces the former with desired. Otherwise, loads the actual value
|
||||
* pointed to by p_data into *p_expected.
|
||||
*
|
||||
* @param p_data Atomic memory pointer to test and modify.
|
||||
* @param p_expected Pointer to test value.
|
||||
* @param desired Value to be stored to atomic memory.
|
||||
*
|
||||
* @retval true *p_data was equal to *p_expected
|
||||
* @retval false *p_data was not equal to *p_expected
|
||||
*/
|
||||
bool nrf_atomic_u32_cmp_exch(nrf_atomic_u32_t * p_data,
|
||||
uint32_t * p_expected,
|
||||
uint32_t desired);
|
||||
|
||||
/**
|
||||
* @brief Arithmetic SUB operation on an atomic object performed if object >= value.
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand SUB operation
|
||||
*
|
||||
* @return Old value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_fetch_sub_hs(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Arithmetic SUB operation on an atomic object performed if object >= value.
|
||||
*
|
||||
* @param[in] p_data Atomic memory pointer
|
||||
* @param[in] value Value of second operand SUB operation
|
||||
*
|
||||
* @return New value stored into atomic object
|
||||
* */
|
||||
uint32_t nrf_atomic_u32_sub_hs(nrf_atomic_u32_t * p_data, uint32_t value);
|
||||
|
||||
/**************************************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief Logic one bit flag set operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic flag memory pointer
|
||||
*
|
||||
* @return Old flag value
|
||||
* */
|
||||
uint32_t nrf_atomic_flag_set_fetch(nrf_atomic_flag_t * p_data);
|
||||
|
||||
/**
|
||||
* @brief Logic one bit flag set operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic flag memory pointer
|
||||
*
|
||||
* @return New flag value
|
||||
* */
|
||||
uint32_t nrf_atomic_flag_set(nrf_atomic_flag_t * p_data);
|
||||
|
||||
/**
|
||||
* @brief Logic one bit flag clear operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic flag memory pointer
|
||||
*
|
||||
* @return Old flag value
|
||||
* */
|
||||
uint32_t nrf_atomic_flag_clear_fetch(nrf_atomic_flag_t * p_data);
|
||||
|
||||
/**
|
||||
* @brief Logic one bit flag clear operation on an atomic object
|
||||
*
|
||||
* @param[in] p_data Atomic flag memory pointer
|
||||
*
|
||||
* @return New flag value
|
||||
* */
|
||||
uint32_t nrf_atomic_flag_clear(nrf_atomic_flag_t * p_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NRF_ATOMIC_H__ */
|
||||
|
||||
/** @} */
|
||||
|
||||
+343
-343
@@ -1,343 +1,343 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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_ATOMIC_INTERNAL_H__
|
||||
#define NRF_ATOMIC_INTERNAL_H__
|
||||
|
||||
#include "sdk_common.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
*
|
||||
* @defgroup nrf_atomic_internal Atomic operations internals
|
||||
* @ingroup nrf_atomic
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
/* Only Cortex M cores > 3 support LDREX/STREX instructions*/
|
||||
#if ((__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U)) == 0
|
||||
#error "Unsupported core version"
|
||||
#endif
|
||||
|
||||
#if defined ( __CC_ARM )
|
||||
static __asm uint32_t nrf_atomic_internal_mov(nrf_atomic_u32_t * p_ptr,
|
||||
uint32_t value,
|
||||
uint32_t * p_new)
|
||||
{
|
||||
/* The base standard provides for passing arguments in core registers (r0-r3) and on the stack.
|
||||
* Registers r4 and r5 have to be saved on stack. Note that only even number of register push are
|
||||
* allowed. This is a requirement of the Procedure Call Standard for the ARM Architecture [AAPCS].
|
||||
* */
|
||||
push {r4, r5}
|
||||
mov r4, r0
|
||||
|
||||
loop_mov
|
||||
ldrex r0, [r4]
|
||||
mov r5, r1
|
||||
strex r3, r5, [r4]
|
||||
cmp r3, #0
|
||||
bne loop_mov
|
||||
|
||||
str r5, [r2]
|
||||
pop {r4, r5}
|
||||
bx lr
|
||||
}
|
||||
|
||||
|
||||
static __asm uint32_t nrf_atomic_internal_orr(nrf_atomic_u32_t * p_ptr,
|
||||
uint32_t value,
|
||||
uint32_t * p_new)
|
||||
{
|
||||
push {r4, r5}
|
||||
mov r4, r0
|
||||
|
||||
loop_orr
|
||||
ldrex r0, [r4]
|
||||
orr r5, r0, r1
|
||||
strex r3, r5, [r4]
|
||||
cmp r3, #0
|
||||
bne loop_orr
|
||||
|
||||
str r5, [r2]
|
||||
pop {r4, r5}
|
||||
bx lr
|
||||
}
|
||||
|
||||
static __asm uint32_t nrf_atomic_internal_and(nrf_atomic_u32_t * p_ptr,
|
||||
uint32_t value,
|
||||
uint32_t * p_new)
|
||||
{
|
||||
push {r4, r5}
|
||||
mov r4, r0
|
||||
|
||||
loop_and
|
||||
ldrex r0, [r4]
|
||||
and r5, r0, r1
|
||||
strex r3, r5, [r4]
|
||||
cmp r3, #0
|
||||
bne loop_and
|
||||
|
||||
str r5, [r2]
|
||||
pop {r4, r5}
|
||||
bx lr
|
||||
}
|
||||
|
||||
static __asm uint32_t nrf_atomic_internal_eor(nrf_atomic_u32_t * p_ptr,
|
||||
uint32_t value,
|
||||
uint32_t * p_new)
|
||||
{
|
||||
push {r4, r5}
|
||||
mov r4, r0
|
||||
|
||||
loop_eor
|
||||
ldrex r0, [r4]
|
||||
eor r5, r0, r1
|
||||
strex r3, r5, [r4]
|
||||
cmp r3, #0
|
||||
bne loop_eor
|
||||
|
||||
str r5, [r2]
|
||||
pop {r4, r5}
|
||||
bx lr
|
||||
}
|
||||
|
||||
static __asm uint32_t nrf_atomic_internal_add(nrf_atomic_u32_t * p_ptr,
|
||||
uint32_t value,
|
||||
uint32_t * p_new)
|
||||
{
|
||||
push {r4, r5}
|
||||
mov r4, r0
|
||||
|
||||
loop_add
|
||||
ldrex r0, [r4]
|
||||
add r5, r0, r1
|
||||
strex r3, r5, [r4]
|
||||
cmp r3, #0
|
||||
bne loop_add
|
||||
|
||||
str r5, [r2]
|
||||
pop {r4, r5}
|
||||
bx lr
|
||||
}
|
||||
|
||||
static __asm uint32_t nrf_atomic_internal_sub(nrf_atomic_u32_t * p_ptr,
|
||||
uint32_t value,
|
||||
uint32_t * p_new)
|
||||
{
|
||||
push {r4, r5}
|
||||
mov r4, r0
|
||||
|
||||
loop_sub
|
||||
ldrex r0, [r4]
|
||||
sub r5, r0, r1
|
||||
strex r3, r5, [r4]
|
||||
cmp r3, #0
|
||||
bne loop_sub
|
||||
|
||||
str r5, [r2]
|
||||
pop {r4, r5}
|
||||
bx lr
|
||||
}
|
||||
|
||||
static __asm bool nrf_atomic_internal_cmp_exch(nrf_atomic_u32_t * p_data,
|
||||
uint32_t * p_expected,
|
||||
uint32_t value)
|
||||
{
|
||||
#define RET_REG r0
|
||||
#define P_EXPC r1
|
||||
#define VALUE r2
|
||||
#define STR_RES r3
|
||||
#define P_DATA r4
|
||||
#define EXPC_VAL r5
|
||||
#define ACT_VAL r6
|
||||
|
||||
push {r4-r6}
|
||||
mov P_DATA, r0
|
||||
mov RET_REG, #0
|
||||
|
||||
loop_cmp_exch
|
||||
ldrex ACT_VAL, [P_DATA]
|
||||
ldr EXPC_VAL, [P_EXPC]
|
||||
cmp ACT_VAL, EXPC_VAL
|
||||
ittee eq
|
||||
strexeq STR_RES, VALUE, [P_DATA]
|
||||
moveq RET_REG, #1
|
||||
strexne STR_RES, ACT_VAL, [P_DATA]
|
||||
strne ACT_VAL, [P_EXPC]
|
||||
cmp STR_RES, #0
|
||||
itt ne
|
||||
movne RET_REG, #0
|
||||
bne loop_cmp_exch
|
||||
|
||||
pop {r4-r6}
|
||||
bx lr
|
||||
|
||||
#undef RET_REG
|
||||
#undef P_EXPC
|
||||
#undef VALUE
|
||||
#undef STR_RES
|
||||
#undef P_DATA
|
||||
#undef EXPC_VAL
|
||||
#undef ACT_VAL
|
||||
}
|
||||
|
||||
static __asm uint32_t nrf_atomic_internal_sub_hs(nrf_atomic_u32_t * p_ptr,
|
||||
uint32_t value,
|
||||
uint32_t * p_new)
|
||||
{
|
||||
push {r4, r5}
|
||||
mov r4, r0
|
||||
|
||||
loop_sub_ge
|
||||
ldrex r0, [r4]
|
||||
cmp r0, r1
|
||||
ite hs
|
||||
subhs r5, r0, r1
|
||||
movlo r5, r0
|
||||
strex r3, r5, [r4]
|
||||
cmp r3, #0
|
||||
bne loop_sub_ge
|
||||
|
||||
str r5, [r2]
|
||||
pop {r4, r5}
|
||||
bx lr
|
||||
}
|
||||
|
||||
|
||||
#define NRF_ATOMIC_OP(asm_op, old_val, new_val, ptr, value) \
|
||||
old_val = nrf_atomic_internal_##asm_op(ptr, value, &new_val)
|
||||
|
||||
#elif defined ( __ICCARM__ ) || defined ( __GNUC__ )
|
||||
|
||||
/**
|
||||
* @brief Atomic operation generic macro
|
||||
* @param[in] asm_op operation: mov, orr, and, eor, add, sub
|
||||
* @param[out] old_val atomic object output (uint32_t), value before operation
|
||||
* @param[out] new_val atomic object output (uint32_t), value after operation
|
||||
* @param[in] value atomic operation operand
|
||||
* */
|
||||
#define NRF_ATOMIC_OP(asm_op, old_val, new_val, ptr, value) \
|
||||
{ \
|
||||
uint32_t str_res; \
|
||||
__ASM volatile( \
|
||||
"1: ldrex %["#old_val"], [%["#ptr"]]\n" \
|
||||
NRF_ATOMIC_OP_##asm_op(new_val, old_val, value) \
|
||||
" strex %[str_res], %["#new_val"], [%["#ptr"]]\n" \
|
||||
" teq %[str_res], #0\n" \
|
||||
" bne.n 1b" \
|
||||
: \
|
||||
[old_val]"=&r" (old_val), \
|
||||
[new_val]"=&r" (new_val), \
|
||||
[str_res]"=&r" (str_res) \
|
||||
: \
|
||||
[ptr]"r" (ptr), \
|
||||
[value]"r" (value) \
|
||||
: "cc"); \
|
||||
UNUSED_PARAMETER(str_res); \
|
||||
}
|
||||
|
||||
#define NRF_ATOMIC_OP_mov(new_val, old_val, value) "mov %["#new_val"], %["#value"]\n"
|
||||
#define NRF_ATOMIC_OP_orr(new_val, old_val, value) "orr %["#new_val"], %["#old_val"], %["#value"]\n"
|
||||
#define NRF_ATOMIC_OP_and(new_val, old_val, value) "and %["#new_val"], %["#old_val"], %["#value"]\n"
|
||||
#define NRF_ATOMIC_OP_eor(new_val, old_val, value) "eor %["#new_val"], %["#old_val"], %["#value"]\n"
|
||||
#define NRF_ATOMIC_OP_add(new_val, old_val, value) "add %["#new_val"], %["#old_val"], %["#value"]\n"
|
||||
#define NRF_ATOMIC_OP_sub(new_val, old_val, value) "sub %["#new_val"], %["#old_val"], %["#value"]\n"
|
||||
#define NRF_ATOMIC_OP_sub_hs(new_val, old_val, value) \
|
||||
"cmp %["#old_val"], %["#value"]\n " \
|
||||
"ite hs\n" \
|
||||
"subhs %["#new_val"], %["#old_val"], %["#value"]\n" \
|
||||
"movlo %["#new_val"], %["#old_val"]\n"
|
||||
|
||||
static inline bool nrf_atomic_internal_cmp_exch(nrf_atomic_u32_t * p_data,
|
||||
uint32_t * p_expected,
|
||||
uint32_t value)
|
||||
{
|
||||
bool res = false;
|
||||
uint32_t str_res = 0;
|
||||
uint32_t act_val = 0;
|
||||
uint32_t exp_val = 0;
|
||||
UNUSED_VARIABLE(str_res);
|
||||
UNUSED_VARIABLE(act_val);
|
||||
UNUSED_VARIABLE(exp_val);
|
||||
__ASM volatile(
|
||||
"1: ldrex %[act_val], [%[ptr]]\n"
|
||||
" ldr %[exp_val], [%[expc]]\n"
|
||||
" cmp %[act_val], %[exp_val]\n"
|
||||
" ittee eq\n"
|
||||
" strexeq %[str_res], %[value], [%[ptr]]\n"
|
||||
" moveq %[res], #1\n"
|
||||
" strexne %[str_res], %[act_val], [%[ptr]]\n"
|
||||
" strne %[act_val], [%[expc]]\n"
|
||||
" cmp %[str_res], #0\n"
|
||||
" itt ne\n"
|
||||
" movne %[res], #0\n"
|
||||
" bne.n 1b"
|
||||
:
|
||||
[res] "=&r" (res),
|
||||
[exp_val] "=&r" (exp_val),
|
||||
[act_val] "=&r" (act_val),
|
||||
[str_res] "=&r" (str_res)
|
||||
:
|
||||
"0" (res),
|
||||
"1" (exp_val),
|
||||
"2" (act_val),
|
||||
[expc] "r" (p_expected),
|
||||
[ptr] "r" (p_data),
|
||||
[value] "r" (value)
|
||||
: "cc");
|
||||
return res;
|
||||
}
|
||||
|
||||
#else
|
||||
#error "Unsupported compiler"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NRF_ATOMIC_INTERNAL_H__ */
|
||||
|
||||
/** @} */
|
||||
/**
|
||||
* Copyright (c) 2016 - 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_ATOMIC_INTERNAL_H__
|
||||
#define NRF_ATOMIC_INTERNAL_H__
|
||||
|
||||
#include "sdk_common.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
*
|
||||
* @defgroup nrf_atomic_internal Atomic operations internals
|
||||
* @ingroup nrf_atomic
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
/* Only Cortex M cores > 3 support LDREX/STREX instructions*/
|
||||
#if ((__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U)) == 0
|
||||
#error "Unsupported core version"
|
||||
#endif
|
||||
|
||||
#if defined ( __CC_ARM )
|
||||
static __asm uint32_t nrf_atomic_internal_mov(nrf_atomic_u32_t * p_ptr,
|
||||
uint32_t value,
|
||||
uint32_t * p_new)
|
||||
{
|
||||
/* The base standard provides for passing arguments in core registers (r0-r3) and on the stack.
|
||||
* Registers r4 and r5 have to be saved on stack. Note that only even number of register push are
|
||||
* allowed. This is a requirement of the Procedure Call Standard for the ARM Architecture [AAPCS].
|
||||
* */
|
||||
push {r4, r5}
|
||||
mov r4, r0
|
||||
|
||||
loop_mov
|
||||
ldrex r0, [r4]
|
||||
mov r5, r1
|
||||
strex r3, r5, [r4]
|
||||
cmp r3, #0
|
||||
bne loop_mov
|
||||
|
||||
str r5, [r2]
|
||||
pop {r4, r5}
|
||||
bx lr
|
||||
}
|
||||
|
||||
|
||||
static __asm uint32_t nrf_atomic_internal_orr(nrf_atomic_u32_t * p_ptr,
|
||||
uint32_t value,
|
||||
uint32_t * p_new)
|
||||
{
|
||||
push {r4, r5}
|
||||
mov r4, r0
|
||||
|
||||
loop_orr
|
||||
ldrex r0, [r4]
|
||||
orr r5, r0, r1
|
||||
strex r3, r5, [r4]
|
||||
cmp r3, #0
|
||||
bne loop_orr
|
||||
|
||||
str r5, [r2]
|
||||
pop {r4, r5}
|
||||
bx lr
|
||||
}
|
||||
|
||||
static __asm uint32_t nrf_atomic_internal_and(nrf_atomic_u32_t * p_ptr,
|
||||
uint32_t value,
|
||||
uint32_t * p_new)
|
||||
{
|
||||
push {r4, r5}
|
||||
mov r4, r0
|
||||
|
||||
loop_and
|
||||
ldrex r0, [r4]
|
||||
and r5, r0, r1
|
||||
strex r3, r5, [r4]
|
||||
cmp r3, #0
|
||||
bne loop_and
|
||||
|
||||
str r5, [r2]
|
||||
pop {r4, r5}
|
||||
bx lr
|
||||
}
|
||||
|
||||
static __asm uint32_t nrf_atomic_internal_eor(nrf_atomic_u32_t * p_ptr,
|
||||
uint32_t value,
|
||||
uint32_t * p_new)
|
||||
{
|
||||
push {r4, r5}
|
||||
mov r4, r0
|
||||
|
||||
loop_eor
|
||||
ldrex r0, [r4]
|
||||
eor r5, r0, r1
|
||||
strex r3, r5, [r4]
|
||||
cmp r3, #0
|
||||
bne loop_eor
|
||||
|
||||
str r5, [r2]
|
||||
pop {r4, r5}
|
||||
bx lr
|
||||
}
|
||||
|
||||
static __asm uint32_t nrf_atomic_internal_add(nrf_atomic_u32_t * p_ptr,
|
||||
uint32_t value,
|
||||
uint32_t * p_new)
|
||||
{
|
||||
push {r4, r5}
|
||||
mov r4, r0
|
||||
|
||||
loop_add
|
||||
ldrex r0, [r4]
|
||||
add r5, r0, r1
|
||||
strex r3, r5, [r4]
|
||||
cmp r3, #0
|
||||
bne loop_add
|
||||
|
||||
str r5, [r2]
|
||||
pop {r4, r5}
|
||||
bx lr
|
||||
}
|
||||
|
||||
static __asm uint32_t nrf_atomic_internal_sub(nrf_atomic_u32_t * p_ptr,
|
||||
uint32_t value,
|
||||
uint32_t * p_new)
|
||||
{
|
||||
push {r4, r5}
|
||||
mov r4, r0
|
||||
|
||||
loop_sub
|
||||
ldrex r0, [r4]
|
||||
sub r5, r0, r1
|
||||
strex r3, r5, [r4]
|
||||
cmp r3, #0
|
||||
bne loop_sub
|
||||
|
||||
str r5, [r2]
|
||||
pop {r4, r5}
|
||||
bx lr
|
||||
}
|
||||
|
||||
static __asm bool nrf_atomic_internal_cmp_exch(nrf_atomic_u32_t * p_data,
|
||||
uint32_t * p_expected,
|
||||
uint32_t value)
|
||||
{
|
||||
#define RET_REG r0
|
||||
#define P_EXPC r1
|
||||
#define VALUE r2
|
||||
#define STR_RES r3
|
||||
#define P_DATA r4
|
||||
#define EXPC_VAL r5
|
||||
#define ACT_VAL r6
|
||||
|
||||
push {r4-r6}
|
||||
mov P_DATA, r0
|
||||
mov RET_REG, #0
|
||||
|
||||
loop_cmp_exch
|
||||
ldrex ACT_VAL, [P_DATA]
|
||||
ldr EXPC_VAL, [P_EXPC]
|
||||
cmp ACT_VAL, EXPC_VAL
|
||||
ittee eq
|
||||
strexeq STR_RES, VALUE, [P_DATA]
|
||||
moveq RET_REG, #1
|
||||
strexne STR_RES, ACT_VAL, [P_DATA]
|
||||
strne ACT_VAL, [P_EXPC]
|
||||
cmp STR_RES, #0
|
||||
itt ne
|
||||
movne RET_REG, #0
|
||||
bne loop_cmp_exch
|
||||
|
||||
pop {r4-r6}
|
||||
bx lr
|
||||
|
||||
#undef RET_REG
|
||||
#undef P_EXPC
|
||||
#undef VALUE
|
||||
#undef STR_RES
|
||||
#undef P_DATA
|
||||
#undef EXPC_VAL
|
||||
#undef ACT_VAL
|
||||
}
|
||||
|
||||
static __asm uint32_t nrf_atomic_internal_sub_hs(nrf_atomic_u32_t * p_ptr,
|
||||
uint32_t value,
|
||||
uint32_t * p_new)
|
||||
{
|
||||
push {r4, r5}
|
||||
mov r4, r0
|
||||
|
||||
loop_sub_ge
|
||||
ldrex r0, [r4]
|
||||
cmp r0, r1
|
||||
ite hs
|
||||
subhs r5, r0, r1
|
||||
movlo r5, r0
|
||||
strex r3, r5, [r4]
|
||||
cmp r3, #0
|
||||
bne loop_sub_ge
|
||||
|
||||
str r5, [r2]
|
||||
pop {r4, r5}
|
||||
bx lr
|
||||
}
|
||||
|
||||
|
||||
#define NRF_ATOMIC_OP(asm_op, old_val, new_val, ptr, value) \
|
||||
old_val = nrf_atomic_internal_##asm_op(ptr, value, &new_val)
|
||||
|
||||
#elif defined ( __ICCARM__ ) || defined ( __GNUC__ )
|
||||
|
||||
/**
|
||||
* @brief Atomic operation generic macro
|
||||
* @param[in] asm_op operation: mov, orr, and, eor, add, sub
|
||||
* @param[out] old_val atomic object output (uint32_t), value before operation
|
||||
* @param[out] new_val atomic object output (uint32_t), value after operation
|
||||
* @param[in] value atomic operation operand
|
||||
* */
|
||||
#define NRF_ATOMIC_OP(asm_op, old_val, new_val, ptr, value) \
|
||||
{ \
|
||||
uint32_t str_res; \
|
||||
__ASM volatile( \
|
||||
"1: ldrex %["#old_val"], [%["#ptr"]]\n" \
|
||||
NRF_ATOMIC_OP_##asm_op(new_val, old_val, value) \
|
||||
" strex %[str_res], %["#new_val"], [%["#ptr"]]\n" \
|
||||
" teq %[str_res], #0\n" \
|
||||
" bne.n 1b" \
|
||||
: \
|
||||
[old_val]"=&r" (old_val), \
|
||||
[new_val]"=&r" (new_val), \
|
||||
[str_res]"=&r" (str_res) \
|
||||
: \
|
||||
[ptr]"r" (ptr), \
|
||||
[value]"r" (value) \
|
||||
: "cc"); \
|
||||
UNUSED_PARAMETER(str_res); \
|
||||
}
|
||||
|
||||
#define NRF_ATOMIC_OP_mov(new_val, old_val, value) "mov %["#new_val"], %["#value"]\n"
|
||||
#define NRF_ATOMIC_OP_orr(new_val, old_val, value) "orr %["#new_val"], %["#old_val"], %["#value"]\n"
|
||||
#define NRF_ATOMIC_OP_and(new_val, old_val, value) "and %["#new_val"], %["#old_val"], %["#value"]\n"
|
||||
#define NRF_ATOMIC_OP_eor(new_val, old_val, value) "eor %["#new_val"], %["#old_val"], %["#value"]\n"
|
||||
#define NRF_ATOMIC_OP_add(new_val, old_val, value) "add %["#new_val"], %["#old_val"], %["#value"]\n"
|
||||
#define NRF_ATOMIC_OP_sub(new_val, old_val, value) "sub %["#new_val"], %["#old_val"], %["#value"]\n"
|
||||
#define NRF_ATOMIC_OP_sub_hs(new_val, old_val, value) \
|
||||
"cmp %["#old_val"], %["#value"]\n " \
|
||||
"ite hs\n" \
|
||||
"subhs %["#new_val"], %["#old_val"], %["#value"]\n" \
|
||||
"movlo %["#new_val"], %["#old_val"]\n"
|
||||
|
||||
static inline bool nrf_atomic_internal_cmp_exch(nrf_atomic_u32_t * p_data,
|
||||
uint32_t * p_expected,
|
||||
uint32_t value)
|
||||
{
|
||||
bool res = false;
|
||||
uint32_t str_res = 0;
|
||||
uint32_t act_val = 0;
|
||||
uint32_t exp_val = 0;
|
||||
UNUSED_VARIABLE(str_res);
|
||||
UNUSED_VARIABLE(act_val);
|
||||
UNUSED_VARIABLE(exp_val);
|
||||
__ASM volatile(
|
||||
"1: ldrex %[act_val], [%[ptr]]\n"
|
||||
" ldr %[exp_val], [%[expc]]\n"
|
||||
" cmp %[act_val], %[exp_val]\n"
|
||||
" ittee eq\n"
|
||||
" strexeq %[str_res], %[value], [%[ptr]]\n"
|
||||
" moveq %[res], #1\n"
|
||||
" strexne %[str_res], %[act_val], [%[ptr]]\n"
|
||||
" strne %[act_val], [%[expc]]\n"
|
||||
" cmp %[str_res], #0\n"
|
||||
" itt ne\n"
|
||||
" movne %[res], #0\n"
|
||||
" bne.n 1b"
|
||||
:
|
||||
[res] "=&r" (res),
|
||||
[exp_val] "=&r" (exp_val),
|
||||
[act_val] "=&r" (act_val),
|
||||
[str_res] "=&r" (str_res)
|
||||
:
|
||||
"0" (res),
|
||||
"1" (exp_val),
|
||||
"2" (act_val),
|
||||
[expc] "r" (p_expected),
|
||||
[ptr] "r" (p_data),
|
||||
[value] "r" (value)
|
||||
: "cc");
|
||||
return res;
|
||||
}
|
||||
|
||||
#else
|
||||
#error "Unsupported compiler"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NRF_ATOMIC_INTERNAL_H__ */
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* Copyright (c) 2011 - 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_DELAY_H
|
||||
#define _NRF_DELAY_H
|
||||
|
||||
#include <nrfx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Function for delaying execution for a number of microseconds.
|
||||
*
|
||||
* @param us_time Number of microseconds to wait.
|
||||
*/
|
||||
#define nrf_delay_us(us_time) NRFX_DELAY_US(us_time)
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function for delaying execution for a number of milliseconds.
|
||||
*
|
||||
* @param ms_time Number of milliseconds to wait.
|
||||
*/
|
||||
|
||||
__STATIC_INLINE void nrf_delay_ms(uint32_t ms_time)
|
||||
{
|
||||
if (ms_time == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
nrf_delay_us(1000);
|
||||
} while (--ms_time);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+33
-8
@@ -1,11 +1,36 @@
|
||||
/****************************************************************************
|
||||
* This confidential and proprietary software may be used only as authorized *
|
||||
* by a licensing agreement from ARM Israel. *
|
||||
* Copyright (C) 2015 ARM Limited or its affiliates. All rights reserved. *
|
||||
* The entire notice above must be reproduced on all authorized copies and *
|
||||
* copies may only be made to the extent permitted by a licensing agreement *
|
||||
* from ARM Israel. *
|
||||
*****************************************************************************/
|
||||
/**************************************************************************************
|
||||
* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved *
|
||||
* *
|
||||
* This file and the related binary are licensed under the following license: *
|
||||
* *
|
||||
* ARM Object Code and Header Files License, v1.0 Redistribution. *
|
||||
* *
|
||||
* Redistribution and use of object code, header files, and documentation, without *
|
||||
* modification, are permitted provided that the following conditions are met: *
|
||||
* *
|
||||
* 1) Redistributions must reproduce the above copyright notice and the *
|
||||
* following disclaimer in the documentation and/or other materials *
|
||||
* provided with the distribution. *
|
||||
* *
|
||||
* 2) Unless to the extent explicitly permitted by law, no reverse *
|
||||
* engineering, decompilation, or disassembly of is permitted. *
|
||||
* *
|
||||
* 3) Redistribution and use is permitted solely for the purpose of *
|
||||
* developing or executing applications that are targeted for use *
|
||||
* on an ARM-based product. *
|
||||
* *
|
||||
* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT *
|
||||
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, *
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
|
||||
* COPYRIGHT HOLDERS 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 __DX_REG_BASE_HOST_H__
|
||||
#define __DX_REG_BASE_HOST_H__
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
/**************************************************************************************
|
||||
* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved *
|
||||
* *
|
||||
* This file and the related binary are licensed under the following license: *
|
||||
* *
|
||||
* ARM Object Code and Header Files License, v1.0 Redistribution. *
|
||||
* *
|
||||
* Redistribution and use of object code, header files, and documentation, without *
|
||||
* modification, are permitted provided that the following conditions are met: *
|
||||
* *
|
||||
* 1) Redistributions must reproduce the above copyright notice and the *
|
||||
* following disclaimer in the documentation and/or other materials *
|
||||
* provided with the distribution. *
|
||||
* *
|
||||
* 2) Unless to the extent explicitly permitted by law, no reverse *
|
||||
* engineering, decompilation, or disassembly of is permitted. *
|
||||
* *
|
||||
* 3) Redistribution and use is permitted solely for the purpose of *
|
||||
* developing or executing applications that are targeted for use *
|
||||
* on an ARM-based product. *
|
||||
* *
|
||||
* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT *
|
||||
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, *
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
|
||||
* COPYRIGHT HOLDERS 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 _SSI_UTIL_DEFS_H
|
||||
#define _SSI_UTIL_DEFS_H
|
||||
|
||||
/*!
|
||||
@defgroup ssi_utils CryptoCell utility APIs
|
||||
@{
|
||||
@ingroup cryptocell_api
|
||||
@brief This group is the utility apis group
|
||||
@}
|
||||
|
||||
@file
|
||||
@brief This file contains CryptoCell Util general definitions.
|
||||
@defgroup ssi_utils_defs CryptoCell utils general definitions
|
||||
@{
|
||||
@ingroup ssi_utils
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "ssi_pal_types_plat.h"
|
||||
#include "ssi_util_key_derivation_defs.h"
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* DEFINITIONS
|
||||
******************************************************************************/
|
||||
/*! Supported AES key size in bits. */
|
||||
#define SASI_UTIL_AES_128BIT_SIZE 16 // same as SEP_AES_128_BIT_KEY_SIZE
|
||||
/*****************************************/
|
||||
/* CMAC derive key definitions*/
|
||||
/*****************************************/
|
||||
/*! Minimal data size for CMAC derivation operation. */
|
||||
#define SASI_UTIL_CMAC_DERV_MIN_DATA_IN_SIZE SASI_UTIL_FIX_DATA_MIN_SIZE_IN_BYTES+2
|
||||
/*! Maximal data size for CMAC derivation operation. */
|
||||
#define SASI_UTIL_CMAC_DERV_MAX_DATA_IN_SIZE SASI_UTIL_MAX_KDF_SIZE_IN_BYTES
|
||||
/*! AES CMAC result size in bytes. */
|
||||
#define SASI_UTIL_AES_CMAC_RESULT_SIZE_IN_BYTES 0x10UL
|
||||
/*! AES CMAC result size in words. */
|
||||
#define SASI_UTIL_AES_CMAC_RESULT_SIZE_IN_WORDS (SASI_UTIL_AES_CMAC_RESULT_SIZE_IN_BYTES/4)
|
||||
|
||||
/*! Util Error type. */
|
||||
typedef uint32_t SaSiUtilError_t;
|
||||
/*! Defines the CMAC result buffer. */
|
||||
typedef uint8_t SaSiUtilAesCmacResult_t[SASI_UTIL_AES_CMAC_RESULT_SIZE_IN_BYTES];
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
#endif /*_SSI_UTIL_DEFS_H*/
|
||||
@@ -0,0 +1,97 @@
|
||||
/**************************************************************************************
|
||||
* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved *
|
||||
* *
|
||||
* This file and the related binary are licensed under the following license: *
|
||||
* *
|
||||
* ARM Object Code and Header Files License, v1.0 Redistribution. *
|
||||
* *
|
||||
* Redistribution and use of object code, header files, and documentation, without *
|
||||
* modification, are permitted provided that the following conditions are met: *
|
||||
* *
|
||||
* 1) Redistributions must reproduce the above copyright notice and the *
|
||||
* following disclaimer in the documentation and/or other materials *
|
||||
* provided with the distribution. *
|
||||
* *
|
||||
* 2) Unless to the extent explicitly permitted by law, no reverse *
|
||||
* engineering, decompilation, or disassembly of is permitted. *
|
||||
* *
|
||||
* 3) Redistribution and use is permitted solely for the purpose of *
|
||||
* developing or executing applications that are targeted for use *
|
||||
* on an ARM-based product. *
|
||||
* *
|
||||
* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT *
|
||||
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, *
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
|
||||
* COPYRIGHT HOLDERS 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 _SSI_UTIL_ERROR_H
|
||||
#define _SSI_UTIL_ERROR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@file
|
||||
@brief This module contains the definitions of the UTIL module errors.
|
||||
@defgroup ssi_utils_errors CryptoCell utils error definitions
|
||||
@{
|
||||
@ingroup ssi_utils
|
||||
|
||||
*/
|
||||
|
||||
/***********************/
|
||||
/* Util return codes */
|
||||
/***********************/
|
||||
|
||||
/*! Success definition. */
|
||||
#define SASI_UTIL_OK 0x00UL
|
||||
/*! Error base number definition. */
|
||||
#define SASI_UTIL_MODULE_ERROR_BASE 0x80000000
|
||||
|
||||
/*! Illegal key type. */
|
||||
#define SASI_UTIL_INVALID_KEY_TYPE (SASI_UTIL_MODULE_ERROR_BASE + 0x00UL)
|
||||
/*! Illegal data in pointer. */
|
||||
#define SASI_UTIL_DATA_IN_POINTER_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x01UL)
|
||||
/*! Illegal data in size. */
|
||||
#define SASI_UTIL_DATA_IN_SIZE_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x02UL)
|
||||
/*! Illegal data out pointer. */
|
||||
#define SASI_UTIL_DATA_OUT_POINTER_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x03UL)
|
||||
/*! Illegal data out size. */
|
||||
#define SASI_UTIL_DATA_OUT_SIZE_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x04UL)
|
||||
/*! Fatal error. */
|
||||
#define SASI_UTIL_FATAL_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x05UL)
|
||||
/*! Illegal parameters. */
|
||||
#define SASI_UTIL_ILLEGAL_PARAMS_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x06UL)
|
||||
/*! Invalid address given. */
|
||||
#define SASI_UTIL_BAD_ADDR_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x07UL)
|
||||
/*! Illegal domain for endorsement key. */
|
||||
#define SASI_UTIL_EK_DOMAIN_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x08UL)
|
||||
/*! Kdr is not valid. */
|
||||
#define SASI_UTIL_KDR_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x09UL)
|
||||
/*! LCS is not valid. */
|
||||
#define SASI_UTIL_LCS_INVALID_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x0AUL)
|
||||
/*! session key is not valid. */
|
||||
#define SASI_UTIL_SESSION_KEY_ERROR (SASI_UTIL_MODULE_ERROR_BASE + 0x0BUL)
|
||||
/*! Illegal user key size. */
|
||||
#define SASI_UTIL_INVALID_USER_KEY_SIZE (SASI_UTIL_MODULE_ERROR_BASE + 0x0DUL)
|
||||
/*! Illegal LCS for the required operation. */
|
||||
#define SASI_UTIL_ILLEGAL_LCS_FOR_OPERATION_ERR (SASI_UTIL_MODULE_ERROR_BASE + 0x0EUL)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
#endif /*_SSI_UTIL_ERROR_H*/
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
/**************************************************************************************
|
||||
* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved *
|
||||
* *
|
||||
* This file and the related binary are licensed under the following license: *
|
||||
* *
|
||||
* ARM Object Code and Header Files License, v1.0 Redistribution. *
|
||||
* *
|
||||
* Redistribution and use of object code, header files, and documentation, without *
|
||||
* modification, are permitted provided that the following conditions are met: *
|
||||
* *
|
||||
* 1) Redistributions must reproduce the above copyright notice and the *
|
||||
* following disclaimer in the documentation and/or other materials *
|
||||
* provided with the distribution. *
|
||||
* *
|
||||
* 2) Unless to the extent explicitly permitted by law, no reverse *
|
||||
* engineering, decompilation, or disassembly of is permitted. *
|
||||
* *
|
||||
* 3) Redistribution and use is permitted solely for the purpose of *
|
||||
* developing or executing applications that are targeted for use *
|
||||
* on an ARM-based product. *
|
||||
* *
|
||||
* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT *
|
||||
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, *
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
|
||||
* COPYRIGHT HOLDERS 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 _SSI_UTIL_KEY_DERIVATION_H
|
||||
#define _SSI_UTIL_KEY_DERIVATION_H
|
||||
|
||||
/*!
|
||||
@file
|
||||
@brief This module defines the API that supports Key derivation function as specified
|
||||
in [SP800-108] in section "KDF in Counter Mode".
|
||||
@defgroup ssi_utils_key_derivation CryptoCell utility key derivation APIs
|
||||
@{
|
||||
@ingroup ssi_utils
|
||||
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "ssi_util_defs.h"
|
||||
#include "ssi_util_key_derivation_defs.h"
|
||||
#include "ssi_aes.h"
|
||||
|
||||
/******************************************************************************
|
||||
* DEFINITIONS
|
||||
******************************************************************************/
|
||||
|
||||
/*! Input key derivation type. */
|
||||
typedef enum {
|
||||
/*! User's key.*/
|
||||
SASI_UTIL_USER_KEY = 0,
|
||||
/*! Root key (Kdr).*/
|
||||
SASI_UTIL_ROOT_KEY = 1,
|
||||
/*! Reserved.*/
|
||||
SASI_UTIL_END_OF_KEY_TYPE = 0x7FFFFFFF
|
||||
}SaSiUtilKeyType_t;
|
||||
|
||||
|
||||
/*!
|
||||
@brief The key derivation function is as specified in [SP800-108] in section "KDF in Counter Mode".
|
||||
The derivation is based on length l, label L, context C and derivation key Ki.
|
||||
AES-CMAC is used as the pseudorandom function (PRF).
|
||||
|
||||
@return SASI_UTIL_OK on success.
|
||||
@return A non-zero value from ssi_util_error.h on failure.
|
||||
*/
|
||||
|
||||
/* A key derivation functions can iterates n times until l bits of keying material are generated.
|
||||
For each of the iteration of the PRF, i=1 to n, do:
|
||||
result(0) = 0;
|
||||
K(i) = PRF (Ki, [i] || Label || 0x00 || Context || length);
|
||||
results(i) = result(i-1) || K(i);
|
||||
|
||||
concisely, result(i) = K(i) || k(i-1) || .... || k(0)*/
|
||||
SaSiUtilError_t SaSi_UtilKeyDerivation(
|
||||
SaSiUtilKeyType_t keyType, /*!< [in] The key type that is used as an input to a key derivation function.
|
||||
Can be one of: SASI_UTIL_USER_KEY or SASI_UTIL_ROOT_KEY. */
|
||||
SaSiAesUserKeyData_t *pUserKey, /*!< [in] A pointer to the user's key buffer (in case of SASI_UTIL_USER_KEY). */
|
||||
const uint8_t *pLabel, /*!< [in] A string that identifies the purpose for the derived keying material.*/
|
||||
size_t labelSize, /*!< [in] The label size should be in range of 1 to 64 bytes length. */
|
||||
const uint8_t *pContextData, /*!< [in] A binary string containing the information related to the derived keying material. */
|
||||
size_t contextSize, /*!< [in] The context size should be in range of 1 to 64 bytes length. */
|
||||
uint8_t *pDerivedKey, /*!< [out] Keying material output (MUST be atleast the size of derivedKeySize). */
|
||||
size_t derivedKeySize /*!< [in] Size of the derived keying material in bytes (limited to 4080 bytes). */
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
#endif /*_SSI_UTIL_KEY_DERIVATION_H*/
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/**************************************************************************************
|
||||
* Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved *
|
||||
* *
|
||||
* This file and the related binary are licensed under the following license: *
|
||||
* *
|
||||
* ARM Object Code and Header Files License, v1.0 Redistribution. *
|
||||
* *
|
||||
* Redistribution and use of object code, header files, and documentation, without *
|
||||
* modification, are permitted provided that the following conditions are met: *
|
||||
* *
|
||||
* 1) Redistributions must reproduce the above copyright notice and the *
|
||||
* following disclaimer in the documentation and/or other materials *
|
||||
* provided with the distribution. *
|
||||
* *
|
||||
* 2) Unless to the extent explicitly permitted by law, no reverse *
|
||||
* engineering, decompilation, or disassembly of is permitted. *
|
||||
* *
|
||||
* 3) Redistribution and use is permitted solely for the purpose of *
|
||||
* developing or executing applications that are targeted for use *
|
||||
* on an ARM-based product. *
|
||||
* *
|
||||
* DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT *
|
||||
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, *
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
|
||||
* COPYRIGHT HOLDERS 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 _SSI_UTIL_KEY_DERIVATION_DEFS_H
|
||||
#define _SSI_UTIL_KEY_DERIVATION_DEFS_H
|
||||
|
||||
/*!
|
||||
@file
|
||||
@brief This file contains the definitions for the key derivation API.
|
||||
@defgroup ssi_utils_key_defs CryptoCell utils general key definitions
|
||||
@{
|
||||
@ingroup ssi_utils
|
||||
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* DEFINITIONS
|
||||
******************************************************************************/
|
||||
|
||||
/*! Maximal label length in bytes. */
|
||||
#define SASI_UTIL_MAX_LABEL_LENGTH_IN_BYTES 64
|
||||
/*! Maximal context length in bytes. */
|
||||
#define SASI_UTIL_MAX_CONTEXT_LENGTH_IN_BYTES 64
|
||||
|
||||
/*! Minimal fixed data size in bytes. */
|
||||
#define SASI_UTIL_FIX_DATA_MIN_SIZE_IN_BYTES 3 /*!< \internal counter, 0x00, lengt(-0xff) */
|
||||
/*! Maximal fixed data size in bytes. */
|
||||
#define SASI_UTIL_FIX_DATA_MAX_SIZE_IN_BYTES 4 /*!< \internal counter, 0x00, lengt(0x100-0xff0) */
|
||||
|
||||
/*! Maximal derived key material size in bytes. */
|
||||
#define SASI_UTIL_MAX_KDF_SIZE_IN_BYTES (SASI_UTIL_MAX_LABEL_LENGTH_IN_BYTES+ \
|
||||
SASI_UTIL_MAX_CONTEXT_LENGTH_IN_BYTES+SASI_UTIL_FIX_DATA_MAX_SIZE_IN_BYTES)
|
||||
|
||||
/*! Maximal derived key size in bytes. */
|
||||
#define SASI_UTIL_MAX_DERIVED_KEY_SIZE_IN_BYTES 4080
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
#endif /*_SSI_UTIL_KEY_DERIVATION_DEFS_H*/
|
||||
|
||||
BIN
Binary file not shown.
+303
-125
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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
|
||||
@@ -35,13 +35,14 @@
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
#include "sdk_common.h"
|
||||
#if NRF_MODULE_ENABLED(APP_USBD)
|
||||
|
||||
#include "app_usbd.h"
|
||||
#include "app_usbd_core.h"
|
||||
#include "app_usbd_request.h"
|
||||
#include "nrf_power.h"
|
||||
#include "nrf_drv_clock.h"
|
||||
#include "nrf_drv_power.h"
|
||||
@@ -95,14 +96,14 @@ static uint16_t m_last_frame;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Variable type for endpoint configuration
|
||||
* @brief Variable type for endpoint configuration.
|
||||
*
|
||||
* Each endpoint would have assigned this type of configuration structure.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/**
|
||||
* @brief The class instance
|
||||
* @brief The class instance.
|
||||
*
|
||||
* The pointer to the class instance that is connected to the endpoint.
|
||||
*/
|
||||
@@ -129,27 +130,30 @@ typedef struct
|
||||
|
||||
#if (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE) \
|
||||
|| defined(__SDK_DOXYGEN__)
|
||||
uint16_t sof_cnt; //!< Number of the SOF events that appears before current event
|
||||
uint16_t sof_cnt; //!< Number of the SOF events that appears before current event
|
||||
uint16_t start_frame; //!< Number of the SOF frame that starts this event
|
||||
#endif // (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE)
|
||||
|
||||
} app_usbd_internal_queue_evt_t;
|
||||
|
||||
#if (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) || defined(__SDK_DOXYGEN__)
|
||||
/**
|
||||
* @brief Event queue
|
||||
* @brief Event queue.
|
||||
*
|
||||
* The queue with events to be processed
|
||||
* The queue with events to be processed.
|
||||
*/
|
||||
NRF_ATFIFO_DEF(m_event_queue, app_usbd_internal_queue_evt_t, APP_USBD_CONFIG_EVENT_QUEUE_SIZE);
|
||||
|
||||
#if (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE) \
|
||||
|| defined(__SDK_DOXYGEN__)
|
||||
/**
|
||||
* @brief SOF events counter.
|
||||
*/
|
||||
|
||||
/** @brief SOF events counter */
|
||||
static nrf_atomic_u32_t m_sof_events_cnt;
|
||||
|
||||
// Limit of SOF events stacked until warning message.
|
||||
/** @brief SOF Frame counter */
|
||||
static uint16_t m_event_frame;
|
||||
|
||||
/* Limit of SOF events stacked until warning message. */
|
||||
#define APP_USBD_SOF_WARNING_LIMIT 500
|
||||
#endif // (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE)
|
||||
// || defined(__SDK_DOXYGEN__)
|
||||
@@ -157,7 +161,7 @@ static nrf_atomic_u32_t m_sof_events_cnt;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Instances connected with IN endpoints
|
||||
* @brief Instances connected with IN endpoints.
|
||||
*
|
||||
* Array of instance pointers connected with every IN endpoint.
|
||||
* @sa m_epout_instances
|
||||
@@ -165,7 +169,7 @@ static nrf_atomic_u32_t m_sof_events_cnt;
|
||||
static app_usbd_ep_conf_t m_epin_conf[NRF_USBD_EPIN_CNT];
|
||||
|
||||
/**
|
||||
* @brief Instances connected with OUT endpoints
|
||||
* @brief Instances connected with OUT endpoints.
|
||||
*
|
||||
* Array of instance pointers connected with every OUT endpoint.
|
||||
* @sa m_epin_instances
|
||||
@@ -173,7 +177,7 @@ static app_usbd_ep_conf_t m_epin_conf[NRF_USBD_EPIN_CNT];
|
||||
static app_usbd_ep_conf_t m_epout_conf[NRF_USBD_EPIN_CNT];
|
||||
|
||||
/**
|
||||
* @brief Beginning of classes list
|
||||
* @brief Beginning of classes list.
|
||||
*
|
||||
* All enabled in current configuration instances are connected into
|
||||
* a single linked list chain.
|
||||
@@ -183,12 +187,19 @@ static app_usbd_ep_conf_t m_epout_conf[NRF_USBD_EPIN_CNT];
|
||||
static app_usbd_class_inst_t const * m_p_first_cinst;
|
||||
|
||||
/**
|
||||
* @brief Classes list that requires SOF events
|
||||
* @brief Classes list that requires SOF events.
|
||||
*
|
||||
* @todo RK Implement and documentation
|
||||
* Pointer to first class that requires SOF events.
|
||||
*/
|
||||
static app_usbd_class_inst_t const * m_p_first_sof_cinst;
|
||||
|
||||
/**
|
||||
* @brief Classes list that require SOF events in interrupt.
|
||||
*
|
||||
* Pointer to first class that requires SOF events in interrupt.
|
||||
*/
|
||||
static app_usbd_class_inst_t const * m_p_first_sof_interrupt_cinst;
|
||||
|
||||
/**
|
||||
* @brief Default configuration (when NULL is passed to @ref app_usbd_init).
|
||||
*/
|
||||
@@ -204,7 +215,7 @@ static const app_usbd_config_t m_default_conf = {
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief SUSPEND state machine states
|
||||
* @brief SUSPEND state machine states.
|
||||
*
|
||||
* The enumeration of internal SUSPEND state machine states.
|
||||
*/
|
||||
@@ -222,14 +233,14 @@ typedef enum
|
||||
}app_usbd_sustate_t;
|
||||
|
||||
/**
|
||||
* @brief Current suspend state
|
||||
* @brief Current suspend state.
|
||||
*
|
||||
* The state of the suspend state machine
|
||||
* The state of the suspend state machine.
|
||||
*/
|
||||
static app_usbd_sustate_t m_sustate;
|
||||
|
||||
/**
|
||||
* @brief Remote wake-up register/unregister
|
||||
* @brief Remote wake-up register/unregister.
|
||||
*
|
||||
* Counter incremented when appended instance required remote wake-up functionality.
|
||||
* It should be decremented when the class is removed.
|
||||
@@ -247,12 +258,12 @@ static app_usbd_config_t m_current_conf;
|
||||
*
|
||||
* @ref app_usbd_class_interface_t::event_handler
|
||||
*
|
||||
* @param[in] p_cinst Class instance
|
||||
* @param[in] p_event Event passed to class instance
|
||||
* @param[in] p_cinst Class instance.
|
||||
* @param[in] p_event Event passed to class instance.
|
||||
*
|
||||
* @return Standard error code @ref ret_code_t
|
||||
* @retval NRF_SUCCESS event handled successfully
|
||||
* @retval NRF_ERROR_NOT_SUPPORTED unsupported event
|
||||
* @retval NRF_SUCCESS event handled successfully.
|
||||
* @retval NRF_ERROR_NOT_SUPPORTED unsupported event.
|
||||
* */
|
||||
static inline ret_code_t class_event_handler(app_usbd_class_inst_t const * const p_cinst,
|
||||
app_usbd_complex_evt_t const * const p_event)
|
||||
@@ -264,6 +275,15 @@ static inline ret_code_t class_event_handler(app_usbd_class_inst_t const * cons
|
||||
}
|
||||
|
||||
#if (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) || defined(__SDK_DOXYGEN__)
|
||||
static inline void class_sof_interrupt_handler(app_usbd_class_inst_t const * const p_cinst,
|
||||
app_usbd_complex_evt_t const * const p_event)
|
||||
{
|
||||
ASSERT(p_cinst != NULL);
|
||||
ASSERT(p_cinst->p_data != NULL);
|
||||
ASSERT(p_cinst->p_data->sof_handler != NULL);
|
||||
p_cinst->p_data->sof_handler(p_event->drv_evt.data.sof.framecnt);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief User event handler call (passed via configuration).
|
||||
*
|
||||
@@ -280,7 +300,7 @@ static inline void user_event_handler(app_usbd_internal_evt_t const * const p_ev
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief User event processor call (passed via configuration)
|
||||
* @brief User event processor call (passed via configuration).
|
||||
*
|
||||
* @param event Event type.
|
||||
*/
|
||||
@@ -293,17 +313,17 @@ static inline void user_event_state_proc(app_usbd_event_type_t event)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Find a specified descriptor
|
||||
* @brief Find a specified descriptor.
|
||||
*
|
||||
* @param[in] p_cinst Class instance
|
||||
* @param[in] desc_type Descriptor type @ref app_usbd_descriptor_t
|
||||
* @param[in] desc_index Descriptor index
|
||||
* @param[out] p_desc Pointer to escriptor
|
||||
* @param[out] p_desc_len Length of descriptor
|
||||
* @param[in] p_cinst Class instance.
|
||||
* @param[in] desc_type Descriptor type @ref app_usbd_descriptor_t
|
||||
* @param[in] desc_index Descriptor index.
|
||||
* @param[out] p_desc Pointer to escriptor.
|
||||
* @param[out] p_desc_len Length of descriptor.
|
||||
*
|
||||
* @return Standard error code @ref ret_code_t
|
||||
* @retval NRF_SUCCESS descriptor successfully found
|
||||
* @retval NRF_ERROR_NOT_FOUND descriptor not found
|
||||
* @retval NRF_SUCCESS Descriptor successfully found.
|
||||
* @retval NRF_ERROR_NOT_FOUND Descriptor not found.
|
||||
* */
|
||||
ret_code_t app_usbd_class_descriptor_find(app_usbd_class_inst_t const * const p_cinst,
|
||||
uint8_t desc_type,
|
||||
@@ -373,10 +393,10 @@ ret_code_t app_usbd_class_descriptor_find(app_usbd_class_inst_t const * const p_
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Access into selected endpoint configuration structure
|
||||
* @brief Access into selected endpoint configuration structure.
|
||||
*
|
||||
* @param ep Endpoint address
|
||||
* @return A pointer to the endpoint configuration structure
|
||||
* @param ep Endpoint address.
|
||||
* @return A pointer to the endpoint configuration structure.
|
||||
*
|
||||
* @note This function would assert when endpoint number is not correct and debugging is enabled.
|
||||
*/
|
||||
@@ -397,11 +417,11 @@ static app_usbd_ep_conf_t * app_usbd_ep_conf_access(nrf_drv_usbd_ep_t ep)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Accessing instance connected with selected endpoint
|
||||
* @brief Accessing instance connected with selected endpoint.
|
||||
*
|
||||
* @param ep Endpoint number
|
||||
* @param ep Endpoint number.
|
||||
*
|
||||
* @return The pointer to the instance connected with endpoint
|
||||
* @return The pointer to the instance connected with endpoint.
|
||||
*/
|
||||
static inline app_usbd_class_inst_t const * app_usbd_ep_instance_get(nrf_drv_usbd_ep_t ep)
|
||||
{
|
||||
@@ -409,12 +429,12 @@ static inline app_usbd_class_inst_t const * app_usbd_ep_instance_get(nrf_drv_usb
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Connect instance with selected endpoint
|
||||
* @brief Connect instance with selected endpoint.
|
||||
*
|
||||
* This function configures instance connected to endpoint but also sets
|
||||
* default event handler function pointer.
|
||||
*
|
||||
* @param ep Endpoint number
|
||||
* @param ep Endpoint number.
|
||||
* @param p_cinst The instance to connect into the selected endpoint.
|
||||
* NULL if endpoint is going to be disconnected.
|
||||
*
|
||||
@@ -437,7 +457,7 @@ static void app_usbd_ep_instance_set(nrf_drv_usbd_ep_t ep, app_usbd_class_inst_t
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Call the core handler
|
||||
* @brief Call the core handler.
|
||||
*
|
||||
* Core instance is special kind of instance that is connected only to endpoint 0.
|
||||
* It is not present in instance list.
|
||||
@@ -454,38 +474,74 @@ static inline ret_code_t app_usbd_core_handler_call(app_usbd_internal_evt_t cons
|
||||
|
||||
|
||||
/**
|
||||
* @brief Add event for execution
|
||||
* @brief Add event for execution.
|
||||
*
|
||||
* Dependent on configuration event would be executed in place or would be added into queue
|
||||
* to be executed later.
|
||||
*
|
||||
* @param p_event Event to be executed
|
||||
* @param p_event_input Event to be executed.
|
||||
*/
|
||||
static inline void app_usbd_event_add(app_usbd_internal_evt_t const * const p_event)
|
||||
static inline void app_usbd_event_add(app_usbd_internal_evt_t const * const p_event_input)
|
||||
{
|
||||
app_usbd_internal_evt_t const * p_event = p_event_input;
|
||||
|
||||
|
||||
if (p_event->type == APP_USBD_EVT_DRV_SETUP)
|
||||
{
|
||||
uint8_t bRequest = nrf_usbd_setup_brequest_get();
|
||||
uint8_t bmRequestType = nrf_usbd_setup_bmrequesttype_get();
|
||||
|
||||
if ((bmRequestType == app_usbd_setup_req_val(
|
||||
APP_USBD_SETUP_REQREC_DEVICE,
|
||||
APP_USBD_SETUP_REQTYPE_STD,
|
||||
APP_USBD_SETUP_REQDIR_OUT))
|
||||
&& (bRequest == APP_USBD_SETUP_STDREQ_SET_ADDRESS))
|
||||
{
|
||||
static const app_usbd_internal_evt_t event_setaddress =
|
||||
{
|
||||
.type = APP_USBD_EVT_SETUP_SETADDRESS,
|
||||
};
|
||||
p_event = &event_setaddress;
|
||||
}
|
||||
}
|
||||
|
||||
#if (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE)
|
||||
|
||||
#if (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE)
|
||||
if (p_event->app_evt.type == APP_USBD_EVT_DRV_SOF)
|
||||
{
|
||||
/* Propagate SOF event to classes that need it in interrupt */
|
||||
app_usbd_class_inst_t const * p_inst = app_usbd_class_sof_interrupt_first_get();
|
||||
while (NULL != p_inst)
|
||||
{
|
||||
class_sof_interrupt_handler(p_inst, (app_usbd_complex_evt_t const *)p_event);
|
||||
p_inst = app_usbd_class_sof_interrupt_next_get(p_inst);
|
||||
}
|
||||
|
||||
#if (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE)
|
||||
CRITICAL_REGION_ENTER();
|
||||
if (m_sof_events_cnt == 0)
|
||||
{
|
||||
m_event_frame = p_event->drv_evt.data.sof.framecnt;
|
||||
}
|
||||
UNUSED_RETURN_VALUE(nrf_atomic_u32_add(&m_sof_events_cnt, 1));
|
||||
CRITICAL_REGION_EXIT();
|
||||
|
||||
user_event_handler(p_event, true);
|
||||
if (m_sof_events_cnt == APP_USBD_SOF_WARNING_LIMIT)
|
||||
{
|
||||
NRF_LOG_WARNING("Stacked over %d SOF events.", APP_USBD_SOF_WARNING_LIMIT);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#endif // (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE)
|
||||
|
||||
if (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_INTERRUPT)
|
||||
{
|
||||
if (p_event->app_evt.type == APP_USBD_EVT_DRV_SOF)
|
||||
{
|
||||
user_event_handler(p_event, false);
|
||||
app_usbd_event_execute(p_event);
|
||||
return;
|
||||
}
|
||||
#if (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_INTERRUPT)
|
||||
|
||||
user_event_handler(p_event, false);
|
||||
app_usbd_event_execute(p_event);
|
||||
return;
|
||||
|
||||
#endif // (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_INTERRUPT)
|
||||
}
|
||||
|
||||
nrf_atfifo_item_put_t cx;
|
||||
@@ -497,7 +553,10 @@ static inline void app_usbd_event_add(app_usbd_internal_evt_t const * const p_ev
|
||||
p_event_item->evt = *p_event;
|
||||
|
||||
#if (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE)
|
||||
CRITICAL_REGION_ENTER();
|
||||
p_event_item->start_frame = m_event_frame - m_sof_events_cnt + 1;
|
||||
p_event_item->sof_cnt = nrf_atomic_u32_fetch_store(&m_sof_events_cnt, 0);
|
||||
CRITICAL_REGION_EXIT();
|
||||
#endif // (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE)
|
||||
|
||||
visible = nrf_atfifo_item_put(m_event_queue, &cx);
|
||||
@@ -513,10 +572,10 @@ static inline void app_usbd_event_add(app_usbd_internal_evt_t const * const p_ev
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Power event handler
|
||||
* @brief Power event handler.
|
||||
*
|
||||
* The function that pushes power events into the queue
|
||||
* @param p_event
|
||||
* The function that pushes power events into the queue.
|
||||
* @param p_event Event from power driver to map into APP_USBD_EVT_POWER_ event.
|
||||
*/
|
||||
#if APP_USBD_CONFIG_POWER_EVENTS_PROCESS
|
||||
static void app_usbd_power_event_handler(nrf_drv_power_usb_evt_t event)
|
||||
@@ -554,10 +613,10 @@ static void app_usbd_power_event_handler(nrf_drv_power_usb_evt_t event)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Event handler
|
||||
* @brief Event handler.
|
||||
*
|
||||
* The function that pushes the event into the queue
|
||||
* @param p_event
|
||||
* The function that pushes the event into the queue.
|
||||
* @param p_event Event to push.
|
||||
*/
|
||||
static void app_usbd_event_handler(nrf_drv_usbd_evt_t const * const p_event)
|
||||
{
|
||||
@@ -565,11 +624,11 @@ static void app_usbd_event_handler(nrf_drv_usbd_evt_t const * const p_event)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief HF clock ready event handler
|
||||
* @brief HF clock ready event handler.
|
||||
*
|
||||
* Function that is called when high frequency clock is started
|
||||
* Function that is called when high frequency clock is started.
|
||||
*
|
||||
* @param event Event type that comes from clock driver
|
||||
* @param event Event type that comes from clock driver.
|
||||
*/
|
||||
static void app_usbd_hfclk_ready(nrf_drv_clock_evt_type_t event)
|
||||
{
|
||||
@@ -581,62 +640,62 @@ static void app_usbd_hfclk_ready(nrf_drv_clock_evt_type_t event)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the HFCLK was requested in selected suspend state machine state
|
||||
* @brief Check if the HFCLK was requested in selected suspend state machine state.
|
||||
*
|
||||
*
|
||||
* @param sustate State to be checked
|
||||
* @param sustate State to be checked.
|
||||
*
|
||||
* @retval true High frequency clock was requested in selected state
|
||||
* @retval false High frequency clock was released in selected state
|
||||
* @retval true High frequency clock was requested in selected state.
|
||||
* @retval false High frequency clock was released in selected state.
|
||||
*/
|
||||
static inline bool app_usbd_sustate_with_requested_hfclk(app_usbd_sustate_t sustate)
|
||||
{
|
||||
switch(sustate)
|
||||
{
|
||||
case SUSTATE_STOPPED: return false;
|
||||
case SUSTATE_STARTED: return false;
|
||||
case SUSTATE_ACTIVE: return true;
|
||||
case SUSTATE_SUSPENDING: return false;
|
||||
case SUSTATE_SUSPEND: return false;
|
||||
case SUSTATE_RESUMING: return true;
|
||||
case SUSTATE_WAKINGUP_WAITING_HFCLK_WREQ: return true;
|
||||
case SUSTATE_WAKINGUP_WAITING_HFCLK: return true;
|
||||
case SUSTATE_WAKINGUP_WAITING_WREQ: return true;
|
||||
case SUSTATE_STOPPED: return false;
|
||||
case SUSTATE_STARTED: return false;
|
||||
case SUSTATE_ACTIVE: return true;
|
||||
case SUSTATE_SUSPENDING: return false;
|
||||
case SUSTATE_SUSPEND: return false;
|
||||
case SUSTATE_RESUMING: return true;
|
||||
case SUSTATE_WAKINGUP_WAITING_HFCLK_WREQ: return true;
|
||||
case SUSTATE_WAKINGUP_WAITING_HFCLK: return true;
|
||||
case SUSTATE_WAKINGUP_WAITING_WREQ: return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check it the HFCLK is running in selected suspend state machine state
|
||||
* @brief Check it the HFCLK is running in selected suspend state machine state.
|
||||
*
|
||||
* @param sustate State to be checked
|
||||
* @param sustate State to be checked.
|
||||
*
|
||||
* @retval true High frequency clock is running in selected state
|
||||
* @retval false High frequency clock is released in selected state
|
||||
* @retval true High frequency clock is running in selected state.
|
||||
* @retval false High frequency clock is released in selected state.
|
||||
*/
|
||||
static inline bool app_usbd_sustate_with_running_hfclk(app_usbd_sustate_t sustate)
|
||||
{
|
||||
switch(sustate)
|
||||
{
|
||||
case SUSTATE_STOPPED: return false;
|
||||
case SUSTATE_STARTED: return false;
|
||||
case SUSTATE_ACTIVE: return true;
|
||||
case SUSTATE_SUSPENDING: return false;
|
||||
case SUSTATE_SUSPEND: return false;
|
||||
case SUSTATE_RESUMING: return false;
|
||||
case SUSTATE_WAKINGUP_WAITING_HFCLK_WREQ: return false;
|
||||
case SUSTATE_WAKINGUP_WAITING_HFCLK: return false;
|
||||
case SUSTATE_WAKINGUP_WAITING_WREQ: return true;
|
||||
case SUSTATE_STOPPED: return false;
|
||||
case SUSTATE_STARTED: return false;
|
||||
case SUSTATE_ACTIVE: return true;
|
||||
case SUSTATE_SUSPENDING: return false;
|
||||
case SUSTATE_SUSPEND: return false;
|
||||
case SUSTATE_RESUMING: return false;
|
||||
case SUSTATE_WAKINGUP_WAITING_HFCLK_WREQ: return false;
|
||||
case SUSTATE_WAKINGUP_WAITING_HFCLK: return false;
|
||||
case SUSTATE_WAKINGUP_WAITING_WREQ: return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get current suspend state machine state
|
||||
* @brief Get current suspend state machine state.
|
||||
*
|
||||
* @return The state of the suspend state machine
|
||||
* @return The state of the suspend state machine.
|
||||
*/
|
||||
static inline app_usbd_sustate_t sustate_get(void)
|
||||
{
|
||||
@@ -644,9 +703,9 @@ static inline app_usbd_sustate_t sustate_get(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set current suspend state machine state
|
||||
* @brief Set current suspend state machine state.
|
||||
*
|
||||
* @param sustate The requested state of the state machine
|
||||
* @param sustate The requested state of the state machine.
|
||||
*/
|
||||
static inline void sustate_set(app_usbd_sustate_t sustate)
|
||||
{
|
||||
@@ -680,14 +739,19 @@ static inline void sustate_set(app_usbd_sustate_t sustate)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Default selection function for interface
|
||||
* @brief Default selection function for interface.
|
||||
*
|
||||
* This function just enables and clears interface endpoints
|
||||
* This function just enables and clears interface endpoints.
|
||||
*
|
||||
* @param p_inst See the documentation for @ref app_usbd_iface_select
|
||||
* @param iface_idx See the documentation for @ref app_usbd_iface_select
|
||||
* @param alternate See the documentation for @ref app_usbd_iface_select
|
||||
* @return
|
||||
* @param[in] p_inst Class instance.
|
||||
* @param[in] iface_idx Interface index.
|
||||
* @param[in] alternate Interface alternate setting.
|
||||
*
|
||||
* @note Currently only alternate setting 0 is supported.
|
||||
*
|
||||
* @return Standard error code @ref ret_code_t
|
||||
* @retval NRF_SUCCESS Endpoints enabled and cleared.
|
||||
* @retval NRF_ERROR_INVALID_PARAM Unsupported alternate selected.
|
||||
*/
|
||||
static inline ret_code_t default_iface_select(
|
||||
app_usbd_class_inst_t const * const p_inst,
|
||||
@@ -714,12 +778,12 @@ static inline ret_code_t default_iface_select(
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Default deselection function for interface
|
||||
* @brief Default deselection function for interface.
|
||||
*
|
||||
* This function just disables all interface endpoints.
|
||||
*
|
||||
* @param p_inst See the documentation for @ref app_usbd_iface_deselect
|
||||
* @param iface_idx See the documentation for @ref app_usbd_iface_deselect
|
||||
* @param[in] p_inst Class instance.
|
||||
* @param[in] iface_idx Interface index.
|
||||
*/
|
||||
static inline void default_iface_deselect(
|
||||
app_usbd_class_inst_t const * const p_inst,
|
||||
@@ -858,6 +922,15 @@ ret_code_t app_usbd_uninit(void)
|
||||
(*pp_inst) = NULL;
|
||||
pp_inst = pp_next;
|
||||
}
|
||||
|
||||
/* Unchain SOF interrupt list */
|
||||
pp_inst = &m_p_first_sof_interrupt_cinst;
|
||||
while (NULL != (*pp_inst))
|
||||
{
|
||||
app_usbd_class_inst_t const * * pp_next = &app_usbd_class_data_access(*pp_inst)->p_sof_next;
|
||||
(*pp_inst) = NULL;
|
||||
pp_inst = pp_next;
|
||||
}
|
||||
|
||||
/* Clear all endpoints configurations */
|
||||
memset(m_epin_conf , 0, sizeof(m_epin_conf ));
|
||||
@@ -1008,8 +1081,9 @@ void app_usbd_event_execute(app_usbd_internal_evt_t const * const p_event)
|
||||
app_usbd_all_call((app_usbd_complex_evt_t const *)&evt_data);
|
||||
user_event_state_proc(APP_USBD_EVT_STARTED);
|
||||
|
||||
nrf_drv_usbd_start((NULL != m_p_first_sof_cinst) || (m_current_conf.enable_sof) || (APP_USBD_PROVIDE_SOF_TIMESTAMP));
|
||||
app_usbd_all_iface_deselect();
|
||||
app_usbd_core_ep0_disable();
|
||||
nrf_drv_usbd_start((NULL != m_p_first_sof_cinst) || (m_current_conf.enable_sof) || (APP_USBD_PROVIDE_SOF_TIMESTAMP));
|
||||
sustate_set(SUSTATE_STARTED);
|
||||
break;
|
||||
}
|
||||
@@ -1054,7 +1128,7 @@ void app_usbd_event_execute(app_usbd_internal_evt_t const * const p_event)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break; // Just ignore - it can happen in specyfic situation
|
||||
break; // Just ignore - it can happen in specific situation
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1090,9 +1164,18 @@ void app_usbd_event_execute(app_usbd_internal_evt_t const * const p_event)
|
||||
|
||||
case APP_USBD_EVT_DRV_SOF:
|
||||
{
|
||||
#if (APP_USBD_PROVIDE_SOF_TIMESTAMP) || defined(__SDK_DOXYGEN__)
|
||||
m_last_frame = p_event->drv_evt.data.sof.framecnt;
|
||||
#endif
|
||||
#if (APP_USBD_PROVIDE_SOF_TIMESTAMP) || defined(__SDK_DOXYGEN__)
|
||||
m_last_frame = p_event->drv_evt.data.sof.framecnt;
|
||||
#endif
|
||||
/* Wake up if suspended */
|
||||
if ((sustate_get() == SUSTATE_SUSPENDING) || (sustate_get() == SUSTATE_WAKINGUP_WAITING_WREQ))
|
||||
{
|
||||
static const app_usbd_evt_t evt_data = {
|
||||
.type = APP_USBD_EVT_DRV_RESUME
|
||||
};
|
||||
app_usbd_event_execute((app_usbd_internal_evt_t *)&evt_data);
|
||||
}
|
||||
|
||||
user_event_state_proc(APP_USBD_EVT_DRV_SOF);
|
||||
|
||||
app_usbd_class_inst_t const * p_inst = app_usbd_class_sof_first_get();
|
||||
@@ -1108,6 +1191,7 @@ void app_usbd_event_execute(app_usbd_internal_evt_t const * const p_event)
|
||||
case APP_USBD_EVT_DRV_RESET:
|
||||
{
|
||||
app_usbd_all_iface_deselect();
|
||||
app_usbd_core_ep0_enable();
|
||||
sustate_set(SUSTATE_ACTIVE);
|
||||
user_event_state_proc(APP_USBD_EVT_DRV_RESET);
|
||||
/* Processing core interface (connected only to EP0) and then all instances from the list */
|
||||
@@ -1117,7 +1201,15 @@ void app_usbd_event_execute(app_usbd_internal_evt_t const * const p_event)
|
||||
}
|
||||
case APP_USBD_EVT_DRV_RESUME:
|
||||
{
|
||||
sustate_set(SUSTATE_RESUMING);
|
||||
if (sustate_get() == SUSTATE_WAKINGUP_WAITING_WREQ)
|
||||
{
|
||||
sustate_set(SUSTATE_ACTIVE);
|
||||
nrf_drv_usbd_force_bus_wakeup();
|
||||
}
|
||||
else
|
||||
{
|
||||
sustate_set(SUSTATE_RESUMING);
|
||||
}
|
||||
user_event_state_proc(APP_USBD_EVT_DRV_RESUME);
|
||||
/* Processing core interface (connected only to EP0) and then all instances from the list */
|
||||
UNUSED_RETURN_VALUE(app_usbd_core_handler_call(p_event));
|
||||
@@ -1144,7 +1236,7 @@ void app_usbd_event_execute(app_usbd_internal_evt_t const * const p_event)
|
||||
break;
|
||||
default:
|
||||
{
|
||||
// This should not happen - but try to recover by setting directly active state
|
||||
/* This should not happen - but try to recover by setting directly active state */
|
||||
NRF_LOG_WARNING("Unexpected state on WUREQ event (%u)", sustate_get());
|
||||
sustate_set(SUSTATE_ACTIVE);
|
||||
}
|
||||
@@ -1177,6 +1269,12 @@ void app_usbd_event_execute(app_usbd_internal_evt_t const * const p_event)
|
||||
break;
|
||||
}
|
||||
|
||||
case APP_USBD_EVT_SETUP_SETADDRESS:
|
||||
{
|
||||
UNUSED_RETURN_VALUE(app_usbd_core_handler_call(p_event));
|
||||
break;
|
||||
}
|
||||
|
||||
case APP_USBD_EVT_DRV_EPTRANSFER:
|
||||
{
|
||||
app_usbd_ep_conf_t const * p_ep_conf =
|
||||
@@ -1227,7 +1325,7 @@ void app_usbd_event_execute(app_usbd_internal_evt_t const * const p_event)
|
||||
bool app_usbd_event_queue_process(void)
|
||||
{
|
||||
#if (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE)
|
||||
static app_usbd_internal_evt_t const sof_event = {
|
||||
app_usbd_internal_evt_t sof_event = {
|
||||
.app_evt.type = APP_USBD_EVT_DRV_SOF
|
||||
};
|
||||
#endif // (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE)
|
||||
@@ -1244,8 +1342,13 @@ bool app_usbd_event_queue_process(void)
|
||||
#if (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE)
|
||||
if (p_event_item->sof_cnt > 0)
|
||||
{
|
||||
app_usbd_event_execute(&sof_event);
|
||||
if (p_event_item->start_frame > USBD_FRAMECNTR_FRAMECNTR_Msk)
|
||||
{
|
||||
p_event_item->start_frame = 0;
|
||||
}
|
||||
sof_event.drv_evt.data.sof.framecnt = (p_event_item->start_frame)++;
|
||||
--(p_event_item->sof_cnt);
|
||||
app_usbd_event_execute(&sof_event);
|
||||
return true;
|
||||
}
|
||||
#endif // (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE)
|
||||
@@ -1258,7 +1361,14 @@ bool app_usbd_event_queue_process(void)
|
||||
#if (APP_USBD_CONFIG_SOF_HANDLING_MODE == APP_USBD_SOF_HANDLING_COMPRESS_QUEUE)
|
||||
else if (m_sof_events_cnt > 0)
|
||||
{
|
||||
CRITICAL_REGION_ENTER();
|
||||
if (m_event_frame > USBD_FRAMECNTR_FRAMECNTR_Msk)
|
||||
{
|
||||
m_event_frame = 0;
|
||||
}
|
||||
sof_event.drv_evt.data.sof.framecnt = m_event_frame++;
|
||||
UNUSED_RETURN_VALUE(nrf_atomic_u32_sub_hs(&m_sof_events_cnt, 1));
|
||||
CRITICAL_REGION_EXIT();
|
||||
app_usbd_event_execute(&sof_event);
|
||||
return true;
|
||||
}
|
||||
@@ -1334,7 +1444,7 @@ ret_code_t app_usbd_class_remove(app_usbd_class_inst_t const * p_cinst)
|
||||
ASSERT(NULL != p_cinst);
|
||||
ASSERT(NULL != p_cinst->p_class_methods);
|
||||
ASSERT(NULL != p_cinst->p_class_methods->event_handler);
|
||||
/** This function should be only called if USBD is disabled */
|
||||
/* This function should be only called if USBD is disabled */
|
||||
ASSERT(!nrf_drv_usbd_is_enabled() && nrf_drv_usbd_is_initialized());
|
||||
ret_code_t ret;
|
||||
/* Remove this class from the chain */
|
||||
@@ -1407,7 +1517,7 @@ ret_code_t app_usbd_ep_handler_set(app_usbd_class_inst_t const * const p_cinst,
|
||||
{
|
||||
ASSERT(NULL != p_cinst);
|
||||
ASSERT(NULL != handler);
|
||||
/** This function should be only called if USBD is disabled */
|
||||
/* This function should be only called if USBD is disabled */
|
||||
ASSERT(!nrf_drv_usbd_is_enabled() && nrf_drv_usbd_is_initialized());
|
||||
|
||||
if (p_cinst != app_usbd_ep_instance_get(ep))
|
||||
@@ -1425,17 +1535,24 @@ ret_code_t app_usbd_class_sof_register(app_usbd_class_inst_t const * p_cinst)
|
||||
ASSERT(NULL != p_cinst);
|
||||
ASSERT(NULL != p_cinst->p_class_methods);
|
||||
ASSERT(NULL != p_cinst->p_class_methods->event_handler);
|
||||
/** This function should be only called if USBD is disabled */
|
||||
/* This function should be only called if USBD is disabled */
|
||||
ASSERT(!nrf_drv_usbd_is_enabled() && nrf_drv_usbd_is_initialized());
|
||||
|
||||
/* Next SOF event requiring instance have to be null now */
|
||||
/* Make sure it's not in interrupt SOF list */
|
||||
app_usbd_class_inst_t const * * pp_last = &m_p_first_sof_interrupt_cinst;
|
||||
while (NULL != (*pp_last))
|
||||
{
|
||||
ASSERT((*pp_last) != p_cinst);
|
||||
pp_last = &(app_usbd_class_data_access(*pp_last)->p_sof_next);
|
||||
}
|
||||
|
||||
/* Next SOF event requiring instance has to be NULL now */
|
||||
ASSERT(NULL == (app_usbd_class_data_access(p_cinst)->p_sof_next));
|
||||
|
||||
/* Adding pointer to this instance to the end of the chain */
|
||||
app_usbd_class_inst_t const * * pp_last = &m_p_first_sof_cinst;
|
||||
pp_last = &m_p_first_sof_cinst;
|
||||
while (NULL != (*pp_last))
|
||||
{
|
||||
|
||||
ASSERT((*pp_last) != p_cinst);
|
||||
pp_last = &(app_usbd_class_data_access(*pp_last)->p_sof_next);
|
||||
}
|
||||
@@ -1467,6 +1584,62 @@ ret_code_t app_usbd_class_sof_unregister(app_usbd_class_inst_t const * p_cinst)
|
||||
return NRF_ERROR_NOT_FOUND;
|
||||
}
|
||||
|
||||
ret_code_t app_usbd_class_sof_interrupt_register(app_usbd_class_inst_t const * p_cinst, app_usbd_sof_interrupt_handler_t handler)
|
||||
{
|
||||
ASSERT(NULL != p_cinst);
|
||||
ASSERT(NULL != p_cinst->p_class_methods);
|
||||
ASSERT(NULL != handler);
|
||||
/* This function should be only called if USBD is disabled */
|
||||
ASSERT(!nrf_drv_usbd_is_enabled() && nrf_drv_usbd_is_initialized());
|
||||
|
||||
/* Next SOF event requiring instance has to be NULL now */
|
||||
ASSERT(NULL == (app_usbd_class_data_access(p_cinst)->p_sof_next));
|
||||
|
||||
app_usbd_class_data_access(p_cinst)->sof_handler = handler;
|
||||
|
||||
/* Make sure it's not in normal SOF list */
|
||||
app_usbd_class_inst_t const * * pp_last = &m_p_first_sof_cinst;
|
||||
while (NULL != (*pp_last))
|
||||
{
|
||||
ASSERT((*pp_last) != p_cinst);
|
||||
pp_last = &(app_usbd_class_data_access(*pp_last)->p_sof_next);
|
||||
}
|
||||
|
||||
/* Adding pointer to this instance to the end of the interrupt chain */
|
||||
pp_last = &m_p_first_sof_interrupt_cinst;
|
||||
while (NULL != (*pp_last))
|
||||
{
|
||||
|
||||
ASSERT((*pp_last) != p_cinst);
|
||||
pp_last = &(app_usbd_class_data_access(*pp_last)->p_sof_next);
|
||||
}
|
||||
(*pp_last) = p_cinst;
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ret_code_t app_usbd_class_sof_interrupt_unregister(app_usbd_class_inst_t const * p_cinst)
|
||||
{
|
||||
ASSERT(NULL != p_cinst);
|
||||
/** This function should be only called if USBD is disabled */
|
||||
ASSERT(!nrf_drv_usbd_is_enabled() && nrf_drv_usbd_is_initialized());
|
||||
|
||||
app_usbd_class_inst_t const * * pp_last = &m_p_first_sof_interrupt_cinst;
|
||||
while (NULL != (*pp_last))
|
||||
{
|
||||
if ((*pp_last) == p_cinst)
|
||||
{
|
||||
/* Breaking chain */
|
||||
(*pp_last) = (app_usbd_class_data_access(p_cinst)->p_sof_next);
|
||||
app_usbd_class_data_access(p_cinst)->p_sof_next = NULL;
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
pp_last = &(app_usbd_class_data_access(*pp_last)->p_sof_next);
|
||||
}
|
||||
return NRF_ERROR_NOT_FOUND;
|
||||
}
|
||||
|
||||
ret_code_t app_usbd_class_rwu_register(app_usbd_class_inst_t const * const p_inst)
|
||||
{
|
||||
@@ -1558,6 +1731,11 @@ app_usbd_class_inst_t const * app_usbd_class_sof_first_get(void)
|
||||
return m_p_first_sof_cinst;
|
||||
}
|
||||
|
||||
app_usbd_class_inst_t const * app_usbd_class_sof_interrupt_first_get(void)
|
||||
{
|
||||
return m_p_first_sof_interrupt_cinst;
|
||||
}
|
||||
|
||||
app_usbd_class_inst_t const * app_usbd_iface_find(uint8_t iface, uint8_t * p_iface_idx)
|
||||
{
|
||||
app_usbd_class_inst_t const * p_inst = app_usbd_class_first_get();
|
||||
|
||||
+164
-93
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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 APP_USBD_H__
|
||||
@@ -60,6 +60,11 @@ extern "C" {
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Highest value of Frame Number in SOF packets.
|
||||
*/
|
||||
#define APP_USBD_SOF_MAX 2047
|
||||
|
||||
/**
|
||||
* @brief True if SOF timestamping is really provided.
|
||||
*
|
||||
@@ -139,11 +144,14 @@ typedef struct {
|
||||
* - APP_USBD_EVT_START
|
||||
* - APP_USBD_EVT_STOP
|
||||
* - APP_USBD_EVT_STATE_CHANGED
|
||||
* - APP_USBD_EVT_POWER_DETECTED
|
||||
* - APP_USBD_EVT_POWER_REMOVED
|
||||
* - APP_USBD_EVT_POWER_READY
|
||||
*/
|
||||
void (*ev_state_proc)(app_usbd_event_type_t event);
|
||||
|
||||
/**
|
||||
* @brief SOF processing required by the user event processing
|
||||
* @brief SOF processing required by the user event processing.
|
||||
*
|
||||
* This flag would enable SOF processing for the user events regardless of the fact if any
|
||||
* of the implemented class requires SOF event.
|
||||
@@ -177,20 +185,20 @@ uint32_t app_usbd_sof_timestamp_get(void);
|
||||
ret_code_t app_usbd_init(app_usbd_config_t const * p_config);
|
||||
|
||||
/**
|
||||
* @brief USB library un-initialization
|
||||
* @brief USB library un-initialization.
|
||||
*
|
||||
* @note Currently not supported
|
||||
* @note Currently not supported.
|
||||
*/
|
||||
ret_code_t app_usbd_uninit(void);
|
||||
|
||||
#if (APP_USBD_CONFIG_POWER_EVENTS_PROCESS) || defined(__SDK_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function to start USB related power events processing
|
||||
* @brief Function to start USB related power events processing.
|
||||
*
|
||||
* This function should be called after @ref app_usbd_init and after all the
|
||||
* required classes were appended (@ref app_usbd_class_append).
|
||||
*
|
||||
* @retval NRF_SUCCESS Power events successfully initialized
|
||||
* @retval NRF_SUCCESS Power events successfully initialized.
|
||||
* @retval NRF_ERROR_INVALID_STATE The state of the driver does not allow to enable
|
||||
* the power events processing.
|
||||
*/
|
||||
@@ -198,7 +206,7 @@ ret_code_t app_usbd_power_events_enable(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable USBD
|
||||
* @brief Enable USBD.
|
||||
*
|
||||
* USBD is enabled.
|
||||
* Since now the high frequency clock may be requested when USB RESET would be detected.
|
||||
@@ -206,7 +214,7 @@ ret_code_t app_usbd_power_events_enable(void);
|
||||
void app_usbd_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Disable USBD
|
||||
* @brief Disable USBD.
|
||||
*
|
||||
* Disabled USDB peripheral cannot be accessed but also stops requesting
|
||||
* High Frequency clock and releases power regulator.
|
||||
@@ -216,7 +224,7 @@ void app_usbd_enable(void);
|
||||
void app_usbd_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Request USBD to start
|
||||
* @brief Request USBD to start.
|
||||
*
|
||||
* The function sends start request to the event queue.
|
||||
* If the queue is enabled (@ref APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) it would be processed
|
||||
@@ -245,7 +253,7 @@ void app_usbd_disable(void);
|
||||
void app_usbd_start(void);
|
||||
|
||||
/**
|
||||
* @brief Stop USB to work
|
||||
* @brief Stop USB.
|
||||
*
|
||||
* The function sends stop request to the event queue.
|
||||
* If the queue is enabled (@ref APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) it would be processed
|
||||
@@ -265,7 +273,7 @@ void app_usbd_start(void);
|
||||
void app_usbd_stop(void);
|
||||
|
||||
/**
|
||||
* @brief Request library to suspend
|
||||
* @brief Request library to suspend.
|
||||
*
|
||||
* This function send suspend request to the event queue.
|
||||
*
|
||||
@@ -275,7 +283,7 @@ void app_usbd_stop(void);
|
||||
void app_usbd_suspend_req(void);
|
||||
|
||||
/**
|
||||
* @brief Request library to wake-up
|
||||
* @brief Request library to wake-up.
|
||||
*
|
||||
* This function send wakeup request to the event queue.
|
||||
*
|
||||
@@ -298,7 +306,7 @@ bool app_usbd_wakeup_req(void);
|
||||
bool app_usbd_active_check(void);
|
||||
|
||||
/**
|
||||
* @brief USBD event processor
|
||||
* @brief USBD event processor.
|
||||
*
|
||||
* Function to be called on each event to be processed by the library.
|
||||
*/
|
||||
@@ -307,18 +315,18 @@ void app_usbd_event_execute(app_usbd_internal_evt_t const * const p_event);
|
||||
|
||||
#if (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE) || defined(__SDK_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function that process events from the queue
|
||||
* @brief Function that process events from the queue.
|
||||
*
|
||||
* @note This function calls @ref app_usbd_event_execute internally.
|
||||
*
|
||||
* @retval true Event was processed
|
||||
* @retval false The event queue is empty
|
||||
* @retval true Event was processed.
|
||||
* @retval false The event queue is empty.
|
||||
*/
|
||||
bool app_usbd_event_queue_process(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Add class instance
|
||||
* @brief Add class instance.
|
||||
*
|
||||
* This function connects given instance into internal class instance chain and
|
||||
* into all required endpoints.
|
||||
@@ -331,11 +339,14 @@ bool app_usbd_event_queue_process(void);
|
||||
* Assertion would be generated otherwise.
|
||||
*
|
||||
* @param[in,out] p_cinst Instance to connect. Chain data would be written into writable instance data.
|
||||
*
|
||||
* @retval NRF_SUCCESS Instance successfully added.
|
||||
* @retval NRF_ERROR_BUSY Endpoint(s) not available.
|
||||
*/
|
||||
ret_code_t app_usbd_class_append(app_usbd_class_inst_t const * p_cinst);
|
||||
|
||||
/**
|
||||
* @brief Remove class instance
|
||||
* @brief Remove class instance.
|
||||
*
|
||||
* Instance is removed from instance chain.
|
||||
* Instance and event handlers are removed also from endpoints.
|
||||
@@ -352,7 +363,7 @@ ret_code_t app_usbd_class_append(app_usbd_class_inst_t const * p_cinst);
|
||||
ret_code_t app_usbd_class_remove(app_usbd_class_inst_t const * p_cinst);
|
||||
|
||||
/**
|
||||
* @brief Remove all class instances
|
||||
* @brief Remove all class instances.
|
||||
*
|
||||
* This function basically calls @ref app_usbd_class_remove
|
||||
* on instances chain as long as there is any element left.
|
||||
@@ -368,7 +379,7 @@ ret_code_t app_usbd_class_remove(app_usbd_class_inst_t const * p_cinst);
|
||||
ret_code_t app_usbd_class_remove_all(void);
|
||||
|
||||
/**
|
||||
* @brief Change endpoint handler
|
||||
* @brief Change endpoint handler.
|
||||
*
|
||||
* This function may be called for the endpoint only if the class instance is
|
||||
* already properly attached by the @ref app_usbd_class_append function.
|
||||
@@ -393,7 +404,7 @@ ret_code_t app_usbd_ep_handler_set(app_usbd_class_inst_t const * p_cinst,
|
||||
app_usbd_ep_event_handler_t handler);
|
||||
|
||||
/**
|
||||
* @brief Register class instance as the one that requires SOF events
|
||||
* @brief Register class instance as the one that requires SOF events.
|
||||
*
|
||||
* This function should be called in reaction on APP_USBD_EVT_INST_APPEND event.
|
||||
* Connect the class instance to the list of instances that requires SOF processing.
|
||||
@@ -408,7 +419,7 @@ ret_code_t app_usbd_ep_handler_set(app_usbd_class_inst_t const * p_cinst,
|
||||
ret_code_t app_usbd_class_sof_register(app_usbd_class_inst_t const * p_cinst);
|
||||
|
||||
/**
|
||||
* @brief Unregister class instance from SOF processing instances list
|
||||
* @brief Unregister class instance from SOF processing instances list.
|
||||
*
|
||||
* Every class that calls @ref app_usbd_class_sof_register have to call also unregistering function
|
||||
* in reaction to @ref APP_USBD_EVT_INST_REMOVE event.
|
||||
@@ -423,47 +434,80 @@ ret_code_t app_usbd_class_sof_register(app_usbd_class_inst_t const * p_cinst);
|
||||
ret_code_t app_usbd_class_sof_unregister(app_usbd_class_inst_t const * p_cinst);
|
||||
|
||||
/**
|
||||
* @brief Register class on remote wake-up feature
|
||||
* @brief Register class instance as the one that requires SOF events in interrupt.
|
||||
*
|
||||
* @param[in] p_inst Instance of the class
|
||||
* This function should be called in reaction on APP_USBD_EVT_INST_APPEND event.
|
||||
* Connect the class instance to the list of instances that requires SOF processing.
|
||||
* If none of the appended instances requires SOF event - it is disabled.
|
||||
*
|
||||
* @retval NRF_SUCCESS Instance that requires remote wake-up registered
|
||||
* @param p_cinst Instance that requires SOF event.
|
||||
* @param handler Handler to SOF event
|
||||
*
|
||||
* @retval NRF_SUCCESS Instance linked into SOF processing list.
|
||||
*
|
||||
* @sa app_usbd_class_sof_interrupt_unregister
|
||||
*/
|
||||
ret_code_t app_usbd_class_sof_interrupt_register(app_usbd_class_inst_t const * p_cinst,
|
||||
app_usbd_sof_interrupt_handler_t handler);
|
||||
|
||||
/**
|
||||
* @brief Unregister class instance from SOF processing in interrupt instances list.
|
||||
*
|
||||
* Every class that calls @ref app_usbd_class_sof_interrupt_register have to call
|
||||
* also unregistering function in reaction to @ref APP_USBD_EVT_INST_REMOVE event.
|
||||
*
|
||||
* @param p_cinst Instance to be unregistered from SOF processing in interrupt list.
|
||||
*
|
||||
* @retval NRF_SUCCESS Instance linked into SOF processing in interrupt list.
|
||||
* @retval NRF_ERROR_NOT_FOUND Instance not found in the SOF processing in interrupt list.
|
||||
*
|
||||
* @sa app_usbd_class_sof_interrupt_register
|
||||
*/
|
||||
ret_code_t app_usbd_class_sof_interrupt_unregister(app_usbd_class_inst_t const * p_cinst);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Register class on remote wake-up feature.
|
||||
*
|
||||
* @param[in] p_inst Instance of the class.
|
||||
*
|
||||
* @retval NRF_SUCCESS Instance that requires remote wake-up registered.
|
||||
*/
|
||||
ret_code_t app_usbd_class_rwu_register(app_usbd_class_inst_t const * const p_inst);
|
||||
|
||||
/**
|
||||
* @brief Unregister class from remote wake-up feature
|
||||
* @brief Unregister class from remote wake-up feature.
|
||||
*
|
||||
* @param[in] p_inst Instance of the class
|
||||
* @param[in] p_inst Instance of the class.
|
||||
*
|
||||
* @retval NRF_SUCCESS Instance that requires remote wake-up removed
|
||||
* @retval NRF_SUCCESS Instance that requires remote wake-up removed.
|
||||
*/
|
||||
ret_code_t app_usbd_class_rwu_unregister(app_usbd_class_inst_t const * const p_inst);
|
||||
|
||||
/**
|
||||
* @brief Check if there is any class with remote wakeup
|
||||
* @brief Check if there is any class with remote wakeup.
|
||||
*
|
||||
* The function checks internal registered class with remote wakeup counter.
|
||||
*
|
||||
* @sa app_usbd_class_rwu_register, app_usbd_class_rwu_unregister
|
||||
*
|
||||
* @retval true The remote wakeup functionality is required by some class instance
|
||||
* @retval false There is no class instance that requires wakeup functionality
|
||||
* @retval true The remote wakeup functionality is required by some class instance.
|
||||
* @retval false There is no class instance that requires wakeup functionality.
|
||||
*/
|
||||
bool app_usbd_class_rwu_enabled_check(void);
|
||||
|
||||
/**
|
||||
* @brief Find a specified descriptor
|
||||
* @brief Find a specified descriptor.
|
||||
*
|
||||
* @param[in] p_cinst Class instance
|
||||
* @param[in] desc_type Descriptor type @ref app_usbd_descriptor_t
|
||||
* @param[in] desc_index Descriptor index
|
||||
* @param[out] p_desc Pointer to escriptor
|
||||
* @param[out] p_desc_len Length of descriptor
|
||||
* @param[in] p_cinst Class instance.
|
||||
* @param[in] desc_type Descriptor type @ref app_usbd_descriptor_t
|
||||
* @param[in] desc_index Descriptor index.
|
||||
* @param[out] p_desc Pointer to escriptor.
|
||||
* @param[out] p_desc_len Length of descriptor.
|
||||
*
|
||||
* @return Standard error code @ref ret_code_t
|
||||
* @retval NRF_SUCCESS descriptor successfully found
|
||||
* @retval NRF_ERROR_NOT_FOUND descriptor not found
|
||||
* @retval NRF_SUCCESS Descriptor successfully found.
|
||||
* @retval NRF_ERROR_NOT_FOUND Descriptor not found.
|
||||
* */
|
||||
ret_code_t app_usbd_class_descriptor_find(app_usbd_class_inst_t const * const p_cinst,
|
||||
uint8_t desc_type,
|
||||
@@ -472,35 +516,34 @@ ret_code_t app_usbd_class_descriptor_find(app_usbd_class_inst_t const * const p_
|
||||
size_t * p_desc_len);
|
||||
|
||||
/**
|
||||
* @brief Standard set interface request handle
|
||||
* @brief Standard set interface request handle.
|
||||
*
|
||||
* This function should be called when processing SET_INTERFACE request.
|
||||
*
|
||||
* @param[in] p_cinst Instance of a class
|
||||
* @param[in] iface Interface number
|
||||
* @param[in] p_cinst Instance of a class.
|
||||
* @param[in] iface Interface number.
|
||||
*
|
||||
* @return Standard error code
|
||||
* @return Standard error code.
|
||||
*
|
||||
* @note Selected interface to reset has to be part of given class.
|
||||
* In other case
|
||||
* */
|
||||
ret_code_t app_usbd_interface_ep_reset(app_usbd_class_inst_t const * const p_cinst,
|
||||
uint8_t iface);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Enable selected endpoint
|
||||
* @brief Enable selected endpoint.
|
||||
*
|
||||
* Selected endpoint is enabled and cleared.
|
||||
*
|
||||
* @param ep Endpoint number
|
||||
* @param ep Endpoint number.
|
||||
*/
|
||||
void app_usbd_ep_enable(nrf_drv_usbd_ep_t ep);
|
||||
|
||||
/**
|
||||
* @brief Disable selected endpoint
|
||||
* @brief Disable selected endpoint.
|
||||
*
|
||||
* @param ep Endpoint number
|
||||
* @param ep Endpoint number.
|
||||
*/
|
||||
void app_usbd_ep_disable(nrf_drv_usbd_ep_t ep);
|
||||
|
||||
@@ -511,7 +554,7 @@ void app_usbd_ep_disable(nrf_drv_usbd_ep_t ep);
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Get first class instance in the list
|
||||
* @brief Get first class instance in the list.
|
||||
*
|
||||
* Get first instance from the list of active class instances.
|
||||
* That instance may be used then in @ref app_usbd_class_next_get function.
|
||||
@@ -521,7 +564,7 @@ void app_usbd_ep_disable(nrf_drv_usbd_ep_t ep);
|
||||
app_usbd_class_inst_t const * app_usbd_class_first_get(void);
|
||||
|
||||
/**
|
||||
* @brief Get next instance in the list
|
||||
* @brief Get next instance in the list.
|
||||
*
|
||||
* Get the next instance from the list of active instances.
|
||||
* Used to iterate through all instances.
|
||||
@@ -538,18 +581,18 @@ void app_usbd_ep_disable(nrf_drv_usbd_ep_t ep);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get first instance in SOF list
|
||||
* @brief Get first instance in SOF list.
|
||||
*
|
||||
* Start iteration through the list of instances that requires SOF event processing.
|
||||
* Start iteration through the list of instances that require SOF event processing.
|
||||
*
|
||||
* @return First instance in the list or NULL if the list is empty
|
||||
* @return First instance in the list or NULL if the list is empty.
|
||||
*
|
||||
* @sa app_usbd_class_first_get
|
||||
*/
|
||||
app_usbd_class_inst_t const * app_usbd_class_sof_first_get(void);
|
||||
|
||||
/**
|
||||
* @brief Get next instance in the SOF list
|
||||
* @brief Get next instance in the SOF list.
|
||||
*
|
||||
* Get the next instance from the list of instances requiring SOF event processing.
|
||||
* Used to iterate through all SOF instances.
|
||||
@@ -564,15 +607,43 @@ void app_usbd_ep_disable(nrf_drv_usbd_ep_t ep);
|
||||
ASSERT(NULL != p_cinst);
|
||||
return app_usbd_class_data_access(p_cinst)->p_sof_next;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get first instance in SOF interrupt list.
|
||||
*
|
||||
* Start iteration through the list of instances that require SOF processing in interrupt.
|
||||
*
|
||||
* @return First instance in the list or NULL if the list is empty.
|
||||
*
|
||||
* @sa app_usbd_class_first_get
|
||||
*/
|
||||
app_usbd_class_inst_t const * app_usbd_class_sof_interrupt_first_get(void);
|
||||
|
||||
/**
|
||||
* @brief Get next instance in the SOF interrupt list.
|
||||
*
|
||||
* Get the next instance from the list of instances requiring SOF processing in interrupt.
|
||||
* Used to iterate through all SOF instances that have SOF handlers.
|
||||
*
|
||||
* @param p_cinst The current instance from with next one is required.
|
||||
*
|
||||
* @return Next instance to the given one or NULL if there is no more instances in the list.
|
||||
*/
|
||||
static inline app_usbd_class_inst_t const * app_usbd_class_sof_interrupt_next_get(
|
||||
app_usbd_class_inst_t const * const p_cinst)
|
||||
{
|
||||
ASSERT(NULL != p_cinst);
|
||||
return app_usbd_class_data_access(p_cinst)->p_sof_next;
|
||||
}
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Search for selected interface
|
||||
* @brief Search for selected interface.
|
||||
*
|
||||
* Function searches for the given interface number and returns the class that contains it.
|
||||
* Optionally it can return interface index inside class instance.
|
||||
*
|
||||
* @param[in] iface Interface number
|
||||
* @param[in] iface Interface number.
|
||||
* @param[out] p_iface_idx Pointer to a variable that would hold interface index inside returned
|
||||
* class instance.
|
||||
*
|
||||
@@ -588,14 +659,14 @@ app_usbd_class_inst_t const * app_usbd_iface_find(uint8_t iface, uint8_t * p_ifa
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Call interface event handler
|
||||
* @brief Call interface event handler.
|
||||
*
|
||||
* Call event handler for selected interface.
|
||||
* @param[in,out] p_class_inst Class instance that holds selected interface
|
||||
* @param[in] iface_idx Index of the interface in class structure
|
||||
* @param[in] p_event Event structure to be processed
|
||||
* @param[in,out] p_class_inst Class instance that holds selected interface.
|
||||
* @param[in] iface_idx Index of the interface in class structure.
|
||||
* @param[in] p_event Event structure to be processed.
|
||||
*
|
||||
* @return Operation status
|
||||
* @return Operation status.
|
||||
*/
|
||||
ret_code_t app_usbd_iface_call(
|
||||
app_usbd_class_inst_t const * const p_class_inst,
|
||||
@@ -603,30 +674,30 @@ app_usbd_class_inst_t const * app_usbd_iface_find(uint8_t iface, uint8_t * p_ifa
|
||||
app_usbd_complex_evt_t const * const p_event);
|
||||
|
||||
/**
|
||||
* @brief Call endpoint event handler
|
||||
* @brief Call endpoint event handler.
|
||||
*
|
||||
* Call event handler for the selected endpoint.
|
||||
* @param[in] ep Endpoint number
|
||||
* @param[in] p_event Event structure to send
|
||||
* @param[in] ep Endpoint number.
|
||||
* @param[in] p_event Event structure to send.
|
||||
*
|
||||
* @return Operation status
|
||||
* @return Operation status.
|
||||
*/
|
||||
ret_code_t app_usbd_ep_call(nrf_drv_usbd_ep_t ep, app_usbd_complex_evt_t const * const p_event);
|
||||
|
||||
/**
|
||||
* @brief Auxiliary function that process event by every instance in the list
|
||||
* @brief Auxiliary function that process event by every instance in the list.
|
||||
*
|
||||
* This function ignores the result of called handler.
|
||||
*
|
||||
* @param p_event Event to pass to every instance
|
||||
* @param p_event Event to pass to every instance.
|
||||
*/
|
||||
void app_usbd_all_call(app_usbd_complex_evt_t const * const p_event);
|
||||
|
||||
/**
|
||||
* @brief Call interface event handlers and stop when served
|
||||
* @brief Call interface event handlers and stop when served.
|
||||
*
|
||||
* Call event handlers from instances as long as we get result different than @ref NRF_ERROR_NOT_SUPPORTED
|
||||
* @param[in] p_event Event structure to send
|
||||
* @param[in] p_event Event structure to send.
|
||||
*
|
||||
* @return Operation status or @ref NRF_ERROR_NOT_SUPPORTED if none of instances in the list can support given event.
|
||||
*/
|
||||
@@ -634,16 +705,16 @@ app_usbd_class_inst_t const * app_usbd_iface_find(uint8_t iface, uint8_t * p_ifa
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Endpoint transfer
|
||||
* @brief Endpoint transfer.
|
||||
*
|
||||
* @param ep Endpoint number
|
||||
* @param ep Endpoint number.
|
||||
* @param p_transfer Description of the transfer to be performed.
|
||||
* The direction of the transfer is determined by the
|
||||
* endpoint number.
|
||||
*
|
||||
* @retval NRF_ERROR_INVALID_STATE The state of the USB device does not allow
|
||||
* data transfer on the endpoint.
|
||||
* @return Values returned by @ref nrf_drv_usbd_ep_transfer
|
||||
* @return Values returned by @ref nrf_drv_usbd_ep_transfer.
|
||||
*
|
||||
* @sa app_usbd_ep_handled_transfer
|
||||
*/
|
||||
@@ -677,11 +748,11 @@ ret_code_t app_usbd_ep_handled_transfer(
|
||||
*
|
||||
* After calling this function interface should be functional.
|
||||
*
|
||||
* @param[in,out] p_inst Instance of the class
|
||||
* @param[in] iface_idx Index of the interface inside class structure
|
||||
* @param[in] alternate Alternate setting that should be selected
|
||||
* @param[in,out] p_inst Instance of the class.
|
||||
* @param[in] iface_idx Index of the interface inside class structure.
|
||||
* @param[in] alternate Alternate setting that should be selected.
|
||||
*
|
||||
* @return Standard Error code
|
||||
* @return Standard error code.
|
||||
*/
|
||||
ret_code_t app_usbd_iface_select(
|
||||
app_usbd_class_inst_t const * const p_inst,
|
||||
@@ -690,7 +761,7 @@ ret_code_t app_usbd_iface_select(
|
||||
|
||||
|
||||
/**
|
||||
* @brief Deselect interface
|
||||
* @brief Deselect interface.
|
||||
*
|
||||
* Disable the given interface.
|
||||
* This function calls class interface deselection function or
|
||||
@@ -699,38 +770,38 @@ ret_code_t app_usbd_iface_select(
|
||||
* After calling this function all the endpoints from the interface
|
||||
* have to be disabled.
|
||||
*
|
||||
* @param[in,out] p_inst Instance of the class
|
||||
* @param[in] iface_idx Index of the interface inside class structure
|
||||
* @param[in,out] p_inst Instance of the class.
|
||||
* @param[in] iface_idx Index of the interface inside class structure.
|
||||
*/
|
||||
void app_usbd_iface_deselect(
|
||||
app_usbd_class_inst_t const * const p_inst,
|
||||
uint8_t iface_idx);
|
||||
|
||||
/**
|
||||
* @brief Get selected interface
|
||||
* @brief Get selected interface.
|
||||
*
|
||||
* Function retieves currently selected interface.
|
||||
* If the class contains @ref app_usbd_class_methods_t::iface_selection_get it is called.
|
||||
* It it does not contain this function this function would return default, 0 value.
|
||||
*
|
||||
* @param[in] p_inst Instance of the class
|
||||
* @param[in] iface_idx Index of the interface inside class structure
|
||||
* @param[in] p_inst Instance of the class.
|
||||
* @param[in] iface_idx Index of the interface inside class structure.
|
||||
*
|
||||
* @return Selected alternate interface setting
|
||||
* @return Selected alternate interface setting.
|
||||
*/
|
||||
uint8_t app_usbd_iface_selection_get(
|
||||
app_usbd_class_inst_t const * const p_inst,
|
||||
uint8_t iface_idx);
|
||||
|
||||
/**
|
||||
* @brief Select alternate configuration 0 for all interfaces
|
||||
* @brief Select alternate configuration 0 for all interfaces.
|
||||
*
|
||||
* Auxiliary function that clears settings for all interfaces leaving them enabled.
|
||||
*/
|
||||
void app_usbd_all_iface_select_0(void);
|
||||
|
||||
/**
|
||||
* @brief Deselect all interfaces
|
||||
* @brief Deselect all interfaces.
|
||||
*
|
||||
* Auxiliary function to disable all interfaces.
|
||||
*/
|
||||
|
||||
+168
-143
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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 APP_USBD_CLASS_BASE_H__
|
||||
@@ -66,7 +66,7 @@ extern "C" {
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Endpoint configuration
|
||||
* @brief Endpoint configuration.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
@@ -74,7 +74,7 @@ typedef struct
|
||||
} app_usbd_class_ep_conf_t;
|
||||
|
||||
/**
|
||||
* @brief Interface configuration
|
||||
* @brief Interface configuration.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
@@ -87,35 +87,47 @@ typedef struct
|
||||
} app_usbd_class_iface_conf_t;
|
||||
|
||||
/**
|
||||
* @brief Instance variable data
|
||||
* @brief Instance variable data.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
app_usbd_class_inst_t const * p_next; //!< Pointer to the next instance
|
||||
app_usbd_class_inst_t const * p_sof_next; //!< Pointer to the next SOF event requiring instance
|
||||
app_usbd_class_inst_t const * p_next; //!< Pointer to the next instance
|
||||
app_usbd_class_inst_t const * p_sof_next; //!< Pointer to the next SOF event requiring instance
|
||||
app_usbd_sof_interrupt_handler_t sof_handler; //!< Instance specific SOF interrupt handler
|
||||
} app_usbd_class_data_t;
|
||||
|
||||
/**
|
||||
* @brief Class descriptor context
|
||||
* @brief Class descriptor context.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t line; //!< Number of line to resume writing descriptors from
|
||||
uint32_t line; //!< Number of line to resume writing descriptors from
|
||||
uint8_t data_buffer; //!< Data from last call of feeder
|
||||
} app_usbd_class_descriptor_ctx_t;
|
||||
|
||||
/**
|
||||
* @brief Class descriptor state.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t * p_buffer; //!< Pointer to buffer
|
||||
uint32_t current_size; //!< Current size of descriptor
|
||||
uint32_t maximum_size; //!< Maximum size of descriptor
|
||||
app_usbd_class_descriptor_ctx_t * p_context; //!< Pointer to context
|
||||
} app_usbd_class_descriptor_state_t;
|
||||
|
||||
/**
|
||||
* @brief Class interface function set
|
||||
* @brief Class interface function set.
|
||||
* */
|
||||
typedef struct {
|
||||
/**
|
||||
* @brief Instance callback function
|
||||
* @brief Instance callback function.
|
||||
*
|
||||
* The function used by every class instance.
|
||||
* @param[in,out] p_inst Instance of the class
|
||||
* @param[in] p_event Event to process
|
||||
* @param[in,out] p_inst Instance of the class.
|
||||
* @param[in] p_event Event to process.
|
||||
*
|
||||
* @return Standard error code
|
||||
* @return Standard error code.
|
||||
*
|
||||
* @note If given event is not supported by class, return @ref NRF_ERROR_NOT_SUPPORTED
|
||||
*/
|
||||
@@ -123,15 +135,15 @@ typedef struct {
|
||||
app_usbd_complex_evt_t const * const p_event);
|
||||
|
||||
/**
|
||||
* @brief Instance feed descriptors
|
||||
* @brief Instance feed descriptors.
|
||||
*
|
||||
* Feeds whole descriptor of the instance
|
||||
* @param[in] p_ctx Class descriptor context
|
||||
* @param[in,out] p_inst Instance of the class
|
||||
* @param[out] p_buff Buffer for descriptor
|
||||
* @param[in] max_size Requested size of the descriptor
|
||||
* Feeds whole descriptor of the instance.
|
||||
* @param[in] p_ctx Class descriptor context.
|
||||
* @param[in,out] p_inst Instance of the class.
|
||||
* @param[out] p_buff Buffer for descriptor.
|
||||
* @param[in] max_size Requested size of the descriptor.
|
||||
*
|
||||
* @return True if not finished feeding the descriptor, false if done
|
||||
* @return True if not finished feeding the descriptor, false if done.
|
||||
*/
|
||||
bool (* feed_descriptors)(app_usbd_class_descriptor_ctx_t * p_ctx,
|
||||
app_usbd_class_inst_t const * p_inst,
|
||||
@@ -170,7 +182,7 @@ typedef struct {
|
||||
uint8_t alternate);
|
||||
|
||||
/**
|
||||
* @brief Deselect interface
|
||||
* @brief Deselect interface.
|
||||
*
|
||||
* Function called when the class interface has to be deselected.
|
||||
*
|
||||
@@ -186,20 +198,20 @@ typedef struct {
|
||||
* @note If this function pointer is NULL default procedure would
|
||||
* just disable all the interface endpoints.
|
||||
*
|
||||
* @param[in,out] p_inst Instance of the class
|
||||
* @param[in] iface_idx Index of the interface inside class structure
|
||||
* @param[in,out] p_inst Instance of the class.
|
||||
* @param[in] iface_idx Index of the interface inside class structure.
|
||||
*/
|
||||
void (* iface_deselect)(app_usbd_class_inst_t const * const p_inst, uint8_t iface_idx);
|
||||
|
||||
/**
|
||||
* @brief Get current interface
|
||||
* @brief Get current interface.
|
||||
*
|
||||
* Function called when class interface has to return its alternate settings
|
||||
* in reaction on GET_INTERFACE command.
|
||||
* It should be defined in a pair with @ref app_usbd_class_methods_t::iface_select.
|
||||
*
|
||||
* @param[in] p_inst Instance of the class
|
||||
* @param[in] iface_idx Index of the interface inside class structure
|
||||
* @param[in] p_inst Instance of the class.
|
||||
* @param[in] iface_idx Index of the interface inside class structure.
|
||||
*
|
||||
* @return Current alternate setting of the selected interface.
|
||||
*
|
||||
@@ -214,9 +226,9 @@ typedef struct {
|
||||
} app_usbd_class_methods_t;
|
||||
|
||||
/**
|
||||
* @brief The instance structure itself
|
||||
* @brief The instance structure itself.
|
||||
*
|
||||
* The structure of base class instance
|
||||
* The structure of base class instance.
|
||||
*/
|
||||
struct app_usbd_class_inst_s
|
||||
{
|
||||
@@ -231,7 +243,7 @@ struct app_usbd_class_inst_s
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get total number of interfaces
|
||||
* @brief Get total number of interfaces.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@@ -241,11 +253,11 @@ static inline uint8_t app_usbd_class_iface_count_get(app_usbd_class_inst_t const
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Interface accessing function
|
||||
* @brief Interface accessing function.
|
||||
*
|
||||
* Get interface pointer.
|
||||
* Interfaces creates continuous array in the memory so it is possible to get
|
||||
* interface with index 0 and the just iterate to the next one.
|
||||
* Interfaces create continuous array in the memory so it is possible to get
|
||||
* interface with index 0 and then just iterate to the next one.
|
||||
*
|
||||
* @param p_inst Pointer to the class instance
|
||||
* @param iface_idx Index of the instance to get.
|
||||
@@ -269,11 +281,11 @@ static inline app_usbd_class_iface_conf_t const * app_usbd_class_iface_get(
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get interface number
|
||||
* @brief Get interface number.
|
||||
*
|
||||
* @param p_iface Pointer to interface structure
|
||||
* @param p_iface Pointer to interface structure.
|
||||
*
|
||||
* @return Interface number from interface configuration structure
|
||||
* @return Interface number from interface configuration structure.
|
||||
*/
|
||||
static inline uint8_t app_usbd_class_iface_number_get(
|
||||
app_usbd_class_iface_conf_t const * const p_iface)
|
||||
@@ -282,11 +294,11 @@ static inline uint8_t app_usbd_class_iface_number_get(
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get number of endpoints in interface
|
||||
* @brief Get number of endpoints in interface.
|
||||
*
|
||||
* @param p_iface Pointer to interface structure
|
||||
* @param p_iface Pointer to interface structure.
|
||||
*
|
||||
* @return Number of endpoints used by given interface
|
||||
* @return Number of endpoints used by given interface.
|
||||
*/
|
||||
static inline uint8_t app_usbd_class_iface_ep_count_get(
|
||||
app_usbd_class_iface_conf_t const * const p_iface)
|
||||
@@ -295,10 +307,10 @@ static inline uint8_t app_usbd_class_iface_ep_count_get(
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Interface Endpoint accessing function
|
||||
* @brief Interface Endpoint accessing function.
|
||||
*
|
||||
* @param p_iface Interface configuration pointer
|
||||
* @param ep_idx Endpoint index
|
||||
* @param p_iface Interface configuration pointer.
|
||||
* @param ep_idx Endpoint index.
|
||||
*
|
||||
* @return Endpoint information structure pointer or NULL if given index is outside of endpoints for selected interface.
|
||||
*
|
||||
@@ -320,12 +332,12 @@ static inline app_usbd_class_ep_conf_t const * app_usbd_class_iface_ep_get(
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Translate endpoint address to class index
|
||||
* @brief Translate endpoint address to class index.
|
||||
*
|
||||
* @param p_iface Interface configuration pointer
|
||||
* @param ep_address Endpoint address
|
||||
* @param p_iface Interface configuration pointer.
|
||||
* @param ep_address Endpoint address.
|
||||
*
|
||||
* @return Endpoint index or number of endpoints if not found
|
||||
* @return Endpoint index or number of endpoints if not found.
|
||||
*
|
||||
*/
|
||||
static inline uint8_t app_usbd_class_iface_ep_idx_get(
|
||||
@@ -349,9 +361,9 @@ static inline uint8_t app_usbd_class_iface_ep_idx_get(
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the selected endpoint address
|
||||
* @brief Get the selected endpoint address.
|
||||
*
|
||||
* @param p_ep Endpoint configuration structure
|
||||
* @param p_ep Endpoint configuration structure.
|
||||
*
|
||||
* @return Endpoint address
|
||||
*/
|
||||
@@ -361,10 +373,10 @@ static inline nrf_drv_usbd_ep_t app_usbd_class_ep_address_get(app_usbd_class_ep_
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the pointer to the writable instance data
|
||||
* @brief Get the pointer to the writable instance data.
|
||||
*
|
||||
* @param p_inst Instance pointer
|
||||
* @return Pointer to writable instance data
|
||||
* @param p_inst Instance pointer.
|
||||
* @return Pointer to writable instance data.
|
||||
*/
|
||||
static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
app_usbd_class_inst_t const * const p_inst)
|
||||
@@ -379,7 +391,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Count the number of endpoints in given configuration
|
||||
* @brief Count the number of endpoints in given configuration.
|
||||
*
|
||||
* Config should be given as a interface configuration in a brackets:
|
||||
* @code
|
||||
@@ -388,7 +400,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
* Number of endpoints may vary from 0 to a few (technically up to 16, but it seems not to make sense to use more than 4).
|
||||
* Interface number is always present.
|
||||
*
|
||||
* @param iface_config Single interface configuration (in brackets)
|
||||
* @param iface_config Single interface configuration (in brackets).
|
||||
*
|
||||
* @return Number of endpoints in interface. This is computed value - can be used by compiler but not by preprocessor.
|
||||
*/
|
||||
@@ -396,7 +408,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
(NUM_VA_ARGS(BRACKET_EXTRACT(iface_config)) - 1)
|
||||
|
||||
/**
|
||||
* @brief Adds the number of endpoints in given config to the current value
|
||||
* @brief Adds the number of endpoints in given config to the current value.
|
||||
*
|
||||
* This is basically @ref APP_USBD_CLASS_CONF_IFACE_EP_COUNT_ with plus sign added.
|
||||
*
|
||||
@@ -410,11 +422,11 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
+ APP_USBD_CLASS_CONF_IFACE_EP_COUNT_(iface_config)
|
||||
|
||||
/**
|
||||
* @brief Create variable for endpoint
|
||||
* @brief Create variable for endpoint.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Extract endpoints given interface configuration
|
||||
* @brief Extract endpoints given interface configuration.
|
||||
*
|
||||
* This macro gets single endpoint configuration and extracts all the endpoints.
|
||||
* It also adds comma on the end of extracted endpoints.
|
||||
@@ -432,43 +444,51 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
/**
|
||||
* @brief Auxiliary macro for @ref APP_USBD_CLASS_IFACE_EP_EXTRACT_
|
||||
*
|
||||
* This macro is called when interface has no endpoints
|
||||
* This macro is called when interface has no endpoints.
|
||||
*/
|
||||
#define APP_USBD_CLASS_IFACE_EP_EXTRACT_0(iface_nr)
|
||||
|
||||
/**
|
||||
* @brief Auxiliary macro for @ref APP_USBD_CLASS_IFACE_EP_EXTRACT_
|
||||
*
|
||||
* This macro is called when interface has at least one endpoint
|
||||
* This macro is called when interface has at least one endpoint.
|
||||
*/
|
||||
#define APP_USBD_CLASS_IFACE_EP_EXTRACT_1(...) \
|
||||
APP_USBD_CLASS_IFACE_EP_EXTRACT_1_(__VA_ARGS__)
|
||||
|
||||
#define APP_USBD_CLASS_IFACE_EP_EXTRACT_1_(iface_nr, ...) \
|
||||
MACRO_MAP_REC(PARAM_CBRACE, __VA_ARGS__)
|
||||
MACRO_MAP_REC(APP_USBD_CLASS_IFACE_EP_EXTRACT_1__, __VA_ARGS__)
|
||||
|
||||
#define APP_USBD_CLASS_IFACE_EP_EXTRACT_1__(ep) \
|
||||
{(nrf_drv_usbd_ep_t) (ep)},
|
||||
|
||||
/**
|
||||
* @brief Generate configuration for single interface
|
||||
* @brief Generate configuration for single interface.
|
||||
*
|
||||
* This macro extract configuration for single interface.
|
||||
* The configuration is inside curly brackets and comma is added on the end.
|
||||
* This mean it can be directly used to init array of interface configurations.
|
||||
*
|
||||
* @param iface_config Single interface configuration
|
||||
* @param N Currently processed configuration
|
||||
* @param iface_configs All interfaces configuration in brackets
|
||||
* @param iface_config Single interface configuration.
|
||||
* @param N Currently processed configuration.
|
||||
* @param iface_configs All interfaces configuration in brackets.
|
||||
*/
|
||||
#define APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_(iface_config, N, iface_configs) \
|
||||
CONCAT_2(APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_, \
|
||||
NUM_VA_ARGS_IS_MORE_THAN_1(BRACKET_EXTRACT(iface_config))) \
|
||||
(N, iface_configs, BRACKET_EXTRACT(iface_config))
|
||||
|
||||
/**
|
||||
* @brief Macro used when there was an error extracting number of configs.
|
||||
*
|
||||
* Throws a syntax error.
|
||||
*/
|
||||
#define APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_x(iface_config, N, iface_configs) \
|
||||
[N] = !!!iface_config!!!
|
||||
/**
|
||||
* @brief Auxiliary macro for @ref APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_
|
||||
*
|
||||
* This macro is called when interface has no endpoints
|
||||
* This macro is called when interface has no endpoints.
|
||||
*/
|
||||
#define APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_0(N, iface_configs, iface_nr) \
|
||||
APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_0_(N, iface_configs, iface_nr)
|
||||
@@ -478,7 +498,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
/**
|
||||
* @brief Auxiliary macro for @ref APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_
|
||||
*
|
||||
* This macro is called when interface has at last one endpoint
|
||||
* This macro is called when interface has at last one endpoint.
|
||||
*/
|
||||
#define APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_1(N, iface_configs, ...) \
|
||||
APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_1_(N, iface_configs, __VA_ARGS__)
|
||||
@@ -502,7 +522,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Count total number of endpoints
|
||||
* @brief Count total number of endpoints.
|
||||
*
|
||||
* @param iface_configs List of interface configurations like explained
|
||||
* in documentation for @ref APP_USBD_CLASS_INSTANCE_TYPEDEF
|
||||
@@ -513,12 +533,12 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
(0 MACRO_MAP(APP_USBD_CLASS_CONF_IFACE_EP_PLUS_COUNT_, BRACKET_EXTRACT(iface_configs)))
|
||||
|
||||
/**
|
||||
* @brief Count total number of endpoint up-to interface index
|
||||
* @brief Count total number of endpoint up-to interface index.
|
||||
*
|
||||
* The version of @ref APP_USBD_CLASS_CONF_TOTAL_EP_COUNT macro which takes the
|
||||
* number of interfaces to analyze.
|
||||
*
|
||||
* @param N Number of interfaces to analyze
|
||||
* @param N Number of interfaces to analyze.
|
||||
* @param iface_configs List of interface configurations like explained
|
||||
* in documentation for @ref APP_USBD_CLASS_INSTANCE_TYPEDEF
|
||||
*
|
||||
@@ -528,7 +548,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
(0 MACRO_MAP_N(N, APP_USBD_CLASS_CONF_IFACE_EP_PLUS_COUNT_, BRACKET_EXTRACT(iface_configs)))
|
||||
|
||||
/**
|
||||
* @brief Extract configurations for interfaces
|
||||
* @brief Extract configurations for interfaces.
|
||||
*
|
||||
* This macro extracts the configurations for every interface.
|
||||
* Basically uses the @ref APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_ macro on every
|
||||
@@ -549,14 +569,14 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
BRACKET_EXTRACT(iface_configs))
|
||||
|
||||
/**
|
||||
* @brief Extract all endpoints
|
||||
* @brief Extract all endpoints.
|
||||
*
|
||||
* Macro that extracts all endpoints from every interface
|
||||
* Macro that extracts all endpoints from every interface.
|
||||
*
|
||||
* @param iface_configs List of interface configurations like explained
|
||||
* in documentation for @ref APP_USBD_CLASS_INSTANCE_TYPEDEF
|
||||
*
|
||||
* @return Comma separated list of endpoints
|
||||
* @return Comma separated list of endpoints.
|
||||
*/
|
||||
/*lint -emacro( (40), APP_USBD_CLASS_IFACES_EP_EXTRACT) */
|
||||
#define APP_USBD_CLASS_IFACES_EP_EXTRACT(iface_configs) \
|
||||
@@ -567,29 +587,29 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
|
||||
|
||||
/**
|
||||
* @brief USBD instance of class mnemonic
|
||||
* @brief USBD instance of class mnemonic.
|
||||
*
|
||||
* Macro that generates mnemonic for the name of the structure that describes instance for selected class.
|
||||
*
|
||||
* @param type_name The name of the instance without _t postfix
|
||||
* @param type_name The name of the instance without _t postfix.
|
||||
*
|
||||
* @return The name with the right postfix to create the name for the type for the class.
|
||||
*/
|
||||
#define APP_USBD_CLASS_INSTANCE_TYPE(type_name) CONCAT_2(type_name, _t)
|
||||
|
||||
/**
|
||||
* @brief USBD data for instance class mnemonic
|
||||
* @brief USBD data for instance class mnemonic.
|
||||
*
|
||||
* The mnemonic of the variable type that holds writable part of the class instance.
|
||||
*
|
||||
* @param type_name The name of the instance without _t postfix
|
||||
* @param type_name The name of the instance without _t postfix.
|
||||
*
|
||||
* @return The name with the right postfix to create the name for the data type for the class.
|
||||
*/
|
||||
#define APP_USBD_CLASS_DATA_TYPE(type_name) CONCAT_2(type_name, _data_t)
|
||||
|
||||
/**
|
||||
* @brief Declare class specific member of class instance
|
||||
* @brief Declare class specific member of class instance.
|
||||
*
|
||||
* @param type Type of the attached class configuration.
|
||||
*
|
||||
@@ -598,16 +618,16 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
#define APP_USBD_CLASS_INSTANCE_SPECIFIC_DEC(type) type class_part;
|
||||
|
||||
/**
|
||||
* @brief Used if there is no class specific configuration
|
||||
* @brief Used if there is no class specific configuration.
|
||||
*
|
||||
* This constant can be used if there is no specific configuration inside created instance
|
||||
* This constant can be used if there is no specific configuration inside created instance.
|
||||
*
|
||||
* @sa APP_USBD_CLASS_INSTANCE_TYPEDEF
|
||||
*/
|
||||
#define APP_USBD_CLASS_INSTANCE_SPECIFIC_DEC_NONE
|
||||
|
||||
/**
|
||||
* @brief Declare class specific member of class data
|
||||
* @brief Declare class specific member of class data.
|
||||
*
|
||||
* @param type Type of the attached class data.
|
||||
*
|
||||
@@ -616,9 +636,9 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
#define APP_USBD_CLASS_DATA_SPECIFIC_DEC(type) APP_USBD_CLASS_INSTANCE_SPECIFIC_DEC(type)
|
||||
|
||||
/**
|
||||
* @brief Used if there is no class specific data
|
||||
* @brief Used if there is no class specific data.
|
||||
*
|
||||
* This constant can be used if there is no specific writable data inside created instance
|
||||
* This constant can be used if there is no specific writable data inside created instance.
|
||||
*
|
||||
* @sa APP_USBD_CLASS_DATA_TYPEDEF
|
||||
*/
|
||||
@@ -628,7 +648,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
|
||||
|
||||
/**
|
||||
* @brief Instance structure declaration
|
||||
* @brief Instance structure declaration.
|
||||
*
|
||||
* The macro that declares a variable type that would be used to store given class instance.
|
||||
* Class instance stores all the data from @ref app_usbd_class_inst_t and overlaid data for specified class.
|
||||
@@ -698,7 +718,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
} APP_USBD_CLASS_INSTANCE_TYPE(type_name)
|
||||
|
||||
/**
|
||||
* @brief Writable data structure declaration
|
||||
* @brief Writable data structure declaration.
|
||||
*
|
||||
* The macro that declares a variable type that would be used to store given class writable data.
|
||||
* Writable data contains base part of the type @ref app_usbd_class_data_t followed by
|
||||
@@ -709,7 +729,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
* @ref APP_USBD_CLASS_DATA_SPECIFIC_DEC or
|
||||
* @ref APP_USBD_CLASS_DATA_SPECIFIC_DEC_NONE
|
||||
*
|
||||
* @return The definition of the structure type that holds all the required writable data
|
||||
* @return The definition of the structure type that holds all the required writable data.
|
||||
*
|
||||
* @note It should not be used directly in the final application. See @ref APP_USBD_CLASS_DATA_TYPEDEF instead.
|
||||
*
|
||||
@@ -724,7 +744,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
|
||||
|
||||
/**
|
||||
* @brief Declare all data types required by the class instance
|
||||
* @brief Declare all data types required by the class instance.
|
||||
*
|
||||
* Macro that declares data type first and then instance type.
|
||||
*
|
||||
@@ -764,12 +784,12 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
#define APP_USBD_CLASS_FORWARD(type_name) union CONCAT_2(type_name, _u)
|
||||
|
||||
/**
|
||||
* @brief Generate the initialization data for
|
||||
* @brief Generate the initialization data for.
|
||||
*
|
||||
* Macro that generates the initialization data for instance.
|
||||
*
|
||||
* @param p_ram_data Pointer to writable instance data structure
|
||||
* @param class_methods Class methods
|
||||
* @param p_ram_data Pointer to writable instance data structure.
|
||||
* @param class_methods Class methods.
|
||||
* @param interfaces_configs Exactly the same interface config data that in @ref APP_USBD_CLASS_INSTANCE_TYPEDEF
|
||||
* @param class_config_part Configuration part. The data should be inside brackets.
|
||||
* Any data here would be removed from brackets and then put as an initialization
|
||||
@@ -814,7 +834,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Define the base class instance
|
||||
* @brief Define the base class instance.
|
||||
*
|
||||
* Macro that defines whole instance variable and fill it with initialization data.
|
||||
*
|
||||
@@ -905,7 +925,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
|
||||
|
||||
/**
|
||||
* @brief Define the base class instance in global scope
|
||||
* @brief Define the base class instance in global scope.
|
||||
*
|
||||
* This is the same macro like @ref APP_USBD_CLASS_INST_DEF but it creates the instance
|
||||
* without static keyword.
|
||||
@@ -945,13 +965,13 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
interfaces_configs, \
|
||||
class_config_part)
|
||||
/**
|
||||
* @brief Access class specific configuration
|
||||
* @brief Access class specific configuration.
|
||||
*
|
||||
* Macro that returns class specific configuration.
|
||||
*
|
||||
* @param[in] p_inst Instance pointer
|
||||
* @param[in] p_inst Instance pointer.
|
||||
*
|
||||
* @return A pointer for class specific part of the instance
|
||||
* @return A pointer for class specific part of the instance.
|
||||
*
|
||||
* @note If macro is used on the instance that has no class specific configuration
|
||||
* an error would be generated during compilation.
|
||||
@@ -959,11 +979,11 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
#define APP_USBD_CLASS_GET_SPECIFIC_CONFIG(p_inst) (&((p_inst)->specific.class_part))
|
||||
|
||||
/**
|
||||
* @brief Access class specific data
|
||||
* @brief Access class specific data.
|
||||
*
|
||||
* @param[in] p_inst Instance pointer
|
||||
* @param[in] p_inst Instance pointer.
|
||||
*
|
||||
* @return A pointer for class specific part of writable data
|
||||
* @return A pointer for class specific part of writable data.
|
||||
*
|
||||
* @note If macro is used on the instance that has no class specific data
|
||||
* an error would be generated during compilation.
|
||||
@@ -971,7 +991,7 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
#define APP_USBD_CLASS_GET_SPECIFIC_DATA(p_inst) (&(((p_inst)->specific.p_data)->class_part))
|
||||
|
||||
/**
|
||||
* @brief Macro to get base instance from class specific instance
|
||||
* @brief Macro to get base instance from class specific instance.
|
||||
*
|
||||
* This macro may be used on class specific instance to get base instance that
|
||||
* can be processed by base instance access functions.
|
||||
@@ -987,60 +1007,66 @@ static inline app_usbd_class_data_t * app_usbd_class_data_access(
|
||||
/*lint -emacro(142 438 616 646, APP_USBD_CLASS_DESCRIPTOR_INIT, APP_USBD_CLASS_DESCRIPTOR_BEGIN, APP_USBD_CLASS_DESCRIPTOR_YIELD, APP_USBD_CLASS_DESCRIPTOR_END, APP_USBD_CLASS_DESCRIPTOR_WRITE)*/
|
||||
|
||||
/**
|
||||
* @brief Initialize class descriptor
|
||||
* @brief Initialize class descriptor.
|
||||
*
|
||||
* @param[in] p_ctx Class descriptor context
|
||||
* @param[in] p_ctx Class descriptor context.
|
||||
*/
|
||||
|
||||
#define APP_USBD_CLASS_DESCRIPTOR_INIT(p_ctx) \
|
||||
(p_ctx)->line = 0;
|
||||
|
||||
/**
|
||||
* @brief Begin class descriptor
|
||||
* @brief Begin class descriptor.
|
||||
*
|
||||
* @param[in] p_ctx Class descriptor context
|
||||
* @param[in] p_ctx Class descriptor context.
|
||||
* @param[in] p_buff Buffer to write into.
|
||||
* @param[in] max_size Size of the buffer.
|
||||
*/
|
||||
|
||||
#define APP_USBD_CLASS_DESCRIPTOR_BEGIN(p_ctx) \
|
||||
switch ((p_ctx)->line) \
|
||||
{ \
|
||||
case 0: \
|
||||
#define APP_USBD_CLASS_DESCRIPTOR_BEGIN(p_ctx, p_buff, max_size) \
|
||||
ASSERT((p_ctx) != NULL); \
|
||||
app_usbd_class_descriptor_state_t this_descriptor_feed; \
|
||||
this_descriptor_feed.p_buffer = (p_buff); \
|
||||
this_descriptor_feed.current_size = 0; \
|
||||
this_descriptor_feed.maximum_size = (max_size); \
|
||||
this_descriptor_feed.p_context = (p_ctx); \
|
||||
switch ((this_descriptor_feed.p_context)->line) \
|
||||
{ \
|
||||
case 0: \
|
||||
;
|
||||
|
||||
/**
|
||||
* @brief Yield class descriptor
|
||||
*
|
||||
* @param[in] p_ctx Class descriptor context
|
||||
*/
|
||||
|
||||
#define APP_USBD_CLASS_DESCRIPTOR_YIELD(p_ctx) \
|
||||
do \
|
||||
{ \
|
||||
(p_ctx)->line = __LINE__; \
|
||||
return true; \
|
||||
case __LINE__: \
|
||||
; \
|
||||
#define APP_USBD_CLASS_DESCRIPTOR_YIELD() \
|
||||
do \
|
||||
{ \
|
||||
(this_descriptor_feed.p_context)->line = __LINE__; \
|
||||
return true; \
|
||||
case __LINE__: \
|
||||
; \
|
||||
} while (0)
|
||||
|
||||
/*lint -emacro(438 527, APP_USBD_CLASS_DESCRIPTOR_END)*/
|
||||
|
||||
/**
|
||||
* @brief End class descriptor
|
||||
* @brief End class descriptor.
|
||||
*
|
||||
* This function has to be called at the end of class descriptor feeder function.
|
||||
* No other operations in feeder function can be done after calling it.
|
||||
*
|
||||
* @param[in] p_ctx Class descriptor context
|
||||
*/
|
||||
|
||||
#define APP_USBD_CLASS_DESCRIPTOR_END(p_ctx) \
|
||||
#define APP_USBD_CLASS_DESCRIPTOR_END() \
|
||||
APP_USBD_CLASS_DESCRIPTOR_YIELD(); \
|
||||
} \
|
||||
(p_ctx)->line = 0; \
|
||||
(this_descriptor_feed.p_context)->line = 0; \
|
||||
return false;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Write descriptor using protothreads
|
||||
* @brief Write descriptor using protothreads.
|
||||
*
|
||||
* This function writes one byte to the buffer with offset. If buffer is full
|
||||
* it yields.
|
||||
@@ -1050,23 +1076,22 @@ do \
|
||||
* @ref APP_USBD_CLASS_DESCRIPTOR_BEGIN has to be called before using this function.
|
||||
* @ref APP_USBD_CLASS_DESCRIPTOR_END has to be called after last use of this function.
|
||||
*
|
||||
* @param data Byte to be written to buffer
|
||||
* @param buff Buffer to write into
|
||||
* @param cur_size Offset
|
||||
* @param max_size Size of the buffer
|
||||
* @param data Byte to be written to buffer.
|
||||
*/
|
||||
#define APP_USBD_CLASS_DESCRIPTOR_WRITE(data, buff, cur_size, max_size) \
|
||||
do \
|
||||
{ \
|
||||
if(buff != NULL) \
|
||||
{ \
|
||||
*(buff + cur_size) = data; \
|
||||
} \
|
||||
cur_size++; \
|
||||
if (cur_size >= max_size) \
|
||||
{ \
|
||||
APP_USBD_CLASS_DESCRIPTOR_YIELD(p_ctx); \
|
||||
} \
|
||||
#define APP_USBD_CLASS_DESCRIPTOR_WRITE(data) \
|
||||
do \
|
||||
{ \
|
||||
(this_descriptor_feed.p_context)->data_buffer = (data); \
|
||||
if (this_descriptor_feed.current_size >= this_descriptor_feed.maximum_size) \
|
||||
{ \
|
||||
APP_USBD_CLASS_DESCRIPTOR_YIELD(); \
|
||||
} \
|
||||
if(this_descriptor_feed.p_buffer != NULL) \
|
||||
{ \
|
||||
*(this_descriptor_feed.p_buffer + this_descriptor_feed.current_size) = \
|
||||
(this_descriptor_feed.p_context)->data_buffer; \
|
||||
} \
|
||||
this_descriptor_feed.current_size++; \
|
||||
} while(0);
|
||||
|
||||
/** @} */
|
||||
|
||||
+114
-74
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
#include "sdk_common.h"
|
||||
#if NRF_MODULE_ENABLED(APP_USBD)
|
||||
@@ -50,6 +50,18 @@
|
||||
#include "app_usbd.h"
|
||||
#include "app_usbd_class_base.h"
|
||||
|
||||
#define NRF_LOG_MODULE_NAME app_usbd_core
|
||||
|
||||
#if APP_USBD_CONFIG_LOG_ENABLED
|
||||
#define NRF_LOG_LEVEL APP_USBD_CONFIG_LOG_LEVEL
|
||||
#define NRF_LOG_INFO_COLOR APP_USBD_CONFIG_INFO_COLOR
|
||||
#define NRF_LOG_DEBUG_COLOR APP_USBD_CONFIG_DEBUG_COLOR
|
||||
#else //APP_USBD_CONFIG_LOG_ENABLED
|
||||
#define NRF_LOG_LEVEL 0
|
||||
#endif //APP_USBD_CONFIG_LOG_ENABLED
|
||||
#include "nrf_log.h"
|
||||
NRF_LOG_MODULE_REGISTER();
|
||||
|
||||
/* Test if VID was configured */
|
||||
#ifndef APP_USBD_VID
|
||||
#error APP_USBD_VID not properly defined.
|
||||
@@ -106,13 +118,13 @@
|
||||
.wTotalLength = 0, /*Calculated dynamically*/ \
|
||||
.bNumInterfaces = 0, /*Calculated dynamically*/ \
|
||||
.bConfigurationValue = 1, /*Value passed to set configuration*/ \
|
||||
.iConfiguration = 0, /*Configuration ID: fixed to 0*/ \
|
||||
.iConfiguration = APP_USBD_STRING_ID_CONFIGURATION, /*Configuration ID*/ \
|
||||
.bmAttributes = APP_USBD_DESCRIPTOR_CONFIGURATION_ATTRIBUTE_ALWAYS_SET_MASK | \
|
||||
((APP_USBD_CONFIG_SELF_POWERED) ? \
|
||||
APP_USBD_DESCRIPTOR_CONFIGURATION_ATTRIBUTE_SELF_POWERED_MASK \
|
||||
: \
|
||||
0), \
|
||||
.bMaxPower = APP_USBD_POWER_MAKE(500), \
|
||||
.bMaxPower = APP_USBD_POWER_MAKE(APP_USBD_CONFIG_MAX_POWER), \
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,27 +154,27 @@ static ret_code_t app_usbd_core_event_handler(app_usbd_class_inst_t const * cons
|
||||
app_usbd_complex_evt_t const * const p_event);
|
||||
|
||||
/**
|
||||
* @brief Current USB device state
|
||||
* @brief Current USB device state.
|
||||
*
|
||||
* This variable is updated automatically by core library.
|
||||
*/
|
||||
static app_usbd_state_t m_app_usbd_state = APP_USBD_STATE_Disabled;
|
||||
|
||||
/**
|
||||
* @brief Active device features
|
||||
* @brief Active device features.
|
||||
*
|
||||
* @note Only @ref APP_USBD_SETUP_STDFEATURE_DEVICE_REMOTE_WAKEUP is supported for device
|
||||
* @note Only @ref APP_USBD_SETUP_STDFEATURE_DEVICE_REMOTE_WAKEUP is supported for device.
|
||||
*/
|
||||
static uint8_t m_device_features_state;
|
||||
|
||||
/**
|
||||
* @brief Remote wake-up pending flag
|
||||
* @brief Remote wake-up pending flag.
|
||||
*/
|
||||
static nrf_atomic_flag_t m_rwu_pending;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Core class methods
|
||||
* @brief Core class methods.
|
||||
*
|
||||
* Base methods interface for core class.
|
||||
* This is quite specific class - it would be only connected into endpoint 0.
|
||||
@@ -174,15 +186,14 @@ static const app_usbd_class_methods_t m_core_methods = {
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Setup transfer buffer
|
||||
* @brief Setup transfer buffer.
|
||||
*/
|
||||
static uint8_t m_setup_transfer_buff[NRF_DRV_USBD_EPSIZE];
|
||||
|
||||
|
||||
/**
|
||||
* @brief Handler for outgoing setup data
|
||||
* @brief Handler for outgoing setup data.
|
||||
*
|
||||
* @todo RK documentation
|
||||
*/
|
||||
static app_usbd_core_setup_data_handler_desc_t m_ep0_handler_desc;
|
||||
|
||||
@@ -192,7 +203,7 @@ static app_usbd_core_setup_data_handler_desc_t m_ep0_handler_desc;
|
||||
/*lint -u -save -e26 -e40 -e64 -e123 -e505 -e651*/
|
||||
|
||||
/**
|
||||
* @brief Core instance
|
||||
* @brief Core instance.
|
||||
*
|
||||
* Create instance that would be connected into endpoints in USBD library.
|
||||
*/
|
||||
@@ -205,13 +216,13 @@ APP_USBD_CLASS_INST_GLOBAL_DEF(
|
||||
/*lint -restore*/
|
||||
|
||||
/**
|
||||
* @brief Set the new USB state
|
||||
* @brief Set the new USB state.
|
||||
*
|
||||
* Function changes the internal status of the bus.
|
||||
* If the bus status is different than the one configured, an event is passed to all
|
||||
* the instances.
|
||||
*
|
||||
* @param state New state to be set
|
||||
* @param state New state to be set.
|
||||
*
|
||||
* @sa usbd_core_state_get
|
||||
*/
|
||||
@@ -232,12 +243,12 @@ static void usbd_core_state_set(app_usbd_state_t state)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the current USB state - internal function
|
||||
* @brief Get the current USB state - internal function.
|
||||
*
|
||||
* This is just a wrapper for @ref app_usbd_core_state_get
|
||||
* to make symmetrical function to the internal @ref usbd_core_state_set.
|
||||
*
|
||||
* @return Current USB state
|
||||
* @return Current USB state.
|
||||
*
|
||||
* @sa usbd_core_state_set
|
||||
* @sa app_usbd_core_state_get
|
||||
@@ -248,7 +259,7 @@ static inline app_usbd_state_t usbd_core_state_get(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check current USBD power connection status
|
||||
* @brief Check current USBD power connection status.
|
||||
*
|
||||
*/
|
||||
static inline bool usbd_core_power_is_detected(void)
|
||||
@@ -256,9 +267,18 @@ static inline bool usbd_core_power_is_detected(void)
|
||||
return 0 != ( (NRF_POWER->USBREGSTATUS) & POWER_USBREGSTATUS_VBUSDETECT_Msk);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear current EP0 handler.
|
||||
*
|
||||
* Function just clears the EP0 handler without calling it.
|
||||
*/
|
||||
static inline void usbd_core_ep0_handler_clear(void)
|
||||
{
|
||||
m_ep0_handler_desc.handler = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Safely call EP0 handler
|
||||
* @brief Safely call EP0 handler.
|
||||
*
|
||||
* Function calls EP0 handler only if its pointer is non-zero.
|
||||
*
|
||||
@@ -269,7 +289,7 @@ static inline ret_code_t usbd_core_ep0_handler_call_and_clear(nrf_drv_usbd_ep_st
|
||||
app_usbd_core_setup_data_handler_t handler = m_ep0_handler_desc.handler;
|
||||
if (NULL != handler)
|
||||
{
|
||||
m_ep0_handler_desc.handler = NULL;
|
||||
usbd_core_ep0_handler_clear();
|
||||
return handler(status, m_ep0_handler_desc.p_context);
|
||||
}
|
||||
|
||||
@@ -277,7 +297,7 @@ static inline ret_code_t usbd_core_ep0_handler_call_and_clear(nrf_drv_usbd_ep_st
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if EP0 handler is configured
|
||||
* @brief Check if EP0 handler is configured.
|
||||
*
|
||||
* EP0 handler is configured is any instance that has processed SETUP command
|
||||
* expects some incoming / outgoing data.
|
||||
@@ -290,8 +310,8 @@ static inline ret_code_t usbd_core_ep0_handler_call_and_clear(nrf_drv_usbd_ep_st
|
||||
* This function adds small layer of abstraction for checking if EP0 handler
|
||||
* is already configured.
|
||||
*
|
||||
* @retval true EP0 handler is set
|
||||
* @retval false EP0 handler is cleared
|
||||
* @retval true EP0 handler is set.
|
||||
* @retval false EP0 handler is cleared.
|
||||
*/
|
||||
static inline bool usb_core_ep0_handler_check(void)
|
||||
{
|
||||
@@ -299,7 +319,7 @@ static inline bool usb_core_ep0_handler_check(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Empty data handler
|
||||
* @brief Empty data handler.
|
||||
*
|
||||
* Data handler used only to mark that there is requested data during SETUP.
|
||||
*
|
||||
@@ -316,7 +336,7 @@ static ret_code_t setup_data_handler_empty(nrf_drv_usbd_ep_status_t status, void
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @todo RK Documentation
|
||||
* Empty EP0 transfer transfer handler.
|
||||
*/
|
||||
static app_usbd_core_setup_data_handler_desc_t const m_setup_data_handler_empty_desc =
|
||||
{
|
||||
@@ -325,7 +345,7 @@ static app_usbd_core_setup_data_handler_desc_t const m_setup_data_handler_empty_
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Structure used as a context for descriptor feeder
|
||||
* @brief Structure used as a context for descriptor feeder.
|
||||
*
|
||||
* Structure with all the data required to process instances to generate descriptor
|
||||
* data chunk.
|
||||
@@ -344,14 +364,14 @@ typedef struct
|
||||
} app_usbd_core_descriptor_conf_feed_data_t;
|
||||
|
||||
/**
|
||||
* @brief Default data used by the feeder
|
||||
* @brief Default data used by the feeder.
|
||||
*
|
||||
*
|
||||
*/
|
||||
static app_usbd_core_descriptor_conf_feed_data_t m_descriptor_conf_feed_data;
|
||||
|
||||
/**
|
||||
* @brief Descriptor feeder
|
||||
* @brief Descriptor feeder.
|
||||
*
|
||||
* Descriptor feeder is used as an callback function when descriptors are
|
||||
* transfered and buffer is ready for next data.
|
||||
@@ -472,11 +492,11 @@ static bool usbd_descriptor_conf_feeder(
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Standard endpoint request handle
|
||||
* @brief Standard endpoint request handle.
|
||||
*
|
||||
* @param[in] p_setup_ev Setup event
|
||||
* @param[in] p_setup_ev Setup event.
|
||||
*
|
||||
* @return Standard error code
|
||||
* @return Standard error code.
|
||||
*/
|
||||
static ret_code_t setup_endpoint_req_std(app_usbd_setup_evt_t const * p_setup_ev)
|
||||
{
|
||||
@@ -547,13 +567,13 @@ static ret_code_t setup_endpoint_req_std(app_usbd_setup_evt_t const * p_setup_ev
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Standard interface request handle
|
||||
* @brief Standard interface request handle.
|
||||
*
|
||||
* @param[in,out] p_class_inst Class instance that holds selected interface
|
||||
* @param[in] iface_idx Index of the interface in class structure
|
||||
* @param[in] p_event Event structure to be processed
|
||||
* @param[in,out] p_class_inst Class instance that holds selected interface.
|
||||
* @param[in] iface_idx Index of the interface in class structure.
|
||||
* @param[in] p_event Event structure to be processed.
|
||||
*
|
||||
* @return Operation status
|
||||
* @return Operation status.
|
||||
*/
|
||||
static ret_code_t setup_interface_req_std_handle(
|
||||
app_usbd_class_inst_t const * const p_class_inst,
|
||||
@@ -623,7 +643,7 @@ static ret_code_t setup_interface_req_std_handle(
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @todo RK Documentation
|
||||
* Descriptors feeder handle structure.
|
||||
*/
|
||||
static const nrf_drv_usbd_handler_desc_t usbd_descriptor_feeder_desc =
|
||||
{
|
||||
@@ -813,12 +833,12 @@ static ret_code_t setup_device_req_set_configuration(
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Internal SETUP event handler
|
||||
* @param[in] p_inst Instance of the class
|
||||
* @param[in] p_setup_ev Setup request
|
||||
* @return Standard error code
|
||||
* @retval NRF_SUCCESS if request handled correctly
|
||||
* @retval NRF_ERROR_NOT_SUPPORTED if request is not supported
|
||||
* @brief Internal SETUP event handler.
|
||||
* @param[in] p_inst Instance of the class.
|
||||
* @param[in] p_setup_ev Setup request.
|
||||
* @return Standard error code.
|
||||
* @retval NRF_SUCCESS Request handled correctly.
|
||||
* @retval NRF_ERROR_NOT_SUPPORTED Request is not supported.
|
||||
*/
|
||||
static ret_code_t setup_device_req_std_handler(app_usbd_class_inst_t const * const p_inst,
|
||||
app_usbd_setup_evt_t const * const p_setup_ev)
|
||||
@@ -859,16 +879,8 @@ static ret_code_t setup_device_req_std_handler(app_usbd_class_inst_t const * con
|
||||
{
|
||||
case APP_USBD_SETUP_STDREQ_SET_ADDRESS:
|
||||
{
|
||||
app_usbd_state_t usb_state = usbd_core_state_get();
|
||||
if ((usb_state != APP_USBD_STATE_Default) &&
|
||||
(usb_state != APP_USBD_STATE_Addressed) &&
|
||||
(usb_state != APP_USBD_STATE_Configured))
|
||||
{
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
app_usbd_all_iface_deselect();
|
||||
usbd_core_state_set(APP_USBD_STATE_Addressed);
|
||||
return NRF_SUCCESS;
|
||||
ASSERT(0); /* should never reach this point */
|
||||
break;
|
||||
}
|
||||
case APP_USBD_SETUP_STDREQ_SET_FEATURE:
|
||||
{
|
||||
@@ -914,21 +926,28 @@ static ret_code_t setup_device_req_std_handler(app_usbd_class_inst_t const * con
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Process SETUP command
|
||||
* @brief Process SETUP command.
|
||||
*
|
||||
* Auxiliary function for SETUP command processing
|
||||
* Auxiliary function for SETUP command processing.
|
||||
*/
|
||||
static inline ret_code_t app_usbd_core_setup_req_handler(app_usbd_class_inst_t const * const p_inst)
|
||||
{
|
||||
app_usbd_setup_evt_t setup_ev;
|
||||
ret_code_t ret = NRF_ERROR_NOT_SUPPORTED; /* Final result of request processing function */
|
||||
|
||||
/* This handler have to be cleared when SETUP is entered */
|
||||
// ASSERT(!usb_core_ep0_handler_check());
|
||||
|
||||
setup_ev.type = APP_USBD_EVT_DRV_SETUP;
|
||||
nrf_drv_usbd_setup_get((nrf_drv_usbd_setup_t *)&(setup_ev.setup));
|
||||
|
||||
NRF_LOG_DEBUG("SETUP: t: 0x%.2x r: 0x%.2x",
|
||||
setup_ev.setup.bmRequestType,
|
||||
setup_ev.setup.bmRequest);
|
||||
if (usb_core_ep0_handler_check())
|
||||
{
|
||||
NRF_LOG_WARNING("Previous setup not finished!");
|
||||
}
|
||||
/* Clear EP0 handler if there is anything in progress */
|
||||
usbd_core_ep0_handler_clear();
|
||||
|
||||
switch (app_usbd_setup_req_rec(setup_ev.setup.bmRequestType))
|
||||
{
|
||||
case APP_USBD_SETUP_REQREC_DEVICE:
|
||||
@@ -1014,7 +1033,7 @@ static inline ret_code_t app_usbd_core_setup_req_handler(app_usbd_class_inst_t c
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Event handler for core module
|
||||
* @brief Event handler for core module.
|
||||
*
|
||||
* The event handler that would process all events directed to device.
|
||||
*
|
||||
@@ -1046,6 +1065,15 @@ static ret_code_t app_usbd_core_event_handler(app_usbd_class_inst_t const * cons
|
||||
ret = NRF_SUCCESS;
|
||||
break;
|
||||
}
|
||||
case APP_USBD_EVT_SETUP_SETADDRESS:
|
||||
{
|
||||
app_usbd_state_t usb_state = usbd_core_state_get();
|
||||
if (usb_state == APP_USBD_STATE_Default)
|
||||
{
|
||||
usbd_core_state_set(APP_USBD_STATE_Addressed);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case APP_USBD_EVT_DRV_SETUP:
|
||||
{
|
||||
ret = app_usbd_core_setup_req_handler(p_inst);
|
||||
@@ -1087,6 +1115,11 @@ static ret_code_t app_usbd_core_event_handler(app_usbd_class_inst_t const * cons
|
||||
/* Data transfer on endpoint 0 */
|
||||
case APP_USBD_EVT_DRV_EPTRANSFER:
|
||||
{
|
||||
if (p_event->drv_evt.data.eptransfer.status == NRF_USBD_EP_ABORTED)
|
||||
{
|
||||
/* Just ignore aborting */
|
||||
break;
|
||||
}
|
||||
/* This EPTRANSFER event has to be called only for EP0 */
|
||||
ASSERT((p_event->drv_evt.data.eptransfer.ep == NRF_DRV_USBD_EPOUT0) ||
|
||||
(p_event->drv_evt.data.eptransfer.ep == NRF_DRV_USBD_EPIN0));
|
||||
@@ -1104,15 +1137,9 @@ static ret_code_t app_usbd_core_event_handler(app_usbd_class_inst_t const * cons
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Request processed successfully */
|
||||
/* Clear setup only for a write transfer - for a read transfer,
|
||||
* it is cleared inside the driver */
|
||||
if (p_event->drv_evt.data.eptransfer.ep == NRF_DRV_USBD_EPOUT0)
|
||||
if (!nrf_drv_usbd_errata_154())
|
||||
{
|
||||
if (!nrf_drv_usbd_errata_154())
|
||||
{
|
||||
nrf_drv_usbd_setup_clear();
|
||||
}
|
||||
nrf_drv_usbd_setup_clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1132,6 +1159,19 @@ static ret_code_t app_usbd_core_event_handler(app_usbd_class_inst_t const * cons
|
||||
|
||||
/** @} */
|
||||
|
||||
void app_usbd_core_ep0_enable(void)
|
||||
{
|
||||
app_usbd_ep_enable(NRF_DRV_USBD_EPOUT0);
|
||||
app_usbd_ep_enable(NRF_DRV_USBD_EPIN0);
|
||||
}
|
||||
|
||||
void app_usbd_core_ep0_disable(void)
|
||||
{
|
||||
app_usbd_ep_disable(NRF_DRV_USBD_EPOUT0);
|
||||
app_usbd_ep_disable(NRF_DRV_USBD_EPIN0);
|
||||
}
|
||||
|
||||
|
||||
ret_code_t app_usbd_core_setup_rsp(app_usbd_setup_t const * p_setup,
|
||||
void const * p_data,
|
||||
size_t size)
|
||||
|
||||
+44
-28
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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 APP_USBD_CORE_H__
|
||||
@@ -62,7 +62,7 @@ extern "C" {
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Core interface configuration
|
||||
* @brief Core interface configuration.
|
||||
*
|
||||
* Core instance would have 2 endpoints (IN0 and OUT0).
|
||||
* The interface number does not matter because it is not used.
|
||||
@@ -70,7 +70,7 @@ extern "C" {
|
||||
#define APP_USBD_CORE_CLASS_CONFIGURATION ((0, NRF_DRV_USBD_EPOUT0, NRF_DRV_USBD_EPIN0))
|
||||
|
||||
/**
|
||||
* @brief USB Device state
|
||||
* @brief USB Device state.
|
||||
*
|
||||
* Possible USB Device states according to specification.
|
||||
*/
|
||||
@@ -85,7 +85,7 @@ typedef enum
|
||||
}app_usbd_state_t;
|
||||
|
||||
/**
|
||||
* @brief EP0 handler function pointer
|
||||
* @brief EP0 handler function pointer.
|
||||
*
|
||||
* Type of the variable that would hold the pointer to the handler for
|
||||
* endpoint 0 messages processing.
|
||||
@@ -96,7 +96,7 @@ typedef ret_code_t (*app_usbd_core_setup_data_handler_t)(nrf_drv_usbd_ep_status_
|
||||
void * p_context);
|
||||
|
||||
/**
|
||||
* @brief Variable type used to register EP0 transfer handler
|
||||
* @brief Variable type used to register EP0 transfer handler.
|
||||
*
|
||||
* EP0 messages are processed by core instance.
|
||||
* Another class can register itself to receive messages from EP0 when requesting
|
||||
@@ -110,7 +110,7 @@ typedef struct
|
||||
|
||||
/*lint -save -e10 -e26 -e93 -e123 -e505 */
|
||||
/**
|
||||
* @brief Declare Core instance type
|
||||
* @brief Declare Core instance type.
|
||||
*
|
||||
* USBD core instance type definition.
|
||||
*/
|
||||
@@ -121,11 +121,11 @@ APP_USBD_CLASS_TYPEDEF(app_usbd_core,
|
||||
/*lint -restore*/
|
||||
|
||||
/**
|
||||
* @brief Access to core instance
|
||||
* @brief Access to core instance.
|
||||
*
|
||||
* Function that returns pointer to the USBD core instance.
|
||||
*
|
||||
* @return pointer to the core instance
|
||||
* @return pointer to the core instance.
|
||||
*/
|
||||
static inline app_usbd_class_inst_t const * app_usbd_core_instance_access(void)
|
||||
{
|
||||
@@ -134,13 +134,29 @@ static inline app_usbd_class_inst_t const * app_usbd_core_instance_access(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Default simple response to setup command
|
||||
* @brief Enable endpoint 0
|
||||
*
|
||||
* Function enables endpoint OUT0 and IN0.
|
||||
* This makes the USB respond to SETUP transfers.
|
||||
*/
|
||||
void app_usbd_core_ep0_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Disable endpoint 0
|
||||
*
|
||||
* Function disables endpoint OUT0 and IN0.
|
||||
* This makes the USB ignore SETUP transfers.
|
||||
*/
|
||||
void app_usbd_core_ep0_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Default simple response to setup command.
|
||||
*
|
||||
* This function generates default simple response.
|
||||
* It sends ZLP when required and on takes care on allowing status stage when
|
||||
* transfer is finished.
|
||||
*
|
||||
* @param p_setup Pointer to original setup message
|
||||
* @param p_setup Pointer to original setup message.
|
||||
* @param p_data Pointer to the response. This has to be globaly aviable data.
|
||||
* @param size Total size of the answer - The function takes care about
|
||||
* limiting the size of transfered data to the size required
|
||||
@@ -151,16 +167,16 @@ ret_code_t app_usbd_core_setup_rsp(app_usbd_setup_t const * p_setup,
|
||||
size_t size);
|
||||
|
||||
/**
|
||||
* @brief Configure the handler for the nearest setup data endpoint transfer
|
||||
* @brief Configure the handler for the nearest setup data endpoint transfer.
|
||||
*
|
||||
* This function would be called on incomming setup data.
|
||||
* The correct place to set the handler for a data is when SETUP command
|
||||
* was received.
|
||||
*
|
||||
* @param ep Endpoint number (only IN0 and OUT0) are supported.
|
||||
* @param ep Endpoint number (only IN0 and OUT0 are supported).
|
||||
* @param p_handler_desc Descriptor of the handler to be called.
|
||||
*
|
||||
* @retval NRF_SUCCESS Successfully configured
|
||||
* @retval NRF_SUCCESS Successfully configured.
|
||||
* @retval NRF_ERROR_INVALID_ADDR Last received setup direction does not match
|
||||
* configured endpoint.
|
||||
*/
|
||||
@@ -172,28 +188,28 @@ ret_code_t app_usbd_core_setup_data_handler_set(
|
||||
* @brief Set up a data transfer buffer.
|
||||
*
|
||||
* Returns special internal buffer that can be used in setup transfer.
|
||||
* @return Internal buffer pointer
|
||||
* @return Internal buffer pointer.
|
||||
*/
|
||||
void * app_usbd_core_setup_transfer_buff_get(size_t * p_size);
|
||||
|
||||
|
||||
/**@brief Return internal USBD core state
|
||||
/**@brief Return internal USBD core state.
|
||||
*
|
||||
* @return Check @ref app_usbd_state_t to find possible USBD core states
|
||||
* @return Check @ref app_usbd_state_t to find possible USBD core states.
|
||||
*/
|
||||
app_usbd_state_t app_usbd_core_state_get(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Check current feature state
|
||||
* @brief Check current feature state.
|
||||
*
|
||||
* Function checks the state of the selected feature that was configured by the host.
|
||||
*
|
||||
* @param feature Feature to check.
|
||||
* @param feature Feature to check. @ref app_usbd_setup_stdfeature_t
|
||||
* Only features related to the device should be checked by this function.
|
||||
*
|
||||
* @retval true Selected feature is set
|
||||
* @retval false Selected feature is cleared
|
||||
* @retval true Selected feature is set.
|
||||
* @retval false Selected feature is cleared.
|
||||
*/
|
||||
bool app_usbd_core_feature_state_get(app_usbd_setup_stdfeature_t feature);
|
||||
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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 APP_USBD_DESCRIPTOR_H__
|
||||
@@ -62,27 +62,27 @@ ANON_UNIONS_ENABLE;
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Helper macro for translating unsigned 24 bit value to 2 byte raw descriptor
|
||||
* @brief Helper macro for translating unsigned 24 bit value to 2 byte raw descriptor.
|
||||
* */
|
||||
#define APP_USBD_U16_TO_RAW_DSC(val) (uint8_t)(val), \
|
||||
(uint8_t)(((val) / (256)))
|
||||
|
||||
/**
|
||||
* @brief Helper macro for translating unsigned 24 bit value to 3 byte raw descriptor
|
||||
* @brief Helper macro for translating unsigned 24 bit value to 3 byte raw descriptor.
|
||||
* */
|
||||
#define APP_USBD_U24_TO_RAW_DSC(val) (uint8_t)(val), \
|
||||
(uint8_t)(((val) / (256))), \
|
||||
(uint8_t)(((val) / (256 * 256)))
|
||||
|
||||
/**
|
||||
* @brief Helper macro for translating unsigned 32 bit value to 4 byte raw descriptor
|
||||
* @brief Helper macro for translating unsigned 32 bit value to 4 byte raw descriptor.
|
||||
* */
|
||||
#define APP_USBD_U32_TO_RAW_DSC(val) (uint8_t)(val), \
|
||||
(uint8_t)(((val) / (256))), \
|
||||
(uint8_t)(((val) / (256 * 256))) \
|
||||
(uint8_t)(((val) / (256 * 256 * 256)))
|
||||
/**
|
||||
* @brief Descriptor types
|
||||
* @brief Descriptor types.
|
||||
*
|
||||
* Descriptor types used in two situations:
|
||||
* - when processing @ref APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR SETUP request,
|
||||
@@ -137,7 +137,7 @@ typedef enum
|
||||
#pragma pack(push, 1)
|
||||
|
||||
/**
|
||||
* @brief Common descriptor header
|
||||
* @brief Common descriptor header.
|
||||
*
|
||||
* The header that we can find on the beginning of all descriptors that contains
|
||||
* the descriptor length and type.
|
||||
@@ -150,9 +150,9 @@ typedef struct
|
||||
} app_usbd_descriptor_header_t;
|
||||
|
||||
/**
|
||||
* @brief Device descriptor
|
||||
* @brief Device descriptor.
|
||||
*
|
||||
* Descriptor used for the whole device
|
||||
* Descriptor used for the whole device.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
@@ -183,7 +183,7 @@ typedef struct
|
||||
} app_usbd_descriptor_device_t;
|
||||
|
||||
/**
|
||||
* @brief Attributes masks
|
||||
* @brief Attributes masks.
|
||||
*
|
||||
* Masks used for attributes in configuration.
|
||||
*/
|
||||
@@ -198,7 +198,7 @@ typedef enum
|
||||
} app_usbd_descriptor_configuration_attributes_t;
|
||||
|
||||
/**
|
||||
* @brief Configuration descriptor
|
||||
* @brief Configuration descriptor.
|
||||
*
|
||||
* Descriptor used at the beginning of configuration response.
|
||||
*/
|
||||
@@ -215,7 +215,7 @@ typedef struct
|
||||
} app_usbd_descriptor_configuration_t;
|
||||
|
||||
/**
|
||||
* @brief Raw descriptor - String descriptor zero
|
||||
* @brief Raw descriptor - String descriptor zero.
|
||||
*
|
||||
* String descriptor sent only as a response for GetDescriptor.
|
||||
*/
|
||||
@@ -227,7 +227,7 @@ typedef struct
|
||||
} app_usbd_descriptor_string0_t;
|
||||
|
||||
/**
|
||||
* @brief Raw descriptor - Any normal string
|
||||
* @brief Raw descriptor - Any normal string.
|
||||
*
|
||||
* String descriptor sent only as a response for GetDescriptor.
|
||||
*/
|
||||
@@ -240,7 +240,7 @@ typedef struct
|
||||
|
||||
|
||||
/**
|
||||
* @brief Interface descriptor
|
||||
* @brief Interface descriptor.
|
||||
*
|
||||
* Interface descriptor, returned as a part of configuration descriptor.
|
||||
*/
|
||||
@@ -273,7 +273,7 @@ typedef struct
|
||||
#define APP_USBD_DESCRIPTOR_EP_ATTR_USAGE_MASK BF_MASK(2, APP_USBD_DESCRIPTOR_EP_ATTR_USAGE_OFFSET)
|
||||
|
||||
/**
|
||||
* @brief Endpoint attributes mnemonics
|
||||
* @brief Endpoint attributes mnemonics.
|
||||
*
|
||||
* @sa APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_OFFSET APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_MASK
|
||||
* @sa APP_USBD_DESCRIPTOR_EP_ATTR_SYNC_OFFSET APP_USBD_DESCRIPTOR_EP_ATTR_SYNC_MASK
|
||||
@@ -297,7 +297,7 @@ typedef enum
|
||||
} app_usbd_descriptor_ep_attr_bitmap_t;
|
||||
|
||||
/**
|
||||
* @brief Endpoint descriptor
|
||||
* @brief Endpoint descriptor.
|
||||
*
|
||||
* Endpoint descriptor, returned as a part of configuration descriptor.
|
||||
*/
|
||||
@@ -312,7 +312,7 @@ typedef struct
|
||||
} app_usbd_descriptor_ep_t;
|
||||
|
||||
/**
|
||||
* @brief Interface association descriptor
|
||||
* @brief Interface association descriptor.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
+202
-188
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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 APP_USBD_LANGID_H__
|
||||
@@ -47,7 +47,7 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief This file contains LANGID variable type with all defined values
|
||||
* @brief This file contains LANGID variable type with all defined values.
|
||||
*
|
||||
* This file was created using Language Identifiers (LANGIDs) 3/29/00 Version 1.0,
|
||||
* available on USB web page:
|
||||
@@ -59,220 +59,234 @@ extern "C" {
|
||||
*/
|
||||
|
||||
/**
|
||||
* Offset of the lowest bit of primary language identifier
|
||||
* Offset of the lowest bit of primary language identifier.
|
||||
* @sa app_usbd_langid_t
|
||||
*/
|
||||
#define APP_USB_LANG_OFFSET 0
|
||||
|
||||
/**
|
||||
* Bitmask for a primary language identifier
|
||||
* Bitmask for a primary language identifier.
|
||||
* @sa app_usbd_langid_t
|
||||
*/
|
||||
#define APP_USB_LANG_MASK BF_MASK(10, APP_USB_LANG_OFFSET)
|
||||
|
||||
/**
|
||||
* Offset of the lowest bit of sub-language identifier
|
||||
* Macro for defining language identifier.
|
||||
*
|
||||
* @param x Language identifier value.
|
||||
*/
|
||||
#define APP_USB_LANG_DEF(x) ((x) << (APP_USB_LANG_OFFSET))
|
||||
|
||||
/**
|
||||
* Offset of the lowest bit of sublanguage identifier.
|
||||
* @sa app_usbd_langid_t
|
||||
*/
|
||||
#define APP_USB_SUBLANG_OFFSET 10
|
||||
|
||||
/**
|
||||
* Bitmask for a sub-language identifier
|
||||
* Bitmask for a sublanguage identifier.
|
||||
* @sa app_usbd_langid_t
|
||||
*/
|
||||
#define APP_USB_SUBLANG_MASK BF_MASK(6, APP_USB_SUBLANG_OFFSET)
|
||||
|
||||
/**
|
||||
* @brief Primary language identifiers
|
||||
* Macro for defining language identifier.
|
||||
*
|
||||
* @param x Language identifier value.
|
||||
*/
|
||||
#define APP_USB_SUBLANG_DEF(x) ((x) << (APP_USB_SUBLANG_OFFSET))
|
||||
|
||||
/**
|
||||
* @brief Primary language identifiers.
|
||||
*
|
||||
* Mnemonics for primary language identifiers.
|
||||
* This mnemonics can be combined using logical OR operator with @ref app_usbd_langid_sub_t.
|
||||
* This mnemonics can be combined using the logical OR operator with @ref app_usbd_langid_sub_t.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
APP_USBD_LANG_ARABIC = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Arabic */
|
||||
APP_USBD_LANG_BULGARIAN = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Bulgarian */
|
||||
APP_USBD_LANG_CATALAN = 0x03U << ( APP_USB_LANG_OFFSET ), /**< Catalan */
|
||||
APP_USBD_LANG_CHINESE = 0x04U << ( APP_USB_LANG_OFFSET ), /**< Chinese */
|
||||
APP_USBD_LANG_CZECH = 0x05U << ( APP_USB_LANG_OFFSET ), /**< Czech */
|
||||
APP_USBD_LANG_DANISH = 0x06U << ( APP_USB_LANG_OFFSET ), /**< Danish */
|
||||
APP_USBD_LANG_GERMAN = 0x07U << ( APP_USB_LANG_OFFSET ), /**< German */
|
||||
APP_USBD_LANG_GREEK = 0x08U << ( APP_USB_LANG_OFFSET ), /**< Greek */
|
||||
APP_USBD_LANG_ENGLISH = 0x09U << ( APP_USB_LANG_OFFSET ), /**< English */
|
||||
APP_USBD_LANG_SPANISH = 0x0aU << ( APP_USB_LANG_OFFSET ), /**< Spanish */
|
||||
APP_USBD_LANG_FINNISH = 0x0bU << ( APP_USB_LANG_OFFSET ), /**< Finnish */
|
||||
APP_USBD_LANG_FRENCH = 0x0cU << ( APP_USB_LANG_OFFSET ), /**< French */
|
||||
APP_USBD_LANG_HEBREW = 0x0dU << ( APP_USB_LANG_OFFSET ), /**< Hebrew */
|
||||
APP_USBD_LANG_HUNGARIAN = 0x0eU << ( APP_USB_LANG_OFFSET ), /**< Hungarian */
|
||||
APP_USBD_LANG_ICELANDIC = 0x0fU << ( APP_USB_LANG_OFFSET ), /**< Icelandic */
|
||||
APP_USBD_LANG_ITALIAN = 0x10U << ( APP_USB_LANG_OFFSET ), /**< Italian */
|
||||
APP_USBD_LANG_JAPANESE = 0x11U << ( APP_USB_LANG_OFFSET ), /**< Japanese */
|
||||
APP_USBD_LANG_KOREAN = 0x12U << ( APP_USB_LANG_OFFSET ), /**< Korean */
|
||||
APP_USBD_LANG_DUTCH = 0x13U << ( APP_USB_LANG_OFFSET ), /**< Dutch */
|
||||
APP_USBD_LANG_NORWEGIAN = 0x14U << ( APP_USB_LANG_OFFSET ), /**< Norwegian */
|
||||
APP_USBD_LANG_POLISH = 0x15U << ( APP_USB_LANG_OFFSET ), /**< Polish */
|
||||
APP_USBD_LANG_PORTUGUESE = 0x16U << ( APP_USB_LANG_OFFSET ), /**< Portuguese */
|
||||
APP_USBD_LANG_ROMANIAN = 0x18U << ( APP_USB_LANG_OFFSET ), /**< Romanian */
|
||||
APP_USBD_LANG_RUSSIAN = 0x19U << ( APP_USB_LANG_OFFSET ), /**< Russian */
|
||||
APP_USBD_LANG_CROATIAN = 0x1aU << ( APP_USB_LANG_OFFSET ), /**< Croatian */
|
||||
APP_USBD_LANG_SERBIAN = 0x1aU << ( APP_USB_LANG_OFFSET ), /**< Serbian */
|
||||
APP_USBD_LANG_SLOVAK = 0x1bU << ( APP_USB_LANG_OFFSET ), /**< Slovak */
|
||||
APP_USBD_LANG_ALBANIAN = 0x1cU << ( APP_USB_LANG_OFFSET ), /**< Albanian */
|
||||
APP_USBD_LANG_SWEDISH = 0x1dU << ( APP_USB_LANG_OFFSET ), /**< Swedish */
|
||||
APP_USBD_LANG_THAI = 0x1eU << ( APP_USB_LANG_OFFSET ), /**< Thai */
|
||||
APP_USBD_LANG_TURKISH = 0x1fU << ( APP_USB_LANG_OFFSET ), /**< Turkish */
|
||||
APP_USBD_LANG_URDU = 0x20U << ( APP_USB_LANG_OFFSET ), /**< Urdu */
|
||||
APP_USBD_LANG_INDONESIAN = 0x21U << ( APP_USB_LANG_OFFSET ), /**< Indonesian */
|
||||
APP_USBD_LANG_UKRANIAN = 0x22U << ( APP_USB_LANG_OFFSET ), /**< Ukrainian */
|
||||
APP_USBD_LANG_BELARUSIAN = 0x23U << ( APP_USB_LANG_OFFSET ), /**< Belarusian */
|
||||
APP_USBD_LANG_SLOVENIAN = 0x24U << ( APP_USB_LANG_OFFSET ), /**< Slovenian */
|
||||
APP_USBD_LANG_ESTONIAN = 0x25U << ( APP_USB_LANG_OFFSET ), /**< Estonian */
|
||||
APP_USBD_LANG_LATVIAN = 0x26U << ( APP_USB_LANG_OFFSET ), /**< Latvian */
|
||||
APP_USBD_LANG_LITHUANIAN = 0x27U << ( APP_USB_LANG_OFFSET ), /**< Lithuanian */
|
||||
APP_USBD_LANG_FARSI = 0x29U << ( APP_USB_LANG_OFFSET ), /**< Farsi */
|
||||
APP_USBD_LANG_VIETNAMESE = 0x2aU << ( APP_USB_LANG_OFFSET ), /**< Vietnamese */
|
||||
APP_USBD_LANG_ARMENIAN = 0x2bU << ( APP_USB_LANG_OFFSET ), /**< Armenian */
|
||||
APP_USBD_LANG_AZERI = 0x2cU << ( APP_USB_LANG_OFFSET ), /**< Azeri */
|
||||
APP_USBD_LANG_BASQUE = 0x2dU << ( APP_USB_LANG_OFFSET ), /**< Basque */
|
||||
APP_USBD_LANG_MACEDONIAN = 0x2fU << ( APP_USB_LANG_OFFSET ), /**< Macedonian */
|
||||
APP_USBD_LANG_AFRIKAANS = 0x36U << ( APP_USB_LANG_OFFSET ), /**< Afrikaans */
|
||||
APP_USBD_LANG_GEORGIAN = 0x37U << ( APP_USB_LANG_OFFSET ), /**< Georgian */
|
||||
APP_USBD_LANG_FAEROESE = 0x38U << ( APP_USB_LANG_OFFSET ), /**< Faeroese */
|
||||
APP_USBD_LANG_HINDI = 0x39U << ( APP_USB_LANG_OFFSET ), /**< Hindi */
|
||||
APP_USBD_LANG_MALAY = 0x3eU << ( APP_USB_LANG_OFFSET ), /**< Malay */
|
||||
APP_USBD_LANG_KAZAK = 0x3fU << ( APP_USB_LANG_OFFSET ), /**< Kazak */
|
||||
APP_USBD_LANG_SWAHILI = 0x41U << ( APP_USB_LANG_OFFSET ), /**< Swahili */
|
||||
APP_USBD_LANG_UZBEK = 0x43U << ( APP_USB_LANG_OFFSET ), /**< Uzbek */
|
||||
APP_USBD_LANG_TATAR = 0x44U << ( APP_USB_LANG_OFFSET ), /**< Tatar */
|
||||
APP_USBD_LANG_BENGALI = 0x45U << ( APP_USB_LANG_OFFSET ), /**< Bengali */
|
||||
APP_USBD_LANG_PUNJABI = 0x46U << ( APP_USB_LANG_OFFSET ), /**< Punjabi */
|
||||
APP_USBD_LANG_GUJARATI = 0x47U << ( APP_USB_LANG_OFFSET ), /**< Gujarati */
|
||||
APP_USBD_LANG_ORIYA = 0x48U << ( APP_USB_LANG_OFFSET ), /**< Oriya */
|
||||
APP_USBD_LANG_TAMIL = 0x49U << ( APP_USB_LANG_OFFSET ), /**< Tamil */
|
||||
APP_USBD_LANG_TELUGU = 0x4aU << ( APP_USB_LANG_OFFSET ), /**< Telugu */
|
||||
APP_USBD_LANG_KANNADA = 0x4bU << ( APP_USB_LANG_OFFSET ), /**< Kannada */
|
||||
APP_USBD_LANG_MALAYALAM = 0x4cU << ( APP_USB_LANG_OFFSET ), /**< Malayalam */
|
||||
APP_USBD_LANG_ASSAMESE = 0x4dU << ( APP_USB_LANG_OFFSET ), /**< Assamese */
|
||||
APP_USBD_LANG_MARATHI = 0x4eU << ( APP_USB_LANG_OFFSET ), /**< Marathi */
|
||||
APP_USBD_LANG_SANSKRIT = 0x4fU << ( APP_USB_LANG_OFFSET ), /**< Sanskrit */
|
||||
APP_USBD_LANG_KONKANI = 0x57U << ( APP_USB_LANG_OFFSET ), /**< Konkani */
|
||||
APP_USBD_LANG_MANIPURI = 0x58U << ( APP_USB_LANG_OFFSET ), /**< Manipuri */
|
||||
APP_USBD_LANG_SINDHI = 0x59U << ( APP_USB_LANG_OFFSET ), /**< Sindhi */
|
||||
APP_USBD_LANG_KASHMIRI = 0x60U << ( APP_USB_LANG_OFFSET ), /**< Kashmiri */
|
||||
APP_USBD_LANG_NEPALI = 0x61U << ( APP_USB_LANG_OFFSET ), /**< Nepali */
|
||||
APP_USBD_LANG_HID = 0xffU << ( APP_USB_LANG_OFFSET ), /**< Reserved for USB HID Class use */
|
||||
}app_usbd_langid_primary_t;
|
||||
APP_USBD_LANG_ARABIC = APP_USB_LANG_DEF(0x01U), /**< Arabic */
|
||||
APP_USBD_LANG_BULGARIAN = APP_USB_LANG_DEF(0x02U), /**< Bulgarian */
|
||||
APP_USBD_LANG_CATALAN = APP_USB_LANG_DEF(0x03U), /**< Catalan */
|
||||
APP_USBD_LANG_CHINESE = APP_USB_LANG_DEF(0x04U), /**< Chinese */
|
||||
APP_USBD_LANG_CZECH = APP_USB_LANG_DEF(0x05U), /**< Czech */
|
||||
APP_USBD_LANG_DANISH = APP_USB_LANG_DEF(0x06U), /**< Danish */
|
||||
APP_USBD_LANG_GERMAN = APP_USB_LANG_DEF(0x07U), /**< German */
|
||||
APP_USBD_LANG_GREEK = APP_USB_LANG_DEF(0x08U), /**< Greek */
|
||||
APP_USBD_LANG_ENGLISH = APP_USB_LANG_DEF(0x09U), /**< English */
|
||||
APP_USBD_LANG_SPANISH = APP_USB_LANG_DEF(0x0aU), /**< Spanish */
|
||||
APP_USBD_LANG_FINNISH = APP_USB_LANG_DEF(0x0bU), /**< Finnish */
|
||||
APP_USBD_LANG_FRENCH = APP_USB_LANG_DEF(0x0cU), /**< French */
|
||||
APP_USBD_LANG_HEBREW = APP_USB_LANG_DEF(0x0dU), /**< Hebrew */
|
||||
APP_USBD_LANG_HUNGARIAN = APP_USB_LANG_DEF(0x0eU), /**< Hungarian */
|
||||
APP_USBD_LANG_ICELANDIC = APP_USB_LANG_DEF(0x0fU), /**< Icelandic */
|
||||
APP_USBD_LANG_ITALIAN = APP_USB_LANG_DEF(0x10U), /**< Italian */
|
||||
APP_USBD_LANG_JAPANESE = APP_USB_LANG_DEF(0x11U), /**< Japanese */
|
||||
APP_USBD_LANG_KOREAN = APP_USB_LANG_DEF(0x12U), /**< Korean */
|
||||
APP_USBD_LANG_DUTCH = APP_USB_LANG_DEF(0x13U), /**< Dutch */
|
||||
APP_USBD_LANG_NORWEGIAN = APP_USB_LANG_DEF(0x14U), /**< Norwegian */
|
||||
APP_USBD_LANG_POLISH = APP_USB_LANG_DEF(0x15U), /**< Polish */
|
||||
APP_USBD_LANG_PORTUGUESE = APP_USB_LANG_DEF(0x16U), /**< Portuguese */
|
||||
APP_USBD_LANG_ROMANIAN = APP_USB_LANG_DEF(0x18U), /**< Romanian */
|
||||
APP_USBD_LANG_RUSSIAN = APP_USB_LANG_DEF(0x19U), /**< Russian */
|
||||
APP_USBD_LANG_CROATIAN = APP_USB_LANG_DEF(0x1aU), /**< Croatian */
|
||||
APP_USBD_LANG_SERBIAN = APP_USB_LANG_DEF(0x1aU), /**< Serbian */
|
||||
APP_USBD_LANG_SLOVAK = APP_USB_LANG_DEF(0x1bU), /**< Slovak */
|
||||
APP_USBD_LANG_ALBANIAN = APP_USB_LANG_DEF(0x1cU), /**< Albanian */
|
||||
APP_USBD_LANG_SWEDISH = APP_USB_LANG_DEF(0x1dU), /**< Swedish */
|
||||
APP_USBD_LANG_THAI = APP_USB_LANG_DEF(0x1eU), /**< Thai */
|
||||
APP_USBD_LANG_TURKISH = APP_USB_LANG_DEF(0x1fU), /**< Turkish */
|
||||
APP_USBD_LANG_URDU = APP_USB_LANG_DEF(0x20U), /**< Urdu */
|
||||
APP_USBD_LANG_INDONESIAN = APP_USB_LANG_DEF(0x21U), /**< Indonesian */
|
||||
APP_USBD_LANG_UKRANIAN = APP_USB_LANG_DEF(0x22U), /**< Ukrainian */
|
||||
APP_USBD_LANG_BELARUSIAN = APP_USB_LANG_DEF(0x23U), /**< Belarusian */
|
||||
APP_USBD_LANG_SLOVENIAN = APP_USB_LANG_DEF(0x24U), /**< Slovenian */
|
||||
APP_USBD_LANG_ESTONIAN = APP_USB_LANG_DEF(0x25U), /**< Estonian */
|
||||
APP_USBD_LANG_LATVIAN = APP_USB_LANG_DEF(0x26U), /**< Latvian */
|
||||
APP_USBD_LANG_LITHUANIAN = APP_USB_LANG_DEF(0x27U), /**< Lithuanian */
|
||||
APP_USBD_LANG_FARSI = APP_USB_LANG_DEF(0x29U), /**< Farsi */
|
||||
APP_USBD_LANG_VIETNAMESE = APP_USB_LANG_DEF(0x2aU), /**< Vietnamese */
|
||||
APP_USBD_LANG_ARMENIAN = APP_USB_LANG_DEF(0x2bU), /**< Armenian */
|
||||
APP_USBD_LANG_AZERI = APP_USB_LANG_DEF(0x2cU), /**< Azeri */
|
||||
APP_USBD_LANG_BASQUE = APP_USB_LANG_DEF(0x2dU), /**< Basque */
|
||||
APP_USBD_LANG_MACEDONIAN = APP_USB_LANG_DEF(0x2fU), /**< Macedonian */
|
||||
APP_USBD_LANG_AFRIKAANS = APP_USB_LANG_DEF(0x36U), /**< Afrikaans */
|
||||
APP_USBD_LANG_GEORGIAN = APP_USB_LANG_DEF(0x37U), /**< Georgian */
|
||||
APP_USBD_LANG_FAEROESE = APP_USB_LANG_DEF(0x38U), /**< Faeroese */
|
||||
APP_USBD_LANG_HINDI = APP_USB_LANG_DEF(0x39U), /**< Hindi */
|
||||
APP_USBD_LANG_MALAY = APP_USB_LANG_DEF(0x3eU), /**< Malay */
|
||||
APP_USBD_LANG_KAZAK = APP_USB_LANG_DEF(0x3fU), /**< Kazak */
|
||||
APP_USBD_LANG_SWAHILI = APP_USB_LANG_DEF(0x41U), /**< Swahili */
|
||||
APP_USBD_LANG_UZBEK = APP_USB_LANG_DEF(0x43U), /**< Uzbek */
|
||||
APP_USBD_LANG_TATAR = APP_USB_LANG_DEF(0x44U), /**< Tatar */
|
||||
APP_USBD_LANG_BENGALI = APP_USB_LANG_DEF(0x45U), /**< Bengali */
|
||||
APP_USBD_LANG_PUNJABI = APP_USB_LANG_DEF(0x46U), /**< Punjabi */
|
||||
APP_USBD_LANG_GUJARATI = APP_USB_LANG_DEF(0x47U), /**< Gujarati */
|
||||
APP_USBD_LANG_ORIYA = APP_USB_LANG_DEF(0x48U), /**< Oriya */
|
||||
APP_USBD_LANG_TAMIL = APP_USB_LANG_DEF(0x49U), /**< Tamil */
|
||||
APP_USBD_LANG_TELUGU = APP_USB_LANG_DEF(0x4aU), /**< Telugu */
|
||||
APP_USBD_LANG_KANNADA = APP_USB_LANG_DEF(0x4bU), /**< Kannada */
|
||||
APP_USBD_LANG_MALAYALAM = APP_USB_LANG_DEF(0x4cU), /**< Malayalam */
|
||||
APP_USBD_LANG_ASSAMESE = APP_USB_LANG_DEF(0x4dU), /**< Assamese */
|
||||
APP_USBD_LANG_MARATHI = APP_USB_LANG_DEF(0x4eU), /**< Marathi */
|
||||
APP_USBD_LANG_SANSKRIT = APP_USB_LANG_DEF(0x4fU), /**< Sanskrit */
|
||||
APP_USBD_LANG_KONKANI = APP_USB_LANG_DEF(0x57U), /**< Konkani */
|
||||
APP_USBD_LANG_MANIPURI = APP_USB_LANG_DEF(0x58U), /**< Manipuri */
|
||||
APP_USBD_LANG_SINDHI = APP_USB_LANG_DEF(0x59U), /**< Sindhi */
|
||||
APP_USBD_LANG_KASHMIRI = APP_USB_LANG_DEF(0x60U), /**< Kashmiri */
|
||||
APP_USBD_LANG_NEPALI = APP_USB_LANG_DEF(0x61U), /**< Nepali */
|
||||
APP_USBD_LANG_HID = APP_USB_LANG_DEF(0xffU), /**< Reserved for USB HID Class use. */
|
||||
} app_usbd_langid_primary_t;
|
||||
|
||||
/**
|
||||
* @brief Sublanguage identifiers
|
||||
* @brief Sublanguage identifiers.
|
||||
*
|
||||
* Mnemonics with sublanguage values.
|
||||
* Use them in combination with @ref app_usbd_langid_primary_t.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
APP_USBD_SUBLANG_ARABIC_SAUDI_ARABIA = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Saudi Arabia) */
|
||||
APP_USBD_SUBLANG_ARABIC_IRAQ = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Iraq) */
|
||||
APP_USBD_SUBLANG_ARABIC_EGYPT = 0x03U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Egypt) */
|
||||
APP_USBD_SUBLANG_ARABIC_LIBYA = 0x04U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Libya) */
|
||||
APP_USBD_SUBLANG_ARABIC_ALGERIA = 0x05U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Algeria) */
|
||||
APP_USBD_SUBLANG_ARABIC_MOROCCO = 0x06U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Morocco) */
|
||||
APP_USBD_SUBLANG_ARABIC_TUNISIA = 0x07U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Tunisia) */
|
||||
APP_USBD_SUBLANG_ARABIC_OMAN = 0x08U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Oman) */
|
||||
APP_USBD_SUBLANG_ARABIC_YEMEN = 0x09U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Yemen) */
|
||||
APP_USBD_SUBLANG_ARABIC_SYRIA = 0x10U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Syria) */
|
||||
APP_USBD_SUBLANG_ARABIC_JORDAN = 0x11U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Jordan) */
|
||||
APP_USBD_SUBLANG_ARABIC_LEBANON = 0x12U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Lebanon) */
|
||||
APP_USBD_SUBLANG_ARABIC_KUWAIT = 0x13U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Kuwait) */
|
||||
APP_USBD_SUBLANG_ARABIC_UAE = 0x14U << ( APP_USB_LANG_OFFSET ), /**< Arabic (U.A.E.) */
|
||||
APP_USBD_SUBLANG_ARABIC_BAHRAIN = 0x15U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Bahrain) */
|
||||
APP_USBD_SUBLANG_ARABIC_QATAR = 0x16U << ( APP_USB_LANG_OFFSET ), /**< Arabic (Qatar) */
|
||||
APP_USBD_SUBLANG_AZERI_CYRILLIC = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Azeri (Cyrillic) */
|
||||
APP_USBD_SUBLANG_AZERI_LATIN = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Azeri (Latin) */
|
||||
APP_USBD_SUBLANG_CHINESE_TRADITIONAL = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Chinese (Traditional) */
|
||||
APP_USBD_SUBLANG_CHINESE_SIMPLIFIED = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Chinese (Simplified) */
|
||||
APP_USBD_SUBLANG_CHINESE_HONGKONG = 0x03U << ( APP_USB_LANG_OFFSET ), /**< Chinese (Hong Kong SAR, PRC) */
|
||||
APP_USBD_SUBLANG_CHINESE_SINGAPORE = 0x04U << ( APP_USB_LANG_OFFSET ), /**< Chinese (Singapore) */
|
||||
APP_USBD_SUBLANG_CHINESE_MACAU = 0x05U << ( APP_USB_LANG_OFFSET ), /**< Chinese (Macau SAR) */
|
||||
APP_USBD_SUBLANG_DUTCH = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Dutch */
|
||||
APP_USBD_SUBLANG_DUTCH_BELGIAN = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Dutch (Belgian) */
|
||||
APP_USBD_SUBLANG_ENGLISH_US = 0x01U << ( APP_USB_LANG_OFFSET ), /**< English (US) */
|
||||
APP_USBD_SUBLANG_ENGLISH_UK = 0x02U << ( APP_USB_LANG_OFFSET ), /**< English (UK) */
|
||||
APP_USBD_SUBLANG_ENGLISH_AUS = 0x03U << ( APP_USB_LANG_OFFSET ), /**< English (Australian) */
|
||||
APP_USBD_SUBLANG_ENGLISH_CAN = 0x04U << ( APP_USB_LANG_OFFSET ), /**< English (Canadian) */
|
||||
APP_USBD_SUBLANG_ENGLISH_NZ = 0x05U << ( APP_USB_LANG_OFFSET ), /**< English (New Zealand) */
|
||||
APP_USBD_SUBLANG_ENGLISH_EIRE = 0x06U << ( APP_USB_LANG_OFFSET ), /**< English (Ireland) */
|
||||
APP_USBD_SUBLANG_ENGLISH_SOUTH_AFRICA = 0x07U << ( APP_USB_LANG_OFFSET ), /**< English (South Africa) */
|
||||
APP_USBD_SUBLANG_ENGLISH_JAMAICA = 0x08U << ( APP_USB_LANG_OFFSET ), /**< English (Jamaica) */
|
||||
APP_USBD_SUBLANG_ENGLISH_CARIBBEAN = 0x09U << ( APP_USB_LANG_OFFSET ), /**< English (Caribbean) */
|
||||
APP_USBD_SUBLANG_ENGLISH_BELIZE = 0x0aU << ( APP_USB_LANG_OFFSET ), /**< English (Belize) */
|
||||
APP_USBD_SUBLANG_ENGLISH_TRINIDAD = 0x0bU << ( APP_USB_LANG_OFFSET ), /**< English (Trinidad) */
|
||||
APP_USBD_SUBLANG_ENGLISH_PHILIPPINES = 0x0cU << ( APP_USB_LANG_OFFSET ), /**< English (Zimbabwe) */
|
||||
APP_USBD_SUBLANG_ENGLISH_ZIMBABWE = 0x0dU << ( APP_USB_LANG_OFFSET ), /**< English (Philippines) */
|
||||
APP_USBD_SUBLANG_FRENCH = 0x01U << ( APP_USB_LANG_OFFSET ), /**< French */
|
||||
APP_USBD_SUBLANG_FRENCH_BELGIAN = 0x02U << ( APP_USB_LANG_OFFSET ), /**< French (Belgian) */
|
||||
APP_USBD_SUBLANG_FRENCH_CANADIAN = 0x03U << ( APP_USB_LANG_OFFSET ), /**< French (Canadian) */
|
||||
APP_USBD_SUBLANG_FRENCH_SWISS = 0x04U << ( APP_USB_LANG_OFFSET ), /**< French (Swiss) */
|
||||
APP_USBD_SUBLANG_FRENCH_LUXEMBOURG = 0x05U << ( APP_USB_LANG_OFFSET ), /**< French (Luxembourg) */
|
||||
APP_USBD_SUBLANG_FRENCH_MONACO = 0x06U << ( APP_USB_LANG_OFFSET ), /**< French (Monaco) */
|
||||
APP_USBD_SUBLANG_GERMAN = 0x01U << ( APP_USB_LANG_OFFSET ), /**< German */
|
||||
APP_USBD_SUBLANG_GERMAN_SWISS = 0x02U << ( APP_USB_LANG_OFFSET ), /**< German (Swiss) */
|
||||
APP_USBD_SUBLANG_GERMAN_AUSTRIAN = 0x03U << ( APP_USB_LANG_OFFSET ), /**< German (Austrian) */
|
||||
APP_USBD_SUBLANG_GERMAN_LUXEMBOURG = 0x04U << ( APP_USB_LANG_OFFSET ), /**< German (Luxembourg) */
|
||||
APP_USBD_SUBLANG_GERMAN_LIECHTENSTEIN = 0x05U << ( APP_USB_LANG_OFFSET ), /**< German (Liechtenstein) */
|
||||
APP_USBD_SUBLANG_ITALIAN = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Italian */
|
||||
APP_USBD_SUBLANG_ITALIAN_SWISS = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Italian (Swiss) */
|
||||
APP_USBD_SUBLANG_KASHMIRI_INDIA = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Kashmiri (India) */
|
||||
APP_USBD_SUBLANG_KOREAN = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Korean */
|
||||
APP_USBD_SUBLANG_LITHUANIAN = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Lithuanian */
|
||||
APP_USBD_SUBLANG_MALAY_MALAYSIA = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Malay (Malaysia) */
|
||||
APP_USBD_SUBLANG_MALAY_BRUNEI_DARUSSALAM = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Malay (Brunei Darassalam) */
|
||||
APP_USBD_SUBLANG_NEPALI_INDIA = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Nepali (India) */
|
||||
APP_USBD_SUBLANG_NORWEGIAN_BOKMAL = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Norwegian (Bokmal) */
|
||||
APP_USBD_SUBLANG_NORWEGIAN_NYNORSK = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Norwegian (Nynorsk) */
|
||||
APP_USBD_SUBLANG_PORTUGUESE = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Portuguese (Brazilian) */
|
||||
APP_USBD_SUBLANG_PORTUGUESE_BRAZILIAN = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Portuguese */
|
||||
APP_USBD_SUBLANG_SERBIAN_LATIN = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Serbian (Latin) */
|
||||
APP_USBD_SUBLANG_SERBIAN_CYRILLIC = 0x03U << ( APP_USB_LANG_OFFSET ), /**< Serbian (Cyrillic) */
|
||||
APP_USBD_SUBLANG_SPANISH = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Castilian) */
|
||||
APP_USBD_SUBLANG_SPANISH_MEXICAN = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Mexican) */
|
||||
APP_USBD_SUBLANG_SPANISH_MODERN = 0x03U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Modern) */
|
||||
APP_USBD_SUBLANG_SPANISH_GUATEMALA = 0x04U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Guatemala) */
|
||||
APP_USBD_SUBLANG_SPANISH_COSTA_RICA = 0x05U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Costa Rica) */
|
||||
APP_USBD_SUBLANG_SPANISH_PANAMA = 0x06U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Panama) */
|
||||
APP_USBD_SUBLANG_SPANISH_DOMINICAN_REPUBLIC = 0x07U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Dominican Republic) */
|
||||
APP_USBD_SUBLANG_SPANISH_VENEZUELA = 0x08U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Venezuela) */
|
||||
APP_USBD_SUBLANG_SPANISH_COLOMBIA = 0x09U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Colombia) */
|
||||
APP_USBD_SUBLANG_SPANISH_PERU = 0x0aU << ( APP_USB_LANG_OFFSET ), /**< Spanish (Peru) */
|
||||
APP_USBD_SUBLANG_SPANISH_ARGENTINA = 0x0bU << ( APP_USB_LANG_OFFSET ), /**< Spanish (Argentina) */
|
||||
APP_USBD_SUBLANG_SPANISH_ECUADOR = 0x0cU << ( APP_USB_LANG_OFFSET ), /**< Spanish (Ecuador) */
|
||||
APP_USBD_SUBLANG_SPANISH_CHILE = 0x0dU << ( APP_USB_LANG_OFFSET ), /**< Spanish (Chile) */
|
||||
APP_USBD_SUBLANG_SPANISH_URUGUAY = 0x0eU << ( APP_USB_LANG_OFFSET ), /**< Spanish (Uruguay) */
|
||||
APP_USBD_SUBLANG_SPANISH_PARAGUAY = 0x0fU << ( APP_USB_LANG_OFFSET ), /**< Spanish (Paraguay) */
|
||||
APP_USBD_SUBLANG_SPANISH_BOLIVIA = 0x10U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Bolivia) */
|
||||
APP_USBD_SUBLANG_SPANISH_EL_SALVADOR = 0x11U << ( APP_USB_LANG_OFFSET ), /**< Spanish (El Salvador) */
|
||||
APP_USBD_SUBLANG_SPANISH_HONDURAS = 0x12U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Honduras) */
|
||||
APP_USBD_SUBLANG_SPANISH_NICARAGUA = 0x13U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Nicaragua) */
|
||||
APP_USBD_SUBLANG_SPANISH_PUERTO_RICO = 0x14U << ( APP_USB_LANG_OFFSET ), /**< Spanish (Puerto Rico) */
|
||||
APP_USBD_SUBLANG_SWEDISH = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Swedish */
|
||||
APP_USBD_SUBLANG_SWEDISH_FINLAND = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Swedish (Finland) */
|
||||
APP_USBD_SUBLANG_URDU_PAKISTAN = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Urdu (Pakistan) */
|
||||
APP_USBD_SUBLANG_URDU_INDIA = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Urdu (India) */
|
||||
APP_USBD_SUBLANG_UZBEK_LATIN = 0x01U << ( APP_USB_LANG_OFFSET ), /**< Uzbek (Latin) */
|
||||
APP_USBD_SUBLANG_UZBEK_CYRILLIC = 0x02U << ( APP_USB_LANG_OFFSET ), /**< Uzbek (Cyrillic) */
|
||||
APP_USBD_SUBLANG_HID_USAGE_DATA_DESCRIPTOR = 0x01U << ( APP_USB_LANG_OFFSET ), /**< HID (Usage Data Descriptor) */
|
||||
APP_USBD_SUBLANG_HID_VENDOR_DEFINED_1 = 0x3cU << ( APP_USB_LANG_OFFSET ), /**< HID (Vendor Defined 1) */
|
||||
APP_USBD_SUBLANG_HID_VENDOR_DEFINED_2 = 0x3dU << ( APP_USB_LANG_OFFSET ), /**< HID (Vendor Defined 2) */
|
||||
APP_USBD_SUBLANG_HID_VENDOR_DEFINED_3 = 0x3eU << ( APP_USB_LANG_OFFSET ), /**< HID (Vendor Defined 3) */
|
||||
APP_USBD_SUBLANG_HID_VENDOR_DEFINED_4 = 0x3fU << ( APP_USB_LANG_OFFSET ), /**< HID (Vendor Defined 4) */
|
||||
}app_usbd_langid_sub_t;
|
||||
APP_USBD_SUBLANG_ARABIC_SAUDI_ARABIA = APP_USB_SUBLANG_DEF(0x01U), /**< Arabic (Saudi Arabia) */
|
||||
APP_USBD_SUBLANG_ARABIC_IRAQ = APP_USB_SUBLANG_DEF(0x02U), /**< Arabic (Iraq) */
|
||||
APP_USBD_SUBLANG_ARABIC_EGYPT = APP_USB_SUBLANG_DEF(0x03U), /**< Arabic (Egypt) */
|
||||
APP_USBD_SUBLANG_ARABIC_LIBYA = APP_USB_SUBLANG_DEF(0x04U), /**< Arabic (Libya) */
|
||||
APP_USBD_SUBLANG_ARABIC_ALGERIA = APP_USB_SUBLANG_DEF(0x05U), /**< Arabic (Algeria) */
|
||||
APP_USBD_SUBLANG_ARABIC_MOROCCO = APP_USB_SUBLANG_DEF(0x06U), /**< Arabic (Morocco) */
|
||||
APP_USBD_SUBLANG_ARABIC_TUNISIA = APP_USB_SUBLANG_DEF(0x07U), /**< Arabic (Tunisia) */
|
||||
APP_USBD_SUBLANG_ARABIC_OMAN = APP_USB_SUBLANG_DEF(0x08U), /**< Arabic (Oman) */
|
||||
APP_USBD_SUBLANG_ARABIC_YEMEN = APP_USB_SUBLANG_DEF(0x09U), /**< Arabic (Yemen) */
|
||||
APP_USBD_SUBLANG_ARABIC_SYRIA = APP_USB_SUBLANG_DEF(0x10U), /**< Arabic (Syria) */
|
||||
APP_USBD_SUBLANG_ARABIC_JORDAN = APP_USB_SUBLANG_DEF(0x11U), /**< Arabic (Jordan) */
|
||||
APP_USBD_SUBLANG_ARABIC_LEBANON = APP_USB_SUBLANG_DEF(0x12U), /**< Arabic (Lebanon) */
|
||||
APP_USBD_SUBLANG_ARABIC_KUWAIT = APP_USB_SUBLANG_DEF(0x13U), /**< Arabic (Kuwait) */
|
||||
APP_USBD_SUBLANG_ARABIC_UAE = APP_USB_SUBLANG_DEF(0x14U), /**< Arabic (U.A.E.) */
|
||||
APP_USBD_SUBLANG_ARABIC_BAHRAIN = APP_USB_SUBLANG_DEF(0x15U), /**< Arabic (Bahrain) */
|
||||
APP_USBD_SUBLANG_ARABIC_QATAR = APP_USB_SUBLANG_DEF(0x16U), /**< Arabic (Qatar) */
|
||||
APP_USBD_SUBLANG_AZERI_CYRILLIC = APP_USB_SUBLANG_DEF(0x01U), /**< Azeri (Cyrillic) */
|
||||
APP_USBD_SUBLANG_AZERI_LATIN = APP_USB_SUBLANG_DEF(0x02U), /**< Azeri (Latin) */
|
||||
APP_USBD_SUBLANG_CHINESE_TRADITIONAL = APP_USB_SUBLANG_DEF(0x01U), /**< Chinese (Traditional) */
|
||||
APP_USBD_SUBLANG_CHINESE_SIMPLIFIED = APP_USB_SUBLANG_DEF(0x02U), /**< Chinese (Simplified) */
|
||||
APP_USBD_SUBLANG_CHINESE_HONGKONG = APP_USB_SUBLANG_DEF(0x03U), /**< Chinese (Hong Kong SAR, PRC) */
|
||||
APP_USBD_SUBLANG_CHINESE_SINGAPORE = APP_USB_SUBLANG_DEF(0x04U), /**< Chinese (Singapore) */
|
||||
APP_USBD_SUBLANG_CHINESE_MACAU = APP_USB_SUBLANG_DEF(0x05U), /**< Chinese (Macau SAR) */
|
||||
APP_USBD_SUBLANG_DUTCH = APP_USB_SUBLANG_DEF(0x01U), /**< Dutch */
|
||||
APP_USBD_SUBLANG_DUTCH_BELGIAN = APP_USB_SUBLANG_DEF(0x02U), /**< Dutch (Belgian) */
|
||||
APP_USBD_SUBLANG_ENGLISH_US = APP_USB_SUBLANG_DEF(0x01U), /**< English (US) */
|
||||
APP_USBD_SUBLANG_ENGLISH_UK = APP_USB_SUBLANG_DEF(0x02U), /**< English (UK) */
|
||||
APP_USBD_SUBLANG_ENGLISH_AUS = APP_USB_SUBLANG_DEF(0x03U), /**< English (Australian) */
|
||||
APP_USBD_SUBLANG_ENGLISH_CAN = APP_USB_SUBLANG_DEF(0x04U), /**< English (Canadian) */
|
||||
APP_USBD_SUBLANG_ENGLISH_NZ = APP_USB_SUBLANG_DEF(0x05U), /**< English (New Zealand) */
|
||||
APP_USBD_SUBLANG_ENGLISH_EIRE = APP_USB_SUBLANG_DEF(0x06U), /**< English (Ireland) */
|
||||
APP_USBD_SUBLANG_ENGLISH_SOUTH_AFRICA = APP_USB_SUBLANG_DEF(0x07U), /**< English (South Africa) */
|
||||
APP_USBD_SUBLANG_ENGLISH_JAMAICA = APP_USB_SUBLANG_DEF(0x08U), /**< English (Jamaica) */
|
||||
APP_USBD_SUBLANG_ENGLISH_CARIBBEAN = APP_USB_SUBLANG_DEF(0x09U), /**< English (Caribbean) */
|
||||
APP_USBD_SUBLANG_ENGLISH_BELIZE = APP_USB_SUBLANG_DEF(0x0aU), /**< English (Belize) */
|
||||
APP_USBD_SUBLANG_ENGLISH_TRINIDAD = APP_USB_SUBLANG_DEF(0x0bU), /**< English (Trinidad) */
|
||||
APP_USBD_SUBLANG_ENGLISH_PHILIPPINES = APP_USB_SUBLANG_DEF(0x0cU), /**< English (Zimbabwe) */
|
||||
APP_USBD_SUBLANG_ENGLISH_ZIMBABWE = APP_USB_SUBLANG_DEF(0x0dU), /**< English (Philippines) */
|
||||
APP_USBD_SUBLANG_FRENCH = APP_USB_SUBLANG_DEF(0x01U), /**< French */
|
||||
APP_USBD_SUBLANG_FRENCH_BELGIAN = APP_USB_SUBLANG_DEF(0x02U), /**< French (Belgian) */
|
||||
APP_USBD_SUBLANG_FRENCH_CANADIAN = APP_USB_SUBLANG_DEF(0x03U), /**< French (Canadian) */
|
||||
APP_USBD_SUBLANG_FRENCH_SWISS = APP_USB_SUBLANG_DEF(0x04U), /**< French (Switzerland) */
|
||||
APP_USBD_SUBLANG_FRENCH_LUXEMBOURG = APP_USB_SUBLANG_DEF(0x05U), /**< French (Luxembourg) */
|
||||
APP_USBD_SUBLANG_FRENCH_MONACO = APP_USB_SUBLANG_DEF(0x06U), /**< French (Monaco) */
|
||||
APP_USBD_SUBLANG_GERMAN = APP_USB_SUBLANG_DEF(0x01U), /**< German */
|
||||
APP_USBD_SUBLANG_GERMAN_SWISS = APP_USB_SUBLANG_DEF(0x02U), /**< German (Switzerland) */
|
||||
APP_USBD_SUBLANG_GERMAN_AUSTRIAN = APP_USB_SUBLANG_DEF(0x03U), /**< German (Austria) */
|
||||
APP_USBD_SUBLANG_GERMAN_LUXEMBOURG = APP_USB_SUBLANG_DEF(0x04U), /**< German (Luxembourg) */
|
||||
APP_USBD_SUBLANG_GERMAN_LIECHTENSTEIN = APP_USB_SUBLANG_DEF(0x05U), /**< German (Liechtenstein) */
|
||||
APP_USBD_SUBLANG_ITALIAN = APP_USB_SUBLANG_DEF(0x01U), /**< Italian */
|
||||
APP_USBD_SUBLANG_ITALIAN_SWISS = APP_USB_SUBLANG_DEF(0x02U), /**< Italian (Switzerland) */
|
||||
APP_USBD_SUBLANG_KASHMIRI_INDIA = APP_USB_SUBLANG_DEF(0x02U), /**< Kashmiri (India) */
|
||||
APP_USBD_SUBLANG_KOREAN = APP_USB_SUBLANG_DEF(0x01U), /**< Korean */
|
||||
APP_USBD_SUBLANG_LITHUANIAN = APP_USB_SUBLANG_DEF(0x01U), /**< Lithuanian */
|
||||
APP_USBD_SUBLANG_MALAY_MALAYSIA = APP_USB_SUBLANG_DEF(0x01U), /**< Malay (Malaysia) */
|
||||
APP_USBD_SUBLANG_MALAY_BRUNEI_DARUSSALAM = APP_USB_SUBLANG_DEF(0x02U), /**< Malay (Brunei Darassalam) */
|
||||
APP_USBD_SUBLANG_NEPALI_INDIA = APP_USB_SUBLANG_DEF(0x02U), /**< Nepali (India) */
|
||||
APP_USBD_SUBLANG_NORWEGIAN_BOKMAL = APP_USB_SUBLANG_DEF(0x01U), /**< Norwegian (Bokmal) */
|
||||
APP_USBD_SUBLANG_NORWEGIAN_NYNORSK = APP_USB_SUBLANG_DEF(0x02U), /**< Norwegian (Nynorsk) */
|
||||
APP_USBD_SUBLANG_PORTUGUESE = APP_USB_SUBLANG_DEF(0x01U), /**< Portuguese */
|
||||
APP_USBD_SUBLANG_PORTUGUESE_BRAZILIAN = APP_USB_SUBLANG_DEF(0x02U), /**< Portuguese (Brazil) */
|
||||
APP_USBD_SUBLANG_SERBIAN_LATIN = APP_USB_SUBLANG_DEF(0x02U), /**< Serbian (Latin) */
|
||||
APP_USBD_SUBLANG_SERBIAN_CYRILLIC = APP_USB_SUBLANG_DEF(0x03U), /**< Serbian (Cyrillic) */
|
||||
APP_USBD_SUBLANG_SPANISH = APP_USB_SUBLANG_DEF(0x01U), /**< Spanish (Traditional) */
|
||||
APP_USBD_SUBLANG_SPANISH_MEXICAN = APP_USB_SUBLANG_DEF(0x02U), /**< Spanish (Mexican) */
|
||||
APP_USBD_SUBLANG_SPANISH_MODERN = APP_USB_SUBLANG_DEF(0x03U), /**< Spanish (Modern) */
|
||||
APP_USBD_SUBLANG_SPANISH_GUATEMALA = APP_USB_SUBLANG_DEF(0x04U), /**< Spanish (Guatemala) */
|
||||
APP_USBD_SUBLANG_SPANISH_COSTA_RICA = APP_USB_SUBLANG_DEF(0x05U), /**< Spanish (Costa Rica) */
|
||||
APP_USBD_SUBLANG_SPANISH_PANAMA = APP_USB_SUBLANG_DEF(0x06U), /**< Spanish (Panama) */
|
||||
APP_USBD_SUBLANG_SPANISH_DOMINICAN_REPUBLIC = APP_USB_SUBLANG_DEF(0x07U), /**< Spanish (Dominican Republic) */
|
||||
APP_USBD_SUBLANG_SPANISH_VENEZUELA = APP_USB_SUBLANG_DEF(0x08U), /**< Spanish (Venezuela) */
|
||||
APP_USBD_SUBLANG_SPANISH_COLOMBIA = APP_USB_SUBLANG_DEF(0x09U), /**< Spanish (Colombia) */
|
||||
APP_USBD_SUBLANG_SPANISH_PERU = APP_USB_SUBLANG_DEF(0x0aU), /**< Spanish (Peru) */
|
||||
APP_USBD_SUBLANG_SPANISH_ARGENTINA = APP_USB_SUBLANG_DEF(0x0bU), /**< Spanish (Argentina) */
|
||||
APP_USBD_SUBLANG_SPANISH_ECUADOR = APP_USB_SUBLANG_DEF(0x0cU), /**< Spanish (Ecuador) */
|
||||
APP_USBD_SUBLANG_SPANISH_CHILE = APP_USB_SUBLANG_DEF(0x0dU), /**< Spanish (Chile) */
|
||||
APP_USBD_SUBLANG_SPANISH_URUGUAY = APP_USB_SUBLANG_DEF(0x0eU), /**< Spanish (Uruguay) */
|
||||
APP_USBD_SUBLANG_SPANISH_PARAGUAY = APP_USB_SUBLANG_DEF(0x0fU), /**< Spanish (Paraguay) */
|
||||
APP_USBD_SUBLANG_SPANISH_BOLIVIA = APP_USB_SUBLANG_DEF(0x10U), /**< Spanish (Bolivia) */
|
||||
APP_USBD_SUBLANG_SPANISH_EL_SALVADOR = APP_USB_SUBLANG_DEF(0x11U), /**< Spanish (El Salvador) */
|
||||
APP_USBD_SUBLANG_SPANISH_HONDURAS = APP_USB_SUBLANG_DEF(0x12U), /**< Spanish (Honduras) */
|
||||
APP_USBD_SUBLANG_SPANISH_NICARAGUA = APP_USB_SUBLANG_DEF(0x13U), /**< Spanish (Nicaragua) */
|
||||
APP_USBD_SUBLANG_SPANISH_PUERTO_RICO = APP_USB_SUBLANG_DEF(0x14U), /**< Spanish (Puerto Rico) */
|
||||
APP_USBD_SUBLANG_SWEDISH = APP_USB_SUBLANG_DEF(0x01U), /**< Swedish */
|
||||
APP_USBD_SUBLANG_SWEDISH_FINLAND = APP_USB_SUBLANG_DEF(0x02U), /**< Swedish (Finland) */
|
||||
APP_USBD_SUBLANG_URDU_PAKISTAN = APP_USB_SUBLANG_DEF(0x01U), /**< Urdu (Pakistan) */
|
||||
APP_USBD_SUBLANG_URDU_INDIA = APP_USB_SUBLANG_DEF(0x02U), /**< Urdu (India) */
|
||||
APP_USBD_SUBLANG_UZBEK_LATIN = APP_USB_SUBLANG_DEF(0x01U), /**< Uzbek (Latin) */
|
||||
APP_USBD_SUBLANG_UZBEK_CYRILLIC = APP_USB_SUBLANG_DEF(0x02U), /**< Uzbek (Cyrillic) */
|
||||
APP_USBD_SUBLANG_HID_USAGE_DATA_DESCRIPTOR = APP_USB_SUBLANG_DEF(0x01U), /**< HID (Usage Data Descriptor) */
|
||||
APP_USBD_SUBLANG_HID_VENDOR_DEFINED_1 = APP_USB_SUBLANG_DEF(0x3cU), /**< HID (Vendor Defined 1) */
|
||||
APP_USBD_SUBLANG_HID_VENDOR_DEFINED_2 = APP_USB_SUBLANG_DEF(0x3dU), /**< HID (Vendor Defined 2) */
|
||||
APP_USBD_SUBLANG_HID_VENDOR_DEFINED_3 = APP_USB_SUBLANG_DEF(0x3eU), /**< HID (Vendor Defined 3) */
|
||||
APP_USBD_SUBLANG_HID_VENDOR_DEFINED_4 = APP_USB_SUBLANG_DEF(0x3fU), /**< HID (Vendor Defined 4) */
|
||||
} app_usbd_langid_sub_t;
|
||||
|
||||
/**
|
||||
* @brief LANGID variable
|
||||
* @brief LANGID variable.
|
||||
*
|
||||
* The LANGID value is composed from:
|
||||
* - 10-bit (9-0) of Primary Language Identifiers
|
||||
* - 6-bit (15-10) of Sublanguage Identifiers.
|
||||
* The LANGID value is composed of:
|
||||
* - 10 bits (9-0) of Primary Language Identifier,
|
||||
* - 6 bits (15-10) of Sublanguage Identifier.
|
||||
*
|
||||
* @sa app_usbd_langid_primary_t
|
||||
* @sa app_usbd_langid_sub_t
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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 APP_USBD_REQUEST_H__
|
||||
@@ -65,21 +65,21 @@ ANON_UNIONS_ENABLE;
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Recipient bit-field in request type
|
||||
* @brief Recipient bit-field in request type.
|
||||
*
|
||||
* Bits 4...0
|
||||
*/
|
||||
#define APP_USBD_SETUP_REQ_BF_REC BF_CX(5, 0)
|
||||
|
||||
/**
|
||||
* @brief Type bit-field in request type
|
||||
* @brief Type bit-field in request type.
|
||||
*
|
||||
* Bits 6...5
|
||||
*/
|
||||
#define APP_USBD_SETUP_REQ_BF_TYP BF_CX(2, 5)
|
||||
|
||||
/**
|
||||
* @brief Direction bit-field in request type
|
||||
* @brief Direction bit-field in request type.
|
||||
*
|
||||
* Bit 7
|
||||
*/
|
||||
@@ -109,7 +109,7 @@ typedef enum {
|
||||
} app_usbd_setup_reqtype_t;
|
||||
|
||||
/**
|
||||
* @brief Direction of setup command
|
||||
* @brief Direction of setup command.
|
||||
*
|
||||
* @note It is part of @ref app_usbd_setup_reqtype_t variable type.
|
||||
*/
|
||||
@@ -120,9 +120,9 @@ typedef enum {
|
||||
|
||||
|
||||
/**
|
||||
* @brief Standard requests
|
||||
* @brief Standard requests.
|
||||
*
|
||||
* Enumerator for standard requests values
|
||||
* Enumerator for standard requests values.
|
||||
*/
|
||||
typedef enum {
|
||||
APP_USBD_SETUP_STDREQ_GET_STATUS = 0x00, /**<
|
||||
@@ -226,21 +226,22 @@ typedef enum {
|
||||
} app_usbd_setup_stdrequest_t;
|
||||
|
||||
/**
|
||||
* @brief Standard feature selectors
|
||||
* @brief Standard feature selectors.
|
||||
*
|
||||
* Standard features that may be disabled or enabled by
|
||||
* @ref APP_USBD_SETUP_STDREQ_CLEAR_FEATURE or @ref APP_USBD_SETUP_STDREQ_SET_FEATURE
|
||||
*/
|
||||
typedef enum {
|
||||
APP_USBD_SETUP_STDFEATURE_DEVICE_REMOTE_WAKEUP = 1, /**< Remote wakeup feature.
|
||||
*
|
||||
APP_USBD_SETUP_STDFEATURE_DEVICE_REMOTE_WAKEUP = 1, /**<
|
||||
* Remote wakeup feature.
|
||||
* Target: Device only
|
||||
*/
|
||||
APP_USBD_SETUP_STDFEATURE_ENDPOINT_HALT = 0, /**< Stall or clear the endpoint.
|
||||
*
|
||||
APP_USBD_SETUP_STDFEATURE_ENDPOINT_HALT = 0, /**<
|
||||
* Stall or clear the endpoint.
|
||||
* Target: Endpoint different than default (0)
|
||||
*/
|
||||
APP_USBD_SETUP_STDFEATURE_TEST_MODE = 2 /**< Upstream port test mode.
|
||||
APP_USBD_SETUP_STDFEATURE_TEST_MODE = 2 /**<
|
||||
* Upstream port test mode.
|
||||
* Power has to be cycled to exit test mode.
|
||||
* This feature cannot be cleared.
|
||||
*
|
||||
@@ -254,7 +255,7 @@ typedef enum {
|
||||
|
||||
|
||||
/**
|
||||
* @brief Universal way to access 16 bit values and its parts
|
||||
* @brief Universal way to access 16 bit values and its parts.
|
||||
*/
|
||||
typedef union {
|
||||
uint16_t w; //!< 16 bit access
|
||||
@@ -266,7 +267,7 @@ typedef union {
|
||||
} app_usbd_setup_w_t;
|
||||
|
||||
/**
|
||||
* @brief Internal redefinition of setup structure
|
||||
* @brief Internal redefinition of setup structure.
|
||||
*
|
||||
* Redefinition of the structure to simplify changes in the future
|
||||
* if required - app_usbd API would present setup data using app_usbd_setup_t.
|
||||
@@ -285,11 +286,11 @@ typedef struct {
|
||||
|
||||
|
||||
/**
|
||||
* @brief Extract recipient from request type
|
||||
* @brief Extract recipient from request type.
|
||||
*
|
||||
* @param[in] bmRequestType
|
||||
*
|
||||
* @return Extracted recipient field from request type value
|
||||
* @return Extracted recipient field from request type value.
|
||||
*/
|
||||
static inline app_usbd_setup_reqrec_t app_usbd_setup_req_rec(uint8_t bmRequestType)
|
||||
{
|
||||
@@ -297,11 +298,11 @@ static inline app_usbd_setup_reqrec_t app_usbd_setup_req_rec(uint8_t bmRequestTy
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Extract type from request type
|
||||
* @brief Extract type from request type.
|
||||
*
|
||||
* @param[in] bmRequestType
|
||||
*
|
||||
* @return Extracted type field from request type value
|
||||
* @return Extracted type field from request type value.
|
||||
*/
|
||||
static inline app_usbd_setup_reqtype_t app_usbd_setup_req_typ(uint8_t bmRequestType)
|
||||
{
|
||||
@@ -310,11 +311,11 @@ static inline app_usbd_setup_reqtype_t app_usbd_setup_req_typ(uint8_t bmRequestT
|
||||
|
||||
|
||||
/**
|
||||
* @brief Extract direction from request type
|
||||
* @brief Extract direction from request type.
|
||||
*
|
||||
* @param[in] bmRequestType
|
||||
*
|
||||
* @return Extracted direction field from request type value
|
||||
* @return Extracted direction field from request type value.
|
||||
*/
|
||||
static inline app_usbd_setup_reqdir_t app_usbd_setup_req_dir(uint8_t bmRequestType)
|
||||
{
|
||||
@@ -322,13 +323,13 @@ static inline app_usbd_setup_reqdir_t app_usbd_setup_req_dir(uint8_t bmRequestTy
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Make request type value
|
||||
* @brief Make request type value.
|
||||
*
|
||||
* @param[in] rec Recipient
|
||||
* @param[in] typ Request type
|
||||
* @param[in] dir Direction
|
||||
* @param[in] rec Recipient.
|
||||
* @param[in] typ Request type.
|
||||
* @param[in] dir Direction.
|
||||
*
|
||||
* @return Assembled request type value
|
||||
* @return Assembled request type value.
|
||||
*/
|
||||
static inline uint8_t app_usbd_setup_req_val(app_usbd_setup_reqrec_t rec,
|
||||
app_usbd_setup_reqtype_t typ,
|
||||
|
||||
@@ -1,87 +1,84 @@
|
||||
/**
|
||||
* Copyright (c) 2018 - 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.
|
||||
*
|
||||
*/
|
||||
#include "app_usbd_serial_num.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include "app_usbd.h"
|
||||
|
||||
#define SERIAL_NUMBER_STRING_SIZE (12)
|
||||
|
||||
/**@brief Serial number generated
|
||||
*
|
||||
* Serial number generated by the @ref serial_number_string_create function
|
||||
*/
|
||||
uint16_t g_extern_serial_number[SERIAL_NUMBER_STRING_SIZE + 1];
|
||||
|
||||
|
||||
/**@brief Function for creating the serial number string from a regular C string.
|
||||
*
|
||||
* @param[in] p_serial_number_string The serial number string. Must be terminated with \0.
|
||||
*/
|
||||
static void string_create(char * p_serial_number_string)
|
||||
{
|
||||
g_extern_serial_number[0] =
|
||||
(uint16_t)APP_USBD_DESCRIPTOR_STRING << 8 | sizeof(g_extern_serial_number);
|
||||
|
||||
for (uint32_t i = 0; i < strlen(p_serial_number_string); i++)
|
||||
{
|
||||
g_extern_serial_number[i + 1] = (uint8_t)p_serial_number_string[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void app_usbd_serial_num_generate(void)
|
||||
{
|
||||
char serial_number_string[SERIAL_NUMBER_STRING_SIZE + 1];
|
||||
const uint16_t serial_num_high_bytes = (uint16_t)NRF_FICR->DEVICEADDR[1] | 0xC000; // The masking makes the address match the Random Static BLE address.
|
||||
const uint32_t serial_num_low_bytes = NRF_FICR->DEVICEADDR[0];
|
||||
|
||||
(void)snprintf(serial_number_string,
|
||||
SERIAL_NUMBER_STRING_SIZE + 1,
|
||||
"%04"PRIX16"%08"PRIX32,
|
||||
serial_num_high_bytes,
|
||||
serial_num_low_bytes);
|
||||
|
||||
string_create(serial_number_string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
*/
|
||||
#include "app_usbd_serial_num.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include "app_usbd.h"
|
||||
|
||||
#define SERIAL_NUMBER_STRING_SIZE (12)
|
||||
|
||||
/**@brief Serial number generated.
|
||||
*
|
||||
* Serial number generated by the @ref serial_number_string_create function.
|
||||
*/
|
||||
uint8_t g_extern_serial_number[SERIAL_NUMBER_STRING_SIZE + 1];
|
||||
|
||||
|
||||
/**@brief Function for creating the serial number string from a regular C string.
|
||||
*
|
||||
* @param[in] p_serial_number_string The serial number string. Must be terminated with \0.
|
||||
*/
|
||||
static void string_create(char * p_serial_number_string)
|
||||
{
|
||||
|
||||
for (uint32_t i = 0; i < strlen(p_serial_number_string); i++)
|
||||
{
|
||||
g_extern_serial_number[i] = (uint8_t)p_serial_number_string[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void app_usbd_serial_num_generate(void)
|
||||
{
|
||||
char serial_number_string[SERIAL_NUMBER_STRING_SIZE + 1];
|
||||
const uint16_t serial_num_high_bytes = (uint16_t)NRF_FICR->DEVICEADDR[1] | 0xC000; // The masking makes the address match the Random Static BLE address.
|
||||
const uint32_t serial_num_low_bytes = NRF_FICR->DEVICEADDR[0];
|
||||
|
||||
(void)snprintf(serial_number_string,
|
||||
SERIAL_NUMBER_STRING_SIZE + 1,
|
||||
"%04"PRIX16"%08"PRIX32,
|
||||
serial_num_high_bytes,
|
||||
serial_num_low_bytes);
|
||||
|
||||
string_create(serial_number_string);
|
||||
}
|
||||
|
||||
@@ -1,54 +1,75 @@
|
||||
/**
|
||||
* Copyright (c) 2018 - 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 APP_USBD_SERIAL_NUM_H__
|
||||
#define APP_USBD_SERIAL_NUM_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/**@brief Function for generating a default serial number string based on FIRC->DEVICEADDR.
|
||||
*
|
||||
* The generated string is identical to the default BLE address. After calling this function, the
|
||||
* the serial number is ready for the USB driver.
|
||||
*/
|
||||
void app_usbd_serial_num_generate(void);
|
||||
|
||||
#endif // APP_USBD_SERIAL_NUM_H__
|
||||
/**
|
||||
* Copyright (c) 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 APP_USBD_SERIAL_NUM_H__
|
||||
#define APP_USBD_SERIAL_NUM_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup app_usbd_serial_num USBD serial number generator
|
||||
* @ingroup app_usbd
|
||||
*
|
||||
* @brief @tagAPI52840 Generate a standard USB serial number that is unique for each device.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**@brief Function for generating a default serial number string based on FIRC->DEVICEADDR.
|
||||
*
|
||||
* After calling this function, the serial number is ready for the USB driver.
|
||||
*
|
||||
* The generated serial number shows up as a 12-hexidecimal-digit string with no delimiters
|
||||
* (e.g 123456ABCDEF). The byte string is also printed on the PCA10059 dongle. It is also used as
|
||||
* the default advertising address in the SoftDevice.
|
||||
*/
|
||||
void app_usbd_serial_num_generate(void);
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // APP_USBD_SERIAL_NUM_H__
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
#include "sdk_config.h"
|
||||
#if APP_USBD_ENABLED
|
||||
@@ -43,56 +43,85 @@
|
||||
#include "app_usbd_langid.h"
|
||||
#include "app_usbd_core.h"
|
||||
#include "nordic_common.h"
|
||||
#include "utf.h"
|
||||
|
||||
/**
|
||||
* @defgroup app_usbd_string_desc
|
||||
* @ingroup app_usbd
|
||||
*
|
||||
* USBD string descriptors management
|
||||
* USBD string descriptor management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Array with language identifiers
|
||||
* @brief Array with language identifiers.
|
||||
*
|
||||
* This array would be used to search the proper string for selected language.
|
||||
* This array is used to search the proper string for the selected language.
|
||||
*/
|
||||
static const uint16_t m_langids[] = { APP_USBD_STRINGS_LANGIDS };
|
||||
static uint16_t const m_langids[] = { APP_USBD_STRINGS_LANGIDS };
|
||||
|
||||
/**
|
||||
* @brief Language ID descriptor
|
||||
* @brief Language ID descriptor.
|
||||
*
|
||||
* Language
|
||||
* Language.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Mnemonics for the string positions in the array
|
||||
* @brief Mnemonics for the string positions in the array.
|
||||
*
|
||||
* The mnemonics for the indexes of the strings inside the string array.
|
||||
*/
|
||||
enum {
|
||||
APP_USBD_STRING_ID_LANGIDS_ARRAY_POS = 0, /**< Supported language identifiers */
|
||||
APP_USBD_STRING_ID_MANUFACTURER_ARRAY_POS, /**< Manufacturer name */
|
||||
APP_USBD_STRING_ID_PRODUCT_ARRAY_POS, /**< Product name */
|
||||
APP_USBD_STRING_ID_SERIAL_ARRAY_POS, /**< Serial number */
|
||||
APP_USBD_STRING_ID_LANGIDS_ARRAY_POS = 0, /**< Supported language identifiers. */
|
||||
|
||||
#if (APP_USBD_STRING_ID_MANUFACTURER != 0)
|
||||
APP_USBD_STRING_ID_MANUFACTURER_ARRAY_POS, /**< Manufacturer name. */
|
||||
#endif // (APP_USBD_STRING_ID_MANUFACTURER != 0)
|
||||
|
||||
#if (APP_USBD_STRING_ID_PRODUCT != 0)
|
||||
APP_USBD_STRING_ID_PRODUCT_ARRAY_POS, /**< Product name. */
|
||||
#endif // (APP_USBD_STRING_ID_PRODUCT != 0)
|
||||
|
||||
#if (APP_USBD_STRING_ID_SERIAL != 0)
|
||||
APP_USBD_STRING_ID_SERIAL_ARRAY_POS, /**< Serial number. */
|
||||
#endif // (APP_USBD_STRING_ID_SERIAL != 0)
|
||||
|
||||
#if (APP_USBD_STRING_ID_CONFIGURATION != 0)
|
||||
APP_USBD_STRING_ID_CONFIGURATION_ARRAY_POS, /**< Configuration string. */
|
||||
#endif // (APP_USBD_STRING_ID_CONFIGURATION != 0)
|
||||
|
||||
#define X(mnemonic, str_idx, ...) CONCAT_2(mnemonic, _ARRAY_POS),
|
||||
APP_USBD_STRINGS_USER
|
||||
#undef X
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief String index into internal array index conversion table
|
||||
* @brief String index into internal array index conversion table.
|
||||
*
|
||||
* The array that transforms the USB string indexes into internal array position.
|
||||
* @note Value 0 used to mark non-existing string.
|
||||
* @note Value 0 is used to mark non-existing string.
|
||||
*/
|
||||
static const uint8_t m_string_translation[APP_USBD_STRING_ID_CNT] =
|
||||
static uint8_t const m_string_translation[APP_USBD_STRING_ID_CNT] =
|
||||
{
|
||||
[APP_USBD_STRING_ID_LANGIDS ] = APP_USBD_STRING_ID_LANGIDS_ARRAY_POS,
|
||||
[APP_USBD_STRING_ID_LANGIDS] = APP_USBD_STRING_ID_LANGIDS_ARRAY_POS,
|
||||
|
||||
#if (APP_USBD_STRING_ID_MANUFACTURER != 0)
|
||||
[APP_USBD_STRING_ID_MANUFACTURER] = APP_USBD_STRING_ID_MANUFACTURER_ARRAY_POS,
|
||||
[APP_USBD_STRING_ID_PRODUCT ] = APP_USBD_STRING_ID_PRODUCT_ARRAY_POS,
|
||||
[APP_USBD_STRING_ID_SERIAL ] = APP_USBD_STRING_ID_SERIAL_ARRAY_POS,
|
||||
#endif // (APP_USBD_STRING_ID_MANUFACTURER != 0)
|
||||
|
||||
#if (APP_USBD_STRING_ID_PRODUCT != 0)
|
||||
[APP_USBD_STRING_ID_PRODUCT] = APP_USBD_STRING_ID_PRODUCT_ARRAY_POS,
|
||||
#endif // (APP_USBD_STRING_ID_PRODUCT != 0)
|
||||
|
||||
#if (APP_USBD_STRING_ID_SERIAL != 0)
|
||||
[APP_USBD_STRING_ID_SERIAL] = APP_USBD_STRING_ID_SERIAL_ARRAY_POS,
|
||||
#endif // (APP_USBD_STRING_ID_SERIAL != 0)
|
||||
|
||||
#if (APP_USBD_STRING_ID_CONFIGURATION != 0)
|
||||
[APP_USBD_STRING_ID_CONFIGURATION] = APP_USBD_STRING_ID_CONFIGURATION_ARRAY_POS,
|
||||
#endif // (APP_USBD_STRING_ID_CONFIGURATION != 0)
|
||||
|
||||
#define X(mnemonic, str_idx, ...) [mnemonic] = CONCAT_2(mnemonic, _ARRAY_POS),
|
||||
APP_USBD_STRINGS_USER
|
||||
#undef X
|
||||
@@ -102,65 +131,139 @@ static const uint8_t m_string_translation[APP_USBD_STRING_ID_CNT] =
|
||||
#define APP_USBD_STRINGS_MANUFACTURER_EXTERN 0
|
||||
#endif
|
||||
|
||||
#if APP_USBD_STRINGS_MANUFACTURER_EXTERN
|
||||
extern uint8_t APP_USBD_STRINGS_MANUFACTURER[];
|
||||
#endif
|
||||
|
||||
#ifndef APP_USBD_STRINGS_PRODUCT_EXTERN
|
||||
#define APP_USBD_STRINGS_PRODUCT_EXTERN 0
|
||||
#endif
|
||||
|
||||
#if APP_USBD_STRINGS_PRODUCT_EXTERN
|
||||
extern uint8_t APP_USBD_STRINGS_PRODUCT[];
|
||||
#endif
|
||||
|
||||
#ifndef APP_USBD_STRING_SERIAL_EXTERN
|
||||
#define APP_USBD_STRING_SERIAL_EXTERN 0
|
||||
#endif
|
||||
|
||||
#if APP_USBD_STRINGS_MANUFACTURER_EXTERN
|
||||
extern uint16_t APP_USBD_STRINGS_MANUFACTURER[];
|
||||
#endif
|
||||
|
||||
#if APP_USBD_STRINGS_PRODUCT_EXTERN
|
||||
extern uint16_t APP_USBD_STRINGS_PRODUCT[];
|
||||
#endif
|
||||
|
||||
#if APP_USBD_STRING_SERIAL_EXTERN
|
||||
extern uint16_t APP_USBD_STRING_SERIAL[];
|
||||
extern uint8_t APP_USBD_STRING_SERIAL[];
|
||||
#endif
|
||||
|
||||
#ifndef APP_USBD_STRING_CONFIGURATION_EXTERN
|
||||
#define APP_USBD_STRING_CONFIGURATION_EXTERN 0
|
||||
#endif
|
||||
|
||||
#if APP_USBD_STRING_CONFIGURATION_EXTERN
|
||||
extern uint8_t APP_USBD_STRING_CONFIGURATION[];
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief String descriptors table
|
||||
* @brief String descriptor table.
|
||||
* */
|
||||
static const uint16_t * m_string_dsc[APP_USBD_STRING_ID_CNT][ARRAY_SIZE(m_langids)] =
|
||||
static uint8_t const * m_string_dsc[APP_USBD_STRING_ID_CNT][ARRAY_SIZE(m_langids)] =
|
||||
{
|
||||
[APP_USBD_STRING_ID_LANGIDS_ARRAY_POS] = { APP_USBD_STRING_DESC(APP_USBD_STRINGS_LANGIDS) },
|
||||
[APP_USBD_STRING_ID_LANGIDS_ARRAY_POS] = {APP_USBD_STRING_RAW16_DESC(APP_USBD_STRINGS_LANGIDS)},
|
||||
|
||||
#if (APP_USBD_STRING_ID_MANUFACTURER != 0)
|
||||
[APP_USBD_STRING_ID_MANUFACTURER_ARRAY_POS] = { APP_USBD_STRINGS_MANUFACTURER },
|
||||
[APP_USBD_STRING_ID_PRODUCT_ARRAY_POS] = { APP_USBD_STRINGS_PRODUCT },
|
||||
[APP_USBD_STRING_ID_SERIAL_ARRAY_POS] = { APP_USBD_STRING_SERIAL },
|
||||
#define X(mnemonic, str_idx, ...) [CONCAT_2(mnemonic, _ARRAY_POS)] = { __VA_ARGS__ },
|
||||
#endif // (APP_USBD_STRING_ID_MANUFACTURER != 0)
|
||||
|
||||
#if (APP_USBD_STRING_ID_PRODUCT != 0)
|
||||
[APP_USBD_STRING_ID_PRODUCT_ARRAY_POS] = { APP_USBD_STRINGS_PRODUCT },
|
||||
#endif // (APP_USBD_STRING_ID_PRODUCT != 0)
|
||||
|
||||
#if (APP_USBD_STRING_ID_SERIAL != 0)
|
||||
[APP_USBD_STRING_ID_SERIAL_ARRAY_POS] = { APP_USBD_STRING_SERIAL },
|
||||
#endif // (APP_USBD_STRING_ID_SERIAL != 0)
|
||||
|
||||
#if (APP_USBD_STRING_ID_CONFIGURATION != 0)
|
||||
[APP_USBD_STRING_ID_CONFIGURATION_ARRAY_POS] = { APP_USBD_STRINGS_CONFIGURATION },
|
||||
#endif // (APP_USBD_STRING_ID_CONFIGURATION != 0)
|
||||
|
||||
#define X(mnemonic, str_idx, ...) [CONCAT_2(mnemonic, _ARRAY_POS)] = {__VA_ARGS__},
|
||||
APP_USBD_STRINGS_USER
|
||||
#undef X
|
||||
};
|
||||
|
||||
|
||||
|
||||
uint16_t const * app_usbd_string_desc_get(app_usbd_string_desc_idx_t idx, uint16_t langid)
|
||||
/**
|
||||
* @brief Function for preparing UTF16 string descriptor.
|
||||
*
|
||||
* @param idx String descriptor ID.
|
||||
* @param langid Language ID.
|
||||
*
|
||||
* @return Pointer to the string descriptor.
|
||||
*/
|
||||
static uint16_t * app_usbd_prepare_string(uint8_t idx, uint16_t langid)
|
||||
{
|
||||
/* LANGID string */
|
||||
if (APP_USBD_STRING_ID_LANGIDS == idx)
|
||||
if (m_string_dsc[idx][langid][0] == 0x00)
|
||||
{
|
||||
return m_string_dsc[APP_USBD_STRING_ID_LANGIDS_ARRAY_POS][0];
|
||||
return (uint16_t *) &(m_string_dsc[idx][langid][2]);
|
||||
}
|
||||
|
||||
/* Searching for the language */
|
||||
#if ((APP_USBD_CONFIG_DESC_STRING_SIZE * 2) + 2) <= NRF_DRV_USBD_EPSIZE
|
||||
uint16_t * string_buffer = app_usbd_core_setup_transfer_buff_get(NULL);
|
||||
#else
|
||||
static uint16_t string_buffer[APP_USBD_CONFIG_DESC_STRING_SIZE + 1];
|
||||
// + 1 element for string descriptor type and size
|
||||
#endif
|
||||
|
||||
uint8_t size = 0;
|
||||
const uint8_t * p_pos = m_string_dsc[idx][langid];
|
||||
|
||||
#if APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED
|
||||
size = utf8UTF16Count((char *) p_pos, 0);
|
||||
ASSERT(size <= APP_USBD_CONFIG_DESC_STRING_SIZE);
|
||||
|
||||
uint16_t * p_out = &(string_buffer[1]);
|
||||
uint32_t rune;
|
||||
|
||||
while (*p_pos != 0)
|
||||
{
|
||||
p_pos = (uint8_t *) utf8DecodeRune((char *) p_pos, 0, &rune);
|
||||
p_out += utf16EncodeRune(rune, p_out);
|
||||
}
|
||||
#else
|
||||
while(*p_pos != 0)
|
||||
{
|
||||
ASSERT(size < APP_USBD_CONFIG_DESC_STRING_SIZE);
|
||||
++size;
|
||||
string_buffer[size] = *p_pos;
|
||||
++p_pos;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Descriptor size is length of the string times 2 bytes per character + 2 bytes for
|
||||
// descriptor type and size.
|
||||
string_buffer[0] = (0xff & (size * 2 + 2)) | ((uint16_t)APP_USBD_DESCRIPTOR_STRING) << 8;
|
||||
|
||||
return string_buffer;
|
||||
}
|
||||
|
||||
uint16_t const * app_usbd_string_desc_get(uint8_t idx, uint16_t langid)
|
||||
{
|
||||
/* LANGID string. */
|
||||
if (APP_USBD_STRING_ID_LANGIDS == idx)
|
||||
{
|
||||
return app_usbd_prepare_string(APP_USBD_STRING_ID_LANGIDS_ARRAY_POS, 0);
|
||||
}
|
||||
|
||||
/* Searching for the language. */
|
||||
uint8_t lang_idx = 0;
|
||||
if (ARRAY_SIZE(m_langids) > 1)
|
||||
{
|
||||
while (m_langids[lang_idx] != langid)
|
||||
{
|
||||
if (++lang_idx >= ARRAY_SIZE(m_langids))
|
||||
++lang_idx;
|
||||
if (lang_idx >= ARRAY_SIZE(m_langids))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the string index in array */
|
||||
/* Get the string index in array. */
|
||||
if (idx >= ARRAY_SIZE(m_string_translation))
|
||||
{
|
||||
return NULL;
|
||||
@@ -172,16 +275,20 @@ uint16_t const * app_usbd_string_desc_get(app_usbd_string_desc_idx_t idx, uint16
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint16_t const * p_str = m_string_dsc[str_pos][lang_idx];
|
||||
if ((ARRAY_SIZE(m_langids) > 1) && (lang_idx != 0))
|
||||
{
|
||||
if (p_str == NULL)
|
||||
if (m_string_dsc[str_pos][lang_idx] == NULL)
|
||||
{
|
||||
p_str = m_string_dsc[str_pos][0];
|
||||
lang_idx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return p_str;
|
||||
if (m_string_dsc[str_pos][lang_idx] == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return app_usbd_prepare_string(str_pos, lang_idx);
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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 APP_USBD_STRING_DESC_H__
|
||||
#define APP_USBD_STRING_DESC_H__
|
||||
@@ -43,7 +43,6 @@
|
||||
#include <stdint.h>
|
||||
#include "sdk_common.h"
|
||||
#include "app_usbd.h"
|
||||
#include "app_usbd_string_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -53,57 +52,118 @@ extern "C" {
|
||||
* @defgroup app_usbd_string_desc USBD string descriptors
|
||||
* @ingroup app_usbd
|
||||
*
|
||||
* @brief @tagAPI52840 USBD string descriptors management.
|
||||
* @brief @tagAPI52840 USBD string descriptor management.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief USB string initialization
|
||||
* @brief USB Language identifier initialization.
|
||||
*
|
||||
* Macro that creates initialization values for USB string.
|
||||
* The format contains header and string itself.
|
||||
* The string should be declared as an array of uint16_t type.
|
||||
* @param[in] lang Language identifier.
|
||||
*/
|
||||
#define APP_USBD_LANG(lang) \
|
||||
((app_usbd_langid_t) lang)
|
||||
|
||||
/**
|
||||
* @brief USB Language identifier with sublanguage initialization.
|
||||
*
|
||||
* @param[in] lang Language identifier.
|
||||
* @param[in] sublang Sublanguage identifier.
|
||||
*/
|
||||
#define APP_USBD_LANG_AND_SUBLANG(lang, sublang) \
|
||||
((app_usbd_langid_t) lang | (app_usbd_langid_t) sublang)
|
||||
|
||||
/**
|
||||
* @brief USB string initialization.
|
||||
*
|
||||
* Macro that creates initialization values for the USB string.
|
||||
* The string must be declared as a NULL-terminated string.
|
||||
*
|
||||
* @param[in] str NULL-terminated string.
|
||||
*
|
||||
* @param[in] ... Comma separated string letters or language ID.
|
||||
* @return String descriptor initialization data.
|
||||
*/
|
||||
#define APP_USBD_STRING_DESC(...) (const uint16_t[]){ \
|
||||
(0xff & (sizeof((uint16_t[]){__VA_ARGS__}) + 2)) | \
|
||||
((uint16_t)APP_USBD_DESCRIPTOR_STRING) << 8, \
|
||||
#define APP_USBD_STRING_DESC(str) (const uint8_t *)(const char[]){str}
|
||||
|
||||
/**
|
||||
* @brief USB raw 8-bit string initialization.
|
||||
*
|
||||
* Macro that creates header for raw values passed into descriptor.
|
||||
* Values must be of the uint8_t type and separated by commas.
|
||||
*
|
||||
* @param[in] ... comma-separated values.
|
||||
*
|
||||
* @return String descriptor initialization data.
|
||||
*/
|
||||
#define APP_USBD_STRING_RAW8_DESC(...) (const uint8_t[]){ \
|
||||
0x00, 0x00, /* NULL character at start to differentiate from normal string */ \
|
||||
(0xff & (sizeof((uint8_t[]){__VA_ARGS__}) + 2)), \
|
||||
(APP_USBD_DESCRIPTOR_STRING), \
|
||||
__VA_ARGS__ }
|
||||
|
||||
/**
|
||||
* @brief USB string descriptors ID's
|
||||
* @brief USB raw 16-bit string initialization.
|
||||
*
|
||||
* Macro that creates header for raw values passed into descriptor.
|
||||
* Values must be of the uint16_t type and separated by commas.
|
||||
*
|
||||
* @param[in] ... comma-separated values.
|
||||
*
|
||||
* @return String descriptor initialization data.
|
||||
*/
|
||||
#define APP_USBD_STRING_RAW16_DESC(...) (const uint8_t *) ((const uint16_t[]){ \
|
||||
0x00, /* NULL character at start to differentiate from normal string */ \
|
||||
(0xff & (sizeof((uint16_t[]){__VA_ARGS__}) + 2)) | \
|
||||
((uint16_t)APP_USBD_DESCRIPTOR_STRING) << 8, \
|
||||
__VA_ARGS__ })
|
||||
|
||||
/**
|
||||
* @brief USB string descriptors IDs
|
||||
*/
|
||||
typedef enum {
|
||||
APP_USBD_STRING_ID_LANGIDS = 0, /**< Supported language identifiers */
|
||||
APP_USBD_STRING_ID_MANUFACTURER, /**< Manufacturer name */
|
||||
APP_USBD_STRING_ID_PRODUCT, /**< Product name */
|
||||
APP_USBD_STRING_ID_SERIAL, /**< Serial number */
|
||||
|
||||
/// Placeholders used only for alignement of user strings. Do not use or modify them.
|
||||
|
||||
#if (APP_USBD_STRING_ID_MANUFACTURER != 0)
|
||||
APP_USBD_STRING_ID_MANUFACTURER_PLACEHOLDER = APP_USBD_STRING_ID_MANUFACTURER,
|
||||
#endif // (APP_USBD_STRING_ID_MANUFACTURER != 0)
|
||||
|
||||
#if (APP_USBD_STRING_ID_PRODUCT != 0)
|
||||
APP_USBD_STRING_ID_PRODUCT_PLACEHOLDER = APP_USBD_STRING_ID_PRODUCT,
|
||||
#endif // (APP_USBD_STRING_ID_PRODUCT != 0)
|
||||
|
||||
#if (APP_USBD_STRING_ID_SERIAL != 0)
|
||||
APP_USBD_STRING_ID_SERIAL_PLACEHOLDER = APP_USBD_STRING_ID_SERIAL,
|
||||
#endif // (APP_USBD_STRING_ID_SERIAL != 0)
|
||||
|
||||
#if (APP_USBD_STRING_ID_CONFIGURATION != 0)
|
||||
APP_USBD_STRING_ID_CONFIGURATION_PLACEHOLDER = APP_USBD_STRING_ID_CONFIGURATION,
|
||||
#endif // (APP_USBD_STRING_ID_CONFIGURATION != 0)
|
||||
|
||||
#define X(mnemonic, str_idx, ...) mnemonic str_idx,
|
||||
APP_USBD_STRINGS_USER
|
||||
#undef X
|
||||
|
||||
APP_USBD_STRING_ID_CNT /**< Total number of identifiers */
|
||||
APP_USBD_STRING_ID_CNT /**< Total number of identifiers. */
|
||||
} app_usbd_string_desc_idx_t;
|
||||
|
||||
/**
|
||||
* @brief Get string descriptor
|
||||
* @brief Get string descriptor.
|
||||
*
|
||||
* @param[in] idx String descriptor index
|
||||
* @param[in] langid Selected language for the string
|
||||
* @return String descriptor or NULL if not exist
|
||||
* @param[in] idx String descriptor index.
|
||||
* @param[in] langid Selected language for the string.
|
||||
* @return String descriptor, or NULL if it does not exist.
|
||||
* */
|
||||
uint16_t const * app_usbd_string_desc_get(app_usbd_string_desc_idx_t idx, uint16_t langid);
|
||||
uint16_t const * app_usbd_string_desc_get(uint8_t idx, uint16_t langid);
|
||||
|
||||
/**
|
||||
* @brief Get string length
|
||||
* @brief Get string length.
|
||||
*
|
||||
* Function to get string length from descriptor (descriptor returned by @ref app_usbd_string_desc_get)
|
||||
* Function for getting string length from descriptor (descriptor returned by @ref app_usbd_string_desc_get).
|
||||
*
|
||||
* @param[in] p_str String descriptor pointer
|
||||
* @return Total descriptor length in bytes
|
||||
* @param[in] p_str String descriptor pointer.
|
||||
* @return Total descriptor length in bytes.
|
||||
*/
|
||||
static inline size_t app_usbd_string_desc_length(uint16_t const * p_str)
|
||||
{
|
||||
|
||||
+64
-30
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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 APP_USBD_TYPES_H__
|
||||
@@ -61,7 +61,7 @@ extern "C" {
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Change given value to 2 digits in BCD notation
|
||||
* @brief Change given value to 2 digits in BCD notation.
|
||||
*
|
||||
* @param[in] val The decimal value to be converted in the range from 0 to 99.
|
||||
* @return Calculated BCD value.
|
||||
@@ -72,24 +72,40 @@ extern "C" {
|
||||
)
|
||||
|
||||
/**
|
||||
* @brief Change given decimal version values to 4 digits in BCD notation
|
||||
* @brief Change given decimal version values to 4 digits in BCD notation.
|
||||
*
|
||||
* USB specification uses 4 digits BCD version notation in many descriptors.
|
||||
* This macro changes 2 values to 4 BCD digits (one 16 bit value)
|
||||
* that describes version in USB standard.
|
||||
*
|
||||
* @param[in] major Major version
|
||||
* @param[in] minor Minor version
|
||||
* @param[in] major Major version.
|
||||
* @param[in] minor Minor version.
|
||||
*
|
||||
* @return Calculated 16 bit value with BCD representation of the version
|
||||
* @return Calculated 16 bit value with BCD representation of the version.
|
||||
*/
|
||||
#define APP_USBD_BCD_VER_MAKE(major, minor) \
|
||||
((APP_USBD_BCD_2_MAKE(major) << 8) | APP_USBD_BCD_2_MAKE(minor))
|
||||
|
||||
/**
|
||||
* @brief Events codes
|
||||
* @brief Combine endpoint address and its interval.
|
||||
*
|
||||
* Redefined application event codes
|
||||
* @param[in] address Endpoint address
|
||||
* @param[in] interval Endpoint interval
|
||||
* @return Combined address and interval.
|
||||
*/
|
||||
#define APP_USBD_EP_WITH_INTERVAL(address, interval) \
|
||||
((1UL << 16) | ((interval) << 8) | (address))
|
||||
|
||||
#define APP_USBD_EXTRACT_INTERVAL_VALUE(combined) \
|
||||
(((combined) & 0xFF00) >> 8)
|
||||
|
||||
#define APP_USBD_EXTRACT_INTERVAL_FLAG(combined) \
|
||||
(((combined) >> 16) & 0x01)
|
||||
|
||||
/**
|
||||
* @brief Events codes.
|
||||
*
|
||||
* Redefined application event codes.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
@@ -111,13 +127,17 @@ typedef enum
|
||||
APP_USBD_EVT_FIRST_APP, /**< First application event code - for internal static assert checking */
|
||||
|
||||
APP_USBD_EVT_INST_APPEND = APP_USBD_EVT_FIRST_APP, /**< The instance was attached to the library, any configuration action can be done now */
|
||||
APP_USBD_EVT_INST_REMOVE, /**< The instance is going to be removed, this event is called just before removing the instance.
|
||||
* This removing cannot be stopped. */
|
||||
APP_USBD_EVT_INST_REMOVE, /**<
|
||||
* The instance is going to be removed, this event is called just before removing the instance.
|
||||
* This removing cannot be stopped.
|
||||
*/
|
||||
APP_USBD_EVT_STARTED, /**< USBD library has just been started and functional - event passed to all instances, before USBD interrupts have been enabled */
|
||||
APP_USBD_EVT_STOPPED, /**< USBD library has just been stopped and is not functional - event passed to all instances, after USBD interrupts have been disabled*/
|
||||
|
||||
APP_USBD_EVT_STATE_CHANGED, /**< Informs all the classes that base state has been changed.
|
||||
* This event is processed before setup stage that caused the state change finishes (before acknowledging it). */
|
||||
APP_USBD_EVT_STATE_CHANGED, /**<
|
||||
* Informs all the classes that base state has been changed.
|
||||
* This event is processed before setup stage that caused the state change finishes (before acknowledging it).
|
||||
*/
|
||||
|
||||
APP_USBD_EVT_FIRST_INTERNAL = 0x80, /**< First internal event, used by the APP library internally. */
|
||||
|
||||
@@ -126,15 +146,21 @@ typedef enum
|
||||
APP_USBD_EVT_STOP_REQ, /**< Stop requested */
|
||||
APP_USBD_EVT_SUSPEND_REQ, /**< Suspend request - HFCLK would be released and USBD peripheral clock would be disconnected */
|
||||
APP_USBD_EVT_WAKEUP_REQ, /**< Wakeup request - start the whole wakeup generation. */
|
||||
APP_USBD_EVT_SETUP_SETADDRESS, /**<
|
||||
* Setup request to set address, separated from
|
||||
* regular EVT_SETUP because this request is
|
||||
* fully handled by hardware and for the software
|
||||
* it is only a notification about what happened
|
||||
*/
|
||||
|
||||
} app_usbd_event_type_t;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Specific application event structure
|
||||
* @brief Specific application event structure.
|
||||
*
|
||||
* All the data required by the events that comes from the application level
|
||||
* All the data required by the events that comes from the application level.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
@@ -142,10 +168,10 @@ typedef struct
|
||||
} app_usbd_evt_t;
|
||||
|
||||
/**
|
||||
* @brief Specific application event structure with setup structure included
|
||||
* @brief Specific application event structure with setup structure included.
|
||||
*
|
||||
* This event structure would be used when @ref APP_USBD_EVT_DRV_SETUP
|
||||
* is passed to instance event handler
|
||||
* is passed to instance event handler.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
@@ -155,7 +181,7 @@ typedef struct
|
||||
|
||||
|
||||
/**
|
||||
* @brief Complex event variable type
|
||||
* @brief Complex event variable type.
|
||||
*
|
||||
* A variable that can store any kind of event.
|
||||
*/
|
||||
@@ -178,7 +204,7 @@ typedef union
|
||||
|
||||
|
||||
/**
|
||||
* @brief Internal event variable type
|
||||
* @brief Internal event variable type.
|
||||
*
|
||||
* The variable type used for internal event processing.
|
||||
* This kind of event is the one that goes into the event queue.
|
||||
@@ -203,7 +229,7 @@ typedef union
|
||||
|
||||
#ifdef DOXYGEN
|
||||
/**
|
||||
* @brief Base instance of a USBD class
|
||||
* @brief Base instance of a USBD class.
|
||||
*
|
||||
* Any USBD class instance have to begin with this instance.
|
||||
* This may then be followed by any implementation dependent data.
|
||||
@@ -221,11 +247,11 @@ typedef struct {} app_usbd_class_inst_t;
|
||||
typedef struct app_usbd_class_inst_s app_usbd_class_inst_t;
|
||||
#endif
|
||||
/**
|
||||
* @brief Endpoint callback function
|
||||
* @brief Endpoint callback function.
|
||||
*
|
||||
* The function used by every class instance.
|
||||
* @param[in,out] p_inst Instance of the class
|
||||
* @param[in] p_event Event to process
|
||||
* @param[in,out] p_inst Instance of the class.
|
||||
* @param[in] p_event Event to process.
|
||||
*
|
||||
* @note If given event is not supported by class, return @ref NRF_ERROR_NOT_SUPPORTED
|
||||
*/
|
||||
@@ -234,6 +260,14 @@ typedef ret_code_t (*app_usbd_ep_event_handler_t)(
|
||||
app_usbd_complex_evt_t const * const p_event
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief SOF interrupt callback function.
|
||||
*
|
||||
* @param[in] framecnt Number of current SOF frame.
|
||||
*
|
||||
* @sa app_usbd_class_sof_register
|
||||
*/
|
||||
typedef void (*app_usbd_sof_interrupt_handler_t)(uint16_t framecnt);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
+105
-127
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
#include "sdk_common.h"
|
||||
#if NRF_MODULE_ENABLED(APP_USBD_CDC_ACM)
|
||||
@@ -207,10 +207,10 @@ static ret_code_t setup_req_std_in(app_usbd_class_inst_t const * p_inst,
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Internal SETUP standard OUT request handler
|
||||
* @brief Internal SETUP standard OUT request handler.
|
||||
*
|
||||
* @param[in] p_inst Generic class instance
|
||||
* @param[in] p_setup_ev Setup event
|
||||
* @param[in] p_inst Generic class instance.
|
||||
* @param[in] p_setup_ev Setup event.
|
||||
*
|
||||
* @return Standard error code.
|
||||
*/
|
||||
@@ -486,7 +486,7 @@ static ret_code_t setup_event_handler(app_usbd_class_inst_t const * p_inst,
|
||||
|
||||
|
||||
/**
|
||||
* @brief CDC ACM consumer
|
||||
* @brief CDC ACM consumer.
|
||||
*
|
||||
* @note See @ref nrf_drv_usbd_consumer_t
|
||||
*/
|
||||
@@ -521,9 +521,9 @@ static bool cdc_acm_consumer(nrf_drv_usbd_ep_transfer_t * p_next,
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CDC ACM single transfer consumer
|
||||
* @brief CDC ACM single transfer consumer.
|
||||
*
|
||||
* This function finalizes transfer after any received block
|
||||
* This function finalizes transfer after any received block.
|
||||
*
|
||||
* @note See @ref nrf_drv_usbd_consumer_t
|
||||
*/
|
||||
@@ -560,7 +560,7 @@ static bool cdc_acm_single_shoot_consumer(nrf_drv_usbd_ep_transfer_t * p_next,
|
||||
*
|
||||
* @param p_inst Generic USB class instance.
|
||||
*
|
||||
* @return Standard error code
|
||||
* @return Standard error code.
|
||||
*/
|
||||
static ret_code_t cdc_acm_rx_block_finished(app_usbd_class_inst_t const * p_inst)
|
||||
{
|
||||
@@ -776,111 +776,88 @@ static bool cdc_acm_feed_descriptors(app_usbd_class_descriptor_ctx_t * p_ctx,
|
||||
uint8_t * p_buff,
|
||||
size_t max_size)
|
||||
{
|
||||
uint8_t cur_size = 0;
|
||||
static uint8_t ifaces = 0;
|
||||
app_usbd_cdc_acm_t const * p_cdc_acm = cdc_acm_get(p_inst);
|
||||
app_usbd_class_ep_conf_t const * cur_ep;
|
||||
|
||||
APP_USBD_CLASS_DESCRIPTOR_BEGIN(p_ctx);
|
||||
|
||||
// INTERFACE ASSOCIATION DESCRIPTOR
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x08, p_buff, cur_size, max_size); // bLength
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_INTERFACE_ASSOCIATION,
|
||||
p_buff,
|
||||
cur_size,
|
||||
max_size); // bDescriptorType = Interface Association
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(p_cdc_acm->specific.inst.comm_interface, p_buff, cur_size,
|
||||
max_size); // bFirstInterface
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x02, p_buff, cur_size, max_size); // bInterfaceCount
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_COMM_CLASS, p_buff, cur_size, max_size); // bFunctionClass
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_SUBCLASS_ACM, p_buff, cur_size, max_size); // bFunctionSubClass
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(p_cdc_acm->specific.inst.protocol, p_buff, cur_size, max_size); // bFunctionProtocol
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00, p_buff, cur_size, max_size); // iFunction
|
||||
|
||||
static uint8_t ifaces = 0;
|
||||
ifaces = app_usbd_class_iface_count_get(p_inst);
|
||||
app_usbd_cdc_acm_t const * p_cdc_acm = cdc_acm_get(p_inst);
|
||||
|
||||
APP_USBD_CLASS_DESCRIPTOR_BEGIN(p_ctx, p_buff, max_size);
|
||||
|
||||
/* INTERFACE ASSOCIATION DESCRIPTOR */
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x08); // bLength
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_INTERFACE_ASSOCIATION); // bDescriptorType = Interface Association
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(p_cdc_acm->specific.inst.comm_interface); // bFirstInterface
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x02); // bInterfaceCount
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_COMM_CLASS); // bFunctionClass
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_SUBCLASS_ACM); // bFunctionSubClass
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(p_cdc_acm->specific.inst.protocol); // bFunctionProtocol
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // iFunction
|
||||
|
||||
static uint8_t i = 0;
|
||||
|
||||
for (i = 0; i < ifaces; i++)
|
||||
{
|
||||
// INTERFACE DESCRIPTOR
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x09, p_buff, cur_size, max_size); // bLength
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_INTERFACE, p_buff, cur_size, max_size); // bDescriptorType = Interface
|
||||
/* INTERFACE DESCRIPTOR */
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x09); // bLength
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_INTERFACE); // bDescriptorType = Interface
|
||||
|
||||
static app_usbd_class_iface_conf_t const * cur_iface = 0;
|
||||
cur_iface = app_usbd_class_iface_get(p_inst, i);
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_iface_number_get(cur_iface),
|
||||
p_buff,
|
||||
cur_size,
|
||||
max_size); // bInterfaceNumber
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00, p_buff, cur_size, max_size); // bAlternateSetting
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_iface_ep_count_get(cur_iface),
|
||||
p_buff,
|
||||
cur_size,
|
||||
max_size); // bNumEndpoints
|
||||
static app_usbd_class_iface_conf_t const * p_cur_iface = NULL;
|
||||
p_cur_iface = app_usbd_class_iface_get(p_inst, i);
|
||||
|
||||
if (p_cdc_acm->specific.inst.comm_interface == app_usbd_class_iface_number_get(cur_iface))
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_iface_number_get(p_cur_iface)); // bInterfaceNumber
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bAlternateSetting
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_iface_ep_count_get(p_cur_iface)); // bNumEndpoints
|
||||
|
||||
if (p_cdc_acm->specific.inst.comm_interface == app_usbd_class_iface_number_get(p_cur_iface))
|
||||
{
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_COMM_CLASS, p_buff, cur_size, max_size); // bInterfaceClass = CDC COMM
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_SUBCLASS_ACM, p_buff, cur_size, max_size); // bInterfaceSubclass
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(p_cdc_acm->specific.inst.protocol,
|
||||
p_buff,
|
||||
cur_size,
|
||||
max_size); // bInterfaceProtocol
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_COMM_CLASS); // bInterfaceClass = CDC COMM
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_SUBCLASS_ACM); // bInterfaceSubclass
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(p_cdc_acm->specific.inst.protocol); // bInterfaceProtocol
|
||||
}
|
||||
else if (p_cdc_acm->specific.inst.data_interface ==
|
||||
app_usbd_class_iface_number_get(cur_iface))
|
||||
app_usbd_class_iface_number_get(p_cur_iface))
|
||||
{
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_DATA_CLASS, p_buff, cur_size, max_size); // bInterfaceClass = CDC DATA
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00, p_buff, cur_size, max_size); // bInterfaceSubclass
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00, p_buff, cur_size, max_size); // bInterfaceProtocol
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_DATA_CLASS); // bInterfaceClass = CDC DATA
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bInterfaceSubclass
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bInterfaceProtocol
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00, p_buff, cur_size, max_size); // iInterface
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // iInterface
|
||||
|
||||
if (p_cdc_acm->specific.inst.comm_interface == app_usbd_class_iface_number_get(cur_iface))
|
||||
if (p_cdc_acm->specific.inst.comm_interface == app_usbd_class_iface_number_get(p_cur_iface))
|
||||
{
|
||||
// HEADER DESCRIPTOR
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x05, p_buff, cur_size, max_size); // bLength
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_CS_INTERFACE, p_buff, cur_size, max_size); // bDescriptorType = Class Specific Interface
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_SCS_HEADER, p_buff, cur_size, max_size); // bDescriptorSubtype = Header Functional Descriptor
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x10, p_buff, cur_size, max_size); // bcdCDC LSB
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x01, p_buff, cur_size, max_size); // bcdCDC MSB
|
||||
/* HEADER DESCRIPTOR */
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x05); // bLength
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_CS_INTERFACE); // bDescriptorType = Class Specific Interface
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_SCS_HEADER); // bDescriptorSubtype = Header Functional Descriptor
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x10); // bcdCDC LSB
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x01); // bcdCDC MSB
|
||||
|
||||
// CALL MANAGEMENT DESCRIPTOR
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x05, p_buff, cur_size, max_size); // bLength
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_CS_INTERFACE, p_buff, cur_size, max_size); // bDescriptorType = Class Specific Interface
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_SCS_CALL_MGMT, p_buff, cur_size, max_size); // bDescriptorSubtype = Call Management Functional Descriptor
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x03, p_buff, cur_size, max_size); // bmCapabilities
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(p_cdc_acm->specific.inst.data_interface,
|
||||
p_buff,
|
||||
cur_size,
|
||||
max_size); // bDataInterface
|
||||
/* CALL MANAGEMENT DESCRIPTOR */
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x05); // bLength
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_CS_INTERFACE); // bDescriptorType = Class Specific Interface
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_SCS_CALL_MGMT); // bDescriptorSubtype = Call Management Functional Descriptor
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x03); // bmCapabilities
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(p_cdc_acm->specific.inst.data_interface); // bDataInterface
|
||||
|
||||
// ABSTRACT CONTROL MANAGEMENT DESCRIPTOR
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x04, p_buff, cur_size, max_size); // bLength
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_CS_INTERFACE, p_buff, cur_size, max_size); // bDescriptorType = Class Specific Interface
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_SCS_ACM, p_buff, cur_size, max_size); // bDescriptorSubtype = Abstract Control Management Functional Descriptor
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x02, p_buff, cur_size, max_size); // bmCapabilities
|
||||
/* ABSTRACT CONTROL MANAGEMENT DESCRIPTOR */
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x04); // bLength
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_CS_INTERFACE); // bDescriptorType = Class Specific Interface
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_SCS_ACM); // bDescriptorSubtype = Abstract Control Management Functional Descriptor
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x02); // bmCapabilities
|
||||
|
||||
// UNION DESCRIPTOR
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x05, p_buff, cur_size, max_size);
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_CS_INTERFACE, p_buff, cur_size, max_size); // bDescriptorType = Class Specific Interface
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_SCS_UNION, p_buff, cur_size, max_size); // bDescriptorSubtype = Union Functional Descriptor
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(p_cdc_acm->specific.inst.comm_interface,
|
||||
p_buff,
|
||||
cur_size,
|
||||
max_size); // bControlInterface
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(p_cdc_acm->specific.inst.data_interface,
|
||||
p_buff,
|
||||
cur_size,
|
||||
max_size); // bSubordinateInterface
|
||||
/* UNION DESCRIPTOR */
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x05);
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_CS_INTERFACE); // bDescriptorType = Class Specific Interface
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_CDC_SCS_UNION); // bDescriptorSubtype = Union Functional Descriptor
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(p_cdc_acm->specific.inst.comm_interface); // bControlInterface
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(p_cdc_acm->specific.inst.data_interface); // bSubordinateInterface
|
||||
}
|
||||
else if (p_cdc_acm->specific.inst.data_interface ==
|
||||
app_usbd_class_iface_number_get(cur_iface))
|
||||
app_usbd_class_iface_number_get(p_cur_iface))
|
||||
{
|
||||
;
|
||||
}
|
||||
@@ -889,56 +866,48 @@ static bool cdc_acm_feed_descriptors(app_usbd_class_descriptor_ctx_t * p_ctx,
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
// ENDPOINT DESCRIPTORS
|
||||
/* ENDPOINT DESCRIPTORS */
|
||||
static uint8_t endpoints = 0;
|
||||
endpoints = app_usbd_class_iface_ep_count_get(cur_iface);
|
||||
endpoints = app_usbd_class_iface_ep_count_get(p_cur_iface);
|
||||
|
||||
static uint8_t j = 0;
|
||||
|
||||
for (j = 0; j < endpoints; j++)
|
||||
{
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x07, p_buff, cur_size, max_size); // bLength
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_ENDPOINT, p_buff, cur_size, max_size); // bDescriptorType = Endpoint
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x07); // bLength
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_ENDPOINT); // bDescriptorType = Endpoint
|
||||
|
||||
cur_ep = app_usbd_class_iface_ep_get(cur_iface, j);
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_ep_address_get(cur_ep),
|
||||
p_buff,
|
||||
cur_size,
|
||||
max_size); // bEndpointAddress
|
||||
static app_usbd_class_ep_conf_t const * p_cur_ep = NULL;
|
||||
p_cur_ep = app_usbd_class_iface_ep_get(p_cur_iface, j);
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(app_usbd_class_ep_address_get(p_cur_ep)); // bEndpointAddress
|
||||
|
||||
if (p_cdc_acm->specific.inst.comm_interface ==
|
||||
app_usbd_class_iface_number_get(cur_iface))
|
||||
app_usbd_class_iface_number_get(p_cur_iface))
|
||||
{
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_INTERRUPT,
|
||||
p_buff,
|
||||
cur_size,
|
||||
max_size); // bmAttributes
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_INTERRUPT); // bmAttributes
|
||||
}
|
||||
else if (p_cdc_acm->specific.inst.data_interface ==
|
||||
app_usbd_class_iface_number_get(cur_iface))
|
||||
app_usbd_class_iface_number_get(p_cur_iface))
|
||||
{
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_BULK,
|
||||
p_buff,
|
||||
cur_size,
|
||||
max_size); // bmAttributes
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_BULK); // bmAttributes
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(NRF_DRV_USBD_EPSIZE), p_buff, cur_size, max_size); // wMaxPacketSize LSB
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(NRF_DRV_USBD_EPSIZE), p_buff, cur_size, max_size); // wMaxPacketSize MSB
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(LSB_16(NRF_DRV_USBD_EPSIZE)); // wMaxPacketSize LSB
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(MSB_16(NRF_DRV_USBD_EPSIZE)); // wMaxPacketSize MSB
|
||||
|
||||
if (p_cdc_acm->specific.inst.comm_interface ==
|
||||
app_usbd_class_iface_number_get(cur_iface))
|
||||
app_usbd_class_iface_number_get(p_cur_iface))
|
||||
{
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(16, p_buff, cur_size, max_size); // bInterval
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(p_cdc_acm->specific.inst.p_ep_interval[0]); // bInterval
|
||||
}
|
||||
else if (p_cdc_acm->specific.inst.data_interface ==
|
||||
app_usbd_class_iface_number_get(cur_iface))
|
||||
app_usbd_class_iface_number_get(p_cur_iface))
|
||||
{
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00, p_buff, cur_size, max_size); // bInterval
|
||||
APP_USBD_CLASS_DESCRIPTOR_WRITE(0x00); // bInterval
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -949,11 +918,11 @@ static bool cdc_acm_feed_descriptors(app_usbd_class_descriptor_ctx_t * p_ctx,
|
||||
|
||||
}
|
||||
|
||||
APP_USBD_CLASS_DESCRIPTOR_END(p_ctx);
|
||||
APP_USBD_CLASS_DESCRIPTOR_END();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Public cdc_acm class interface
|
||||
* @brief Public cdc_acm class interface.
|
||||
*
|
||||
*/
|
||||
const app_usbd_class_methods_t app_usbd_cdc_acm_class_methods = {
|
||||
@@ -977,10 +946,19 @@ ret_code_t app_usbd_cdc_acm_write(app_usbd_cdc_acm_t const * p_cdc_acm,
|
||||
/*Port is not opened*/
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
|
||||
nrf_drv_usbd_ep_t ep = data_ep_in_addr_get(p_inst);
|
||||
NRF_DRV_USBD_TRANSFER_IN(transfer, p_buf, length);
|
||||
return app_usbd_ep_transfer(ep, &transfer);
|
||||
|
||||
if (APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE && ((length % NRF_DRV_USBD_EPSIZE) == 0))
|
||||
{
|
||||
NRF_DRV_USBD_TRANSFER_IN_ZLP(transfer, p_buf, length);
|
||||
return app_usbd_ep_transfer(ep, &transfer);
|
||||
}
|
||||
else
|
||||
{
|
||||
NRF_DRV_USBD_TRANSFER_IN(transfer, p_buf, length);
|
||||
return app_usbd_ep_transfer(ep, &transfer);
|
||||
}
|
||||
}
|
||||
|
||||
size_t app_usbd_cdc_acm_rx_size(app_usbd_cdc_acm_t const * p_cdc_acm)
|
||||
|
||||
+10
-10
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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 APP_USBD_CDC_ACM_H__
|
||||
#define APP_USBD_CDC_ACM_H__
|
||||
@@ -74,7 +74,7 @@ extern "C" {
|
||||
|
||||
#ifdef DOXYGEN
|
||||
/**
|
||||
* @brief CDC ACM class instance type
|
||||
* @brief CDC ACM class instance type.
|
||||
*
|
||||
* @ref APP_USBD_CLASS_TYPEDEF
|
||||
*/
|
||||
|
||||
+57
-38
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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 APP_USBD_CDC_ACM_INTERNAL_H__
|
||||
#define APP_USBD_CDC_ACM_INTERNAL_H__
|
||||
@@ -92,11 +92,13 @@ typedef struct {
|
||||
app_usbd_cdc_comm_protocol_t protocol; //!< User specified CDC protocol.
|
||||
|
||||
app_usbd_cdc_acm_user_ev_handler_t user_ev_handler; //!< User event handler.
|
||||
|
||||
uint8_t * p_ep_interval; //!< Endpoint intervals.
|
||||
} app_usbd_cdc_acm_inst_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief CDC ACM serial state class notify
|
||||
* @brief CDC ACM serial state class notify.
|
||||
*/
|
||||
typedef struct {
|
||||
app_usbd_cdc_notify_t cdc_notify; //!< CDC notify.
|
||||
@@ -117,15 +119,15 @@ typedef struct {
|
||||
} app_usbd_cdc_acm_req_t;
|
||||
|
||||
/**
|
||||
* @brief CDC ACM rx transfer buffer
|
||||
* @brief CDC ACM rx transfer buffer.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t * p_buf; //!< User buffer pointer.
|
||||
size_t read_left; //!< Bytes left to read into buffer.
|
||||
uint8_t * p_buf; //!< User buffer pointer.
|
||||
size_t read_left; //!< Bytes left to read into buffer.
|
||||
} cdc_rx_buffer_t;
|
||||
|
||||
/**
|
||||
* @brief CDC ACM class context
|
||||
* @brief CDC ACM class context.
|
||||
*/
|
||||
typedef struct {
|
||||
app_usbd_cdc_acm_req_t request; //!< CDC ACM class request.
|
||||
@@ -145,6 +147,11 @@ typedef struct {
|
||||
size_t cur_read; //!< Bytes currently read to internal buffer.
|
||||
} app_usbd_cdc_acm_ctx_t;
|
||||
|
||||
/**
|
||||
* @brief Default interval value for comm endpoint IN
|
||||
*
|
||||
*/
|
||||
#define APP_USBD_CDC_ACM_DEFAULT_INTERVAL 0x10
|
||||
|
||||
/**
|
||||
* @brief CDC ACM class configuration macro.
|
||||
@@ -181,9 +188,16 @@ typedef struct {
|
||||
* @param data_ein DATA subclass IN endpoint.
|
||||
* @param data_eout DATA subclass OUT endpoint.
|
||||
* @param cdc_protocol CDC protocol.
|
||||
* @param ep_list List of endpoints and intervals
|
||||
*/
|
||||
#define APP_USBD_CDC_ACM_INST_CONFIG(user_event_handler, comm_ifc, comm_ein, data_ifc, data_ein, \
|
||||
data_eout, cdc_protocol) \
|
||||
#define APP_USBD_CDC_ACM_INST_CONFIG(user_event_handler, \
|
||||
comm_ifc, \
|
||||
comm_ein, \
|
||||
data_ifc, \
|
||||
data_ein, \
|
||||
data_eout, \
|
||||
cdc_protocol, \
|
||||
ep_list) \
|
||||
.inst = { \
|
||||
.user_ev_handler = user_event_handler, \
|
||||
.comm_interface = comm_ifc, \
|
||||
@@ -191,7 +205,8 @@ typedef struct {
|
||||
.data_interface = data_ifc, \
|
||||
.data_epin = data_ein, \
|
||||
.data_epout = data_eout, \
|
||||
.protocol = cdc_protocol \
|
||||
.protocol = cdc_protocol, \
|
||||
.p_ep_interval = ep_list \
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,27 +248,31 @@ extern const app_usbd_class_methods_t app_usbd_cdc_acm_class_methods;
|
||||
* @param data_eout DATA subclass OUT endpoint.
|
||||
* @param cdc_protocol CDC protocol @ref app_usbd_cdc_comm_protocol_t
|
||||
*/
|
||||
/*lint -save -emacro(26 64 123 505 651, APP_USBD_CDC_ACM_GLOBAL_DEF_INTERNAL)*/
|
||||
#define APP_USBD_CDC_ACM_GLOBAL_DEF_INTERNAL(instance_name, \
|
||||
user_ev_handler, \
|
||||
comm_ifc, \
|
||||
data_ifc, \
|
||||
comm_ein, \
|
||||
data_ein, \
|
||||
data_eout, \
|
||||
cdc_protocol) \
|
||||
APP_USBD_CLASS_INST_GLOBAL_DEF( \
|
||||
instance_name, \
|
||||
app_usbd_cdc_acm, \
|
||||
&app_usbd_cdc_acm_class_methods, \
|
||||
APP_USBD_CDC_ACM_CONFIG(comm_ifc, comm_ein, data_ifc, data_ein, data_eout), \
|
||||
(APP_USBD_CDC_ACM_INST_CONFIG(user_ev_handler, \
|
||||
comm_ifc, \
|
||||
comm_ein, \
|
||||
data_ifc, \
|
||||
data_ein, \
|
||||
data_eout, \
|
||||
cdc_protocol)) \
|
||||
/*lint -save -emacro(26 64 123 505 572 651, APP_USBD_CDC_ACM_GLOBAL_DEF_INTERNAL)*/
|
||||
#define APP_USBD_CDC_ACM_GLOBAL_DEF_INTERNAL(instance_name, \
|
||||
user_ev_handler, \
|
||||
comm_ifc, \
|
||||
data_ifc, \
|
||||
comm_ein, \
|
||||
data_ein, \
|
||||
data_eout, \
|
||||
cdc_protocol) \
|
||||
static uint8_t CONCAT_2(instance_name, _ep) = { \
|
||||
(APP_USBD_EXTRACT_INTERVAL_FLAG(comm_ein) ? APP_USBD_EXTRACT_INTERVAL_VALUE(comm_ein) \
|
||||
: APP_USBD_CDC_ACM_DEFAULT_INTERVAL)}; \
|
||||
APP_USBD_CLASS_INST_GLOBAL_DEF( \
|
||||
instance_name, \
|
||||
app_usbd_cdc_acm, \
|
||||
&app_usbd_cdc_acm_class_methods, \
|
||||
APP_USBD_CDC_ACM_CONFIG(comm_ifc, comm_ein, data_ifc, data_ein, data_eout), \
|
||||
(APP_USBD_CDC_ACM_INST_CONFIG(user_ev_handler, \
|
||||
comm_ifc, \
|
||||
comm_ein, \
|
||||
data_ifc, \
|
||||
data_ein, \
|
||||
data_eout, \
|
||||
cdc_protocol, \
|
||||
&CONCAT_2(instance_name, _ep))) \
|
||||
)
|
||||
/*lint -restore*/
|
||||
|
||||
|
||||
+9
-9
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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 APP_USBD_CDC_DESC_H__
|
||||
#define APP_USBD_CDC_DESC_H__
|
||||
|
||||
+13
-13
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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
|
||||
@@ -35,7 +35,7 @@
|
||||
* 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 APP_USBD_CDC_TYPES_H__
|
||||
#define APP_USBD_CDC_TYPES_H__
|
||||
@@ -148,7 +148,7 @@ typedef enum {
|
||||
} app_usbd_cdc_func_type_t;
|
||||
|
||||
/**
|
||||
* @brief CDC Functional Descriptor subtypes
|
||||
* @brief CDC Functional Descriptor subtypes.
|
||||
*/
|
||||
typedef enum {
|
||||
APP_USBD_CDC_SCS_HEADER = 0x00, /**< Header Functional Descriptor, which marks the beginning of the concatenated set of functional descriptors for the interface. */
|
||||
@@ -184,7 +184,7 @@ typedef enum {
|
||||
#pragma pack(push, 1)
|
||||
|
||||
/**
|
||||
* @brief Header Functional Descriptor
|
||||
* @brief Header Functional Descriptor.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t bFunctionLength; //!< Size of this descriptor in bytes.
|
||||
@@ -196,7 +196,7 @@ typedef struct {
|
||||
/**
|
||||
* @brief Call management capabilities.
|
||||
*
|
||||
* @ref app_usbd_cdc_desc_call_mgmt_t::bmCapabilities bit
|
||||
* @ref app_usbd_cdc_desc_call_mgmt_t::bmCapabilities bit.
|
||||
* */
|
||||
typedef enum {
|
||||
APP_USBD_CDC_CALL_MGMT_SUPPORTED = (1 << 0), /**< Call management capability bit 0.*/
|
||||
@@ -217,7 +217,7 @@ typedef struct {
|
||||
/**
|
||||
* @brief ACM capabilities.
|
||||
*
|
||||
* @ref app_usbd_cdc_desc_acm_t::bmCapabilities bit
|
||||
* @ref app_usbd_cdc_desc_acm_t::bmCapabilities bit.
|
||||
* */
|
||||
typedef enum {
|
||||
APP_USBD_CDC_ACM_FEATURE_REQUESTS = (1 << 0), /**< ACM capability bit FEATURE_REQUESTS. */
|
||||
|
||||
+3
-3
@@ -67,7 +67,7 @@
|
||||
* @ref APP_USBD_STRINGS_LANGIDS.
|
||||
*/
|
||||
#define APP_USBD_STRINGS_MANUFACTURER \
|
||||
APP_USBD_STRING_DESC('N', 'o', 'r', 'd', 'i', 'c', ' ', 'S', 'e', 'm', 'i', 'c', 'o', 'n', 'd', 'u', 'c', 't', 'o', 'r')
|
||||
APP_USBD_STRING_DESC("Nordic Semiconductor")
|
||||
|
||||
/**
|
||||
* @brief Define whether @ref APP_USBD_STRINGS_MANUFACTURER is created by @ref APP_USBD_STRING_DESC
|
||||
@@ -81,7 +81,7 @@
|
||||
* List of product names defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER
|
||||
*/
|
||||
#define APP_USBD_STRINGS_PRODUCT \
|
||||
APP_USBD_STRING_DESC('n', 'R', 'F', '5', '2', '8', '4', '0', ' ', 'O', 'p', 'e', 'n', 'T', 'h', 'r', 'e', 'a', 'd', ' ', 'D', 'e', 'v', 'i', 'c', 'e')
|
||||
APP_USBD_STRING_DESC("nRF52840 OpenThread Device")
|
||||
|
||||
|
||||
/**
|
||||
@@ -124,7 +124,7 @@
|
||||
* - @c ... : List of string descriptors for each defined language.
|
||||
*/
|
||||
#define APP_USBD_STRINGS_USER \
|
||||
X(APP_USER_1, , APP_USBD_STRING_DESC('U', 's', 'e', 'r', ' ', '1'))
|
||||
X(APP_USER_1, , APP_USBD_STRING_DESC("User 1"))
|
||||
|
||||
/** @} */
|
||||
#endif /* APP_USBD_STRING_CONFIG_H */
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
Copyright (c) 2016 Pietro Gagliardi
|
||||
|
||||
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.
|
||||
|
||||
(this is called the MIT License or Expat License; see http://www.opensource.org/licenses/MIT)
|
||||
@@ -0,0 +1,350 @@
|
||||
// utf by pietro gagliardi (andlabs) — https://github.com/andlabs/utf/
|
||||
// 10 november 2016
|
||||
#include "utf.h"
|
||||
|
||||
// this code imitates Go's unicode/utf8 and unicode/utf16
|
||||
// the biggest difference is that a rune is unsigned instead of signed (because Go guarantees what a right shift on a signed number will do, whereas C does not)
|
||||
// it is also an imitation so we can license it under looser terms than the Go source
|
||||
#define badrune 0xFFFD
|
||||
|
||||
// encoded must be at most 4 bytes
|
||||
// TODO clean this code up somehow
|
||||
size_t utf8EncodeRune(uint32_t rune, char *encoded)
|
||||
{
|
||||
uint8_t b;
|
||||
uint8_t c = 0;
|
||||
uint8_t d = 0;
|
||||
uint8_t e = 0;
|
||||
size_t n;
|
||||
|
||||
// not in the valid range for Unicode
|
||||
if (rune > 0x10FFFF)
|
||||
rune = badrune;
|
||||
// surrogate runes cannot be encoded
|
||||
if (rune >= 0xD800 && rune < 0xE000)
|
||||
rune = badrune;
|
||||
|
||||
if (rune < 0x80) { // ASCII bytes represent themselves
|
||||
b = (uint8_t) (rune & 0xFF);
|
||||
n = 1;
|
||||
goto done;
|
||||
}
|
||||
if (rune < 0x800) { // two-byte encoding
|
||||
c = (uint8_t) (rune & 0x3F);
|
||||
c |= 0x80;
|
||||
rune >>= 6;
|
||||
b = (uint8_t) (rune & 0x1F);
|
||||
b |= 0xC0;
|
||||
n = 2;
|
||||
goto done;
|
||||
}
|
||||
if (rune < 0x10000) { // three-byte encoding
|
||||
d = (uint8_t) (rune & 0x3F);
|
||||
d |= 0x80;
|
||||
rune >>= 6;
|
||||
c = (uint8_t) (rune & 0x3F);
|
||||
c |= 0x80;
|
||||
rune >>= 6;
|
||||
b = (uint8_t) (rune & 0x0F);
|
||||
b |= 0xE0;
|
||||
n = 3;
|
||||
goto done;
|
||||
}
|
||||
// otherwise use a four-byte encoding
|
||||
e = (uint8_t) (rune & 0x3F);
|
||||
e |= 0x80;
|
||||
rune >>= 6;
|
||||
d = (uint8_t) (rune & 0x3F);
|
||||
d |= 0x80;
|
||||
rune >>= 6;
|
||||
c = (uint8_t) (rune & 0x3F);
|
||||
c |= 0x80;
|
||||
rune >>= 6;
|
||||
b = (uint8_t) (rune & 0x07);
|
||||
b |= 0xF0;
|
||||
n = 4;
|
||||
|
||||
done:
|
||||
encoded[0] = b;
|
||||
if (n > 1)
|
||||
encoded[1] = c;
|
||||
if (n > 2)
|
||||
encoded[2] = d;
|
||||
if (n > 3)
|
||||
encoded[3] = e;
|
||||
return n;
|
||||
}
|
||||
|
||||
const char *utf8DecodeRune(const char *s, size_t nElem, uint32_t *rune)
|
||||
{
|
||||
uint8_t b, c;
|
||||
uint8_t lowestAllowed, highestAllowed;
|
||||
size_t i, expected;
|
||||
int bad;
|
||||
|
||||
b = (uint8_t) (*s);
|
||||
if (b < 0x80) { // ASCII bytes represent themselves
|
||||
*rune = b;
|
||||
s++;
|
||||
return s;
|
||||
}
|
||||
// 0xC0 and 0xC1 cover 2-byte overlong equivalents
|
||||
// 0xF5 to 0xFD cover values > 0x10FFFF
|
||||
// 0xFE and 0xFF were never defined (always illegal)
|
||||
if (b < 0xC2 || b > 0xF4) { // invalid
|
||||
*rune = badrune;
|
||||
s++;
|
||||
return s;
|
||||
}
|
||||
|
||||
// this determines the range of allowed first continuation bytes
|
||||
lowestAllowed = 0x80;
|
||||
highestAllowed = 0xBF;
|
||||
switch (b) {
|
||||
case 0xE0:
|
||||
// disallow 3-byte overlong equivalents
|
||||
lowestAllowed = 0xA0;
|
||||
break;
|
||||
case 0xED:
|
||||
// disallow surrogate characters
|
||||
highestAllowed = 0x9F;
|
||||
break;
|
||||
case 0xF0:
|
||||
// disallow 4-byte overlong equivalents
|
||||
lowestAllowed = 0x90;
|
||||
break;
|
||||
case 0xF4:
|
||||
// disallow values > 0x10FFFF
|
||||
highestAllowed = 0x8F;
|
||||
break;
|
||||
}
|
||||
|
||||
// and this determines how many continuation bytes are expected
|
||||
expected = 1;
|
||||
if (b >= 0xE0)
|
||||
expected++;
|
||||
if (b >= 0xF0)
|
||||
expected++;
|
||||
if (nElem != 0) { // are there enough bytes?
|
||||
nElem--;
|
||||
if (nElem < expected) { // nope
|
||||
*rune = badrune;
|
||||
s++;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
// ensure that everything is correct
|
||||
// if not, **only** consume the initial byte
|
||||
bad = 0;
|
||||
for (i = 0; i < expected; i++) {
|
||||
c = (uint8_t) (s[1 + i]);
|
||||
if (c < lowestAllowed || c > highestAllowed) {
|
||||
bad = 1;
|
||||
break;
|
||||
}
|
||||
// the old lowestAllowed and highestAllowed is only for the first continuation byte
|
||||
lowestAllowed = 0x80;
|
||||
highestAllowed = 0xBF;
|
||||
}
|
||||
if (bad) {
|
||||
*rune = badrune;
|
||||
s++;
|
||||
return s;
|
||||
}
|
||||
|
||||
// now do the topmost bits
|
||||
if (b < 0xE0)
|
||||
*rune = b & 0x1F;
|
||||
else if (b < 0xF0)
|
||||
*rune = b & 0x0F;
|
||||
else
|
||||
*rune = b & 0x07;
|
||||
s++; // we can finally move on
|
||||
|
||||
// now do the continuation bytes
|
||||
for (; expected; expected--) {
|
||||
c = (uint8_t) (*s);
|
||||
s++;
|
||||
c &= 0x3F; // strip continuation bits
|
||||
*rune <<= 6;
|
||||
*rune |= c;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// encoded must have at most 2 elements
|
||||
size_t utf16EncodeRune(uint32_t rune, uint16_t *encoded)
|
||||
{
|
||||
uint16_t low, high;
|
||||
|
||||
// not in the valid range for Unicode
|
||||
if (rune > 0x10FFFF)
|
||||
rune = badrune;
|
||||
// surrogate runes cannot be encoded
|
||||
if (rune >= 0xD800 && rune < 0xE000)
|
||||
rune = badrune;
|
||||
|
||||
if (rune < 0x10000) {
|
||||
encoded[0] = (uint16_t) rune;
|
||||
return 1;
|
||||
}
|
||||
|
||||
rune -= 0x10000;
|
||||
low = (uint16_t) (rune & 0x3FF);
|
||||
rune >>= 10;
|
||||
high = (uint16_t) (rune & 0x3FF);
|
||||
encoded[0] = high | 0xD800;
|
||||
encoded[1] = low | 0xDC00;
|
||||
return 2;
|
||||
}
|
||||
|
||||
// TODO see if this can be cleaned up somehow
|
||||
const uint16_t *utf16DecodeRune(const uint16_t *s, size_t nElem, uint32_t *rune)
|
||||
{
|
||||
uint16_t high, low;
|
||||
|
||||
if (*s < 0xD800 || *s >= 0xE000) {
|
||||
// self-representing character
|
||||
*rune = *s;
|
||||
s++;
|
||||
return s;
|
||||
}
|
||||
if (*s >= 0xDC00) {
|
||||
// out-of-order surrogates
|
||||
*rune = badrune;
|
||||
s++;
|
||||
return s;
|
||||
}
|
||||
if (nElem == 1) { // not enough elements
|
||||
*rune = badrune;
|
||||
s++;
|
||||
return s;
|
||||
}
|
||||
high = *s;
|
||||
high &= 0x3FF;
|
||||
if (s[1] < 0xDC00 || s[1] >= 0xE000) {
|
||||
// bad surrogate pair
|
||||
*rune = badrune;
|
||||
s++;
|
||||
return s;
|
||||
}
|
||||
s++;
|
||||
low = *s;
|
||||
s++;
|
||||
low &= 0x3FF;
|
||||
*rune = high;
|
||||
*rune <<= 10;
|
||||
*rune |= low;
|
||||
*rune += 0x10000;
|
||||
return s;
|
||||
}
|
||||
|
||||
// TODO find a way to reduce the code in all of these somehow
|
||||
// TODO find a way to remove u as well
|
||||
size_t utf8RuneCount(const char *s, size_t nElem)
|
||||
{
|
||||
size_t len;
|
||||
uint32_t rune;
|
||||
|
||||
if (nElem != 0) {
|
||||
const char *t, *u;
|
||||
|
||||
len = 0;
|
||||
t = s;
|
||||
while (nElem != 0) {
|
||||
u = utf8DecodeRune(t, nElem, &rune);
|
||||
len++;
|
||||
nElem -= u - t;
|
||||
t = u;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
len = 0;
|
||||
while (*s) {
|
||||
s = utf8DecodeRune(s, nElem, &rune);
|
||||
len++;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
size_t utf8UTF16Count(const char *s, size_t nElem)
|
||||
{
|
||||
size_t len;
|
||||
uint32_t rune;
|
||||
uint16_t encoded[2];
|
||||
|
||||
if (nElem != 0) {
|
||||
const char *t, *u;
|
||||
|
||||
len = 0;
|
||||
t = s;
|
||||
while (nElem != 0) {
|
||||
u = utf8DecodeRune(t, nElem, &rune);
|
||||
len += utf16EncodeRune(rune, encoded);
|
||||
nElem -= u - t;
|
||||
t = u;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
len = 0;
|
||||
while (*s) {
|
||||
s = utf8DecodeRune(s, nElem, &rune);
|
||||
len += utf16EncodeRune(rune, encoded);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
size_t utf16RuneCount(const uint16_t *s, size_t nElem)
|
||||
{
|
||||
size_t len;
|
||||
uint32_t rune;
|
||||
|
||||
if (nElem != 0) {
|
||||
const uint16_t *t, *u;
|
||||
|
||||
len = 0;
|
||||
t = s;
|
||||
while (nElem != 0) {
|
||||
u = utf16DecodeRune(t, nElem, &rune);
|
||||
len++;
|
||||
nElem -= u - t;
|
||||
t = u;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
len = 0;
|
||||
while (*s) {
|
||||
s = utf16DecodeRune(s, nElem, &rune);
|
||||
len++;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
size_t utf16UTF8Count(const uint16_t *s, size_t nElem)
|
||||
{
|
||||
size_t len;
|
||||
uint32_t rune;
|
||||
char encoded[4];
|
||||
|
||||
if (nElem != 0) {
|
||||
const uint16_t *t, *u;
|
||||
|
||||
len = 0;
|
||||
t = s;
|
||||
while (nElem != 0) {
|
||||
u = utf16DecodeRune(t, nElem, &rune);
|
||||
len += utf8EncodeRune(rune, encoded);
|
||||
nElem -= u - t;
|
||||
t = u;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
len = 0;
|
||||
while (*s) {
|
||||
s = utf16DecodeRune(s, nElem, &rune);
|
||||
len += utf8EncodeRune(rune, encoded);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
// utf by pietro gagliardi (andlabs) — https://github.com/andlabs/utf/
|
||||
// 10 november 2016
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// if nElem == 0, assume the buffer has no upper limit and is '\0' terminated
|
||||
// otherwise, assume buffer is NOT '\0' terminated but is bounded by nElem *elements*
|
||||
|
||||
extern size_t utf8EncodeRune(uint32_t rune, char *encoded);
|
||||
extern const char *utf8DecodeRune(const char *s, size_t nElem, uint32_t *rune);
|
||||
extern size_t utf16EncodeRune(uint32_t rune, uint16_t *encoded);
|
||||
extern const uint16_t *utf16DecodeRune(const uint16_t *s, size_t nElem, uint32_t *rune);
|
||||
|
||||
extern size_t utf8RuneCount(const char *s, size_t nElem);
|
||||
extern size_t utf8UTF16Count(const char *s, size_t nElem);
|
||||
extern size_t utf16RuneCount(const uint16_t *s, size_t nElem);
|
||||
extern size_t utf16UTF8Count(const uint16_t *s, size_t nElem);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
// Provide overloads on Windows for using these functions with wchar_t and WCHAR when wchar_t is a keyword in C++ mode (the default).
|
||||
// Otherwise, you'd need to cast to pass a wchar_t pointer, WCHAR pointer, or equivalent to these functions.
|
||||
// We use __wchar_t to be independent of the setting; see https://blogs.msdn.microsoft.com/oldnewthing/20161201-00/?p=94836 (ironically posted one day after I initially wrote this code!).
|
||||
// TODO check this on MinGW-w64
|
||||
// TODO check this under /Wall
|
||||
// TODO C-style casts enough? or will that fail in /Wall?
|
||||
// TODO same for UniChar/unichar on Mac? if both are unsigned then we have nothing to worry about
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
inline size_t utf16EncodeRune(uint32_t rune, __wchar_t *encoded)
|
||||
{
|
||||
return utf16EncodeRune(rune, reinterpret_cast<uint16_t *>(encoded));
|
||||
}
|
||||
|
||||
inline const __wchar_t *utf16DecodeRune(const __wchar_t *s, size_t nElem, uint32_t *rune)
|
||||
{
|
||||
const uint16_t *ret;
|
||||
|
||||
ret = utf16DecodeRune(reinterpret_cast<const uint16_t *>(s), nElem, rune);
|
||||
return reinterpret_cast<const __wchar_t *>(ret);
|
||||
}
|
||||
|
||||
inline size_t utf16RuneCount(const __wchar_t *s, size_t nElem)
|
||||
{
|
||||
return utf16RuneCount(reinterpret_cast<const uint16_t *>(s), nElem);
|
||||
}
|
||||
|
||||
inline size_t utf16UTF8Count(const __wchar_t *s, size_t nElem)
|
||||
{
|
||||
return utf16UTF8Count(reinterpret_cast<const uint16_t *>(s), nElem);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+79
-59
@@ -1,59 +1,79 @@
|
||||
# Changelog
|
||||
All notable changes to this project are documented in this file.
|
||||
|
||||
## [1.0.0] - 2018-03-21
|
||||
### Added
|
||||
- Added the NRFX_WAIT_FOR macro to improve the time-out functionality in QSPI and SAADC drivers.
|
||||
- Added glue layer macros for checking and modifying the pending status of interrupts.
|
||||
- Added new enumeration values for interrupts and events in the UARTE HAL.
|
||||
- Implemented workarounds for nRF52 anomalies 192 and 201 in the CLOCK driver.
|
||||
- Implemented workaround for nRF52840 anomaly 122 in the QSPI driver.
|
||||
- Implemented workaround for nRF52840 anomaly 198 in the SPIM driver.
|
||||
|
||||
### Changed
|
||||
- Updated MDK to 8.16.0.
|
||||
- Extended input pin configuration in the GPIOTE driver.
|
||||
- Unified the way of checking if a required event handler was provided. Now, all drivers do it with assertions.
|
||||
- Changed the RNG bias correction configuration option to be enabled by default.
|
||||
- Refactored the ADC driver and HAL.
|
||||
- Corrected assertions in the TIMER driver to make it usable in debug version with PPI.
|
||||
- Improved buffer handling in the I2S driver. The API of the driver has been sligthly modified.
|
||||
- Enhanced SPIS driver API: added the "p_context" parameter, allowed NULL pointers for zero-length buffers.
|
||||
|
||||
### Fixed
|
||||
- Fixed result value casting in the TEMP HAL.
|
||||
- Fixed types of conversion result and buffer size in the ADC HAL and driver.
|
||||
- Fixed time-out in the SAADC driver in abort function.
|
||||
|
||||
## [0.8.0] - 2017-12-20
|
||||
### Added
|
||||
- Added XIP support in the QSPI driver.
|
||||
- Implemented Errata 132 in the CLOCK driver.
|
||||
- Added function for checking if a TIMER instance is enabled.
|
||||
- Added extended SPIM support.
|
||||
|
||||
### Changed
|
||||
- Updated MDK to 8.15.0. Introduced Segger Embedded Studio startup files.
|
||||
- Updated drivers: COMP, PWM, QDEC, SAADC, SPIS, TIMER, TWI, TWIS.
|
||||
- Changed the type used for transfer lengths to 'size_t' in drivers: SPI, SPIM, SPIS, TWI, TWIM, TWIS, UART, UARTE. Introduced checking of EasyDMA transfers limits.
|
||||
- Updated HALs: COMP, NVMC, UART, UARTE, USBD.
|
||||
- Updated template files and documentation of configuration options.
|
||||
|
||||
### Fixed
|
||||
- Fixed TWI and TWIM drivers so that they now support GPIOs from all ports.
|
||||
- Fixed definitions related to compare channels in the TIMER HAL.
|
||||
|
||||
### Removed
|
||||
- Removed the possibility of passing NULL instead of configuration to get default settings during drivers initialization.
|
||||
- Removed support for UART1 and PRS box #5.
|
||||
|
||||
## [0.7.0] - 2017-10-20
|
||||
### Added
|
||||
- This CHANGELOG.md file.
|
||||
- README.md file with simple description and explanations.
|
||||
- HAL for: ADC, CLOCK, COMP, ECB, EGU, GPIO, GPIOTE, I2S, LPCOMP, NVMC, PDM, POWER, PPI, PWM, QDEC, QSPI, RNG, RTC, SAADC, SPI, SPIM, SPIS, ARM(R) SysTick, TEMP, TIMER, TWI, TWIM, TWIS, UART, UARTE, USBD, WDT.
|
||||
- Drivers for: ADC, CLOCK, COMP, GPIOTE, I2S, LPCOMP, PDM, POWER, PWM, QDEC, QSPI, RNG, RTC, SAADC, SPI, SPIM, SPIS, ARM(R) SysTick, TIMER, TWI, TWIM, TWIS, UART, UARTE, WDT.
|
||||
- Allocators for: PPI, SWI/EGU.
|
||||
- MDK in version 8.14.0.
|
||||
- Offline documentation for every added driver and simple integration description.
|
||||
- Template integration files.
|
||||
# Changelog
|
||||
All notable changes to this project are documented in this file.
|
||||
|
||||
## [1.1.0] - 2018-06-15
|
||||
### Added
|
||||
- Implemented workaround for nRF52832 and nRF52840 anomaly 194 in the I2S driver.
|
||||
- Implemented workaround for nRF52840 anomaly 195 in the SPIM driver.
|
||||
- Added HALs for CCM, ECB, and RADIO.
|
||||
- Extended HALs for GPIO, PPI, SAADC, and USBD.
|
||||
- Added support for external LFCLK sources.
|
||||
|
||||
### Changed
|
||||
- Corrected handling of transfer lengths in the TWI driver.
|
||||
- Updated MDK to version 8.17.0.
|
||||
|
||||
### Fixed
|
||||
- Fixed logging in the PPI driver.
|
||||
- Fixed SPIM interrupt definition for nRF52810.
|
||||
- Fixed Slave Select configuration in the SPIM driver.
|
||||
- Corrected default settings for NRF_SPIM3.
|
||||
- Fixed a typo in the UARTE TXDRDY event definition.
|
||||
- Corrected the TIMEOUT event clearing in the WDT interrupt handler.
|
||||
|
||||
## [1.0.0] - 2018-03-21
|
||||
### Added
|
||||
- Added the NRFX_WAIT_FOR macro to improve the time-out functionality in QSPI and SAADC drivers.
|
||||
- Added glue layer macros for checking and modifying the pending status of interrupts.
|
||||
- Added new enumeration values for interrupts and events in the UARTE HAL.
|
||||
- Implemented workarounds for nRF52 anomalies 192 and 201 in the CLOCK driver.
|
||||
- Implemented workaround for nRF52840 anomaly 122 in the QSPI driver.
|
||||
- Implemented workaround for nRF52840 anomaly 198 in the SPIM driver.
|
||||
|
||||
### Changed
|
||||
- Updated MDK to 8.16.0.
|
||||
- Extended input pin configuration in the GPIOTE driver.
|
||||
- Unified the way of checking if a required event handler was provided. Now, all drivers do it with assertions.
|
||||
- Changed the RNG bias correction configuration option to be enabled by default.
|
||||
- Refactored the ADC driver and HAL.
|
||||
- Corrected assertions in the TIMER driver to make it usable in debug version with PPI.
|
||||
- Improved buffer handling in the I2S driver. The API of the driver has been sligthly modified.
|
||||
- Enhanced SPIS driver API: added the "p_context" parameter, allowed NULL pointers for zero-length buffers.
|
||||
|
||||
### Fixed
|
||||
- Fixed result value casting in the TEMP HAL.
|
||||
- Fixed types of conversion result and buffer size in the ADC HAL and driver.
|
||||
- Fixed time-out in the SAADC driver in abort function.
|
||||
|
||||
## [0.8.0] - 2017-12-20
|
||||
### Added
|
||||
- Added XIP support in the QSPI driver.
|
||||
- Implemented Errata 132 in the CLOCK driver.
|
||||
- Added function for checking if a TIMER instance is enabled.
|
||||
- Added extended SPIM support.
|
||||
|
||||
### Changed
|
||||
- Updated MDK to 8.15.0. Introduced Segger Embedded Studio startup files.
|
||||
- Updated drivers: COMP, PWM, QDEC, SAADC, SPIS, TIMER, TWI, TWIS.
|
||||
- Changed the type used for transfer lengths to 'size_t' in drivers: SPI, SPIM, SPIS, TWI, TWIM, TWIS, UART, UARTE. Introduced checking of EasyDMA transfers limits.
|
||||
- Updated HALs: COMP, NVMC, UART, UARTE, USBD.
|
||||
- Updated template files and documentation of configuration options.
|
||||
|
||||
### Fixed
|
||||
- Fixed TWI and TWIM drivers so that they now support GPIOs from all ports.
|
||||
- Fixed definitions related to compare channels in the TIMER HAL.
|
||||
|
||||
### Removed
|
||||
- Removed the possibility of passing NULL instead of configuration to get default settings during drivers initialization.
|
||||
- Removed support for UART1 and PRS box #5.
|
||||
|
||||
## [0.7.0] - 2017-10-20
|
||||
### Added
|
||||
- This CHANGELOG.md file.
|
||||
- README.md file with simple description and explanations.
|
||||
- HAL for: ADC, CLOCK, COMP, ECB, EGU, GPIO, GPIOTE, I2S, LPCOMP, NVMC, PDM, POWER, PPI, PWM, QDEC, QSPI, RNG, RTC, SAADC, SPI, SPIM, SPIS, ARM(R) SysTick, TEMP, TIMER, TWI, TWIM, TWIS, UART, UARTE, USBD, WDT.
|
||||
- Drivers for: ADC, CLOCK, COMP, GPIOTE, I2S, LPCOMP, PDM, POWER, PWM, QDEC, QSPI, RNG, RTC, SAADC, SPI, SPIM, SPIS, ARM(R) SysTick, TIMER, TWI, TWIM, TWIS, UART, UARTE, WDT.
|
||||
- Allocators for: PPI, SWI/EGU.
|
||||
- MDK in version 8.14.0.
|
||||
- Offline documentation for every added driver and simple integration description.
|
||||
- Template integration files.
|
||||
|
||||
+39
-29
@@ -1,29 +1,39 @@
|
||||
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 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 holder 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 AND CONTRIBUTORS "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 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.
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
+37
-37
@@ -1,37 +1,37 @@
|
||||
# nrfx
|
||||
|
||||
## Overview
|
||||
|
||||
nrfx is an extract from the nRF5 SDK that contains solely the drivers for
|
||||
peripherals present in Nordic SoCs, for convenience complemented with the MDK
|
||||
package containing required structures and bitfields definitions, startup
|
||||
files etc.
|
||||
|
||||
## Supported SoCs
|
||||
|
||||
* nRF51 Series
|
||||
* nRF52810
|
||||
* nRF52832
|
||||
* nRF52840
|
||||
|
||||
## Directories
|
||||
|
||||
```
|
||||
.
|
||||
├── doc # Project documentation files
|
||||
├── drivers # nrfx drivers files
|
||||
│ └── include # nrfx drivers headers
|
||||
│ └── src # nrfx drivers sources
|
||||
├── hal # Hardware Access Layer files
|
||||
├── mdk # Nordic MDK files
|
||||
├── soc # Nordic SoC related files
|
||||
└── templates # Templates of nrfx integration files
|
||||
```
|
||||
|
||||
## Generating documentation
|
||||
|
||||
nrfx documentation is availabe in the `doc\html` folder of the release package.
|
||||
|
||||
You can also generate documentation yourself from the source code. To do it, install doxygen
|
||||
and run one of the scripts: `generate_html_doc.bat` or `generate_html_doc.sh`. Generated
|
||||
documentation will be stored in the `doc\html` directory. Use `index.html` to open it.
|
||||
# nrfx
|
||||
|
||||
## Overview
|
||||
|
||||
nrfx is an extract from the nRF5 SDK that contains solely the drivers for
|
||||
peripherals present in Nordic SoCs, for convenience complemented with the MDK
|
||||
package containing required structures and bitfields definitions, startup
|
||||
files etc.
|
||||
|
||||
## Supported SoCs
|
||||
|
||||
* nRF51 Series
|
||||
* nRF52810
|
||||
* nRF52832
|
||||
* nRF52840
|
||||
|
||||
## Directories
|
||||
|
||||
```
|
||||
.
|
||||
├── doc # Project documentation files
|
||||
├── drivers # nrfx drivers files
|
||||
│ └── include # nrfx drivers headers
|
||||
│ └── src # nrfx drivers sources
|
||||
├── hal # Hardware Access Layer files
|
||||
├── mdk # Nordic MDK files
|
||||
├── soc # Nordic SoC related files
|
||||
└── templates # Templates of nrfx integration files
|
||||
```
|
||||
|
||||
## Generating documentation
|
||||
|
||||
nrfx documentation is availabe in the `doc\html` folder of the release package.
|
||||
|
||||
You can also generate documentation yourself from the source code. To do it, install doxygen
|
||||
and run one of the scripts: `generate_html_doc.bat` or `generate_html_doc.sh`. Generated
|
||||
documentation will be stored in the `doc\html` directory. Use `index.html` to open it.
|
||||
|
||||
@@ -0,0 +1,506 @@
|
||||
.appliesto {background-color:#3D578C;color:#fff}
|
||||
|
||||
div.header
|
||||
{
|
||||
background-image:none;
|
||||
background-color: #FFF;
|
||||
border-bottom: 0px;
|
||||
}
|
||||
|
||||
body, table, div, p, dl {
|
||||
font-size: 16px;
|
||||
font-family: Open Sans, Calibri, Arial, Sans-Serif;
|
||||
color: #474747;
|
||||
line-height: 20px;
|
||||
|
||||
}
|
||||
|
||||
a.code {
|
||||
color: #1c99c7;
|
||||
}
|
||||
|
||||
a.el {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.contents a:visited, a:visited.code {
|
||||
color: #16779a;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 1.34em
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.25em
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.15em
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1.05em
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 1em
|
||||
}
|
||||
|
||||
table.memberdecls, table.directory, table.memname {
|
||||
margin:0px;
|
||||
border:0px;
|
||||
-moz-box-shadow: 0 0px 0px #d1d1d1;
|
||||
-webkit-box-shadow: 0 0px 0px #d1d1d1;
|
||||
box-shadow: 0 0px 0px #d1d1d1;
|
||||
}
|
||||
|
||||
table.memberdecls tr {
|
||||
padding-left:0px;
|
||||
}
|
||||
|
||||
table.memberdecls tr:hover td, table.memname tr:hover td {
|
||||
background: inherit;
|
||||
}
|
||||
|
||||
table.directory tr.even, table.directory tr.odd {
|
||||
background: inherit;
|
||||
}
|
||||
|
||||
table.memberdecls td, table.directory td, table.directory td.desc {
|
||||
border:0px;
|
||||
padding: 2px 0px 0px;
|
||||
}
|
||||
|
||||
table.memberdecls td.memSeparator {
|
||||
background-color:#inherit;
|
||||
padding:2px;
|
||||
border-bottom: 1px dotted #DEE4F0;
|
||||
}
|
||||
|
||||
.mdescLeft, .mdescRight,
|
||||
.memItemLeft, .memItemRight,
|
||||
.memTemplItemLeft, .memTemplItemRight, .memTemplParams {
|
||||
background-color: inherit;
|
||||
}
|
||||
|
||||
div.levels {
|
||||
display:none;
|
||||
}
|
||||
|
||||
table.retval {
|
||||
border:#ccc 1px solid;
|
||||
}
|
||||
|
||||
|
||||
table.memname td, table.params td, table.retval td {
|
||||
padding:5px;
|
||||
border:0px;
|
||||
}
|
||||
|
||||
div.fragment div.line {
|
||||
font-size: 14px;
|
||||
line-height:18px;
|
||||
}
|
||||
|
||||
table.fieldtable, table.params, table.retval {
|
||||
-moz-box-shadow: none;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
table.fieldtable th {
|
||||
border:none;
|
||||
border-bottom:1px solid #A8B8D9;
|
||||
}
|
||||
|
||||
table.blank, table.blank tr th, table.blank tr td {
|
||||
border:none;
|
||||
-moz-box-shadow: none;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
table.blank tr:hover td {
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
|
||||
#projectlogo
|
||||
{
|
||||
text-align: left;
|
||||
vertical-align: middle;
|
||||
border-collapse: separate;
|
||||
}
|
||||
|
||||
#projectname
|
||||
{
|
||||
font-size: 40px;
|
||||
font-family: Open Sans, Calibri, Arial, Sans-Serif;
|
||||
margin: 0px;
|
||||
padding: 2px 0px;
|
||||
}
|
||||
|
||||
#projectbrief
|
||||
{
|
||||
font-size: 30px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
#titlearea
|
||||
{
|
||||
border-bottom: 1px solid #e0e0e0;
|
||||
}
|
||||
|
||||
.label a, .item a
|
||||
{
|
||||
border-bottom: none;
|
||||
|
||||
}
|
||||
|
||||
#nav-tree {
|
||||
background-image: none;
|
||||
background-color: #FAFAFA;
|
||||
}
|
||||
|
||||
div.contents {
|
||||
margin-left: 30px;
|
||||
margin-right: 30px;
|
||||
|
||||
}
|
||||
|
||||
div.header {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
table td.doclinks a {
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
color: #e97c25;
|
||||
border: 1px solid #e97c25;
|
||||
padding: 2px 5px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
table td.docselected a {
|
||||
background: #e97c25;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
table td.doclinkintro {
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
||||
/* nordic.css */
|
||||
.p {
|
||||
margin-top: .3em;
|
||||
}
|
||||
|
||||
/* fix for table spacing */
|
||||
td p.p {
|
||||
margin: 0em;
|
||||
padding: 0px;
|
||||
}
|
||||
dt.line_sep {
|
||||
border-top: solid #c9c9c9 1px;
|
||||
padding-top: 5px;
|
||||
|
||||
}
|
||||
|
||||
a
|
||||
{
|
||||
color: #1c99c7;
|
||||
text-decoration: none;
|
||||
border-bottom: 1px #e5e5e5 solid;
|
||||
|
||||
}
|
||||
|
||||
a:visited
|
||||
{
|
||||
color: #16779a;
|
||||
}
|
||||
a:hover
|
||||
{
|
||||
color: #none;
|
||||
text-decoration: underline;
|
||||
border: none;
|
||||
}
|
||||
|
||||
a:active
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ul.ul {
|
||||
margin-top: 4px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
|
||||
a[href*='.pdf'] {
|
||||
background:transparent url(./pdf.png) center left no-repeat;
|
||||
padding-left:22px;
|
||||
line-height:18px;
|
||||
}
|
||||
|
||||
|
||||
a[href*='.zip'] {
|
||||
background:transparent url(./zip_s.png) center left no-repeat;
|
||||
padding-left:22px;
|
||||
line-height:18px;
|
||||
}
|
||||
|
||||
a[href*='.exe'] {
|
||||
background:transparent url(./execute_s.png) center left no-repeat;
|
||||
padding-left:22px;
|
||||
line-height:18px;
|
||||
}
|
||||
|
||||
a[href*='.msi'] {
|
||||
background:transparent url(./msi_s.png) center left no-repeat;
|
||||
padding-left:22px;
|
||||
line-height:18px;
|
||||
}
|
||||
|
||||
table a:link {
|
||||
color: #1c99c7;
|
||||
text-decoration: none;
|
||||
border-bottom: 1px #e5e5e5 solid;
|
||||
}
|
||||
table a:visited {
|
||||
color: #16779a;
|
||||
}
|
||||
table a:active,
|
||||
table a:hover {
|
||||
color: #none;
|
||||
text-decoration: underline;
|
||||
border: none;
|
||||
}
|
||||
table {
|
||||
font-family:Calibri, Arial, Sans-Serif;
|
||||
color:#474747;
|
||||
font-size:16px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
border:#ccc 1px solid;
|
||||
|
||||
|
||||
-moz-box-shadow: 0 1px 2px #d1d1d1;
|
||||
-webkit-box-shadow: 0 1px 2px #d1d1d1;
|
||||
box-shadow: 0 1px 2px #d1d1d1;
|
||||
}
|
||||
table th {
|
||||
color: #000;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
text-align: left;
|
||||
padding:10px 15px 10px 10px;
|
||||
border-top:1px solid #7eceed;
|
||||
border-bottom:1px solid #7eceed;
|
||||
border-right:1px solid #7eceed;
|
||||
border-left:1px solid #7eceed;
|
||||
|
||||
background: #7eceed;
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#7eceed), to(#7eceed));
|
||||
background: -moz-linear-gradient(top, #7eceed, #7eceed);
|
||||
}
|
||||
|
||||
table th.center {
|
||||
text-align: center;
|
||||
}
|
||||
table tr {
|
||||
text-align: left;
|
||||
|
||||
}
|
||||
table td {
|
||||
padding:5px 5px 5px 10px;
|
||||
border-top: 1px solid #ffffff;
|
||||
border-bottom:1px solid #e0e0e0;
|
||||
border-left: 1px solid #e0e0e0;
|
||||
border-right: 1px solid #e0e0e0;
|
||||
|
||||
}
|
||||
table tr:hover td {
|
||||
background: #ebebeb;
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#f2f2f2), to(#f0f0f0));
|
||||
background: -moz-linear-gradient(top, #f2f2f2, #f0f0f0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
img {
|
||||
border: 0;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
max-width:100%;
|
||||
}
|
||||
|
||||
|
||||
/* make svg files scale in IE. compatible with Dita OT v2.0
|
||||
img:not(.png) {
|
||||
width: 100%;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/* make svg files scale in IE */
|
||||
embed.image:not(.png):not(.gif):not(.jpg) {
|
||||
width: 100%;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
svg {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
|
||||
}
|
||||
|
||||
caption {
|
||||
caption-side: bottom;
|
||||
text-align: center;
|
||||
font-size: 100%;
|
||||
font-weight: bold;
|
||||
margin-top: 15px;
|
||||
margin-bottom: 35px;
|
||||
|
||||
}
|
||||
|
||||
figdesc {
|
||||
caption-side: bottom;
|
||||
text-align: center;
|
||||
font-size: 100%;
|
||||
font-weight: bold;
|
||||
margin-top: 15px;
|
||||
margin-bottom: 20px;
|
||||
|
||||
}
|
||||
|
||||
/* to get figure captions to appear below the image and center */
|
||||
|
||||
div.fig {
|
||||
display: table;
|
||||
width: 100%;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 55px;
|
||||
}
|
||||
|
||||
div.fig span.figcap {
|
||||
display:table-footer-group;
|
||||
text-align:center;
|
||||
font-size: 100%;
|
||||
font-weight: bold;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 20px;
|
||||
font-style: normal;
|
||||
}
|
||||
div.fig div.imagecenter {
|
||||
display:table-row-group;
|
||||
}
|
||||
|
||||
|
||||
/* fix to hide borders in image maps (Chrome only) */
|
||||
img.map, map area{
|
||||
outline: none;
|
||||
}
|
||||
|
||||
|
||||
/* fix placement of <sup>®</sup> */
|
||||
sup {
|
||||
line-height: 1em;
|
||||
}
|
||||
|
||||
.sdkversion span {
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
color: #e97c25;
|
||||
border: 1px solid #e97c25;
|
||||
padding: 2px 5px;
|
||||
}
|
||||
|
||||
.sdkversion {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.whichSDs span,.whichnRF span {
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
color: #e97c25;
|
||||
border: 1px solid #e97c25;
|
||||
padding: 2px 5px;
|
||||
}
|
||||
|
||||
.whichSDs.nRF52 span,.whichnRF.nRF52 span {
|
||||
color: #e97c25;
|
||||
border-color: #e97c25;
|
||||
}
|
||||
|
||||
.whichSDs.nRF52840 span,.whichnRF.nRF52840 span {
|
||||
color: #0081B7;
|
||||
border-color: #0081B7;
|
||||
}
|
||||
|
||||
.whichSDs.nRF51 span,.whichnRF.nRF51 span {
|
||||
color: #7f7f7f;
|
||||
border-color: #7f7f7f;
|
||||
}
|
||||
|
||||
div.whichnRF {
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
span.whichnRF{
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
color: #e97c25;
|
||||
border: 1px solid #e97c25;
|
||||
padding: 2px 5px;
|
||||
}
|
||||
|
||||
span.whichnRF.nRF52 {
|
||||
color: #e97c25;
|
||||
border-color: #e97c25;
|
||||
}
|
||||
|
||||
span.whichnRF.nRF52840 {
|
||||
color: #0081B7;
|
||||
border-color: #0081B7;
|
||||
}
|
||||
|
||||
span.whichnRF.nRF51 {
|
||||
color: #7f7f7f;
|
||||
border-color: #7f7f7f;
|
||||
}
|
||||
|
||||
.orange {
|
||||
color: #e97c25;
|
||||
}
|
||||
|
||||
hr {
|
||||
margin-top:20px;
|
||||
border-top:1px solid #8EA7B0;
|
||||
}
|
||||
|
||||
|
||||
.directory td.entry {
|
||||
white-space: normal;
|
||||
width:50%;
|
||||
}
|
||||
|
||||
/* overrides */
|
||||
.topicfooter {
|
||||
text-align: right;
|
||||
// margin-top: 1px;
|
||||
padding-right: 10px;
|
||||
box-shadow: inset 0px 1px 0px 0px #e0e0e0;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
@@ -0,0 +1,13 @@
|
||||
<div id="nav-path" class="topicfooter">
|
||||
<a href="mailto:[email protected]?subject=Documentation%20feedback" id="maillink">Documentation feedback</a> | <a href="https://devzone.nordicsemi.com/questions/" target="_blank">Developer Zone</a> | <a href="http://response.nordicsemi.com/subscribe-to-our-newsletters" target="_blank">Subscribe</a> | Updated <span id="date"/>
|
||||
|
||||
<script>
|
||||
var date = new Date("$date" + " UTC");
|
||||
document.getElementById("date").innerHTML = date.toJSON().slice(0, 10);
|
||||
var url=window.location.href.split("?")[0];
|
||||
var filename=url.substring(url.lastIndexOf('/')+1);
|
||||
document.getElementById("maillink").href = "mailto:[email protected]?subject=Documentation%20feedback"+decodeURIComponent("%26")+"body=File%20name%3A%20"+encodeURIComponent(filename);
|
||||
</script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,68 @@
|
||||
<!-- HTML header for doxygen 1.8.3.1-->
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen $doxygenversion"/>
|
||||
<!--BEGIN PROJECT_NAME--><title>$projectname $projectnumber: $title</title><!--END PROJECT_NAME-->
|
||||
<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME-->
|
||||
<link href="$relpath^tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="$relpath^jquery.js"></script>
|
||||
<script type="text/javascript" src="$relpath^dynsections.js"></script>
|
||||
$treeview
|
||||
$search
|
||||
$mathjax
|
||||
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
|
||||
$extrastylesheet
|
||||
<link href="$relpath^nordic.css" rel="stylesheet" type="text/css" />
|
||||
<link rel="Shortcut icon" href="./favicon.ico" type="image/x-icon" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
|
||||
<!--BEGIN TITLEAREA-->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0" width="100%" class="blank">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<!--BEGIN PROJECT_LOGO-->
|
||||
<td id="projectlogo"><img alt="Nordic Semiconductor" src="$relpath^$projectlogo"/></td>
|
||||
<!--END PROJECT_LOGO-->
|
||||
<!--BEGIN PROJECT_NAME-->
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectname">$projectname
|
||||
<!--BEGIN PROJECT_NUMBER--> <span id="projectnumber">$projectnumber</span><!--END PROJECT_NUMBER-->
|
||||
</div>
|
||||
<!--BEGIN PROJECT_BRIEF--><div id="projectbrief">$projectbrief</div><!--END PROJECT_BRIEF-->
|
||||
</td>
|
||||
<!--END PROJECT_NAME-->
|
||||
<!--BEGIN !PROJECT_NAME-->
|
||||
<!--BEGIN PROJECT_BRIEF-->
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectbrief">$projectbrief</div>
|
||||
</td>
|
||||
<!--END PROJECT_BRIEF-->
|
||||
<!--END !PROJECT_NAME-->
|
||||
<!--BEGIN DISABLE_INDEX-->
|
||||
<!--BEGIN SEARCHENGINE-->
|
||||
<td>$searchbox</td>
|
||||
<!--END SEARCHENGINE-->
|
||||
<!--END DISABLE_INDEX-->
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<script>
|
||||
var url=window.location.href.split("/").reverse()[1];
|
||||
var validLinks= ["nrf5","s132","s140","s212","s332"];
|
||||
var index;
|
||||
for (index = 0; index < validLinks.length; ++index) {
|
||||
if ( url.indexOf(validLinks[index]) !== -1 ) {
|
||||
document.getElementById(validLinks[index]).setAttribute('class', 'doclinks docselected');
|
||||
};
|
||||
};
|
||||
</script>
|
||||
</div>
|
||||
<!--END TITLEAREA-->
|
||||
<!-- end header part -->
|
||||
@@ -0,0 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<script type="text/javascript">
|
||||
window.location="nrf5/index.html";
|
||||
</script>
|
||||
|
||||
</head>
|
||||
</html>
|
||||
@@ -0,0 +1,187 @@
|
||||
<doxygenlayout version="1.0">
|
||||
<!-- Navigation index tabs for HTML output -->
|
||||
<navindex>
|
||||
<tab type="mainpage" visible="yes" title="Home"/>
|
||||
<tab type="pages" visible="yes" title="" intro=""/>
|
||||
<tab type="modules" visible="yes" title="API Reference" intro=""/>
|
||||
<tab type="namespaces" visible="no" title="">
|
||||
<tab type="namespacelist" visible="yes" title="" intro=""/>
|
||||
<tab type="namespacemembers" visible="yes" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="usergroup" visible="yes" title="Data Structures">
|
||||
<tab type="classlist" visible="yes" title="" intro=""/>
|
||||
<tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/>
|
||||
<tab type="hierarchy" visible="no" title="" intro=""/>
|
||||
<tab type="classmembers" visible="yes" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="files" visible="no" title="">
|
||||
<tab type="filelist" visible="yes" title="" intro=""/>
|
||||
<tab type="globals" visible="yes" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="examples" visible="yes" title="Source" intro=""/>
|
||||
</navindex>
|
||||
|
||||
<!-- Layout definition for a class page -->
|
||||
<class>
|
||||
<briefdescription visible="yes"/>
|
||||
<includes visible="$SHOW_INCLUDE_FILES"/>
|
||||
<inheritancegraph visible="$CLASS_GRAPH"/>
|
||||
<collaborationgraph visible="$COLLABORATION_GRAPH"/>
|
||||
<memberdecl>
|
||||
<nestedclasses visible="yes" title=""/>
|
||||
<publictypes title=""/>
|
||||
<publicslots title=""/>
|
||||
<signals title=""/>
|
||||
<publicmethods title=""/>
|
||||
<publicstaticmethods title=""/>
|
||||
<publicattributes title=""/>
|
||||
<publicstaticattributes title=""/>
|
||||
<protectedtypes title=""/>
|
||||
<protectedslots title=""/>
|
||||
<protectedmethods title=""/>
|
||||
<protectedstaticmethods title=""/>
|
||||
<protectedattributes title=""/>
|
||||
<protectedstaticattributes title=""/>
|
||||
<packagetypes title=""/>
|
||||
<packagemethods title=""/>
|
||||
<packagestaticmethods title=""/>
|
||||
<packageattributes title=""/>
|
||||
<packagestaticattributes title=""/>
|
||||
<properties title=""/>
|
||||
<events title=""/>
|
||||
<privatetypes title=""/>
|
||||
<privateslots title=""/>
|
||||
<privatemethods title=""/>
|
||||
<privatestaticmethods title=""/>
|
||||
<privateattributes title=""/>
|
||||
<privatestaticattributes title=""/>
|
||||
<friends title=""/>
|
||||
<related title="" subtitle=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<constructors title=""/>
|
||||
<functions title=""/>
|
||||
<related title=""/>
|
||||
<variables title=""/>
|
||||
<properties title=""/>
|
||||
<events title=""/>
|
||||
</memberdef>
|
||||
<allmemberslink visible="yes"/>
|
||||
<usedfiles visible="$SHOW_USED_FILES"/>
|
||||
<authorsection visible="yes"/>
|
||||
</class>
|
||||
|
||||
<!-- Layout definition for a namespace page -->
|
||||
<namespace>
|
||||
<briefdescription visible="yes"/>
|
||||
<memberdecl>
|
||||
<nestednamespaces visible="yes" title=""/>
|
||||
<classes visible="yes" title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
</memberdef>
|
||||
<authorsection visible="yes"/>
|
||||
</namespace>
|
||||
|
||||
<!-- Layout definition for a file page -->
|
||||
<file>
|
||||
<briefdescription visible="yes"/>
|
||||
<includes visible="$SHOW_INCLUDE_FILES"/>
|
||||
<includegraph visible="$INCLUDE_GRAPH"/>
|
||||
<includedbygraph visible="$INCLUDED_BY_GRAPH"/>
|
||||
<sourcelink visible="yes"/>
|
||||
<memberdecl>
|
||||
<classes visible="yes" title=""/>
|
||||
<namespaces visible="yes" title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
</memberdef>
|
||||
<authorsection/>
|
||||
</file>
|
||||
|
||||
<!-- Layout definition for a group page -->
|
||||
<group>
|
||||
<briefdescription visible="yes"/>
|
||||
<groupgraph visible="$GROUP_GRAPHS"/>
|
||||
<memberdecl>
|
||||
<nestedgroups visible="yes" title=""/>
|
||||
<dirs visible="yes" title=""/>
|
||||
<files visible="yes" title=""/>
|
||||
<namespaces visible="yes" title=""/>
|
||||
<classes visible="yes" title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<enumvalues title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<signals title=""/>
|
||||
<publicslots title=""/>
|
||||
<protectedslots title=""/>
|
||||
<privateslots title=""/>
|
||||
<events title=""/>
|
||||
<properties title=""/>
|
||||
<friends title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<pagedocs/>
|
||||
<inlineclasses title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<enumvalues title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<signals title=""/>
|
||||
<publicslots title=""/>
|
||||
<protectedslots title=""/>
|
||||
<privateslots title=""/>
|
||||
<events title=""/>
|
||||
<properties title=""/>
|
||||
<friends title=""/>
|
||||
</memberdef>
|
||||
<authorsection visible="yes"/>
|
||||
</group>
|
||||
|
||||
<!-- Layout definition for a directory page -->
|
||||
<directory>
|
||||
<briefdescription visible="yes"/>
|
||||
<directorygraph visible="yes"/>
|
||||
<memberdecl>
|
||||
<dirs visible="yes"/>
|
||||
<files visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
</directory>
|
||||
</doxygenlayout>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
@page nrfx_drv_supp_matrix Driver Support Matrix
|
||||
This matrix shows which drivers are supported by particular Nordic SoCs.
|
||||
@{
|
||||
|
||||
Driver | nRF51 Series | nRF52810 | nRF52832 | nRF52840 |
|
||||
-----------------|--------------|--------------| -------------| -------------|
|
||||
@ref nrf_adc |@tagGreenTick |@tagRedCross |@tagRedCross |@tagRedCross |
|
||||
@ref nrf_ccm |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_clock |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_comp |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_ecb |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_gpio |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_gpiote |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_i2s |@tagRedCross |@tagRedCross |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_lpcomp |@tagGreenTick |@tagRedCross |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_nvmc |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_pdm |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_power |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_ppi |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_pwm |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_qdec |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_qspi |@tagRedCross |@tagRedCross |@tagRedCross |@tagGreenTick |
|
||||
@ref nrf_radio |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_rng |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_rtc |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_saadc |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_spi |@tagGreenTick |@tagRedCross |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_spim |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_spis |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_systick |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_swi_egu |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_temp |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_timer |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_twi |@tagGreenTick |@tagRedCross |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_twim |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_twis |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_uart |@tagGreenTick |@tagRedCross |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_uarte |@tagRedCross |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
@ref nrf_usbd |@tagRedCross |@tagRedCross |@tagRedCross |@tagGreenTick |
|
||||
@ref nrf_wdt |@tagGreenTick |@tagGreenTick |@tagGreenTick |@tagGreenTick |
|
||||
|
||||
@}
|
||||
*/
|
||||
@@ -0,0 +1,2 @@
|
||||
del html\*.* /Q
|
||||
doxygen nrfx.doxyfile
|
||||
@@ -0,0 +1,2 @@
|
||||
rm -rf html
|
||||
doxygen nrfx.doxyfile
|
||||
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
@mainpage Introduction
|
||||
|
||||
@em nrfx is an extract from the nRF5 SDK that contains solely the drivers for
|
||||
peripherals present in Nordic SoCs, for convenience complemented with the MDK
|
||||
package containing required structures and bitfields definitions, startup
|
||||
files etc.
|
||||
|
||||
Refer to the @ref nrfx_drv_supp_matrix to check which drivers are suitable
|
||||
for a given SoC.
|
||||
|
||||
@section nrfx_integration Integration
|
||||
|
||||
The purpose of @em nrfx is to make it possible to use the same set of peripheral
|
||||
drivers in various environments, from RTOSes to bare metal applications.
|
||||
Hence, for a given host environment, a light integration layer must be provided
|
||||
that implements certain specific routines, like interrupt management, critical
|
||||
sections, assertions, or logging. This is done by filling a predefined set of
|
||||
macros with proper implementations (or keeping some empty if desired) in files
|
||||
named:
|
||||
- @ref nrfx_glue
|
||||
- @ref nrfx_log
|
||||
|
||||
Templates of these files are provided
|
||||
in the <a href="../../templates/">templates</a> subfolder. Their customized
|
||||
versions can be placed in any location within the host environment that the
|
||||
used compiler can access via include paths.
|
||||
|
||||
In addition, the following locations should be specified as include paths
|
||||
([nrfx] stands for the @em nrfx root folder location):
|
||||
@code
|
||||
[nrfx]/
|
||||
[nrfx]/drivers/include
|
||||
[nrfx]/mdk
|
||||
@endcode
|
||||
|
||||
@section nrfx_irq_handlers IRQ handlers
|
||||
|
||||
The IRQ handlers in all drivers are implemented as ordinary API functions
|
||||
named "nrfx_*_irq_handler". They can be bound to some structures or called in
|
||||
a specific way according to the requirements of the host environment.
|
||||
To install the handlers in the standard MDK way, you must only add the following
|
||||
line to the @ref nrfx_glue file:
|
||||
|
||||
@code
|
||||
#include <soc/nrfx_irqs.h>
|
||||
@endcode
|
||||
|
||||
This will cause the preprocessor to properly rename all the IRQ handler
|
||||
functions so that the linker could install them in the vector table.
|
||||
|
||||
@section nrfx_configuration Configuration
|
||||
|
||||
The drivers use both dynamic (run time) and static (compile time) configuration.
|
||||
|
||||
Dynamic configuration is done by specifying desired options in configuration
|
||||
structures passed to the drivers during their initialization.
|
||||
Refer to the API reference for a given driver to see the members of its
|
||||
configuration structure.
|
||||
|
||||
Static configuration allows enabling and disabling (excluding their code from
|
||||
compilation) particular drivers or in some cases their specific features,
|
||||
defining default parameters for dynamic configuration, parametrization of
|
||||
logging in particular drivers. It is done by specifying desired values of macros
|
||||
in a file named:
|
||||
|
||||
- nrfx_config.h
|
||||
|
||||
This file, similarly to the integration files mentioned above, can be placed
|
||||
in any suitable location within the host environment.
|
||||
The <a href="../../templates/">templates</a> subfolder contains templates of
|
||||
configuration files for all currently supported Nordic SoCs placed in respective
|
||||
subfolders.
|
||||
Refer to the "driver configuration" section in the API reference for a given
|
||||
driver for more information regarding configuration options available for it.
|
||||
|
||||
@section nrfx_additional_reqs Additional requirements
|
||||
|
||||
Nordic SoCs are based on ARM® Cortex™-M series processors. Before you can
|
||||
start developing with @em nrfx, you must add the CMSIS header files to include
|
||||
paths during the compilation process. Download these files from the following
|
||||
website:
|
||||
|
||||
- <a href="https://github.com/ARM-software/CMSIS"> ARM® CMSIS repository</a>
|
||||
(CMSIS/Include directory)
|
||||
*/
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
@page nrf51_series_drivers nRF51 Series Drivers
|
||||
@{
|
||||
|
||||
@ref nrf_adc
|
||||
|
||||
@ref nrf_ccm
|
||||
|
||||
@ref nrf_clock
|
||||
|
||||
@ref nrf_ecb
|
||||
|
||||
@ref nrf_gpio
|
||||
|
||||
@ref nrf_gpiote
|
||||
|
||||
@ref nrf_lpcomp
|
||||
|
||||
@ref nrf_nvmc
|
||||
|
||||
@ref nrf_power
|
||||
|
||||
@ref nrf_ppi
|
||||
|
||||
@ref nrf_qdec
|
||||
|
||||
@ref nrf_radio
|
||||
|
||||
@ref nrf_rng
|
||||
|
||||
@ref nrf_rtc
|
||||
|
||||
@ref nrf_spi
|
||||
|
||||
@ref nrf_spis
|
||||
|
||||
@ref nrf_swi_egu
|
||||
|
||||
@ref nrf_temp
|
||||
|
||||
@ref nrf_timer
|
||||
|
||||
@ref nrf_twi
|
||||
|
||||
@ref nrf_uart
|
||||
|
||||
@ref nrf_wdt
|
||||
|
||||
@}
|
||||
*/
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
@page nrf52810_drivers nRF52810 Drivers
|
||||
@{
|
||||
|
||||
@ref nrf_ccm
|
||||
|
||||
@ref nrf_clock
|
||||
|
||||
@ref nrf_comp
|
||||
|
||||
@ref nrf_ecb
|
||||
|
||||
@ref nrf_gpio
|
||||
|
||||
@ref nrf_gpiote
|
||||
|
||||
@ref nrf_nvmc
|
||||
|
||||
@ref nrf_pdm
|
||||
|
||||
@ref nrf_power
|
||||
|
||||
@ref nrf_ppi
|
||||
|
||||
@ref nrf_pwm
|
||||
|
||||
@ref nrf_qdec
|
||||
|
||||
@ref nrf_radio
|
||||
|
||||
@ref nrf_rng
|
||||
|
||||
@ref nrf_rtc
|
||||
|
||||
@ref nrf_saadc
|
||||
|
||||
@ref nrf_spim
|
||||
|
||||
@ref nrf_spis
|
||||
|
||||
@ref nrf_systick
|
||||
|
||||
@ref nrf_swi_egu
|
||||
|
||||
@ref nrf_temp
|
||||
|
||||
@ref nrf_timer
|
||||
|
||||
@ref nrf_twim
|
||||
|
||||
@ref nrf_twis
|
||||
|
||||
@ref nrf_uarte
|
||||
|
||||
@ref nrf_wdt
|
||||
|
||||
@}
|
||||
*/
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
@page nrf52832_drivers nRF52832 Drivers
|
||||
@{
|
||||
|
||||
@ref nrf_ccm
|
||||
|
||||
@ref nrf_clock
|
||||
|
||||
@ref nrf_comp
|
||||
|
||||
@ref nrf_ecb
|
||||
|
||||
@ref nrf_gpio
|
||||
|
||||
@ref nrf_gpiote
|
||||
|
||||
@ref nrf_i2s
|
||||
|
||||
@ref nrf_lpcomp
|
||||
|
||||
@ref nrf_nvmc
|
||||
|
||||
@ref nrf_pdm
|
||||
|
||||
@ref nrf_power
|
||||
|
||||
@ref nrf_ppi
|
||||
|
||||
@ref nrf_pwm
|
||||
|
||||
@ref nrf_qdec
|
||||
|
||||
@ref nrf_radio
|
||||
|
||||
@ref nrf_rng
|
||||
|
||||
@ref nrf_rtc
|
||||
|
||||
@ref nrf_saadc
|
||||
|
||||
@ref nrf_spi
|
||||
|
||||
@ref nrf_spim
|
||||
|
||||
@ref nrf_spis
|
||||
|
||||
@ref nrf_systick
|
||||
|
||||
@ref nrf_swi_egu
|
||||
|
||||
@ref nrf_temp
|
||||
|
||||
@ref nrf_timer
|
||||
|
||||
@ref nrf_twi
|
||||
|
||||
@ref nrf_twim
|
||||
|
||||
@ref nrf_twis
|
||||
|
||||
@ref nrf_uart
|
||||
|
||||
@ref nrf_uarte
|
||||
|
||||
@ref nrf_wdt
|
||||
|
||||
@}
|
||||
*/
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
@page nrf52840_drivers nRF52840 Drivers
|
||||
@{
|
||||
|
||||
@ref nrf_ccm
|
||||
|
||||
@ref nrf_clock
|
||||
|
||||
@ref nrf_comp
|
||||
|
||||
@ref nrf_ecb
|
||||
|
||||
@ref nrf_gpio
|
||||
|
||||
@ref nrf_gpiote
|
||||
|
||||
@ref nrf_i2s
|
||||
|
||||
@ref nrf_lpcomp
|
||||
|
||||
@ref nrf_nvmc
|
||||
|
||||
@ref nrf_pdm
|
||||
|
||||
@ref nrf_power
|
||||
|
||||
@ref nrf_ppi
|
||||
|
||||
@ref nrf_pwm
|
||||
|
||||
@ref nrf_qdec
|
||||
|
||||
@ref nrf_qspi
|
||||
|
||||
@ref nrf_radio
|
||||
|
||||
@ref nrf_rng
|
||||
|
||||
@ref nrf_rtc
|
||||
|
||||
@ref nrf_saadc
|
||||
|
||||
@ref nrf_spi
|
||||
|
||||
@ref nrf_spim
|
||||
|
||||
@ref nrf_spis
|
||||
|
||||
@ref nrf_systick
|
||||
|
||||
@ref nrf_swi_egu
|
||||
|
||||
@ref nrf_temp
|
||||
|
||||
@ref nrf_timer
|
||||
|
||||
@ref nrf_twi
|
||||
|
||||
@ref nrf_twim
|
||||
|
||||
@ref nrf_twis
|
||||
|
||||
@ref nrf_uart
|
||||
|
||||
@ref nrf_uarte
|
||||
|
||||
@ref nrf_usbd
|
||||
|
||||
@ref nrf_wdt
|
||||
|
||||
@}
|
||||
*/
|
||||
+1892
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
@defgroup nrfx_drivers Drivers
|
||||
@{
|
||||
@brief List of all drivers available in nrfx.
|
||||
@defgroup nrf_adc ADC
|
||||
|
||||
@defgroup nrf_ccm CCM
|
||||
|
||||
@defgroup nrf_clock CLOCK
|
||||
|
||||
@defgroup nrf_comp COMP
|
||||
|
||||
@defgroup nrf_ecb ECB
|
||||
|
||||
@defgroup nrf_gpio GPIO
|
||||
|
||||
@defgroup nrf_gpiote GPIOTE
|
||||
|
||||
@defgroup nrf_i2s I2S
|
||||
|
||||
@defgroup nrf_lpcomp LPCOMP
|
||||
|
||||
@defgroup nrf_nvmc NVMC
|
||||
|
||||
@defgroup nrf_pdm PDM
|
||||
|
||||
@defgroup nrf_power POWER
|
||||
|
||||
@defgroup nrf_ppi PPI
|
||||
|
||||
@defgroup nrf_pwm PWM
|
||||
|
||||
@defgroup nrf_qdec QDEC
|
||||
|
||||
@defgroup nrf_qspi QSPI
|
||||
|
||||
@defgroup nrf_radio RADIO
|
||||
|
||||
@defgroup nrf_rng RNG
|
||||
|
||||
@defgroup nrf_rtc RTC
|
||||
|
||||
@defgroup nrf_saadc SAADC
|
||||
|
||||
@defgroup nrf_spi SPI
|
||||
|
||||
@defgroup nrf_spim SPIM
|
||||
|
||||
@defgroup nrf_spis SPIS
|
||||
|
||||
@defgroup nrf_systick Cortex-M Systick
|
||||
|
||||
@defgroup nrf_swi_egu SWI/EGU
|
||||
|
||||
@defgroup nrf_temp TEMP
|
||||
|
||||
@defgroup nrf_timer TIMER
|
||||
|
||||
@defgroup nrf_twi TWI
|
||||
|
||||
@defgroup nrf_twim TWIM
|
||||
|
||||
@defgroup nrf_twis TWIS
|
||||
|
||||
@defgroup nrf_uart UART
|
||||
|
||||
@defgroup nrf_uarte UARTE
|
||||
|
||||
@defgroup nrf_usbd USBD
|
||||
|
||||
@defgroup nrf_wdt WDT
|
||||
@}
|
||||
|
||||
@defgroup nrfx nrfx API
|
||||
*/
|
||||
+156
-147
@@ -1,147 +1,156 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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 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 holder 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 AND CONTRIBUTORS "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 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_BITMASK_H
|
||||
#define NRF_BITMASK_H
|
||||
|
||||
#include <nrfx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_bitmask Bitmask module
|
||||
* @{
|
||||
* @ingroup nrfx
|
||||
* @brief Bitmask managing module.
|
||||
*/
|
||||
|
||||
#define BITMASK_BYTE_GET(abs_bit) ((abs_bit)/8)
|
||||
#define BITMASK_RELBIT_GET(abs_bit) ((abs_bit) & 0x00000007)
|
||||
|
||||
/**
|
||||
* Function for checking if bit in the multi-byte bit mask is set.
|
||||
*
|
||||
* @param bit Bit index.
|
||||
* @param p_mask A pointer to mask with bit fields.
|
||||
*
|
||||
* @return 0 if bit is not set, positive value otherwise.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_bitmask_bit_is_set(uint32_t bit, void const * p_mask)
|
||||
{
|
||||
uint8_t const * p_mask8 = (uint8_t const *)p_mask;
|
||||
uint32_t byte_idx = BITMASK_BYTE_GET(bit);
|
||||
bit = BITMASK_RELBIT_GET(bit);
|
||||
return (1 << bit) & p_mask8[byte_idx];
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for setting a bit in the multi-byte bit mask.
|
||||
*
|
||||
* @param bit Bit index.
|
||||
* @param p_mask A pointer to mask with bit fields.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_bitmask_bit_set(uint32_t bit, void * p_mask)
|
||||
{
|
||||
uint8_t * p_mask8 = (uint8_t *)p_mask;
|
||||
uint32_t byte_idx = BITMASK_BYTE_GET(bit);
|
||||
bit = BITMASK_RELBIT_GET(bit);
|
||||
p_mask8[byte_idx] |= (1 << bit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for clearing a bit in the multi-byte bit mask.
|
||||
*
|
||||
* @param bit Bit index.
|
||||
* @param p_mask A pointer to mask with bit fields.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_bitmask_bit_clear(uint32_t bit, void * p_mask)
|
||||
{
|
||||
uint8_t * p_mask8 = (uint8_t *)p_mask;
|
||||
uint32_t byte_idx = BITMASK_BYTE_GET(bit);
|
||||
bit = BITMASK_RELBIT_GET(bit);
|
||||
p_mask8[byte_idx] &= ~(1 << bit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for performing bitwise OR operation on two multi-byte bit masks.
|
||||
*
|
||||
* @param p_mask1 A pointer to the first bit mask.
|
||||
* @param p_mask2 A pointer to the second bit mask.
|
||||
* @param p_out_mask A pointer to the output bit mask.
|
||||
* @param length Length of output mask in bytes.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_bitmask_masks_or(void const * p_mask1,
|
||||
void const * p_mask2,
|
||||
void * p_out_mask,
|
||||
uint32_t length)
|
||||
{
|
||||
uint8_t const * p_mask8_1 = (uint8_t const *)p_mask1;
|
||||
uint8_t const * p_mask8_2 = (uint8_t const *)p_mask2;
|
||||
uint8_t * p_mask8_out = (uint8_t *)p_out_mask;
|
||||
uint32_t i;
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
p_mask8_out[i] = p_mask8_1[i] | p_mask8_2[i];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for performing bitwise AND operation on two multi-byte bit masks.
|
||||
*
|
||||
* @param p_mask1 A pointer to the first bit mask.
|
||||
* @param p_mask2 A pointer to the second bit mask.
|
||||
* @param p_out_mask A pointer to the output bit mask.
|
||||
* @param length Length of output mask in bytes.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_bitmask_masks_and(void const * p_mask1,
|
||||
void const * p_mask2,
|
||||
void * p_out_mask,
|
||||
uint32_t length)
|
||||
{
|
||||
uint8_t const * p_mask8_1 = (uint8_t const *)p_mask1;
|
||||
uint8_t const * p_mask8_2 = (uint8_t const *)p_mask2;
|
||||
uint8_t * p_mask8_out = (uint8_t *)p_out_mask;
|
||||
uint32_t i;
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
p_mask8_out[i] = p_mask8_1[i] & p_mask8_2[i];
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_BITMASK_H
|
||||
/**
|
||||
* Copyright (c) 2016 - 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_BITMASK_H
|
||||
#define NRF_BITMASK_H
|
||||
|
||||
#include <nrfx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrf_bitmask Bitmask module
|
||||
* @{
|
||||
* @ingroup nrfx
|
||||
* @brief Bitmask managing module.
|
||||
*/
|
||||
|
||||
#define BITMASK_BYTE_GET(abs_bit) ((abs_bit)/8)
|
||||
#define BITMASK_RELBIT_GET(abs_bit) ((abs_bit) & 0x00000007)
|
||||
|
||||
/**
|
||||
* Function for checking if bit in the multi-byte bit mask is set.
|
||||
*
|
||||
* @param bit Bit index.
|
||||
* @param p_mask A pointer to mask with bit fields.
|
||||
*
|
||||
* @return 0 if bit is not set, positive value otherwise.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_bitmask_bit_is_set(uint32_t bit, void const * p_mask)
|
||||
{
|
||||
uint8_t const * p_mask8 = (uint8_t const *)p_mask;
|
||||
uint32_t byte_idx = BITMASK_BYTE_GET(bit);
|
||||
bit = BITMASK_RELBIT_GET(bit);
|
||||
return (1 << bit) & p_mask8[byte_idx];
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for setting a bit in the multi-byte bit mask.
|
||||
*
|
||||
* @param bit Bit index.
|
||||
* @param p_mask A pointer to mask with bit fields.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_bitmask_bit_set(uint32_t bit, void * p_mask)
|
||||
{
|
||||
uint8_t * p_mask8 = (uint8_t *)p_mask;
|
||||
uint32_t byte_idx = BITMASK_BYTE_GET(bit);
|
||||
bit = BITMASK_RELBIT_GET(bit);
|
||||
p_mask8[byte_idx] |= (1 << bit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for clearing a bit in the multi-byte bit mask.
|
||||
*
|
||||
* @param bit Bit index.
|
||||
* @param p_mask A pointer to mask with bit fields.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_bitmask_bit_clear(uint32_t bit, void * p_mask)
|
||||
{
|
||||
uint8_t * p_mask8 = (uint8_t *)p_mask;
|
||||
uint32_t byte_idx = BITMASK_BYTE_GET(bit);
|
||||
bit = BITMASK_RELBIT_GET(bit);
|
||||
p_mask8[byte_idx] &= ~(1 << bit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for performing bitwise OR operation on two multi-byte bit masks.
|
||||
*
|
||||
* @param p_mask1 A pointer to the first bit mask.
|
||||
* @param p_mask2 A pointer to the second bit mask.
|
||||
* @param p_out_mask A pointer to the output bit mask.
|
||||
* @param length Length of output mask in bytes.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_bitmask_masks_or(void const * p_mask1,
|
||||
void const * p_mask2,
|
||||
void * p_out_mask,
|
||||
uint32_t length)
|
||||
{
|
||||
uint8_t const * p_mask8_1 = (uint8_t const *)p_mask1;
|
||||
uint8_t const * p_mask8_2 = (uint8_t const *)p_mask2;
|
||||
uint8_t * p_mask8_out = (uint8_t *)p_out_mask;
|
||||
uint32_t i;
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
p_mask8_out[i] = p_mask8_1[i] | p_mask8_2[i];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for performing bitwise AND operation on two multi-byte bit masks.
|
||||
*
|
||||
* @param p_mask1 A pointer to the first bit mask.
|
||||
* @param p_mask2 A pointer to the second bit mask.
|
||||
* @param p_out_mask A pointer to the output bit mask.
|
||||
* @param length Length of output mask in bytes.
|
||||
*/
|
||||
__STATIC_INLINE void nrf_bitmask_masks_and(void const * p_mask1,
|
||||
void const * p_mask2,
|
||||
void * p_out_mask,
|
||||
uint32_t length)
|
||||
{
|
||||
uint8_t const * p_mask8_1 = (uint8_t const *)p_mask1;
|
||||
uint8_t const * p_mask8_2 = (uint8_t const *)p_mask2;
|
||||
uint8_t * p_mask8_out = (uint8_t *)p_out_mask;
|
||||
uint32_t i;
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
p_mask8_out[i] = p_mask8_1[i] & p_mask8_2[i];
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_BITMASK_H
|
||||
|
||||
+295
-272
@@ -1,272 +1,295 @@
|
||||
/**
|
||||
* Copyright (c) 2015 - 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 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 holder 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 AND CONTRIBUTORS "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 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 NRFX_ADC_H__
|
||||
#define NRFX_ADC_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <hal/nrf_adc.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrfx_adc ADC driver
|
||||
* @{
|
||||
* @ingroup nrf_adc
|
||||
* @brief Analog-to-Digital Converter (ADC) peripheral driver.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Driver event types.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NRFX_ADC_EVT_DONE, ///< Event generated when the buffer is filled with samples.
|
||||
NRFX_ADC_EVT_SAMPLE, ///< Event generated when the requested channel is sampled.
|
||||
} nrfx_adc_evt_type_t;
|
||||
|
||||
/**
|
||||
* @brief Analog-to-digital converter driver DONE event.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
nrf_adc_value_t * p_buffer; ///< Pointer to the buffer with converted samples.
|
||||
uint16_t size; ///< Number of samples in the buffer.
|
||||
} nrfx_adc_done_evt_t;
|
||||
|
||||
/**
|
||||
* @brief Analog-to-digital converter driver SAMPLE event.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
nrf_adc_value_t sample; ///< Converted sample.
|
||||
} nrfx_adc_sample_evt_t;
|
||||
|
||||
/**
|
||||
* @brief Analog-to-digital converter driver event.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
nrfx_adc_evt_type_t type; ///< Event type.
|
||||
union
|
||||
{
|
||||
nrfx_adc_done_evt_t done; ///< Data for DONE event.
|
||||
nrfx_adc_sample_evt_t sample; ///< Data for SAMPLE event.
|
||||
} data;
|
||||
} nrfx_adc_evt_t;
|
||||
|
||||
/**@brief Macro for initializing the ADC channel with the default configuration. */
|
||||
#define NRFX_ADC_DEFAULT_CHANNEL(analog_input) \
|
||||
{ \
|
||||
NULL, \
|
||||
{ \
|
||||
.resolution = NRF_ADC_CONFIG_RES_10BIT, \
|
||||
.scaling = NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE, \
|
||||
.reference = NRF_ADC_CONFIG_REF_VBG, \
|
||||
.input = (analog_input), \
|
||||
.extref = NRF_ADC_CONFIG_EXTREFSEL_NONE \
|
||||
} \
|
||||
}
|
||||
|
||||
// Forward declaration of the nrfx_adc_channel_t type.
|
||||
typedef struct nrfx_adc_channel_s nrfx_adc_channel_t;
|
||||
|
||||
/**
|
||||
* @brief ADC channel.
|
||||
*
|
||||
* This structure is defined by the user and used by the driver. Therefore, it should
|
||||
* not be defined on the stack as a local variable.
|
||||
*/
|
||||
struct nrfx_adc_channel_s
|
||||
{
|
||||
nrfx_adc_channel_t * p_next; ///< Pointer to the next enabled channel (for internal use).
|
||||
nrf_adc_config_t config; ///< ADC configuration for the current channel.
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief ADC configuration.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t interrupt_priority; ///< Priority of ADC interrupt.
|
||||
} nrfx_adc_config_t;
|
||||
|
||||
/** @brief ADC default configuration. */
|
||||
#define NRFX_ADC_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.interrupt_priority = NRFX_ADC_CONFIG_IRQ_PRIORITY \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief User event handler prototype.
|
||||
*
|
||||
* This function is called when the requested number of samples has been processed.
|
||||
*
|
||||
* @param p_event Event.
|
||||
*/
|
||||
typedef void (*nrfx_adc_event_handler_t)(nrfx_adc_evt_t const * p_event);
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the ADC.
|
||||
*
|
||||
* If a valid event handler is provided, the driver is initialized in non-blocking mode.
|
||||
* If event_handler is NULL, the driver works in blocking mode.
|
||||
*
|
||||
* @param[in] p_config Pointer to the structure with initial configuration.
|
||||
* @param[in] event_handler Event handler provided by the user.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If the driver is already initialized.
|
||||
*/
|
||||
nrfx_err_t nrfx_adc_init(nrfx_adc_config_t const * p_config,
|
||||
nrfx_adc_event_handler_t event_handler);
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing the ADC.
|
||||
*
|
||||
* This function stops all ongoing conversions and disables all channels.
|
||||
*/
|
||||
void nrfx_adc_uninit(void);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling an ADC channel.
|
||||
*
|
||||
* This function configures and enables the channel. When @ref nrfx_adc_buffer_convert is
|
||||
* called, all channels that have been enabled with this function are sampled.
|
||||
*
|
||||
* @note The channel instance variable @p p_channel is used by the driver as an item
|
||||
* in a list. Therefore, it cannot be an automatic variable that is located on the stack.
|
||||
*/
|
||||
void nrfx_adc_channel_enable(nrfx_adc_channel_t * const p_channel);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling an ADC channel.
|
||||
*/
|
||||
void nrfx_adc_channel_disable(nrfx_adc_channel_t * const p_channel);
|
||||
|
||||
/**
|
||||
* @brief Function for starting ADC sampling.
|
||||
*
|
||||
* This function triggers single ADC sampling. If more than one channel is enabled, the driver
|
||||
* emulates scanning and all channels are sampled in the order they were enabled.
|
||||
*/
|
||||
void nrfx_adc_sample(void);
|
||||
|
||||
/**
|
||||
* @brief Function for executing a single ADC conversion.
|
||||
*
|
||||
* This function selects the desired input and starts a single conversion. If a valid pointer
|
||||
* is provided for the result, the function blocks until the conversion is completed. Otherwise, the
|
||||
* function returns when the conversion is started, and the result is provided in an event (driver
|
||||
* must be initialized in non-blocking mode, otherwise an assertion will fail). The function will
|
||||
* fail if ADC is busy. The channel does not need to be enabled to perform a single conversion.
|
||||
*
|
||||
* @param[in] p_channel Channel.
|
||||
* @param[out] p_value Pointer to the location where the result should be placed. Unless NULL is
|
||||
* provided, the function is blocking.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If conversion was successful.
|
||||
* @retval NRFX_ERROR_BUSY If the ADC driver is busy.
|
||||
*/
|
||||
nrfx_err_t nrfx_adc_sample_convert(nrfx_adc_channel_t const * const p_channel,
|
||||
nrf_adc_value_t * p_value);
|
||||
|
||||
/**
|
||||
* @brief Function for converting data to the buffer.
|
||||
*
|
||||
* If the driver is initialized in non-blocking mode, this function returns when the first
|
||||
* conversion is set up. When the buffer is filled, the application is notified by the event
|
||||
* handler. If the driver is initialized in blocking mode, the function returns when the buffer is
|
||||
* filled.
|
||||
*
|
||||
* Conversion is done on all enabled channels, but it is not triggered by this
|
||||
* function. This function will prepare the ADC for sampling and then
|
||||
* wait for the SAMPLE task. Sampling can be triggered manually by the @ref
|
||||
* nrfx_adc_sample function or by PPI using the @ref NRF_ADC_TASK_START task.
|
||||
*
|
||||
* @note If more than one channel is enabled, the function emulates scanning, and
|
||||
* a single START task will trigger conversion on all enabled channels. For example:
|
||||
* If 3 channels are enabled and the user requests 6 samples, the completion event
|
||||
* handler will be called after 2 START tasks.
|
||||
*
|
||||
* @note The application must adjust the sampling frequency. The maximum frequency
|
||||
* depends on the sampling timer and the maximum latency of the ADC interrupt. If
|
||||
* an interrupt is not handled before the next sampling is triggered, the sample
|
||||
* will be lost.
|
||||
*
|
||||
* @param[in] buffer Result buffer.
|
||||
* @param[in] size Buffer size in samples.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If conversion was successful.
|
||||
* @retval NRFX_ERROR_BUSY If the driver is busy.
|
||||
*/
|
||||
nrfx_err_t nrfx_adc_buffer_convert(nrf_adc_value_t * buffer, uint16_t size);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the ADC state.
|
||||
*
|
||||
* @retval true If the ADC is busy.
|
||||
* @retval false If the ADC is ready.
|
||||
*/
|
||||
bool nrfx_adc_is_busy(void);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the ADC START task.
|
||||
*
|
||||
* This function is used to get the address of the START task, which can be used to trigger ADC
|
||||
* conversion.
|
||||
*
|
||||
* @return Start task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_adc_start_task_get(void);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_adc_start_task_get(void)
|
||||
{
|
||||
return nrf_adc_task_address_get(NRF_ADC_TASK_START);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void nrfx_adc_irq_handler(void);
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRFX_ADC_H__
|
||||
/**
|
||||
* Copyright (c) 2015 - 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 NRFX_ADC_H__
|
||||
#define NRFX_ADC_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <hal/nrf_adc.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrfx_adc ADC driver
|
||||
* @{
|
||||
* @ingroup nrf_adc
|
||||
* @brief Analog-to-Digital Converter (ADC) peripheral driver.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Driver event types.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NRFX_ADC_EVT_DONE, ///< Event generated when the buffer is filled with samples.
|
||||
NRFX_ADC_EVT_SAMPLE, ///< Event generated when the requested channel is sampled.
|
||||
} nrfx_adc_evt_type_t;
|
||||
|
||||
/**
|
||||
* @brief Analog-to-digital converter driver DONE event.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
nrf_adc_value_t * p_buffer; ///< Pointer to the buffer with converted samples.
|
||||
uint16_t size; ///< Number of samples in the buffer.
|
||||
} nrfx_adc_done_evt_t;
|
||||
|
||||
/**
|
||||
* @brief Analog-to-digital converter driver SAMPLE event.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
nrf_adc_value_t sample; ///< Converted sample.
|
||||
} nrfx_adc_sample_evt_t;
|
||||
|
||||
/**
|
||||
* @brief Analog-to-digital converter driver event.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
nrfx_adc_evt_type_t type; ///< Event type.
|
||||
union
|
||||
{
|
||||
nrfx_adc_done_evt_t done; ///< Data for DONE event.
|
||||
nrfx_adc_sample_evt_t sample; ///< Data for SAMPLE event.
|
||||
} data;
|
||||
} nrfx_adc_evt_t;
|
||||
|
||||
/**@brief Macro for initializing the ADC channel with the default configuration. */
|
||||
#define NRFX_ADC_DEFAULT_CHANNEL(analog_input) \
|
||||
{ \
|
||||
NULL, \
|
||||
{ \
|
||||
.resolution = NRF_ADC_CONFIG_RES_10BIT, \
|
||||
.scaling = NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE, \
|
||||
.reference = NRF_ADC_CONFIG_REF_VBG, \
|
||||
.input = (analog_input), \
|
||||
.extref = NRF_ADC_CONFIG_EXTREFSEL_NONE \
|
||||
} \
|
||||
}
|
||||
|
||||
// Forward declaration of the nrfx_adc_channel_t type.
|
||||
typedef struct nrfx_adc_channel_s nrfx_adc_channel_t;
|
||||
|
||||
/**
|
||||
* @brief ADC channel.
|
||||
*
|
||||
* This structure is defined by the user and used by the driver. Therefore, it should
|
||||
* not be defined on the stack as a local variable.
|
||||
*/
|
||||
struct nrfx_adc_channel_s
|
||||
{
|
||||
nrfx_adc_channel_t * p_next; ///< Pointer to the next enabled channel (for internal use).
|
||||
nrf_adc_config_t config; ///< ADC configuration for the current channel.
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief ADC configuration.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t interrupt_priority; ///< Priority of ADC interrupt.
|
||||
} nrfx_adc_config_t;
|
||||
|
||||
/** @brief ADC default configuration. */
|
||||
#define NRFX_ADC_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.interrupt_priority = NRFX_ADC_CONFIG_IRQ_PRIORITY \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief User event handler prototype.
|
||||
*
|
||||
* This function is called when the requested number of samples has been processed.
|
||||
*
|
||||
* @param p_event Event.
|
||||
*/
|
||||
typedef void (*nrfx_adc_event_handler_t)(nrfx_adc_evt_t const * p_event);
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the ADC.
|
||||
*
|
||||
* If a valid event handler is provided, the driver is initialized in non-blocking mode.
|
||||
* If event_handler is NULL, the driver works in blocking mode.
|
||||
*
|
||||
* @param[in] p_config Pointer to the structure with initial configuration.
|
||||
* @param[in] event_handler Event handler provided by the user.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If the driver is already initialized.
|
||||
*/
|
||||
nrfx_err_t nrfx_adc_init(nrfx_adc_config_t const * p_config,
|
||||
nrfx_adc_event_handler_t event_handler);
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing the ADC.
|
||||
*
|
||||
* This function stops all ongoing conversions and disables all channels.
|
||||
*/
|
||||
void nrfx_adc_uninit(void);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling an ADC channel.
|
||||
*
|
||||
* This function configures and enables the channel. When @ref nrfx_adc_buffer_convert is
|
||||
* called, all channels that have been enabled with this function are sampled.
|
||||
*
|
||||
* This function can be called only when there is no conversion in progress
|
||||
* (the ADC is not busy).
|
||||
*
|
||||
* @note The channel instance variable @p p_channel is used by the driver as an item
|
||||
* in a list. Therefore, it cannot be an automatic variable that is located on the stack.
|
||||
*/
|
||||
void nrfx_adc_channel_enable(nrfx_adc_channel_t * const p_channel);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling an ADC channel.
|
||||
*
|
||||
* This function can be called only when there is no conversion in progress
|
||||
* (the ADC is not busy).
|
||||
*/
|
||||
void nrfx_adc_channel_disable(nrfx_adc_channel_t * const p_channel);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling all ADC channels.
|
||||
*
|
||||
* This function can be called only when there is no conversion in progress
|
||||
* (the ADC is not busy).
|
||||
*/
|
||||
void nrfx_adc_all_channels_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Function for starting ADC sampling.
|
||||
*
|
||||
* This function triggers single ADC sampling. If more than one channel is enabled, the driver
|
||||
* emulates scanning and all channels are sampled in the order they were enabled.
|
||||
*/
|
||||
void nrfx_adc_sample(void);
|
||||
|
||||
/**
|
||||
* @brief Function for executing a single ADC conversion.
|
||||
*
|
||||
* This function selects the desired input and starts a single conversion. If a valid pointer
|
||||
* is provided for the result, the function blocks until the conversion is completed. Otherwise, the
|
||||
* function returns when the conversion is started, and the result is provided in an event (driver
|
||||
* must be initialized in non-blocking mode, otherwise an assertion will fail). The function will
|
||||
* fail if ADC is busy. The channel does not need to be enabled to perform a single conversion.
|
||||
*
|
||||
* @param[in] p_channel Channel.
|
||||
* @param[out] p_value Pointer to the location where the result should be placed. Unless NULL is
|
||||
* provided, the function is blocking.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If conversion was successful.
|
||||
* @retval NRFX_ERROR_BUSY If the ADC driver is busy.
|
||||
*/
|
||||
nrfx_err_t nrfx_adc_sample_convert(nrfx_adc_channel_t const * const p_channel,
|
||||
nrf_adc_value_t * p_value);
|
||||
|
||||
/**
|
||||
* @brief Function for converting data to the buffer.
|
||||
*
|
||||
* If the driver is initialized in non-blocking mode, this function returns when the first
|
||||
* conversion is set up. When the buffer is filled, the application is notified by the event
|
||||
* handler. If the driver is initialized in blocking mode, the function returns when the buffer is
|
||||
* filled.
|
||||
*
|
||||
* Conversion is done on all enabled channels, but it is not triggered by this
|
||||
* function. This function will prepare the ADC for sampling and then
|
||||
* wait for the SAMPLE task. Sampling can be triggered manually by the @ref
|
||||
* nrfx_adc_sample function or by PPI using the @ref NRF_ADC_TASK_START task.
|
||||
*
|
||||
* @note If more than one channel is enabled, the function emulates scanning, and
|
||||
* a single START task will trigger conversion on all enabled channels. For example:
|
||||
* If 3 channels are enabled and the user requests 6 samples, the completion event
|
||||
* handler will be called after 2 START tasks.
|
||||
*
|
||||
* @note The application must adjust the sampling frequency. The maximum frequency
|
||||
* depends on the sampling timer and the maximum latency of the ADC interrupt. If
|
||||
* an interrupt is not handled before the next sampling is triggered, the sample
|
||||
* will be lost.
|
||||
*
|
||||
* @param[in] buffer Result buffer.
|
||||
* @param[in] size Buffer size in samples.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If conversion was successful.
|
||||
* @retval NRFX_ERROR_BUSY If the driver is busy.
|
||||
*/
|
||||
nrfx_err_t nrfx_adc_buffer_convert(nrf_adc_value_t * buffer, uint16_t size);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the ADC state.
|
||||
*
|
||||
* @retval true If the ADC is busy.
|
||||
* @retval false If the ADC is ready.
|
||||
*/
|
||||
bool nrfx_adc_is_busy(void);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the ADC START task.
|
||||
*
|
||||
* This function is used to get the address of the START task, which can be used to trigger ADC
|
||||
* conversion.
|
||||
*
|
||||
* @return Start task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_adc_start_task_get(void);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_adc_start_task_get(void)
|
||||
{
|
||||
return nrf_adc_task_address_get(NRF_ADC_TASK_START);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void nrfx_adc_irq_handler(void);
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRFX_ADC_H__
|
||||
|
||||
+223
-214
@@ -1,214 +1,223 @@
|
||||
/**
|
||||
* Copyright (c) 2016 - 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 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 holder 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 AND CONTRIBUTORS "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 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 NRFX_CLOCK_H__
|
||||
#define NRFX_CLOCK_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <hal/nrf_clock.h>
|
||||
#include <nrfx_power_clock.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrfx_clock CLOCK driver
|
||||
* @{
|
||||
* @ingroup nrf_clock
|
||||
* @brief CLOCK peripheral driver.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Clock events.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NRFX_CLOCK_EVT_HFCLK_STARTED, ///< HFCLK has been started.
|
||||
NRFX_CLOCK_EVT_LFCLK_STARTED, ///< LFCLK has been started.
|
||||
NRFX_CLOCK_EVT_CTTO, ///< Calibration timeout.
|
||||
NRFX_CLOCK_EVT_CAL_DONE ///< Calibration has been done.
|
||||
} nrfx_clock_evt_type_t;
|
||||
|
||||
/**
|
||||
* @brief Clock event handler.
|
||||
*
|
||||
* @param[in] event Event.
|
||||
*/
|
||||
typedef void (*nrfx_clock_event_handler_t)(nrfx_clock_evt_type_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for initializing internal structures in the nrfx_clock module.
|
||||
*
|
||||
* After initialization, the module is in power off state (clocks are not started).
|
||||
*
|
||||
* @param[in] event_handler Event handler provided by the user.
|
||||
* Must not be NULL.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If the procedure was successful.
|
||||
* @retval NRFX_ERROR_ALREADY_INITIALIZED If the driver was already initialized.
|
||||
*/
|
||||
nrfx_err_t nrfx_clock_init(nrfx_clock_event_handler_t event_handler);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling interrupts in the clock module.
|
||||
*/
|
||||
void nrfx_clock_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling interrupts in the clock module.
|
||||
*/
|
||||
void nrfx_clock_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing the clock module.
|
||||
*/
|
||||
void nrfx_clock_uninit(void);
|
||||
|
||||
/**
|
||||
* @brief Function for starting the LFCLK.
|
||||
*/
|
||||
void nrfx_clock_lfclk_start(void);
|
||||
|
||||
/**
|
||||
* @brief Function for stoping the LFCLK.
|
||||
*/
|
||||
void nrfx_clock_lfclk_stop(void);
|
||||
|
||||
/**
|
||||
* @brief Function for checking the LFCLK state.
|
||||
*
|
||||
* @retval true If the LFCLK is running.
|
||||
* @retval false If the LFCLK is not running.
|
||||
*/
|
||||
__STATIC_INLINE bool nrfx_clock_lfclk_is_running(void);
|
||||
|
||||
/**
|
||||
* @brief Function for starting the high-accuracy source HFCLK.
|
||||
*/
|
||||
void nrfx_clock_hfclk_start(void);
|
||||
|
||||
/**
|
||||
* @brief Function for stoping external high-accuracy source HFCLK.
|
||||
*/
|
||||
void nrfx_clock_hfclk_stop(void);
|
||||
|
||||
/**
|
||||
* @brief Function for checking the HFCLK state.
|
||||
*
|
||||
* @retval true If the HFCLK is running (XTAL source).
|
||||
* @retval false If the HFCLK is not running.
|
||||
*/
|
||||
__STATIC_INLINE bool nrfx_clock_hfclk_is_running(void);
|
||||
|
||||
/**
|
||||
* @brief Function for starting calibration of internal LFCLK.
|
||||
*
|
||||
* This function starts the calibration process. The process cannot be aborted. LFCLK and HFCLK
|
||||
* must be running before this function is called.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If the procedure was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If the low-frequency of high-frequency clock is off.
|
||||
* @retval NRFX_ERROR_BUSY If calibration is in progress.
|
||||
*/
|
||||
nrfx_err_t nrfx_clock_calibration_start(void);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if calibration is in progress.
|
||||
*
|
||||
* This function indicates that the system is in calibration phase.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If the procedure was successful.
|
||||
* @retval NRFX_ERROR_BUSY If calibration is in progress.
|
||||
*/
|
||||
nrfx_err_t nrfx_clock_is_calibrating(void);
|
||||
|
||||
/**
|
||||
* @brief Function for starting calibration timer.
|
||||
* @param interval Time after which the CTTO event and interrupt will be generated (in 0.25 s units).
|
||||
*/
|
||||
void nrfx_clock_calibration_timer_start(uint8_t interval);
|
||||
|
||||
/**
|
||||
* @brief Function for stoping calibration timer.
|
||||
*/
|
||||
void nrfx_clock_calibration_timer_stop(void);
|
||||
|
||||
/**@brief Function for returning a requested task address for the clock driver module.
|
||||
*
|
||||
* @param[in] task One of the peripheral tasks.
|
||||
*
|
||||
* @return Task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_clock_ppi_task_addr(nrf_clock_task_t task);
|
||||
|
||||
/**@brief Function for returning a requested event address for the clock driver module.
|
||||
*
|
||||
* @param[in] event One of the peripheral events.
|
||||
*
|
||||
* @return Event address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_clock_ppi_event_addr(nrf_clock_event_t event);
|
||||
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
__STATIC_INLINE uint32_t nrfx_clock_ppi_task_addr(nrf_clock_task_t task)
|
||||
{
|
||||
return nrf_clock_task_address_get(task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_clock_ppi_event_addr(nrf_clock_event_t event)
|
||||
{
|
||||
return nrf_clock_event_address_get(event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrfx_clock_hfclk_is_running(void)
|
||||
{
|
||||
return nrf_clock_hf_is_running(NRF_CLOCK_HFCLK_HIGH_ACCURACY);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrfx_clock_lfclk_is_running(void)
|
||||
{
|
||||
return nrf_clock_lf_is_running();
|
||||
}
|
||||
#endif //SUPPRESS_INLINE_IMPLEMENTATION
|
||||
|
||||
|
||||
void nrfx_clock_irq_handler(void);
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRFX_CLOCK_H__
|
||||
/**
|
||||
* Copyright (c) 2016 - 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 NRFX_CLOCK_H__
|
||||
#define NRFX_CLOCK_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <hal/nrf_clock.h>
|
||||
#include <nrfx_power_clock.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrfx_clock CLOCK driver
|
||||
* @{
|
||||
* @ingroup nrf_clock
|
||||
* @brief CLOCK peripheral driver.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Clock events.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NRFX_CLOCK_EVT_HFCLK_STARTED, ///< HFCLK has been started.
|
||||
NRFX_CLOCK_EVT_LFCLK_STARTED, ///< LFCLK has been started.
|
||||
NRFX_CLOCK_EVT_CTTO, ///< Calibration timeout.
|
||||
NRFX_CLOCK_EVT_CAL_DONE ///< Calibration has been done.
|
||||
} nrfx_clock_evt_type_t;
|
||||
|
||||
/**
|
||||
* @brief Clock event handler.
|
||||
*
|
||||
* @param[in] event Event.
|
||||
*/
|
||||
typedef void (*nrfx_clock_event_handler_t)(nrfx_clock_evt_type_t event);
|
||||
|
||||
/**
|
||||
* @brief Function for initializing internal structures in the nrfx_clock module.
|
||||
*
|
||||
* After initialization, the module is in power off state (clocks are not started).
|
||||
*
|
||||
* @param[in] event_handler Event handler provided by the user.
|
||||
* Must not be NULL.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If the procedure was successful.
|
||||
* @retval NRFX_ERROR_ALREADY_INITIALIZED If the driver was already initialized.
|
||||
*/
|
||||
nrfx_err_t nrfx_clock_init(nrfx_clock_event_handler_t event_handler);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling interrupts in the clock module.
|
||||
*/
|
||||
void nrfx_clock_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling interrupts in the clock module.
|
||||
*/
|
||||
void nrfx_clock_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing the clock module.
|
||||
*/
|
||||
void nrfx_clock_uninit(void);
|
||||
|
||||
/**
|
||||
* @brief Function for starting the LFCLK.
|
||||
*/
|
||||
void nrfx_clock_lfclk_start(void);
|
||||
|
||||
/**
|
||||
* @brief Function for stoping the LFCLK.
|
||||
*/
|
||||
void nrfx_clock_lfclk_stop(void);
|
||||
|
||||
/**
|
||||
* @brief Function for checking the LFCLK state.
|
||||
*
|
||||
* @retval true If the LFCLK is running.
|
||||
* @retval false If the LFCLK is not running.
|
||||
*/
|
||||
__STATIC_INLINE bool nrfx_clock_lfclk_is_running(void);
|
||||
|
||||
/**
|
||||
* @brief Function for starting the high-accuracy source HFCLK.
|
||||
*/
|
||||
void nrfx_clock_hfclk_start(void);
|
||||
|
||||
/**
|
||||
* @brief Function for stoping external high-accuracy source HFCLK.
|
||||
*/
|
||||
void nrfx_clock_hfclk_stop(void);
|
||||
|
||||
/**
|
||||
* @brief Function for checking the HFCLK state.
|
||||
*
|
||||
* @retval true If the HFCLK is running (XTAL source).
|
||||
* @retval false If the HFCLK is not running.
|
||||
*/
|
||||
__STATIC_INLINE bool nrfx_clock_hfclk_is_running(void);
|
||||
|
||||
/**
|
||||
* @brief Function for starting calibration of internal LFCLK.
|
||||
*
|
||||
* This function starts the calibration process. The process cannot be aborted. LFCLK and HFCLK
|
||||
* must be running before this function is called.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If the procedure was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If the low-frequency of high-frequency clock is off.
|
||||
* @retval NRFX_ERROR_BUSY If calibration is in progress.
|
||||
*/
|
||||
nrfx_err_t nrfx_clock_calibration_start(void);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if calibration is in progress.
|
||||
*
|
||||
* This function indicates that the system is in calibration phase.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If the procedure was successful.
|
||||
* @retval NRFX_ERROR_BUSY If calibration is in progress.
|
||||
*/
|
||||
nrfx_err_t nrfx_clock_is_calibrating(void);
|
||||
|
||||
/**
|
||||
* @brief Function for starting calibration timer.
|
||||
* @param interval Time after which the CTTO event and interrupt will be generated (in 0.25 s units).
|
||||
*/
|
||||
void nrfx_clock_calibration_timer_start(uint8_t interval);
|
||||
|
||||
/**
|
||||
* @brief Function for stoping calibration timer.
|
||||
*/
|
||||
void nrfx_clock_calibration_timer_stop(void);
|
||||
|
||||
/**@brief Function for returning a requested task address for the clock driver module.
|
||||
*
|
||||
* @param[in] task One of the peripheral tasks.
|
||||
*
|
||||
* @return Task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_clock_ppi_task_addr(nrf_clock_task_t task);
|
||||
|
||||
/**@brief Function for returning a requested event address for the clock driver module.
|
||||
*
|
||||
* @param[in] event One of the peripheral events.
|
||||
*
|
||||
* @return Event address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_clock_ppi_event_addr(nrf_clock_event_t event);
|
||||
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
__STATIC_INLINE uint32_t nrfx_clock_ppi_task_addr(nrf_clock_task_t task)
|
||||
{
|
||||
return nrf_clock_task_address_get(task);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t nrfx_clock_ppi_event_addr(nrf_clock_event_t event)
|
||||
{
|
||||
return nrf_clock_event_address_get(event);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrfx_clock_hfclk_is_running(void)
|
||||
{
|
||||
return nrf_clock_hf_is_running(NRF_CLOCK_HFCLK_HIGH_ACCURACY);
|
||||
}
|
||||
|
||||
__STATIC_INLINE bool nrfx_clock_lfclk_is_running(void)
|
||||
{
|
||||
return nrf_clock_lf_is_running();
|
||||
}
|
||||
#endif //SUPPRESS_INLINE_IMPLEMENTATION
|
||||
|
||||
|
||||
void nrfx_clock_irq_handler(void);
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRFX_CLOCK_H__
|
||||
|
||||
+247
-238
@@ -1,238 +1,247 @@
|
||||
/**
|
||||
* Copyright (c) 2015 - 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 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 holder 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 AND CONTRIBUTORS "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 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 NRFX_COMP_H__
|
||||
#define NRFX_COMP_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <hal/nrf_comp.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrfx_comp COMP driver
|
||||
* @{
|
||||
* @ingroup nrf_comp
|
||||
* @brief Comparator (COMP) peripheral driver.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Macro to convert the threshold voltage to an integer value
|
||||
* (needed by the COMP_TH register).
|
||||
*
|
||||
* @param[in] vol Voltage to be changed to COMP_TH register value. This value
|
||||
* must not be smaller than reference voltage divided by 64.
|
||||
* @param[in] ref Reference voltage.
|
||||
*/
|
||||
#define NRFX_VOLTAGE_THRESHOLD_TO_INT(vol, ref) \
|
||||
(uint8_t)(((vol) > ((ref) / 64)) ? (NRFX_ROUNDED_DIV((vol) * 64,(ref)) - 1) : 0)
|
||||
|
||||
/**
|
||||
* @brief COMP event handler function type.
|
||||
* @param[in] event COMP event.
|
||||
*/
|
||||
typedef void (* nrfx_comp_event_handler_t)(nrf_comp_event_t event);
|
||||
|
||||
/** @brief COMP shortcut masks. */
|
||||
typedef enum
|
||||
{
|
||||
NRFX_COMP_SHORT_STOP_AFTER_CROSS_EVT = COMP_SHORTS_CROSS_STOP_Msk, /*!< Shortcut between the CROSS event and the STOP task. */
|
||||
NRFX_COMP_SHORT_STOP_AFTER_UP_EVT = COMP_SHORTS_UP_STOP_Msk, /*!< Shortcut between the UP event and the STOP task. */
|
||||
NRFX_COMP_SHORT_STOP_AFTER_DOWN_EVT = COMP_SHORTS_DOWN_STOP_Msk /*!< Shortcut between the DOWN event and the STOP task. */
|
||||
} nrfx_comp_short_mask_t;
|
||||
|
||||
/** @brief COMP events masks. */
|
||||
typedef enum
|
||||
{
|
||||
NRFX_COMP_EVT_EN_CROSS_MASK = COMP_INTENSET_CROSS_Msk, /*!< CROSS event (generated after VIN+ == VIN-). */
|
||||
NRFX_COMP_EVT_EN_UP_MASK = COMP_INTENSET_UP_Msk, /*!< UP event (generated when VIN+ crosses VIN- while increasing). */
|
||||
NRFX_COMP_EVT_EN_DOWN_MASK = COMP_INTENSET_DOWN_Msk, /*!< DOWN event (generated when VIN+ crosses VIN- while decreasing). */
|
||||
NRFX_COMP_EVT_EN_READY_MASK = COMP_INTENSET_READY_Msk /*!< READY event (generated when the module is ready). */
|
||||
} nrfx_comp_evt_en_mask_t;
|
||||
|
||||
/** @brief COMP configuration. */
|
||||
typedef struct
|
||||
{
|
||||
nrf_comp_ref_t reference; /**< Reference selection. */
|
||||
nrf_comp_ext_ref_t ext_ref; /**< External analog reference selection. */
|
||||
nrf_comp_main_mode_t main_mode; /**< Main operation mode. */
|
||||
nrf_comp_th_t threshold; /**< Structure holding THDOWN and THUP values needed by the COMP_TH register. */
|
||||
nrf_comp_sp_mode_t speed_mode; /**< Speed and power mode. */
|
||||
nrf_comp_hyst_t hyst; /**< Comparator hysteresis.*/
|
||||
#if defined (COMP_ISOURCE_ISOURCE_Msk) || defined (__NRFX_DOXYGEN__)
|
||||
nrf_isource_t isource; /**< Current source selected on analog input. */
|
||||
#endif
|
||||
nrf_comp_input_t input; /**< Input to be monitored. */
|
||||
uint8_t interrupt_priority; /**< Interrupt priority. */
|
||||
} nrfx_comp_config_t;
|
||||
|
||||
/** @brief COMP threshold default configuration. */
|
||||
#define NRFX_COMP_CONFIG_TH \
|
||||
{ \
|
||||
.th_down = NRFX_VOLTAGE_THRESHOLD_TO_INT(0.5, 1.8), \
|
||||
.th_up = NRFX_VOLTAGE_THRESHOLD_TO_INT(1.5, 1.8) \
|
||||
}
|
||||
|
||||
/** @brief COMP driver default configuration including the COMP HAL configuration. */
|
||||
#if defined (COMP_ISOURCE_ISOURCE_Msk) || defined (__NRFX_DOXYGEN__)
|
||||
#define NRFX_COMP_DEFAULT_CONFIG(_input) \
|
||||
{ \
|
||||
.reference = (nrf_comp_ref_t)NRFX_COMP_CONFIG_REF, \
|
||||
.main_mode = (nrf_comp_main_mode_t)NRFX_COMP_CONFIG_MAIN_MODE, \
|
||||
.threshold = NRFX_COMP_CONFIG_TH, \
|
||||
.speed_mode = (nrf_comp_sp_mode_t)NRFX_COMP_CONFIG_SPEED_MODE, \
|
||||
.hyst = (nrf_comp_hyst_t)NRFX_COMP_CONFIG_HYST, \
|
||||
.isource = (nrf_isource_t)NRFX_COMP_CONFIG_ISOURCE, \
|
||||
.input = (nrf_comp_input_t)_input, \
|
||||
.interrupt_priority = NRFX_COMP_CONFIG_IRQ_PRIORITY \
|
||||
}
|
||||
#else
|
||||
#define NRFX_COMP_DEFAULT_CONFIG(_input) \
|
||||
{ \
|
||||
.reference = (nrf_comp_ref_t)NRFX_COMP_CONFIG_REF, \
|
||||
.main_mode = (nrf_comp_main_mode_t)NRFX_COMP_CONFIG_MAIN_MODE, \
|
||||
.threshold = NRFX_COMP_CONFIG_TH, \
|
||||
.speed_mode = (nrf_comp_sp_mode_t)NRFX_COMP_CONFIG_SPEED_MODE, \
|
||||
.hyst = (nrf_comp_hyst_t)NRFX_COMP_CONFIG_HYST, \
|
||||
.input = (nrf_comp_input_t)_input, \
|
||||
.interrupt_priority = NRFX_COMP_CONFIG_IRQ_PRIORITY \
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the COMP driver.
|
||||
*
|
||||
* This function initializes the COMP driver, but does not enable the peripheral or any interrupts.
|
||||
* To start the driver, call the function @ref nrfx_comp_start() after initialization.
|
||||
*
|
||||
* @param[in] p_config Pointer to the structure with initial configuration.
|
||||
* @param[in] event_handler Event handler provided by the user.
|
||||
* Must not be NULL.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If the driver has already been initialized.
|
||||
* @retval NRFX_ERROR_BUSY If the LPCOMP peripheral is already in use.
|
||||
* This is possible only if @ref nrfx_prs module
|
||||
* is enabled.
|
||||
*/
|
||||
nrfx_err_t nrfx_comp_init(nrfx_comp_config_t const * p_config,
|
||||
nrfx_comp_event_handler_t event_handler);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing the COMP driver.
|
||||
*
|
||||
* This function uninitializes the COMP driver. The COMP peripheral and
|
||||
* its interrupts are disabled, and local variables are cleaned. After this call, you must
|
||||
* initialize the driver again by calling nrfx_comp_init() if you want to use it.
|
||||
*
|
||||
* @sa nrfx_comp_stop()
|
||||
*/
|
||||
void nrfx_comp_uninit(void);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the analog input.
|
||||
*
|
||||
* @param[in] psel COMP analog pin selection.
|
||||
*/
|
||||
void nrfx_comp_pin_select(nrf_comp_input_t psel);
|
||||
|
||||
/**
|
||||
* @brief Function for starting the COMP peripheral and interrupts.
|
||||
*
|
||||
* Before calling this function, the driver must be initialized. This function
|
||||
* enables the COMP peripheral and its interrupts.
|
||||
*
|
||||
* @param[in] comp_evt_en_mask Mask of events to be enabled. This parameter should be built as
|
||||
* 'or' of elements from @ref nrfx_comp_evt_en_mask_t.
|
||||
* @param[in] comp_shorts_mask Mask of shorts to be enabled. This parameter should be built as
|
||||
* 'or' of elements from @ref nrfx_comp_short_mask_t.
|
||||
*
|
||||
* @sa nrfx_comp_init()
|
||||
*
|
||||
*/
|
||||
void nrfx_comp_start(uint32_t comp_evt_en_mask, uint32_t comp_shorts_mask);
|
||||
|
||||
/**@brief Function for stopping the COMP peripheral.
|
||||
*
|
||||
* Before calling this function, the driver must be enabled. This function disables the COMP
|
||||
* peripheral and its interrupts.
|
||||
*
|
||||
* @sa nrfx_comp_uninit()
|
||||
*
|
||||
*/
|
||||
void nrfx_comp_stop(void);
|
||||
|
||||
/**
|
||||
* @brief Function for copying the current state of the comparator result to the RESULT register.
|
||||
*
|
||||
* @retval 0 If the input voltage is below the threshold (VIN+ < VIN-).
|
||||
* @retval 1 If the input voltage is above the threshold (VIN+ > VIN-).
|
||||
*/
|
||||
uint32_t nrfx_comp_sample(void);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a COMP task.
|
||||
*
|
||||
* @param[in] task COMP task.
|
||||
*
|
||||
* @return Address of the given COMP task.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_comp_task_address_get(nrf_comp_task_t task)
|
||||
{
|
||||
return (uint32_t)nrf_comp_task_address_get(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a COMP event.
|
||||
*
|
||||
* @param[in] event COMP event.
|
||||
*
|
||||
* @return Address of the given COMP event.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_comp_event_address_get(nrf_comp_event_t event)
|
||||
{
|
||||
return (uint32_t)nrf_comp_event_address_get(event);
|
||||
}
|
||||
|
||||
|
||||
void nrfx_comp_irq_handler(void);
|
||||
|
||||
|
||||
/** @} **/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRFX_COMP_H__
|
||||
/**
|
||||
* Copyright (c) 2015 - 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 NRFX_COMP_H__
|
||||
#define NRFX_COMP_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <hal/nrf_comp.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrfx_comp COMP driver
|
||||
* @{
|
||||
* @ingroup nrf_comp
|
||||
* @brief Comparator (COMP) peripheral driver.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Macro to convert the threshold voltage to an integer value
|
||||
* (needed by the COMP_TH register).
|
||||
*
|
||||
* @param[in] vol Voltage to be changed to COMP_TH register value. This value
|
||||
* must not be smaller than reference voltage divided by 64.
|
||||
* @param[in] ref Reference voltage.
|
||||
*/
|
||||
#define NRFX_VOLTAGE_THRESHOLD_TO_INT(vol, ref) \
|
||||
(uint8_t)(((vol) > ((ref) / 64)) ? (NRFX_ROUNDED_DIV((vol) * 64,(ref)) - 1) : 0)
|
||||
|
||||
/**
|
||||
* @brief COMP event handler function type.
|
||||
* @param[in] event COMP event.
|
||||
*/
|
||||
typedef void (* nrfx_comp_event_handler_t)(nrf_comp_event_t event);
|
||||
|
||||
/** @brief COMP shortcut masks. */
|
||||
typedef enum
|
||||
{
|
||||
NRFX_COMP_SHORT_STOP_AFTER_CROSS_EVT = COMP_SHORTS_CROSS_STOP_Msk, /*!< Shortcut between the CROSS event and the STOP task. */
|
||||
NRFX_COMP_SHORT_STOP_AFTER_UP_EVT = COMP_SHORTS_UP_STOP_Msk, /*!< Shortcut between the UP event and the STOP task. */
|
||||
NRFX_COMP_SHORT_STOP_AFTER_DOWN_EVT = COMP_SHORTS_DOWN_STOP_Msk /*!< Shortcut between the DOWN event and the STOP task. */
|
||||
} nrfx_comp_short_mask_t;
|
||||
|
||||
/** @brief COMP events masks. */
|
||||
typedef enum
|
||||
{
|
||||
NRFX_COMP_EVT_EN_CROSS_MASK = COMP_INTENSET_CROSS_Msk, /*!< CROSS event (generated after VIN+ == VIN-). */
|
||||
NRFX_COMP_EVT_EN_UP_MASK = COMP_INTENSET_UP_Msk, /*!< UP event (generated when VIN+ crosses VIN- while increasing). */
|
||||
NRFX_COMP_EVT_EN_DOWN_MASK = COMP_INTENSET_DOWN_Msk, /*!< DOWN event (generated when VIN+ crosses VIN- while decreasing). */
|
||||
NRFX_COMP_EVT_EN_READY_MASK = COMP_INTENSET_READY_Msk /*!< READY event (generated when the module is ready). */
|
||||
} nrfx_comp_evt_en_mask_t;
|
||||
|
||||
/** @brief COMP configuration. */
|
||||
typedef struct
|
||||
{
|
||||
nrf_comp_ref_t reference; /**< Reference selection. */
|
||||
nrf_comp_ext_ref_t ext_ref; /**< External analog reference selection. */
|
||||
nrf_comp_main_mode_t main_mode; /**< Main operation mode. */
|
||||
nrf_comp_th_t threshold; /**< Structure holding THDOWN and THUP values needed by the COMP_TH register. */
|
||||
nrf_comp_sp_mode_t speed_mode; /**< Speed and power mode. */
|
||||
nrf_comp_hyst_t hyst; /**< Comparator hysteresis.*/
|
||||
#if defined (COMP_ISOURCE_ISOURCE_Msk) || defined (__NRFX_DOXYGEN__)
|
||||
nrf_isource_t isource; /**< Current source selected on analog input. */
|
||||
#endif
|
||||
nrf_comp_input_t input; /**< Input to be monitored. */
|
||||
uint8_t interrupt_priority; /**< Interrupt priority. */
|
||||
} nrfx_comp_config_t;
|
||||
|
||||
/** @brief COMP threshold default configuration. */
|
||||
#define NRFX_COMP_CONFIG_TH \
|
||||
{ \
|
||||
.th_down = NRFX_VOLTAGE_THRESHOLD_TO_INT(0.5, 1.8), \
|
||||
.th_up = NRFX_VOLTAGE_THRESHOLD_TO_INT(1.5, 1.8) \
|
||||
}
|
||||
|
||||
/** @brief COMP driver default configuration including the COMP HAL configuration. */
|
||||
#if defined (COMP_ISOURCE_ISOURCE_Msk) || defined (__NRFX_DOXYGEN__)
|
||||
#define NRFX_COMP_DEFAULT_CONFIG(_input) \
|
||||
{ \
|
||||
.reference = (nrf_comp_ref_t)NRFX_COMP_CONFIG_REF, \
|
||||
.main_mode = (nrf_comp_main_mode_t)NRFX_COMP_CONFIG_MAIN_MODE, \
|
||||
.threshold = NRFX_COMP_CONFIG_TH, \
|
||||
.speed_mode = (nrf_comp_sp_mode_t)NRFX_COMP_CONFIG_SPEED_MODE, \
|
||||
.hyst = (nrf_comp_hyst_t)NRFX_COMP_CONFIG_HYST, \
|
||||
.isource = (nrf_isource_t)NRFX_COMP_CONFIG_ISOURCE, \
|
||||
.input = (nrf_comp_input_t)_input, \
|
||||
.interrupt_priority = NRFX_COMP_CONFIG_IRQ_PRIORITY \
|
||||
}
|
||||
#else
|
||||
#define NRFX_COMP_DEFAULT_CONFIG(_input) \
|
||||
{ \
|
||||
.reference = (nrf_comp_ref_t)NRFX_COMP_CONFIG_REF, \
|
||||
.main_mode = (nrf_comp_main_mode_t)NRFX_COMP_CONFIG_MAIN_MODE, \
|
||||
.threshold = NRFX_COMP_CONFIG_TH, \
|
||||
.speed_mode = (nrf_comp_sp_mode_t)NRFX_COMP_CONFIG_SPEED_MODE, \
|
||||
.hyst = (nrf_comp_hyst_t)NRFX_COMP_CONFIG_HYST, \
|
||||
.input = (nrf_comp_input_t)_input, \
|
||||
.interrupt_priority = NRFX_COMP_CONFIG_IRQ_PRIORITY \
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the COMP driver.
|
||||
*
|
||||
* This function initializes the COMP driver, but does not enable the peripheral or any interrupts.
|
||||
* To start the driver, call the function @ref nrfx_comp_start() after initialization.
|
||||
*
|
||||
* @param[in] p_config Pointer to the structure with initial configuration.
|
||||
* @param[in] event_handler Event handler provided by the user.
|
||||
* Must not be NULL.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If the driver has already been initialized.
|
||||
* @retval NRFX_ERROR_BUSY If the LPCOMP peripheral is already in use.
|
||||
* This is possible only if @ref nrfx_prs module
|
||||
* is enabled.
|
||||
*/
|
||||
nrfx_err_t nrfx_comp_init(nrfx_comp_config_t const * p_config,
|
||||
nrfx_comp_event_handler_t event_handler);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing the COMP driver.
|
||||
*
|
||||
* This function uninitializes the COMP driver. The COMP peripheral and
|
||||
* its interrupts are disabled, and local variables are cleaned. After this call, you must
|
||||
* initialize the driver again by calling nrfx_comp_init() if you want to use it.
|
||||
*
|
||||
* @sa nrfx_comp_stop()
|
||||
*/
|
||||
void nrfx_comp_uninit(void);
|
||||
|
||||
/**
|
||||
* @brief Function for setting the analog input.
|
||||
*
|
||||
* @param[in] psel COMP analog pin selection.
|
||||
*/
|
||||
void nrfx_comp_pin_select(nrf_comp_input_t psel);
|
||||
|
||||
/**
|
||||
* @brief Function for starting the COMP peripheral and interrupts.
|
||||
*
|
||||
* Before calling this function, the driver must be initialized. This function
|
||||
* enables the COMP peripheral and its interrupts.
|
||||
*
|
||||
* @param[in] comp_evt_en_mask Mask of events to be enabled. This parameter should be built as
|
||||
* 'or' of elements from @ref nrfx_comp_evt_en_mask_t.
|
||||
* @param[in] comp_shorts_mask Mask of shorts to be enabled. This parameter should be built as
|
||||
* 'or' of elements from @ref nrfx_comp_short_mask_t.
|
||||
*
|
||||
* @sa nrfx_comp_init()
|
||||
*
|
||||
*/
|
||||
void nrfx_comp_start(uint32_t comp_evt_en_mask, uint32_t comp_shorts_mask);
|
||||
|
||||
/**@brief Function for stopping the COMP peripheral.
|
||||
*
|
||||
* Before calling this function, the driver must be enabled. This function disables the COMP
|
||||
* peripheral and its interrupts.
|
||||
*
|
||||
* @sa nrfx_comp_uninit()
|
||||
*
|
||||
*/
|
||||
void nrfx_comp_stop(void);
|
||||
|
||||
/**
|
||||
* @brief Function for copying the current state of the comparator result to the RESULT register.
|
||||
*
|
||||
* @retval 0 If the input voltage is below the threshold (VIN+ < VIN-).
|
||||
* @retval 1 If the input voltage is above the threshold (VIN+ > VIN-).
|
||||
*/
|
||||
uint32_t nrfx_comp_sample(void);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a COMP task.
|
||||
*
|
||||
* @param[in] task COMP task.
|
||||
*
|
||||
* @return Address of the given COMP task.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_comp_task_address_get(nrf_comp_task_t task)
|
||||
{
|
||||
return (uint32_t)nrf_comp_task_address_get(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a COMP event.
|
||||
*
|
||||
* @param[in] event COMP event.
|
||||
*
|
||||
* @return Address of the given COMP event.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrfx_comp_event_address_get(nrf_comp_event_t event)
|
||||
{
|
||||
return (uint32_t)nrf_comp_event_address_get(event);
|
||||
}
|
||||
|
||||
|
||||
void nrfx_comp_irq_handler(void);
|
||||
|
||||
|
||||
/** @} **/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRFX_COMP_H__
|
||||
|
||||
+423
-414
@@ -1,414 +1,423 @@
|
||||
/**
|
||||
* Copyright (c) 2015 - 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 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 holder 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 AND CONTRIBUTORS "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 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 NRFX_GPIOTE_H__
|
||||
#define NRFX_GPIOTE_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <hal/nrf_gpiote.h>
|
||||
#include <hal/nrf_gpio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrfx_gpiote GPIOTE driver
|
||||
* @{
|
||||
* @ingroup nrf_gpiote
|
||||
* @brief GPIOTE peripheral driver.
|
||||
*/
|
||||
|
||||
/**@brief Input pin configuration. */
|
||||
typedef struct
|
||||
{
|
||||
nrf_gpiote_polarity_t sense; /**< Transition that triggers interrupt. */
|
||||
nrf_gpio_pin_pull_t pull; /**< Pulling mode. */
|
||||
bool is_watcher : 1; /**< True when the input pin is tracking an output pin. */
|
||||
bool hi_accuracy : 1; /**< True when high accuracy (IN_EVENT) is used. */
|
||||
bool skip_gpio_setup : 1; /**< Do not change GPIO configuration */
|
||||
} nrfx_gpiote_in_config_t;
|
||||
|
||||
/**@brief Macro for configuring a pin to use a GPIO IN or PORT EVENT to detect low-to-high transition.
|
||||
* @details Set hi_accu to true to use IN_EVENT. */
|
||||
#define NRFX_GPIOTE_CONFIG_IN_SENSE_LOTOHI(hi_accu) \
|
||||
{ \
|
||||
.is_watcher = false, \
|
||||
.hi_accuracy = hi_accu, \
|
||||
.pull = NRF_GPIO_PIN_NOPULL, \
|
||||
.sense = NRF_GPIOTE_POLARITY_LOTOHI, \
|
||||
}
|
||||
|
||||
/**@brief Macro for configuring a pin to use a GPIO IN or PORT EVENT to detect high-to-low transition.
|
||||
* @details Set hi_accu to true to use IN_EVENT. */
|
||||
#define NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(hi_accu) \
|
||||
{ \
|
||||
.is_watcher = false, \
|
||||
.hi_accuracy = hi_accu, \
|
||||
.pull = NRF_GPIO_PIN_NOPULL, \
|
||||
.sense = NRF_GPIOTE_POLARITY_HITOLO, \
|
||||
}
|
||||
|
||||
/**@brief Macro for configuring a pin to use a GPIO IN or PORT EVENT to detect any change on the pin.
|
||||
* @details Set hi_accu to true to use IN_EVENT.*/
|
||||
#define NRFX_GPIOTE_CONFIG_IN_SENSE_TOGGLE(hi_accu) \
|
||||
{ \
|
||||
.is_watcher = false, \
|
||||
.hi_accuracy = hi_accu, \
|
||||
.pull = NRF_GPIO_PIN_NOPULL, \
|
||||
.sense = NRF_GPIOTE_POLARITY_TOGGLE, \
|
||||
}
|
||||
|
||||
/**@brief Macro for configuring a pin to use a GPIO IN or PORT EVENT to detect low-to-high transition.
|
||||
* @details Set hi_accu to true to use IN_EVENT.
|
||||
* @note This macro prepares configuration that skips GPIO setup. */
|
||||
#define NRFX_GPIOTE_RAW_CONFIG_IN_SENSE_LOTOHI(hi_accu) \
|
||||
{ \
|
||||
.is_watcher = false, \
|
||||
.hi_accuracy = hi_accu, \
|
||||
.pull = NRF_GPIO_PIN_NOPULL, \
|
||||
.sense = NRF_GPIOTE_POLARITY_LOTOHI, \
|
||||
.skip_gpio_setup = true, \
|
||||
}
|
||||
|
||||
/**@brief Macro for configuring a pin to use a GPIO IN or PORT EVENT to detect high-to-low transition.
|
||||
* @details Set hi_accu to true to use IN_EVENT.
|
||||
* @note This macro prepares configuration that skips GPIO setup. */
|
||||
#define NRFX_GPIOTE_RAW_CONFIG_IN_SENSE_HITOLO(hi_accu) \
|
||||
{ \
|
||||
.is_watcher = false, \
|
||||
.hi_accuracy = hi_accu, \
|
||||
.pull = NRF_GPIO_PIN_NOPULL, \
|
||||
.sense = NRF_GPIOTE_POLARITY_HITOLO, \
|
||||
.skip_gpio_setup = true, \
|
||||
}
|
||||
|
||||
/**@brief Macro for configuring a pin to use a GPIO IN or PORT EVENT to detect any change on the pin.
|
||||
* @details Set hi_accu to true to use IN_EVENT.
|
||||
* @note This macro prepares configuration that skips GPIO setup. */
|
||||
#define NRFX_GPIOTE_RAW_CONFIG_IN_SENSE_TOGGLE(hi_accu) \
|
||||
{ \
|
||||
.is_watcher = false, \
|
||||
.hi_accuracy = hi_accu, \
|
||||
.pull = NRF_GPIO_PIN_NOPULL, \
|
||||
.sense = NRF_GPIOTE_POLARITY_TOGGLE, \
|
||||
.skip_gpio_setup = true, \
|
||||
}
|
||||
|
||||
|
||||
/**@brief Output pin configuration. */
|
||||
typedef struct
|
||||
{
|
||||
nrf_gpiote_polarity_t action; /**< Configuration of the pin task. */
|
||||
nrf_gpiote_outinit_t init_state; /**< Initial state of the output pin. */
|
||||
bool task_pin; /**< True if the pin is controlled by a GPIOTE task. */
|
||||
} nrfx_gpiote_out_config_t;
|
||||
|
||||
/**@brief Macro for configuring a pin to use as output. GPIOTE is not used for the pin. */
|
||||
#define NRFX_GPIOTE_CONFIG_OUT_SIMPLE(init_high) \
|
||||
{ \
|
||||
.init_state = init_high ? NRF_GPIOTE_INITIAL_VALUE_HIGH : NRF_GPIOTE_INITIAL_VALUE_LOW, \
|
||||
.task_pin = false, \
|
||||
}
|
||||
|
||||
/**@brief Macro for configuring a pin to use the GPIO OUT TASK to change the state from high to low.
|
||||
* @details The task will clear the pin. Therefore, the pin is set initially. */
|
||||
#define NRFX_GPIOTE_CONFIG_OUT_TASK_LOW \
|
||||
{ \
|
||||
.init_state = NRF_GPIOTE_INITIAL_VALUE_HIGH, \
|
||||
.task_pin = true, \
|
||||
.action = NRF_GPIOTE_POLARITY_HITOLO, \
|
||||
}
|
||||
|
||||
/**@brief Macro for configuring a pin to use the GPIO OUT TASK to change the state from low to high.
|
||||
* @details The task will set the pin. Therefore, the pin is cleared initially. */
|
||||
#define NRFX_GPIOTE_CONFIG_OUT_TASK_HIGH \
|
||||
{ \
|
||||
.init_state = NRF_GPIOTE_INITIAL_VALUE_LOW, \
|
||||
.task_pin = true, \
|
||||
.action = NRF_GPIOTE_POLARITY_LOTOHI, \
|
||||
}
|
||||
|
||||
/**@brief Macro for configuring a pin to use the GPIO OUT TASK to toggle the pin state.
|
||||
* @details The initial pin state must be provided. */
|
||||
#define NRFX_GPIOTE_CONFIG_OUT_TASK_TOGGLE(init_high) \
|
||||
{ \
|
||||
.init_state = init_high ? NRF_GPIOTE_INITIAL_VALUE_HIGH : NRF_GPIOTE_INITIAL_VALUE_LOW, \
|
||||
.task_pin = true, \
|
||||
.action = NRF_GPIOTE_POLARITY_TOGGLE, \
|
||||
}
|
||||
|
||||
/** @brief Pin. */
|
||||
typedef uint32_t nrfx_gpiote_pin_t;
|
||||
|
||||
/**
|
||||
* @brief Pin event handler prototype.
|
||||
*
|
||||
* @param pin Pin that triggered this event.
|
||||
* @param action Action that lead to triggering this event.
|
||||
*/
|
||||
typedef void (*nrfx_gpiote_evt_handler_t)(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action);
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the GPIOTE module.
|
||||
*
|
||||
* @details Only static configuration is supported to prevent the shared
|
||||
* resource being customized by the initiator.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If the driver was already initialized.
|
||||
*/
|
||||
nrfx_err_t nrfx_gpiote_init(void);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the GPIOTE module is initialized.
|
||||
*
|
||||
* @details The GPIOTE module is a shared module. Therefore, you should check if
|
||||
* the module is already initialized and skip initialization if it is.
|
||||
*
|
||||
* @retval true If the module is already initialized.
|
||||
* @retval false If the module is not initialized.
|
||||
*/
|
||||
bool nrfx_gpiote_is_init(void);
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing the GPIOTE module.
|
||||
*/
|
||||
void nrfx_gpiote_uninit(void);
|
||||
|
||||
/**
|
||||
* @brief Function for initializing a GPIOTE output pin.
|
||||
* @details The output pin can be controlled by the CPU or by PPI. The initial
|
||||
* configuration specifies which mode is used. If PPI mode is used, the driver
|
||||
* attempts to allocate one of the available GPIOTE channels. If no channel is
|
||||
* available, an error is returned.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
* @param[in] p_config Initial configuration.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If the driver is not initialized or the pin is already used.
|
||||
* @retval NRFX_ERROR_NO_MEM If no GPIOTE channel is available.
|
||||
*/
|
||||
nrfx_err_t nrfx_gpiote_out_init(nrfx_gpiote_pin_t pin,
|
||||
nrfx_gpiote_out_config_t const * p_config);
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing a GPIOTE output pin.
|
||||
* @details The driver frees the GPIOTE channel if the output pin was using one.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_out_uninit(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for setting a GPIOTE output pin.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_out_set(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing a GPIOTE output pin.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_out_clear(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for toggling a GPIOTE output pin.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_out_toggle(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling a GPIOTE output pin task.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_out_task_enable(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling a GPIOTE output pin task.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_out_task_disable(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a configurable GPIOTE task.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*
|
||||
* @return Address of OUT task.
|
||||
*/
|
||||
uint32_t nrfx_gpiote_out_task_addr_get(nrfx_gpiote_pin_t pin);
|
||||
|
||||
#if defined(GPIOTE_FEATURE_SET_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for getting the address of a configurable GPIOTE task.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*
|
||||
* @return Address of SET task.
|
||||
*/
|
||||
uint32_t nrfx_gpiote_set_task_addr_get(nrfx_gpiote_pin_t pin);
|
||||
#endif // defined(GPIOTE_FEATURE_SET_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
#if defined(GPIOTE_FEATURE_CLR_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for getting the address of a configurable GPIOTE task.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*
|
||||
* @return Address of CLR task.
|
||||
*/
|
||||
uint32_t nrfx_gpiote_clr_task_addr_get(nrfx_gpiote_pin_t pin);
|
||||
#endif // defined(GPIOTE_FEATURE_CLR_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
* @brief Function for initializing a GPIOTE input pin.
|
||||
* @details The input pin can act in two ways:
|
||||
* - lower accuracy but low power (high frequency clock not needed)
|
||||
* - higher accuracy (high frequency clock required)
|
||||
*
|
||||
* The initial configuration specifies which mode is used.
|
||||
* If high-accuracy mode is used, the driver attempts to allocate one
|
||||
* of the available GPIOTE channels. If no channel is
|
||||
* available, an error is returned.
|
||||
* In low accuracy mode SENSE feature is used. In this case only one active pin
|
||||
* can be detected at a time. It can be worked around by setting all of the used
|
||||
* low accuracy pins to toggle mode.
|
||||
* For more information about SENSE functionality, refer to Product Specification.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
* @param[in] p_config Initial configuration.
|
||||
* @param[in] evt_handler User function to be called when the configured transition occurs.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If the driver is not initialized or the pin is already used.
|
||||
* @retval NRFX_ERROR_NO_MEM If no GPIOTE channel is available.
|
||||
*/
|
||||
nrfx_err_t nrfx_gpiote_in_init(nrfx_gpiote_pin_t pin,
|
||||
nrfx_gpiote_in_config_t const * p_config,
|
||||
nrfx_gpiote_evt_handler_t evt_handler);
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing a GPIOTE input pin.
|
||||
* @details The driver frees the GPIOTE channel if the input pin was using one.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_in_uninit(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling sensing of a GPIOTE input pin.
|
||||
*
|
||||
* @details If the input pin is configured as high-accuracy pin, the function
|
||||
* enables an IN_EVENT. Otherwise, the function enables the GPIO sense mechanism.
|
||||
* Note that a PORT event is shared between multiple pins, therefore the
|
||||
* interrupt is always enabled.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
* @param[in] int_enable True to enable the interrupt. Always valid for a high-accuracy pin.
|
||||
*/
|
||||
void nrfx_gpiote_in_event_enable(nrfx_gpiote_pin_t pin, bool int_enable);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling a GPIOTE input pin.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_in_event_disable(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if a GPIOTE input pin is set.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*
|
||||
* @retval true If the input pin is set.
|
||||
* @retval false If the input pin is not set.
|
||||
*/
|
||||
bool nrfx_gpiote_in_is_set(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a GPIOTE input pin event.
|
||||
* @details If the pin is configured to use low-accuracy mode, the address of the PORT event is returned.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
uint32_t nrfx_gpiote_in_event_addr_get(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for forcing a specific state on the pin configured as task.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
* @param[in] state Pin state.
|
||||
*/
|
||||
void nrfx_gpiote_out_task_force(nrfx_gpiote_pin_t pin, uint8_t state);
|
||||
|
||||
/**
|
||||
* @brief Function for triggering the task OUT manually.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_out_task_trigger(nrfx_gpiote_pin_t pin);
|
||||
|
||||
#if defined(GPIOTE_FEATURE_SET_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for triggering the task SET manually.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_set_task_trigger(nrfx_gpiote_pin_t pin);
|
||||
#endif // defined(GPIOTE_FEATURE_SET_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
#if defined(GPIOTE_FEATURE_CLR_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for triggering the task CLR manually.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_clr_task_trigger(nrfx_gpiote_pin_t pin);
|
||||
#endif // defined(GPIOTE_FEATURE_CLR_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
|
||||
void nrfx_gpiote_irq_handler(void);
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRFX_GPIOTE_H__
|
||||
/**
|
||||
* Copyright (c) 2015 - 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 NRFX_GPIOTE_H__
|
||||
#define NRFX_GPIOTE_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <hal/nrf_gpiote.h>
|
||||
#include <hal/nrf_gpio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrfx_gpiote GPIOTE driver
|
||||
* @{
|
||||
* @ingroup nrf_gpiote
|
||||
* @brief GPIOTE peripheral driver.
|
||||
*/
|
||||
|
||||
/**@brief Input pin configuration. */
|
||||
typedef struct
|
||||
{
|
||||
nrf_gpiote_polarity_t sense; /**< Transition that triggers interrupt. */
|
||||
nrf_gpio_pin_pull_t pull; /**< Pulling mode. */
|
||||
bool is_watcher : 1; /**< True when the input pin is tracking an output pin. */
|
||||
bool hi_accuracy : 1; /**< True when high accuracy (IN_EVENT) is used. */
|
||||
bool skip_gpio_setup : 1; /**< Do not change GPIO configuration */
|
||||
} nrfx_gpiote_in_config_t;
|
||||
|
||||
/**@brief Macro for configuring a pin to use a GPIO IN or PORT EVENT to detect low-to-high transition.
|
||||
* @details Set hi_accu to true to use IN_EVENT. */
|
||||
#define NRFX_GPIOTE_CONFIG_IN_SENSE_LOTOHI(hi_accu) \
|
||||
{ \
|
||||
.is_watcher = false, \
|
||||
.hi_accuracy = hi_accu, \
|
||||
.pull = NRF_GPIO_PIN_NOPULL, \
|
||||
.sense = NRF_GPIOTE_POLARITY_LOTOHI, \
|
||||
}
|
||||
|
||||
/**@brief Macro for configuring a pin to use a GPIO IN or PORT EVENT to detect high-to-low transition.
|
||||
* @details Set hi_accu to true to use IN_EVENT. */
|
||||
#define NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(hi_accu) \
|
||||
{ \
|
||||
.is_watcher = false, \
|
||||
.hi_accuracy = hi_accu, \
|
||||
.pull = NRF_GPIO_PIN_NOPULL, \
|
||||
.sense = NRF_GPIOTE_POLARITY_HITOLO, \
|
||||
}
|
||||
|
||||
/**@brief Macro for configuring a pin to use a GPIO IN or PORT EVENT to detect any change on the pin.
|
||||
* @details Set hi_accu to true to use IN_EVENT.*/
|
||||
#define NRFX_GPIOTE_CONFIG_IN_SENSE_TOGGLE(hi_accu) \
|
||||
{ \
|
||||
.is_watcher = false, \
|
||||
.hi_accuracy = hi_accu, \
|
||||
.pull = NRF_GPIO_PIN_NOPULL, \
|
||||
.sense = NRF_GPIOTE_POLARITY_TOGGLE, \
|
||||
}
|
||||
|
||||
/**@brief Macro for configuring a pin to use a GPIO IN or PORT EVENT to detect low-to-high transition.
|
||||
* @details Set hi_accu to true to use IN_EVENT.
|
||||
* @note This macro prepares configuration that skips GPIO setup. */
|
||||
#define NRFX_GPIOTE_RAW_CONFIG_IN_SENSE_LOTOHI(hi_accu) \
|
||||
{ \
|
||||
.is_watcher = false, \
|
||||
.hi_accuracy = hi_accu, \
|
||||
.pull = NRF_GPIO_PIN_NOPULL, \
|
||||
.sense = NRF_GPIOTE_POLARITY_LOTOHI, \
|
||||
.skip_gpio_setup = true, \
|
||||
}
|
||||
|
||||
/**@brief Macro for configuring a pin to use a GPIO IN or PORT EVENT to detect high-to-low transition.
|
||||
* @details Set hi_accu to true to use IN_EVENT.
|
||||
* @note This macro prepares configuration that skips GPIO setup. */
|
||||
#define NRFX_GPIOTE_RAW_CONFIG_IN_SENSE_HITOLO(hi_accu) \
|
||||
{ \
|
||||
.is_watcher = false, \
|
||||
.hi_accuracy = hi_accu, \
|
||||
.pull = NRF_GPIO_PIN_NOPULL, \
|
||||
.sense = NRF_GPIOTE_POLARITY_HITOLO, \
|
||||
.skip_gpio_setup = true, \
|
||||
}
|
||||
|
||||
/**@brief Macro for configuring a pin to use a GPIO IN or PORT EVENT to detect any change on the pin.
|
||||
* @details Set hi_accu to true to use IN_EVENT.
|
||||
* @note This macro prepares configuration that skips GPIO setup. */
|
||||
#define NRFX_GPIOTE_RAW_CONFIG_IN_SENSE_TOGGLE(hi_accu) \
|
||||
{ \
|
||||
.is_watcher = false, \
|
||||
.hi_accuracy = hi_accu, \
|
||||
.pull = NRF_GPIO_PIN_NOPULL, \
|
||||
.sense = NRF_GPIOTE_POLARITY_TOGGLE, \
|
||||
.skip_gpio_setup = true, \
|
||||
}
|
||||
|
||||
|
||||
/**@brief Output pin configuration. */
|
||||
typedef struct
|
||||
{
|
||||
nrf_gpiote_polarity_t action; /**< Configuration of the pin task. */
|
||||
nrf_gpiote_outinit_t init_state; /**< Initial state of the output pin. */
|
||||
bool task_pin; /**< True if the pin is controlled by a GPIOTE task. */
|
||||
} nrfx_gpiote_out_config_t;
|
||||
|
||||
/**@brief Macro for configuring a pin to use as output. GPIOTE is not used for the pin. */
|
||||
#define NRFX_GPIOTE_CONFIG_OUT_SIMPLE(init_high) \
|
||||
{ \
|
||||
.init_state = init_high ? NRF_GPIOTE_INITIAL_VALUE_HIGH : NRF_GPIOTE_INITIAL_VALUE_LOW, \
|
||||
.task_pin = false, \
|
||||
}
|
||||
|
||||
/**@brief Macro for configuring a pin to use the GPIO OUT TASK to change the state from high to low.
|
||||
* @details The task will clear the pin. Therefore, the pin is set initially. */
|
||||
#define NRFX_GPIOTE_CONFIG_OUT_TASK_LOW \
|
||||
{ \
|
||||
.init_state = NRF_GPIOTE_INITIAL_VALUE_HIGH, \
|
||||
.task_pin = true, \
|
||||
.action = NRF_GPIOTE_POLARITY_HITOLO, \
|
||||
}
|
||||
|
||||
/**@brief Macro for configuring a pin to use the GPIO OUT TASK to change the state from low to high.
|
||||
* @details The task will set the pin. Therefore, the pin is cleared initially. */
|
||||
#define NRFX_GPIOTE_CONFIG_OUT_TASK_HIGH \
|
||||
{ \
|
||||
.init_state = NRF_GPIOTE_INITIAL_VALUE_LOW, \
|
||||
.task_pin = true, \
|
||||
.action = NRF_GPIOTE_POLARITY_LOTOHI, \
|
||||
}
|
||||
|
||||
/**@brief Macro for configuring a pin to use the GPIO OUT TASK to toggle the pin state.
|
||||
* @details The initial pin state must be provided. */
|
||||
#define NRFX_GPIOTE_CONFIG_OUT_TASK_TOGGLE(init_high) \
|
||||
{ \
|
||||
.init_state = init_high ? NRF_GPIOTE_INITIAL_VALUE_HIGH : NRF_GPIOTE_INITIAL_VALUE_LOW, \
|
||||
.task_pin = true, \
|
||||
.action = NRF_GPIOTE_POLARITY_TOGGLE, \
|
||||
}
|
||||
|
||||
/** @brief Pin. */
|
||||
typedef uint32_t nrfx_gpiote_pin_t;
|
||||
|
||||
/**
|
||||
* @brief Pin event handler prototype.
|
||||
*
|
||||
* @param pin Pin that triggered this event.
|
||||
* @param action Action that lead to triggering this event.
|
||||
*/
|
||||
typedef void (*nrfx_gpiote_evt_handler_t)(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action);
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the GPIOTE module.
|
||||
*
|
||||
* @details Only static configuration is supported to prevent the shared
|
||||
* resource being customized by the initiator.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If the driver was already initialized.
|
||||
*/
|
||||
nrfx_err_t nrfx_gpiote_init(void);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if the GPIOTE module is initialized.
|
||||
*
|
||||
* @details The GPIOTE module is a shared module. Therefore, you should check if
|
||||
* the module is already initialized and skip initialization if it is.
|
||||
*
|
||||
* @retval true If the module is already initialized.
|
||||
* @retval false If the module is not initialized.
|
||||
*/
|
||||
bool nrfx_gpiote_is_init(void);
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing the GPIOTE module.
|
||||
*/
|
||||
void nrfx_gpiote_uninit(void);
|
||||
|
||||
/**
|
||||
* @brief Function for initializing a GPIOTE output pin.
|
||||
* @details The output pin can be controlled by the CPU or by PPI. The initial
|
||||
* configuration specifies which mode is used. If PPI mode is used, the driver
|
||||
* attempts to allocate one of the available GPIOTE channels. If no channel is
|
||||
* available, an error is returned.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
* @param[in] p_config Initial configuration.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If the driver is not initialized or the pin is already used.
|
||||
* @retval NRFX_ERROR_NO_MEM If no GPIOTE channel is available.
|
||||
*/
|
||||
nrfx_err_t nrfx_gpiote_out_init(nrfx_gpiote_pin_t pin,
|
||||
nrfx_gpiote_out_config_t const * p_config);
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing a GPIOTE output pin.
|
||||
* @details The driver frees the GPIOTE channel if the output pin was using one.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_out_uninit(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for setting a GPIOTE output pin.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_out_set(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for clearing a GPIOTE output pin.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_out_clear(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for toggling a GPIOTE output pin.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_out_toggle(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling a GPIOTE output pin task.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_out_task_enable(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling a GPIOTE output pin task.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_out_task_disable(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a configurable GPIOTE task.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*
|
||||
* @return Address of OUT task.
|
||||
*/
|
||||
uint32_t nrfx_gpiote_out_task_addr_get(nrfx_gpiote_pin_t pin);
|
||||
|
||||
#if defined(GPIOTE_FEATURE_SET_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for getting the address of a configurable GPIOTE task.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*
|
||||
* @return Address of SET task.
|
||||
*/
|
||||
uint32_t nrfx_gpiote_set_task_addr_get(nrfx_gpiote_pin_t pin);
|
||||
#endif // defined(GPIOTE_FEATURE_SET_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
#if defined(GPIOTE_FEATURE_CLR_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for getting the address of a configurable GPIOTE task.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*
|
||||
* @return Address of CLR task.
|
||||
*/
|
||||
uint32_t nrfx_gpiote_clr_task_addr_get(nrfx_gpiote_pin_t pin);
|
||||
#endif // defined(GPIOTE_FEATURE_CLR_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
/**
|
||||
* @brief Function for initializing a GPIOTE input pin.
|
||||
* @details The input pin can act in two ways:
|
||||
* - lower accuracy but low power (high frequency clock not needed)
|
||||
* - higher accuracy (high frequency clock required)
|
||||
*
|
||||
* The initial configuration specifies which mode is used.
|
||||
* If high-accuracy mode is used, the driver attempts to allocate one
|
||||
* of the available GPIOTE channels. If no channel is
|
||||
* available, an error is returned.
|
||||
* In low accuracy mode SENSE feature is used. In this case only one active pin
|
||||
* can be detected at a time. It can be worked around by setting all of the used
|
||||
* low accuracy pins to toggle mode.
|
||||
* For more information about SENSE functionality, refer to Product Specification.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
* @param[in] p_config Initial configuration.
|
||||
* @param[in] evt_handler User function to be called when the configured transition occurs.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If the driver is not initialized or the pin is already used.
|
||||
* @retval NRFX_ERROR_NO_MEM If no GPIOTE channel is available.
|
||||
*/
|
||||
nrfx_err_t nrfx_gpiote_in_init(nrfx_gpiote_pin_t pin,
|
||||
nrfx_gpiote_in_config_t const * p_config,
|
||||
nrfx_gpiote_evt_handler_t evt_handler);
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing a GPIOTE input pin.
|
||||
* @details The driver frees the GPIOTE channel if the input pin was using one.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_in_uninit(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling sensing of a GPIOTE input pin.
|
||||
*
|
||||
* @details If the input pin is configured as high-accuracy pin, the function
|
||||
* enables an IN_EVENT. Otherwise, the function enables the GPIO sense mechanism.
|
||||
* Note that a PORT event is shared between multiple pins, therefore the
|
||||
* interrupt is always enabled.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
* @param[in] int_enable True to enable the interrupt. Always valid for a high-accuracy pin.
|
||||
*/
|
||||
void nrfx_gpiote_in_event_enable(nrfx_gpiote_pin_t pin, bool int_enable);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling a GPIOTE input pin.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_in_event_disable(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for checking if a GPIOTE input pin is set.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*
|
||||
* @retval true If the input pin is set.
|
||||
* @retval false If the input pin is not set.
|
||||
*/
|
||||
bool nrfx_gpiote_in_is_set(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of a GPIOTE input pin event.
|
||||
* @details If the pin is configured to use low-accuracy mode, the address of the PORT event is returned.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
uint32_t nrfx_gpiote_in_event_addr_get(nrfx_gpiote_pin_t pin);
|
||||
|
||||
/**
|
||||
* @brief Function for forcing a specific state on the pin configured as task.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
* @param[in] state Pin state.
|
||||
*/
|
||||
void nrfx_gpiote_out_task_force(nrfx_gpiote_pin_t pin, uint8_t state);
|
||||
|
||||
/**
|
||||
* @brief Function for triggering the task OUT manually.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_out_task_trigger(nrfx_gpiote_pin_t pin);
|
||||
|
||||
#if defined(GPIOTE_FEATURE_SET_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for triggering the task SET manually.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_set_task_trigger(nrfx_gpiote_pin_t pin);
|
||||
#endif // defined(GPIOTE_FEATURE_SET_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
#if defined(GPIOTE_FEATURE_CLR_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
/**
|
||||
* @brief Function for triggering the task CLR manually.
|
||||
*
|
||||
* @param[in] pin Pin.
|
||||
*/
|
||||
void nrfx_gpiote_clr_task_trigger(nrfx_gpiote_pin_t pin);
|
||||
#endif // defined(GPIOTE_FEATURE_CLR_PRESENT) || defined(__NRFX_DOXYGEN__)
|
||||
|
||||
|
||||
void nrfx_gpiote_irq_handler(void);
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRFX_GPIOTE_H__
|
||||
|
||||
+254
-245
@@ -1,245 +1,254 @@
|
||||
/**
|
||||
* Copyright (c) 2015 - 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 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 holder 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 AND CONTRIBUTORS "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 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 NRFX_I2S_H__
|
||||
#define NRFX_I2S_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <hal/nrf_i2s.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrfx_i2s I2S driver
|
||||
* @{
|
||||
* @ingroup nrf_i2s
|
||||
* @brief Inter-IC Sound (I2S) peripheral driver.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief This value can be provided instead of a pin number for the signals
|
||||
* SDOUT, SDIN, and MCK to specify that a given signal is not used
|
||||
* and therefore does not need to be connected to a pin.
|
||||
*/
|
||||
#define NRFX_I2S_PIN_NOT_USED 0xFF
|
||||
|
||||
/** @brief I2S driver configuration structure. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t sck_pin; ///< SCK pin number.
|
||||
uint8_t lrck_pin; ///< LRCK pin number.
|
||||
uint8_t mck_pin; ///< MCK pin number.
|
||||
/**< Optional. Use @ref NRFX_I2S_PIN_NOT_USED
|
||||
* if this signal is not needed. */
|
||||
uint8_t sdout_pin; ///< SDOUT pin number.
|
||||
/**< Optional. Use @ref NRFX_I2S_PIN_NOT_USED
|
||||
* if this signal is not needed. */
|
||||
uint8_t sdin_pin; ///< SDIN pin number.
|
||||
/**< Optional. Use @ref NRFX_I2S_PIN_NOT_USED
|
||||
* if this signal is not needed. */
|
||||
uint8_t irq_priority; ///< Interrupt priority.
|
||||
|
||||
nrf_i2s_mode_t mode; ///< Mode of operation.
|
||||
nrf_i2s_format_t format; ///< Frame format.
|
||||
nrf_i2s_align_t alignment; ///< Alignment of sample within a frame.
|
||||
nrf_i2s_swidth_t sample_width; ///< Sample width.
|
||||
nrf_i2s_channels_t channels; ///< Enabled channels.
|
||||
nrf_i2s_mck_t mck_setup; ///< Master clock setup.
|
||||
nrf_i2s_ratio_t ratio; ///< MCK/LRCK ratio.
|
||||
} nrfx_i2s_config_t;
|
||||
|
||||
/** @brief I2S driver buffers structure. */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t * p_rx_buffer;
|
||||
uint32_t const * p_tx_buffer;
|
||||
} nrfx_i2s_buffers_t;
|
||||
|
||||
/**
|
||||
* @brief I2S driver default configuration.
|
||||
*/
|
||||
#define NRFX_I2S_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.sck_pin = NRFX_I2S_CONFIG_SCK_PIN, \
|
||||
.lrck_pin = NRFX_I2S_CONFIG_LRCK_PIN, \
|
||||
.mck_pin = NRFX_I2S_CONFIG_MCK_PIN, \
|
||||
.sdout_pin = NRFX_I2S_CONFIG_SDOUT_PIN, \
|
||||
.sdin_pin = NRFX_I2S_CONFIG_SDIN_PIN, \
|
||||
.irq_priority = NRFX_I2S_CONFIG_IRQ_PRIORITY, \
|
||||
.mode = (nrf_i2s_mode_t)NRFX_I2S_CONFIG_MASTER, \
|
||||
.format = (nrf_i2s_format_t)NRFX_I2S_CONFIG_FORMAT, \
|
||||
.alignment = (nrf_i2s_align_t)NRFX_I2S_CONFIG_ALIGN, \
|
||||
.sample_width = (nrf_i2s_swidth_t)NRFX_I2S_CONFIG_SWIDTH, \
|
||||
.channels = (nrf_i2s_channels_t)NRFX_I2S_CONFIG_CHANNELS, \
|
||||
.mck_setup = (nrf_i2s_mck_t)NRFX_I2S_CONFIG_MCK_SETUP, \
|
||||
.ratio = (nrf_i2s_ratio_t)NRFX_I2S_CONFIG_RATIO, \
|
||||
}
|
||||
|
||||
|
||||
#define NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED (1UL << 0)
|
||||
/**< The application should provide buffers that are to be used in the next
|
||||
* part of the transfer. A call to @ref nrfx_i2s_next_buffers_set should
|
||||
* be done before the currently used buffers are completely processed
|
||||
* (i.e. the time remaining for supplying the next buffers depends on
|
||||
* the used size of the buffers). */
|
||||
|
||||
/**
|
||||
* @brief I2S driver data handler type.
|
||||
*
|
||||
* A data handling function of this type must be specified during initialization
|
||||
* of the driver. The driver will call this function when it finishes using
|
||||
* buffers passed to it by the application, and when it needs to be provided
|
||||
* with buffers for the next part of the transfer.
|
||||
*
|
||||
* @note The @c p_released pointer passed to this function is temporary and
|
||||
* will be invalid after the function returns, hence it cannot be stored
|
||||
* and used later. If needed, the pointed content (i.e. buffers pointers)
|
||||
* should be copied instead.
|
||||
*
|
||||
* @param[in] p_released Pointer to a structure with pointers to buffers
|
||||
* passed previously to the driver that will no longer
|
||||
* be access by it (they can be now safely released or
|
||||
* used for another purpose, in particular for a next
|
||||
* part of the transfer).
|
||||
* This pointer will be NULL if the application did not
|
||||
* supply the buffers for the next part of the transfer
|
||||
* (via a call to @ref nrfx_i2s_next_buffers_set) since
|
||||
* the previous time the data handler signaled such need.
|
||||
* This means that data corruption occurred (the previous
|
||||
* buffers are used for the second time) and no buffers
|
||||
* can be released at the moment.
|
||||
* Both pointers in this structure are NULL when the
|
||||
* handler is called for the first time after a transfer
|
||||
* is started, because no data has been transferred yet
|
||||
* at this point. In all successive calls the pointers
|
||||
* specify what has been sent (TX) and what has been
|
||||
* received (RX) in the part of transfer that has just
|
||||
* been completed (provided that a given direction is
|
||||
* enabled, see @ref nrfx_i2s_start).
|
||||
* @param[in] status Bit field describing the current status of the transfer.
|
||||
* It can be 0 or a combination of the following flags:
|
||||
* - @ref NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED
|
||||
*/
|
||||
typedef void (* nrfx_i2s_data_handler_t)(nrfx_i2s_buffers_t const * p_released,
|
||||
uint32_t status);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the I2S driver.
|
||||
*
|
||||
* @param[in] p_config Pointer to the structure with initial configuration.
|
||||
* @param[in] handler Data handler provided by the user. Must not be NULL.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If the driver was already initialized.
|
||||
* @retval NRFX_ERROR_INVALID_PARAM If the requested combination of configuration
|
||||
* options is not allowed by the I2S peripheral.
|
||||
*/
|
||||
nrfx_err_t nrfx_i2s_init(nrfx_i2s_config_t const * p_config,
|
||||
nrfx_i2s_data_handler_t handler);
|
||||
|
||||
/** @brief Function for uninitializing the I2S driver. */
|
||||
void nrfx_i2s_uninit(void);
|
||||
|
||||
/**
|
||||
* @brief Function for starting the continuous I2S transfer.
|
||||
*
|
||||
* The I2S data transfer can be performed in one of three modes: RX (reception)
|
||||
* only, TX (transmission) only, or in both directions simultaneously.
|
||||
* The mode is selected by specifying a proper buffer for a given direction
|
||||
* in the call to this function or by passing NULL instead if this direction
|
||||
* should be disabled.
|
||||
*
|
||||
* The length of the buffer (which is a common value for RX and TX if both
|
||||
* directions are enabled) is specified in 32-bit words. One 32-bit memory
|
||||
* word can either contain four 8-bit samples, two 16-bit samples, or one
|
||||
* right-aligned 24-bit sample sign-extended to a 32-bit value.
|
||||
* For a detailed memory mapping for different supported configurations,
|
||||
* see the @linkProductSpecification52.
|
||||
*
|
||||
* @note Peripherals using EasyDMA (including I2S) require the transfer buffers
|
||||
* to be placed in the Data RAM region. If this condition is not met,
|
||||
* this function will fail with the error code NRFX_ERROR_INVALID_ADDR.
|
||||
*
|
||||
* @param[in] p_initial_buffers Pointer to a structure specifying the buffers
|
||||
* to be used in the initial part of the transfer
|
||||
* (buffers for all consecutive parts are provided
|
||||
* through the data handler).
|
||||
* @param[in] buffer_size Size of the buffers (in 32-bit words).
|
||||
* Must not be 0.
|
||||
* @param[in] flags Transfer options (0 for default settings).
|
||||
* Currently, no additional flags are available.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If the operation was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If a transfer was already started or
|
||||
* the driver has not been initialized.
|
||||
* @retval NRFX_ERROR_INVALID_ADDR If the provided buffers are not placed
|
||||
* in the Data RAM region.
|
||||
*/
|
||||
nrfx_err_t nrfx_i2s_start(nrfx_i2s_buffers_t const * p_initial_buffers,
|
||||
uint16_t buffer_size,
|
||||
uint8_t flags);
|
||||
|
||||
/**
|
||||
* @brief Function for supplying the buffers to be used in the next part of
|
||||
* the transfer.
|
||||
*
|
||||
* The application should call this function when the data handler receives
|
||||
* @ref NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED in the @c status parameter.
|
||||
* The call can be done immediately from the data handler function or later,
|
||||
* but it has to be done before the I2S peripheral finishes processing the
|
||||
* buffers supplied previously. Otherwise, data corruption will occur.
|
||||
*
|
||||
* @sa nrfx_i2s_data_handler_t
|
||||
*
|
||||
* @retval NRFX_SUCCESS If the operation was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If the buffers were already supplied or
|
||||
* the peripheral is currently being stopped.
|
||||
*/
|
||||
nrfx_err_t nrfx_i2s_next_buffers_set(nrfx_i2s_buffers_t const * p_buffers);
|
||||
|
||||
/** @brief Function for stopping the I2S transfer. */
|
||||
void nrfx_i2s_stop(void);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
void nrfx_i2s_irq_handler(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRFX_I2S_H__
|
||||
/**
|
||||
* Copyright (c) 2015 - 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 NRFX_I2S_H__
|
||||
#define NRFX_I2S_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <hal/nrf_i2s.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrfx_i2s I2S driver
|
||||
* @{
|
||||
* @ingroup nrf_i2s
|
||||
* @brief Inter-IC Sound (I2S) peripheral driver.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief This value can be provided instead of a pin number for the signals
|
||||
* SDOUT, SDIN, and MCK to specify that a given signal is not used
|
||||
* and therefore does not need to be connected to a pin.
|
||||
*/
|
||||
#define NRFX_I2S_PIN_NOT_USED 0xFF
|
||||
|
||||
/** @brief I2S driver configuration structure. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t sck_pin; ///< SCK pin number.
|
||||
uint8_t lrck_pin; ///< LRCK pin number.
|
||||
uint8_t mck_pin; ///< MCK pin number.
|
||||
/**< Optional. Use @ref NRFX_I2S_PIN_NOT_USED
|
||||
* if this signal is not needed. */
|
||||
uint8_t sdout_pin; ///< SDOUT pin number.
|
||||
/**< Optional. Use @ref NRFX_I2S_PIN_NOT_USED
|
||||
* if this signal is not needed. */
|
||||
uint8_t sdin_pin; ///< SDIN pin number.
|
||||
/**< Optional. Use @ref NRFX_I2S_PIN_NOT_USED
|
||||
* if this signal is not needed. */
|
||||
uint8_t irq_priority; ///< Interrupt priority.
|
||||
|
||||
nrf_i2s_mode_t mode; ///< Mode of operation.
|
||||
nrf_i2s_format_t format; ///< Frame format.
|
||||
nrf_i2s_align_t alignment; ///< Alignment of sample within a frame.
|
||||
nrf_i2s_swidth_t sample_width; ///< Sample width.
|
||||
nrf_i2s_channels_t channels; ///< Enabled channels.
|
||||
nrf_i2s_mck_t mck_setup; ///< Master clock setup.
|
||||
nrf_i2s_ratio_t ratio; ///< MCK/LRCK ratio.
|
||||
} nrfx_i2s_config_t;
|
||||
|
||||
/** @brief I2S driver buffers structure. */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t * p_rx_buffer;
|
||||
uint32_t const * p_tx_buffer;
|
||||
} nrfx_i2s_buffers_t;
|
||||
|
||||
/**
|
||||
* @brief I2S driver default configuration.
|
||||
*/
|
||||
#define NRFX_I2S_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.sck_pin = NRFX_I2S_CONFIG_SCK_PIN, \
|
||||
.lrck_pin = NRFX_I2S_CONFIG_LRCK_PIN, \
|
||||
.mck_pin = NRFX_I2S_CONFIG_MCK_PIN, \
|
||||
.sdout_pin = NRFX_I2S_CONFIG_SDOUT_PIN, \
|
||||
.sdin_pin = NRFX_I2S_CONFIG_SDIN_PIN, \
|
||||
.irq_priority = NRFX_I2S_CONFIG_IRQ_PRIORITY, \
|
||||
.mode = (nrf_i2s_mode_t)NRFX_I2S_CONFIG_MASTER, \
|
||||
.format = (nrf_i2s_format_t)NRFX_I2S_CONFIG_FORMAT, \
|
||||
.alignment = (nrf_i2s_align_t)NRFX_I2S_CONFIG_ALIGN, \
|
||||
.sample_width = (nrf_i2s_swidth_t)NRFX_I2S_CONFIG_SWIDTH, \
|
||||
.channels = (nrf_i2s_channels_t)NRFX_I2S_CONFIG_CHANNELS, \
|
||||
.mck_setup = (nrf_i2s_mck_t)NRFX_I2S_CONFIG_MCK_SETUP, \
|
||||
.ratio = (nrf_i2s_ratio_t)NRFX_I2S_CONFIG_RATIO, \
|
||||
}
|
||||
|
||||
|
||||
#define NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED (1UL << 0)
|
||||
/**< The application should provide buffers that are to be used in the next
|
||||
* part of the transfer. A call to @ref nrfx_i2s_next_buffers_set should
|
||||
* be done before the currently used buffers are completely processed
|
||||
* (i.e. the time remaining for supplying the next buffers depends on
|
||||
* the used size of the buffers). */
|
||||
|
||||
/**
|
||||
* @brief I2S driver data handler type.
|
||||
*
|
||||
* A data handling function of this type must be specified during initialization
|
||||
* of the driver. The driver will call this function when it finishes using
|
||||
* buffers passed to it by the application, and when it needs to be provided
|
||||
* with buffers for the next part of the transfer.
|
||||
*
|
||||
* @note The @c p_released pointer passed to this function is temporary and
|
||||
* will be invalid after the function returns, hence it cannot be stored
|
||||
* and used later. If needed, the pointed content (i.e. buffers pointers)
|
||||
* should be copied instead.
|
||||
*
|
||||
* @param[in] p_released Pointer to a structure with pointers to buffers
|
||||
* passed previously to the driver that will no longer
|
||||
* be access by it (they can be now safely released or
|
||||
* used for another purpose, in particular for a next
|
||||
* part of the transfer).
|
||||
* This pointer will be NULL if the application did not
|
||||
* supply the buffers for the next part of the transfer
|
||||
* (via a call to @ref nrfx_i2s_next_buffers_set) since
|
||||
* the previous time the data handler signaled such need.
|
||||
* This means that data corruption occurred (the previous
|
||||
* buffers are used for the second time) and no buffers
|
||||
* can be released at the moment.
|
||||
* Both pointers in this structure are NULL when the
|
||||
* handler is called for the first time after a transfer
|
||||
* is started, because no data has been transferred yet
|
||||
* at this point. In all successive calls the pointers
|
||||
* specify what has been sent (TX) and what has been
|
||||
* received (RX) in the part of transfer that has just
|
||||
* been completed (provided that a given direction is
|
||||
* enabled, see @ref nrfx_i2s_start).
|
||||
* @param[in] status Bit field describing the current status of the transfer.
|
||||
* It can be 0 or a combination of the following flags:
|
||||
* - @ref NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED
|
||||
*/
|
||||
typedef void (* nrfx_i2s_data_handler_t)(nrfx_i2s_buffers_t const * p_released,
|
||||
uint32_t status);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the I2S driver.
|
||||
*
|
||||
* @param[in] p_config Pointer to the structure with initial configuration.
|
||||
* @param[in] handler Data handler provided by the user. Must not be NULL.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If the driver was already initialized.
|
||||
* @retval NRFX_ERROR_INVALID_PARAM If the requested combination of configuration
|
||||
* options is not allowed by the I2S peripheral.
|
||||
*/
|
||||
nrfx_err_t nrfx_i2s_init(nrfx_i2s_config_t const * p_config,
|
||||
nrfx_i2s_data_handler_t handler);
|
||||
|
||||
/** @brief Function for uninitializing the I2S driver. */
|
||||
void nrfx_i2s_uninit(void);
|
||||
|
||||
/**
|
||||
* @brief Function for starting the continuous I2S transfer.
|
||||
*
|
||||
* The I2S data transfer can be performed in one of three modes: RX (reception)
|
||||
* only, TX (transmission) only, or in both directions simultaneously.
|
||||
* The mode is selected by specifying a proper buffer for a given direction
|
||||
* in the call to this function or by passing NULL instead if this direction
|
||||
* should be disabled.
|
||||
*
|
||||
* The length of the buffer (which is a common value for RX and TX if both
|
||||
* directions are enabled) is specified in 32-bit words. One 32-bit memory
|
||||
* word can either contain four 8-bit samples, two 16-bit samples, or one
|
||||
* right-aligned 24-bit sample sign-extended to a 32-bit value.
|
||||
* For a detailed memory mapping for different supported configurations,
|
||||
* see the @linkProductSpecification52.
|
||||
*
|
||||
* @note Peripherals using EasyDMA (including I2S) require the transfer buffers
|
||||
* to be placed in the Data RAM region. If this condition is not met,
|
||||
* this function will fail with the error code NRFX_ERROR_INVALID_ADDR.
|
||||
*
|
||||
* @param[in] p_initial_buffers Pointer to a structure specifying the buffers
|
||||
* to be used in the initial part of the transfer
|
||||
* (buffers for all consecutive parts are provided
|
||||
* through the data handler).
|
||||
* @param[in] buffer_size Size of the buffers (in 32-bit words).
|
||||
* Must not be 0.
|
||||
* @param[in] flags Transfer options (0 for default settings).
|
||||
* Currently, no additional flags are available.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If the operation was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If a transfer was already started or
|
||||
* the driver has not been initialized.
|
||||
* @retval NRFX_ERROR_INVALID_ADDR If the provided buffers are not placed
|
||||
* in the Data RAM region.
|
||||
*/
|
||||
nrfx_err_t nrfx_i2s_start(nrfx_i2s_buffers_t const * p_initial_buffers,
|
||||
uint16_t buffer_size,
|
||||
uint8_t flags);
|
||||
|
||||
/**
|
||||
* @brief Function for supplying the buffers to be used in the next part of
|
||||
* the transfer.
|
||||
*
|
||||
* The application should call this function when the data handler receives
|
||||
* @ref NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED in the @c status parameter.
|
||||
* The call can be done immediately from the data handler function or later,
|
||||
* but it has to be done before the I2S peripheral finishes processing the
|
||||
* buffers supplied previously. Otherwise, data corruption will occur.
|
||||
*
|
||||
* @sa nrfx_i2s_data_handler_t
|
||||
*
|
||||
* @retval NRFX_SUCCESS If the operation was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If the buffers were already supplied or
|
||||
* the peripheral is currently being stopped.
|
||||
*/
|
||||
nrfx_err_t nrfx_i2s_next_buffers_set(nrfx_i2s_buffers_t const * p_buffers);
|
||||
|
||||
/** @brief Function for stopping the I2S transfer. */
|
||||
void nrfx_i2s_stop(void);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
void nrfx_i2s_irq_handler(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRFX_I2S_H__
|
||||
|
||||
+150
-141
@@ -1,141 +1,150 @@
|
||||
/**
|
||||
* Copyright (c) 2014 - 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 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 holder 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 AND CONTRIBUTORS "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 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 NRFX_LPCOMP_H__
|
||||
#define NRFX_LPCOMP_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <hal/nrf_lpcomp.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrfx_lpcomp LPCOMP driver
|
||||
* @{
|
||||
* @ingroup nrf_lpcomp
|
||||
* @brief Low Power Comparator (LPCOMP) peripheral driver.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief LPCOMP event handler function type.
|
||||
* @param[in] event LPCOMP event.
|
||||
*/
|
||||
typedef void (* nrfx_lpcomp_event_handler_t)(nrf_lpcomp_event_t event);
|
||||
|
||||
/** @brief LPCOMP configuration. */
|
||||
typedef struct
|
||||
{
|
||||
nrf_lpcomp_config_t hal; /**< LPCOMP HAL configuration. */
|
||||
nrf_lpcomp_input_t input; /**< Input to be monitored. */
|
||||
uint8_t interrupt_priority; /**< LPCOMP interrupt priority. */
|
||||
} nrfx_lpcomp_config_t;
|
||||
|
||||
/** @brief LPCOMP driver default configuration including the LPCOMP HAL configuration. */
|
||||
#ifdef NRF52_SERIES
|
||||
#define NRFX_LPCOMP_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.hal = { (nrf_lpcomp_ref_t)NRFX_LPCOMP_CONFIG_REFERENCE , \
|
||||
(nrf_lpcomp_detect_t)NRFX_LPCOMP_CONFIG_DETECTION, \
|
||||
(nrf_lpcomp_hysteresis_t)NRFX_LPCOMP_CONFIG_HYST }, \
|
||||
.input = (nrf_lpcomp_input_t)NRFX_LPCOMP_CONFIG_INPUT, \
|
||||
.interrupt_priority = NRFX_LPCOMP_CONFIG_IRQ_PRIORITY \
|
||||
}
|
||||
#else
|
||||
#define NRFX_LPCOMP_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.hal = { (nrf_lpcomp_ref_t)NRFX_LPCOMP_CONFIG_REFERENCE , \
|
||||
(nrf_lpcomp_detect_t)NRFX_LPCOMP_CONFIG_DETECTION }, \
|
||||
.input = (nrf_lpcomp_input_t)NRFX_LPCOMP_CONFIG_INPUT, \
|
||||
.interrupt_priority = NRFX_LPCOMP_CONFIG_IRQ_PRIORITY \
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the LPCOMP driver.
|
||||
*
|
||||
* This function initializes the LPCOMP driver, but does not enable the peripheral or any interrupts.
|
||||
* To start the driver, call the function nrfx_lpcomp_enable() after initialization.
|
||||
*
|
||||
* @param[in] p_config Pointer to the structure with initial configuration.
|
||||
* @param[in] event_handler Event handler provided by the user.
|
||||
* Must not be NULL.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If the driver has already been initialized.
|
||||
* @retval NRFX_ERROR_BUSY If the COMP peripheral is already in use.
|
||||
* This is possible only if @ref nrfx_prs module
|
||||
* is enabled.
|
||||
*/
|
||||
nrfx_err_t nrfx_lpcomp_init(nrfx_lpcomp_config_t const * p_config,
|
||||
nrfx_lpcomp_event_handler_t event_handler);
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing the LCOMP driver.
|
||||
*
|
||||
* This function uninitializes the LPCOMP driver. The LPCOMP peripheral and
|
||||
* its interrupts are disabled, and local variables are cleaned. After this call, you must
|
||||
* initialize the driver again by calling nrfx_lpcomp_init() if you want to use it.
|
||||
*
|
||||
* @sa nrfx_lpcomp_disable()
|
||||
* @sa nrfx_lpcomp_init()
|
||||
*/
|
||||
void nrfx_lpcomp_uninit(void);
|
||||
|
||||
/**@brief Function for enabling the LPCOMP peripheral and interrupts.
|
||||
*
|
||||
* Before calling this function, the driver must be initialized. This function
|
||||
* enables the LPCOMP peripheral and its interrupts.
|
||||
*
|
||||
* @sa nrfx_lpcomp_disable()
|
||||
*/
|
||||
void nrfx_lpcomp_enable(void);
|
||||
|
||||
/**@brief Function for disabling the LPCOMP peripheral.
|
||||
*
|
||||
* Before calling this function, the driver must be initialized. This function disables the LPCOMP
|
||||
* peripheral and its interrupts.
|
||||
*
|
||||
* @sa nrfx_lpcomp_enable()
|
||||
*/
|
||||
void nrfx_lpcomp_disable(void);
|
||||
|
||||
|
||||
void nrfx_lpcomp_irq_handler(void);
|
||||
|
||||
/** @} **/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRFX_LPCOMP_H__
|
||||
/**
|
||||
* Copyright (c) 2014 - 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 NRFX_LPCOMP_H__
|
||||
#define NRFX_LPCOMP_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <hal/nrf_lpcomp.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrfx_lpcomp LPCOMP driver
|
||||
* @{
|
||||
* @ingroup nrf_lpcomp
|
||||
* @brief Low Power Comparator (LPCOMP) peripheral driver.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief LPCOMP event handler function type.
|
||||
* @param[in] event LPCOMP event.
|
||||
*/
|
||||
typedef void (* nrfx_lpcomp_event_handler_t)(nrf_lpcomp_event_t event);
|
||||
|
||||
/** @brief LPCOMP configuration. */
|
||||
typedef struct
|
||||
{
|
||||
nrf_lpcomp_config_t hal; /**< LPCOMP HAL configuration. */
|
||||
nrf_lpcomp_input_t input; /**< Input to be monitored. */
|
||||
uint8_t interrupt_priority; /**< LPCOMP interrupt priority. */
|
||||
} nrfx_lpcomp_config_t;
|
||||
|
||||
/** @brief LPCOMP driver default configuration including the LPCOMP HAL configuration. */
|
||||
#ifdef NRF52_SERIES
|
||||
#define NRFX_LPCOMP_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.hal = { (nrf_lpcomp_ref_t)NRFX_LPCOMP_CONFIG_REFERENCE , \
|
||||
(nrf_lpcomp_detect_t)NRFX_LPCOMP_CONFIG_DETECTION, \
|
||||
(nrf_lpcomp_hysteresis_t)NRFX_LPCOMP_CONFIG_HYST }, \
|
||||
.input = (nrf_lpcomp_input_t)NRFX_LPCOMP_CONFIG_INPUT, \
|
||||
.interrupt_priority = NRFX_LPCOMP_CONFIG_IRQ_PRIORITY \
|
||||
}
|
||||
#else
|
||||
#define NRFX_LPCOMP_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.hal = { (nrf_lpcomp_ref_t)NRFX_LPCOMP_CONFIG_REFERENCE , \
|
||||
(nrf_lpcomp_detect_t)NRFX_LPCOMP_CONFIG_DETECTION }, \
|
||||
.input = (nrf_lpcomp_input_t)NRFX_LPCOMP_CONFIG_INPUT, \
|
||||
.interrupt_priority = NRFX_LPCOMP_CONFIG_IRQ_PRIORITY \
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the LPCOMP driver.
|
||||
*
|
||||
* This function initializes the LPCOMP driver, but does not enable the peripheral or any interrupts.
|
||||
* To start the driver, call the function nrfx_lpcomp_enable() after initialization.
|
||||
*
|
||||
* @param[in] p_config Pointer to the structure with initial configuration.
|
||||
* @param[in] event_handler Event handler provided by the user.
|
||||
* Must not be NULL.
|
||||
*
|
||||
* @retval NRFX_SUCCESS If initialization was successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE If the driver has already been initialized.
|
||||
* @retval NRFX_ERROR_BUSY If the COMP peripheral is already in use.
|
||||
* This is possible only if @ref nrfx_prs module
|
||||
* is enabled.
|
||||
*/
|
||||
nrfx_err_t nrfx_lpcomp_init(nrfx_lpcomp_config_t const * p_config,
|
||||
nrfx_lpcomp_event_handler_t event_handler);
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing the LCOMP driver.
|
||||
*
|
||||
* This function uninitializes the LPCOMP driver. The LPCOMP peripheral and
|
||||
* its interrupts are disabled, and local variables are cleaned. After this call, you must
|
||||
* initialize the driver again by calling nrfx_lpcomp_init() if you want to use it.
|
||||
*
|
||||
* @sa nrfx_lpcomp_disable()
|
||||
* @sa nrfx_lpcomp_init()
|
||||
*/
|
||||
void nrfx_lpcomp_uninit(void);
|
||||
|
||||
/**@brief Function for enabling the LPCOMP peripheral and interrupts.
|
||||
*
|
||||
* Before calling this function, the driver must be initialized. This function
|
||||
* enables the LPCOMP peripheral and its interrupts.
|
||||
*
|
||||
* @sa nrfx_lpcomp_disable()
|
||||
*/
|
||||
void nrfx_lpcomp_enable(void);
|
||||
|
||||
/**@brief Function for disabling the LPCOMP peripheral.
|
||||
*
|
||||
* Before calling this function, the driver must be initialized. This function disables the LPCOMP
|
||||
* peripheral and its interrupts.
|
||||
*
|
||||
* @sa nrfx_lpcomp_enable()
|
||||
*/
|
||||
void nrfx_lpcomp_disable(void);
|
||||
|
||||
|
||||
void nrfx_lpcomp_irq_handler(void);
|
||||
|
||||
/** @} **/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRFX_LPCOMP_H__
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user