http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/nordic_common.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/nordic_common.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/nordic_common.h deleted file mode 100644 index b0f8290..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/nordic_common.h +++ /dev/null @@ -1,116 +0,0 @@ -/* Copyright (c) 2008 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is property of Nordic Semiconductor ASA. - * Terms and conditions of usage are described in detail in NORDIC - * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. - * - * Licensees are granted free, non-transferable use of the information. NO - * WARRANTY of ANY KIND is provided. This heading must NOT be removed from - * the file. - */ - -/** @file - * @brief Common defines and macros for firmware developed by Nordic Semiconductor. - */ - -#ifndef NORDIC_COMMON_H__ -#define NORDIC_COMMON_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/** The upper 8 bits of a 32 bit value */ -//lint -emacro(572,MSB) // Suppress warning 572 "Excessive shift value" -#define MSB_32(a) (((a) & 0xFF000000) >> 24) -/** The lower 8 bits (of a 32 bit value) */ -#define LSB_32(a) ((a) & 0x000000FF) - -/** The upper 8 bits of a 16 bit value */ -//lint -emacro(572,MSB_16) // Suppress warning 572 "Excessive shift value" -#define MSB_16(a) (((a) & 0xFF00) >> 8) -/** The lower 8 bits (of a 16 bit value) */ -#define LSB_16(a) ((a) & 0x00FF) - -/** Leaves the minimum of the two 32-bit arguments */ -/*lint -emacro(506, MIN) */ /* Suppress "Constant value Boolean */ -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -/** Leaves the maximum of the two 32-bit arguments */ -/*lint -emacro(506, MAX) */ /* Suppress "Constant value Boolean */ -#define MAX(a, b) ((a) < (b) ? (b) : (a)) - -/** Concatenates two parameters. Useful as a second level of indirection, - * when a parameter can be macro itself. */ -#define CONCAT_2(p1, p2) p1##p2 -/** Concatenates three parameters. Useful as a second level of indirection, - * when a parameter can be macro itself. */ -#define CONCAT_3(p1, p2, p3) p1##p2##p3 - -/**@brief Set a bit in the uint32 word. - * - * @param[in] W Word whose bit is being set. - * @param[in] B Bit number in the word to be set. - */ -#define SET_BIT(W,B) ((W) |= (uint32_t)(1U << (B))) - - -/**@brief Clears a bit in the uint32 word. - * - * @param[in] W Word whose bit is to be cleared. - * @param[in] B Bit number in the word to be cleared. - */ -#define CLR_BIT(W, B) ((W) &= (~((uint32_t)1 << (B)))) - - -/**@brief Checks if a bit is set. - * - * @param[in] W Word whose bit is to be checked. - * @param[in] B Bit number in the word to be checked. - * - * @retval 1 if bit is set. - * @retval 0 if bit is not set. - */ -#define IS_SET(W,B) (((W) >> (B)) & 1) - -#define BIT_0 0x01 /**< The value of bit 0 */ -#define BIT_1 0x02 /**< The value of bit 1 */ -#define BIT_2 0x04 /**< The value of bit 2 */ -#define BIT_3 0x08 /**< The value of bit 3 */ -#define BIT_4 0x10 /**< The value of bit 4 */ -#define BIT_5 0x20 /**< The value of bit 5 */ -#define BIT_6 0x40 /**< The value of bit 6 */ -#define BIT_7 0x80 /**< The value of bit 7 */ -#define BIT_8 0x0100 /**< The value of bit 8 */ -#define BIT_9 0x0200 /**< The value of bit 9 */ -#define BIT_10 0x0400 /**< The value of bit 10 */ -#define BIT_11 0x0800 /**< The value of bit 11 */ -#define BIT_12 0x1000 /**< The value of bit 12 */ -#define BIT_13 0x2000 /**< The value of bit 13 */ -#define BIT_14 0x4000 /**< The value of bit 14 */ -#define BIT_15 0x8000 /**< The value of bit 15 */ -#define BIT_16 0x00010000 /**< The value of bit 16 */ -#define BIT_17 0x00020000 /**< The value of bit 17 */ -#define BIT_18 0x00040000 /**< The value of bit 18 */ -#define BIT_19 0x00080000 /**< The value of bit 19 */ -#define BIT_20 0x00100000 /**< The value of bit 20 */ -#define BIT_21 0x00200000 /**< The value of bit 21 */ -#define BIT_22 0x00400000 /**< The value of bit 22 */ -#define BIT_23 0x00800000 /**< The value of bit 23 */ -#define BIT_24 0x01000000 /**< The value of bit 24 */ -#define BIT_25 0x02000000 /**< The value of bit 25 */ -#define BIT_26 0x04000000 /**< The value of bit 26 */ -#define BIT_27 0x08000000 /**< The value of bit 27 */ -#define BIT_28 0x10000000 /**< The value of bit 28 */ -#define BIT_29 0x20000000 /**< The value of bit 29 */ -#define BIT_30 0x40000000 /**< The value of bit 30 */ -#define BIT_31 0x80000000 /**< The value of bit 31 */ - -#define UNUSED_VARIABLE(X) ((void)(X)) -#define UNUSED_PARAMETER(X) UNUSED_VARIABLE(X) -#define UNUSED_RETURN_VALUE(X) UNUSED_VARIABLE(X) - -#ifdef __cplusplus -} -#endif - -#endif // NORDIC_COMMON_H__
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/nrf_assert.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/nrf_assert.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/nrf_assert.c deleted file mode 100644 index 3596565..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/nrf_assert.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2006 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is property of Nordic Semiconductor ASA. - * Terms and conditions of usage are described in detail in NORDIC - * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. - * - * Licensees are granted free, non-transferable use of the information. NO - * WARRANTY of ANY KIND is provided. This heading must NOT be removed from - * the file. - * - */ -#include "nrf_assert.h" -#include "app_error.h" -#include "nordic_common.h" - -#if defined(DEBUG_NRF) -void assert_nrf_callback(uint16_t line_num, const uint8_t * file_name) -{ - assert_info_t assert_info = - { - .line_num = line_num, - .p_file_name = file_name, - }; - app_error_fault_handler(NRF_FAULT_ID_SDK_ASSERT, 0, (uint32_t)(&assert_info)); - - UNUSED_VARIABLE(assert_info); -} -#endif /* DEBUG_NRF */ http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_common.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_common.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_common.h deleted file mode 100644 index bab4964..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_common.h +++ /dev/null @@ -1,182 +0,0 @@ -/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is property of Nordic Semiconductor ASA. - * Terms and conditions of usage are described in detail in NORDIC - * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. - * - * Licensees are granted free, non-transferable use of the information. NO - * WARRANTY of ANY KIND is provided. This heading must NOT be removed from - * the file. - * - */ - -/** @cond */ -/**@file - * - * @ingroup experimental_api - * @defgroup sdk_common SDK Common Header - * @breif All common headers needed for SDK examples will be included here so that application - * developer does not have to include headers on him/herself. - * @{ - */ - -#ifndef SDK_COMMON_H__ -#define SDK_COMMON_H__ - -#include <stdint.h> -#include <stdbool.h> -#include <string.h> -#include "nordic_common.h" -#include "compiler_abstraction.h" -#include "sdk_os.h" -#include "sdk_errors.h" -#include "app_util.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/**@brief Macro for verifying that the module is initialized. It will cause the function to return - * if not. - * - * @param[in] param The variable to check if is NULL. - */ -#ifndef DISABLE_PARAM_CHECK -#define VERIFY_PARAM_NOT_NULL(param) \ -do \ -{ \ - if (param == NULL) \ - { \ - return NRF_ERROR_NULL; \ - } \ -} while(0) -#else -#define VERIFY_PARAM_NOT_NULL() -#endif /* DISABLE_PARAM_CHECK */ - - -/**@brief Macro for verifying that the module is initialized. It will cause the function to return - * if not. - * - * @param[in] param The variable to check if is NULL. - */ -#ifndef DISABLE_PARAM_CHECK -#define VERIFY_PARAM_NOT_NULL_VOID(param) \ -do \ -{ \ - if (param == NULL) \ - { \ - return; \ - } \ -} while(0) -#else -#define VERIFY_PARAM_NOT_NULL_VOID() -#endif /* DISABLE_PARAM_CHECK */ - - -/**@brief Macro for verifying that a function returned NRF_SUCCESS. Will return the err code - * if not. - * - * @param[in] err_code The error code to check. - */ -#ifndef DISABLE_PARAM_CHECK -#define VERIFY_SUCCESS(err_code) \ -do \ -{ \ - if (err_code != NRF_SUCCESS) \ - { \ - return err_code; \ - } \ -} while(0) -#else -#define VERIFY_SUCCESS() -#endif /* DISABLE_PARAM_CHECK */ - - -/**@brief Macro for verifying that a function returned NRF_SUCCESS. Will return if not. - * - * @param[in] err_code The error code to check. - */ -#ifndef DISABLE_PARAM_CHECK -#define VERIFY_SUCCESS_VOID(err_code) \ -do \ -{ \ - if (err_code != NRF_SUCCESS) \ - { \ - return; \ - } \ -} while(0) -#else -#define VERIFY_SUCCESS_VOID() -#endif /* DISABLE_PARAM_CHECK */ - - -/**@brief Macro for verifying statement to be true. Will return err_code if not. -* -* @param[in] statement Statement to test. -* @param[in] err_code Error value to return if test was invalid. -* -* @retval err_code if test fails. -*/ -#define VERIFY_TRUE(statement, err_code) \ -do \ -{ \ - if (!(statement)) \ - { \ - return err_code; \ - } \ -} while(0) - - -/**@brief Macro for verifying statement to be true. Will return if not. -* -* @param[in] statement Statement to test. -*/ -#define VERIFY_TRUE_VOID(statement) \ -do \ -{ \ - if (!(statement)) \ - { \ - return; \ - } \ -} while(0) - - -/**@brief Macro for verifying statement to be false. Will return err_code if not. -* -* @param[in] statement Statement to test. -* @param[in] err_code Error value to return if test was invalid. -* -* @retval err_code if test fails. -*/ -#define VERIFY_FALSE(statement, err_code) \ -do \ -{ \ - if ((statement)) \ - { \ - return err_code; \ - } \ -} while(0) - - -/**@brief Macro for verifying statement to be false. Will return if not. -* -* @param[in] statement Statement to test. -*/ -#define VERIFY_FALSE_VOID(statement) \ -do \ -{ \ - if ((statement)) \ - { \ - return; \ - } \ -} while(0) - -/** @} */ -/** @endcond */ -#ifdef __cplusplus -} -#endif - -#endif // SDK_COMMON_H__ - http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_errors.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_errors.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_errors.h deleted file mode 100644 index f3b5997..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_errors.h +++ /dev/null @@ -1,123 +0,0 @@ -/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is property of Nordic Semiconductor ASA. - * Terms and conditions of usage are described in detail in NORDIC - * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. - * - * Licensees are granted free, non-transferable use of the information. NO - * WARRANTY of ANY KIND is provided. This heading must NOT be removed from - * the file. - * - */ - -/**@file - * - * @defgroup sdk_error SDK Error codes - * @{ - * @ingroup app_common - * @{ - * @details Error codes are 32-bit unsigned integers with the most significant 16-bit reserved for - * identifying the module where the error occurred while the least least significant LSB - * are used to provide the cause or nature of error. Each module is assigned a 16-bit - * unsigned integer. Which it will use to identify all errors that occurred in it. 16-bit - * LSB range is with module id as the MSB in the 32-bit error code is reserved for the - * module. As an example, if 0x8800 identifies a certain SDK module, all values from - * 0x88000000 - 0x8800FFFF are reserved for this module. - * It should be noted that common error reasons have been assigned values to make it - * possible to decode error reason easily. As an example, lets module uninitialized has - * been assigned an error code 0x000A0. Then, if application encounters an error code - * 0xZZZZ00A0, it knows that it accessing a certain module without initializing it. - * Apart from this, each module is allowed to define error codes that are not covered by - * the common ones, however, these values are defined in a range that does not conflict - * with common error values. For module, specific error however, it is possible that the - * same error value is used by two different modules to indicated errors of very different - * nature. If error is already defined by the NRF common error codes, these are reused. - * A range is reserved for application as well, it can use this range for defining - * application specific errors. - * - * @note Success code, NRF_SUCCESS, does not include any module identifier. - - */ - -#ifndef SDK_ERRORS_H__ -#define SDK_ERRORS_H__ - -#include <stdint.h> -#include "nrf_error.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup sdk_err_base Base defined for SDK Modules - * @{ - */ -#define SDK_ERROR_BASE (NRF_ERROR_BASE_NUM + 0x8000) /**< Base value defined for SDK module identifiers. */ -#define SDK_COMMON_ERROR_BASE (NRF_ERROR_BASE_NUM + 0x0080) /**< Base error value to be used for SDK error values. */ -/* @} */ - -/** - * @defgroup sdk_module_codes Codes reserved as identification for module where the error occurred. - * @{ - */ -#define DEVICE_MANAGER_ERR_BASE (0x8000) -#define MEMORY_MANAGER_ERR_BASE (0x8100) -/* @} */ - - -/** - * @defgroup sdk_iot_errors Codes reserved as identification for IoT errors. - * @{ - */ -#define IOT_ERR_BASE_START (0xA000) -#define IOT_ERR_BASE_STOP (0xAFFF) -/* @} */ - - -/** - * @defgroup sdk_common_errors Codes reserved as identification for common errors. - * @{ - */ -#define MODULE_NOT_INITIALZED (SDK_COMMON_ERROR_BASE + 0x0000) -#define MUTEX_INIT_FAILED (SDK_COMMON_ERROR_BASE + 0x0001) -#define MUTEX_LOCK_FAILED (SDK_COMMON_ERROR_BASE + 0x0002) -#define MUTEX_UNLOCK_FAILED (SDK_COMMON_ERROR_BASE + 0x0003) -#define MUTEX_COND_INIT_FAILED (SDK_COMMON_ERROR_BASE + 0x0004) -#define MODULE_ALREADY_INITIALIZED (SDK_COMMON_ERROR_BASE + 0x0005) -#define API_NOT_IMPLEMENTED (SDK_COMMON_ERROR_BASE + 0x0010) -#define FEATURE_NOT_ENABLED (SDK_COMMON_ERROR_BASE + 0x0011) -/* @} */ - - -/** - * @defgroup dm_specific_errors Error / status codes specific to device manager. - * @{ - */ -#define DM_NO_APP_CONTEXT (DEVICE_MANAGER_ERR_BASE + 0x0040) -#define DM_SERVICE_CONTEXT_NOT_APPLIED (DEVICE_MANAGER_ERR_BASE + 0x0041) -#define DM_CONTEXT_INFO_LOST (DEVICE_MANAGER_ERR_BASE + 0x0042) -#define DM_DEVICE_CONTEXT_FULL (DEVICE_MANAGER_ERR_BASE + 0x0043) -/* @} */ - -/** - * @brief API Result. - * - * @details Indicates success or failure of an API procedure. In case of failure, a comprehensive - * error code indicating cause or reason for failure is provided. - * - * Though called an API result, it could used in Asynchronous notifications callback along - * with asynchronous callback as event result. This mechanism is employed when an event - * marks the end of procedure initiated using API. API result, in this case, will only be - * an indicative of whether the procedure has been requested successfully. - */ -typedef uint32_t ret_code_t; -/** @} */ -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif // SDK_ERRORS_H__ - http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_macros.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_macros.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_macros.h deleted file mode 100644 index 83e489f..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_macros.h +++ /dev/null @@ -1,80 +0,0 @@ -/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is property of Nordic Semiconductor ASA. - * Terms and conditions of usage are described in detail in NORDIC - * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. - * - * Licensees are granted free, non-transferable use of the information. NO - * WARRANTY of ANY KIND is provided. This heading must NOT be removed from - * the file. - * - */ - -/** @cond */ -/**@file - * - * @ingroup sdk_util - * @defgroup sdk_common_macros SDK Common Header - * @breif Macros for parameter checking and similar tasks - * @{ - */ - -#ifndef SDK_MACROS_H__ -#define SDK_MACROS_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/**@brief Macro for verifying that the module is initialized. It will cause the function to return - * @ref NRF_ERROR_INVALID_STATE if not. - */ -#ifdef DISABLE_PARAM_CHECK -#define VERIFY_MODULE_INITIALIZED() -#else -#ifdef MODULE_INITIALIZED -#define VERIFY_MODULE_INITIALIZED() \ -do \ -{ \ - if (!MODULE_INITIALIZED) \ - { \ - return NRF_ERROR_INVALID_STATE; \ - } \ -} while(0) -#else -#define VERIFY_MODULE_INITIALIZED() -#endif /* MODULE_INITIALIZED */ -#endif /* DISABLE_PARAM_CHECK */ - - -/**@brief Macro for verifying that the module is initialized. It will cause the function to return - * if not. - */ -#ifdef DISABLE_PARAM_CHECK -#define VERIFY_MODULE_INITIALIZED_VOID() -#else -#ifdef MODULE_INITIALIZED -#define VERIFY_MODULE_INITIALIZED_VOID() \ -do \ -{ \ - if (!MODULE_INITIALIZED) \ - { \ - return; \ - } \ -} while(0) -#else -#define VERIFY_MODULE_INITIALIZED_VOID() -#endif /* MODULE_INITIALIZED */ -#endif /* DISABLE_PARAM_CHECK */ - - - - -/** @} */ -/** @endcond */ -#ifdef __cplusplus -} -#endif - -#endif // SDK_MACROS_H__ - http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_mapped_flags.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_mapped_flags.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_mapped_flags.c deleted file mode 100644 index 697dd3f..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_mapped_flags.c +++ /dev/null @@ -1,161 +0,0 @@ -/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is property of Nordic Semiconductor ASA. - * Terms and conditions of usage are described in detail in NORDIC - * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. - * - * Licensees are granted free, non-transferable use of the information. NO - * WARRANTY of ANY KIND is provided. This heading must NOT be removed from - * the file. - * - */ - -#include "sdk_mapped_flags.h" -#include <stdint.h> -#include <stdbool.h> -#include <stddef.h> -#include "compiler_abstraction.h" - - -/**@brief Function for setting the state of a flag to true. - * - * @note This function does not check whether the index is valid. - * - * @param[in] p_flags The collection of flags to modify. - * @param[in] index The index of the flag to modify. - */ -static __INLINE void sdk_mapped_flags_set_by_index(sdk_mapped_flags_t * p_flags, uint16_t index) -{ - *p_flags |= (1U << index); -} - - -/**@brief Function for setting the state of a flag to false. - * - * @note This function does not check whether the index is valid. - * - * @param[in] p_flags The collection of flags to modify. - * @param[in] index The index of the flag to modify. - */ -static __INLINE void sdk_mapped_flags_clear_by_index(sdk_mapped_flags_t * p_flags, uint16_t index) -{ - *p_flags &= ~(1U << index); -} - - -/**@brief Function for getting the state of a flag. - * - * @note This function does not check whether the index is valid. - * - * @param[in] p_flags The collection of flags to read. - * @param[in] index The index of the flag to get. - */ -static __INLINE bool sdk_mapped_flags_get_by_index(sdk_mapped_flags_t flags, uint16_t index) -{ - return ((flags & (1 << index)) != 0); -} - - - -uint16_t sdk_mapped_flags_first_key_index_get(sdk_mapped_flags_t flags) -{ - for (uint16_t i = 0; i < SDK_MAPPED_FLAGS_N_KEYS; i++) - { - if (sdk_mapped_flags_get_by_index(flags, i)) - { - return i; - } - } - return SDK_MAPPED_FLAGS_INVALID_INDEX; -} - - -void sdk_mapped_flags_update_by_key(uint16_t * p_keys, - sdk_mapped_flags_t * p_flags, - uint16_t key, - bool value) -{ - sdk_mapped_flags_bulk_update_by_key(p_keys, p_flags, 1, key, value); -} - - -void sdk_mapped_flags_bulk_update_by_key(uint16_t * p_keys, - sdk_mapped_flags_t * p_flags, - uint32_t n_flag_collections, - uint16_t key, - bool value) -{ - if ((p_keys != NULL) && (p_flags != NULL) && (n_flag_collections > 0)) - { - for (uint32_t i = 0; i < SDK_MAPPED_FLAGS_N_KEYS; i++) - { - if (p_keys[i] == key) - { - for (uint32_t j = 0; j < n_flag_collections; j++) - { - if (value) - { - sdk_mapped_flags_set_by_index(&p_flags[j], i); - } - else - { - sdk_mapped_flags_clear_by_index(&p_flags[j], i); - } - } - return; - } - } - } -} - - -bool sdk_mapped_flags_get_by_key(uint16_t * p_keys, sdk_mapped_flags_t flags, uint16_t key) -{ - if (p_keys != NULL) - { - for (uint32_t i = 0; i < SDK_MAPPED_FLAGS_N_KEYS; i++) - { - if (p_keys[i] == key) - { - return sdk_mapped_flags_get_by_index(flags, i); - } - } - } - return false; -} - - -sdk_mapped_flags_key_list_t sdk_mapped_flags_key_list_get(uint16_t * p_keys, - sdk_mapped_flags_t flags) -{ - sdk_mapped_flags_key_list_t key_list; - key_list.len = 0; - - if (p_keys != NULL) - { - for (uint32_t i = 0; i < SDK_MAPPED_FLAGS_N_KEYS; i++) - { - if (sdk_mapped_flags_get_by_index(flags, i)) - { - key_list.flag_keys[key_list.len++] = p_keys[i]; - } - } - } - - return key_list; -} - - -uint32_t sdk_mapped_flags_n_flags_set(sdk_mapped_flags_t flags) -{ - uint32_t n_flags_set = 0; - - for (uint32_t i = 0; i < SDK_MAPPED_FLAGS_N_KEYS; i++) - { - if (sdk_mapped_flags_get_by_index(flags, i)) - { - n_flags_set += 1; - } - } - return n_flags_set; -} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_mapped_flags.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_mapped_flags.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_mapped_flags.h deleted file mode 100644 index 63733bc..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_mapped_flags.h +++ /dev/null @@ -1,161 +0,0 @@ -/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is property of Nordic Semiconductor ASA. - * Terms and conditions of usage are described in detail in NORDIC - * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. - * - * Licensees are granted free, non-transferable use of the information. NO - * WARRANTY of ANY KIND is provided. This heading must NOT be removed from - * the file. - * - */ - -#ifndef SDK_MAPPED_FLAGS_H__ -#define SDK_MAPPED_FLAGS_H__ - -#include <stdint.h> -#include <stdbool.h> -#include "app_util.h" -#include "compiler_abstraction.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file - * @defgroup sdk_mapped_flags Mapped flags - * @ingroup app_common - * @{ - * @brief Module for writing and reading flags that are associated - * with keys. - * - * @details The flags are represented as bits in a bitmap called a <i>flag collection</i>. The keys - * are uint16_t. Each flag collection contains all flags of the same type, one flag for - * each key. - * - * The mapped flags module does not keep the flag states, nor the list of keys. These are - * provided in the API calls. A key's index in the key list determines which bit in the - * flag collection is associated with it. This module does not ever edit the key list, and - * does not edit flags except in function calls that take the flag collection as a pointer. - * - */ - -#define SDK_MAPPED_FLAGS_N_KEYS 8 /**< The number of keys to keep flags for. This is also the number of flags in a flag collection. If changing this value, you might also need change the width of the sdk_mapped_flags_t type. */ -#define SDK_MAPPED_FLAGS_N_KEYS_PER_BYTE 8 /**< The number of flags that fit in one byte. */ -#define SDK_MAPPED_FLAGS_INVALID_INDEX 0xFFFF /**< A flag index guaranteed to be invalid. */ - -typedef uint8_t sdk_mapped_flags_t; /**< The bitmap to hold flags. Each flag is one bit, and each bit represents the flag state associated with one key. */ - - -// Test whether the flag collection type is large enough to hold all the flags. If this fails, -// reduce SDK_MAPPED_FLAGS_N_KEYS or increase the size of sdk_mapped_flags_t. -STATIC_ASSERT(( - sizeof(sdk_mapped_flags_t)*SDK_MAPPED_FLAGS_N_KEYS_PER_BYTE) >= SDK_MAPPED_FLAGS_N_KEYS); - - -/**@brief Type used to present a subset of the registered keys. - */ -typedef struct -{ - uint32_t len; /**< The length of the list. */ - uint16_t flag_keys[SDK_MAPPED_FLAGS_N_KEYS]; /**< The list of keys. */ -} sdk_mapped_flags_key_list_t; - - -/**@brief Function for getting the first index at which the flag is true in the provided - * collection. - * - * @param[in] flags The flag collection to search for a flag set to true. - * - * @return The first index that has its flag set to true. If none were found, the - * function returns @ref SDK_MAPPED_FLAGS_INVALID_INDEX. - */ -uint16_t sdk_mapped_flags_first_key_index_get(sdk_mapped_flags_t flags); - - -/**@brief Function for updating the state of a flag. - * - * @param[in] p_keys The list of associated keys (assumed to have a length of - * @ref SDK_MAPPED_FLAGS_N_KEYS). - * @param[out] p_flags The flag collection to modify. - * @param[in] key The key to modify the flag of. - * @param[in] value The state to set the flag to. - */ -void sdk_mapped_flags_update_by_key(uint16_t * p_keys, - sdk_mapped_flags_t * p_flags, - uint16_t key, - bool value); - - -/**@brief Function for updating the state of the same flag in multiple flag collections. - * - * @details The key and value are the same for all flag collections in the p_flags array. - * - * @param[in] p_keys The list of associated keys (assumed to have a length of - * @ref SDK_MAPPED_FLAGS_N_KEYS). - * @param[out] p_flags The flag collections to modify. - * @param[out] n_flag_collections The number of flag collections in p_flags. - * @param[in] key The key to modify the flag of. - * @param[in] value The state to set the flag to. - */ -void sdk_mapped_flags_bulk_update_by_key(uint16_t * p_keys, - sdk_mapped_flags_t * p_flags, - uint32_t n_flag_collections, - uint16_t key, - bool value); - - -/**@brief Function for getting the state of a specific flag. - * - * @param[in] p_keys The list of associated keys (assumed to have a length of - * @ref SDK_MAPPED_FLAGS_N_KEYS). - * @param[in] flags The flag collection to read from. - * @param[in] key The key to get the flag for. - * - * @return The state of the flag. - */ -bool sdk_mapped_flags_get_by_key(uint16_t * p_keys, sdk_mapped_flags_t flags, uint16_t key); - - -/**@brief Function for getting a list of all keys that have a specific flag set to true. - * - * @param[in] p_keys The list of associated keys (assumed to have a length of - * @ref SDK_MAPPED_FLAGS_N_KEYS). - * @param[in] flags The flag collection to search. - * - * @return The list of keys. - */ -sdk_mapped_flags_key_list_t sdk_mapped_flags_key_list_get(uint16_t * p_keys, - sdk_mapped_flags_t flags); - - -/**@brief Function for getting the number of keys that have a specific flag set to true. - * - * @param[in] flags The flag collection to search. - * - * @return The number of keys. - */ -uint32_t sdk_mapped_flags_n_flags_set(sdk_mapped_flags_t flags); - - -/**@brief Function for querying whether any flags in the collection are set. - * - * @param[in] flags The flag collection to query. - * - * @retval true If one or more flags are set to true. - * @retval false Otherwise. - */ -static __INLINE bool sdk_mapped_flags_any_set(sdk_mapped_flags_t flags) -{ - return (flags != 0); -} - - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* SDK_MAPPED_FLAGS_H__ */ http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_os.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_os.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_os.h deleted file mode 100644 index 3fbbf4b..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_os.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is property of Nordic Semiconductor ASA. - * Terms and conditions of usage are described in detail in NORDIC - * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. - * - * Licensees are granted free, non-transferable use of the information. NO - * WARRANTY of ANY KIND is provided. This heading must NOT be removed from - * the file. - * - */ - - /** @cond */ -/**@file - * - * @defgroup sdk_os SDK OS Abstraction - * @ingroup experimental_api - * @details In order to made SDK modules independent of use of an embedded OS, and permit - * application with varied task architecture, SDK abstracts the OS specific - * elements here in order to make all other modules agnostic to the OS or task - * architecture. - * @{ - */ - -#ifndef SDK_OS_H__ -#define SDK_OS_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#define SDK_MUTEX_DEFINE(X) -#define SDK_MUTEX_INIT(X) -#define SDK_MUTEX_LOCK(X) -#define SDK_MUTEX_UNLOCK(X) - -/** - * @defgroup os_data_type Data types. - */ - -/** @} */ -/** @endcond */ -#ifdef __cplusplus -} -#endif - -#endif // SDK_OS_H__ - http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_resources.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_resources.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_resources.h deleted file mode 100644 index c95a65e..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/util/sdk_resources.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is property of Nordic Semiconductor ASA. - * Terms and conditions of usage are described in detail in NORDIC - * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. - * - * Licensees are granted free, non-transferable use of the information. NO - * WARRANTY of ANY KIND is provided. This heading must NOT be removed from - * the file. - */ - -/** @file - * @brief Definition file for resource usage by SoftDevice, ESB and Gazell. - */ - -#ifndef APP_RESOURCES_H__ -#define APP_RESOURCES_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef SOFTDEVICE_PRESENT - #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 // APP_RESOURCES_H__ http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/common/ble_dtm_app.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/common/ble_dtm_app.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/common/ble_dtm_app.c deleted file mode 100644 index 1362d23..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/common/ble_dtm_app.c +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is property of Nordic Semiconductor ASA. - * Terms and conditions of usage are described in detail in NORDIC - * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. - * - * Licensees are granted free, non-transferable use of the information. NO - * WARRANTY of ANY KIND is provided. This heading must NOT be removed from - * the file. - * - */ - -#include <stdint.h> -#include "app_error.h" -#include "ble_dtm_app.h" -#include "ble_serialization.h" -#include "nrf_error.h" -#include "ser_config.h" -#include "ser_hal_transport.h" -#include "ser_sd_transport.h" - - -static uint32_t dtm_init_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = ble_dtm_init_rsp_dec(p_buffer, length, &result_code); - APP_ERROR_CHECK(err_code); - - return result_code; -} - - -uint32_t ble_dtm_init(app_uart_stream_comm_params_t * p_uart_comm_params) -{ - if (p_uart_comm_params == NULL) - { - return NRF_ERROR_NULL; - } - - uint32_t err_code = NRF_SUCCESS; - uint32_t index = 0; - - uint8_t * p_tx_buf = NULL; - uint32_t tx_buf_len = 0; - - err_code = ser_hal_transport_tx_pkt_alloc(&p_tx_buf, (uint16_t *)&tx_buf_len); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - - p_tx_buf[index++] = SER_PKT_TYPE_DTM_CMD; - tx_buf_len -= SER_PKT_TYPE_SIZE; - - err_code = ble_dtm_init_req_enc(p_uart_comm_params, &(p_tx_buf[SER_PKT_TYPE_SIZE]), &tx_buf_len); - if (err_code == NRF_SUCCESS) - { - tx_buf_len += SER_PKT_TYPE_SIZE; - - err_code = ser_sd_transport_cmd_write(p_tx_buf, tx_buf_len, dtm_init_rsp_dec); - if (err_code != NRF_SUCCESS) - { - err_code = NRF_ERROR_INTERNAL; - } - } - else - { - err_code = NRF_ERROR_INTERNAL; - } - - return err_code; -} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/common/ble_dtm_app.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/common/ble_dtm_app.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/common/ble_dtm_app.h deleted file mode 100644 index e47ae2f..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/common/ble_dtm_app.h +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is property of Nordic Semiconductor ASA. - * Terms and conditions of usage are described in detail in NORDIC - * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. - * - * Licensees are granted free, non-transferable use of the information. NO - * WARRANTY of ANY KIND is provided. This heading must NOT be removed from - * the file. - * - */ - -#ifndef BLE_DTM_APP_H__ -#define BLE_DTM_APP_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ser_codecs Serialization codecs - * @ingroup ble_sdk_lib_serialization - */ - -/** - * @addtogroup ser_app_common_codecs Application common codecs - * @ingroup ser_codecs - */ - -/**@file - * - * @defgroup ble_dtm_app DTM Application command request encoders and command response decoders - * @{ - * @ingroup ser_app_common_codecs - * - * @brief DTM Application command request encoders and command response decoders. - */ - -#include "dtm_uart_params.h" - -/**@brief Encodes @ref ble_dtm_init command request. - * - * @sa @ref nrf51_dtm_init_encoding_sec for packet format, - * @ref ble_dtm_init_rsp_dec for command response decoder. - * - * @param[in] p_uart_comm_params Pointer to UART configuration parameters. - * @param[in] p_buf Pointer to buffer where encoded data command will be returned. - * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. - * \c out: Length of encoded command packet. - * - * @retval NRF_SUCCESS Encoding success. - * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. - * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. - */ -uint32_t ble_dtm_init_req_enc(app_uart_stream_comm_params_t const * const p_uart_comm_params, - uint8_t * const p_buf, - uint32_t * const p_buf_len); - - -/**@brief Decodes response @ref ble_dtm_init command. - * - * @sa @ref nrf51_dtm_init_encoding_sec for packet format, - * @ref ble_dtm_init_req_enc for command request encoder. - * - * @param[in] p_buf Pointer to beginning of command response packet. - * @param[in] packet_len Length (in bytes) of response packet. - * @param[out] p_result_code Command result code. - * - * @retval NRF_SUCCESS Decoding success. - * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. - * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. - */ -uint32_t ble_dtm_init_rsp_dec(uint8_t const * const p_buf, - uint32_t packet_len, - uint32_t * const p_result_code); - - -/**@brief Function to initializing DTM mode. - * - * @param[in] p_uart_comm_params Pointer to the DTM UART configuration parameters. - * - * @retval NRF_SUCCESS Encoding success. - * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. - */ -uint32_t ble_dtm_init(app_uart_stream_comm_params_t * p_uart_comm_params); - -/** @} */ -#ifdef __cplusplus -} -#endif - -#endif // BLE_DTM_APP_H__ http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/common/ble_dtm_init.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/common/ble_dtm_init.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/common/ble_dtm_init.c deleted file mode 100644 index 443b7b5..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/common/ble_dtm_init.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is property of Nordic Semiconductor ASA. - * Terms and conditions of usage are described in detail in NORDIC - * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. - * - * Licensees are granted free, non-transferable use of the information. NO - * WARRANTY of ANY KIND is provided. This heading must NOT be removed from - * the file. - * - */ - -#include "ble_dtm_app.h" -#include "ble_serialization.h" -#include "nrf_error.h" - -uint32_t ble_dtm_init_req_enc(app_uart_stream_comm_params_t const * const p_uart_comm_params, uint8_t * const p_buf, uint32_t * const p_buf_len) -{ - SER_ASSERT_NOT_NULL(p_buf); - SER_ASSERT_NOT_NULL(p_buf_len); - SER_ASSERT_NOT_NULL(p_uart_comm_params); - - uint32_t index = 0; - uint32_t buf_len = *p_buf_len; - uint32_t err_code; - - err_code = uint8_t_enc(&p_uart_comm_params->tx_pin_no, p_buf, buf_len, &index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint8_t_enc(&p_uart_comm_params->rx_pin_no, p_buf, buf_len, &index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - err_code = uint8_t_enc(&p_uart_comm_params->baud_rate, p_buf, buf_len, &index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - *p_buf_len = index; - - return err_code; -} - - -uint32_t ble_dtm_init_rsp_dec(uint8_t const * const p_buf, uint32_t packet_len, uint32_t * const p_result_code) -{ - SER_ASSERT_NOT_NULL(p_buf); - SER_ASSERT_NOT_NULL(p_result_code); - - uint32_t err_code; - uint32_t index = 0; - - err_code = uint32_t_dec(p_buf, packet_len, &index, p_result_code); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - - SER_ASSERT(packet_len == index, NRF_ERROR_INVALID_LENGTH); - - return err_code; -} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/common/conn_systemreset.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/common/conn_systemreset.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/common/conn_systemreset.c deleted file mode 100644 index c8950ec..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/common/conn_systemreset.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is property of Nordic Semiconductor ASA. - * Terms and conditions of usage are described in detail in NORDIC - * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. - * - * Licensees are granted free, non-transferable use of the information. NO - * WARRANTY of ANY KIND is provided. This heading must NOT be removed from - * the file. - * - */ - -#include <stdint.h> -#include "ble_serialization.h" -#include "ser_hal_transport.h" -#include "ser_sd_transport.h" - - -uint32_t conn_systemreset(void) -{ - uint32_t err_code = NRF_SUCCESS; - uint8_t * p_tx_buf = NULL; - uint32_t tx_buf_len = 0; - - err_code = ser_hal_transport_tx_pkt_alloc(&p_tx_buf, (uint16_t *)&tx_buf_len); - if (err_code != NRF_SUCCESS) - { - return err_code; - } - - SER_ASSERT_LENGTH_LEQ(SER_PKT_TYPE_SIZE, tx_buf_len); - p_tx_buf[SER_PKT_TYPE_POS] = SER_PKT_TYPE_RESET_CMD; - tx_buf_len = SER_PKT_TYPE_SIZE; - - err_code = ser_sd_transport_cmd_write(p_tx_buf, tx_buf_len, NULL); - if (err_code != NRF_SUCCESS) - { - err_code = NRF_ERROR_INTERNAL; - } - - return err_code; -} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/common/conn_systemreset.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/common/conn_systemreset.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/common/conn_systemreset.h deleted file mode 100644 index a1004aa..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/common/conn_systemreset.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is property of Nordic Semiconductor ASA. - * Terms and conditions of usage are described in detail in NORDIC - * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. - * - * Licensees are granted free, non-transferable use of the information. NO - * WARRANTY of ANY KIND is provided. This heading must NOT be removed from - * the file. - * - */ - -#ifndef CONN_SYSTEMRESET_H__ -#define CONN_SYSTEMRESET_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ser_codecs Serialization codecs - * @ingroup ble_sdk_lib_serialization - */ - -/** - * @addtogroup ser_app_common_codecs Application common codecs - * @ingroup ser_codecs - */ - -/**@file - * - * @defgroup conn_systemreset Connectivity chip reset command request encoder. - * @{ - * @ingroup ser_app_common_codecs - * - * @brief Connectivity chip reset command request encoder. - */ - -/**@brief Function for performing the connectivity chip reset. - * - * @retval NRF_SUCCESS Encoding success. - * @retval NRF_ERROR_INTERNAL Encoding failure. Transport error. - */ -uint32_t conn_systemreset(void); - -/** @} */ -#ifdef __cplusplus -} -#endif - -#endif // CONN_SYSTEMRESET_H__ http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_ble.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_ble.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_ble.c deleted file mode 100644 index 8948e5f..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/serialization/application/codecs/s130/middleware/app_mw_ble.c +++ /dev/null @@ -1,498 +0,0 @@ -/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is property of Nordic Semiconductor ASA. - * Terms and conditions of usage are described in detail in NORDIC - * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. - * - * Licensees are granted free, non-transferable use of the information. NO - * WARRANTY of ANY KIND is provided. This heading must NOT be removed from - * the file. - * - */ - -#include "ble.h" -#include "ble_serialization.h" -#include <stdint.h> -#include "ble_app.h" -#include "ser_sd_transport.h" -#include "app_error.h" -#include "app_ble_user_mem.h" - -extern ser_ble_user_mem_t m_app_user_mem_table[]; - -/**@brief Structure containing @ref sd_ble_uuid_encode output parameters. */ -typedef struct -{ - uint8_t * p_uuid_le_len; /**< @ref sd_ble_uuid_encode appearance p_uuid_le_len output parameter. */ - uint8_t * p_uuid_le; /**< @ref sd_ble_uuid_encode appearance p_uuid_le output parameter. */ -} ble_uuid_encode_out_params_t; - -/**@brief Structure containing @ref sd_ble_user_mem_reply output parameters. */ -typedef struct -{ - uint16_t conn_handle; /**< @ref sd_ble_user_mem_reply conn_handle. */ - uint8_t context_allocated; /**< @ref sd_ble_user_mem_reply user memory context allocated flag. */ -} ble_user_mem_reply_out_params_t; - -/**@brief Union containing BLE command output parameters. */ -typedef union -{ - ble_uuid_encode_out_params_t ble_uuid_encode_out_params; /**< @ref sd_ble_uuid_encode output parameters. */ - ble_user_mem_reply_out_params_t ble_user_mem_reply_out_params; /**< @ref sd_ble_user_mem_reply output parameters. */ -} ble_command_output_params_t; - -static ble_command_output_params_t m_output_params; /**< BLE command output parameters. */ - -static void * mp_out_params[3]; -static uint32_t m_uint32_param; - -static void tx_buf_alloc(uint8_t * * p_data, uint32_t * p_len) -{ - uint32_t err_code; - uint16_t len16; - - do - { - err_code = ser_sd_transport_tx_alloc(p_data, &len16); - } - while (err_code != NRF_SUCCESS); - - *p_data[0] = SER_PKT_TYPE_CMD; - *p_len = (uint32_t)len16 - 1; -} - -/**@brief Command response callback function for @ref sd_ble_uuid_encode BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t uuid_encode_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = - ble_uuid_encode_rsp_dec(p_buffer, - length, - m_output_params.ble_uuid_encode_out_params.p_uuid_le_len, - m_output_params.ble_uuid_encode_out_params.p_uuid_le, - &result_code); - - //@note: Should never fail. - APP_ERROR_CHECK(err_code); - return result_code; -} - - -uint32_t sd_ble_uuid_encode(ble_uuid_t const * const p_uuid, - uint8_t * const p_uuid_le_len, - uint8_t * const p_uuid_le) -{ - uint8_t * p_buffer; - uint32_t buffer_length; - - tx_buf_alloc(&p_buffer, &buffer_length); - - m_output_params.ble_uuid_encode_out_params.p_uuid_le_len = p_uuid_le_len; - m_output_params.ble_uuid_encode_out_params.p_uuid_le = p_uuid_le; - - uint32_t err_code = ble_uuid_encode_req_enc(p_uuid, - p_uuid_le_len, - p_uuid_le, - &(p_buffer[1]), - &buffer_length); - //@note: Should never fail. - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - uuid_encode_rsp_dec); - -} - -/**@brief Command response callback function for @ref sd_ble_tx_packet_count_get BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t tx_packet_count_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = ble_tx_packet_count_get_rsp_dec(p_buffer, - length, - (uint8_t * *)&mp_out_params[0], - &result_code); - - //@note: Should never fail. - APP_ERROR_CHECK(err_code); - - return result_code; -} - -uint32_t sd_ble_tx_packet_count_get(uint16_t conn_handle, uint8_t * p_count) -{ - uint8_t * p_buffer; - uint32_t buffer_length; - - tx_buf_alloc(&p_buffer, &buffer_length); - mp_out_params[0] = p_count; - - const uint32_t err_code = ble_tx_packet_count_get_req_enc(conn_handle, - p_count, - &(p_buffer[1]), - &buffer_length); - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - tx_packet_count_get_rsp_dec); - -} - -/**@brief Command response callback function for @ref sd_ble_uuid_vs_add BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t uuid_vs_add_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = ble_uuid_vs_add_rsp_dec(p_buffer, - length, - (uint8_t * *)&mp_out_params[0], - &result_code); - - //@note: Should never fail. - APP_ERROR_CHECK(err_code); - - return result_code; -} - -uint32_t sd_ble_uuid_vs_add(ble_uuid128_t const * const p_vs_uuid, uint8_t * const p_uuid_type) -{ - uint8_t * p_buffer; - uint32_t buffer_length; - - tx_buf_alloc(&p_buffer, &buffer_length); - mp_out_params[0] = p_uuid_type; - - const uint32_t err_code = ble_uuid_vs_add_req_enc(p_vs_uuid, p_uuid_type, - &(p_buffer[1]), - &buffer_length); - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - uuid_vs_add_rsp_dec); -} - -/**@brief Command response callback function for @ref sd_ble_uuid_decode BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t uuid_decode_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = ble_uuid_decode_rsp_dec(p_buffer, - length, - (ble_uuid_t * *)&mp_out_params[0], - &result_code); - - //@note: Should never fail. - APP_ERROR_CHECK(err_code); - - return result_code; -} - -uint32_t sd_ble_uuid_decode(uint8_t uuid_le_len, - uint8_t const * const p_uuid_le, - ble_uuid_t * const p_uuid) -{ - uint8_t * p_buffer; - uint32_t buffer_length; - - tx_buf_alloc(&p_buffer, &buffer_length); - mp_out_params[0] = p_uuid; - - const uint32_t err_code = ble_uuid_decode_req_enc(uuid_le_len, p_uuid_le, p_uuid, - &(p_buffer[1]), - &buffer_length); - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - uuid_decode_rsp_dec); -} - -/**@brief Command response callback function for @ref sd_ble_version_get BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t version_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = ble_version_get_rsp_dec(p_buffer, - length, - (ble_version_t *)mp_out_params[0], - &result_code); - - //@note: Should never fail. - APP_ERROR_CHECK(err_code); - - return result_code; -} - -uint32_t sd_ble_version_get(ble_version_t * p_version) -{ - uint8_t * p_buffer; - uint32_t buffer_length; - - tx_buf_alloc(&p_buffer, &buffer_length); - mp_out_params[0] = p_version; - - const uint32_t err_code = ble_version_get_req_enc(p_version, - &(p_buffer[1]), - &buffer_length); - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - version_get_rsp_dec); - -} - -/**@brief Command response callback function for @ref sd_ble_opt_get BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t opt_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - uint32_t uint32_param; - - uint32_t err_code = ble_opt_get_rsp_dec(p_buffer, - length, - &uint32_param, - (ble_opt_t *)mp_out_params[0], - &result_code); - - APP_ERROR_CHECK(err_code); - if (m_uint32_param != uint32_param) // decoded id should be the same as encoded one - { - err_code = NRF_ERROR_INVALID_PARAM; - } - APP_ERROR_CHECK(err_code); - - return result_code; -} - -uint32_t sd_ble_opt_get(uint32_t opt_id, ble_opt_t *p_opt) -{ - uint8_t * p_buffer; - uint32_t buffer_length; - - tx_buf_alloc(&p_buffer, &buffer_length); - mp_out_params[0] = p_opt; - m_uint32_param = opt_id; - - const uint32_t err_code = ble_opt_get_req_enc(opt_id, - p_opt, - &(p_buffer[1]), - &buffer_length); - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - opt_get_rsp_dec); - -} - -/**@brief Command response callback function for @ref sd_ble_opt_set BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t opt_set_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = ble_opt_set_rsp_dec(p_buffer, - length, - &result_code); - - APP_ERROR_CHECK(err_code); - - return result_code; -} - -uint32_t sd_ble_opt_set(uint32_t opt_id, ble_opt_t const *p_opt) -{ - uint8_t * p_buffer; - uint32_t buffer_length; - - tx_buf_alloc(&p_buffer, &buffer_length); - - const uint32_t err_code = ble_opt_set_req_enc(opt_id, - p_opt, - &(p_buffer[1]), - &buffer_length); - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - opt_set_rsp_dec); - -} - -/**@brief Command response callback function for @ref sd_ble_enable BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t enable_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - const uint32_t err_code = ble_enable_rsp_dec(p_buffer, - length, - &result_code); - - //@note: Should never fail. - APP_ERROR_CHECK(err_code); - - return result_code; -} - -uint32_t sd_ble_enable(ble_enable_params_t * p_params, uint32_t * p_app_ram_base) -{ - uint8_t * p_buffer; - uint32_t buffer_length; - - //Ignore ram_base parameter - (void)p_app_ram_base; - - tx_buf_alloc(&p_buffer, &buffer_length); - mp_out_params[0] = p_params; - - const uint32_t err_code = ble_enable_req_enc(p_params, - &(p_buffer[1]), - &buffer_length); - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - enable_rsp_dec); - -} - -/**@brief Command response callback function for @ref sd_ble_user_mem_reply BLE command. - * - * Callback for decoding the output parameters and the command response return code. - * - * @param[in] p_buffer Pointer to begin of command response buffer. - * @param[in] length Length of data in bytes. - * - * @return Decoded command response return code. - */ -static uint32_t user_mem_reply_rsp_dec(const uint8_t * p_buffer, uint16_t length) -{ - uint32_t result_code; - - uint32_t err_code = ble_user_mem_reply_rsp_dec(p_buffer, - length, - &result_code); - APP_ERROR_CHECK(err_code); - - if ((result_code != NRF_SUCCESS) && - (m_output_params.ble_user_mem_reply_out_params.context_allocated)) - { - err_code = app_ble_user_mem_context_destroy( - m_output_params.ble_user_mem_reply_out_params.conn_handle); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - } - - return result_code; -} - -uint32_t sd_ble_user_mem_reply(uint16_t conn_handle, ble_user_mem_block_t const *p_block) -{ - uint8_t * p_buffer; - uint32_t buffer_length, user_mem_table_index; - uint32_t err_code = NRF_SUCCESS; - - tx_buf_alloc(&p_buffer, &buffer_length); - - // Prepare User Memory Block context for later synchronization when SoftDevice updates - // the data in the memory block - if(p_block != NULL) - { - err_code = app_ble_user_mem_context_create(conn_handle, &user_mem_table_index); - SER_ASSERT(err_code == NRF_SUCCESS, err_code); - m_app_user_mem_table[user_mem_table_index].mem_block.len = p_block->len; - m_app_user_mem_table[user_mem_table_index].mem_block.p_mem = p_block->p_mem; - // Save connection handle and context allocation flag for case if context destroy was needed - m_output_params.ble_user_mem_reply_out_params.conn_handle = conn_handle; - m_output_params.ble_user_mem_reply_out_params.context_allocated = 1; - } - else - { - m_output_params.ble_user_mem_reply_out_params.context_allocated = 0; - } - - err_code = ble_user_mem_reply_req_enc(conn_handle, - p_block, - &(p_buffer[1]), - &buffer_length); - APP_ERROR_CHECK(err_code); - - //@note: Increment buffer length as internally managed packet type field must be included. - return ser_sd_transport_cmd_write(p_buffer, - (++buffer_length), - user_mem_reply_rsp_dec); -}
