初始版本

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,346 @@
/**
* 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_config.h"
#if ANT_HRM_ENABLED
#include "nrf_assert.h"
#include "app_error.h"
#include "ant_interface.h"
#include "app_util.h"
#include "ant_hrm.h"
#include "ant_hrm_utils.h"
#include "app_error.h"
#define NRF_LOG_MODULE_NAME ant_hrm
#if ANT_HRM_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_HRM_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_HRM_INFO_COLOR
#else // ANT_HRM_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_HRM_LOG_ENABLED
#include "nrf_log.h"
NRF_LOG_MODULE_REGISTER();
#define BACKGROUND_DATA_INTERVAL 64 /**< The number of main data pages sent between background data page.
Background data page is sent every 65th message. */
#define TX_TOGGLE_DIVISOR 4 /**< The number of messages between changing state of toggle bit. */
/**@brief HRM message data layout structure. */
typedef struct
{
ant_hrm_page_t page_number : 7;
uint8_t toggle_bit : 1;
uint8_t page_payload[7];
} ant_hrm_message_layout_t;
/**@brief Function for initializing the ANT HRM profile instance.
*
* @param[in] p_profile Pointer to the profile instance.
* @param[in] p_channel_config Pointer to the ANT channel configuration structure.
*
* @retval NRF_SUCCESS If initialization was successful. Otherwise, an error code is returned.
*/
static ret_code_t ant_hrm_init(ant_hrm_profile_t * p_profile,
ant_channel_config_t const * p_channel_config)
{
p_profile->channel_number = p_channel_config->channel_number;
p_profile->page_0 = DEFAULT_ANT_HRM_PAGE0();
p_profile->page_1 = DEFAULT_ANT_HRM_PAGE1();
p_profile->page_2 = DEFAULT_ANT_HRM_PAGE2();
p_profile->page_3 = DEFAULT_ANT_HRM_PAGE3();
p_profile->page_4 = DEFAULT_ANT_HRM_PAGE4();
NRF_LOG_INFO("ANT HRM channel %u init", p_profile->channel_number);
return ant_channel_init(p_channel_config);
}
ret_code_t ant_hrm_disp_init(ant_hrm_profile_t * p_profile,
ant_channel_config_t const * p_channel_config,
ant_hrm_evt_handler_t evt_handler)
{
ASSERT(p_profile != NULL);
ASSERT(p_channel_config != NULL);
ASSERT(evt_handler != NULL);
p_profile->evt_handler = evt_handler;
return ant_hrm_init(p_profile, p_channel_config);
}
ret_code_t ant_hrm_sens_init(ant_hrm_profile_t * p_profile,
ant_channel_config_t const * p_channel_config,
ant_hrm_sens_config_t const * p_sens_config)
{
ASSERT(p_profile != NULL);
ASSERT(p_channel_config != NULL);
ASSERT(p_sens_config != NULL);
ASSERT(p_sens_config->p_cb != NULL);
ASSERT(p_sens_config->evt_handler != NULL);
ASSERT((p_sens_config->main_page_number == ANT_HRM_PAGE_0)
|| (p_sens_config->main_page_number == ANT_HRM_PAGE_4));
p_profile->evt_handler = p_sens_config->evt_handler;
p_profile->_cb.p_sens_cb = p_sens_config->p_cb;
ant_hrm_sens_cb_t * p_hrm_cb = p_profile->_cb.p_sens_cb;
p_hrm_cb->page_1_present = p_sens_config->page_1_present;
p_hrm_cb->main_page_number = p_sens_config->main_page_number;
p_hrm_cb->ext_page_number = p_hrm_cb->page_1_present ? ANT_HRM_PAGE_1 : ANT_HRM_PAGE_2;
p_hrm_cb->message_counter = 0;
p_hrm_cb->toggle_bit = true;
return ant_hrm_init(p_profile, p_channel_config);
}
/**@brief Function for getting next page number to send.
*
* @param[in] p_profile Pointer to the profile instance.
*
* @return Next page number.
*/
static ant_hrm_page_t next_page_number_get(ant_hrm_profile_t * p_profile)
{
ant_hrm_sens_cb_t * p_hrm_cb = p_profile->_cb.p_sens_cb;
ant_hrm_page_t page_number;
if (p_hrm_cb->message_counter == (BACKGROUND_DATA_INTERVAL))
{
page_number = p_hrm_cb->ext_page_number;
p_hrm_cb->message_counter = 0;
p_hrm_cb->ext_page_number++;
if (p_hrm_cb->ext_page_number > ANT_HRM_PAGE_3)
{
p_hrm_cb->ext_page_number = p_hrm_cb->page_1_present ? ANT_HRM_PAGE_1 : ANT_HRM_PAGE_2;
}
}
else
{
page_number = p_hrm_cb->main_page_number;
}
if (p_hrm_cb->message_counter % TX_TOGGLE_DIVISOR == 0)
{
p_hrm_cb->toggle_bit ^= 1;
}
p_hrm_cb->message_counter++;
return page_number;
}
/**@brief Function for encoding HRM message.
*
* @note Assume to be call each time when Tx window will occur.
*/
static void sens_message_encode(ant_hrm_profile_t * p_profile, uint8_t * p_message_payload)
{
ant_hrm_message_layout_t * p_hrm_message_payload =
(ant_hrm_message_layout_t *)p_message_payload;
ant_hrm_sens_cb_t * p_hrm_cb = p_profile->_cb.p_sens_cb;
p_hrm_message_payload->page_number = next_page_number_get(p_profile);
p_hrm_message_payload->toggle_bit = p_hrm_cb->toggle_bit;
NRF_LOG_INFO("HRM TX Page number: %u", p_hrm_message_payload->page_number);
ant_hrm_page_0_encode(p_hrm_message_payload->page_payload, &(p_profile->page_0)); // Page 0 is present in each message
switch (p_hrm_message_payload->page_number)
{
case ANT_HRM_PAGE_0:
// No implementation needed
break;
case ANT_HRM_PAGE_1:
ant_hrm_page_1_encode(p_hrm_message_payload->page_payload, &(p_profile->page_1));
break;
case ANT_HRM_PAGE_2:
ant_hrm_page_2_encode(p_hrm_message_payload->page_payload, &(p_profile->page_2));
break;
case ANT_HRM_PAGE_3:
ant_hrm_page_3_encode(p_hrm_message_payload->page_payload, &(p_profile->page_3));
break;
case ANT_HRM_PAGE_4:
ant_hrm_page_4_encode(p_hrm_message_payload->page_payload, &(p_profile->page_4));
break;
default:
return;
}
p_profile->evt_handler(p_profile, (ant_hrm_evt_t)p_hrm_message_payload->page_number);
}
/**@brief Function for setting payload for ANT message and sending it.
*
* @param[in] p_profile Pointer to the profile instance.
*/
static void ant_message_send(ant_hrm_profile_t * p_profile)
{
uint32_t err_code;
uint8_t p_message_payload[ANT_STANDARD_DATA_PAYLOAD_SIZE];
sens_message_encode(p_profile, p_message_payload);
err_code =
sd_ant_broadcast_message_tx(p_profile->channel_number,
sizeof (p_message_payload),
p_message_payload);
APP_ERROR_CHECK(err_code);
}
void ant_hrm_sens_evt_handler(ant_evt_t * p_ant_evt, void * p_context)
{
ant_hrm_profile_t * p_profile = (ant_hrm_profile_t *)p_context;
if (p_ant_evt->channel == p_profile->channel_number)
{
switch (p_ant_evt->event)
{
case EVENT_TX:
ant_message_send(p_profile);
break;
default:
break;
}
}
}
ret_code_t ant_hrm_disp_open(ant_hrm_profile_t * p_profile)
{
ASSERT(p_profile != NULL);
NRF_LOG_INFO("ANT HRM channel %u open", p_profile->channel_number);
return sd_ant_channel_open(p_profile->channel_number);
}
ret_code_t ant_hrm_sens_open(ant_hrm_profile_t * p_profile)
{
ASSERT(p_profile != NULL);
// Fill tx buffer for the first frame
ant_message_send(p_profile);
NRF_LOG_INFO("ANT HRM channel %u open", p_profile->channel_number);
return sd_ant_channel_open(p_profile->channel_number);
}
/**@brief Function for decoding HRM message.
*
* @note Assume to be call each time when Rx window will occur.
*/
static void disp_message_decode(ant_hrm_profile_t * p_profile, uint8_t * p_message_payload)
{
const ant_hrm_message_layout_t * p_hrm_message_payload =
(ant_hrm_message_layout_t *)p_message_payload;
NRF_LOG_INFO("HRM RX Page Number: %u", p_hrm_message_payload->page_number);
ant_hrm_page_0_decode(p_hrm_message_payload->page_payload, &(p_profile->page_0)); // Page 0 is present in each message
switch (p_hrm_message_payload->page_number)
{
case ANT_HRM_PAGE_0:
// No implementation needed
break;
case ANT_HRM_PAGE_1:
ant_hrm_page_1_decode(p_hrm_message_payload->page_payload, &(p_profile->page_1));
break;
case ANT_HRM_PAGE_2:
ant_hrm_page_2_decode(p_hrm_message_payload->page_payload, &(p_profile->page_2));
break;
case ANT_HRM_PAGE_3:
ant_hrm_page_3_decode(p_hrm_message_payload->page_payload, &(p_profile->page_3));
break;
case ANT_HRM_PAGE_4:
ant_hrm_page_4_decode(p_hrm_message_payload->page_payload, &(p_profile->page_4));
break;
default:
return;
}
p_profile->evt_handler(p_profile, (ant_hrm_evt_t)p_hrm_message_payload->page_number);
}
void ant_hrm_disp_evt_handler(ant_evt_t * p_ant_evt, void * p_context)
{
ant_hrm_profile_t * p_profile = ( ant_hrm_profile_t *)p_context;
if (p_ant_evt->channel == p_profile->channel_number)
{
switch (p_ant_evt->event)
{
case EVENT_RX:
if (p_ant_evt->message.ANT_MESSAGE_ucMesgID == MESG_BROADCAST_DATA_ID
|| p_ant_evt->message.ANT_MESSAGE_ucMesgID == MESG_ACKNOWLEDGED_DATA_ID
|| p_ant_evt->message.ANT_MESSAGE_ucMesgID == MESG_BURST_DATA_ID)
{
disp_message_decode(p_profile, p_ant_evt->message.ANT_MESSAGE_aucPayload);
}
break;
default:
break;
}
}
}
#endif // ANT_HRM_ENABLED

