diff options
Diffstat (limited to 'thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages')
13 files changed, 1380 insertions, 0 deletions
diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_common_data.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_common_data.c new file mode 100644 index 0000000..8378d31 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_common_data.c @@ -0,0 +1,104 @@ +/** + * 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. + * + */ +#include "sdk_common.h" +#if NRF_MODULE_ENABLED(ANT_SDM) + +#include "ant_sdm_common_data.h" +#include "ant_sdm_utils.h" + +#define NRF_LOG_MODULE_NAME ant_sdm +#if ANT_SDM_LOG_ENABLED +#define NRF_LOG_LEVEL ANT_SDM_LOG_LEVEL +#define NRF_LOG_INFO_COLOR ANT_SDM_INFO_COLOR +#else // ANT_SDM_LOG_ENABLED +#define NRF_LOG_LEVEL 0 +#endif // ANT_SDM_LOG_ENABLED +#include "nrf_log.h" + +/**@brief SDM common page data layout structure. */ +typedef struct +{ + uint8_t reserved0[3]; + uint8_t speed_integer :4; + uint8_t reserved1 :4; + uint8_t speed_fractional; + uint8_t reserved2[2]; +}ant_sdm_speed_data_layout_t; + +/**@brief Function for tracing common data. + * + * @param[in] p_common_data Pointer to the common data. + */ +static void speed_data_log(ant_sdm_common_data_t const * p_common_data) +{ + uint32_t speed = ANT_SDM_SPEED_RESCALE(p_common_data->speed); + UNUSED_VARIABLE(speed); + + NRF_LOG_INFO("Speed %u.%02u m/s\r\n\n", + (unsigned int)(speed / ANT_SDM_SPEED_DISP_PRECISION), + (unsigned int)(speed % ANT_SDM_SPEED_DISP_PRECISION)); +} + +void ant_sdm_speed_encode(uint8_t * p_page_buffer, + ant_sdm_common_data_t const * p_common_data) +{ + ant_sdm_speed_data_layout_t * p_outcoming_data = (ant_sdm_speed_data_layout_t *)p_page_buffer; + uint16_t speed = p_common_data->speed; + + p_outcoming_data->speed_integer = speed / ANT_SDM_SPEED_UNIT_REVERSAL; + p_outcoming_data->speed_fractional = speed % ANT_SDM_SPEED_UNIT_REVERSAL; + + speed_data_log(p_common_data); +} + +void ant_sdm_speed_decode(uint8_t const * p_page_buffer, + ant_sdm_common_data_t * p_common_data) +{ + ant_sdm_speed_data_layout_t const * p_incoming_data = (ant_sdm_speed_data_layout_t *)p_page_buffer; + uint16_t speed = (p_incoming_data->speed_integer + * ANT_SDM_SPEED_UNIT_REVERSAL) + + p_incoming_data->speed_fractional; + + p_common_data->speed = speed; + + speed_data_log(p_common_data); +} + +#endif // NRF_MODULE_ENABLED(ANT_SDM) diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_common_data.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_common_data.h new file mode 100644 index 0000000..d22c491 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_common_data.h @@ -0,0 +1,103 @@ +/** + * 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 ANT_SDM_COMMON_DATA_H__ +#define ANT_SDM_COMMON_DATA_H__ + +/** @file + * + * @defgroup ant_sdk_profiles_sdm_common_data_page Stride Based Speed and Distance Monitor profile common data + * @{ + * @ingroup ant_sdk_profiles_sdm_pages + */ + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Data structure for SDM common data. + * + * @details This structure stores data that is not associated with a particular page. + */ +typedef struct +{ + uint16_t speed; ///< Actual speed. + uint32_t distance; ///< Accumulated distance. + uint32_t strides; ///< Accumulated strides. +} ant_sdm_common_data_t; + +/**@brief Initialize common data. + */ +#define DEFAULT_ANT_SDM_COMMON_DATA() \ + (ant_sdm_common_data_t) \ + { \ + .speed = 0, \ + .distance = 0, \ + .strides = 0, \ + } + +/**@brief Function for encoding speed. + * + * This function can be used for pages 2 and 3. + * + * @param[in] p_common_data Pointer to the common data. + * @param[out] p_page_buffer Pointer to the data buffer. + */ +void ant_sdm_speed_encode(uint8_t * p_page_buffer, + ant_sdm_common_data_t const * p_common_data); + +/**@brief Function for decoding speed. + * + * This function can be used for pages 2 and 3. + * + * @param[in] p_page_buffer Pointer to the data buffer. + * @param[out] p_common_data Pointer to the common data. + */ +void ant_sdm_speed_decode(uint8_t const * p_page_buffer, + ant_sdm_common_data_t * p_common_data); + + +#ifdef __cplusplus +} +#endif + +#endif // ANT_SDM_COMMON_DATA_H__ +/** @} */ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_1.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_1.c new file mode 100644 index 0000000..b2e4eed --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_1.c @@ -0,0 +1,144 @@ +/** + * 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. + * + */ +#include "sdk_common.h" +#if NRF_MODULE_ENABLED(ANT_SDM) + +#include "ant_sdm_page_1.h" +#include "ant_sdm_utils.h" + +#define NRF_LOG_MODULE_NAME ant_sdm +#if ANT_SDM_LOG_ENABLED +#define NRF_LOG_LEVEL ANT_SDM_LOG_LEVEL +#define NRF_LOG_INFO_COLOR ANT_SDM_INFO_COLOR +#else // ANT_SDM_LOG_ENABLED +#define NRF_LOG_LEVEL 0 +#endif // ANT_SDM_LOG_ENABLED +#include "nrf_log.h" + +/**@brief SDM page 1 data layout structure. */ +typedef struct +{ + uint8_t time_fractional; + uint8_t time_integer; + uint8_t distance_integer; + uint8_t reserved0 : 4; + uint8_t distance_fractional : 4; + uint8_t reserved1; + uint8_t strides; + uint8_t update_latency; +}ant_sdm_page1_data_layout_t; + +STATIC_ASSERT(ANT_SDM_UPDATE_LATENCY_DISP_PRECISION == 1000); ///< Display format need to be updated +STATIC_ASSERT(ANT_SDM_TIME_DISP_PRECISION == 1000); ///< Display format need to be updated +STATIC_ASSERT(ANT_SDM_DISTANCE_DISP_PRECISION == 10); ///< Display format need to be updated + +/**@brief Function for tracing page 1 and common data. + * + * @param[in] p_common_data Pointer to the common data. + * @param[in] p_page_data Pointer to the page 1 data. + */ +static void page_1_data_log(ant_sdm_page1_data_t const * p_page_data, + ant_sdm_common_data_t const * p_common_data) +{ + uint32_t strides = p_common_data->strides; + uint64_t distance = ANT_SDM_DISTANCE_RESCALE(p_common_data->distance); + uint16_t update_latency = ANT_SDM_UPDATE_LATENCY_RESCALE(p_page_data->update_latency); + uint32_t time = ANT_SDM_TIME_RESCALE(p_page_data->time); + + NRF_LOG_INFO("Update latency %u.%03u s", + update_latency / ANT_SDM_UPDATE_LATENCY_DISP_PRECISION, + update_latency % ANT_SDM_UPDATE_LATENCY_DISP_PRECISION); + NRF_LOG_INFO("Time %u.%03u s", + (unsigned int)(time / ANT_SDM_TIME_DISP_PRECISION), + (unsigned int)(time % ANT_SDM_TIME_DISP_PRECISION)); + NRF_LOG_INFO("Distance %u.%01um ", + (unsigned int)(distance / ANT_SDM_DISTANCE_DISP_PRECISION), + (unsigned int)(distance % ANT_SDM_DISTANCE_DISP_PRECISION)); + NRF_LOG_INFO("Strides %u", (unsigned int)strides); +} + + +void ant_sdm_page_1_encode(uint8_t * p_page_buffer, + ant_sdm_page1_data_t const * p_page_data, + ant_sdm_common_data_t const * p_common_data) +{ + ant_sdm_page1_data_layout_t * p_outcoming_data = (ant_sdm_page1_data_layout_t *)p_page_buffer; + uint32_t distance = p_common_data->distance; + uint16_t time = p_page_data->time; + + p_outcoming_data->time_fractional = time % ANT_SDM_TIME_UNIT_REVERSAL; + p_outcoming_data->time_integer = time / ANT_SDM_TIME_UNIT_REVERSAL; + p_outcoming_data->distance_integer = + (UINT8_MAX & (distance / ANT_SDM_DISTANCE_UNIT_REVERSAL)); // Only LSB + p_outcoming_data->distance_fractional = distance % ANT_SDM_DISTANCE_UNIT_REVERSAL; + p_outcoming_data->strides = (UINT8_MAX & p_common_data->strides); // Only LSB + p_outcoming_data->update_latency = p_page_data->update_latency; + + page_1_data_log(p_page_data, p_common_data); +} + + +void ant_sdm_page_1_decode(uint8_t const * p_page_buffer, + ant_sdm_page1_data_t * p_page_data, + ant_sdm_common_data_t * p_common_data) +{ + ant_sdm_page1_data_layout_t const * p_incoming_data = + (ant_sdm_page1_data_layout_t *)p_page_buffer; + + uint16_t distance = p_incoming_data->distance_integer * ANT_SDM_DISTANCE_UNIT_REVERSAL + + p_incoming_data->distance_fractional; + uint16_t time = p_incoming_data->time_integer * ANT_SDM_TIME_UNIT_REVERSAL + + p_incoming_data->time_fractional; + + uint8_t prev_strides = p_common_data->strides; + + p_common_data->strides += ((p_incoming_data->strides - prev_strides) & UINT8_MAX); + + uint16_t prev_distance = p_common_data->distance; + p_common_data->distance += ((distance - prev_distance) & 0xFFF); + + p_page_data->update_latency = p_incoming_data->update_latency; + p_page_data->time = time; + p_page_data->strides = p_incoming_data->strides; + + page_1_data_log(p_page_data, p_common_data); +} + +#endif // NRF_MODULE_ENABLED(ANT_SDM) diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_1.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_1.h new file mode 100644 index 0000000..e9afca3 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_1.h @@ -0,0 +1,101 @@ +/** + * 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 ANT_SDM_PAGE_1_H__ +#define ANT_SDM_PAGE_1_H__ + +/** @file + * + * @defgroup ant_sdk_profiles_sdm_page1 Stride Based Speed and Distance Monitor profile page 1 + * @{ + * @ingroup ant_sdk_profiles_sdm_pages + */ + +#include <stdint.h> +#include "ant_sdm_common_data.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Data structure for SDM data page 1. + */ +typedef struct +{ + uint8_t update_latency; ///< Update latency. + uint8_t strides; ///< Strides (writing to this field has no effect). + uint16_t time; ///< Time. +} ant_sdm_page1_data_t; + +/**@brief Initialize page 1. + */ +#define DEFAULT_ANT_SDM_PAGE1() \ + (ant_sdm_page1_data_t) \ + { \ + .update_latency = 0, \ + .time = 0, \ + } + +/**@brief Function for encoding page 1. + * + * @param[in] p_page_data Pointer to the page data. + * @param[in] p_common_data Pointer to the common data. + * @param[out] p_page_buffer Pointer to the data buffer. + */ +void ant_sdm_page_1_encode(uint8_t * p_page_buffer, + ant_sdm_page1_data_t const * p_page_data, + ant_sdm_common_data_t const * p_common_data); + +/**@brief Function for decoding page 1. + * + * @param[in] p_page_buffer Pointer to the data buffer. + * @param[out] p_page_data Pointer to the page data. + * @param[out] p_common_data Pointer to the common data. + */ +void ant_sdm_page_1_decode(uint8_t const * p_page_buffer, + ant_sdm_page1_data_t * p_page_data, + ant_sdm_common_data_t * p_common_data); + + +#ifdef __cplusplus +} +#endif + +#endif // ANT_SDM_PAGE_1_H__ +/** @} */ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_16.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_16.c new file mode 100644 index 0000000..f557db6 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_16.c @@ -0,0 +1,104 @@ +/** + * 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. + * + */ +#include "sdk_common.h" +#if NRF_MODULE_ENABLED(ANT_SDM) + +#include "ant_sdm_page_16.h" +#include "ant_sdm_utils.h" + +#define NRF_LOG_MODULE_NAME ant_sdm +#if ANT_SDM_LOG_ENABLED +#define NRF_LOG_LEVEL ANT_SDM_LOG_LEVEL +#define NRF_LOG_INFO_COLOR ANT_SDM_INFO_COLOR +#else // ANT_SDM_LOG_ENABLED +#define NRF_LOG_LEVEL 0 +#endif // ANT_SDM_LOG_ENABLED +#include "nrf_log.h" + +/**@brief SDM page 16 data layout structure. */ +typedef struct +{ + uint8_t strides[3]; + uint8_t distance[4]; +}ant_sdm_page16_data_layout_t; + +STATIC_ASSERT(ANT_SDM_DISTANCE_DISP_PRECISION == 10); ///< Display format need to be updated + +/**@brief Function for tracing common data. + * + * @param[in] p_common_data Pointer to the common data. + */ +static void page_16_data_log(ant_sdm_common_data_t const * p_common_data) +{ + uint64_t distance = ANT_SDM_DISTANCE_RESCALE(p_common_data->distance); + + NRF_LOG_INFO("Distance %u.%01u m", + (unsigned int)(distance / ANT_SDM_DISTANCE_DISP_PRECISION), + (unsigned int)(distance % ANT_SDM_DISTANCE_DISP_PRECISION)); + NRF_LOG_INFO("Strides %u\r\n\n", + (unsigned int)p_common_data->strides); +} + + +void ant_sdm_page_16_encode(uint8_t * p_page_buffer, + ant_sdm_common_data_t const * p_common_data) +{ + ant_sdm_page16_data_layout_t * p_outcoming_data = (ant_sdm_page16_data_layout_t *)p_page_buffer; + + UNUSED_PARAMETER(uint24_encode(p_common_data->strides, p_outcoming_data->strides)); + UNUSED_PARAMETER(uint32_encode(p_common_data->distance << 4, p_outcoming_data->distance)); + + page_16_data_log(p_common_data); +} + + +void ant_sdm_page_16_decode(uint8_t const * p_page_buffer, + ant_sdm_common_data_t * p_common_data) +{ + ant_sdm_page16_data_layout_t const * p_incoming_data = + (ant_sdm_page16_data_layout_t *)p_page_buffer; + + p_common_data->strides = uint24_decode(p_incoming_data->strides); + p_common_data->distance = uint32_decode(p_incoming_data->distance) >> 4; + + page_16_data_log(p_common_data); +} + +#endif // NRF_MODULE_ENABLED(ANT_SDM) diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_16.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_16.h new file mode 100644 index 0000000..7bb80ee --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_16.h @@ -0,0 +1,79 @@ +/** + * 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 ANT_SDM_PAGE_16_H__ +#define ANT_SDM_PAGE_16_H__ + +/** @file + * + * @defgroup ant_sdk_profiles_sdm_page16 Stride Based Speed and Distance Monitor profile page 16 + * @{ + * @ingroup ant_sdk_profiles_sdm_pages + */ + +#include <stdint.h> +#include "ant_sdm_common_data.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Function for encoding page 16. + * + * @param[in] p_common_data Pointer to the page data. + * @param[out] p_page_buffer Pointer to the data buffer. + */ +void ant_sdm_page_16_encode(uint8_t * p_page_buffer, + ant_sdm_common_data_t const * p_common_data); + +/**@brief Function for decoding page 16. + * + * @param[in] p_page_buffer Pointer to the data buffer. + * @param[out] p_common_data Pointer to the page data. + */ +void ant_sdm_page_16_decode(uint8_t const * p_page_buffer, + ant_sdm_common_data_t * p_common_data); + + +#ifdef __cplusplus +} +#endif + +#endif // ANT_SDM_PAGE_16_H__ +/** @} */ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_2.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_2.c new file mode 100644 index 0000000..5302827 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_2.c @@ -0,0 +1,128 @@ +/** + * 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. + * + */ +#include "sdk_common.h" +#if NRF_MODULE_ENABLED(ANT_SDM) + +#include "ant_sdm_page_2.h" +#include "ant_sdm_utils.h" + +#define NRF_LOG_MODULE_NAME ant_sdm +#if ANT_SDM_LOG_ENABLED +#define NRF_LOG_LEVEL ANT_SDM_LOG_LEVEL +#define NRF_LOG_INFO_COLOR ANT_SDM_INFO_COLOR +#else // ANT_SDM_LOG_ENABLED +#define NRF_LOG_LEVEL 0 +#endif // ANT_SDM_LOG_ENABLED +#include "nrf_log.h" + +/**@brief SDM page 2 data layout structure. */ +typedef struct +{ + uint8_t reserved0[2]; + uint8_t cadence_integer; + uint8_t reserved1 : 4; + uint8_t cadence_fractional : 4; + uint8_t reserved2; + uint8_t reserved3; + uint8_t status; +}ant_sdm_page2_data_layout_t; + +/**@brief Function for page 2 data. + * + * @param[in] p_common_data Pointer to the page 2 data. + */ +static void page_2_data_log(ant_sdm_page2_data_t const * p_page_data) +{ + static const char * p_location[4] = {"Laces", "Midsole", "Other", "Ankle"}; + static const char * p_battery[4] = {"New", "Good", "OK", "Low"}; + static const char * p_health[4] = {"OK", "Error", "Warning", ""}; + static const char * p_state[4] = {"Inactive", "Active", "", ""}; + + uint16_t cadence = ANT_SDM_CADENCE_RESCALE(p_page_data->cadence); + + NRF_LOG_INFO("Status:"); + NRF_LOG_INFO("state: %s", + (uint32_t)p_state[p_page_data->status.items.state]); + NRF_LOG_INFO("health: %s", + (uint32_t)p_health[p_page_data->status.items.health]); + NRF_LOG_INFO("battery: %s", + (uint32_t)p_battery[p_page_data->status.items.battery]); + NRF_LOG_INFO("location: %s", + (uint32_t)p_location[p_page_data->status.items.location]); + NRF_LOG_INFO("Cadence %u.%01u strides/min", + cadence / ANT_SDM_CADENCE_DISP_PRECISION, + cadence % ANT_SDM_CADENCE_DISP_PRECISION); +} + + +void ant_sdm_page_2_encode(uint8_t * p_page_buffer, + ant_sdm_page2_data_t const * p_page_data) +{ + ant_sdm_page2_data_layout_t * p_outcoming_data = (ant_sdm_page2_data_layout_t *)p_page_buffer; + uint8_t status = p_page_data->status.byte; + uint16_t cadence = p_page_data->cadence; + + p_outcoming_data->reserved0[0] = UINT8_MAX; + p_outcoming_data->reserved0[1] = UINT8_MAX; + p_outcoming_data->cadence_integer = cadence / ANT_SDM_CADENCE_UNIT_REVERSAL; + p_outcoming_data->cadence_fractional = cadence % ANT_SDM_CADENCE_UNIT_REVERSAL; + p_outcoming_data->reserved3 = UINT8_MAX; + p_outcoming_data->status = status; + page_2_data_log(p_page_data); +} + + +void ant_sdm_page_2_decode(uint8_t const * p_page_buffer, + ant_sdm_page2_data_t * p_page_data) +{ + ant_sdm_page2_data_layout_t const * p_incoming_data = + (ant_sdm_page2_data_layout_t *)p_page_buffer; + + uint8_t status = p_incoming_data->status; + uint16_t cadence = p_incoming_data->cadence_integer * ANT_SDM_CADENCE_UNIT_REVERSAL + + p_incoming_data->cadence_fractional; + + p_page_data->cadence = cadence; + p_page_data->status.byte = status; + + page_2_data_log(p_page_data); +} + +#endif // NRF_MODULE_ENABLED(ANT_SDM) diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_2.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_2.h new file mode 100644 index 0000000..6243be0 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_2.h @@ -0,0 +1,129 @@ +/** + * 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 ANT_SDM_PAGE_2_H__ +#define ANT_SDM_PAGE_2_H__ + +/** @file + * + * @defgroup ant_sdk_profiles_sdm_page2 Stride Based Speed and Distance Monitor profile page 2 + * @{ + * @ingroup ant_sdk_profiles_sdm_pages + */ + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Data structure for SDM data page 2. + */ +typedef struct +{ + union + { + struct + { + enum + { + ANT_SDM_USE_STATE_INACTIVE = 0x00, + ANT_SDM_USE_STATE_ACTIVE = 0x01, + ANT_SDM_STATE_RESERVED0 = 0x02, + ANT_SDM_STATE_RESERVED1 = 0x03, + } state : 2; ///< Use state. + enum + { + ANT_SDM_HEALTH_OK = 0x00, + ANT_SDM_HEALTH_ERROR = 0x01, + ANT_SDM_HEALTH_WARNING = 0x02, + ANT_SDM_HEALTH_RESERVED = 0x03, + } health : 2; ///< SDM health. + enum + { + ANT_SDM_BATTERY_STATUS_NEW = 0x00, + ANT_SDM_BATTERY_STATUS_GOOD = 0x01, + ANT_SDM_BATTERY_STATUS_OK = 0x02, + ANT_SDM_BATTERY_STATUS_LOW = 0x03, + } battery : 2; ///< Battery status. + enum + { + ANT_SDM_LOCATION_LACES = 0x00, + ANT_SDM_LOCATION_MIDSOLE = 0x01, + ANT_SDM_LOCATION_OTHER = 0x02, + ANT_SDM_LOCATION_ANKLE = 0x03, + } location : 2; ///< Location of the SDM sensor. + } items; + uint8_t byte; + } status; ///< Actual status. + uint16_t cadence; ///< Actual cadence. +} ant_sdm_page2_data_t; + +/**@brief Initialize page 2. + */ +#define DEFAULT_ANT_SDM_PAGE2() \ + (ant_sdm_page2_data_t) \ + { \ + .status.byte = 0, \ + .cadence = 0, \ + } + +/**@brief Function for encoding page 2. + * + * @param[in] p_page_data Pointer to the page data. + * @param[out] p_page_buffer Pointer to the data buffer. + */ +void ant_sdm_page_2_encode(uint8_t * p_page_buffer, + ant_sdm_page2_data_t const * p_page_data); + +/**@brief Function for decoding page 2. + * + * @param[in] p_page_buffer Pointer to the data buffer. + * @param[out] p_page_data Pointer to the page data. + */ +void ant_sdm_page_2_decode(uint8_t const * p_page_buffer, + ant_sdm_page2_data_t * p_page_data); + + +#ifdef __cplusplus +} +#endif + +#endif // ANT_SDM_PAGE_2_H__ +/** @} */ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_22.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_22.c new file mode 100644 index 0000000..4f489e5 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_22.c @@ -0,0 +1,127 @@ +/** + * 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. + * + */ +#include "sdk_common.h" +#if NRF_MODULE_ENABLED(ANT_SDM) + +#include <string.h> +#include "ant_sdm_page_22.h" +#include "ant_sdm_utils.h" + +#define NRF_LOG_MODULE_NAME ant_sdm +#if ANT_SDM_LOG_ENABLED +#define NRF_LOG_LEVEL ANT_SDM_LOG_LEVEL +#define NRF_LOG_INFO_COLOR ANT_SDM_INFO_COLOR +#else // ANT_SDM_LOG_ENABLED +#define NRF_LOG_LEVEL 0 +#endif // ANT_SDM_LOG_ENABLED +#include "nrf_log.h" + +/**@brief SDM page 22 data layout structure. */ +typedef struct +{ + uint8_t capabilities; + uint8_t reserved[6]; +}ant_sdm_page22_data_layout_t; + +/**@brief Function for tracing page 22 data. + * + * @param[in] p_page_data Pointer to the page 22 data. + */ +static void page_22_data_log(ant_sdm_page22_data_t const * p_page_data) +{ + NRF_LOG_INFO("Capabilities: "); + + if (p_page_data->capabilities.items.time_is_valid) + { + NRF_LOG_RAW_INFO(" time"); + } + + if (p_page_data->capabilities.items.distance_is_valid) + { + NRF_LOG_RAW_INFO(" distance"); + } + + if (p_page_data->capabilities.items.speed_is_valid) + { + NRF_LOG_RAW_INFO(" speed"); + } + + if (p_page_data->capabilities.items.latency_is_valid) + { + NRF_LOG_RAW_INFO(" latency"); + } + + if (p_page_data->capabilities.items.cadency_is_valid) + { + NRF_LOG_RAW_INFO(" cadence"); + } + + if (p_page_data->capabilities.items.calorie_is_valid) + { + NRF_LOG_RAW_INFO(" calories"); + } + NRF_LOG_RAW_INFO("\r\n\n"); +} + + +void ant_sdm_page_22_encode(uint8_t * p_page_buffer, + ant_sdm_page22_data_t const * p_page_data) +{ + ant_sdm_page22_data_layout_t * p_outcoming_data = (ant_sdm_page22_data_layout_t *)p_page_buffer; + + p_outcoming_data->capabilities = p_page_data->capabilities.byte; + memset(p_outcoming_data->reserved, UINT8_MAX, sizeof (p_outcoming_data->reserved)); + + page_22_data_log(p_page_data); +} + + +void ant_sdm_page_22_decode(uint8_t const * p_page_buffer, + ant_sdm_page22_data_t * p_page_data) +{ + ant_sdm_page22_data_layout_t const * p_incoming_data = + (ant_sdm_page22_data_layout_t *)p_page_buffer; + + p_page_data->capabilities.byte = p_incoming_data->capabilities; + + page_22_data_log(p_page_data); +} + +#endif // NRF_MODULE_ENABLED(ANT_SDM) diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_22.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_22.h new file mode 100644 index 0000000..42e2697 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_22.h @@ -0,0 +1,106 @@ +/** + * 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 ANT_SDM_PAGE_22_H__ +#define ANT_SDM_PAGE_22_H__ + +/** @file + * + * @defgroup ant_sdk_profiles_sdm_page22 Stride Based Speed and Distance Monitor profile page 22 + * @{ + * @ingroup ant_sdk_profiles_sdm_pages + */ + +#include <stdint.h> +#include <stdbool.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Data structure for SDM data page 22. + */ +typedef struct +{ + union + { + struct + { + bool time_is_valid : 1; ///< Transmitted time is valid. + bool distance_is_valid : 1; ///< Transmitted distance is valid. + bool speed_is_valid : 1; ///< Transmitted speed is valid. + bool latency_is_valid : 1; ///< Transmitted latency is valid. + bool cadency_is_valid : 1; ///< Transmitted cadency is valid. + bool calorie_is_valid : 1; ///< Transmitted calorie is valid. + } items; + uint8_t byte; + } capabilities; +} ant_sdm_page22_data_t; + +/**@brief Initialize page 2. + */ +#define DEFAULT_ANT_SDM_PAGE22() \ + (ant_sdm_page22_data_t) \ + { \ + .capabilities.byte = 0, \ + } + +/**@brief Function for encoding page 22. + * + * @param[in] p_page_data Pointer to the page data. + * @param[out] p_page_buffer Pointer to the data buffer. + */ +void ant_sdm_page_22_encode(uint8_t * p_page_buffer, + ant_sdm_page22_data_t const * p_page_data); + +/**@brief Function for decoding page 22. + * + * @param[in] p_page_buffer Pointer to the data buffer. + * @param[out] p_page_data Pointer to the page data. + */ +void ant_sdm_page_22_decode(uint8_t const * p_page_buffer, + ant_sdm_page22_data_t * p_page_data); + + +#ifdef __cplusplus +} +#endif + +#endif // ANT_SDM_PAGE_22_H__ +/** @} */ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_3.c b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_3.c new file mode 100644 index 0000000..7a3e092 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_3.c @@ -0,0 +1,92 @@ +/** + * 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. + * + */ +#include "sdk_common.h" +#if NRF_MODULE_ENABLED(ANT_SDM) + +#include "ant_sdm_page_3.h" +#include "ant_sdm_utils.h" + +#define NRF_LOG_MODULE_NAME ant_sdm +#if ANT_SDM_LOG_ENABLED +#define NRF_LOG_LEVEL ANT_SDM_LOG_LEVEL +#define NRF_LOG_INFO_COLOR ANT_SDM_INFO_COLOR +#else // ANT_SDM_LOG_ENABLED +#define NRF_LOG_LEVEL 0 +#endif // ANT_SDM_LOG_ENABLED +#include "nrf_log.h" + +/**@brief SDM page 3 data layout structure. */ +typedef struct +{ + uint8_t reserved0[5]; + uint8_t calories; + uint8_t reserved1; +}ant_sdm_page3_data_layout_t; + +static void page_3_data_log(ant_sdm_page3_data_t const * p_page_data) +{ + NRF_LOG_INFO("Calories: %u\r\n\n", p_page_data->calories); +} + + +void ant_sdm_page_3_encode(uint8_t * p_page_buffer, + ant_sdm_page3_data_t const * p_page_data) +{ + ant_sdm_page3_data_layout_t * p_outcoming_data = (ant_sdm_page3_data_layout_t *)p_page_buffer; + + p_outcoming_data->calories = p_page_data->calories; + page_3_data_log(p_page_data); +} + + +void ant_sdm_page_3_decode(uint8_t const * p_page_buffer, + ant_sdm_page3_data_t * p_page_data) +{ + ant_sdm_page3_data_layout_t const * p_incoming_data = + (ant_sdm_page3_data_layout_t *)p_page_buffer; + + uint8_t prev_calories = (uint8_t) p_page_data->calories; + + p_page_data->calories += ((p_incoming_data->calories - prev_calories) & UINT8_MAX); + + page_3_data_log(p_page_data); +} + +#endif // NRF_MODULE_ENABLED(ANT_SDM) diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_3.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_3.h new file mode 100644 index 0000000..0321ee1 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_page_3.h @@ -0,0 +1,93 @@ +/** + * 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 ANT_SDM_PAGE_3_H__ +#define ANT_SDM_PAGE_3_H__ + +/** @file + * + * @defgroup ant_sdk_profiles_sdm_page3 Stride Based Speed and Distance Monitor profile page 3 + * @{ + * @ingroup ant_sdk_profiles_sdm_pages + */ + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Data structure for SDM data page 3. + */ +typedef struct +{ + uint32_t calories; ///< Calories. +} ant_sdm_page3_data_t; + +/**@brief Initialize page 3. + */ +#define DEFAULT_ANT_SDM_PAGE3() \ + (ant_sdm_page3_data_t) \ + { \ + .calories = 0, \ + } + +/**@brief Function for encoding page 3. + * + * @param[in] p_page_data Pointer to the page data. + * @param[out] p_page_buffer Pointer to the data buffer. + */ +void ant_sdm_page_3_encode(uint8_t * p_page_buffer, + ant_sdm_page3_data_t const * p_page_data); + +/**@brief Function for decoding page 3. + * + * @param[in] p_page_buffer Pointer to the data buffer. + * @param[out] p_page_data Pointer to the page data. + */ +void ant_sdm_page_3_decode(uint8_t const * p_page_buffer, + ant_sdm_page3_data_t * p_page_data); + + +#ifdef __cplusplus +} +#endif + +#endif // ANT_SDM_PAGE_3_H__ +/** @} */ diff --git a/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_pages.h b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_pages.h new file mode 100644 index 0000000..55a8643 --- /dev/null +++ b/thirdparty/nRF5_SDK_15.0.0_a53641a/components/ant/ant_profiles/ant_sdm/pages/ant_sdm_pages.h @@ -0,0 +1,70 @@ +/** + * 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 __ANT_SDM_PAGES_H +#define __ANT_SDM_PAGES_H + +/** @file + * + * @defgroup ant_sdk_profiles_sdm_pages Stride Based Speed and Distance Monitor profile pages + * @{ + * @ingroup ant_sdm + * @brief This module implements functions for the SDM data pages. + */ + +#include "ant_sdm_page_1.h" +#include "ant_sdm_page_2.h" +#include "ant_sdm_page_3.h" +#include "ant_sdm_page_16.h" +#include "ant_sdm_page_22.h" +#include "ant_sdm_common_data.h" +#include "ant_common_page_70.h" +#include "ant_common_page_80.h" +#include "ant_common_page_81.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif // __ANT_SDM_PAGES_H +/** @} */ |