初始版本

This commit is contained in:
xiaozhengsheng
2025-08-19 09:49:41 +08:00
parent 10f1ddf1c1
commit 6df0f7d96e
2974 changed files with 1712873 additions and 54 deletions

View File

@@ -0,0 +1,129 @@
/**
* Copyright (c) 2015 - 2020, 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_BSC)
#include "ant_bsc_combined_page_0.h"
#include "ant_bsc_utils.h"
#define NRF_LOG_MODULE_NAME ant_bcs_combined_page_0
#if ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BSC_COMBINED_PAGE_0_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BSC_COMBINED_PAGE_0_INFO_COLOR
#else // ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED
#include "nrf_log.h"
NRF_LOG_MODULE_REGISTER();
/**@brief BSC page 0 data layout structure. */
typedef struct
{
uint8_t cadence_evt_time_LSB;
uint8_t cadence_evt_time_MSB;
uint8_t cadence_rev_count_LSB;
uint8_t cadence_rev_count_MSB;
uint8_t speed_evt_time_LSB;
uint8_t speed_evt_time_MSB;
uint8_t speed_rev_count_LSB;
uint8_t speed_rev_count_MSB;
}ant_bsc_combined_page0_data_layout_t;
/**@brief Function for printing combined speed and cadence page0 data. */
static void comb_page0_data_log(ant_bsc_combined_page0_data_t const * p_page_data)
{
NRF_LOG_INFO("Cadence Revolution count: %u",
(unsigned int)p_page_data->cadence_rev_count);
NRF_LOG_INFO("Cadence event time: %u.%03us",
(unsigned int)ANT_BSC_EVENT_TIME_SEC(p_page_data->cadence_event_time),
(unsigned int)ANT_BSC_EVENT_TIME_MSEC(p_page_data->cadence_event_time));
NRF_LOG_INFO("Speed Revolution count: %u",
(unsigned int)p_page_data->speed_rev_count);
NRF_LOG_INFO("Speed event time: %u.%03us\r\n\n",
(unsigned int)ANT_BSC_EVENT_TIME_SEC(p_page_data->speed_event_time),
(unsigned int)ANT_BSC_EVENT_TIME_MSEC(p_page_data->speed_event_time));
}
void ant_bsc_combined_page_0_encode(uint8_t * p_page_buffer, ant_bsc_combined_page0_data_t const * p_page_data)
{
ant_bsc_combined_page0_data_layout_t * p_outcoming_data = (ant_bsc_combined_page0_data_layout_t *) p_page_buffer;
uint16_t cadence_event_time = p_page_data->cadence_event_time;
uint16_t cadence_rev_count = p_page_data->cadence_rev_count;
uint16_t speed_event_time = p_page_data->speed_event_time;
uint16_t speed_rev_count = p_page_data->speed_rev_count;
p_outcoming_data->cadence_evt_time_LSB = (uint8_t)(cadence_event_time & UINT8_MAX);
p_outcoming_data->cadence_evt_time_MSB = (uint8_t)((cadence_event_time >> 8) & UINT8_MAX);
p_outcoming_data->cadence_rev_count_LSB = (uint8_t)(cadence_rev_count & UINT8_MAX);
p_outcoming_data->cadence_rev_count_MSB = (uint8_t)((cadence_rev_count >> 8) & UINT8_MAX);
p_outcoming_data->speed_evt_time_LSB = (uint8_t)(speed_event_time & UINT8_MAX);
p_outcoming_data->speed_evt_time_MSB = (uint8_t)((speed_event_time >> 8) & UINT8_MAX);
p_outcoming_data->speed_rev_count_LSB = (uint8_t)(speed_rev_count & UINT8_MAX);
p_outcoming_data->speed_rev_count_MSB = (uint8_t)((speed_rev_count >> 8) & UINT8_MAX);
comb_page0_data_log(p_page_data);
}
void ant_bsc_combined_page_0_decode(uint8_t const * p_page_buffer, ant_bsc_combined_page0_data_t * p_page_data)
{
ant_bsc_combined_page0_data_layout_t const * p_incoming_data = (ant_bsc_combined_page0_data_layout_t *)p_page_buffer;
uint16_t cadence_event_time = (uint16_t)((p_incoming_data->cadence_evt_time_MSB << 8)
+ p_incoming_data->cadence_evt_time_LSB);
uint16_t cadence_revolution_count = (uint16_t) ((p_incoming_data->cadence_rev_count_MSB << 8)
+ p_incoming_data->cadence_rev_count_LSB);
uint16_t speed_event_time = (uint16_t)((p_incoming_data->speed_evt_time_MSB << 8)
+ p_incoming_data->speed_evt_time_LSB);
uint16_t speed_revolution_count = (uint16_t) ((p_incoming_data->speed_rev_count_MSB << 8)
+ p_incoming_data->speed_rev_count_LSB);
p_page_data->cadence_event_time = cadence_event_time;
p_page_data->cadence_rev_count = cadence_revolution_count;
p_page_data->speed_event_time = speed_event_time;
p_page_data->speed_rev_count = speed_revolution_count;
comb_page0_data_log(p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BSC)

View File

@@ -0,0 +1,99 @@
/**
* Copyright (c) 2015 - 2020, 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_BSC_COMBINED_PAGE_0_H__
#define ANT_BSC_COMBINED_PAGE_0_H__
/** @file
*
* @defgroup ant_sdk_profiles_bsc_combined_page0 BSC profile page 0 (combined speed & cadence)
* @{
* @ingroup ant_sdk_profiles_bsc_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for Bicycle Combined Speed and Cadence data page 0.
*
* This structure is used as a common page.
*/
typedef struct
{
uint16_t cadence_event_time; ///< Cadence event time.
uint16_t cadence_rev_count; ///< Cadence revolution count.
uint16_t speed_event_time; ///< Speed event time.
uint16_t speed_rev_count; ///< Speed revolution count.
} ant_bsc_combined_page0_data_t;
/**@brief Initialize page 0.
*/
#define DEFAULT_ANT_BSC_COMBINED_PAGE0() \
(ant_bsc_combined_page0_data_t) \
{ \
.cadence_event_time = 0, \
.cadence_rev_count = 0, \
.speed_event_time = 0, \
.speed_rev_count = 0, \
}
/**@brief Function for encoding page 0.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bsc_combined_page_0_encode(uint8_t * p_page_buffer, ant_bsc_combined_page0_data_t const * p_page_data);
/**@brief Function for decoding page 0.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_bsc_combined_page_0_decode(uint8_t const * p_page_buffer, ant_bsc_combined_page0_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BSC_COMBINED_PAGE_0_H__
/** @} */

View File

@@ -0,0 +1,111 @@
/**
* Copyright (c) 2015 - 2020, 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_BSC)
#include "ant_bsc_page_0.h"
#include "ant_bsc_utils.h"
#define NRF_LOG_MODULE_NAME ant_bcs_page_0
#if ANT_BSC_PAGE_0_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BSC_PAGE_0_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BSC_PAGE_0_INFO_COLOR
#else // ANT_BSC_PAGE_0_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BSC_PAGE_0_LOG_ENABLED
#include "nrf_log.h"
NRF_LOG_MODULE_REGISTER();
/**@brief BSC page 0 data layout structure. */
typedef struct
{
uint8_t reserved[3];
uint8_t bsc_evt_time_LSB;
uint8_t bsc_evt_time_MSB;
uint8_t bsc_rev_count_LSB;
uint8_t bsc_rev_count_MSB;
}ant_bsc_page0_data_layout_t;
/**@brief Function for printing speed or cadence page0 data. */
static void page0_data_log(ant_bsc_page0_data_t const * p_page_data)
{
NRF_LOG_INFO("Revolution count: %u", (unsigned int)p_page_data->rev_count);
NRF_LOG_INFO("BSC event time: %u.%03us",
(unsigned int)ANT_BSC_EVENT_TIME_SEC(p_page_data->event_time),
(unsigned int)ANT_BSC_EVENT_TIME_MSEC(p_page_data->event_time));
// NRF_LOG_INFO("%03us", (unsigned int)ANT_BSC_EVENT_TIME_MSEC(p_page_data->event_time));
}
void ant_bsc_page_0_encode(uint8_t * p_page_buffer, ant_bsc_page0_data_t const * p_page_data)
{
ant_bsc_page0_data_layout_t * p_outcoming_data = (ant_bsc_page0_data_layout_t *) p_page_buffer;
uint16_t event_time = p_page_data->event_time;
uint16_t rev_count = p_page_data->rev_count;
p_outcoming_data->reserved[0] = UINT8_MAX;
p_outcoming_data->reserved[1] = UINT8_MAX;
p_outcoming_data->reserved[2] = UINT8_MAX;
p_outcoming_data->bsc_evt_time_LSB = (uint8_t)(event_time & UINT8_MAX);
p_outcoming_data->bsc_evt_time_MSB = (uint8_t)((event_time >> 8) & UINT8_MAX);
p_outcoming_data->bsc_rev_count_LSB = (uint8_t)(rev_count & UINT8_MAX);
p_outcoming_data->bsc_rev_count_MSB = (uint8_t)((rev_count >> 8) & UINT8_MAX);
page0_data_log(p_page_data);
}
void ant_bsc_page_0_decode(uint8_t const * p_page_buffer, ant_bsc_page0_data_t * p_page_data)
{
ant_bsc_page0_data_layout_t const * p_incoming_data = (ant_bsc_page0_data_layout_t *)p_page_buffer;
uint16_t event_time = (uint16_t)((p_incoming_data->bsc_evt_time_MSB << 8)
+ p_incoming_data->bsc_evt_time_LSB);
uint16_t revolution_count = (uint16_t) ((p_incoming_data->bsc_rev_count_MSB << 8)
+ p_incoming_data->bsc_rev_count_LSB);
p_page_data->event_time = event_time;
p_page_data->rev_count = revolution_count;
page0_data_log(p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BSC)

View File

@@ -0,0 +1,95 @@
/**
* Copyright (c) 2015 - 2020, 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_BSC_PAGE_0_H__
#define ANT_BSC_PAGE_0_H__
/** @file
*
* @defgroup ant_sdk_profiles_bsc_page0 BSC profile page 0
* @{
* @ingroup ant_sdk_profiles_bsc_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for BSC data page 0.
*
* This structure is used as a common page.
*/
typedef struct
{
uint16_t event_time; ///< Speed or cadence event time.
uint16_t rev_count; ///< Speed or cadence revolution count.
} ant_bsc_page0_data_t;
/**@brief Initialize page 0.
*/
#define DEFAULT_ANT_BSC_PAGE0() \
(ant_bsc_page0_data_t) \
{ \
.event_time = 0, \
.rev_count = 0 \
}
/**@brief Function for encoding page 0.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bsc_page_0_encode(uint8_t * p_page_buffer, ant_bsc_page0_data_t const * p_page_data);
/**@brief Function for decoding page 0.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_bsc_page_0_decode(uint8_t const * p_page_buffer, ant_bsc_page0_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BSC_PAGE_0_H__
/** @} */

View File

@@ -0,0 +1,94 @@
/**
* Copyright (c) 2015 - 2020, 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_BSC)
#include "ant_bsc_page_1.h"
#include "ant_bsc_utils.h"
#include "app_util.h"
#include "nordic_common.h"
#define NRF_LOG_MODULE_NAME ant_bcs_page_1
#if ANT_BSC_PAGE_1_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BSC_PAGE_1_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BSC_PAGE_1_INFO_COLOR
#else // ANT_BSC_PAGE_1_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BSC_PAGE_1_LOG_ENABLED
#include "nrf_log.h"
NRF_LOG_MODULE_REGISTER();
/**@brief BSC page 1 data layout structure. */
typedef struct
{
uint8_t cumulative_operating_time[3];
uint8_t reserved[4];
}ant_bsc_page1_data_layout_t;
/**@brief Function for printing speed or cadence page1 data. */
static void page1_data_log(ant_bsc_page1_data_t const * p_page_data)
{
NRF_LOG_INFO("Cumulative operating time: %ud %uh %um %us",
(unsigned int)ANT_BSC_OPERATING_DAYS(p_page_data->operating_time),
(unsigned int)ANT_BSC_OPERATING_HOURS(p_page_data->operating_time),
(unsigned int)ANT_BSC_OPERATING_MINUTES(p_page_data->operating_time),
(unsigned int)ANT_BSC_OPERATING_SECONDS(p_page_data->operating_time));
}
void ant_bsc_page_1_encode(uint8_t * p_page_buffer, ant_bsc_page1_data_t const * p_page_data)
{
ant_bsc_page1_data_layout_t * p_outcoming_data = (ant_bsc_page1_data_layout_t *)p_page_buffer;
UNUSED_PARAMETER(uint24_encode(p_page_data->operating_time,
p_outcoming_data->cumulative_operating_time));
page1_data_log( p_page_data);
}
void ant_bsc_page_1_decode(uint8_t const * p_page_buffer, ant_bsc_page1_data_t * p_page_data)
{
ant_bsc_page1_data_layout_t const * p_incoming_data = (ant_bsc_page1_data_layout_t *)p_page_buffer;
p_page_data->operating_time = uint24_decode(p_incoming_data->cumulative_operating_time);
page1_data_log( p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BSC)

View File

@@ -0,0 +1,93 @@
/**
* Copyright (c) 2015 - 2020, 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_BSC_PAGE_1_H__
#define ANT_BSC_PAGE_1_H__
/** @file
*
* @defgroup ant_sdk_profiles_bsc_page1 BSC profile page 1
* @{
* @ingroup ant_sdk_profiles_bsc_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for BSC data page 1.
*
* This structure implements only page 1 specific data.
*/
typedef struct
{
uint32_t operating_time; ///< Operating time.
} ant_bsc_page1_data_t;
/**@brief Initialize page 1.
*/
#define DEFAULT_ANT_BSC_PAGE1() \
(ant_bsc_page1_data_t) \
{ \
.operating_time = 0, \
}
/**@brief Function for encoding page 1.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bsc_page_1_encode(uint8_t * p_page_buffer, ant_bsc_page1_data_t const * p_page_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.
*/
void ant_bsc_page_1_decode(uint8_t const * p_page_buffer, ant_bsc_page1_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BSC_PAGE_1_H__
/** @} */

View File

@@ -0,0 +1,96 @@
/**
* Copyright (c) 2015 - 2020, 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_BSC)
#include "ant_bsc_page_2.h"
#define NRF_LOG_MODULE_NAME ant_bcs_page_2
#if ANT_BSC_PAGE_2_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BSC_PAGE_2_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BSC_PAGE_2_INFO_COLOR
#else // ANT_BSC_PAGE_2_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BSC_PAGE_2_LOG_ENABLED
#include "nrf_log.h"
NRF_LOG_MODULE_REGISTER();
/**@brief BSC page 2 data layout structure. */
typedef struct
{
uint8_t manuf_id;
uint8_t serial_num_LSB;
uint8_t serial_num_MSB;
uint8_t reserved[4];
}ant_bsc_page2_data_layout_t;
/**@brief Function for printing speed or cadence page2 data. */
static void page2_data_log(ant_bsc_page2_data_t const * p_page_data)
{
NRF_LOG_INFO("Manufacturer ID: %u", (unsigned int)p_page_data->manuf_id);
NRF_LOG_INFO("Serial No (upper 16-bits): 0x%X",
(unsigned int)p_page_data->serial_num);
}
void ant_bsc_page_2_encode(uint8_t * p_page_buffer, ant_bsc_page2_data_t const * p_page_data)
{
ant_bsc_page2_data_layout_t * p_outcoming_data = (ant_bsc_page2_data_layout_t *)p_page_buffer;
uint32_t serial_num = p_page_data->serial_num;
p_outcoming_data->manuf_id = (uint8_t)p_page_data->manuf_id;
p_outcoming_data->serial_num_LSB = (uint8_t)(serial_num & UINT8_MAX);
p_outcoming_data->serial_num_MSB = (uint8_t)((serial_num >> 8) & UINT8_MAX);
page2_data_log( p_page_data);
}
void ant_bsc_page_2_decode(uint8_t const * p_page_buffer, ant_bsc_page2_data_t * p_page_data)
{
ant_bsc_page2_data_layout_t const * p_incoming_data = (ant_bsc_page2_data_layout_t *)p_page_buffer;
uint32_t serial_num = (uint32_t)((p_incoming_data->serial_num_MSB << 8)
+ p_incoming_data->serial_num_LSB);
p_page_data->manuf_id = (uint32_t)p_incoming_data->manuf_id;
p_page_data->serial_num = serial_num;
page2_data_log( p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BSC)

View File

@@ -0,0 +1,95 @@
/**
* Copyright (c) 2015 - 2020, 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_BSC_PAGE_2_H__
#define ANT_BSC_PAGE_2_H__
/** @file
*
* @defgroup ant_sdk_profiles_bsc_page2 BSC profile page 2
* @{
* @ingroup ant_sdk_profiles_bsc_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for BSC data page 2.
*
* This structure implements only page 2 specific data.
*/
typedef struct
{
uint8_t manuf_id; ///< Manufacturer ID.
uint16_t serial_num; ///< Serial number.
} ant_bsc_page2_data_t;
/**@brief Initialize page 2.
*/
#define DEFAULT_ANT_BSC_PAGE2() \
(ant_bsc_page2_data_t) \
{ \
.manuf_id = 0, \
.serial_num = 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_bsc_page_2_encode(uint8_t * p_page_buffer, ant_bsc_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_bsc_page_2_decode(uint8_t const * p_page_buffer, ant_bsc_page2_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BSC_PAGE_2_H__
/** @} */

View File

@@ -0,0 +1,94 @@
/**
* Copyright (c) 2015 - 2020, 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_BSC)
#include "ant_bsc_page_3.h"
#define NRF_LOG_MODULE_NAME ant_bcs_page_3
#if ANT_BSC_PAGE_3_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BSC_PAGE_3_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BSC_PAGE_3_INFO_COLOR
#else // ANT_BSC_PAGE_3_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BSC_PAGE_3_LOG_ENABLED
#include "nrf_log.h"
NRF_LOG_MODULE_REGISTER();
/**@brief BSC page 3 data layout structure. */
typedef struct
{
uint8_t hw_version;
uint8_t sw_version;
uint8_t model_num;
uint8_t reserved[4];
}ant_bsc_page3_data_layout_t;
/**@brief Function for printing speed or cadence page3 data. */
static void page3_data_log(ant_bsc_page3_data_t const * p_page_data)
{
NRF_LOG_INFO("Hardware Rev ID: %u", (unsigned int)p_page_data->hw_version);
NRF_LOG_INFO("Model Number: %u", (unsigned int)p_page_data->model_num);
NRF_LOG_INFO("Software Ver ID: %u", (unsigned int)p_page_data->sw_version);
}
void ant_bsc_page_3_encode(uint8_t * p_page_buffer, ant_bsc_page3_data_t const * p_page_data)
{
ant_bsc_page3_data_layout_t * p_outcoming_data = (ant_bsc_page3_data_layout_t *)p_page_buffer;
p_outcoming_data->hw_version = (uint8_t)p_page_data->hw_version;
p_outcoming_data->sw_version = (uint8_t)p_page_data->sw_version;
p_outcoming_data->model_num = (uint8_t)p_page_data->model_num;
page3_data_log( p_page_data);
}
void ant_bsc_page_3_decode(uint8_t const * p_page_buffer, ant_bsc_page3_data_t * p_page_data)
{
ant_bsc_page3_data_layout_t const * p_incoming_data = (ant_bsc_page3_data_layout_t *)p_page_buffer;
p_page_data->hw_version = (uint32_t)p_incoming_data->hw_version;
p_page_data->sw_version = (uint32_t)p_incoming_data->sw_version;
p_page_data->model_num = (uint32_t)p_incoming_data->model_num;
page3_data_log( p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BSC)

View File

@@ -0,0 +1,97 @@
/**
* Copyright (c) 2015 - 2020, 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_BSC_PAGE_3_H__
#define ANT_BSC_PAGE_3_H__
/** @file
*
* @defgroup ant_sdk_profiles_bsc_page3 BSC profile page 3
* @{
* @ingroup ant_sdk_profiles_bsc_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for BSC data page 3.
*
* This structure implements only page 3 specific data.
*/
typedef struct
{
uint8_t hw_version; ///< Hardware version.
uint8_t sw_version; ///< Software version.
uint8_t model_num; ///< Model number.
} ant_bsc_page3_data_t;
/**@brief Initialize page 3.
*/
#define DEFAULT_ANT_BSC_PAGE3() \
(ant_bsc_page3_data_t) \
{ \
.hw_version = 0, \
.sw_version = 0, \
.model_num = 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_bsc_page_3_encode(uint8_t * p_page_buffer, ant_bsc_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_bsc_page_3_decode(uint8_t const * p_page_buffer, ant_bsc_page3_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BSC_PAGE_3_H__
/** @} */

View File

@@ -0,0 +1,104 @@
/**
* Copyright (c) 2015 - 2020, 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_BSC)
#include "ant_bsc_page_4.h"
#include "ant_bsc_utils.h"
#include "app_util.h"
#define NRF_LOG_MODULE_NAME ant_bcs_page_4
#if ANT_BSC_PAGE_4_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BSC_PAGE_4_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BSC_PAGE_4_INFO_COLOR
#else // ANT_BSC_PAGE_4_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BSC_PAGE_4_LOG_ENABLED
#include "nrf_log.h"
NRF_LOG_MODULE_REGISTER();
/**@brief BSC page 4 data layout structure. */
typedef struct
{
uint8_t reserved_byte;
uint8_t fract_bat_volt;
uint8_t coarse_bat_volt : 4;
uint8_t bat_status : 3;
uint8_t bitfield_reserved : 1;
uint8_t reserved[4];
}ant_bsc_page4_data_layout_t;
/* Display precission must be updated. */
STATIC_ASSERT(ANT_BSC_BAT_VOLTAGE_PRECISION == 1000);
/**@brief Function for printing speed or cadence page4 data. */
static void page4_data_log( ant_bsc_page4_data_t const * p_page_data)
{
NRF_LOG_INFO("Battery voltage: %u.%03uV",
(unsigned int)p_page_data->coarse_bat_volt,
(unsigned int)ANT_BSC_BAT_VOLTAGE_FRACTION_MV(p_page_data->fract_bat_volt));
NRF_LOG_INFO("Battery status: %u", (unsigned int)p_page_data->bat_status);
}
void ant_bsc_page_4_encode(uint8_t * p_page_buffer, ant_bsc_page4_data_t const * p_page_data)
{
ant_bsc_page4_data_layout_t * p_outcoming_data = (ant_bsc_page4_data_layout_t *)p_page_buffer;
p_outcoming_data->reserved_byte = UINT8_MAX;
p_outcoming_data->fract_bat_volt = p_page_data->fract_bat_volt;
p_outcoming_data->coarse_bat_volt = p_page_data->coarse_bat_volt;
p_outcoming_data->bat_status = p_page_data->bat_status;
p_outcoming_data->bitfield_reserved = 0;
page4_data_log( p_page_data);
}
void ant_bsc_page_4_decode(uint8_t const * p_page_buffer, ant_bsc_page4_data_t * p_page_data)
{
ant_bsc_page4_data_layout_t const * p_incoming_data = (ant_bsc_page4_data_layout_t *)p_page_buffer;
p_page_data->fract_bat_volt = p_incoming_data->fract_bat_volt;
p_page_data->coarse_bat_volt = p_incoming_data->coarse_bat_volt;
p_page_data->bat_status = p_incoming_data->bat_status;
page4_data_log( p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BSC)

View File

@@ -0,0 +1,113 @@
/**
* Copyright (c) 2015 - 2020, 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_BSC_PAGE_4_H__
#define ANT_BSC_PAGE_4_H__
/** @file
*
* @defgroup ant_sdk_profiles_bsc_page4 BSC profile page 4
* @{
* @ingroup ant_sdk_profiles_bsc_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief BSC profile battery status.
*
* This enum represents possible battery status values for the ANT BSC profile.
*/
typedef enum
{
RESERVED0 = 0, ///< Reserved.
BSC_BAT_STATUS_NEW = 1, ///< Battery status: new.
BSC_BAT_STATUS_GOOD = 2, ///< Battery status: good.
BSC_BAT_STATUS_OK = 3, ///< Battery status: ok.
BSC_BAT_STATUS_LOW = 4, ///< Battery status: low.
BSC_BAT_STATUS_CRITICAL = 5, ///< Battery status: critical.
RESERVED1 = 6, ///< Reserved.
BSC_BAT_STATUS_INVALID = 7 ///< Invalid battery status.
} ant_bsc_bat_status_t;
/**@brief Data structure for BSC data page 4.
*
* This structure implements only page 4 specific data.
*/
typedef struct
{
uint8_t fract_bat_volt; ///< Fractional battery voltage.
uint8_t coarse_bat_volt : 4; ///< Coarse battery voltage.
uint8_t bat_status : 3; ///< Battery status.
} ant_bsc_page4_data_t;
/**@brief Initialize page 4.
*/
#define DEFAULT_ANT_BSC_PAGE4() \
(ant_bsc_page4_data_t) \
{ \
.fract_bat_volt = 0, \
.coarse_bat_volt = 0, \
.bat_status = BSC_BAT_STATUS_INVALID \
}
/**@brief Function for encoding page 4.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bsc_page_4_encode(uint8_t * p_page_buffer, ant_bsc_page4_data_t const * p_page_data);
/**@brief Function for decoding page 4.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_bsc_page_4_decode(uint8_t const * p_page_buffer, ant_bsc_page4_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BSC_PAGE_4_H__
/** @} */

View File

@@ -0,0 +1,97 @@
/**
* Copyright (c) 2015 - 2020, 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_BSC)
#include "ant_bsc_page_5.h"
#include "ant_bsc_utils.h"
#define NRF_LOG_MODULE_NAME ant_bcs_page_5
#if ANT_BSC_PAGE_5_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BSC_PAGE_5_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BSC_PAGE_5_INFO_COLOR
#else // ANT_BSC_PAGE_5_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BSC_PAGE_5_LOG_ENABLED
#include "nrf_log.h"
NRF_LOG_MODULE_REGISTER();
/**@brief BSC profile page 5 bitfields definitions. */
#define ANT_BSC_STOP_IND_MASK 0x01
/**@brief BSC page 5 data layout structure. */
typedef struct
{
uint8_t flags;
uint8_t reserved[6];
}ant_bsc_page5_data_layout_t;
/**@brief Function for printing speed or cadence page5 data. */
static void page5_data_log(ant_bsc_page5_data_t const * p_page_data)
{
if (p_page_data->stop_indicator)
{
NRF_LOG_INFO("Bicycle stopped.");
}
else
{
NRF_LOG_INFO("Bicycle moving.");
}
}
void ant_bsc_page_5_encode(uint8_t * p_page_buffer, ant_bsc_page5_data_t const * p_page_data)
{
ant_bsc_page5_data_layout_t * p_outcoming_data = (ant_bsc_page5_data_layout_t *)p_page_buffer;
p_outcoming_data->flags = (uint8_t)p_page_data->stop_indicator;
page5_data_log( p_page_data);
}
void ant_bsc_page_5_decode(uint8_t const * p_page_buffer, ant_bsc_page5_data_t * p_page_data)
{
ant_bsc_page5_data_layout_t const * p_incoming_data = (ant_bsc_page5_data_layout_t *)p_page_buffer;
p_page_data->stop_indicator = (p_incoming_data->flags) & ANT_BSC_STOP_IND_MASK;
page5_data_log( p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BSC)

View File

@@ -0,0 +1,95 @@
/**
* Copyright (c) 2015 - 2020, 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_BSC_PAGE_5_H__
#define ANT_BSC_PAGE_5_H__
/** @file
*
* @defgroup ant_sdk_profiles_bsc_page5 BSC profile page 5
* @{
* @ingroup ant_sdk_profiles_bsc_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for BSC data page 5.
*
* This structure implements only page 5 specific data.
*/
typedef struct
{
uint8_t stop_indicator:1; ///< Stop indication bit.
uint8_t reserved:7; ///< Reserved.
} ant_bsc_page5_data_t;
/**@brief Initialize page 5.
*/
#define DEFAULT_ANT_BSC_PAGE5() \
(ant_bsc_page5_data_t) \
{ \
.stop_indicator = 0, \
.reserved = 0, \
}
/**@brief Function for encoding page 5.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bsc_page_5_encode(uint8_t * p_page_buffer, ant_bsc_page5_data_t const * p_page_data);
/**@brief Function for decoding page 5.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_bsc_page_5_decode(uint8_t const * p_page_buffer, ant_bsc_page5_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BSC_PAGE_5_H__
/** @} */

View File

@@ -0,0 +1,69 @@
/**
* Copyright (c) 2015 - 2020, 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_BSC_PAGES_H
#define __ANT_BSC_PAGES_H
/** @file
*
* @defgroup ant_sdk_profiles_bsc_pages Bicycle Speed and Cadence profile pages
* @{
* @ingroup ant_bsc
* @brief This module implements functions for the BSC data pages.
*/
#include "ant_bsc_page_0.h"
#include "ant_bsc_page_1.h"
#include "ant_bsc_page_2.h"
#include "ant_bsc_page_3.h"
#include "ant_bsc_page_4.h"
#include "ant_bsc_page_5.h"
#include "ant_bsc_combined_page_0.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif // __ANT_BSC_PAGES_H
/** @} */