View File

@@ -0,0 +1,292 @@
/**
* 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.
*
*/
/** @file
*
* @defgroup ant_hrm Heart Rate Monitor profile
* @{
* @ingroup ant_sdk_profiles
* @brief This module implements the Heart Rate Monitor profile.
*
*/
#ifndef ANT_HRM_H__
#define ANT_HRM_H__
#include <stdint.h>
#include <stdbool.h>
#include "app_util.h"
#include "ant_parameters.h"
#include "nrf_sdh_ant.h"
#include "ant_channel_config.h"
#include "ant_hrm_pages.h"
#include "sdk_errors.h"
#define HRM_DEVICE_TYPE 0x78u ///< Device type reserved for ANT+ heart rate monitor.
#define HRM_ANTPLUS_RF_FREQ 0x39u ///< Frequency, decimal 57 (2457 MHz).
#define HRM_MSG_PERIOD_4Hz 0x1F86u ///< Message period, decimal 8070 (4.06 Hz).
#define HRM_MSG_PERIOD_2Hz 0x3F0Cu ///< Message period, decimal 16140 (2.03 Hz).
#define HRM_MSG_PERIOD_1Hz 0x7E18u ///< Message period, decimal 32280 (1.02 Hz).
#define HRM_EXT_ASSIGN 0x00 ///< ANT ext assign.
#define HRM_DISP_CHANNEL_TYPE CHANNEL_TYPE_SLAVE ///< Display HRM channel type.
#define HRM_SENS_CHANNEL_TYPE CHANNEL_TYPE_MASTER ///< Sensor HRM channel type.
/**@brief Initialize an ANT channel configuration structure for the HRM profile (Display).
*
* @param[in] NAME Name of related instance.
* @param[in] CHANNEL_NUMBER Number of the channel assigned to the profile instance.
* @param[in] TRANSMISSION_TYPE Type of transmission assigned to the profile instance.
* @param[in] DEVICE_NUMBER Number of the device assigned to the profile instance.
* @param[in] NETWORK_NUMBER Number of the network assigned to the profile instance.
* @param[in] HRM_MSG_PERIOD Channel period in 32 kHz counts. The HRM profile supports only the following periods:
* @ref HRM_MSG_PERIOD_4Hz, @ref HRM_MSG_PERIOD_2Hz, @ref HRM_MSG_PERIOD_1Hz.
*/
#define HRM_DISP_CHANNEL_CONFIG_DEF(NAME, \
CHANNEL_NUMBER, \
TRANSMISSION_TYPE, \
DEVICE_NUMBER, \
NETWORK_NUMBER, \
HRM_MSG_PERIOD) \
static const ant_channel_config_t CONCAT_2(NAME,_channel_hrm_disp_config) = \
{ \
.channel_number = (CHANNEL_NUMBER), \
.channel_type = HRM_DISP_CHANNEL_TYPE, \
.ext_assign = HRM_EXT_ASSIGN, \
.rf_freq = HRM_ANTPLUS_RF_FREQ, \
.transmission_type = (TRANSMISSION_TYPE), \
.device_type = HRM_DEVICE_TYPE, \
.device_number = (DEVICE_NUMBER), \
.channel_period = (HRM_MSG_PERIOD), \
.network_number = (NETWORK_NUMBER), \
}
#define HRM_DISP_CHANNEL_CONFIG(NAME) &CONCAT_2(NAME,_channel_hrm_disp_config)
/**@brief Initialize an ANT channel configuration structure for the HRM profile (Sensor).
*
* @param[in] NAME Name of related instance.
* @param[in] CHANNEL_NUMBER Number of the channel assigned to the profile instance.
* @param[in] TRANSMISSION_TYPE Type of transmission assigned to the profile instance.
* @param[in] DEVICE_NUMBER Number of the device assigned to the profile instance.
* @param[in] NETWORK_NUMBER Number of the network assigned to the profile instance.
*/
#define HRM_SENS_CHANNEL_CONFIG_DEF(NAME, \
CHANNEL_NUMBER, \
TRANSMISSION_TYPE, \
DEVICE_NUMBER, \
NETWORK_NUMBER) \
static const ant_channel_config_t CONCAT_2(NAME,_channel_hrm_sens_config) = \
{ \
.channel_number = (CHANNEL_NUMBER), \
.channel_type = HRM_SENS_CHANNEL_TYPE, \
.ext_assign = HRM_EXT_ASSIGN, \
.rf_freq = HRM_ANTPLUS_RF_FREQ, \
.transmission_type = (TRANSMISSION_TYPE), \
.device_type = HRM_DEVICE_TYPE, \
.device_number = (DEVICE_NUMBER), \
.channel_period = HRM_MSG_PERIOD_4Hz, \
.network_number = (NETWORK_NUMBER), \
}
#define HRM_SENS_CHANNEL_CONFIG(NAME) &CONCAT_2(NAME,_channel_hrm_sens_config)
/**@brief Initialize an ANT profile configuration structure for the HRM profile (Sensor).
*
* @param[in] NAME Name of related instance.
* @param[in] PAGE_1_PRESENT Determines whether page 1 is included.
* @param[in] MAIN_PAGE_NUMBER Determines the main data page (@ref ANT_HRM_PAGE_0 or @ref ANT_HRM_PAGE_4).
* @param[in] EVT_HANDLER Event handler to be called for handling events in the HRM profile.
*/
#define HRM_SENS_PROFILE_CONFIG_DEF(NAME, \
PAGE_1_PRESENT, \
MAIN_PAGE_NUMBER, \
EVT_HANDLER) \
static ant_hrm_sens_cb_t CONCAT_2(NAME,_hrm_sens_cb); \
static const ant_hrm_sens_config_t CONCAT_2(NAME,_profile_hrm_sens_config) = \
{ \
.page_1_present = (PAGE_1_PRESENT), \
.main_page_number = (MAIN_PAGE_NUMBER), \
.p_cb = &CONCAT_2(NAME,_hrm_sens_cb), \
.evt_handler = (EVT_HANDLER), \
}
#define HRM_SENS_PROFILE_CONFIG(NAME) &CONCAT_2(NAME,_profile_hrm_sens_config)
/**@brief HRM page number type. */
typedef enum
{
ANT_HRM_PAGE_0, ///< Main data page number 0.
ANT_HRM_PAGE_1, ///< Background data page number 1. This page is optional.
ANT_HRM_PAGE_2, ///< Background data page number 2.
ANT_HRM_PAGE_3, ///< Background data page number 3.
ANT_HRM_PAGE_4 ///< Main data page number 4.
} ant_hrm_page_t;
/**@brief HRM profile event type. */
typedef enum
{
ANT_HRM_PAGE_0_UPDATED = ANT_HRM_PAGE_0, ///< Data page 0 has been updated (Display) or sent (Sensor).
ANT_HRM_PAGE_1_UPDATED = ANT_HRM_PAGE_1, ///< Data page 0 and page 1 have been updated (Display) or sent (Sensor).
ANT_HRM_PAGE_2_UPDATED = ANT_HRM_PAGE_2, ///< Data page 0 and page 2 have been updated (Display) or sent (Sensor).
ANT_HRM_PAGE_3_UPDATED = ANT_HRM_PAGE_3, ///< Data page 0 and page 3 have been updated (Display) or sent (Sensor).
ANT_HRM_PAGE_4_UPDATED = ANT_HRM_PAGE_4, ///< Data page 0 and page 4 have been updated (Display) or sent (Sensor).
} ant_hrm_evt_t;
// Forward declaration of the ant_hrm_profile_t type.
typedef struct ant_hrm_profile_s ant_hrm_profile_t;
/**@brief HRM event handler type. */
typedef void (* ant_hrm_evt_handler_t) (ant_hrm_profile_t *, ant_hrm_evt_t);
#include "ant_hrm_local.h"
#ifdef __cplusplus
extern "C" {
#endif
/**@brief HRM sensor configuration structure. */
typedef struct
{
bool page_1_present; ///< Determines whether page 1 is included.
ant_hrm_page_t main_page_number; ///< Determines the main data page (@ref ANT_HRM_PAGE_0 or @ref ANT_HRM_PAGE_4).
ant_hrm_sens_cb_t * p_cb; ///< Pointer to the data buffer for internal use.
ant_hrm_evt_handler_t evt_handler; ///< Event handler to be called for handling events in the HRM profile.
} ant_hrm_sens_config_t;
/**@brief HRM profile structure. */
struct ant_hrm_profile_s
{
uint8_t channel_number; ///< Channel number assigned to the profile.
union {
void * p_none;
ant_hrm_sens_cb_t * p_sens_cb;
} _cb; ///< Pointer to internal control block.
ant_hrm_evt_handler_t evt_handler; ///< Event handler to be called for handling events in the HRM profile.
ant_hrm_page0_data_t page_0; ///< Page 0.
ant_hrm_page1_data_t page_1; ///< Page 1.
ant_hrm_page2_data_t page_2; ///< Page 2.
ant_hrm_page3_data_t page_3; ///< Page 3.
ant_hrm_page4_data_t page_4; ///< Page 4.
};
/** @name Defines for accessing ant_hrm_profile_t member variables
@{ */
#define HRM_PROFILE_beat_count page_0.beat_count
#define HRM_PROFILE_computed_heart_rate page_0.computed_heart_rate
#define HRM_PROFILE_beat_time page_0.beat_time
#define HRM_PROFILE_operating_time page_1.operating_time
#define HRM_PROFILE_manuf_id page_2.manuf_id
#define HRM_PROFILE_serial_num page_2.serial_num
#define HRM_PROFILE_hw_version page_3.hw_version
#define HRM_PROFILE_sw_version page_3.sw_version
#define HRM_PROFILE_model_num page_3.model_num
#define HRM_PROFILE_manuf_spec page_4.manuf_spec
#define HRM_PROFILE_prev_beat page_4.prev_beat
/** @} */
/**@brief Function for initializing the ANT HRM Display profile instance.
*
* @param[in] p_profile Pointer to the profile instance.
* @param[in] p_channel_config Pointer to the ANT channel configuration structure.
* @param[in] evt_handler Event handler to be called for handling events in the HRM profile.
*
* @retval NRF_SUCCESS If initialization was successful. Otherwise, an error code is returned.
*/
ret_code_t ant_hrm_disp_init(ant_hrm_profile_t * p_profile,
ant_channel_config_t const * p_channel_config,
ant_hrm_evt_handler_t evt_handler);
/**@brief Function for initializing the ANT HRM Sensor profile instance.
*
* @param[in] p_profile Pointer to the profile instance.
* @param[in] p_channel_config Pointer to the ANT channel configuration structure.
* @param[in] p_sens_config Pointer to the HRM sensor configuration structure.
*
* @retval NRF_SUCCESS If initialization was successful. Otherwise, an error code is returned.
*/
ret_code_t ant_hrm_sens_init(ant_hrm_profile_t * p_profile,
ant_channel_config_t const * p_channel_config,
ant_hrm_sens_config_t const * p_sens_config);
/**@brief Function for opening the profile instance channel for ANT HRM Display.
*
* Before calling this function, pages should be configured.
*
* @param[in] p_profile Pointer to the profile instance.
*
* @retval NRF_SUCCESS If the channel was successfully opened. Otherwise, an error code is returned.
*/
ret_code_t ant_hrm_disp_open(ant_hrm_profile_t * p_profile);
/**@brief Function for opening the profile instance channel for ANT HRM Sensor.
*
* Before calling this function, pages should be configured.
*
* @param[in] p_profile Pointer to the profile instance.
*
* @retval NRF_SUCCESS If the channel was successfully opened. Otherwise, an error code is returned.
*/
ret_code_t ant_hrm_sens_open(ant_hrm_profile_t * p_profile);
/**@brief Function for handling the sensor ANT events.
*
* @details This function handles all events from the ANT stack that are of interest to the Heart Rate Monitor Sensor profile.
*
* @param[in] p_ant_evt Event received from the ANT stack.
* @param[in] p_context Pointer to the profile instance.
*/
void ant_hrm_sens_evt_handler(ant_evt_t * p_ant_evt, void * p_context);
/**@brief Function for handling the display ANT events.
*
* @details This function handles all events from the ANT stack that are of interest to the Heart Rate Monitor Display profile.
*
* @param[in] p_ant_evt Event received from the ANT stack.
* @param[in] p_context Pointer to the profile instance.
*/
void ant_hrm_disp_evt_handler(ant_evt_t * p_ant_evt, void * p_context);
#ifdef __cplusplus
}
#endif
#endif // ANT_HRM_H__
/** @} */

