The bicycle power minimum receiver implementation.
More...
|
enum | calibration_notif_event_t {
CALIBRATION_NOT_ACTIVE_STATE_ENTER,
CALIBRATION_RESPONSE_TIMEOUT,
CALIBRATION_NOT_ACTIVE_STATE_ENTER,
CALIBRATION_RESPONSE_TIMEOUT
} |
|
enum | antplus_event_t {
ANTPLUS_EVENT_PAGE,
ANTPLUS_EVENT_MAX,
ANTPLUS_EVENT_NONE,
ANTPLUS_EVENT_CALIBRATION_REQUEST,
ANTPLUS_EVENT_PAGE,
ANTPLUS_EVENT_MAX,
ANTPLUS_EVENT_NONE,
ANTPLUS_EVENT_CALIBRATION_REQUEST
} |
| Bicycle Power profile application events. More...
|
|
|
void | bicycle_power_rx_init (void) |
| Function for initializing the module.
|
|
void | bp_rx_calibration_cb_register (calibration_process_callback_t callback) |
| Function for registering a calibration process statemachine callback client. More...
|
|
bool | bp_rx_channel_event_handle (uint32_t event, uint8_t const *const p_event_message_buffer, antplus_event_return_t *p_event_return) |
| Function for processing received ANT channel event message. More...
|
|
void | bp_rx_calibration_start (void) |
| Function for starting manual zero-offset calibration procedure. More...
|
|
void | bp_rx_calibration_tout_handle (void) |
| Function for handling a calibration response timeout event.
|
|
bp_page16_data_t * | bp_rx_data_page16_get (void) |
| Function for getting the reference to data page 16, which is the standard power-only main data page. More...
|
|
bp_page17_data_t * | bp_rx_data_page17_get (void) |
| Function for getting the reference to data page 17, which is the standard wheel torque main data page. More...
|
|
bp_page18_data_t * | bp_rx_data_page18_get (void) |
| Function for getting the reference to data page 18, which is the standard crank torque main data page. More...
|
|
bp_page32_data_t * | bp_rx_data_page32_get (void) |
| Function for getting the reference to data page 32, which is the crank torque frequency (CTF) main data page. More...
|
|
bp_page1_response_data_t * | bp_rx_data_page1_response_get (void) |
| Function for getting the reference to data page 1, which is the general calibration response main data page. More...
|
|
page80_data_t * | bp_rx_data_page80_get (void) |
| Function for getting the reference to data page 80, which is the manufacturer's identification common page. More...
|
|
page81_data_t * | bp_rx_data_page81_get (void) |
| Function for getting the reference to data page 81, which is the product information common page. More...
|
|
void | bicycle_power_rx_main_loop_run (void) |
| Function for running the bicycle power RX main processing loop. Does not return.
|
|
void | softdevice_assert_callback (uint32_t pc, uint16_t line_num, const uint8_t *p_file_name) |
| Function for handling SoftDevice asserts. Does not return. More...
|
|
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. More...
|
|
static __INLINE void | softdevice_setup (void) |
| Function for configuring and setting up the SoftDevice.
|
|
int | main () |
| Function for main application entry. Does not return.
|
|
void | button_event_handle (uint8_t pin_no) |
| Function for handling button events. More...
|
|
static void | calibration_process_cb_handle (calibration_notif_event_t event) |
| Function for handling calibration process statemachine callback events. More...
|
|
static __INLINE void | button_press_handle (void) |
| Function for handling user button presses. More...
|
|
static __INLINE void | bicycle_power_channel_open (void) |
| Function for configuring the ANT channel.
|
|
static __INLINE void | profile_event_page_handle (const antplus_event_return_t *const p_event_return) |
| Function for processing received profile page events. More...
|
|
static __INLINE void | profile_event_handle (const antplus_event_return_t *const p_event_return) |
| Function for processing received profile events. More...
|
|
void | PROTOCOL_EVENT_IRQHandler (void) |
| Function for handling stack interrupts.
|
|
The Bicycle Power receiver implementation implements all of the features, which are required for the receiver to be fully compliant with the ANT+ Bike Power profile, as defined by the ANT+ Bicycle Power Profile specification:
- Receive all power messages (0x10, 0x11, 0x12, 0x20).
- Provide the user a means to initiate and confirm a manual zero-offset calibration procedure (0x01).
- Receive Manufacturer Information (ANT Common Data Page).
- Receive Product Information (ANT Common Data Page).
The general architecture of the bicycle power minimum receiver is illustrated in the picture below.
Architecture overview
- User interface
A simple user interface exists consisting of button0, which allows the user to start a manual zero-offset calibration procedure.
The calibration process statemachine is illustrated in the picture below.
Calibration process statemachine
- Bicycle power receiver configuration options
The following compile time configuration options are available to suit various bicycle power receiver implementations:
- BP_NETWORK_KEY ANT PLUS network key.
- ANTPLUS_NETWORK_NUMBER Network key associated with the channel.
- BP_RX_ANT_CHANNEL Channel number.
- BP_RX_DEVICE_NUMBER Device number.
- BP_DEVICE_TYPE Device type.
- BP_RX_TRANS_TYPE Transmission type.
- BP_RF_FREQ Channel radio frequency offset from 2400 MHz.
- BP_MSG_PERIOD Channel period set to 32 kHz counts.
- Development phase configuration options
The bicycle power receiver will trace profile specific information to the UART depending on the selected compile time configuration options.
The following compile time configuration options are available, and enabled by default, to assist in the development phase of the bicycle power receiver implementation:
- TRACE_UART - Enable UART output.
- TRACE_CALIBRATION - Trace information specific to calibration process.
- TRACE_DATA_PAGE - Trace information specific to received data page.
- 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 BP_RX_ANT_CHANNEL 0 |
Default ANT Channel used.
Calibration message main data page.
Standard Power only main data page.
Wheel Torque (WT) main data page.
Standard Crank Torque (CT) main data page.
Standard Crank Torque Frequency (CTF) main data page.
Calibration ID 0xAA = generic calibration request.
Calibration ID 0xAC = calibration response manual zero success.
Calibration ID 0xAF = calibration response failure.
#define BP_PAGE_RESERVE_BYTE 0xFFu |
#define COMMON_PAGE_80 0x50u |
Manufacturer's identification common data page.
#define COMMON_PAGE_81 0x51u |
Product information common data page.
#define APP_TIMER_PRESCALER 0 |
Value of the RTC1 PRESCALER register.
#define UART_TX_BUF_SIZE 256u |
#define UART_RX_BUF_SIZE 1u |
#define ANTPLUS_NETWORK_NUMBER 0 |
#define ANT_EVENT_MSG_BUFFER_MIN_SIZE 32u |
Minimum size of ANT event message buffer.
#define BP_RX_TRANS_TYPE 0 |
#define BP_RX_DEVICE_NUMBER 0 |
#define BP_DEVICE_TYPE 0x0Bu |
RF Channel 57 (2457 MHz).
#define BP_MSG_PERIOD 0x1FF6u |
#define BP_NETWORK_KEY {0,0,0,0,0,0,0,0} |
#define APP_TIMER_MAX_TIMERS 2u |
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 EVT_BUTTON_0 (1u << 0) |
Event for: button 0 pressed.
#define EVT_CALIBRATION_RESPONSE_TIMEOUT (1u << 1u) |
Event for: calibration response timeout.
#define EVT_ANT_STACK (1u << 2u) |
Event for: ANT stack interrupt received.
Enumerator |
---|
CALIBRATION_NOT_ACTIVE_STATE_ENTER |
Calibration process not running state entry event.
|
CALIBRATION_RESPONSE_TIMEOUT |
Calibration process response timeout event.
|
CALIBRATION_NOT_ACTIVE_STATE_ENTER |
Calibration process not running state entry event.
|
CALIBRATION_RESPONSE_TIMEOUT |
Calibration process response timeout event.
|
Enumerator |
---|
ANTPLUS_EVENT_PAGE |
Received a data page.
|
ANTPLUS_EVENT_MAX |
Upper limit.
|
ANTPLUS_EVENT_NONE |
No event.
|
ANTPLUS_EVENT_CALIBRATION_REQUEST |
Calibration request received event.
|
ANTPLUS_EVENT_PAGE |
Received a data page.
|
ANTPLUS_EVENT_MAX |
Upper limit.
|
ANTPLUS_EVENT_NONE |
No event.
|
ANTPLUS_EVENT_CALIBRATION_REQUEST |
Calibration request received event.
|
void bp_rx_calibration_cb_register |
( |
calibration_process_callback_t |
callback | ) |
|
- Parameters
-
[in] | callback | The callback, which is called when various calibration process statemachine events occur. |
bool bp_rx_channel_event_handle |
( |
uint32_t |
event, |
|
|
uint8_t const *const |
p_event_message_buffer, |
|
|
antplus_event_return_t * |
p_event_return |
|
) |
| |
- Parameters
-
[in] | event | ANT event received. |
[in] | p_event_message_buffer | ANT event message buffer. |
[out] | p_event_return | Output data from the profile. |
- Returns
- true if p_event_return contains valid data, false otherwise.
void bp_rx_calibration_start |
( |
void |
| ) |
|
- Note
- If this method is called when the calibration process is running, the end result is undefined.
- Returns
- Reference to data page 16.
- Returns
- Reference to data page 17.
- Returns
- Reference to data page 18.
- Returns
- Reference to data page 32.
- Returns
- Reference to data page 1 general response.
- Returns
- Reference to data page 80.
- Returns
- Reference to data page 81.
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 occured. |
[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 |
|
) |
| |
- Parameters
-
[in] | error_code | Error code supplied to the handler. |
[in] | line_num | Line number where the handler is called. |
[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. |
- Parameters
-
[in] | event | The event to be handled. |
static __INLINE void button_press_handle |
( |
void |
| ) |
|
|
static |
This function starts the calibration process that is triggered when a user presses a button. Disable the app_button module until the calibration process has been finished.
- Parameters
-
[in] | p_event_return | Profile page event to be processed. |
- Parameters
-
[in] | p_event_return | Profile event to be processed. |
volatile uint32_t m_event_flags = 0 |
|
static |
Event flags used for deferred event processing in application main loop context.