初始版本

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,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.
*
*/
#include "sdk_common.h"
#if NRF_MODULE_ENABLED(ANT_BPWR)
#include "ant_bpwr_common_data.h"
#include "ant_bpwr_utils.h"
#define NRF_LOG_MODULE_NAME ant_bpwr_common
#if ANT_BPWR_COMMON_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BPWR_COMMON_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BPWR_COMMON_INFO_COLOR
#else // ANT_BPWR_COMMON_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BPWR_COMMON_LOG_ENABLED
#include "nrf_log.h"
NRF_LOG_MODULE_REGISTER();
/**@brief BPWR common page data layout structure. */
typedef struct
{
uint8_t reserved0[2];
uint8_t instantaneous_cadence;
uint8_t reserved1[4];
}ant_bpwr_cadence_data_layout_t;
/**@brief Function for tracing common data.
*
* @param[in] p_common_data Pointer to the common data.
*/
static void cadence_data_log(ant_bpwr_common_data_t const * p_common_data)
{
if (p_common_data->instantaneous_cadence == 0xFF)
{
NRF_LOG_INFO("instantaneous cadence: -- rpm\r\n\n");
}
else
{
NRF_LOG_INFO("instantaneous cadence: %u rpm\r\n\n",
p_common_data->instantaneous_cadence);
}
}
void ant_bpwr_cadence_encode(uint8_t * p_page_buffer,
ant_bpwr_common_data_t const * p_common_data)
{
ant_bpwr_cadence_data_layout_t * p_outcoming_data = (ant_bpwr_cadence_data_layout_t *)p_page_buffer;
p_outcoming_data->instantaneous_cadence = p_common_data->instantaneous_cadence;
cadence_data_log(p_common_data);
}
void ant_bpwr_cadence_decode(uint8_t const * p_page_buffer,
ant_bpwr_common_data_t * p_common_data)
{
ant_bpwr_cadence_data_layout_t const * p_incoming_data = (ant_bpwr_cadence_data_layout_t *)p_page_buffer;
p_common_data->instantaneous_cadence = p_incoming_data->instantaneous_cadence;
cadence_data_log(p_common_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BPWR)

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_BPWR_COMMON_DATA_H__
#define ANT_BPWR_COMMON_DATA_H__
/** @file
*
* @defgroup ant_sdk_profiles_bpwr_common_data_page Stride Based Speed and Distance Monitor profile common data
* @{
* @ingroup ant_sdk_profiles_bpwr_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for BPWR common data.
*
* @details This structure stores data that is not associated with a particular page.
*/
typedef struct
{
uint8_t instantaneous_cadence; ///< Crank cadence (rpm, 0 - 254, 255-> invalid).
} ant_bpwr_common_data_t;
/**@brief Initialize common data.
*/
#define DEFAULT_ANT_BPWR_COMMON_DATA() \
(ant_bpwr_common_data_t) \
{ \
.instantaneous_cadence = 0, \
}
/**@brief Function for encoding speed.
*
* This function can be used for pages 16, 17, and 18.
*
* @param[in] p_common_data Pointer to the common data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bpwr_cadence_encode(uint8_t * p_page_buffer,
ant_bpwr_common_data_t const * p_common_data);
/**@brief Function for decoding speed.
*
* This function can be used for pages 16, 17, and 18.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_common_data Pointer to the common data.
*/
void ant_bpwr_cadence_decode(uint8_t const * p_page_buffer,
ant_bpwr_common_data_t * p_common_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BPWR_COMMON_DATA_H__
/** @} */

View File

@@ -0,0 +1,286 @@
/**
* 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_BPWR)
#include <string.h>
#include "ant_bpwr_page_1.h"
#define NRF_LOG_MODULE_NAME ant_bpwr_page_1
#if ANT_BPWR_PAGE_1_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BPWR_PAGE_1_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BPWR_PAGE_1_INFO_COLOR
#else // ANT_BPWR_PAGE_1_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BPWR_PAGE_1_LOG_ENABLED
#include "nrf_log.h"
NRF_LOG_MODULE_REGISTER();
/**@brief bicycle power page 1 data layout structure. */
typedef struct
{
uint8_t calibration_id; ///< Calibration request type
union
{
struct
{
uint8_t reserved[6]; ///< Unused, fill by 0xFF.
} general_calib_request;
struct
{
uint8_t auto_zero_status; ///< Status of automatic zero feature of power sensor.
uint8_t reserved[5]; ///< Unused, fill by 0xFF.
} auto_zero_config;
struct
{
uint8_t auto_zero_status; ///< Status of automatic zero feature of power sensor.
uint8_t reserved[3]; ///< Unused, fill by 0xFF.
uint8_t data[2]; ///< Calibration Data.
} general_calib_response;
struct
{
uint8_t enable : 1;
uint8_t status : 1;
uint8_t reserved0 : 6; ///< Unused, fill by 0x00.
uint8_t reserved1[5]; ///< Unused, fill by 0xFF.
} auto_zero_support;
struct
{
uint8_t manufac_spec[6]; ///< Manufacture Specyfic Data.
} custom_calib;
} data;
} ant_bpwr_page1_data_layout_t;
static void page1_data_log(ant_bpwr_page1_data_t const * p_page_data)
{
NRF_LOG_INFO("Calibration id: %u", p_page_data->calibration_id);
switch (p_page_data->calibration_id)
{
case ANT_BPWR_CALIB_ID_MANUAL:
// No implementation needed
break;
case ANT_BPWR_CALIB_ID_MANUAL_SUCCESS:
/* fall through */
case ANT_BPWR_CALIB_ID_FAILED:
NRF_LOG_INFO("General calibration data: %u",
p_page_data->data.general_calib);
/* fall through */
case ANT_BPWR_CALIB_ID_AUTO:
/* fall through */
case ANT_BPWR_CALIB_ID_AUTO_SUPPORT:
switch (p_page_data->auto_zero_status)
{
case ANT_BPWR_AUTO_ZERO_NOT_SUPPORTED:
NRF_LOG_INFO("Auto zero not supported\r\n\n");
break;
case ANT_BPWR_AUTO_ZERO_OFF:
NRF_LOG_INFO("Auto zero off\r\n\n");
break;
case ANT_BPWR_AUTO_ZERO_ON:
NRF_LOG_INFO("Auto zero on\r\n\n");
break;
}
break;
case ANT_BPWR_CALIB_ID_CTF:
NRF_LOG_INFO("Not supported\r\n\n");
break;
case ANT_BPWR_CALIB_ID_CUSTOM_REQ:
/* fall through */
case ANT_BPWR_CALIB_ID_CUSTOM_REQ_SUCCESS:
/* fall through */
case ANT_BPWR_CALIB_ID_CUSTOM_UPDATE:
/* fall through */
case ANT_BPWR_CALIB_ID_CUSTOM_UPDATE_SUCCESS:
NRF_LOG_INFO("Manufacture specyfic: ");
NRF_LOG_HEXDUMP_INFO((uint8_t*)p_page_data->data.custom_calib,
sizeof (p_page_data->data.custom_calib));
break;
default: // shouldn't occur
NRF_LOG_INFO("Unsupported calibration ID\r\n\n");
break;
}
}
void ant_bpwr_page_1_encode(uint8_t * p_page_buffer,
ant_bpwr_page1_data_t const * p_page_data)
{
ant_bpwr_page1_data_layout_t * p_outcoming_data = (ant_bpwr_page1_data_layout_t *)p_page_buffer;
page1_data_log(p_page_data);
p_outcoming_data->calibration_id = p_page_data->calibration_id;
switch (p_page_data->calibration_id)
{
case ANT_BPWR_CALIB_ID_MANUAL:
memset(p_outcoming_data->data.general_calib_request.reserved, 0xFF,
sizeof (p_outcoming_data->data.general_calib_request.reserved));
break;
case ANT_BPWR_CALIB_ID_AUTO:
memset(p_outcoming_data->data.auto_zero_config.reserved, 0xFF,
sizeof (p_outcoming_data->data.auto_zero_config.reserved));
p_outcoming_data->data.auto_zero_config.auto_zero_status =
p_page_data->auto_zero_status;
break;
case ANT_BPWR_CALIB_ID_MANUAL_SUCCESS:
/* fall through */
case ANT_BPWR_CALIB_ID_FAILED:
memset(p_outcoming_data->data.general_calib_response.reserved, 0xFF,
sizeof (p_outcoming_data->data.general_calib_response.reserved));
p_outcoming_data->data.general_calib_response.auto_zero_status =
p_page_data->auto_zero_status;
UNUSED_PARAMETER(uint16_encode(p_page_data->data.general_calib,
p_outcoming_data->data.general_calib_response.data));
break;
case ANT_BPWR_CALIB_ID_CTF:
NRF_LOG_INFO("Not supported");
break;
case ANT_BPWR_CALIB_ID_AUTO_SUPPORT:
memset(p_outcoming_data->data.auto_zero_support.reserved1, 0xFF,
sizeof (p_outcoming_data->data.auto_zero_support.reserved1));
p_outcoming_data->data.auto_zero_support.reserved0 = 0x00;
p_outcoming_data->data.auto_zero_support.enable =
(p_page_data->auto_zero_status == ANT_BPWR_AUTO_ZERO_NOT_SUPPORTED) ? false : true;
p_outcoming_data->data.auto_zero_support.status =
(p_page_data->auto_zero_status == ANT_BPWR_AUTO_ZERO_ON) ? true : false;
break;
case ANT_BPWR_CALIB_ID_CUSTOM_REQ:
/* fall through */
case ANT_BPWR_CALIB_ID_CUSTOM_REQ_SUCCESS:
/* fall through */
case ANT_BPWR_CALIB_ID_CUSTOM_UPDATE:
/* fall through */
case ANT_BPWR_CALIB_ID_CUSTOM_UPDATE_SUCCESS:
memcpy(p_outcoming_data->data.custom_calib.manufac_spec,
(void *)p_page_data->data.custom_calib,
sizeof (p_page_data->data.custom_calib));
break;
default: // shouldn't occur
break;
}
}
void ant_bpwr_page_1_decode(uint8_t const * p_page_buffer,
ant_bpwr_page1_data_t * p_page_data)
{
ant_bpwr_page1_data_layout_t const * p_incoming_data =
(ant_bpwr_page1_data_layout_t *)p_page_buffer;
p_page_data->calibration_id = (ant_bpwr_calib_id_t)p_incoming_data->calibration_id;
switch (p_incoming_data->calibration_id)
{
case ANT_BPWR_CALIB_ID_MANUAL:
// No implementation needed
break;
case ANT_BPWR_CALIB_ID_AUTO:
/* fall through */
p_page_data->auto_zero_status =
(ant_bpwr_auto_zero_status_t)p_incoming_data->data.auto_zero_config.auto_zero_status;
break;
case ANT_BPWR_CALIB_ID_MANUAL_SUCCESS:
/* fall through */
case ANT_BPWR_CALIB_ID_FAILED:
p_page_data->auto_zero_status =
(ant_bpwr_auto_zero_status_t)p_incoming_data->data.general_calib_response.
auto_zero_status;
p_page_data->data.general_calib = uint16_decode(
p_incoming_data->data.general_calib_response.data);
break;
case ANT_BPWR_CALIB_ID_CTF:
NRF_LOG_INFO("Not supported");
break;
case ANT_BPWR_CALIB_ID_AUTO_SUPPORT:
if (p_incoming_data->data.auto_zero_support.enable == false)
{
p_page_data->auto_zero_status = ANT_BPWR_AUTO_ZERO_NOT_SUPPORTED;
}
else if (p_incoming_data->data.auto_zero_support.status)
{
p_page_data->auto_zero_status = ANT_BPWR_AUTO_ZERO_ON;
}
else
{
p_page_data->auto_zero_status = ANT_BPWR_AUTO_ZERO_OFF;
}
break;
case ANT_BPWR_CALIB_ID_CUSTOM_REQ:
/* fall through */
case ANT_BPWR_CALIB_ID_CUSTOM_REQ_SUCCESS:
/* fall through */
case ANT_BPWR_CALIB_ID_CUSTOM_UPDATE:
/* fall through */
case ANT_BPWR_CALIB_ID_CUSTOM_UPDATE_SUCCESS:
memcpy((void *)p_page_data->data.custom_calib,
p_incoming_data->data.custom_calib.manufac_spec,
sizeof (p_page_data->data.custom_calib));
break;
default: // shouldn't occur
break;
}
page1_data_log(p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BPWR)

View File

@@ -0,0 +1,136 @@
/**
* 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_BPWR_PAGE_1_H__
#define ANT_BPWR_PAGE_1_H__
/** @file
*
* @defgroup ant_sdk_profiles_bpwr_page1 Bicycle Power profile page 1
* @{
* @ingroup ant_sdk_profiles_bpwr_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief BPWR Calibration ID.
*/
typedef enum
{
ANT_BPWR_CALIB_ID_NONE = 0x00,
ANT_BPWR_CALIB_ID_MANUAL = 0xAA, ///< Calibration Request: Manual Zero.
ANT_BPWR_CALIB_ID_AUTO = 0xAB, ///< Calibration Request: Auto Zero Configuration.
ANT_BPWR_CALIB_ID_MANUAL_SUCCESS = 0xAC, ///< Calibration Response: Manual Zero Successful.
ANT_BPWR_CALIB_ID_FAILED = 0xAF, ///< Calibration Response: Failed.
ANT_BPWR_CALIB_ID_CTF = 0x10, ///< Crank Torque Frequency (CTF) Power sensor Defined Message.
ANT_BPWR_CALIB_ID_AUTO_SUPPORT = 0x12, ///< Auto Zero Support.
ANT_BPWR_CALIB_ID_CUSTOM_REQ = 0xBA, ///< Custom Calibration Parameter Request.
ANT_BPWR_CALIB_ID_CUSTOM_REQ_SUCCESS = 0xBB, ///< Custom Calibration Parameter Response.
ANT_BPWR_CALIB_ID_CUSTOM_UPDATE = 0xBC, ///< Custom Calibration Parameter Update.
ANT_BPWR_CALIB_ID_CUSTOM_UPDATE_SUCCESS = 0xBD, ///< Custom Calibration Parameter Update Response.
} ant_bpwr_calib_id_t;
/**@brief BPWR Calibration Auto Zero Status.
*/
typedef enum
{
ANT_BPWR_AUTO_ZERO_NOT_SUPPORTED = 0xFF, ///< Auto Zero Not Supported.
ANT_BPWR_AUTO_ZERO_OFF = 0x00, ///< Auto Zero OFF.
ANT_BPWR_AUTO_ZERO_ON = 0x01, ///< Auto Zero ON.
} ant_bpwr_auto_zero_status_t;
/**@brief Data structure for Bicycle Power data page 1.
*/
typedef struct
{
ant_bpwr_calib_id_t calibration_id; ///< Calibration request type.
ant_bpwr_auto_zero_status_t auto_zero_status; ///< Status of automatic zero feature of power sensor.
union
{
int16_t general_calib;
uint8_t custom_calib[6];
} data;
} ant_bpwr_page1_data_t;
/**@brief Initialize page 1.
*/
#define DEFAULT_ANT_BPWR_PAGE1() \
(ant_bpwr_page1_data_t) \
{ \
.calibration_id = ANT_BPWR_CALIB_ID_NONE, \
.auto_zero_status = ANT_BPWR_AUTO_ZERO_NOT_SUPPORTED, \
.data.general_calib = 0x00, \
}
/**@brief Initialize page 1 with the general request.
*/
#define ANT_BPWR_GENERAL_CALIB_REQUEST() \
(ant_bpwr_page1_data_t) \
{ \
.calibration_id = ANT_BPWR_CALIB_ID_MANUAL, \
}
/**@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_bpwr_page_1_encode(uint8_t * p_page_buffer,
ant_bpwr_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_bpwr_page_1_decode(uint8_t const * p_page_buffer,
ant_bpwr_page1_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BPWR_PAGE_1_H__
/** @} */

View File

@@ -0,0 +1,117 @@
/**
* 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_BPWR)
#include "ant_bpwr_page_16.h"
#define NRF_LOG_MODULE_NAME ant_bpwr_page_16
#if ANT_BPWR_PAGE_16_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BPWR_PAGE_16_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BPWR_PAGE_16_INFO_COLOR
#else // ANT_BPWR_PAGE_16_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BPWR_PAGE_16_LOG_ENABLED
#include "nrf_log.h"
NRF_LOG_MODULE_REGISTER();
/**@brief bicycle power page 16 data layout structure. */
typedef struct
{
uint8_t update_event_count;
uint8_t pedal_power;
uint8_t reserved;
uint8_t accumulated_power[2];
uint8_t instantaneous_power[2];
}ant_bpwr_page16_data_layout_t;
static void page16_data_log(ant_bpwr_page16_data_t const * p_page_data)
{
NRF_LOG_INFO("event count: %u", p_page_data->update_event_count);
if (p_page_data->pedal_power.byte != 0xFF)
{
NRF_LOG_INFO("pedal power: %u %%",
p_page_data->pedal_power.items.distribution);
}
else
{
NRF_LOG_INFO("pedal power: --");
}
NRF_LOG_INFO("accumulated power: %u W", p_page_data->accumulated_power);
NRF_LOG_INFO("instantaneous power: %u W", p_page_data->instantaneous_power);
}
void ant_bpwr_page_16_encode(uint8_t * p_page_buffer,
ant_bpwr_page16_data_t const * p_page_data)
{
ant_bpwr_page16_data_layout_t * p_outcoming_data =
(ant_bpwr_page16_data_layout_t *)p_page_buffer;
p_outcoming_data->update_event_count = p_page_data->update_event_count;
p_outcoming_data->pedal_power = p_page_data->pedal_power.byte;
UNUSED_PARAMETER(uint16_encode(p_page_data->accumulated_power,
p_outcoming_data->accumulated_power));
UNUSED_PARAMETER(uint16_encode(p_page_data->instantaneous_power,
p_outcoming_data->instantaneous_power));
page16_data_log(p_page_data);
}
void ant_bpwr_page_16_decode(uint8_t const * p_page_buffer,
ant_bpwr_page16_data_t * p_page_data)
{
ant_bpwr_page16_data_layout_t const * p_incoming_data =
(ant_bpwr_page16_data_layout_t *)p_page_buffer;
p_page_data->update_event_count = p_incoming_data->update_event_count;
p_page_data->pedal_power.byte = p_incoming_data->pedal_power;
p_page_data->accumulated_power = uint16_decode(p_incoming_data->accumulated_power);
p_page_data->instantaneous_power = uint16_decode(p_incoming_data->instantaneous_power);
page16_data_log(p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BPWR)

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.
*
*/
#ifndef ANT_BPWR_PAGE_16_H__
#define ANT_BPWR_PAGE_16_H__
/** @file
*
* @defgroup ant_sdk_profiles_bpwr_page16 Bicycle Power profile page 16
* @{
* @ingroup ant_sdk_profiles_bpwr_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for Bicycle Power data page 16.
*
* @note This structure implements only page 16 specific data.
*/
typedef struct
{
union
{
struct
{
uint8_t distribution : 7; ///< Pedal power distribution (%).
uint8_t differentiation : 1; ///< Pedal differentiation: 1 -> right, 0 -> unknown.
} items;
uint8_t byte;
} pedal_power;
uint8_t update_event_count; ///< Power event count.
uint16_t accumulated_power; ///< Accumulated power (W).
uint16_t instantaneous_power; ///< Instantaneous power (W).
} ant_bpwr_page16_data_t;
/**@brief Initialize page 16.
*/
#define DEFAULT_ANT_BPWR_PAGE16() \
(ant_bpwr_page16_data_t) \
{ \
.update_event_count = 0, \
.pedal_power.items.distribution = 0, \
.pedal_power.items.differentiation = 0, \
.accumulated_power = 0, \
.instantaneous_power = 0, \
}
/**@brief Function for encoding page 16.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bpwr_page_16_encode(uint8_t * p_page_buffer,
ant_bpwr_page16_data_t const * p_page_data);
/**@brief Function for decoding page 16.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_bpwr_page_16_decode(uint8_t const * p_page_buffer,
ant_bpwr_page16_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BPWR_PAGE_16_H__
/** @} */

View File

@@ -0,0 +1,77 @@
/**
* 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_BPWR)
#include "ant_bpwr_page_17.h"
#define NRF_LOG_MODULE_NAME ant_bpwr_page_17
#if ANT_BPWR_PAGE_17_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BPWR_PAGE_17_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BPWR_PAGE_17_INFO_COLOR
#else // ANT_BPWR_PAGE_17_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BPWR_PAGE_17_LOG_ENABLED
#include "nrf_log.h"
NRF_LOG_MODULE_REGISTER();
static void page17_data_log(ant_bpwr_page17_data_t const * p_page_data)
{
NRF_LOG_INFO("Wheel:");
ant_bpwr_page_torque_log((ant_bpwr_page_torque_data_t *) p_page_data);
}
void ant_bpwr_page_17_encode(uint8_t * p_page_buffer,
ant_bpwr_page17_data_t const * p_page_data)
{
ant_bpwr_page_torque_encode(p_page_buffer, (ant_bpwr_page_torque_data_t *)p_page_data);
page17_data_log(p_page_data);
}
void ant_bpwr_page_17_decode(uint8_t const * p_page_buffer,
ant_bpwr_page17_data_t * p_page_data)
{
ant_bpwr_page_torque_decode(p_page_buffer, (ant_bpwr_page_torque_data_t *) p_page_data);
page17_data_log(p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BPWR)

View File

@@ -0,0 +1,89 @@
/**
* 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_BPWR_PAGE_17_H__
#define ANT_BPWR_PAGE_17_H__
/** @file
*
* @defgroup ant_sdk_profiles_bpwr_page17 Bicycle Power profile page 17
* @{
* @ingroup ant_sdk_profiles_bpwr_pages
*/
#include <stdint.h>
#include "ant_bpwr_page_torque.h"
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for Bicycle Power data page 17.
*
* @note This structure implements only page 17 specific data.
*/
typedef ant_bpwr_page_torque_data_t ant_bpwr_page17_data_t;
/**@brief Initialize page 17.
*/
#define DEFAULT_ANT_BPWR_PAGE17() (ant_bpwr_page17_data_t) DEFAULT_ANT_BPWR_PAGE_TORQUE(0, 0, 0, 0)
/**@brief Function for encoding page 17.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bpwr_page_17_encode(uint8_t * p_page_buffer,
ant_bpwr_page17_data_t const * p_page_data);
/**@brief Function for decoding page 17.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_bpwr_page_17_decode(uint8_t const * p_page_buffer,
ant_bpwr_page17_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BPWR_PAGE_17_H__
/** @} */

View File

@@ -0,0 +1,77 @@
/**
* 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_BPWR)
#include "ant_bpwr_page_18.h"
#define NRF_LOG_MODULE_NAME ant_bpwr_page_18
#if ANT_BPWR_PAGE_18_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BPWR_PAGE_18_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BPWR_PAGE_18_INFO_COLOR
#else // ANT_BPWR_PAGE_18_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BPWR_PAGE_18_LOG_ENABLED
#include "nrf_log.h"
NRF_LOG_MODULE_REGISTER();
static void page18_data_log(ant_bpwr_page18_data_t const * p_page_data)
{
NRF_LOG_INFO("Crank:");
ant_bpwr_page_torque_log((ant_bpwr_page_torque_data_t *) p_page_data);
}
void ant_bpwr_page_18_encode(uint8_t * p_page_buffer,
ant_bpwr_page18_data_t const * p_page_data)
{
ant_bpwr_page_torque_encode(p_page_buffer, (ant_bpwr_page_torque_data_t *)p_page_data);
page18_data_log(p_page_data);
}
void ant_bpwr_page_18_decode(uint8_t const * p_page_buffer,
ant_bpwr_page18_data_t * p_page_data)
{
ant_bpwr_page_torque_decode(p_page_buffer, (ant_bpwr_page_torque_data_t *) p_page_data);
page18_data_log(p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BPWR)

View File

@@ -0,0 +1,89 @@
/**
* Copyright (c) 2011 - 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_BPWR_PAGE_18_H__
#define ANT_BPWR_PAGE_18_H__
/** @file
*
* @defgroup ant_sdk_profiles_bpwr_page18 Bicycle Power profile page 18
* @{
* @ingroup ant_sdk_profiles_bpwr_pages
*/
#include <stdint.h>
#include "ant_bpwr_page_torque.h"
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for Bicycle Power data page 18.
*
* @note This structure implements only page 18 specific data.
*/
typedef ant_bpwr_page_torque_data_t ant_bpwr_page18_data_t;
/**@brief Initialize page 18.
*/
#define DEFAULT_ANT_BPWR_PAGE18() (ant_bpwr_page18_data_t) DEFAULT_ANT_BPWR_PAGE_TORQUE(0, 0, 0, 0)
/**@brief Function for encoding page 18.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bpwr_page_18_encode(uint8_t * p_page_buffer,
ant_bpwr_page18_data_t const * p_page_data);
/**@brief Function for decoding page 18.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_bpwr_page_18_decode(uint8_t const * p_page_buffer,
ant_bpwr_page18_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BPWR_PAGE_18_H__
/** @} */

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.
*
*/
#include "sdk_common.h"
#if NRF_MODULE_ENABLED(ANT_BPWR)
#include <stdio.h>
#include "ant_bpwr_page_torque.h"
#include "ant_bpwr_utils.h"
#define NRF_LOG_MODULE_NAME ant_bpwr_page_torque
#if ANT_BPWR_PAGE_TORQUE_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BPWR_PAGE_TORQUE_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BPWR_PAGE_TORQUE_INFO_COLOR
#else // ANT_BPWR_PAGE_TORQUE_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BPWR_PAGE_TORQUE_LOG_ENABLED
#include "nrf_log.h"
NRF_LOG_MODULE_REGISTER();
/**@brief bicycle power page torque data layout structure. */
typedef struct
{
uint8_t update_event_count;
uint8_t tick;
uint8_t reserved;
uint8_t period[2];
uint8_t accumulated_torque[2];
}ant_bpwr_page_torque_data_layout_t;
STATIC_ASSERT(ANT_BPWR_TORQUE_PERIOD_DISP_PRECISION == 1000); ///< Display format need to be updated
STATIC_ASSERT(ANT_BPWR_ACC_TORQUE_DISP_PRECISION == 10); ///< Display format need to be updated
void ant_bpwr_page_torque_log(ant_bpwr_page_torque_data_t const * p_page_data)
{
uint16_t period = ANT_BPWR_TORQUE_PERIOD_RESCALE(p_page_data->period);
uint32_t acc_torque = ANT_BPWR_ACC_TORQUE_RESCALE(p_page_data->accumulated_torque);
NRF_LOG_INFO("event count: %u", p_page_data->update_event_count);
NRF_LOG_INFO("tick: %u", p_page_data->tick);
NRF_LOG_INFO("period: %u.%03us",
(unsigned int)(period / ANT_BPWR_TORQUE_PERIOD_DISP_PRECISION),
(unsigned int)(period % ANT_BPWR_TORQUE_PERIOD_DISP_PRECISION));
NRF_LOG_INFO("accumulated torque: %u.%01uNm",
(unsigned int)(acc_torque / ANT_BPWR_ACC_TORQUE_DISP_PRECISION),
(unsigned int)(acc_torque % ANT_BPWR_ACC_TORQUE_DISP_PRECISION));
}
void ant_bpwr_page_torque_encode(uint8_t * p_page_buffer,
ant_bpwr_page_torque_data_t const * p_page_data)
{
ant_bpwr_page_torque_data_layout_t * p_outcoming_data =
(ant_bpwr_page_torque_data_layout_t *)p_page_buffer;
p_outcoming_data->update_event_count = p_page_data->update_event_count;
p_outcoming_data->tick = p_page_data->tick;
UNUSED_PARAMETER(uint16_encode(p_page_data->period, p_outcoming_data->period));
UNUSED_PARAMETER(uint16_encode(p_page_data->accumulated_torque,
p_outcoming_data->accumulated_torque));
}
void ant_bpwr_page_torque_decode(uint8_t const * p_page_buffer,
ant_bpwr_page_torque_data_t * p_page_data)
{
ant_bpwr_page_torque_data_layout_t const * p_incoming_data =
(ant_bpwr_page_torque_data_layout_t *)p_page_buffer;
p_page_data->update_event_count = p_incoming_data->update_event_count;
p_page_data->tick = p_incoming_data->tick;
p_page_data->period = uint16_decode(p_incoming_data->period);
p_page_data->accumulated_torque = uint16_decode(p_incoming_data->accumulated_torque);
}
#endif // NRF_MODULE_ENABLED(ANT_BPWR)

View File

@@ -0,0 +1,106 @@
/**
* 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_BPWR_PAGE_TORQUE_COMMON_H__
#define ANT_BPWR_PAGE_TORQUE_COMMON_H__
/** @file
*
* @defgroup ant_sdk_profiles_bicycle_p_page_torque Bicycle Power profile pages 17, 18 (commons)
* @{
* @ingroup ant_sdk_profiles_bpwr_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Common data structure for Bicycle Power data pages 17, 18.
*
* @note This structure implements specific data that is common for pages 17, 18.
*/
typedef struct
{
uint8_t update_event_count; ///< Power event count.
uint8_t tick; ///< Wheel/crank revolutions counter.
uint16_t period; ///< Accumulated wheel/crank period (1/2048 s).
uint16_t accumulated_torque; ///< Accumulated wheel/torque (1/32 Nm).
} ant_bpwr_page_torque_data_t;
/**@brief Initialize page torque.
*/
#define DEFAULT_ANT_BPWR_PAGE_TORQUE(up_evt_cnt, def_tick, def_period, acc_torque) \
{ \
.update_event_count = (up_evt_cnt), \
.tick = (def_tick), \
.period = (def_period), \
.accumulated_torque = (acc_torque) \
}
/**@brief Function for encoding pages 17, 18.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bpwr_page_torque_encode(uint8_t * p_page_buffer,
ant_bpwr_page_torque_data_t const * p_page_data);
/**@brief Function for decoding pages 17, 18.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_bpwr_page_torque_decode(uint8_t const * p_page_buffer,
ant_bpwr_page_torque_data_t * p_page_data);
/**@brief Function for logging pages 17, 18.
*
* @param[in] p_page_data Pointer to the page data.
*/
void ant_bpwr_page_torque_log(ant_bpwr_page_torque_data_t const * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BPWR_PAGE_TORQUE_COMMON_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_BPWR_PAGES_H__
#define ANT_BPWR_PAGES_H__
/** @file
*
* @defgroup ant_sdk_profiles_bpwr_pages Bicycle Power profile pages
* @{
* @ingroup ant_bpwr
* @brief This module implements functions for the BPWR data pages.
*/
#include "ant_bpwr_page_1.h" // Calibration message main data page.
#include "ant_bpwr_page_16.h" // Standard power-only page.
#include "ant_bpwr_page_17.h" // Wheel Torque main data page.
#include "ant_bpwr_page_18.h" // Crank Torque main data page.
#include "ant_bpwr_common_data.h" // Instantaneous cadence data.
#include "ant_common_page_80.h" // Manufacturer's information data page.
#include "ant_common_page_81.h" // Product information data page.
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif // ANT_BPWR_PAGES_H__
/** @} */