update NRF52832 support NRF52SDK13

This commit is contained in:
xieyangrun committed 2017-05-15 16:12:15 +08:00
1 parent 3aa9796496
commit 0f37b300f5
1241 files changed
+338773 -7268

No files matched your search

-27
View File
@@ -1,27 +0,0 @@
import rtconfig
Import('RTT_ROOT')
from building import *
# get current directory
cwd = GetCurrentDir()
# The set of source files associated with this SConscript file.
src = Split("""
nrf52832/Source/templates/system_nrf52.c
""")
#add for Startup script
if rtconfig.CROSS_TOOL == 'gcc':
src = src + ['nrf52832/Source/templates/arm/gcc_startup_nrf52.s']
elif rtconfig.CROSS_TOOL == 'keil':
src = src + ['nrf52832/Source/templates/arm/arm_startup_nrf52.s']
elif rtconfig.CROSS_TOOL == 'iar':
src = src + ['nrf52832/Source/templates/arm/iar_startup_nrf52.s']
path = [cwd + '/CMSIS/Include',
cwd + '/nrf52832/Include']
CPPDEFINES = ['USE_STDPERIPH_DRIVER', 'NRF52']
group = DefineGroup('Startup Code', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
Return('group')
@@ -1,60 +0,0 @@
/* Copyright (c) 2015, 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:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form 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.
*
* * 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.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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 NRF_H
#define NRF_H
#if defined(_WIN32)
/* Do not include nrf51 specific files when building for PC host */
#elif defined(__unix)
/* Do not include nrf51 specific files when building for PC host */
#elif defined(__APPLE__)
/* Do not include nrf51 specific files when building for PC host */
#else
/* Family selection for family includes. */
#if defined (NRF51)
#include "nrf51.h"
#include "nrf51_bitfields.h"
#include "nrf51_deprecated.h"
#elif defined (NRF52)
#include "nrf52.h"
#include "nrf52_bitfields.h"
#include "nrf51_to_nrf52.h"
#else
#error "Device family must be defined. See nrf.h."
#endif /* NRF51, NRF52 */
#include "compiler_abstraction.h"
#endif /* _WIN32 || __unix || __APPLE__ */
#endif /* NRF_H */
File diff suppressed because it is too large. Load diff
@@ -1,69 +0,0 @@
/* Copyright (c) 2015, 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:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form 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.
*
* * 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.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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 SYSTEM_NRF52_H
#define SYSTEM_NRF52_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
/**
* Initialize the system
*
* @param none
* @return none
*
* @brief Setup the microcontroller system.
* Initialize the System and update the SystemCoreClock variable.
*/
extern void SystemInit (void);
/**
* Update SystemCoreClock variable
*
* @param none
* @return none
*
* @brief Updates the SystemCoreClock with current core Clock
* retrieved from cpu registers.
*/
extern void SystemCoreClockUpdate (void);
#ifdef __cplusplus
}
#endif
#endif /* SYSTEM_NRF52_H */
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -1,180 +0,0 @@
/* Copyright (c) 2015, 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:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form 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.
*
* * 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.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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 <stdint.h>
#include <stdbool.h>
#include "nrf.h"
#include "system_nrf52.h"
/*lint ++flb "Enter library region" */
#define __SYSTEM_CLOCK_16M (16000000UL)
#define __SYSTEM_CLOCK_64M (64000000UL)
static bool ftpan_32(void);
static bool ftpan_37(void);
static bool ftpan_36(void);
#if defined ( __CC_ARM )
uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK_64M;
#elif defined ( __ICCARM__ )
__root uint32_t SystemCoreClock = __SYSTEM_CLOCK_64M;
#elif defined ( __GNUC__ )
uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK_64M;
#endif
void SystemCoreClockUpdate(void)
{
SystemCoreClock = __SYSTEM_CLOCK_64M;
}
void SystemInit(void)
{
/* Workaround for FTPAN-32 "DIF: Debug session automatically enables TracePort pins" found at Product Anomaly document
for your device located at https://www.nordicsemi.com/ */
if (ftpan_32()){
CoreDebug->DEMCR &= ~CoreDebug_DEMCR_TRCENA_Msk;
}
/* Workaround for FTPAN-37 "AMLI: EasyDMA is slow with Radio, ECB, AAR and CCM." found at Product Anomaly document
for your device located at https://www.nordicsemi.com/ */
if (ftpan_37()){
*(volatile uint32_t *)0x400005A0 = 0x3;
}
/* Workaround for FTPAN-36 "CLOCK: Some registers are not reset when expected." found at Product Anomaly document
for your device located at https://www.nordicsemi.com/ */
if (ftpan_36()){
NRF_CLOCK->EVENTS_DONE = 0;
NRF_CLOCK->EVENTS_CTTO = 0;
}
/* Enable the FPU if the compiler used floating point unit instructions. __FPU_USED is a MACRO defined by the
* compiler. Since the FPU consumes energy, remember to disable FPU use in the compiler if floating point unit
* operations are not used in your code. */
#if (__FPU_USED == 1)
SCB->CPACR |= (3UL << 20) | (3UL << 22);
__DSB();
__ISB();
#endif
/* Configure NFCT pins as GPIOs if NFCT is not to be used in your code. If CONFIG_NFCT_PINS_AS_GPIOS is not defined,
two GPIOs (see Product Specification to see which ones) will be reserved for NFC and will not be available as
normal GPIOs. */
#if defined (CONFIG_NFCT_PINS_AS_GPIOS)
if ((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk) == (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos)){
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
NRF_UICR->NFCPINS &= ~UICR_NFCPINS_PROTECT_Msk;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
NVIC_SystemReset();
}
#endif
/* Configure GPIO pads as pPin Reset pin if Pin Reset capabilities desired. If CONFIG_GPIO_AS_PINRESET is not
defined, pin reset will not be available. One GPIO (see Product Specification to see which one) will then be
reserved for PinReset and not available as normal GPIO. */
#if defined (CONFIG_GPIO_AS_PINRESET)
if (((NRF_UICR->PSELRESET[0] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos)) ||
((NRF_UICR->PSELRESET[0] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos))){
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
NRF_UICR->PSELRESET[0] = 21;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
NRF_UICR->PSELRESET[1] = 21;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
NVIC_SystemReset();
}
#endif
/* Enable SWO trace functionality. If ENABLE_SWO is not defined, SWO pin will be used as GPIO (see Product
Specification to see which one). */
#if defined (ENABLE_SWO)
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
NRF_CLOCK->TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Serial << CLOCK_TRACECONFIG_TRACEMUX_Pos;
#endif
/* Enable Trace functionality. If ENABLE_TRACE is not defined, TRACE pins will be used as GPIOs (see Product
Specification to see which ones). */
#if defined (ENABLE_TRACE)
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
NRF_CLOCK->TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Parallel << CLOCK_TRACECONFIG_TRACEMUX_Pos;
#endif
SystemCoreClockUpdate();
}
static bool ftpan_32(void)
{
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
{
if ((((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30) && (((*(uint32_t *)0xF0000FEC) & 0x000000F0) == 0x0))
{
return true;
}
}
return false;
}
static bool ftpan_37(void)
{
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
{
if ((((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30) && (((*(uint32_t *)0xF0000FEC) & 0x000000F0) == 0x0))
{
return true;
}
}
return false;
}
static bool ftpan_36(void)
{
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
{
if ((((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30) && (((*(uint32_t *)0xF0000FEC) & 0x000000F0) == 0x0))
{
return true;
}
}
return false;
}
/*lint --flb "Leave library region" */
+16
View File
@@ -0,0 +1,16 @@
# for module compiling
import os
from building import *
cwd = GetCurrentDir()
objs = []
list = os.listdir(cwd)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(d, 'SConscript'))
objs = objs + SConscript(os.path.join(cwd, 'nRF5_SDK_13.0.0_04a0bfd/components/SConscript'))
Return('objs')
+34
View File
@@ -0,0 +1,34 @@
import os
import sys
import rtconfig
if os.getenv('RTT_ROOT'):
RTT_ROOT = os.getenv('RTT_ROOT')
else:
RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
from building import *
TARGET = 'rtthread_nrf52832.' + rtconfig.TARGET_EXT
env = Environment(tools = ['mingw'],
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
AR = rtconfig.AR, ARFLAGS = '-rc',
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
if rtconfig.PLATFORM == 'iar':
env.Replace(CCCOM = ['$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
env.Replace(ARFLAGS = [''])
env.Replace(LINKCOM = ['$LINK $SOURCES $LINKFLAGS -o $TARGET --map project.map'])
Export('RTT_ROOT')
Export('rtconfig')
# prepare building environment
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
# make a building
DoBuilding(TARGET, objs)
+12 -5
View File
@@ -25,13 +25,20 @@
#include <shell.h>
#endif
void rt_init_thread_entry(void* parameter)
{
}
int rt_application_init(void)
{
/* Set finsh device */
#ifdef RT_USING_FINSH
/* initialize finsh */
finsh_system_init();
#endif
rt_thread_t tid;
tid = rt_thread_create("init", rt_init_thread_entry, RT_NULL, 1024,
RT_THREAD_PRIORITY_MAX / 3, 20);
if (tid != RT_NULL)
rt_thread_startup(tid);
return 0;
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -58,7 +58,7 @@ void rtthread_startup(void)
rt_system_timer_init();
#ifdef RT_USING_HEAP
rt_system_heap_init((void*)NRF_SRAM_BEGIN, (void*)NRF_SRAM_END);
rt_system_heap_init((void*)NRF_SRAM_BEGIN, (void*)CHIP_SRAM_END);
#endif
/* init scheduler system */
@@ -83,7 +83,7 @@ void rtthread_startup(void)
int main(void)
{
/* disable interrupt first */
rt_hw_interrupt_disable();
// rt_hw_interrupt_disable();
/* startup RT-Thread RTOS */
rtthread_startup();
+14
View File
@@ -0,0 +1,14 @@
Import('RTT_ROOT')
Import('rtconfig')
from building import *
cwd = GetCurrentDir()
src = Glob('*.c')
CPPPATH = [cwd]
#remove other no use files
#SrcRemove(src, '*.c')
group = DefineGroup('Board', src, depend = [''], CPPPATH = CPPPATH)
Return('group')
File diff suppressed because it is too large. Load diff
+15
View File
@@ -0,0 +1,15 @@
#ifndef _BOARD_H_
#define _BOARD_H_
#include <rtthread.h>
#include "nrf.h"
#define CHIP_SRAM_END (0x20000000 + 64*1024)
void rt_hw_board_init(void);
void rt_os_ready(void);
#endif
File diff suppressed because it is too large. Load diff
+19
View File
@@ -0,0 +1,19 @@
#ifndef _UART_H_
#define _UART_H_
#define RT_DEVICE_CTRL_CUSTOM 0x20
#define RT_DEVICE_CTRL_PIN 0x21
#define RT_DEVICE_POWERSAVE 0x22
#define RT_DEVICE_WAKEUP 0x23
#define UART_CONFIG_BAUD_RATE_9600 1
#define UART_CONFIG_BAUD_RATE_115200 2
#define UART0_RB_SIZE 1024
// #define USE_UART0_1 0
void rt_hw_uart_init(void);
#endif
-13
View File
@@ -1,13 +0,0 @@
Import('RTT_ROOT')
Import('rtconfig')
from building import *
# get current directory
cwd = GetCurrentDir()
src = Glob('*.c')
CPPPATH = [cwd]
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
Return('group')
-58
View File
@@ -1,58 +0,0 @@
/*
* File : board.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2015 RT-Thread Develop Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2015-11-11 Xue Liu Initial for nRF52
*/
#include <rthw.h>
#include <rtthread.h>
#include <nrf52.h>
#include <nrf52_bitfields.h>
#include "board.h"
#include "uart.h"
/**
* @addtogroup NRF52832
*/
/** @brief: Function for handling the Systick interrupts.
*/
void SysTick_Handler(void)
{
/* enter interrupt */
rt_interrupt_enter();
rt_tick_increase(); //This function will notify kernel there is one tick passed
/* leave interrupt */
rt_interrupt_leave();
}
/**
* This function will initial NRF52832 board.
*/
void rt_hw_board_init()
{
/* Configure the SysTick */
SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
/* Initial usart deriver, and set console device */
rt_hw_uart_init();
#ifdef RT_USING_CONSOLE
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
#endif
}
/*@}*/
-19
View File
@@ -1,19 +0,0 @@
/*
* File : board.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
*/
#ifndef __BOARD_H__
#define __BOARD_H__
void rt_hw_board_init(void);
#endif
File diff suppressed because it is too large. Load diff
-26
View File
@@ -1,26 +0,0 @@
/*
* File : uart.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2015, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
*/
#ifndef __UART_H__
#define __UART_H__
#define RX_PIN_NUMBER 8
#define TX_PIN_NUMBER 6
#define CTS_PIN_NUMBER 7
#define RTS_PIN_NUMBER 5
#define HWFC false
void rt_hw_uart_init(void);
#endif
@@ -0,0 +1,34 @@
Import('RTT_ROOT')
Import('rtconfig')
from building import *
# get current directory
cwd = GetCurrentDir()
BLE_COMMON = Glob('./components/ble/common/*.c')
SrcRemove(BLE_COMMON, 'ble_conn_state.c')
BLE_GATT = Glob('./components/ble/nrf_ble_gatt/*.c')
BLE_ADVERTISING = Glob('./components/ble/ble_advertising/*.c')
BLE_SERVICE = Glob('./components/ble/ble_services/ble_nus/*.c')
BLE_SRC = BLE_COMMON + BLE_GATT + BLE_SERVICE + BLE_ADVERTISING
SOFTDEVICE = Glob('./components/softdevice/common/softdevice_handler/*.c')
SrcRemove(SOFTDEVICE, 'softdevice_handler_appsh.c')
BLE_STACK_SRC = BLE_SRC + SOFTDEVICE
path = [cwd + '/components']
path += [cwd + '/components/softdevice/common/softdevice_handler']
path += [cwd + '/components/softdevice/s132/headers']
path += [cwd + '/components/softdevice/s132/headers/nrf52']
path += [cwd + '/components/ble/common']
path += [cwd + '/components/ble/nrf_ble_gatt']
path += [cwd + '/components/ble/ble_advertising']
path += [cwd + '/components/ble/ble_services/ble_nus']
CPPDEFINES = ['BLE_STACK_SUPPORT_REQD', 'NRF_SD_BLE_API_VERSION=4', 'S132', 'SOFTDEVICE_PRESENT']
group = DefineGroup('BLE_STACK', BLE_STACK_SRC, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
Return('group')
@@ -0,0 +1,52 @@
Import('RTT_ROOT')
Import('rtconfig')
from building import *
# get current directory
cwd = GetCurrentDir()
DriversDir = cwd + '/drivers_nrf/'
DeviceDrivers = [DriversDir + 'hal/nrf_saadc.c']
DeviceDrivers += [DriversDir + 'common/nrf_drv_common.c']
#DeviceDrivers += [DriversDir + 'uart/nrf_drv_uart.c']
DeviceDrivers += [DriversDir + 'clock/nrf_drv_clock.c']
DeviceDrivers += [DriversDir + 'gpiote/nrf_drv_gpiote.c']
DeviceDrivers += [DriversDir + 'pwm/nrf_drv_pwm.c']
DeviceDrivers += [DriversDir + 'saadc/nrf_drv_saadc.c']
Libraries_dir = cwd + '/libraries/'
Libraries_src = Glob(Libraries_dir + 'log/src/*.c')
Libraries_src += Glob(Libraries_dir + 'timer/app_timer_rtthread.c')
Libraries_src += Glob(Libraries_dir + 'util/*.c')
Libraries_src += Glob(Libraries_dir + 'fstorage/fstorage.c')
Libraries_src += Glob(Libraries_dir + 'strerror/nrf_strerror.c')
src = DeviceDrivers + Libraries_src
path = [cwd]
path += [cwd + '/device']
path += [cwd + '/drivers_nrf/delay']
path += [cwd + '/drivers_nrf/uart']
path += [cwd + '/drivers_nrf/clock']
path += [cwd + '/drivers_nrf/gpiote']
path += [cwd + '/drivers_nrf/common']
path += [cwd + '/drivers_nrf/hal']
path += [cwd + '/drivers_nrf/pwm']
path += [DriversDir + 'saadc']
path += [Libraries_dir + 'util']
path += [Libraries_dir + 'timer']
path += [Libraries_dir + 'fstorage']
path += [Libraries_dir + 'experimental_section_vars']
path += [Libraries_dir + 'log']
path += [Libraries_dir + 'log/src']
path += [Libraries_dir + 'strerror']
path += [cwd + '/toolchain/cmsis/include']
CPPDEFINES = ['RTTHREAD', 'SWI_DISABLE0', 'CONFIG_GPIO_AS_PINRESET', 'NRF52', 'NRF52832_XXAA']
CPPDEFINES += ['NRF52_PAN_12', 'NRF52_PAN_15', 'NRF52_PAN_20', 'NRF52_PAN_31', 'NRF52_PAN_36']
CPPDEFINES += ['NRF52_PAN_51', 'NRF52_PAN_54', 'NRF52_PAN_55', 'NRF52_PAN_58', 'NRF52_PAN_64', 'NRF52_PAN_74']
group = DefineGroup('NRF_DRIVERS', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
Return('group')
@@ -0,0 +1,86 @@
/**
* Copyright (c) 2015 - 2017, 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_CHANNEL_CONFIG)
#include "nrf_error.h"
#include "ant_channel_config.h"
#include "ant_interface.h"
#include "ant_parameters.h"
uint32_t ant_channel_init(ant_channel_config_t const * p_config)
{
uint32_t err_code;
// Set Channel Number.
err_code = sd_ant_channel_assign(p_config->channel_number,
p_config->channel_type,
p_config->network_number,
p_config->ext_assign);
VERIFY_SUCCESS(err_code);
// Set Channel ID.
err_code = sd_ant_channel_id_set(p_config->channel_number,
p_config->device_number,
p_config->device_type,
p_config->transmission_type);
VERIFY_SUCCESS(err_code);
// Set Channel RF frequency.
err_code = sd_ant_channel_radio_freq_set(p_config->channel_number, p_config->rf_freq);
VERIFY_SUCCESS(err_code);
// Set Channel period.
if (!(p_config->ext_assign & EXT_PARAM_ALWAYS_SEARCH) && (p_config->channel_period != 0))
{
err_code = sd_ant_channel_period_set(p_config->channel_number, p_config->channel_period);
}
#if ANT_CONFIG_ENCRYPTED_CHANNELS > 0
VERIFY_SUCCESS(err_code);
err_code = ant_channel_encrypt_config(p_config->channel_type , p_config->channel_number, p_config->p_crypto_settings);
#endif
return err_code;
}
#endif // NRF_MODULE_ENABLED(ANT_CHANNEL_CONFIG)
@@ -0,0 +1,98 @@
/**
* Copyright (c) 2015 - 2017, 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_CHANNEL_CONFIG_H__
#define ANT_CHANNEL_CONFIG_H__
/** @file
*
* @defgroup ant_channel_config ANT channel configuration
* @{
* @ingroup ant_sdk_utils
* @brief ANT channel configuration module.
*/
#include <stdint.h>
#include "sdk_config.h"
#ifndef ANT_CONFIG_ENCRYPTED_CHANNELS
#error Undefined ANT_CONFIG_ENCRYPTED_CHANNELS. It should be defined in sdk_config.h file.
#elif ANT_CONFIG_ENCRYPTED_CHANNELS > 0
#include "ant_encrypt_config.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**@brief ANT channel configuration structure. */
typedef struct
{
uint8_t channel_number; ///< Assigned channel number.
uint8_t channel_type; ///< Channel type (see Assign Channel Parameters in ant_parameters.h: @ref ant_parameters).
uint8_t ext_assign; ///< Extended assign (see Ext. Assign Channel Parameters in ant_parameters.h: @ref ant_parameters).
uint8_t rf_freq; ///< Radio frequency offset from 2400 MHz (for example, 2466 MHz, rf_freq = 66).
uint8_t transmission_type; ///< Transmission type.
uint8_t device_type; ///< Device type.
uint16_t device_number; ///< Device number.
uint16_t channel_period; ///< The period in 32 kHz counts.
uint8_t network_number; ///< Network number denoting the network key.
#if ANT_CONFIG_ENCRYPTED_CHANNELS > 0
ant_encrypt_channel_settings_t * p_crypto_settings; ///< Pointer to cryptographic settings, NULL if this configuration have to be omitted.
#endif
} ant_channel_config_t;
/**@brief Function for configuring the ANT channel.
*
* @param[in] p_config Pointer to the channel configuration structure.
*
* @retval NRF_SUCCESS If the channel was successfully configured. Otherwise, an error code is returned.
*/
uint32_t ant_channel_init(ant_channel_config_t const * p_config);
#ifdef __cplusplus
}
#endif
#endif // ANT_CHANNEL_CONFIG_H__
/** @} */
@@ -0,0 +1,189 @@
/**
* Copyright (c) 2015 - 2017, 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_ENCRYPT_NEGOTIATION_SLAVE)
#include <stdlib.h>
#include <string.h>
#include "ant_encrypt_config.h"
#include "ant_interface.h"
#include "ant_parameters.h"
#include "nrf_error.h"
#include "app_error.h"
#include "ant_encrypt_negotiation_slave.h"
/** Number of supported channels. */
#define NUMBER_OF_CHANNELS (ANT_CONFIG_TOTAL_CHANNELS_ALLOCATED)
/** Flag to block other channels from attempting to enable encryption while
* another encryption is in the process.
*/
static volatile bool m_can_enable_crypto = true;
/** Array to keep track of which channels are currently tracking. */
static ant_encrypt_tracking_state_t m_encrypt_channel_states[NUMBER_OF_CHANNELS];
/** Array for the slave channels' encryption settings. */
static ant_encrypt_channel_settings_t m_slave_channel_conf[MAX_ANT_CHANNELS];
void ant_channel_encryp_tracking_state_set(uint8_t channel_number,
ant_encrypt_tracking_state_t state)
{
m_encrypt_channel_states[channel_number] = state;
}
void ant_channel_encryp_negotiation_slave_init(void)
{
for (uint32_t channel = 0; channel < NUMBER_OF_CHANNELS; channel++)
{
ant_channel_encryp_tracking_state_set(channel, ANT_ENC_CHANNEL_STAT_TRACKING_UNSUPPORTED);
}
m_can_enable_crypto = true;
}
ant_encrypt_tracking_state_t ant_channel_encryp_tracking_state_get(uint8_t channel_number)
{
return m_encrypt_channel_states[channel_number];
}
void ant_slave_channel_encrypt_config(uint8_t channel_number,
ant_encrypt_channel_settings_t const * const p_crypto_config)
{
memcpy(&m_slave_channel_conf[channel_number], p_crypto_config,
sizeof(ant_encrypt_channel_settings_t));
}
/**@brief Function for handling ANT RX channel events.
*
* @param[in] p_event_message_buffer The ANT event message buffer.
*/
static void ant_slave_encrypt_try_enable(uint8_t ant_channel,
uint8_t ant_message_id)
{
uint32_t err_code;
ant_encrypt_tracking_state_t track_stat;
switch (ant_message_id)
{
// Broadcast data received.
case MESG_BROADCAST_DATA_ID:
track_stat = ant_channel_encryp_tracking_state_get(ant_channel);
// If the encryption has not yet been negotiated for this channel and another channel
// is not currently trying to enable encryption, enable encryption
if ((track_stat != ANT_ENC_CHANNEL_STAT_TRACKING_DECRYPTED)
&& (track_stat != ANT_ENC_CHANNEL_STAT_NEGOTIATING)
&& m_can_enable_crypto)
{
// Block other channels from trying to enable encryption until this channel
// is finished
m_can_enable_crypto = false;
ant_channel_encryp_tracking_state_set(ant_channel,
ANT_ENC_CHANNEL_STAT_NEGOTIATING);
// Enable encryption on ant_channel
err_code =
ant_channel_encrypt_config_perform(ant_channel,
&m_slave_channel_conf[ant_channel]);
APP_ERROR_CHECK(err_code);
}
break;
default:
break;
}
}
void ant_slave_encrypt_negotiation(ant_evt_t * p_ant_evt)
{
uint8_t const ant_channel = p_ant_evt->channel;
ANT_MESSAGE * p_ant_msg;
ant_encrypt_tracking_state_t track_state = ant_channel_encryp_tracking_state_get(ant_channel);
if (track_state == ANT_ENC_CHANNEL_STAT_TRACKING_UNSUPPORTED)
return;
switch (p_ant_evt->event)
{
case EVENT_RX_FAIL_GO_TO_SEARCH:
if (track_state == ANT_ENC_CHANNEL_STAT_NEGOTIATING)
{
m_can_enable_crypto = true;
}
ant_channel_encryp_tracking_state_set(ant_channel, ANT_ENC_CHANNEL_STAT_NOT_TRACKING);
break;
case EVENT_RX:
/*lint -e545 -save*/
p_ant_msg = (ANT_MESSAGE *) &(p_ant_evt->msg.evt_buffer);
/*lint -restore*/
ant_slave_encrypt_try_enable(ant_channel, p_ant_msg->ANT_MESSAGE_ucMesgID);
break;
case EVENT_ENCRYPT_NEGOTIATION_SUCCESS:
m_can_enable_crypto = true;
ant_channel_encryp_tracking_state_set(ant_channel,
ANT_ENC_CHANNEL_STAT_TRACKING_DECRYPTED);
break;
case EVENT_ENCRYPT_NEGOTIATION_FAIL:
m_can_enable_crypto = true;
ant_channel_encryp_tracking_state_set(ant_channel,
ANT_ENC_CHANNEL_STAT_TRACKING_ENCRYPTED);
break;
default:
break;
}
}
#endif // NRF_MODULE_ENABLED(ANT_ENCRYPT_NEGOTIATION_SLAVE)
@@ -0,0 +1,140 @@
/**
* Copyright (c) 2015 - 2017, 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_ENCRYPT_NEGOTIATION_SLAVE_H__
#define ANT_ENCRYPT_NEGOTIATION_SLAVE_H__
/**@file
*
* @defgroup ant_encrypt_negotiation_slave ANT encryption negotiation
* @{
* @ingroup ant_sdk_utils
*
* @brief Encryption negotiation for encrypted ANT slave channels.
*
* After pairing, the slave starts negotiating the encryption with the master. After
* successful negotiation, the slave can decrypt messages from the master, and all
* future messages are sent encrypted.
*
*/
#include <stdint.h>
#include "ant_stack_handler_types.h"
#include "ant_encrypt_config.h"
#ifdef __cplusplus
extern "C" {
#endif
/** Encryption negotiation states for a slave channel. */
typedef enum
{
ANT_ENC_CHANNEL_STAT_NOT_TRACKING, ///< Not tracking the master.
ANT_ENC_CHANNEL_STAT_TRACKING_ENCRYPTED, ///< Tracking the master, but cannot decrypt messages.
ANT_ENC_CHANNEL_STAT_NEGOTIATING, ///< Encryption has been enabled and negotiation is in progress.
ANT_ENC_CHANNEL_STAT_TRACKING_DECRYPTED, ///< Tracking the master and can decrypt messages.
ANT_ENC_CHANNEL_STAT_TRACKING_UNSUPPORTED ///< Tracking unsupported on this channel.
} ant_encrypt_tracking_state_t;
/**
* @brief Function for setting the encryption negotiation state of a slave ANT channel.
*
* This function should be used by the @ref ant_encrypt_config module.
*
* @param[in] channel_number ANT channel number.
* @param[in] state State to set.
*/
void ant_channel_encryp_tracking_state_set(uint8_t channel_number,
ant_encrypt_tracking_state_t state);
/**
* @brief Function for getting the encryption negotiation state of a slave ANT channel.
*
* @param[in] channel_number ANT channel number.
*/
ant_encrypt_tracking_state_t ant_channel_encryp_tracking_state_get(uint8_t channel_number);
/**
* @brief Function for initializing the module.
*
* This function initializes internal states of the module. It should
* only be used by the @ref ant_encrypt_config module.
*
*/
void ant_channel_encryp_negotiation_slave_init(void);
/**
* @brief Function for setting the configuration for the slave channel.
*
* This function saves the channel's encryption configuration to a lookup table (LUT) for
* future usage. The configuration can then be used to enable encryption.
*
* This function is intended to be used by the @ref ant_encrypt_config module.
*
* @param[in] channel_number ANT channel number.
* @param[in] p_crypto_config Pointer to the encryption configuration.
*/
void ant_slave_channel_encrypt_config(uint8_t channel_number,
ant_encrypt_channel_settings_t const * const p_crypto_config);
/**
* @brief Function for handling ANT encryption negotiation on slave nodes.
*
* This function should be used directly in the ANT event dispatching process. It
* tries to enable slave channel encryption for all slave channels that are declared
* as encrypted channels (if appropriate master channels are found).
*
* This function should be used by the @ref ant_encrypt_config module.
*
* @param[in] p_ant_evt Pointer to the ANT stack event message structure.
*/
void ant_slave_encrypt_negotiation(ant_evt_t * p_ant_evt);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif // ANT_ENCRYPT_NEGOTIATION_SLAVE_H__
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,98 @@
/**
* This software is subject to the ANT+ Shared Source License
* www.thisisant.com/swlicenses
* Copyright (c) Dynastream Innovations, Inc. 2012
* 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 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 Dynastream nor the names of its
* contributors may be used to endorse or promote products
* derived from this software without specific prior
* written permission.
*
* The following actions are prohibited:
* 1) Redistribution of source code containing the ANT+ Network
* Key. The ANT+ Network Key is available to ANT+ Adopters.
* Please refer to http://thisisant.com to become an ANT+
* Adopter and access the key.
*
* 2) Reverse engineering, decompilation, and/or disassembly of
* software provided in binary form under this license.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE HEREBY
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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; DAMAGE TO ANY DEVICE, 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. SOME STATES DO NOT ALLOW
* THE EXCLUSION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE
* ABOVE LIMITATIONS MAY NOT APPLY TO YOU.
*
*/
#include "crc.h"
#include "compiler_abstraction.h"
/**@brief Function for updating the current CRC-16 value for a single byte input.
*
* @param[in] current_crc The current calculated CRC-16 value.
* @param[in] byte The input data byte for the computation.
*
* @return The updated CRC-16 value, based on the input supplied.
*/
static __INLINE uint16_t crc16_get(uint16_t current_crc, uint8_t byte)
{
static const uint16_t crc16_table[16] =
{
0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401,
0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400
};
uint16_t temp;
// Compute checksum of lower four bits of a byte.
temp = crc16_table[current_crc & 0xF];
current_crc = (current_crc >> 4u) & 0x0FFFu;
current_crc = current_crc ^ temp ^ crc16_table[byte & 0xF];
// Now compute checksum of upper four bits of a byte.
temp = crc16_table[current_crc & 0xF];
current_crc = (current_crc >> 4u) & 0x0FFFu;
current_crc = current_crc ^ temp ^ crc16_table[(byte >> 4u) & 0xF];
return current_crc;
}
uint16_t crc_crc16_update(uint16_t current_crc, const volatile void * p_data, uint32_t size)
{
uint8_t * p_block = (uint8_t *)p_data;
while (size != 0)
{
current_crc = crc16_get(current_crc, *p_block);
p_block++;
size--;
}
return current_crc;
}
@@ -0,0 +1,94 @@
/**
* This software is subject to the ANT+ Shared Source License
* www.thisisant.com/swlicenses
* Copyright (c) Dynastream Innovations, Inc. 2012
* 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 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 Dynastream nor the names of its
* contributors may be used to endorse or promote products
* derived from this software without specific prior
* written permission.
*
* The following actions are prohibited:
* 1) Redistribution of source code containing the ANT+ Network
* Key. The ANT+ Network Key is available to ANT+ Adopters.
* Please refer to http://thisisant.com to become an ANT+
* Adopter and access the key.
*
* 2) Reverse engineering, decompilation, and/or disassembly of
* software provided in binary form under this license.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE HEREBY
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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; DAMAGE TO ANY DEVICE, 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. SOME STATES DO NOT ALLOW
* THE EXCLUSION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE
* ABOVE LIMITATIONS MAY NOT APPLY TO YOU.
*
*/
/** @file
* @brief The CRC-16 interface.
* This file is based on implementation originally made by Dynastream Innovations Inc. - August 2012
* @defgroup ant_fs_client_main ANT-FS client device simulator
* @{
* @ingroup ant_fs
*
* @brief The ANT-FS client device simulator.
*
*/
#ifndef CRC_H__
#define CRC_H__
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Function for calculating CRC-16 in blocks.
*
* Feed each consecutive data block into this function, along with the current value of current_crc
* as returned by the previous call of this function. The first call of this function should pass
* the initial value (usually 0) of the crc in current_crc.
* @param[in] current_crc The current calculated CRC-16 value.
* @param[in] p_data The input data block for computation.
* @param[in] size The size of the input data block in bytes.
*
* @return The updated CRC-16 value, based on the input supplied.
*/
uint16_t crc_crc16_update(uint16_t current_crc, const volatile void * p_data, uint32_t size);
#ifdef __cplusplus
}
#endif
#endif // CRC_H__
/**
*@}
**/
@@ -0,0 +1,109 @@
/**
* This software is subject to the ANT+ Shared Source License
* www.thisisant.com/swlicenses
* Copyright (c) Dynastream Innovations, Inc. 2012
* 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 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 Dynastream nor the names of its
* contributors may be used to endorse or promote products
* derived from this software without specific prior
* written permission.
*
* The following actions are prohibited:
* 1) Redistribution of source code containing the ANT+ Network
* Key. The ANT+ Network Key is available to ANT+ Adopters.
* Please refer to http://thisisant.com to become an ANT+
* Adopter and access the key.
*
* 2) Reverse engineering, decompilation, and/or disassembly of
* software provided in binary form under this license.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE HEREBY
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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; DAMAGE TO ANY DEVICE, 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. SOME STATES DO NOT ALLOW
* THE EXCLUSION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE
* ABOVE LIMITATIONS MAY NOT APPLY TO YOU.
*
*/
/**@file
* @brief Definitions.
* This file is based on implementation originally made by Dynastream Innovations Inc. - August 2012
* @defgroup ant_fs_client_main ANT-FS client device simulator
* @{
* @ingroup nrf_ant_fs_client
*
* @brief The ANT-FS client device simulator.
*
*/
#ifndef DEFINES_H__
#define DEFINES_H__
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define MAX_ULONG 0xFFFFFFFFu /**< The Max value for the type. */
/**@brief uint16_t type presentation as an union. */
typedef union
{
uint16_t data; /**< The data content. */
struct
{
uint8_t low; /**< The low byte of the data content. */
uint8_t high; /**< The high byte of the data content. */
} bytes;
} ushort_union_t;
/**@brief uint32_t type presentation as an union. */
typedef union
{
uint32_t data; /**< The data content as a single variable. */
uint8_t data_bytes[sizeof(uint32_t)]; /**< The data content as a byte array. */
struct
{
// The least significant byte of the uint32_t in this structure is referenced by byte0.
uint8_t byte0; /**< Byte 0 of the data content. */
uint8_t byte1; /**< Byte 1 of the data content. */
uint8_t byte2; /**< Byte 2 of the data content. */
uint8_t byte3; /**< Byte 3 of the data content. */
} bytes;
} ulong_union_t;
#ifdef __cplusplus
}
#endif
#endif // DEFINES_H__
/**
*@}
**/
@@ -0,0 +1,67 @@
/**
* Copyright (c) 2015 - 2017, 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_KEY_MANAGER)
#include <stdio.h>
#include "ant_key_manager.h"
#include "ant_key_manager_config.h"
#include "ant_interface.h"
#include "nrf_assert.h"
static uint8_t m_ant_plus_network_key[] = ANT_PLUS_NETWORK_KEY;
static uint8_t m_ant_fs_network_key[] = ANT_FS_NETWORK_KEY;
uint32_t ant_custom_key_set(uint8_t network_number, uint8_t * network_key)
{
ASSERT(network_key != NULL);
return sd_ant_network_address_set(network_number, network_key);
}
uint32_t ant_plus_key_set(uint8_t network_number)
{
return sd_ant_network_address_set(network_number, m_ant_plus_network_key);
}
uint32_t ant_fs_key_set(uint8_t network_number)
{
return sd_ant_network_address_set(network_number, m_ant_fs_network_key);
}
#endif // NRF_MODULE_ENABLED(ANT_KEY_MANAGER)
@@ -0,0 +1,104 @@
/**
* Copyright (c) 2015 - 2017, 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_KEY_MANAGER_H__
#define ANT_KEY_MANAGER_H__
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @file
*/
/**
* @defgroup ant_key_manager ANT key manager
* @{
* @ingroup ant_sdk_utils
* @brief Module for registering common and custom ANT network keys.
*/
/**@brief Function for registering a custom network key.
*
* @param[in] network_number Network key number.
* @param[in] p_network_key Pointer to the custom ANT network key.
*
* @return A SoftDevice error code.
*/
uint32_t ant_custom_key_set(uint8_t network_number, uint8_t * p_network_key);
/**@brief Function for registering an ANT+ network key.
*
* The key must be defined by @ref ANT_PLUS_NETWORK_KEY.
*
* @note The ANT+ Network Key is available for ANT+ Adopters. Go to http://thisisant.com
* to become an ANT+ Adopter and access the key.
*
* @param[in] network_number Network key number.
*
* @return A SoftDevice error code.
*/
uint32_t ant_plus_key_set(uint8_t network_number);
/**@brief Function for registering an ANT-FS network key.
*
* The key must be defined by @ref ANT_FS_NETWORK_KEY.
*
* @note The ANT+ Network Key is available for ANT+ Adopters. Go to http://thisisant.com
* to become an ANT+ Adopter and access the key.
*
* @param[in] network_number Network key number.
*
* @return A SoftDevice error code.
*/
uint32_t ant_fs_key_set(uint8_t network_number);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif // ANT_KEY_MANAGER_H__
@@ -0,0 +1,69 @@
/**
* Copyright (c) 2015 - 2017, 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_KEY_MANAGER_CONFIG_H__
#define ANT_KEY_MANAGER_CONFIG_H__
#ifdef __cplusplus
extern "C" {
#endif
/**
* @addtogroup ant_key_manager
* @{
*/
#ifndef ANT_PLUS_NETWORK_KEY
#define ANT_PLUS_NETWORK_KEY {0, 0, 0, 0, 0, 0, 0, 0} /**< The ANT+ network key. */
#endif //ANT_PLUS_NETWORK_KEY
#ifndef ANT_FS_NETWORK_KEY
#define ANT_FS_NETWORK_KEY {0, 0, 0, 0, 0, 0, 0, 0} /**< The ANT-FS network key. */
#endif // ANT_FS_NETWORK_KEY
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif // ANT_KEY_MANAGER_CONFIG_H__
@@ -0,0 +1,89 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BPWR_LOCAL_H__
#define ANT_BPWR_LOCAL_H__
#include <stdint.h>
#include <stdbool.h>
#include "ant_bpwr.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @addtogroup ant_bpwr
* @{
*/
/** @brief Bicycle Power Sensor control block. */
typedef struct
{
uint8_t message_counter;
ant_bpwr_torque_t torque_use;
enum
{
BPWR_SENS_CALIB_NONE, ///< Idle state.
BPWR_SENS_CALIB_REQUESTED, ///< Received request for general calibration result message by the sensor.
BPWR_SENS_CALIB_READY, ///< Calibration response message is ready to be transmitted.
} calib_stat;
ant_bpwr_calib_handler_t calib_handler;
} ant_bpwr_sens_cb_t;
/**@brief Bicycle Power Sensor RX control block. */
typedef struct
{
uint8_t calib_timeout;
enum
{
BPWR_DISP_CALIB_NONE, ///< Idle state.
BPWR_DISP_CALIB_REQUESTED, ///< Calibration requested.
} calib_stat;
} ant_bpwr_disp_cb_t;
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif // ANT_BPWR_LOCAL_H__
@@ -0,0 +1,98 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "sdk_common.h"
#if NRF_MODULE_ENABLED(ANT_BPWR)
#include "ant_bpwr_common_data.h"
#include "ant_bpwr_utils.h"
#define NRF_LOG_MODULE_NAME "ANT_BPWR_COMMON"
#if ANT_BPWR_COMMON_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BPWR_COMMON_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BPWR_COMMON_INFO_COLOR
#else // ANT_BPWR_COMMON_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BPWR_COMMON_LOG_ENABLED
#include "nrf_log.h"
/**@brief BPWR common page data layout structure. */
typedef struct
{
uint8_t reserved0[2];
uint8_t instantaneous_cadence;
uint8_t reserved1[4];
}ant_bpwr_cadence_data_layout_t;
/**@brief Function for tracing common data.
*
* @param[in] p_common_data Pointer to the common data.
*/
static void cadence_data_log(ant_bpwr_common_data_t const * p_common_data)
{
if (p_common_data->instantaneous_cadence == 0xFF)
{
NRF_LOG_INFO("instantaneous cadence: -- rpm\r\n\n");
}
else
{
NRF_LOG_INFO("instantaneous cadence: %u rpm\r\n\n",
p_common_data->instantaneous_cadence);
}
}
void ant_bpwr_cadence_encode(uint8_t * p_page_buffer,
ant_bpwr_common_data_t const * p_common_data)
{
ant_bpwr_cadence_data_layout_t * p_outcoming_data = (ant_bpwr_cadence_data_layout_t *)p_page_buffer;
p_outcoming_data->instantaneous_cadence = p_common_data->instantaneous_cadence;
cadence_data_log(p_common_data);
}
void ant_bpwr_cadence_decode(uint8_t const * p_page_buffer,
ant_bpwr_common_data_t * p_common_data)
{
ant_bpwr_cadence_data_layout_t const * p_incoming_data = (ant_bpwr_cadence_data_layout_t *)p_page_buffer;
p_common_data->instantaneous_cadence = p_incoming_data->instantaneous_cadence;
cadence_data_log(p_common_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BPWR)
@@ -0,0 +1,99 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BPWR_COMMON_DATA_H__
#define ANT_BPWR_COMMON_DATA_H__
/** @file
*
* @defgroup ant_sdk_profiles_bpwr_common_data_page Stride Based Speed and Distance Monitor profile common data
* @{
* @ingroup ant_sdk_profiles_bpwr_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for BPWR common data.
*
* @details This structure stores data that is not associated with a particular page.
*/
typedef struct
{
uint8_t instantaneous_cadence; ///< Crank cadence (rpm, 0 - 254, 255-> invalid).
} ant_bpwr_common_data_t;
/**@brief Initialize common data.
*/
#define DEFAULT_ANT_BPWR_COMMON_DATA() \
(ant_bpwr_common_data_t) \
{ \
.instantaneous_cadence = 0, \
}
/**@brief Function for encoding speed.
*
* This function can be used for pages 16, 17, and 18.
*
* @param[in] p_common_data Pointer to the common data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bpwr_cadence_encode(uint8_t * p_page_buffer,
ant_bpwr_common_data_t const * p_common_data);
/**@brief Function for decoding speed.
*
* This function can be used for pages 16, 17, and 18.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_common_data Pointer to the common data.
*/
void ant_bpwr_cadence_decode(uint8_t const * p_page_buffer,
ant_bpwr_common_data_t * p_common_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BPWR_COMMON_DATA_H__
/** @} */
@@ -0,0 +1,136 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BPWR_PAGE_1_H__
#define ANT_BPWR_PAGE_1_H__
/** @file
*
* @defgroup ant_sdk_profiles_bpwr_page1 Bicycle Power profile page 1
* @{
* @ingroup ant_sdk_profiles_bpwr_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief BPWR Calibration ID.
*/
typedef enum
{
ANT_BPWR_CALIB_ID_NONE = 0x00,
ANT_BPWR_CALIB_ID_MANUAL = 0xAA, ///< Calibration Request: Manual Zero.
ANT_BPWR_CALIB_ID_AUTO = 0xAB, ///< Calibration Request: Auto Zero Configuration.
ANT_BPWR_CALIB_ID_MANUAL_SUCCESS = 0xAC, ///< Calibration Response: Manual Zero Successful.
ANT_BPWR_CALIB_ID_FAILED = 0xAF, ///< Calibration Response: Failed.
ANT_BPWR_CALIB_ID_CTF = 0x10, ///< Crank Torque Frequency (CTF) Power sensor Defined Message.
ANT_BPWR_CALIB_ID_AUTO_SUPPORT = 0x12, ///< Auto Zero Support.
ANT_BPWR_CALIB_ID_CUSTOM_REQ = 0xBA, ///< Custom Calibration Parameter Request.
ANT_BPWR_CALIB_ID_CUSTOM_REQ_SUCCESS = 0xBB, ///< Custom Calibration Parameter Response.
ANT_BPWR_CALIB_ID_CUSTOM_UPDATE = 0xBC, ///< Custom Calibration Parameter Update.
ANT_BPWR_CALIB_ID_CUSTOM_UPDATE_SUCCESS = 0xBD, ///< Custom Calibration Parameter Update Response.
} ant_bpwr_calib_id_t;
/**@brief BPWR Calibration Auto Zero Status.
*/
typedef enum
{
ANT_BPWR_AUTO_ZERO_NOT_SUPPORTED = 0xFF, ///< Auto Zero Not Supported.
ANT_BPWR_AUTO_ZERO_OFF = 0x00, ///< Auto Zero OFF.
ANT_BPWR_AUTO_ZERO_ON = 0x01, ///< Auto Zero ON.
} ant_bpwr_auto_zero_status_t;
/**@brief Data structure for Bicycle Power data page 1.
*/
typedef struct
{
ant_bpwr_calib_id_t calibration_id; ///< Calibration request type.
ant_bpwr_auto_zero_status_t auto_zero_status; ///< Status of automatic zero feature of power sensor.
union
{
int16_t general_calib;
uint8_t custom_calib[6];
} data;
} ant_bpwr_page1_data_t;
/**@brief Initialize page 1.
*/
#define DEFAULT_ANT_BPWR_PAGE1() \
(ant_bpwr_page1_data_t) \
{ \
.calibration_id = ANT_BPWR_CALIB_ID_NONE, \
.auto_zero_status = ANT_BPWR_AUTO_ZERO_NOT_SUPPORTED, \
.data.general_calib = 0x00, \
}
/**@brief Initialize page 1 with the general request.
*/
#define ANT_BPWR_GENERAL_CALIB_REQUEST() \
(ant_bpwr_page1_data_t) \
{ \
.calibration_id = ANT_BPWR_CALIB_ID_MANUAL, \
}
/**@brief Function for encoding page 1.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bpwr_page_1_encode(uint8_t * p_page_buffer,
ant_bpwr_page1_data_t const * p_page_data);
/**@brief Function for decoding page 1.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_bpwr_page_1_decode(uint8_t const * p_page_buffer,
ant_bpwr_page1_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BPWR_PAGE_1_H__
/** @} */
@@ -0,0 +1,116 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "sdk_common.h"
#if NRF_MODULE_ENABLED(ANT_BPWR)
#include "ant_bpwr_page_16.h"
#define NRF_LOG_MODULE_NAME "ANT_BPWR_PAGE_16"
#if ANT_BPWR_PAGE_16_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BPWR_PAGE_16_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BPWR_PAGE_16_INFO_COLOR
#else // ANT_BPWR_PAGE_16_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BPWR_PAGE_16_LOG_ENABLED
#include "nrf_log.h"
/**@brief bicycle power page 16 data layout structure. */
typedef struct
{
uint8_t update_event_count;
uint8_t pedal_power;
uint8_t reserved;
uint8_t accumulated_power[2];
uint8_t instantaneous_power[2];
}ant_bpwr_page16_data_layout_t;
static void page16_data_log(ant_bpwr_page16_data_t const * p_page_data)
{
NRF_LOG_INFO("event count: %u\r\n", p_page_data->update_event_count);
if (p_page_data->pedal_power.byte != 0xFF)
{
NRF_LOG_INFO("pedal power: %u %%\r\n",
p_page_data->pedal_power.items.distribution);
}
else
{
NRF_LOG_INFO("pedal power: --\r\n");
}
NRF_LOG_INFO("accumulated power: %u W\r\n", p_page_data->accumulated_power);
NRF_LOG_INFO("instantaneous power: %u W\r\n", p_page_data->instantaneous_power);
}
void ant_bpwr_page_16_encode(uint8_t * p_page_buffer,
ant_bpwr_page16_data_t const * p_page_data)
{
ant_bpwr_page16_data_layout_t * p_outcoming_data =
(ant_bpwr_page16_data_layout_t *)p_page_buffer;
p_outcoming_data->update_event_count = p_page_data->update_event_count;
p_outcoming_data->pedal_power = p_page_data->pedal_power.byte;
UNUSED_PARAMETER(uint16_encode(p_page_data->accumulated_power,
p_outcoming_data->accumulated_power));
UNUSED_PARAMETER(uint16_encode(p_page_data->instantaneous_power,
p_outcoming_data->instantaneous_power));
page16_data_log(p_page_data);
}
void ant_bpwr_page_16_decode(uint8_t const * p_page_buffer,
ant_bpwr_page16_data_t * p_page_data)
{
ant_bpwr_page16_data_layout_t const * p_incoming_data =
(ant_bpwr_page16_data_layout_t *)p_page_buffer;
p_page_data->update_event_count = p_incoming_data->update_event_count;
p_page_data->pedal_power.byte = p_incoming_data->pedal_power;
p_page_data->accumulated_power = uint16_decode(p_incoming_data->accumulated_power);
p_page_data->instantaneous_power = uint16_decode(p_incoming_data->instantaneous_power);
page16_data_log(p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BPWR)
@@ -0,0 +1,111 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BPWR_PAGE_16_H__
#define ANT_BPWR_PAGE_16_H__
/** @file
*
* @defgroup ant_sdk_profiles_bpwr_page16 Bicycle Power profile page 16
* @{
* @ingroup ant_sdk_profiles_bpwr_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for Bicycle Power data page 16.
*
* @note This structure implements only page 16 specific data.
*/
typedef struct
{
union
{
struct
{
uint8_t distribution : 7; ///< Pedal power distribution (%).
uint8_t differentiation : 1; ///< Pedal differentiation: 1 -> right, 0 -> unknown.
} items;
uint8_t byte;
} pedal_power;
uint8_t update_event_count; ///< Power event count.
uint16_t accumulated_power; ///< Accumulated power (W).
uint16_t instantaneous_power; ///< Instantaneous power (W).
} ant_bpwr_page16_data_t;
/**@brief Initialize page 16.
*/
#define DEFAULT_ANT_BPWR_PAGE16() \
(ant_bpwr_page16_data_t) \
{ \
.update_event_count = 0, \
.pedal_power.items.distribution = 0, \
.pedal_power.items.differentiation = 0, \
.accumulated_power = 0, \
.instantaneous_power = 0, \
}
/**@brief Function for encoding page 16.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bpwr_page_16_encode(uint8_t * p_page_buffer,
ant_bpwr_page16_data_t const * p_page_data);
/**@brief Function for decoding page 16.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_bpwr_page_16_decode(uint8_t const * p_page_buffer,
ant_bpwr_page16_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BPWR_PAGE_16_H__
/** @} */
@@ -0,0 +1,76 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "sdk_common.h"
#if NRF_MODULE_ENABLED(ANT_BPWR)
#include "ant_bpwr_page_17.h"
#define NRF_LOG_MODULE_NAME "ANT_BPWR_PAGE_17"
#if ANT_BPWR_PAGE_17_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BPWR_PAGE_17_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BPWR_PAGE_17_INFO_COLOR
#else // ANT_BPWR_PAGE_17_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BPWR_PAGE_17_LOG_ENABLED
#include "nrf_log.h"
static void page17_data_log(ant_bpwr_page17_data_t const * p_page_data)
{
NRF_LOG_INFO("Wheel:\r\n");
ant_bpwr_page_torque_log((ant_bpwr_page_torque_data_t *) p_page_data);
}
void ant_bpwr_page_17_encode(uint8_t * p_page_buffer,
ant_bpwr_page17_data_t const * p_page_data)
{
ant_bpwr_page_torque_encode(p_page_buffer, (ant_bpwr_page_torque_data_t *)p_page_data);
page17_data_log(p_page_data);
}
void ant_bpwr_page_17_decode(uint8_t const * p_page_buffer,
ant_bpwr_page17_data_t * p_page_data)
{
ant_bpwr_page_torque_decode(p_page_buffer, (ant_bpwr_page_torque_data_t *) p_page_data);
page17_data_log(p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BPWR)
@@ -0,0 +1,89 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BPWR_PAGE_17_H__
#define ANT_BPWR_PAGE_17_H__
/** @file
*
* @defgroup ant_sdk_profiles_bpwr_page17 Bicycle Power profile page 17
* @{
* @ingroup ant_sdk_profiles_bpwr_pages
*/
#include <stdint.h>
#include "ant_bpwr_page_torque.h"
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for Bicycle Power data page 17.
*
* @note This structure implements only page 17 specific data.
*/
typedef ant_bpwr_page_torque_data_t ant_bpwr_page17_data_t;
/**@brief Initialize page 17.
*/
#define DEFAULT_ANT_BPWR_PAGE17() (ant_bpwr_page17_data_t) DEFAULT_ANT_BPWR_PAGE_TORQUE(0, 0, 0, 0)
/**@brief Function for encoding page 17.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bpwr_page_17_encode(uint8_t * p_page_buffer,
ant_bpwr_page17_data_t const * p_page_data);
/**@brief Function for decoding page 17.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_bpwr_page_17_decode(uint8_t const * p_page_buffer,
ant_bpwr_page17_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BPWR_PAGE_17_H__
/** @} */
@@ -0,0 +1,76 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "sdk_common.h"
#if NRF_MODULE_ENABLED(ANT_BPWR)
#include "ant_bpwr_page_18.h"
#define NRF_LOG_MODULE_NAME "ANT_BPWR_PAGE_18"
#if ANT_BPWR_PAGE_18_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BPWR_PAGE_18_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BPWR_PAGE_18_INFO_COLOR
#else // ANT_BPWR_PAGE_18_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BPWR_PAGE_18_LOG_ENABLED
#include "nrf_log.h"
static void page18_data_log(ant_bpwr_page18_data_t const * p_page_data)
{
NRF_LOG_INFO("Crank:\r\n");
ant_bpwr_page_torque_log((ant_bpwr_page_torque_data_t *) p_page_data);
}
void ant_bpwr_page_18_encode(uint8_t * p_page_buffer,
ant_bpwr_page18_data_t const * p_page_data)
{
ant_bpwr_page_torque_encode(p_page_buffer, (ant_bpwr_page_torque_data_t *)p_page_data);
page18_data_log(p_page_data);
}
void ant_bpwr_page_18_decode(uint8_t const * p_page_buffer,
ant_bpwr_page18_data_t * p_page_data)
{
ant_bpwr_page_torque_decode(p_page_buffer, (ant_bpwr_page_torque_data_t *) p_page_data);
page18_data_log(p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BPWR)
@@ -0,0 +1,89 @@
/**
* Copyright (c) 2011 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BPWR_PAGE_18_H__
#define ANT_BPWR_PAGE_18_H__
/** @file
*
* @defgroup ant_sdk_profiles_bpwr_page18 Bicycle Power profile page 18
* @{
* @ingroup ant_sdk_profiles_bpwr_pages
*/
#include <stdint.h>
#include "ant_bpwr_page_torque.h"
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for Bicycle Power data page 18.
*
* @note This structure implements only page 18 specific data.
*/
typedef ant_bpwr_page_torque_data_t ant_bpwr_page18_data_t;
/**@brief Initialize page 18.
*/
#define DEFAULT_ANT_BPWR_PAGE18() (ant_bpwr_page18_data_t) DEFAULT_ANT_BPWR_PAGE_TORQUE(0, 0, 0, 0)
/**@brief Function for encoding page 18.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bpwr_page_18_encode(uint8_t * p_page_buffer,
ant_bpwr_page18_data_t const * p_page_data);
/**@brief Function for decoding page 18.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_bpwr_page_18_decode(uint8_t const * p_page_buffer,
ant_bpwr_page18_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BPWR_PAGE_18_H__
/** @} */
@@ -0,0 +1,112 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "sdk_common.h"
#if NRF_MODULE_ENABLED(ANT_BPWR)
#include <stdio.h>
#include "ant_bpwr_page_torque.h"
#include "ant_bpwr_utils.h"
#define NRF_LOG_MODULE_NAME "ANT_BPWR_PAGE_TORQUE"
#if ANT_BPWR_PAGE_TORQUE_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BPWR_PAGE_TORQUE_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BPWR_PAGE_TORQUE_INFO_COLOR
#else // ANT_BPWR_PAGE_TORQUE_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BPWR_PAGE_TORQUE_LOG_ENABLED
#include "nrf_log.h"
/**@brief bicycle power page torque data layout structure. */
typedef struct
{
uint8_t update_event_count;
uint8_t tick;
uint8_t reserved;
uint8_t period[2];
uint8_t accumulated_torque[2];
}ant_bpwr_page_torque_data_layout_t;
STATIC_ASSERT(ANT_BPWR_TORQUE_PERIOD_DISP_PRECISION == 1000); ///< Display format need to be updated
STATIC_ASSERT(ANT_BPWR_ACC_TORQUE_DISP_PRECISION == 10); ///< Display format need to be updated
void ant_bpwr_page_torque_log(ant_bpwr_page_torque_data_t const * p_page_data)
{
uint16_t period = ANT_BPWR_TORQUE_PERIOD_RESCALE(p_page_data->period);
uint32_t acc_torque = ANT_BPWR_ACC_TORQUE_RESCALE(p_page_data->accumulated_torque);
NRF_LOG_INFO("event count: %u\r\n", p_page_data->update_event_count);
NRF_LOG_INFO("tick: %u\r\n", p_page_data->tick);
NRF_LOG_INFO("period: %u.%03us\r\n",
(unsigned int)(period / ANT_BPWR_TORQUE_PERIOD_DISP_PRECISION),
(unsigned int)(period % ANT_BPWR_TORQUE_PERIOD_DISP_PRECISION));
NRF_LOG_INFO("accumulated torque: %u.%01uNm\r\n",
(unsigned int)(acc_torque / ANT_BPWR_ACC_TORQUE_DISP_PRECISION),
(unsigned int)(acc_torque % ANT_BPWR_ACC_TORQUE_DISP_PRECISION));
}
void ant_bpwr_page_torque_encode(uint8_t * p_page_buffer,
ant_bpwr_page_torque_data_t const * p_page_data)
{
ant_bpwr_page_torque_data_layout_t * p_outcoming_data =
(ant_bpwr_page_torque_data_layout_t *)p_page_buffer;
p_outcoming_data->update_event_count = p_page_data->update_event_count;
p_outcoming_data->tick = p_page_data->tick;
UNUSED_PARAMETER(uint16_encode(p_page_data->period, p_outcoming_data->period));
UNUSED_PARAMETER(uint16_encode(p_page_data->accumulated_torque,
p_outcoming_data->accumulated_torque));
}
void ant_bpwr_page_torque_decode(uint8_t const * p_page_buffer,
ant_bpwr_page_torque_data_t * p_page_data)
{
ant_bpwr_page_torque_data_layout_t const * p_incoming_data =
(ant_bpwr_page_torque_data_layout_t *)p_page_buffer;
p_page_data->update_event_count = p_incoming_data->update_event_count;
p_page_data->tick = p_incoming_data->tick;
p_page_data->period = uint16_decode(p_incoming_data->period);
p_page_data->accumulated_torque = uint16_decode(p_incoming_data->accumulated_torque);
}
#endif // NRF_MODULE_ENABLED(ANT_BPWR)
@@ -0,0 +1,106 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BPWR_PAGE_TORQUE_COMMON_H__
#define ANT_BPWR_PAGE_TORQUE_COMMON_H__
/** @file
*
* @defgroup ant_sdk_profiles_bicycle_p_page_torque Bicycle Power profile pages 17, 18 (commons)
* @{
* @ingroup ant_sdk_profiles_bpwr_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Common data structure for Bicycle Power data pages 17, 18.
*
* @note This structure implements specific data that is common for pages 17, 18.
*/
typedef struct
{
uint8_t update_event_count; ///< Power event count.
uint8_t tick; ///< Wheel/crank revolutions counter.
uint16_t period; ///< Accumulated wheel/crank period (1/2048 s).
uint16_t accumulated_torque; ///< Accumulated wheel/torque (1/32 Nm).
} ant_bpwr_page_torque_data_t;
/**@brief Initialize page torque.
*/
#define DEFAULT_ANT_BPWR_PAGE_TORQUE(up_evt_cnt, def_tick, def_period, acc_torque) \
{ \
.update_event_count = (up_evt_cnt), \
.tick = (def_tick), \
.period = (def_period), \
.accumulated_torque = (acc_torque) \
}
/**@brief Function for encoding pages 17, 18.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bpwr_page_torque_encode(uint8_t * p_page_buffer,
ant_bpwr_page_torque_data_t const * p_page_data);
/**@brief Function for decoding pages 17, 18.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_bpwr_page_torque_decode(uint8_t const * p_page_buffer,
ant_bpwr_page_torque_data_t * p_page_data);
/**@brief Function for logging pages 17, 18.
*
* @param[in] p_page_data Pointer to the page data.
*/
void ant_bpwr_page_torque_log(ant_bpwr_page_torque_data_t const * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BPWR_PAGE_TORQUE_COMMON_H__
/** @} */
@@ -0,0 +1,69 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BPWR_PAGES_H__
#define ANT_BPWR_PAGES_H__
/** @file
*
* @defgroup ant_sdk_profiles_bpwr_pages Bicycle Power profile pages
* @{
* @ingroup ant_bpwr
* @brief This module implements functions for the BPWR data pages.
*/
#include "ant_bpwr_page_1.h" // Calibration message main data page.
#include "ant_bpwr_page_16.h" // Standard power-only page.
#include "ant_bpwr_page_17.h" // Wheel Torque main data page.
#include "ant_bpwr_page_18.h" // Crank Torque main data page.
#include "ant_bpwr_common_data.h" // Instantaneous cadence data.
#include "ant_common_page_80.h" // Manufacturer's information data page.
#include "ant_common_page_81.h" // Product information data page.
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif // ANT_BPWR_PAGES_H__
/** @} */
@@ -0,0 +1,123 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BPWR_SIMULATOR_H__
#define ANT_BPWR_SIMULATOR_H__
/** @file
*
* @defgroup ant_sdk_simulators ANT simulators
* @ingroup ant_sdk_utils
* @brief Modules that simulate sensors.
*
* @defgroup ant_sdk_bpwr_simulator ANT BPWR simulator
* @{
* @ingroup ant_sdk_simulators
* @brief ANT BPWR simulator module.
*
* @details This module simulates power for the ANT BPWR profile. The module calculates
* abstract values, which are handled by the BPWR pages data model to ensure that they are
* compatible. It provides a handler for changing the power value manually and functionality
* for changing the power automatically.
*
*/
#include <stdint.h>
#include <stdbool.h>
#include "bsp.h"
#include "ant_bpwr.h"
#include "sensorsim.h"
#include "ant_bpwr_simulator_local.h"
#ifdef __cplusplus
extern "C" {
#endif
/**@brief BPWR simulator configuration structure. */
typedef struct
{
ant_bpwr_profile_t * p_profile; ///< Related profile.
ant_bpwr_torque_t sensor_type; ///< Type of related sensor.
} ant_bpwr_simulator_cfg_t;
/**@brief BPWR simulator structure. */
typedef struct
{
ant_bpwr_profile_t * p_profile; ///< Related profile.
ant_bpwr_simulator_cb_t _cb; ///< Internal control block.
} ant_bpwr_simulator_t;
/**@brief Function for initializing the ANT BPWR 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 power.
*/
void ant_bpwr_simulator_init(ant_bpwr_simulator_t * p_simulator,
ant_bpwr_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 BPWR TX event handler.
*/
void ant_bpwr_simulator_one_iteration(ant_bpwr_simulator_t * p_simulator, ant_bpwr_evt_t event);
/**@brief Function for incrementing the power value.
*
* @param[in] p_simulator Pointer to the simulator instance.
*/
void ant_bpwr_simulator_increment(ant_bpwr_simulator_t * p_simulator);
/**@brief Function for decrementing the power value.
*
* @param[in] p_simulator Pointer to the simulator instance.
*/
void ant_bpwr_simulator_decrement(ant_bpwr_simulator_t * p_simulator);
#ifdef __cplusplus
}
#endif
#endif // ANT_BPWR_SIMULATOR_H__
/** @} */
@@ -0,0 +1,74 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BPWR_SIMULATOR_LOCAL_H__
#define ANT_BPWR_SIMULATOR_LOCAL_H__
#include <stdint.h>
#include <stdbool.h>
#include "bsp.h"
#include "ant_bpwr.h"
#include "sensorsim.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @ingroup ant_sdk_bpwr_simulator
* @brief BPWR simulator control block structure. */
typedef struct
{
bool auto_change; ///< Power will change automatically (if auto_change is set) or manually.
uint32_t tick_incr; ///< Fractional part of tick increment.
sensorsim_state_t power_sensorsim_state; ///< Power state of the simulated sensor.
sensorsim_cfg_t power_sensorsim_cfg; ///< Power configuration of the simulated sensor.
sensorsim_state_t cadence_sensorsim_state; ///< Cadence stated of the simulated sensor.
sensorsim_cfg_t cadence_sensorsim_cfg; ///< Cadence configuration of the simulated sensor.
sensorsim_state_t pedal_sensorsim_state; ///< Pedal state of the simulated sensor.
sensorsim_cfg_t pedal_sensorsim_cfg; ///< Pedal configuration of the simulated sensor.
}ant_bpwr_simulator_cb_t;
#ifdef __cplusplus
}
#endif
#endif // ANT_BPWR_SIMULATOR_LOCAL_H__
@@ -0,0 +1,86 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BPWR_UTILS_H__
#define ANT_BPWR_UTILS_H__
#include "app_util.h"
#include "nrf_assert.h"
#include "nrf.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @file
*
* @defgroup ant_sdk_profiles_bpwr_utils Bicycle Power profile utilities
* @{
* @ingroup ant_bpwr
* @brief This module implements utilities for the Bicycle Power profile.
*
*/
/*@brief A reversal of torque period unit.
*
* @details According to the ANT BPWR specification, the torque period unit is 1/2048 of a second.
*/
#define ANT_BPWR_TORQUE_PERIOD_UNIT_REVERSAL 2048
#define ANT_BPWR_TORQUE_PERIOD_DISP_PRECISION 1000
#define ANT_BPWR_TORQUE_PERIOD_RESCALE(VALUE) value_rescale((VALUE), ANT_BPWR_TORQUE_PERIOD_UNIT_REVERSAL, \
ANT_BPWR_TORQUE_PERIOD_DISP_PRECISION)
/*@brief A reversal of accumulated torque unit.
*
* @details According to the ANT BPWR specification, the accumulated torque unit is 1/32 of a Nm.
*/
#define ANT_BPWR_ACC_TORQUE_UNIT_REVERSAL 32
#define ANT_BPWR_ACC_TORQUE_DISP_PRECISION 10
#define ANT_BPWR_ACC_TORQUE_RESCALE(VALUE) value_rescale((VALUE), ANT_BPWR_ACC_TORQUE_UNIT_REVERSAL, \
ANT_BPWR_ACC_TORQUE_DISP_PRECISION)
/** @} */
#ifdef __cplusplus
}
#endif
#endif // ANT_BPWR_UTILS_H__
@@ -0,0 +1,83 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BSC_LOCAL_H__
#define ANT_BSC_LOCAL_H__
#include <stdint.h>
#include <stdbool.h>
#include "ant_bsc.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @addtogroup ant_bsc
* @{
*/
/**@brief BSC Sensor control block. */
typedef struct
{
uint8_t device_type;
uint8_t toggle_bit : 1;
ant_bsc_page_t main_page_number : 7;
uint8_t page_1_present : 1;
uint8_t page_4_present : 1;
ant_bsc_page_t bkgd_page_number : 6;
uint8_t message_counter;
}ant_bsc_sens_cb_t;
/**@brief BSC Display control block. */
typedef struct
{
uint8_t device_type;
}ant_bsc_disp_cb_t;
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif // ANT_BSC_LOCAL_H__
@@ -0,0 +1,128 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "sdk_common.h"
#if NRF_MODULE_ENABLED(ANT_BSC)
#include "ant_bsc_combined_page_0.h"
#include "ant_bsc_utils.h"
#define NRF_LOG_MODULE_NAME "ANT_BCS_COMBINED_PAGE_0"
#if ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BSC_COMBINED_PAGE_0_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BSC_COMBINED_PAGE_0_INFO_COLOR
#else // ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED
#include "nrf_log.h"
/**@brief BSC page 0 data layout structure. */
typedef struct
{
uint8_t cadence_evt_time_LSB;
uint8_t cadence_evt_time_MSB;
uint8_t cadence_rev_count_LSB;
uint8_t cadence_rev_count_MSB;
uint8_t speed_evt_time_LSB;
uint8_t speed_evt_time_MSB;
uint8_t speed_rev_count_LSB;
uint8_t speed_rev_count_MSB;
}ant_bsc_combined_page0_data_layout_t;
/**@brief Function for printing combined speed and cadence page0 data. */
static void comb_page0_data_log(ant_bsc_combined_page0_data_t const * p_page_data)
{
NRF_LOG_INFO("Cadence Revolution count: %u\r\n",
(unsigned int)p_page_data->cadence_rev_count);
NRF_LOG_INFO("Cadence event time: %u.%03us\r\n",
(unsigned int)ANT_BSC_EVENT_TIME_SEC(p_page_data->cadence_event_time),
(unsigned int)ANT_BSC_EVENT_TIME_MSEC(p_page_data->cadence_event_time));
NRF_LOG_INFO("Speed Revolution count: %u\r\n",
(unsigned int)p_page_data->speed_rev_count);
NRF_LOG_INFO("Speed event time: %u.%03us\r\n\n",
(unsigned int)ANT_BSC_EVENT_TIME_SEC(p_page_data->speed_event_time),
(unsigned int)ANT_BSC_EVENT_TIME_MSEC(p_page_data->speed_event_time));
}
void ant_bsc_combined_page_0_encode(uint8_t * p_page_buffer, ant_bsc_combined_page0_data_t const * p_page_data)
{
ant_bsc_combined_page0_data_layout_t * p_outcoming_data = (ant_bsc_combined_page0_data_layout_t *) p_page_buffer;
uint16_t cadence_event_time = p_page_data->cadence_event_time;
uint16_t cadence_rev_count = p_page_data->cadence_rev_count;
uint16_t speed_event_time = p_page_data->speed_event_time;
uint16_t speed_rev_count = p_page_data->speed_rev_count;
p_outcoming_data->cadence_evt_time_LSB = (uint8_t)(cadence_event_time & UINT8_MAX);
p_outcoming_data->cadence_evt_time_MSB = (uint8_t)((cadence_event_time >> 8) & UINT8_MAX);
p_outcoming_data->cadence_rev_count_LSB = (uint8_t)(cadence_rev_count & UINT8_MAX);
p_outcoming_data->cadence_rev_count_MSB = (uint8_t)((cadence_rev_count >> 8) & UINT8_MAX);
p_outcoming_data->speed_evt_time_LSB = (uint8_t)(speed_event_time & UINT8_MAX);
p_outcoming_data->speed_evt_time_MSB = (uint8_t)((speed_event_time >> 8) & UINT8_MAX);
p_outcoming_data->speed_rev_count_LSB = (uint8_t)(speed_rev_count & UINT8_MAX);
p_outcoming_data->speed_rev_count_MSB = (uint8_t)((speed_rev_count >> 8) & UINT8_MAX);
comb_page0_data_log(p_page_data);
}
void ant_bsc_combined_page_0_decode(uint8_t const * p_page_buffer, ant_bsc_combined_page0_data_t * p_page_data)
{
ant_bsc_combined_page0_data_layout_t const * p_incoming_data = (ant_bsc_combined_page0_data_layout_t *)p_page_buffer;
uint16_t cadence_event_time = (uint16_t)((p_incoming_data->cadence_evt_time_MSB << 8)
+ p_incoming_data->cadence_evt_time_LSB);
uint16_t cadence_revolution_count = (uint16_t) ((p_incoming_data->cadence_rev_count_MSB << 8)
+ p_incoming_data->cadence_rev_count_LSB);
uint16_t speed_event_time = (uint16_t)((p_incoming_data->speed_evt_time_MSB << 8)
+ p_incoming_data->speed_evt_time_LSB);
uint16_t speed_revolution_count = (uint16_t) ((p_incoming_data->speed_rev_count_MSB << 8)
+ p_incoming_data->speed_rev_count_LSB);
p_page_data->cadence_event_time = cadence_event_time;
p_page_data->cadence_rev_count = cadence_revolution_count;
p_page_data->speed_event_time = speed_event_time;
p_page_data->speed_rev_count = speed_revolution_count;
comb_page0_data_log(p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BSC)
@@ -0,0 +1,99 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BSC_COMBINED_PAGE_0_H__
#define ANT_BSC_COMBINED_PAGE_0_H__
/** @file
*
* @defgroup ant_sdk_profiles_bsc_combined_page0 BSC profile page 0 (combined speed & cadence)
* @{
* @ingroup ant_sdk_profiles_bsc_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for Bicycle Combined Speed and Cadence data page 0.
*
* This structure is used as a common page.
*/
typedef struct
{
uint16_t cadence_event_time; ///< Cadence event time.
uint16_t cadence_rev_count; ///< Cadence revolution count.
uint16_t speed_event_time; ///< Speed event time.
uint16_t speed_rev_count; ///< Speed revolution count.
} ant_bsc_combined_page0_data_t;
/**@brief Initialize page 0.
*/
#define DEFAULT_ANT_BSC_COMBINED_PAGE0() \
(ant_bsc_combined_page0_data_t) \
{ \
.cadence_event_time = 0, \
.cadence_rev_count = 0, \
.speed_event_time = 0, \
.speed_rev_count = 0, \
}
/**@brief Function for encoding page 0.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bsc_combined_page_0_encode(uint8_t * p_page_buffer, ant_bsc_combined_page0_data_t const * p_page_data);
/**@brief Function for decoding page 0.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_bsc_combined_page_0_decode(uint8_t const * p_page_buffer, ant_bsc_combined_page0_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BSC_COMBINED_PAGE_0_H__
/** @} */
@@ -0,0 +1,110 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "sdk_common.h"
#if NRF_MODULE_ENABLED(ANT_BSC)
#include "ant_bsc_page_0.h"
#include "ant_bsc_utils.h"
#define NRF_LOG_MODULE_NAME "ANT_BCS_PAGE_0"
#if ANT_BSC_PAGE_0_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BSC_PAGE_0_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BSC_PAGE_0_INFO_COLOR
#else // ANT_BSC_PAGE_0_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BSC_PAGE_0_LOG_ENABLED
#include "nrf_log.h"
/**@brief BSC page 0 data layout structure. */
typedef struct
{
uint8_t reserved[3];
uint8_t bsc_evt_time_LSB;
uint8_t bsc_evt_time_MSB;
uint8_t bsc_rev_count_LSB;
uint8_t bsc_rev_count_MSB;
}ant_bsc_page0_data_layout_t;
/**@brief Function for printing speed or cadence page0 data. */
static void page0_data_log(ant_bsc_page0_data_t const * p_page_data)
{
NRF_LOG_INFO("Revolution count: %u\r\n", (unsigned int)p_page_data->rev_count);
NRF_LOG_INFO("BSC event time: %u.%03us\r\n",
(unsigned int)ANT_BSC_EVENT_TIME_SEC(p_page_data->event_time),
(unsigned int)ANT_BSC_EVENT_TIME_MSEC(p_page_data->event_time));
// NRF_LOG_INFO("%03us\r\n", (unsigned int)ANT_BSC_EVENT_TIME_MSEC(p_page_data->event_time));
}
void ant_bsc_page_0_encode(uint8_t * p_page_buffer, ant_bsc_page0_data_t const * p_page_data)
{
ant_bsc_page0_data_layout_t * p_outcoming_data = (ant_bsc_page0_data_layout_t *) p_page_buffer;
uint16_t event_time = p_page_data->event_time;
uint16_t rev_count = p_page_data->rev_count;
p_outcoming_data->reserved[0] = UINT8_MAX;
p_outcoming_data->reserved[1] = UINT8_MAX;
p_outcoming_data->reserved[2] = UINT8_MAX;
p_outcoming_data->bsc_evt_time_LSB = (uint8_t)(event_time & UINT8_MAX);
p_outcoming_data->bsc_evt_time_MSB = (uint8_t)((event_time >> 8) & UINT8_MAX);
p_outcoming_data->bsc_rev_count_LSB = (uint8_t)(rev_count & UINT8_MAX);
p_outcoming_data->bsc_rev_count_MSB = (uint8_t)((rev_count >> 8) & UINT8_MAX);
page0_data_log(p_page_data);
}
void ant_bsc_page_0_decode(uint8_t const * p_page_buffer, ant_bsc_page0_data_t * p_page_data)
{
ant_bsc_page0_data_layout_t const * p_incoming_data = (ant_bsc_page0_data_layout_t *)p_page_buffer;
uint16_t event_time = (uint16_t)((p_incoming_data->bsc_evt_time_MSB << 8)
+ p_incoming_data->bsc_evt_time_LSB);
uint16_t revolution_count = (uint16_t) ((p_incoming_data->bsc_rev_count_MSB << 8)
+ p_incoming_data->bsc_rev_count_LSB);
p_page_data->event_time = event_time;
p_page_data->rev_count = revolution_count;
page0_data_log(p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BSC)
@@ -0,0 +1,95 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BSC_PAGE_0_H__
#define ANT_BSC_PAGE_0_H__
/** @file
*
* @defgroup ant_sdk_profiles_bsc_page0 BSC profile page 0
* @{
* @ingroup ant_sdk_profiles_bsc_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for BSC data page 0.
*
* This structure is used as a common page.
*/
typedef struct
{
uint16_t event_time; ///< Speed or cadence event time.
uint16_t rev_count; ///< Speed or cadence revolution count.
} ant_bsc_page0_data_t;
/**@brief Initialize page 0.
*/
#define DEFAULT_ANT_BSC_PAGE0() \
(ant_bsc_page0_data_t) \
{ \
.event_time = 0, \
.rev_count = 0 \
}
/**@brief Function for encoding page 0.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bsc_page_0_encode(uint8_t * p_page_buffer, ant_bsc_page0_data_t const * p_page_data);
/**@brief Function for decoding page 0.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_bsc_page_0_decode(uint8_t const * p_page_buffer, ant_bsc_page0_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BSC_PAGE_0_H__
/** @} */
@@ -0,0 +1,93 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "sdk_common.h"
#if NRF_MODULE_ENABLED(ANT_BSC)
#include "ant_bsc_page_1.h"
#include "ant_bsc_utils.h"
#include "app_util.h"
#include "nordic_common.h"
#define NRF_LOG_MODULE_NAME "ANT_BCS_PAGE_1"
#if ANT_BSC_PAGE_1_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BSC_PAGE_1_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BSC_PAGE_1_INFO_COLOR
#else // ANT_BSC_PAGE_1_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BSC_PAGE_1_LOG_ENABLED
#include "nrf_log.h"
/**@brief BSC page 1 data layout structure. */
typedef struct
{
uint8_t cumulative_operating_time[3];
uint8_t reserved[4];
}ant_bsc_page1_data_layout_t;
/**@brief Function for printing speed or cadence page1 data. */
static void page1_data_log(ant_bsc_page1_data_t const * p_page_data)
{
NRF_LOG_INFO("Cumulative operating time: %ud %uh %um %us\r\n",
(unsigned int)ANT_BSC_OPERATING_DAYS(p_page_data->operating_time),
(unsigned int)ANT_BSC_OPERATING_HOURS(p_page_data->operating_time),
(unsigned int)ANT_BSC_OPERATING_MINUTES(p_page_data->operating_time),
(unsigned int)ANT_BSC_OPERATING_SECONDS(p_page_data->operating_time));
}
void ant_bsc_page_1_encode(uint8_t * p_page_buffer, ant_bsc_page1_data_t const * p_page_data)
{
ant_bsc_page1_data_layout_t * p_outcoming_data = (ant_bsc_page1_data_layout_t *)p_page_buffer;
UNUSED_PARAMETER(uint24_encode(p_page_data->operating_time,
p_outcoming_data->cumulative_operating_time));
page1_data_log( p_page_data);
}
void ant_bsc_page_1_decode(uint8_t const * p_page_buffer, ant_bsc_page1_data_t * p_page_data)
{
ant_bsc_page1_data_layout_t const * p_incoming_data = (ant_bsc_page1_data_layout_t *)p_page_buffer;
p_page_data->operating_time = uint24_decode(p_incoming_data->cumulative_operating_time);
page1_data_log( p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BSC)
@@ -0,0 +1,93 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BSC_PAGE_1_H__
#define ANT_BSC_PAGE_1_H__
/** @file
*
* @defgroup ant_sdk_profiles_bsc_page1 BSC profile page 1
* @{
* @ingroup ant_sdk_profiles_bsc_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for BSC data page 1.
*
* This structure implements only page 1 specific data.
*/
typedef struct
{
uint32_t operating_time; ///< Operating time.
} ant_bsc_page1_data_t;
/**@brief Initialize page 1.
*/
#define DEFAULT_ANT_BSC_PAGE1() \
(ant_bsc_page1_data_t) \
{ \
.operating_time = 0, \
}
/**@brief Function for encoding page 1.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bsc_page_1_encode(uint8_t * p_page_buffer, ant_bsc_page1_data_t const * p_page_data);
/**@brief Function for decoding page 1.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_bsc_page_1_decode(uint8_t const * p_page_buffer, ant_bsc_page1_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BSC_PAGE_1_H__
/** @} */
@@ -0,0 +1,95 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "sdk_common.h"
#if NRF_MODULE_ENABLED(ANT_BSC)
#include "ant_bsc_page_2.h"
#define NRF_LOG_MODULE_NAME "ANT_BCS_PAGE_2"
#if ANT_BSC_PAGE_2_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BSC_PAGE_2_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BSC_PAGE_2_INFO_COLOR
#else // ANT_BSC_PAGE_2_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BSC_PAGE_2_LOG_ENABLED
#include "nrf_log.h"
/**@brief BSC page 2 data layout structure. */
typedef struct
{
uint8_t manuf_id;
uint8_t serial_num_LSB;
uint8_t serial_num_MSB;
uint8_t reserved[4];
}ant_bsc_page2_data_layout_t;
/**@brief Function for printing speed or cadence page2 data. */
static void page2_data_log(ant_bsc_page2_data_t const * p_page_data)
{
NRF_LOG_INFO("Manufacturer ID: %u\r\n", (unsigned int)p_page_data->manuf_id);
NRF_LOG_INFO("Serial No (upper 16-bits): 0x%X\r\n",
(unsigned int)p_page_data->serial_num);
}
void ant_bsc_page_2_encode(uint8_t * p_page_buffer, ant_bsc_page2_data_t const * p_page_data)
{
ant_bsc_page2_data_layout_t * p_outcoming_data = (ant_bsc_page2_data_layout_t *)p_page_buffer;
uint32_t serial_num = p_page_data->serial_num;
p_outcoming_data->manuf_id = (uint8_t)p_page_data->manuf_id;
p_outcoming_data->serial_num_LSB = (uint8_t)(serial_num & UINT8_MAX);
p_outcoming_data->serial_num_MSB = (uint8_t)((serial_num >> 8) & UINT8_MAX);
page2_data_log( p_page_data);
}
void ant_bsc_page_2_decode(uint8_t const * p_page_buffer, ant_bsc_page2_data_t * p_page_data)
{
ant_bsc_page2_data_layout_t const * p_incoming_data = (ant_bsc_page2_data_layout_t *)p_page_buffer;
uint32_t serial_num = (uint32_t)((p_incoming_data->serial_num_MSB << 8)
+ p_incoming_data->serial_num_LSB);
p_page_data->manuf_id = (uint32_t)p_incoming_data->manuf_id;
p_page_data->serial_num = serial_num;
page2_data_log( p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BSC)
@@ -0,0 +1,95 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BSC_PAGE_2_H__
#define ANT_BSC_PAGE_2_H__
/** @file
*
* @defgroup ant_sdk_profiles_bsc_page2 BSC profile page 2
* @{
* @ingroup ant_sdk_profiles_bsc_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for BSC data page 2.
*
* This structure implements only page 2 specific data.
*/
typedef struct
{
uint8_t manuf_id; ///< Manufacturer ID.
uint16_t serial_num; ///< Serial number.
} ant_bsc_page2_data_t;
/**@brief Initialize page 2.
*/
#define DEFAULT_ANT_BSC_PAGE2() \
(ant_bsc_page2_data_t) \
{ \
.manuf_id = 0, \
.serial_num = 0, \
}
/**@brief Function for encoding page 2.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bsc_page_2_encode(uint8_t * p_page_buffer, ant_bsc_page2_data_t const * p_page_data);
/**@brief Function for decoding page 2.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_bsc_page_2_decode(uint8_t const * p_page_buffer, ant_bsc_page2_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BSC_PAGE_2_H__
/** @} */
@@ -0,0 +1,93 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "sdk_common.h"
#if NRF_MODULE_ENABLED(ANT_BSC)
#include "ant_bsc_page_3.h"
#define NRF_LOG_MODULE_NAME "ANT_BCS_PAGE_3"
#if ANT_BSC_PAGE_3_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BSC_PAGE_3_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BSC_PAGE_3_INFO_COLOR
#else // ANT_BSC_PAGE_3_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BSC_PAGE_3_LOG_ENABLED
#include "nrf_log.h"
/**@brief BSC page 3 data layout structure. */
typedef struct
{
uint8_t hw_version;
uint8_t sw_version;
uint8_t model_num;
uint8_t reserved[4];
}ant_bsc_page3_data_layout_t;
/**@brief Function for printing speed or cadence page3 data. */
static void page3_data_log(ant_bsc_page3_data_t const * p_page_data)
{
NRF_LOG_INFO("Hardware Rev ID: %u\r\n", (unsigned int)p_page_data->hw_version);
NRF_LOG_INFO("Model Number: %u\r\n", (unsigned int)p_page_data->model_num);
NRF_LOG_INFO("Software Ver ID: %u\r\n", (unsigned int)p_page_data->sw_version);
}
void ant_bsc_page_3_encode(uint8_t * p_page_buffer, ant_bsc_page3_data_t const * p_page_data)
{
ant_bsc_page3_data_layout_t * p_outcoming_data = (ant_bsc_page3_data_layout_t *)p_page_buffer;
p_outcoming_data->hw_version = (uint8_t)p_page_data->hw_version;
p_outcoming_data->sw_version = (uint8_t)p_page_data->sw_version;
p_outcoming_data->model_num = (uint8_t)p_page_data->model_num;
page3_data_log( p_page_data);
}
void ant_bsc_page_3_decode(uint8_t const * p_page_buffer, ant_bsc_page3_data_t * p_page_data)
{
ant_bsc_page3_data_layout_t const * p_incoming_data = (ant_bsc_page3_data_layout_t *)p_page_buffer;
p_page_data->hw_version = (uint32_t)p_incoming_data->hw_version;
p_page_data->sw_version = (uint32_t)p_incoming_data->sw_version;
p_page_data->model_num = (uint32_t)p_incoming_data->model_num;
page3_data_log( p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BSC)
@@ -0,0 +1,97 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BSC_PAGE_3_H__
#define ANT_BSC_PAGE_3_H__
/** @file
*
* @defgroup ant_sdk_profiles_bsc_page3 BSC profile page 3
* @{
* @ingroup ant_sdk_profiles_bsc_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for BSC data page 3.
*
* This structure implements only page 3 specific data.
*/
typedef struct
{
uint8_t hw_version; ///< Hardware version.
uint8_t sw_version; ///< Software version.
uint8_t model_num; ///< Model number.
} ant_bsc_page3_data_t;
/**@brief Initialize page 3.
*/
#define DEFAULT_ANT_BSC_PAGE3() \
(ant_bsc_page3_data_t) \
{ \
.hw_version = 0, \
.sw_version = 0, \
.model_num = 0, \
}
/**@brief Function for encoding page 3.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bsc_page_3_encode(uint8_t * p_page_buffer, ant_bsc_page3_data_t const * p_page_data);
/**@brief Function for decoding page 3.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_bsc_page_3_decode(uint8_t const * p_page_buffer, ant_bsc_page3_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BSC_PAGE_3_H__
/** @} */
@@ -0,0 +1,103 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "sdk_common.h"
#if NRF_MODULE_ENABLED(ANT_BSC)
#include "ant_bsc_page_4.h"
#include "ant_bsc_utils.h"
#include "app_util.h"
#define NRF_LOG_MODULE_NAME "ANT_BCS_PAGE_4"
#if ANT_BSC_PAGE_4_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BSC_PAGE_4_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BSC_PAGE_4_INFO_COLOR
#else // ANT_BSC_PAGE_4_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BSC_PAGE_4_LOG_ENABLED
#include "nrf_log.h"
/**@brief BSC page 4 data layout structure. */
typedef struct
{
uint8_t reserved_byte;
uint8_t fract_bat_volt;
uint8_t coarse_bat_volt : 4;
uint8_t bat_status : 3;
uint8_t bitfield_reserved : 1;
uint8_t reserved[4];
}ant_bsc_page4_data_layout_t;
/* Display precission must be updated. */
STATIC_ASSERT(ANT_BSC_BAT_VOLTAGE_PRECISION == 1000);
/**@brief Function for printing speed or cadence page4 data. */
static void page4_data_log( ant_bsc_page4_data_t const * p_page_data)
{
NRF_LOG_INFO("Battery voltage: %u.%03uV\r\n",
(unsigned int)p_page_data->coarse_bat_volt,
(unsigned int)ANT_BSC_BAT_VOLTAGE_FRACTION_MV(p_page_data->fract_bat_volt));
NRF_LOG_INFO("Battery status: %u\r\n", (unsigned int)p_page_data->bat_status);
}
void ant_bsc_page_4_encode(uint8_t * p_page_buffer, ant_bsc_page4_data_t const * p_page_data)
{
ant_bsc_page4_data_layout_t * p_outcoming_data = (ant_bsc_page4_data_layout_t *)p_page_buffer;
p_outcoming_data->reserved_byte = UINT8_MAX;
p_outcoming_data->fract_bat_volt = p_page_data->fract_bat_volt;
p_outcoming_data->coarse_bat_volt = p_page_data->coarse_bat_volt;
p_outcoming_data->bat_status = p_page_data->bat_status;
p_outcoming_data->bitfield_reserved = 0;
page4_data_log( p_page_data);
}
void ant_bsc_page_4_decode(uint8_t const * p_page_buffer, ant_bsc_page4_data_t * p_page_data)
{
ant_bsc_page4_data_layout_t const * p_incoming_data = (ant_bsc_page4_data_layout_t *)p_page_buffer;
p_page_data->fract_bat_volt = p_incoming_data->fract_bat_volt;
p_page_data->coarse_bat_volt = p_incoming_data->coarse_bat_volt;
p_page_data->bat_status = p_incoming_data->bat_status;
page4_data_log( p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BSC)
@@ -0,0 +1,113 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BSC_PAGE_4_H__
#define ANT_BSC_PAGE_4_H__
/** @file
*
* @defgroup ant_sdk_profiles_bsc_page4 BSC profile page 4
* @{
* @ingroup ant_sdk_profiles_bsc_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief BSC profile battery status.
*
* This enum represents possible battery status values for the ANT BSC profile.
*/
typedef enum
{
RESERVED0 = 0, ///< Reserved.
BSC_BAT_STATUS_NEW = 1, ///< Battery status: new.
BSC_BAT_STATUS_GOOD = 2, ///< Battery status: good.
BSC_BAT_STATUS_OK = 3, ///< Battery status: ok.
BSC_BAT_STATUS_LOW = 4, ///< Battery status: low.
BSC_BAT_STATUS_CRITICAL = 5, ///< Battery status: critical.
RESERVED1 = 6, ///< Reserved.
BSC_BAT_STATUS_INVALID = 7 ///< Invalid battery status.
} ant_bsc_bat_status_t;
/**@brief Data structure for BSC data page 4.
*
* This structure implements only page 4 specific data.
*/
typedef struct
{
uint8_t fract_bat_volt; ///< Fractional battery voltage.
uint8_t coarse_bat_volt : 4; ///< Coarse battery voltage.
uint8_t bat_status : 3; ///< Battery status.
} ant_bsc_page4_data_t;
/**@brief Initialize page 4.
*/
#define DEFAULT_ANT_BSC_PAGE4() \
(ant_bsc_page4_data_t) \
{ \
.fract_bat_volt = 0, \
.coarse_bat_volt = 0, \
.bat_status = BSC_BAT_STATUS_INVALID \
}
/**@brief Function for encoding page 4.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bsc_page_4_encode(uint8_t * p_page_buffer, ant_bsc_page4_data_t const * p_page_data);
/**@brief Function for decoding page 4.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_bsc_page_4_decode(uint8_t const * p_page_buffer, ant_bsc_page4_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BSC_PAGE_4_H__
/** @} */
@@ -0,0 +1,96 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "sdk_common.h"
#if NRF_MODULE_ENABLED(ANT_BSC)
#include "ant_bsc_page_5.h"
#include "ant_bsc_utils.h"
#define NRF_LOG_MODULE_NAME "ANT_BCS_PAGE_5"
#if ANT_BSC_PAGE_5_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_BSC_PAGE_5_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_BSC_PAGE_5_INFO_COLOR
#else // ANT_BSC_PAGE_5_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_BSC_PAGE_5_LOG_ENABLED
#include "nrf_log.h"
/**@brief BSC profile page 5 bitfields definitions. */
#define ANT_BSC_STOP_IND_MASK 0x01
/**@brief BSC page 5 data layout structure. */
typedef struct
{
uint8_t flags;
uint8_t reserved[6];
}ant_bsc_page5_data_layout_t;
/**@brief Function for printing speed or cadence page5 data. */
static void page5_data_log(ant_bsc_page5_data_t const * p_page_data)
{
if (p_page_data->stop_indicator)
{
NRF_LOG_INFO("Bicycle stopped.\r\n");
}
else
{
NRF_LOG_INFO("Bicycle moving.\r\n");
}
}
void ant_bsc_page_5_encode(uint8_t * p_page_buffer, ant_bsc_page5_data_t const * p_page_data)
{
ant_bsc_page5_data_layout_t * p_outcoming_data = (ant_bsc_page5_data_layout_t *)p_page_buffer;
p_outcoming_data->flags = (uint8_t)p_page_data->stop_indicator;
page5_data_log( p_page_data);
}
void ant_bsc_page_5_decode(uint8_t const * p_page_buffer, ant_bsc_page5_data_t * p_page_data)
{
ant_bsc_page5_data_layout_t const * p_incoming_data = (ant_bsc_page5_data_layout_t *)p_page_buffer;
p_page_data->stop_indicator = (p_incoming_data->flags) & ANT_BSC_STOP_IND_MASK;
page5_data_log( p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_BSC)
@@ -0,0 +1,95 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BSC_PAGE_5_H__
#define ANT_BSC_PAGE_5_H__
/** @file
*
* @defgroup ant_sdk_profiles_bsc_page5 BSC profile page 5
* @{
* @ingroup ant_sdk_profiles_bsc_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Data structure for BSC data page 5.
*
* This structure implements only page 5 specific data.
*/
typedef struct
{
uint8_t stop_indicator:1; ///< Stop indication bit.
uint8_t reserved:7; ///< Reserved.
} ant_bsc_page5_data_t;
/**@brief Initialize page 5.
*/
#define DEFAULT_ANT_BSC_PAGE5() \
(ant_bsc_page5_data_t) \
{ \
.stop_indicator = 0, \
.reserved = 0, \
}
/**@brief Function for encoding page 5.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_bsc_page_5_encode(uint8_t * p_page_buffer, ant_bsc_page5_data_t const * p_page_data);
/**@brief Function for decoding page 5.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_bsc_page_5_decode(uint8_t const * p_page_buffer, ant_bsc_page5_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_BSC_PAGE_5_H__
/** @} */
@@ -0,0 +1,69 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __ANT_BSC_PAGES_H
#define __ANT_BSC_PAGES_H
/** @file
*
* @defgroup ant_sdk_profiles_bsc_pages Bicycle Speed and Cadence profile pages
* @{
* @ingroup ant_bsc
* @brief This module implements functions for the BSC data pages.
*/
#include "ant_bsc_page_0.h"
#include "ant_bsc_page_1.h"
#include "ant_bsc_page_2.h"
#include "ant_bsc_page_3.h"
#include "ant_bsc_page_4.h"
#include "ant_bsc_page_5.h"
#include "ant_bsc_combined_page_0.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif // __ANT_BSC_PAGES_H
/** @} */
@@ -0,0 +1,120 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BSC_SIMULATOR_H__
#define ANT_BSC_SIMULATOR_H__
/** @file
*
* @defgroup ant_sdk_bsc_simulator ANT BSC simulator
* @{
* @ingroup ant_sdk_simulators
* @brief ANT BSC simulator module.
*
* @details This module simulates a pulse for the ANT Bicycle Speed and Cadence profile. The module
* calculates abstract values, which are handled by the BSC pages data model to ensure that
* they are compatible. It provides a handler for changing the cadence and speed values manually
* as well as functionality to change the values automatically.
*
*/
#include <stdint.h>
#include <stdbool.h>
#include "ant_bsc.h"
#include "ant_bsc_utils.h"
#include "sensorsim.h"
#include "ant_bsc_simulator_local.h"
#ifdef __cplusplus
extern "C" {
#endif
/**@brief BSC simulator configuration structure. */
typedef struct
{
ant_bsc_profile_t * p_profile; ///< Related profile.
uint8_t device_type; ///< BSC device type (must be consistent with the type chosen for the profile). Supported types:
// @ref BSC_SPEED_DEVICE_TYPE, @ref BSC_CADENCE_DEVICE_TYPE, @ref BSC_COMBINED_DEVICE_TYPE.
} ant_bsc_simulator_cfg_t;
/**@brief BSC simulator structure. */
typedef struct
{
ant_bsc_profile_t * p_profile; ///< Related profile.
ant_bsc_simulator_cb_t _cb; ///< Internal control block.
} ant_bsc_simulator_t;
/**@brief Function for initializing the ANT BSC 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 speed or cadence.
*/
void ant_bsc_simulator_init(ant_bsc_simulator_t * p_simulator,
ant_bsc_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 BSC Sensor event handler.
*/
void ant_bsc_simulator_one_iteration(ant_bsc_simulator_t * p_simulator);
/**@brief Function for incrementing the cadence value.
*
* @param[in] p_simulator Pointer to the simulator instance.
*/
void ant_bsc_simulator_increment(ant_bsc_simulator_t * p_simulator);
/**@brief Function for decrementing the cadence value.
*
* @param[in] p_simulator Pointer to the simulator instance.
*/
void ant_bsc_simulator_decrement(ant_bsc_simulator_t * p_simulator);
#ifdef __cplusplus
}
#endif
#endif // ANT_BSC_SIMULATOR_H__
/** @} */
@@ -0,0 +1,79 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BSC_SIMULATOR_LOCAL_H__
#define ANT_BSC_SIMULATOR_LOCAL_H__
#include <stdint.h>
#include <stdbool.h>
#include "ant_bsc.h"
#include "sensorsim.h"
#ifdef __cplusplus
extern "C" {
#endif
/**@brief BSC simulator control block structure. */
typedef struct
{
uint8_t device_type;
bool auto_change; ///< Cadence will change automatically (if auto_change is set) or manually.
uint16_t speed_sim_val; ///< Instantaneous speed value.
uint16_t cadence_sim_val; ///< Instantaneous cadence value.
uint32_t time_since_last_s_evt; ///< Time since last speed event occurred (integer part).
uint64_t fraction_since_last_s_evt; ///< Time since last speed event occurred (fractional part).
uint32_t time_since_last_c_evt; ///< Time since last cadence event occurred (integer part).
uint64_t fraction_since_last_c_evt; ///< Time since last cadence event occurred (fractional part).
sensorsim_state_t sensorsim_s_state; ///< State of the simulated speed sensor.
sensorsim_cfg_t sensorsim_s_cfg; ///< Configuration of the simulated speed sensor.
sensorsim_state_t sensorsim_c_state; ///< State of the simulated cadence sensor.
sensorsim_cfg_t sensorsim_c_cfg; ///< Configuration of the simulated cadence sensor.
uint16_t prev_time_since_evt; ///< Previous value of time since the last event.
uint32_t cumulative_time; ///< Cumulative time in 2 s ticks used for updating the cumulative time.
uint32_t cumulative_time_frac; ///< Cumulative time in 2 s ticks (fractional part), used for updating the cumulative time.
uint8_t stop_cnt; ///< Counter used for simulating bicycle stopped state.
} ant_bsc_simulator_cb_t;
#ifdef __cplusplus
}
#endif
#endif // ANT_BSC_SIMULATOR_LOCAL_H__
@@ -0,0 +1,128 @@
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ANT_BSC_UTILS_H__
#define ANT_BSC_UTILS_H__
#include "nrf.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @file
*
* @defgroup ant_sdk_profiles_bsc_utils Bicycle Speed and Cadence profile utilities
* @{
* @ingroup ant_bsc
* @brief This module implements utilities for the Bicycle Speed and Cadence profile.
*
*/
/**@brief Unit for BSC operating time.
*
* @details According to the ANT BSC specification, the operating time unit is 2 seconds.
*/
#define ANT_BSC_OPERATING_TIME_UNIT 2u
/**@brief This macro should be used to get the seconds part of the operating time.
*/
#define ANT_BSC_OPERATING_SECONDS(OPERATING_TIME) (((OPERATING_TIME) * ANT_BSC_OPERATING_TIME_UNIT) % 60)
/**@brief This macro should be used to get the minutes part of the operating time.
*/
#define ANT_BSC_OPERATING_MINUTES(OPERATING_TIME) ((((OPERATING_TIME) * ANT_BSC_OPERATING_TIME_UNIT) / 60) % 60)
/**@brief This macro should be used to get the hours part of the operating time.
*/
#define ANT_BSC_OPERATING_HOURS(OPERATING_TIME) ((((OPERATING_TIME) * ANT_BSC_OPERATING_TIME_UNIT) / (60 * 60)) % 24)
/**@brief This macro should be used to get the days part of the operating time.
*/
#define ANT_BSC_OPERATING_DAYS(OPERATING_TIME) ((((OPERATING_TIME) * ANT_BSC_OPERATING_TIME_UNIT) / (60 * 60)) / 24)
/**@brief Number of Bicycle Speed or Cadence event time counts per second.
*
* @details According to the ANT BSC specification, the speed or cadence event time unit is 1/1024 of a second.
*/
#define ANT_BSC_EVENT_TIME_COUNTS_PER_SEC 1024u
/**@brief BSC event time display required precision.
*
* @details This value is used to decode the number of milliseconds.
*/
#define ANT_BSC_EVENT_TIME_PRECISION 1000u
/**@brief This macro should be used to get the seconds part of the BSC event time.
*/
#define ANT_BSC_EVENT_TIME_SEC(EVENT_TIME) ((EVENT_TIME) / ANT_BSC_EVENT_TIME_COUNTS_PER_SEC)
/**@brief This macro should be used to get the milliseconds part of the BSC event time.
*/
#define ANT_BSC_EVENT_TIME_MSEC(EVENT_TIME) (((((EVENT_TIME) % ANT_BSC_EVENT_TIME_COUNTS_PER_SEC) * ANT_BSC_EVENT_TIME_PRECISION) \
+ ANT_BSC_EVENT_TIME_COUNTS_PER_SEC / 2) \
/ ANT_BSC_EVENT_TIME_COUNTS_PER_SEC)
/**@brief Battery voltage display required precision.
*
* @details This value is used to decode the number of mV.
*/
#define ANT_BSC_BAT_VOLTAGE_PRECISION 1000u
/**@brief Bike Speed and Cadence profile, unit divisor of the fractional part of the battery voltage.
*
* @details According to the ANT BSC specification, the battery voltage fraction unit is (1/256) V.
*/
#define ANT_BSC_BAT_VOLTAGE_FRACTION_PER_VOLT 256u
/**@brief This macro should be used to get the mV part of the BSC battery voltage.
*/
#define ANT_BSC_BAT_VOLTAGE_FRACTION_MV(VOLT_FRACT) ((((VOLT_FRACT) * ANT_BSC_BAT_VOLTAGE_PRECISION) \
+ ANT_BSC_BAT_VOLTAGE_FRACTION_PER_VOLT / 2) \
/ ANT_BSC_BAT_VOLTAGE_FRACTION_PER_VOLT)
/** @} */
#ifdef __cplusplus
}
#endif
#endif // ANT_BSC_UTILS_H__
@@ -0,0 +1,157 @@
/**
* Copyright (c) 2015 - 2017, 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_request_controller ANT request controller
* @{
* @ingroup ant_sdk_utils
*
* @brief Module for handling page requests related to page 70.
*/
#ifndef ANT_REQUEST_CONTROLLER_H__
#define ANT_REQUEST_CONTROLLER_H__
#include <stdbool.h>
#include "ant_common_page_70.h"
#include "ant_stack_handler_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**@brief Request controller events types. */
typedef enum
{
ANT_REQUEST_CONTROLLER_NONE, ///< No event.
ANT_REQUEST_CONTROLLER_SUCCESS, ///< Page request successful.
ANT_REQUEST_CONTROLLER_FAILED, ///< Page request failed.
} ant_request_controller_evt_t;
/**@brief Request controller states. */
typedef enum
{
ANT_REQUEST_CONTROLLER_IDLE, ///< Module is in idle state.
ANT_REQUEST_CONTROLLER_SENDED, ///< Module waits for acknowledgment of its request.
ANT_REQUEST_CONTROLLER_BROADCAST_REQUESTED, ///< Module is requested to send page n times using broadcast.
ANT_REQUEST_CONTROLLER_ACK_REQUESTED, ///< Module is requested to send page n times using acknowledgment.
ANT_REQUEST_CONTROLLER_ACK_UNTIL_SUCCESS_REQUESTED, ///< Module is requested to send page until success using acknowledgment.
} ant_request_controller_state_t;
/**@brief ANT request controller structure. */
typedef struct
{
ant_request_controller_state_t state; ///< Actual module state.
ant_common_page70_data_t page_70; ///< Page 70.
} ant_request_controller_t;
/**@brief Function for initializing the ANT request controller instance.
*
* @param[in] p_controller Pointer to the controller instance.
*/
void ant_request_controller_init(ant_request_controller_t * p_controller);
/**@brief Function for sending a request.
*
* @param[in] p_controller Pointer to the controller instance.
* @param[in] channel_number Channel number.
* @param[in] p_page_70 Pointer to the prepared page 70.
*
* @return Error code returned by @ref sd_ant_acknowledge_message_tx().
*/
uint32_t ant_request_controller_request(ant_request_controller_t * p_controller,
uint8_t channel_number,
ant_common_page70_data_t * p_page_70);
/**@brief Function for getting pending page number.
*
* @details This function checks whether a page number was requested.
*
* @param[in] p_controller Pointer to the controller instance.
* @param[out] p_page_number Pending page number (valid if true was returned).
*
* @retval TRUE If there was a pending page.
* @retval FALSE If no page was pending.
*/
bool ant_request_controller_pending_get(ant_request_controller_t * p_controller,
uint8_t * p_page_number);
/**@brief Function for checking whether the next page must be sent with acknowledgment.
*
* @param[in] p_controller Pointer to the controller instance.
*
* @retval TRUE If the next transmission needs acknowledgment.
* @retval FALSE If the next transmission does not need acknowledgment.
*/
bool ant_request_controller_ack_needed(ant_request_controller_t * p_controller);
/**
* @brief Function for handling ANT events on display side.
*
* @details All events from the ANT stack that are related to the appropriate channel number
* should be propagated.
*
* @param[in] p_controller Pointer to the controller instance.
* @param[in] p_ant_event Event received from the ANT stack.
*/
ant_request_controller_evt_t ant_request_controller_disp_evt_handler(
ant_request_controller_t * p_controller,
ant_evt_t * p_ant_event);
/**
* @brief Function for handling ANT events on sensor side.
*
* @details All events from the ANT stack that are related to the appropriate channel number
* should be propagated.
*
* @param[in] p_controller Pointer to the controller instance.
* @param[in] p_ant_event Event received from the ANT stack.
* @retval TRUE If there was a pending page.
*/
void ant_request_controller_sens_evt_handler(ant_request_controller_t * p_controller,
ant_evt_t * p_ant_event);
#ifdef __cplusplus
}
#endif
#endif // ANT_REQUEST_CONTROLLER_H__
/** @} */
@@ -0,0 +1,140 @@
/**
* Copyright (c) 2015 - 2017, 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_COMMON_PAGE_70)
#include <string.h>
#include "ant_common_page_70.h"
#define NRF_LOG_MODULE_NAME "ANT_COMMON_PAGE_70"
#if ANT_COMMON_PAGE_70_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_COMMON_PAGE_70_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_COMMON_PAGE_70_INFO_COLOR
#else // ANT_COMMON_PAGE_70_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_COMMON_PAGE_70_LOG_ENABLED
#include "nrf_log.h"
/**@brief ANT+ common page 70 data layout structure. */
typedef struct
{
uint8_t reserved[2];
uint8_t descriptor[2];
uint8_t req_trans_response;
uint8_t req_page_number;
uint8_t command_type;
}ant_common_page70_data_layout_t;
/**@brief Function for tracing page 70 data.
*
* @param[in] p_page_data Pointer to the page 70 data.
*/
static void page70_data_log(volatile ant_common_page70_data_t const * p_page_data)
{
NRF_LOG_INFO("Page %d request\r\n", p_page_data->page_number);
switch (p_page_data->transmission_response.specyfic)
{
case ANT_PAGE70_RESPONSE_TRANSMIT_UNTIL_SUCCESS:
NRF_LOG_INFO("Try to send until ACK\r\n");
break;
case ANT_PAGE70_RESPONSE_INVALID:
NRF_LOG_INFO("Invalid requested transmission response\r\n");
break;
default:
if (p_page_data->transmission_response.items.ack_resposne)
{
NRF_LOG_INFO("Answer with acknowledged messages\r\n");
}
NRF_LOG_INFO("Requested number of transmissions: %d\r\n",
p_page_data->transmission_response.items.transmit_count);
}
switch (p_page_data->command_type)
{
case ANT_PAGE70_COMMAND_PAGE_DATA_REQUEST:
NRF_LOG_INFO("Request Data Page\r\n");
break;
case ANT_PAGE70_COMMAND_ANT_FS_SESSION_REQUEST:
NRF_LOG_INFO("Request ANT-FS Session\r\n");
break;
default:
NRF_LOG_INFO("Invalid request\r\n");
}
NRF_LOG_INFO("Descriptor %x\r\n\n", p_page_data->descriptor);
}
void ant_common_page_70_encode(uint8_t * p_page_buffer,
volatile ant_common_page70_data_t const * p_page_data)
{
ant_common_page70_data_layout_t * p_outcoming_data =
(ant_common_page70_data_layout_t *)p_page_buffer;
memset(p_outcoming_data->reserved, UINT8_MAX, sizeof (p_outcoming_data->reserved));
UNUSED_PARAMETER(uint16_encode(p_page_data->descriptor, p_outcoming_data->descriptor));
p_outcoming_data->req_trans_response = p_page_data->transmission_response.byte;
p_outcoming_data->req_page_number = p_page_data->page_number;
p_outcoming_data->command_type = p_page_data->command_type;
page70_data_log(p_page_data);
}
void ant_common_page_70_decode(uint8_t const * p_page_buffer,
volatile ant_common_page70_data_t * p_page_data)
{
ant_common_page70_data_layout_t const * p_incoming_data =
(ant_common_page70_data_layout_t *)p_page_buffer;
p_page_data->descriptor = uint16_decode(p_incoming_data->descriptor);
p_page_data->transmission_response.byte = p_incoming_data->req_trans_response;
p_page_data->page_number = p_incoming_data->req_page_number;
p_page_data->command_type = (ant_page70_command_t)p_incoming_data->command_type;
page70_data_log(p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_COMMON_PAGE_70)
@@ -0,0 +1,135 @@
/**
* Copyright (c) 2015 - 2017, 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_COMMON_PAGE_70_H__
#define ANT_COMMON_PAGE_70_H__
/** @file
*
* @defgroup ant_common_page_70 ANT+ common page 70
* @{
* @ingroup ant_sdk_common_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define ANT_COMMON_PAGE_70 (70) ///< @brief ID value of common page 70.
#define ANT_PAGE70_INVALID_DESCRIPTOR UINT16_MAX ///< Invalid descriptor.
/**@brief Command type.
*/
typedef enum
{
ANT_PAGE70_COMMAND_PAGE_DATA_REQUEST = 0x01, ///< Page request.
ANT_PAGE70_COMMAND_ANT_FS_SESSION_REQUEST = 0x02, ///< ANT FS session request.
} ant_page70_command_t;
/**@brief Data structure for ANT+ common data page 70.
*/
typedef struct
{
uint8_t page_number; ///< Requested page number.
uint16_t descriptor; ///< Descriptor.
ant_page70_command_t command_type; ///< Command type.
union
{
enum
{
ANT_PAGE70_RESPONSE_INVALID = 0x00, ///< Invalid response type.
ANT_PAGE70_RESPONSE_TRANSMIT_UNTIL_SUCCESS = 0x80, ///< Transmit until a successful acknowledge is received.
} specyfic;
struct
{
uint8_t transmit_count :7; ///< Number of re-transmissions.
uint8_t ack_resposne :1; ///< Acknowledge transmission is required.
} items;
uint8_t byte;
} transmission_response;
} ant_common_page70_data_t;
/**@brief Initialize page 70 with default values.
*/
#define DEFAULT_ANT_COMMON_PAGE70() \
(ant_common_page70_data_t) \
{ \
.page_number = 0x00, \
.command_type = (ant_page70_command_t)0x00, \
.transmission_response.specyfic = ANT_PAGE70_RESPONSE_INVALID, \
.descriptor = ANT_PAGE70_INVALID_DESCRIPTOR, \
}
/**@brief Initialize page 70 with the page request.
*/
#define ANT_COMMON_PAGE_DATA_REQUEST(PAGE_NUMBER) \
(ant_common_page70_data_t) \
{ \
.page_number = (PAGE_NUMBER), \
.command_type = ANT_PAGE70_COMMAND_PAGE_DATA_REQUEST, \
.transmission_response.specyfic = ANT_PAGE70_RESPONSE_TRANSMIT_UNTIL_SUCCESS, \
.descriptor = ANT_PAGE70_INVALID_DESCRIPTOR, \
}
/**@brief Function for encoding page 70.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_common_page_70_encode(uint8_t * p_page_buffer,
volatile ant_common_page70_data_t const * p_page_data);
/**@brief Function for decoding page 70.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_common_page_70_decode(uint8_t const * p_page_buffer,
volatile ant_common_page70_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_COMMON_PAGE_70_H__
/** @} */
@@ -0,0 +1,109 @@
/**
* Copyright (c) 2015 - 2017, 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_COMMON_PAGE_80)
#include <string.h>
#include "ant_common_page_80.h"
#define NRF_LOG_MODULE_NAME "ANT_COMMON_PAGE_80"
#if ANT_COMMON_PAGE_80_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_COMMON_PAGE_80_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_COMMON_PAGE_80_INFO_COLOR
#else // ANT_COMMON_PAGE_80_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_COMMON_PAGE_80_LOG_ENABLED
#include "nrf_log.h"
/**@brief ant+ common page 80 data layout structure. */
typedef struct
{
uint8_t reserved[2]; ///< unused, fill by 0xFF
uint8_t hw_revision;
uint8_t manufacturer_id[2];
uint8_t model_number[2];
}ant_common_page80_data_layout_t;
/**@brief Function for tracing page 80 data.
*
* @param[in] p_page_data Pointer to the page 80 data.
*/
static void page80_data_log(volatile ant_common_page80_data_t const * p_page_data)
{
NRF_LOG_INFO("hw revision: %u\r\n", p_page_data->hw_revision);
NRF_LOG_INFO("manufacturer id: %u\r\n", p_page_data->manufacturer_id);
NRF_LOG_INFO("model number: %u\r\n\n", p_page_data->model_number);
}
void ant_common_page_80_encode(uint8_t * p_page_buffer,
volatile ant_common_page80_data_t const * p_page_data)
{
ant_common_page80_data_layout_t * p_outcoming_data =
(ant_common_page80_data_layout_t *)p_page_buffer;
memset(p_page_buffer, UINT8_MAX, sizeof (p_outcoming_data->reserved));
p_outcoming_data->hw_revision = p_page_data->hw_revision;
UNUSED_PARAMETER(uint16_encode(p_page_data->manufacturer_id,
p_outcoming_data->manufacturer_id));
UNUSED_PARAMETER(uint16_encode(p_page_data->model_number, p_outcoming_data->model_number));
page80_data_log(p_page_data);
}
void ant_common_page_80_decode(uint8_t const * p_page_buffer,
volatile ant_common_page80_data_t * p_page_data)
{
ant_common_page80_data_layout_t const * p_incoming_data =
(ant_common_page80_data_layout_t *)p_page_buffer;
p_page_data->hw_revision = p_incoming_data->hw_revision;
p_page_data->manufacturer_id = uint16_decode(p_incoming_data->manufacturer_id);
p_page_data->model_number = uint16_decode(p_incoming_data->model_number);
page80_data_log(p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_COMMON_PAGE_80)
@@ -0,0 +1,120 @@
/**
* Copyright (c) 2015 - 2017, 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_COMMON_PAGE_80_H__
#define ANT_COMMON_PAGE_80_H__
/** @file
*
* @defgroup ant_sdk_common_pages ANT+ common pages
* @{
* @ingroup ant_sdk_profiles
* @brief This module implements functions for the ANT+ common pages.
* @details ANT+ common data pages define common data formats that can be used by any device on any ANT network. The ability to send and receive these common pages is defined by the transmission type of the ANT channel parameter.
*
* Note that all unused pages in this section are not defined and therefore cannot be used.
* @}
*
* @defgroup ant_common_page_80 ANT+ common page 80
* @{
* @ingroup ant_sdk_common_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define ANT_COMMON_PAGE_80 (80) ///< @brief ID value of common page 80.
/**@brief Data structure for ANT+ common data page 80.
*
* @note This structure implements only page 80 specific data.
*/
typedef struct
{
uint8_t hw_revision; ///< Hardware revision.
uint16_t manufacturer_id; ///< Manufacturer ID.
uint16_t model_number; ///< Model number.
} ant_common_page80_data_t;
/**@brief Initialize page 80.
*/
#define DEFAULT_ANT_COMMON_page80() \
(ant_common_page80_data_t) \
{ \
.hw_revision = 0x00, \
.manufacturer_id = UINT8_MAX, \
.model_number = 0x00, \
}
/**@brief Initialize page 80.
*/
#define ANT_COMMON_page80(hw_rev, man_id, mod_num) \
(ant_common_page80_data_t) \
{ \
.hw_revision = (hw_rev), \
.manufacturer_id = (man_id), \
.model_number = (mod_num), \
}
/**@brief Function for encoding page 80.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_common_page_80_encode(uint8_t * p_page_buffer,
volatile ant_common_page80_data_t const * p_page_data);
/**@brief Function for decoding page 80.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_common_page_80_decode(uint8_t const * p_page_buffer,
volatile ant_common_page80_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_COMMON_PAGE_80_H__
/** @} */
@@ -0,0 +1,116 @@
/**
* Copyright (c) 2015 - 2017, 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_COMMON_PAGE_81)
#include "ant_common_page_81.h"
#define NRF_LOG_MODULE_NAME "ANT_COMMON_PAGE_81"
#if ANT_COMMON_PAGE_81_LOG_ENABLED
#define NRF_LOG_LEVEL ANT_COMMON_PAGE_81_LOG_LEVEL
#define NRF_LOG_INFO_COLOR ANT_COMMON_PAGE_81_INFO_COLOR
#else // ANT_COMMON_PAGE_81_LOG_ENABLED
#define NRF_LOG_LEVEL 0
#endif // ANT_COMMON_PAGE_81_LOG_ENABLED
#include "nrf_log.h"
/**@brief ant+ common page 81 data layout structure. */
typedef struct
{
uint8_t reserved; ///< unused, fill by 0xFF
uint8_t sw_revision_minor;
uint8_t sw_revision_major;
uint8_t serial_number[4];
}ant_common_page81_data_layout_t;
/**@brief Function for tracing page 80 data.
*
* @param[in] p_page_data Pointer to the page 80 data.
*/
static void page81_data_log(volatile ant_common_page81_data_t const * p_page_data)
{
if (p_page_data->sw_revision_minor != UINT8_MAX)
{
NRF_LOG_INFO("sw revision: %u.%u\r\n",
((ant_common_page81_data_t const *) p_page_data)->sw_revision_major,
((ant_common_page81_data_t const *) p_page_data)->sw_revision_minor);
}
else
{
NRF_LOG_INFO("sw revision: %u\r\n", p_page_data->sw_revision_major);
}
NRF_LOG_INFO("serial number: %u\r\n\n", (unsigned int) p_page_data->serial_number);
}
void ant_common_page_81_encode(uint8_t * p_page_buffer,
volatile ant_common_page81_data_t const * p_page_data)
{
ant_common_page81_data_layout_t * p_outcoming_data =
(ant_common_page81_data_layout_t *)p_page_buffer;
p_outcoming_data->reserved = UINT8_MAX;
p_outcoming_data->sw_revision_minor = p_page_data->sw_revision_minor;
p_outcoming_data->sw_revision_major = p_page_data->sw_revision_major;
UNUSED_PARAMETER(uint32_encode(p_page_data->serial_number, p_outcoming_data->serial_number));
page81_data_log(p_page_data);
}
void ant_common_page_81_decode(uint8_t const * p_page_buffer,
volatile ant_common_page81_data_t * p_page_data)
{
ant_common_page81_data_layout_t const * p_incoming_data =
(ant_common_page81_data_layout_t *)p_page_buffer;
p_page_data->sw_revision_minor = p_incoming_data->sw_revision_minor;
p_page_data->sw_revision_major = p_incoming_data->sw_revision_major;
p_page_data->serial_number = uint32_decode(p_incoming_data->serial_number);
page81_data_log(p_page_data);
}
#endif // NRF_MODULE_ENABLED(ANT_COMMON_PAGE_81)
@@ -0,0 +1,111 @@
/**
* Copyright (c) 2015 - 2017, 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_COMMON_PAGE_81_H__
#define ANT_COMMON_PAGE_81_H__
/** @file
*
* @defgroup ant_common_page_81 ANT+ common page 81
* @{
* @ingroup ant_sdk_common_pages
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define ANT_COMMON_PAGE_81 (81) ///< @brief ID value of common page 81.
/**@brief Data structure for ANT+ common data page 81.
*
* @note This structure implements only page 81 specific data.
*/
typedef struct
{
uint8_t sw_revision_minor; ///< Supplemental, fill by 0xFF if unused.
uint8_t sw_revision_major; ///< Main software version.
uint32_t serial_number; ///< Lowest 32 b of serial number, fill by 0xFFFFFFFFF if unused.
} ant_common_page81_data_t;
/**@brief Initialize page 81.
*/
#define DEFAULT_ANT_COMMON_page81() \
(ant_common_page81_data_t) \
{ \
.sw_revision_minor = UINT8_MAX, \
.sw_revision_major = UINT8_MAX, \
.serial_number = UINT32_MAX, \
}
/**@brief Initialize page 81.
*/
#define ANT_COMMON_page81(sw_major_rev, sw_minor_rev, seril_no) \
(ant_common_page81_data_t) \
{ \
.sw_revision_minor = (sw_minor_rev), \
.sw_revision_major = (sw_major_rev), \
.serial_number = (seril_no), \
}
/**@brief Function for encoding page 81.
*
* @param[in] p_page_data Pointer to the page data.
* @param[out] p_page_buffer Pointer to the data buffer.
*/
void ant_common_page_81_encode(uint8_t * p_page_buffer,
volatile ant_common_page81_data_t const * p_page_data);
/**@brief Function for decoding page 81.
*
* @param[in] p_page_buffer Pointer to the data buffer.
* @param[out] p_page_data Pointer to the page data.
*/
void ant_common_page_81_decode(uint8_t const * p_page_buffer,
volatile ant_common_page81_data_t * p_page_data);
#ifdef __cplusplus
}
#endif
#endif // ANT_COMMON_PAGE_81_H__
/** @} */
@@ -0,0 +1,75 @@
/**
* Copyright (c) 2015 - 2017, 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__
@@ -0,0 +1,115 @@
/**
* Copyright (c) 2015 - 2017, 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"
/**@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\r\n", (unsigned int)p_page_data->beat_count);
NRF_LOG_INFO("Computed heart rate: %u\r\n",
(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)
@@ -0,0 +1,99 @@
/**
* Copyright (c) 2015 - 2017, 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__
/** @} */
@@ -0,0 +1,101 @@
/**
* Copyright (c) 2015 - 2017, 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"
/**@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)
@@ -0,0 +1,95 @@
/**
* Copyright (c) 2015 - 2017, 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__
/** @} */
@@ -0,0 +1,105 @@
/**
* Copyright (c) 2015 - 2017, 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"
/**@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\r\n", (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)
@@ -0,0 +1,97 @@
/**
* Copyright (c) 2015 - 2017, 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__
/** @} */
@@ -0,0 +1,102 @@
/**
* Copyright (c) 2015 - 2017, 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"
/**@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\r\n", (unsigned int)p_page_data->hw_version);
NRF_LOG_INFO("Model %u\r\n", (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)
@@ -0,0 +1,99 @@
/**
* Copyright (c) 2015 - 2017, 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__
/** @} */
Loaded 100 of 1241 files, more files were not shown because too many files have changed in this diff. Show more