Example of ANT HRM TX profile where the user can directly control the computed heart rate value using buttons.
More...
This example is a Heart Rate Monitor (HRM) transmitter simulator. It will transmit the users heart rate information in the main data page (page 4).
A simple user interface exists consisting of 2 keypad buttons, which allow the user to decrease or increase the computed heart rate value.
Device specific information is transmitted at a slower rate in the background data pages (pages 1-3). It will print out profile state information to UART when data is transmitted out of the device.
- HRM specific configuration options
The following compile time configuration options are available to suit various HRM transmitter implementations:
- HRMTX_NETWORK_KEY ANT PLUS network key.
- ANTPLUS_NETWORK_NUMBER Network key associated with the channel.
- HRMTX_ANT_CHANNEL Channel number.
- HRM_DEVICE_NUMBER Device number.
- HRMTX_DEVICE_TYPE Device type.
- HRM_TRANSMISSION_TYPE Transmission type.
- ANTPLUS_RF_FREQ Channel radio frequency offset from 2400 MHz.
- HRMTX_MSG_PERIOD Channel period set to 32 kHz counts.
- Development phase configuration options
The HRM transmitter simulator will trace out state information to UART depending on the selected compile time configuration options.
The following compile time configuration options are available to assist in the development phase of the HRM transmitter implementation:
- TX_PAGE1 - output page 1 data to UART.
- TX_PAGE2 - output page 2 data to UART.
- TX_PAGE3 - output page 3 data to UART.
- TRACE_UART - UART output enabled.
- Note
- The ANT+ Network Key is available for ANT+ Adopters. Please refer to http://thisisant.com to become an ANT+ Adopter and access the key.
#define HRMTX_MSG_PERIOD_IN_MSECS 246u |
HR TX message period in mseconds.
#define HIGH_BYTE |
( |
|
word | ) |
(uint8_t)((word >> 8u) & 0x00FFu) |
Get high byte of a uint16_t.
#define LOW_BYTE |
( |
|
word | ) |
(uint8_t)(word & 0x00FFu) |
Get low byte of a uint16_t.
#define INITIAL_HEART_RATE_VALUE 60u |
Initial value for instantaneous heart rate value.
#define MIN_HEART_RATE_VALUE 1u |
Minimum allowed instantaneous heart rate value.
#define MAX_HEART_RATE_VALUE 255u |
Maximum allowed instantaneous heart rate value.
#define HEART_RATE_VALUE_INCREMENT 2u |
Instantaneous heart rate value increment amount.
Instantaneous heart rate value decrement amount.
#define UART_TX_BUF_SIZE 256u |
#define UART_RX_BUF_SIZE 1u |
#define ANT_EVENT_MSG_BUFFER_MIN_SIZE 32u |
Minimum size of ANT event message buffer.
#define HRMTX_DEVICE_TYPE 0x78 |
#define HRMTX_MSG_PERIOD 0x1F86u |
#define HRMTX_NETWORK_KEY {0, 0, 0, 0, 0, 0, 0, 0} |
The default network key used.
#define APP_TIMER_PRESCALER 0 |
Value of the RTC1 PRESCALER register.
#define APP_TIMER_MAX_TIMERS 1u |
Maximum number of simultaneously created timers.
#define APP_TIMER_OP_QUEUE_SIZE 2u |
Size of timer operation queues.
#define APP_GPIOTE_MAX_USERS 1u |
Maximum number of users of the GPIOTE handler.
Delay from a GPIOTE event until a button is reported as pushed (in number of timer ticks).
#define HRM_DEVICE_NUMBER 49u |
#define HRM_TRANSMISSION_TYPE 5u |
#define HRMTX_ANT_CHANNEL 1u |
#define HRMTX_SERIAL_NUMBER 0xABCDu |
#define HRMTX_HW_VERSION 5u |
#define HRMTX_SW_VERSION 0u |
#define HRMTX_MODEL_NUMBER 2u |
#define ANTPLUS_NETWORK_NUMBER 0 |
#define ANTPLUS_RF_FREQ 0x39u |
Frequency, Decimal 57 (2457 MHz).
static __INLINE void pulse_event_simulate |
( |
void |
| ) |
|
|
static |
Based on this event, the transmitter data is simulated.
uint32_t hrm_tx_open |
( |
void |
| ) |
|
Function for initializing HRM transmitter.
- Return values
-
NRF_SUCCESS | Operation success. |
NRF_ANT_ERROR_CHANNEL_IN_WRONG_STATE | Operation failure. Attempt to perform an action in a wrong channel state. |
NRF_ANT_ERROR_INVALID_NETWORK_NUMBER | Operation failure. Invalid network number provided. |
NRF_ANT_ERROR_INVALID_PARAMETER_PROVIDED | Operation failure. Invalid parameter specified in a configuration message. |
uint32_t hrm_tx_channel_event_handle |
( |
uint32_t |
ant_event | ) |
|
Function for processing ANT channel event.
- Parameters
-
[in] | ant_event | ANT channel event. |
- Return values
-
NRF_SUCCESS | Operation success. |
void softdevice_assert_callback |
( |
uint32_t |
pc, |
|
|
uint16_t |
line_num, |
|
|
const uint8_t * |
p_file_name |
|
) |
| |
Traces out the user supplied parameters and busy loops.
- Parameters
-
[in] | pc | Value of the program counter. |
[in] | line_num | Line number where the assert occurred. |
[in] | p_file_name | Pointer to the file name. |
void app_error_handler |
( |
uint32_t |
error_code, |
|
|
uint32_t |
line_num, |
|
|
const uint8_t * |
p_file_name |
|
) |
| |
Function for error handling, which is called when an error has occurred.
- Parameters
-
[in] | error_code | Error code supplied to the handler. |
[in] | line_num | Line number where the error occurred. |
[in] | p_file_name | Pointer to the file name. |
void button_event_handle |
( |
uint8_t |
pin_no | ) |
|
- Parameters
-
[in] | pin_no | The pin number of the button pressed. |
void PROTOCOL_EVENT_IRQHandler |
( |
void |
| ) |
|
Interrupt is generated by the ANT stack upon sending an event to the application.
void main_hrm_tx_run |
( |
void |
| ) |
|
Function for configuring the device simulator and HRM TX channel, does not return.
uint32_t m_message_counter |
|
static |
uint32_t m_ext_page_number_tracker |
|
static |
Extended page number tracker.
uint32_t m_event_tx_counter |
|
static |
Counter for TX event from the ANT stack.
uint8_t m_tx_buffer[8] = {0} |
|
static |
Instantaneous heart rate value.
volatile bool m_is_ant_event_received |
|
static |
Flag value to determine is ANT stack interrupt received.