View File

@@ -0,0 +1,75 @@
/**
* 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_HRM_LOCAL_H__
#define ANT_HRM_LOCAL_H__
#include <stdint.h>
#include <stdbool.h>
#include "ant_hrm.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @addtogroup ant_hrm
* @{
*/
/** @brief HRM Sensor control block. */
typedef struct
{
uint8_t toggle_bit;
ant_hrm_page_t main_page_number;
uint8_t page_1_present;
ant_hrm_page_t ext_page_number;
uint8_t message_counter;
} ant_hrm_sens_cb_t;
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif // ANT_HRM_LOCAL_H__

View File

@@ -0,0 +1,116 @@
/**
* 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_HRM)
#include "ant_hrm_page_0.h"
#include "ant_hrm_utils.h"
#define NRF_LOG_MODULE_NAME ant_hrm_page_0
#if ANT_HRM_PAGE_0_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_HRM_PAGE_0_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_HRM_PAGE_0_INFO_COLOR
#else // ANT_HRM_PAGE_0_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_HRM_PAGE_0_LOG_ENABLED
#include "nrf_log.h"
NRF_LOG_MODULE_REGISTER();
/**@brief HRM page 0 data layout structure. */
typedef struct
{
uint8_t reserved[3];
uint8_t heart_beat_evt_time_LSB;
uint8_t heart_beat_evt_time_MSB;
uint8_t heart_beat_count;
uint8_t computed_heart_rate;
}ant_hrm_page0_data_layout_t;
/**@brief Function for tracing page 0 and common data.
*
* @param[in] p_common_data Pointer to the common data.
* @param[in] p_page_data Pointer to the page 0 data.
*/
static void page0_data_log(ant_hrm_page0_data_t const * p_page_data)
{
NRF_LOG_INFO("Heart beat count: %u", (unsigned int)p_page_data->beat_count);
NRF_LOG_INFO("Computed heart rate: %u",
(unsigned int) p_page_data->computed_heart_rate);
NRF_LOG_INFO("Heart beat event time: %u.%03us\r\n\n",
(unsigned int) ANT_HRM_BEAT_TIME_SEC(p_page_data->beat_time),
(unsigned int) ANT_HRM_BEAT_TIME_MSEC(p_page_data->beat_time));
}
void ant_hrm_page_0_encode(uint8_t * p_page_buffer,
ant_hrm_page0_data_t const * p_page_data)
{
ant_hrm_page0_data_layout_t * p_outcoming_data = (ant_hrm_page0_data_layout_t *)p_page_buffer;
uint32_t beat_time = p_page_data->beat_time;
p_outcoming_data->reserved[0] = UINT8_MAX;
p_outcoming_data->reserved[1] = UINT8_MAX;
p_outcoming_data->reserved[2] = UINT8_MAX;
p_outcoming_data->heart_beat_evt_time_LSB = (uint8_t)(beat_time & UINT8_MAX);
p_outcoming_data->heart_beat_evt_time_MSB = (uint8_t)((beat_time >> 8) & UINT8_MAX);
p_outcoming_data->heart_beat_count = (uint8_t)p_page_data->beat_count;
p_outcoming_data->computed_heart_rate = (uint8_t)p_page_data->computed_heart_rate;
page0_data_log(p_page_data);
}
void ant_hrm_page_0_decode(uint8_t const * p_page_buffer,
ant_hrm_page0_data_t * p_page_data)
{
ant_hrm_page0_data_layout_t const * p_incoming_data =
(ant_hrm_page0_data_layout_t *)p_page_buffer;
uint32_t beat_time = (uint32_t)((p_incoming_data->heart_beat_evt_time_MSB << 8)
+ p_incoming_data->heart_beat_evt_time_LSB);
p_page_data->beat_count = (uint32_t)p_incoming_data->heart_beat_count;
p_page_data->computed_heart_rate = (uint32_t)p_incoming_data->computed_heart_rate;
p_page_data->beat_time = beat_time;
page0_data_log(p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_HRM)

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_HRM_PAGE_0_H__
#define ANT_HRM_PAGE_0_H__
/** @file
*
* @defgroup ant_sdk_profiles_hrm_page0 HRM profile page 0
* @{
* @ingroup ant_sdk_profiles_hrm_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for HRM data page 0.
*
* This structure is used as a common page.
*/
typedef struct
{
uint8_t beat_count; ///< Beat count.
uint8_t computed_heart_rate; ///< Computed heart rate.
uint16_t beat_time; ///< Beat time.
} ant_hrm_page0_data_t;
/**@brief Initialize page 0.
*/
#define DEFAULT_ANT_HRM_PAGE0() \
(ant_hrm_page0_data_t) \
{ \
.beat_count = 0, \
.computed_heart_rate = 0, \
.beat_time = 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_hrm_page_0_encode(uint8_t * p_page_buffer,
ant_hrm_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_hrm_page_0_decode(uint8_t const * p_page_buffer,
ant_hrm_page0_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_HRM_PAGE_0_H__
/** @} */

View File

@@ -0,0 +1,102 @@
/**
* 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_HRM)
#include "ant_hrm_page_1.h"
#include "ant_hrm_utils.h"
#define NRF_LOG_MODULE_NAME ant_hrm_page_1
#if ANT_HRM_PAGE_1_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_HRM_PAGE_1_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_HRM_PAGE_1_INFO_COLOR
#else // ANT_HRM_PAGE_1_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_HRM_PAGE_1_LOG_ENABLED
#include "nrf_log.h"
NRF_LOG_MODULE_REGISTER();
/**@brief HRM page 1 data layout structure. */
typedef struct
{
uint8_t cumulative_operating_time[3];
uint8_t reserved[4];
}ant_hrm_page1_data_layout_t;
/**@brief Function for tracing page 1 and common data.
*
* @param[in] p_common_data Pointer to the common data.
* @param[in] p_page_data Pointer to the page 1 data.
*/
static void page1_data_log(ant_hrm_page1_data_t const * p_page_data)
{
NRF_LOG_INFO("Cumulative operating time: %ud %uh %um %us\r\n\n",
(unsigned int) ANT_HRM_OPERATING_DAYS(p_page_data->operating_time),
(unsigned int) ANT_HRM_OPERATING_HOURS(p_page_data->operating_time),
(unsigned int) ANT_HRM_OPERATING_MINUTES(p_page_data->operating_time),
(unsigned int) ANT_HRM_OPERATING_SECONDS(p_page_data->operating_time));
}
void ant_hrm_page_1_encode(uint8_t * p_page_buffer,
ant_hrm_page1_data_t const * p_page_data)
{
ant_hrm_page1_data_layout_t * p_outcoming_data = (ant_hrm_page1_data_layout_t *)p_page_buffer;
uint32_t operating_time = p_page_data->operating_time;
UNUSED_PARAMETER(uint24_encode(operating_time, p_outcoming_data->cumulative_operating_time));
page1_data_log(p_page_data);
}
void ant_hrm_page_1_decode(uint8_t const * p_page_buffer,
ant_hrm_page1_data_t * p_page_data)
{
ant_hrm_page1_data_layout_t const * p_incoming_data =
(ant_hrm_page1_data_layout_t *)p_page_buffer;
uint32_t operating_time = uint24_decode(p_incoming_data->cumulative_operating_time);
p_page_data->operating_time = operating_time;
page1_data_log(p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_HRM)

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_HRM_PAGE_1_H__
#define ANT_HRM_PAGE_1_H__
/** @file
*
* @defgroup ant_sdk_profiles_hrm_page1 HRM profile page 1
* @{
* @ingroup ant_sdk_profiles_hrm_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for HRM data page 1.
*
* This structure implements only page 1 specific data.
*/
typedef struct
{
uint32_t operating_time; ///< Operating time.
} ant_hrm_page1_data_t;
/**@brief Initialize page 1.
*/
#define DEFAULT_ANT_HRM_PAGE1() \
(ant_hrm_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_hrm_page_1_encode(uint8_t * p_page_buffer,
ant_hrm_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_hrm_page_1_decode(uint8_t const * p_page_buffer,
ant_hrm_page1_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_HRM_PAGE_1_H__
/** @} */

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.
*
*/
#include "sdk_common.h"
#if NRF_MODULE_ENABLED(ANT_HRM)
#include "ant_hrm_page_2.h"
#define NRF_LOG_MODULE_NAME ant_hrm_page_2
#if ANT_HRM_PAGE_2_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_HRM_PAGE_2_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_HRM_PAGE_2_INFO_COLOR
#else // ANT_HRM_PAGE_2_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_HRM_PAGE_2_LOG_ENABLED
#include "nrf_log.h"
NRF_LOG_MODULE_REGISTER();
/**@brief HRM 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_hrm_page2_data_layout_t;
/**@brief Function for tracing page 2 and common data.
*
* @param[in] p_common_data Pointer to the common data.
* @param[in] p_page_data Pointer to the page 2 data.
*/
static void page2_data_log(ant_hrm_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\r\n\n", (unsigned int)p_page_data->serial_num);
}
void ant_hrm_page_2_encode(uint8_t * p_page_buffer,
ant_hrm_page2_data_t const * p_page_data)
{
ant_hrm_page2_data_layout_t * p_outcoming_data = (ant_hrm_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_hrm_page_2_decode(uint8_t const * p_page_buffer,
ant_hrm_page2_data_t * p_page_data)
{
ant_hrm_page2_data_layout_t const * p_incoming_data =
(ant_hrm_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_HRM)

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_HRM_PAGE_2_H__
#define ANT_HRM_PAGE_2_H__
/** @file
*
* @defgroup ant_sdk_profiles_hrm_page2 HRM profile page 2
* @{
* @ingroup ant_sdk_profiles_hrm_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for HRM 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_hrm_page2_data_t;
/**@brief Initialize page 2.
*/
#define DEFAULT_ANT_HRM_PAGE2() \
(ant_hrm_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_hrm_page_2_encode(uint8_t * p_page_buffer,
ant_hrm_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_hrm_page_2_decode(uint8_t const * p_page_buffer,
ant_hrm_page2_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_HRM_PAGE_2_H__
/** @} */

View File

@@ -0,0 +1,103 @@
/**
* 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_HRM)
#include "ant_hrm_page_3.h"
#define NRF_LOG_MODULE_NAME ant_hrm_page_3
#if ANT_HRM_PAGE_3_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_HRM_PAGE_3_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_HRM_PAGE_3_INFO_COLOR
#else // ANT_HRM_PAGE_3_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_HRM_PAGE_3_LOG_ENABLED
#include "nrf_log.h"
NRF_LOG_MODULE_REGISTER();
/**@brief HRM page 3 data layout structure. */
typedef struct
{
uint8_t hw_version;
uint8_t sw_version;
uint8_t model_num;
uint8_t reserved[4];
}ant_hrm_page3_data_layout_t;
/**@brief Function for tracing page 3 and common data.
*
* @param[in] p_common_data Pointer to the common data.
* @param[in] p_page_data Pointer to the page 3 data.
*/
static void page3_data_log(ant_hrm_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 %u", (unsigned int)p_page_data->model_num);
NRF_LOG_INFO("Software Ver ID %u\r\n\n", (unsigned int)p_page_data->sw_version);
}
void ant_hrm_page_3_encode(uint8_t * p_page_buffer,
ant_hrm_page3_data_t const * p_page_data)
{
ant_hrm_page3_data_layout_t * p_outcoming_data = (ant_hrm_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_hrm_page_3_decode(uint8_t const * p_page_buffer,
ant_hrm_page3_data_t * p_page_data)
{
ant_hrm_page3_data_layout_t const * p_incoming_data =
(ant_hrm_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_HRM)

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_HRM_PAGE_3_H__
#define ANT_HRM_PAGE_3_H__
/** @file
*
* @defgroup ant_sdk_profiles_hrm_page3 HRM profile page 3
* @{
* @ingroup ant_sdk_profiles_hrm_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for HRM 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_hrm_page3_data_t;
/**@brief Initialize page 3.
*/
#define DEFAULT_ANT_HRM_PAGE3() \
(ant_hrm_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_hrm_page_3_encode(uint8_t * p_page_buffer,
ant_hrm_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_hrm_page_3_decode(uint8_t const * p_page_buffer,
ant_hrm_page3_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_HRM_PAGE_3_H__
/** @} */

View File

@@ -0,0 +1,107 @@
/**
* 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_HRM)
#include "ant_hrm_page_4.h"
#include "ant_hrm_utils.h"
#define NRF_LOG_MODULE_NAME ant_hrm_page_4
#if ANT_HRM_PAGE_4_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_HRM_PAGE_4_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_HRM_PAGE_4_INFO_COLOR
#else // ANT_HRM_PAGE_4_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_HRM_PAGE_4_LOG_ENABLED
#include "nrf_log.h"
NRF_LOG_MODULE_REGISTER();
/**@brief HRM page 4 data layout structure. */
typedef struct
{
uint8_t manuf_spec;
uint8_t prev_beat_LSB;
uint8_t prev_beat_MSB;
uint8_t reserved[4];
}ant_hrm_page4_data_layout_t;
/**@brief Function for tracing page 4 and common data.
*
* @param[in] p_common_data Pointer to the common data.
* @param[in] p_page_data Pointer to the page 4 data.
*/
static void page4_data_log(ant_hrm_page4_data_t const * p_page_data)
{
NRF_LOG_INFO("Previous heart beat event time: %u.%03us\r\n\n",
(unsigned int)ANT_HRM_BEAT_TIME_SEC(p_page_data->prev_beat),
(unsigned int)ANT_HRM_BEAT_TIME_MSEC(p_page_data->prev_beat));
}
void ant_hrm_page_4_encode(uint8_t * p_page_buffer,
ant_hrm_page4_data_t const * p_page_data)
{
ant_hrm_page4_data_layout_t * p_outcoming_data = (ant_hrm_page4_data_layout_t *)p_page_buffer;
uint32_t prev_beat = p_page_data->prev_beat;
p_outcoming_data->manuf_spec = p_page_data->manuf_spec;
p_outcoming_data->prev_beat_LSB = (uint8_t)(prev_beat & UINT8_MAX);
p_outcoming_data->prev_beat_MSB = (uint8_t)((prev_beat >> 8) & UINT8_MAX);
page4_data_log(p_page_data);
}
void ant_hrm_page_4_decode(uint8_t const * p_page_buffer,
ant_hrm_page4_data_t * p_page_data)
{
ant_hrm_page4_data_layout_t const * p_incoming_data =
(ant_hrm_page4_data_layout_t *)p_page_buffer;
uint32_t prev_beat = (uint32_t)((p_incoming_data->prev_beat_MSB << 8)
+ p_incoming_data->prev_beat_LSB);
p_page_data->manuf_spec = p_incoming_data->manuf_spec;
p_page_data->prev_beat = prev_beat;
page4_data_log(p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_HRM)

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_HRM_PAGE_4_H__
#define ANT_HRM_PAGE_4_H__
/** @file
*
* @defgroup ant_sdk_profiles_hrm_page4 HRM profile page 4
* @{
* @ingroup ant_sdk_profiles_hrm_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for HRM data page 4.
*
* This structure implements only page 4 specific data.
*/
typedef struct
{
uint8_t manuf_spec; ///< Manufacturer specific byte.
uint16_t prev_beat; ///< Previous beat.
} ant_hrm_page4_data_t;
/**@brief Initialize page 4.
*/
#define DEFAULT_ANT_HRM_PAGE4() \
(ant_hrm_page4_data_t) \
{ \
.manuf_spec = 0, \
.prev_beat = 0, \
}
/**@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_hrm_page_4_encode(uint8_t * p_page_buffer,
ant_hrm_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_hrm_page_4_decode(uint8_t const * p_page_buffer,
ant_hrm_page4_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_HRM_PAGE_3_H__
/** @} */

View File

@@ -0,0 +1,67 @@
/**
* 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_HRM_PAGES_H
#define __ANT_HRM_PAGES_H
/** @file
*
* @defgroup ant_sdk_profiles_hrm_pages Heart Rate Monitor profile pages
* @{
* @ingroup ant_hrm
* @brief This module implements functions for the HRM data pages.
*/
#include "ant_hrm_page_0.h"
#include "ant_hrm_page_1.h"
#include "ant_hrm_page_2.h"
#include "ant_hrm_page_3.h"
#include "ant_hrm_page_4.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif // __ANT_HRM_PAGES_H
/** @} */

View File

@@ -0,0 +1,148 @@
/**
* 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_config.h"
#if ANT_HRM_ENABLED
#include "ant_hrm_simulator.h"
#include "ant_hrm_utils.h"
#include "nordic_common.h"
#define ITERATION_ANT_CYCLES HRM_MSG_PERIOD_4Hz ///< period of calculation [1/32678 s], defined in ANT device profile
#define ITERATION_PERIOD (ITERATION_ANT_CYCLES * 1024 / ANT_CLOCK_FREQUENCY) ///< integer part of calculation's period [1/1024 s]
#define ITERATION_FRACTION (ITERATION_ANT_CYCLES * 1024 % ANT_CLOCK_FREQUENCY) ///< fractional part of calculation's period [1/32678 s]
void ant_hrm_simulator_init(ant_hrm_simulator_t * p_simulator,
ant_hrm_simulator_cfg_t const * p_config,
bool auto_change)
{
p_simulator->p_profile = p_config->p_profile;
p_simulator->_cb.sensorsim_cfg = p_config->sensorsim_cfg;
p_simulator->_cb.auto_change = auto_change;
p_simulator->_cb.sensorsim_state.current_val = p_simulator->_cb.sensorsim_cfg.min;
p_simulator->_cb.time_since_last_hb = 0;
p_simulator->_cb.fraction_since_last_hb = 0;
sensorsim_init(&(p_simulator->_cb.sensorsim_state), &(p_simulator->_cb.sensorsim_cfg));
}
void ant_hrm_simulator_one_iteration(ant_hrm_simulator_t * p_simulator)
{
if (p_simulator->_cb.auto_change)
{
UNUSED_PARAMETER(sensorsim_measure(&(p_simulator->_cb.sensorsim_state),
&(p_simulator->_cb.sensorsim_cfg)));
}
// @note: Take a local copy within scope in order to assist the compiler in variable register
// allocation.
const uint32_t computed_heart_rate_value = p_simulator->_cb.sensorsim_state.current_val;
// @note: This implementation assumes that the current instantaneous heart can vary and this
// function is called with static frequency.
// value and the heart rate pulse interval is derived from it. The computation is based on 60
// seconds in a minute and the used time base is 1/1024 seconds.
const uint32_t current_hb_pulse_interval = (60u * 1024u) / computed_heart_rate_value;
// update time from last hb detected
p_simulator->_cb.time_since_last_hb += ITERATION_PERIOD;
// extended celculadion by fraction make calculating accurat in long time perspective
p_simulator->_cb.fraction_since_last_hb += ITERATION_FRACTION;
uint32_t add_period = p_simulator->_cb.fraction_since_last_hb / ANT_CLOCK_FREQUENCY;
if (add_period > 0)
{
p_simulator->_cb.time_since_last_hb++;
p_simulator->_cb.fraction_since_last_hb %= ANT_CLOCK_FREQUENCY;
}
// calc number of hb as will fill
uint32_t new_beats = p_simulator->_cb.time_since_last_hb / current_hb_pulse_interval;
uint32_t add_event_time = new_beats * current_hb_pulse_interval;
if (new_beats > 0)
{
p_simulator->p_profile->HRM_PROFILE_computed_heart_rate =
(uint8_t)computed_heart_rate_value;
// Current heart beat event time is the previous event time added with the current heart rate
// pulse interval.
uint32_t current_heart_beat_event_time = p_simulator->p_profile->HRM_PROFILE_beat_time +
add_event_time;
// Set current event time.
p_simulator->p_profile->HRM_PROFILE_beat_time = current_heart_beat_event_time; // <- B<4,5> <-
// Set previous event time. // p4.B<2,3> <- B<4,5>
p_simulator->p_profile->HRM_PROFILE_prev_beat =
p_simulator->p_profile->HRM_PROFILE_beat_time - current_hb_pulse_interval;
// Event count.
p_simulator->p_profile->HRM_PROFILE_beat_count += new_beats; // B<6>
p_simulator->_cb.time_since_last_hb -= add_event_time;
}
}
void ant_hrm_simulator_increment(ant_hrm_simulator_t * p_simulator)
{
if (!p_simulator->_cb.auto_change)
{
sensorsim_increment(&(p_simulator->_cb.sensorsim_state),
&(p_simulator->_cb.sensorsim_cfg));
}
}
void ant_hrm_simulator_decrement(ant_hrm_simulator_t * p_simulator)
{
if (!p_simulator->_cb.auto_change)
{
sensorsim_decrement(&(p_simulator->_cb.sensorsim_state),
&(p_simulator->_cb.sensorsim_cfg));
}
}
#endif // ANT_HRM_ENABLED

View File

@@ -0,0 +1,130 @@
/**
* 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_HRM_SIMULATOR_H__
#define ANT_HRM_SIMULATOR_H__
/** @file
*
* @defgroup ant_sdk_hrm_simulator ANT HRM simulator
* @{
* @ingroup ant_sdk_simulators
* @brief ANT HRM simulator module.
*
* @details This module simulates a pulse for the ANT HRM profile. The module calculates abstract values, which are handled
* by the HRM pages data model to ensure that they are compatible. It provides a handler for changing the heart rate
* value manually and functionality to change the heart rate value automatically.
*
*/
#include <stdint.h>
#include <stdbool.h>
#include "ant_hrm.h"
#include "ant_hrm_utils.h"
#include "sensorsim.h"
#include "ant_hrm_simulator_local.h"
#ifdef __cplusplus
extern "C" {
#endif
/**@brief HRM simulator configuration structure. */
typedef struct
{
ant_hrm_profile_t * p_profile; ///< Related profile.
sensorsim_cfg_t sensorsim_cfg; ///< Sensorsim configuration.
} ant_hrm_simulator_cfg_t;
/**@brief Initialize @ref ant_hrm_simulator_cfg_t.
*/
#define DEFAULT_ANT_HRM_SIMULATOR_CFG(P_PROFILE, MIN_HEART_RATE, MAX_HEART_RATE, INCREMENT) \
{ \
.p_profile = (P_PROFILE), \
.sensorsim_cfg.min = (MIN_HEART_RATE), \
.sensorsim_cfg.max = (MAX_HEART_RATE), \
.sensorsim_cfg.incr = (INCREMENT), \
.sensorsim_cfg.start_at_max = false, \
}
/**@brief HRM simulator structure. */
typedef struct
{
ant_hrm_profile_t * p_profile; ///< Related profile.
ant_hrm_simulator_cb_t _cb; ///< Internal control block.
} ant_hrm_simulator_t;
/**@brief Function for initializing the ANT HRM simulator instance.
*
* @param[in] p_simulator Pointer to the simulator instance.
* @param[in] p_config Pointer to the simulator configuration structure.
* @param[in] auto_change Enable or disable automatic changes of the cadence.
*/
void ant_hrm_simulator_init(ant_hrm_simulator_t * p_simulator,
ant_hrm_simulator_cfg_t const * p_config,
bool auto_change);
/**@brief Function for simulating a device event.
*
* @details Based on this event, the transmitter data is simulated.
*
* This function should be called in the HRM TX event handler.
*/
void ant_hrm_simulator_one_iteration(ant_hrm_simulator_t * p_simulator);
/**@brief Function for incrementing the cadence value.
*
* @param[in] p_simulator Pointer to the simulator instance.
*/
void ant_hrm_simulator_increment(ant_hrm_simulator_t * p_simulator);
/**@brief Function for decrementing the cadence value.
*
* @param[in] p_simulator Pointer to the simulator instance.
*/
void ant_hrm_simulator_decrement(ant_hrm_simulator_t * p_simulator);
#ifdef __cplusplus
}
#endif
#endif // ANT_HRM_SIMULATOR_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_HRM_SIMULATOR_LOCAL_H__
#define ANT_HRM_SIMULATOR_LOCAL_H__
#include <stdint.h>
#include <stdbool.h>
#include "ant_hrm.h"
#include "sensorsim.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @ingroup ant_sdk_hrm_simulator
* @brief HRM simulator control block structure. */
typedef struct
{
bool auto_change; ///< Cadence will change automatically (if auto_change is set) or manually.
uint32_t time_since_last_hb; ///< Time since last heart beat occurred (integer part).
uint64_t fraction_since_last_hb; ///< Time since last heart beat occurred (fractional part).
sensorsim_state_t sensorsim_state; ///< State of the simulated sensor.
sensorsim_cfg_t sensorsim_cfg; ///< Configuration of the simulated sensor.
} ant_hrm_simulator_cb_t;
#ifdef __cplusplus
}
#endif
#endif // ANT_HRM_SIMULATOR_LOCAL_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.
*
*/
#ifndef ANT_HRM_UTILS_H__
#define ANT_HRM_UTILS_H__
#include "app_util.h"
#include "nrf_assert.h"
#include "nrf.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @file
*
* @defgroup ant_sdk_profiles_hrm_utils Heart Rate Monitor profile utilities
* @{
* @ingroup ant_hrm
* @brief This module implements utilities for the Heart Rate Monitor profile.
*
*/
/**@brief Unit for HRM operating time.
*
* @details According to the ANT HRM specification, the operating time unit is 2 seconds.
*/
#define ANT_HRM_OPERATING_TIME_UNIT 2u
/**@brief This macro should be used to get the seconds part of the operating time.
*/
#define ANT_HRM_OPERATING_SECONDS(OPERATING_TIME) (((OPERATING_TIME) * ANT_HRM_OPERATING_TIME_UNIT) % 60)
/**@brief This macro should be used to get the minutes part of the operating time.
*/
#define ANT_HRM_OPERATING_MINUTES(OPERATING_TIME) ((((OPERATING_TIME) * ANT_HRM_OPERATING_TIME_UNIT) / 60) % 60)
/**@brief This macro should be used to get the hours part of the operating time.
*/
#define ANT_HRM_OPERATING_HOURS(OPERATING_TIME) ((((OPERATING_TIME) * ANT_HRM_OPERATING_TIME_UNIT) / (60 * 60)) % 24)
/**@brief This macro should be used to get the days part of the operating time.
*/
#define ANT_HRM_OPERATING_DAYS(OPERATING_TIME) ((((OPERATING_TIME) * ANT_HRM_OPERATING_TIME_UNIT) / (60 * 60)) / 24)
/**@brief Number of HRM beat time counts per second.
*
* @details According to the ANT HRM specification, the beat time unit is 1/1024 of a second.
*/
#define ANT_HRM_BEAT_TIME_COUNTS_PER_SEC 1024u
/**@brief Beat time display required precision.
*
* @details This value is used to decode the number of milliseconds.
*/
#define ANT_HRM_BEAT_TIME_PRECISION 1000u
/**@brief This macro should be used to get the seconds part of the HRM beat time.
*/
#define ANT_HRM_BEAT_TIME_SEC(BEAT_TIME) ((BEAT_TIME) / ANT_HRM_BEAT_TIME_COUNTS_PER_SEC)
/**@brief This macro should be used to get the milliseconds part of the HRM beat time.
*/
#define ANT_HRM_BEAT_TIME_MSEC(BEAT_TIME) (((((BEAT_TIME) % ANT_HRM_BEAT_TIME_COUNTS_PER_SEC) * ANT_HRM_BEAT_TIME_PRECISION) \
+ (ANT_HRM_BEAT_TIME_COUNTS_PER_SEC / 2)) \
/ ANT_HRM_BEAT_TIME_COUNTS_PER_SEC)
/** @} */
#ifdef __cplusplus
}
#endif
#endif // ANT_HRM_UTILS_H__