mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-08 14:43:04 +08:00
Merge branch 'master' into step4
This commit is contained in:
1436 files changed
+14051
-395888
No files matched your search
@@ -47,12 +47,6 @@ void rtthread_startup(void)
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* init tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* init kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
|
||||
@@ -120,8 +120,8 @@ int rt_hw_uart_init(void)
|
||||
uart->irqno = UART1_INTERRUPT; // IRQ_UART1;
|
||||
uart->gpio_rx_port = GPIO_PORT_A;
|
||||
uart->gpio_tx_port = GPIO_PORT_A;
|
||||
uart->gpio_rx_pin = GPIO_PIN_3;
|
||||
uart->gpio_tx_pin = GPIO_PIN_2;
|
||||
uart->gpio_rx_pin = GPIO_PIN_2;
|
||||
uart->gpio_tx_pin = GPIO_PIN_3;
|
||||
uart->gpio_rx_fun = IO_FUN_4;
|
||||
uart->gpio_tx_fun = IO_FUN_4;
|
||||
|
||||
|
||||
@@ -483,7 +483,7 @@ static rt_err_t configure(struct rt_spi_device *device,
|
||||
SPI_SetFirstTransmitBit(spi, SPI_TCTRL_FBS_LSB);
|
||||
}
|
||||
|
||||
switch (configuration->mode)
|
||||
switch (configuration->mode & RT_SPI_MODE_3)
|
||||
{
|
||||
case RT_SPI_MODE_0:
|
||||
SPI_SetSclkMode(spi, SPI_SCLK_Mode0);
|
||||
|
||||
@@ -30,8 +30,6 @@ int main(void)
|
||||
#endif
|
||||
|
||||
rt_hw_board_init();
|
||||
rt_system_tick_init();
|
||||
rt_system_object_init();
|
||||
rt_system_timer_init();
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
|
||||
@@ -35,12 +35,6 @@ void rtthread_startup(void)
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* init tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* init kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
|
||||
@@ -102,12 +102,6 @@ void rtthread_startup(void)
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* init tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* init kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
|
||||
@@ -93,12 +93,6 @@ void rtthread_startup(void)
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* initialize tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* initialize kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
/* initialize timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
|
||||
@@ -65,12 +65,6 @@ void rtthread_startup(void)
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* init tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* init kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
|
||||
@@ -1095,14 +1095,9 @@ U32 RTOS_InitKernel(U32 Heap_size)
|
||||
/* show version */
|
||||
//rt_show_version();
|
||||
|
||||
/* initialize tick */
|
||||
//rt_system_tick_init();
|
||||
RTOS_HwTickInit();
|
||||
//rt_kprintf("set tick\n");
|
||||
|
||||
/* initialize kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
/* initialize timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
* 2019-06-28 misonyo the first version.
|
||||
*/
|
||||
|
||||
#ifndef DRV_SPI_H__
|
||||
#define DRV_SPI_H__
|
||||
#ifndef DRV_CAN_H__
|
||||
#define DRV_CAN_H__
|
||||
|
||||
int rt_hw_can_init(void);
|
||||
|
||||
#endif /* DRV_SPI_H__ */
|
||||
#endif /* DRV_CAN_H__ */
|
||||
+28
-1
@@ -70,6 +70,8 @@ CONFIG_RT_VER_NUM=0x40003
|
||||
CONFIG_ARCH_CPU_64BIT=y
|
||||
# CONFIG_RT_USING_CPU_FFS is not set
|
||||
CONFIG_ARCH_RISCV=y
|
||||
CONFIG_ARCH_RISCV_FPU=y
|
||||
CONFIG_ARCH_RISCV_FPU_S=y
|
||||
CONFIG_ARCH_RISCV64=y
|
||||
# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set
|
||||
|
||||
@@ -150,8 +152,10 @@ CONFIG_RT_SERIAL_RB_BUFSZ=64
|
||||
# CONFIG_RT_USING_HWTIMER is not set
|
||||
# CONFIG_RT_USING_CPUTIME is not set
|
||||
# CONFIG_RT_USING_I2C is not set
|
||||
# CONFIG_RT_USING_PHY is not set
|
||||
CONFIG_RT_USING_PIN=y
|
||||
# CONFIG_RT_USING_ADC is not set
|
||||
# CONFIG_RT_USING_DAC is not set
|
||||
# CONFIG_RT_USING_PWM is not set
|
||||
# CONFIG_RT_USING_MTD_NOR is not set
|
||||
# CONFIG_RT_USING_MTD_NAND is not set
|
||||
@@ -192,6 +196,7 @@ CONFIG_RT_USING_LIBC=y
|
||||
CONFIG_RT_USING_POSIX=y
|
||||
# CONFIG_RT_USING_POSIX_MMAP is not set
|
||||
# CONFIG_RT_USING_POSIX_TERMIOS is not set
|
||||
# CONFIG_RT_USING_POSIX_GETLINE is not set
|
||||
# CONFIG_RT_USING_POSIX_AIO is not set
|
||||
# CONFIG_RT_USING_MODULE is not set
|
||||
|
||||
@@ -262,7 +267,9 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y
|
||||
#
|
||||
# IoT - internet of things
|
||||
#
|
||||
# CONFIG_PKG_USING_LORAWAN_DRIVER is not set
|
||||
# CONFIG_PKG_USING_PAHOMQTT is not set
|
||||
# CONFIG_PKG_USING_UMQTT is not set
|
||||
# CONFIG_PKG_USING_WEBCLIENT is not set
|
||||
# CONFIG_PKG_USING_WEBNET is not set
|
||||
# CONFIG_PKG_USING_MONGOOSE is not set
|
||||
@@ -308,7 +315,7 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y
|
||||
# CONFIG_PKG_USING_GAGENT_CLOUD is not set
|
||||
# CONFIG_PKG_USING_ALI_IOTKIT is not set
|
||||
# CONFIG_PKG_USING_AZURE is not set
|
||||
# CONFIG_PKG_USING_TENCENT_IOTHUB is not set
|
||||
# CONFIG_PKG_USING_TENCENT_IOT_EXPLORER is not set
|
||||
# CONFIG_PKG_USING_JIOT-C-SDK is not set
|
||||
# CONFIG_PKG_USING_UCLOUD_IOT_SDK is not set
|
||||
# CONFIG_PKG_USING_JOYLINK is not set
|
||||
@@ -330,6 +337,9 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y
|
||||
# CONFIG_PKG_USING_CAPNP is not set
|
||||
# CONFIG_PKG_USING_RT_CJSON_TOOLS is not set
|
||||
# CONFIG_PKG_USING_AGILE_TELNET is not set
|
||||
# CONFIG_PKG_USING_NMEALIB is not set
|
||||
# CONFIG_PKG_USING_AGILE_JSMN is not set
|
||||
# CONFIG_PKG_USING_PDULIB is not set
|
||||
|
||||
#
|
||||
# security packages
|
||||
@@ -338,6 +348,7 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y
|
||||
# CONFIG_PKG_USING_libsodium is not set
|
||||
# CONFIG_PKG_USING_TINYCRYPT is not set
|
||||
# CONFIG_PKG_USING_TFM is not set
|
||||
# CONFIG_PKG_USING_YD_CRYPTO is not set
|
||||
|
||||
#
|
||||
# language packages
|
||||
@@ -372,7 +383,9 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y
|
||||
# CONFIG_PKG_USING_CHINESE_FONT_LIBRARY is not set
|
||||
# CONFIG_PKG_USING_LUNAR_CALENDAR is not set
|
||||
# CONFIG_PKG_USING_BS8116A is not set
|
||||
# CONFIG_PKG_USING_GPS_RMC is not set
|
||||
# CONFIG_PKG_USING_URLENCODE is not set
|
||||
# CONFIG_PKG_USING_UMCN is not set
|
||||
|
||||
#
|
||||
# system packages
|
||||
@@ -396,6 +409,10 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y
|
||||
# CONFIG_PKG_USING_SYSWATCH is not set
|
||||
# CONFIG_PKG_USING_SYS_LOAD_MONITOR is not set
|
||||
# CONFIG_PKG_USING_PLCCORE is not set
|
||||
# CONFIG_PKG_USING_RAMDISK is not set
|
||||
# CONFIG_PKG_USING_MININI is not set
|
||||
# CONFIG_PKG_USING_QBOOT is not set
|
||||
# CONFIG_PKG_USING_UCOSIII_WRAPPER is not set
|
||||
|
||||
#
|
||||
# peripheral libraries and drivers
|
||||
@@ -441,6 +458,7 @@ CONFIG_PKG_KENDRYTE_SDK_VERNUM=0x0055
|
||||
# CONFIG_PKG_USING_RPLIDAR is not set
|
||||
# CONFIG_PKG_USING_AS608 is not set
|
||||
# CONFIG_PKG_USING_RC522 is not set
|
||||
# CONFIG_PKG_USING_WS2812B is not set
|
||||
# CONFIG_PKG_USING_EMBARC_BSP is not set
|
||||
# CONFIG_PKG_USING_EXTERN_RTC_DRIVERS is not set
|
||||
# CONFIG_PKG_USING_MULTI_RTIMER is not set
|
||||
@@ -450,6 +468,12 @@ CONFIG_PKG_KENDRYTE_SDK_VERNUM=0x0055
|
||||
# CONFIG_PKG_USING_PMS_SERIES is not set
|
||||
# CONFIG_PKG_USING_NUCLEI_SDK is not set
|
||||
# CONFIG_PKG_USING_CAN_YMODEM is not set
|
||||
# CONFIG_PKG_USING_LORA_RADIO_DRIVER is not set
|
||||
# CONFIG_PKG_USING_QLED is not set
|
||||
# CONFIG_PKG_USING_PAJ7620 is not set
|
||||
# CONFIG_PKG_USING_AGILE_CONSOLE is not set
|
||||
# CONFIG_PKG_USING_LD3320 is not set
|
||||
# CONFIG_PKG_USING_WK2124 is not set
|
||||
|
||||
#
|
||||
# miscellaneous packages
|
||||
@@ -486,6 +510,9 @@ CONFIG_PKG_KENDRYTE_SDK_VERNUM=0x0055
|
||||
# CONFIG_PKG_USING_VT100 is not set
|
||||
# CONFIG_PKG_USING_ULAPACK is not set
|
||||
# CONFIG_PKG_USING_UKAL is not set
|
||||
# CONFIG_PKG_USING_CRCLIB is not set
|
||||
# CONFIG_PKG_USING_THREES is not set
|
||||
# CONFIG_PKG_USING_2048 is not set
|
||||
CONFIG_BOARD_K210_EVB=y
|
||||
CONFIG_BSP_USING_UART_HS=y
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ source "$PKGS_DIR/Kconfig"
|
||||
config BOARD_K210_EVB
|
||||
bool
|
||||
select ARCH_RISCV64
|
||||
select ARCH_RISCV_FPU_S
|
||||
select PKG_USING_KENDRYTE_SDK
|
||||
select RT_USING_COMPONENTS_INIT
|
||||
select RT_USING_USER_MAIN
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
#define RT_VER_NUM 0x40003
|
||||
#define ARCH_CPU_64BIT
|
||||
#define ARCH_RISCV
|
||||
#define ARCH_RISCV_FPU
|
||||
#define ARCH_RISCV_FPU_S
|
||||
#define ARCH_RISCV64
|
||||
|
||||
/* RT-Thread Components */
|
||||
|
||||
@@ -38,7 +38,7 @@ if PLATFORM == 'gcc':
|
||||
OBJDUMP = PREFIX + 'objdump'
|
||||
OBJCPY = PREFIX + 'objcopy'
|
||||
|
||||
DEVICE = ' -mcmodel=medany -march=rv64imafdc -mabi=lp64d'
|
||||
DEVICE = ' -mcmodel=medany -march=rv64imafc -mabi=lp64f -fsingle-precision-constant'
|
||||
CFLAGS = DEVICE + ' -fno-common -ffunction-sections -fdata-sections -fstrict-volatile-bitfields'
|
||||
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
|
||||
LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,_start -T link.lds'
|
||||
|
||||
@@ -77,12 +77,6 @@ void rtthread_startup(void)
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* init tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* init kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
|
||||
@@ -77,12 +77,6 @@ void rtthread_startup(void)
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* init tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* init kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
|
||||
@@ -77,12 +77,6 @@ void rtthread_startup(void)
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* init tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* init kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
|
||||
@@ -52,12 +52,6 @@ void rtthread_startup(void)
|
||||
/* init board */
|
||||
rt_hw_board_init();
|
||||
|
||||
/* init tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* init kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
rt_show_version();
|
||||
|
||||
/* init timer system */
|
||||
|
||||
@@ -38,12 +38,6 @@ void rtthread_startup(void)
|
||||
/* init board */
|
||||
rt_hw_board_init();
|
||||
|
||||
/* init tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* init kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
rt_show_version();
|
||||
|
||||
/* init timer system */
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
* 2015-01-07 Grissiom init commit
|
||||
*/
|
||||
|
||||
#ifndef __VBUS_HW_H__
|
||||
#define __VBUS_HW_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <board.h>
|
||||
|
||||
@@ -32,3 +35,5 @@ rt_inline void rt_vbus_smp_mb(void)
|
||||
{
|
||||
__DSB();
|
||||
}
|
||||
|
||||
#endif /* __VBUS_HW_H__ */
|
||||
@@ -7,6 +7,9 @@
|
||||
* 2015-01-07 Grissiom init commit
|
||||
*/
|
||||
|
||||
#ifndef __VBUS_HW_H__
|
||||
#define __VBUS_HW_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <board.h>
|
||||
|
||||
@@ -32,3 +35,5 @@ rt_inline void rt_vbus_smp_mb(void)
|
||||
{
|
||||
__DSB();
|
||||
}
|
||||
|
||||
#endif /* __VBUS_HW_H__ */
|
||||
@@ -27,12 +27,6 @@ void rtthread_startup(void)
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* initialize tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* initialize kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
/* initialize timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
|
||||
@@ -52,12 +52,6 @@ void rtthread_startup(void)
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* init tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* init kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
|
||||
@@ -48,13 +48,7 @@ void rtthread_startup(void)
|
||||
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* init tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* init kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
|
||||
@@ -44,12 +44,6 @@ void rtthread_startup(void)
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* init tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* init kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
|
||||
@@ -55,12 +55,6 @@ void rtthread_startup(void)
|
||||
|
||||
rt_show_version();
|
||||
|
||||
/* init tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* init kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
|
||||
@@ -49,12 +49,6 @@ void rtthread_startup()
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* init tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* init kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
|
||||
@@ -45,12 +45,6 @@ void rtthread_startup(void)
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* init tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* init kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
|
||||
@@ -48,12 +48,6 @@ void rtthread_startup(void)
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* init tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* init kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,26 +0,0 @@
|
||||
mainmenu "RT-Thread Project Configuration"
|
||||
|
||||
config BSP_DIR
|
||||
string
|
||||
option env="BSP_ROOT"
|
||||
default "."
|
||||
|
||||
config RTT_DIR
|
||||
string
|
||||
option env="RTT_ROOT"
|
||||
default "../.."
|
||||
|
||||
config PKGS_DIR
|
||||
string
|
||||
option env="PKGS_ROOT"
|
||||
default "packages"
|
||||
|
||||
source "$RTT_DIR/Kconfig"
|
||||
source "$PKGS_DIR/Kconfig"
|
||||
|
||||
config SOC_NRF52832
|
||||
bool
|
||||
select RT_USING_COMPONENTS_INIT
|
||||
# select RT_USING_USER_MAIN
|
||||
default y
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# 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')
|
||||
@@ -1,35 +0,0 @@
|
||||
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
|
||||
|
||||
DefaultEnvironment(tools=[])
|
||||
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)
|
||||
@@ -1,11 +0,0 @@
|
||||
Import('RTT_ROOT')
|
||||
Import('rtconfig')
|
||||
from building import *
|
||||
|
||||
cwd = os.path.join(str(Dir('#')), 'applications')
|
||||
src = Glob('*.c')
|
||||
CPPPATH = [cwd, str(Dir('#'))]
|
||||
|
||||
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* File : application.c
|
||||
* 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
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2015-03-01 Yangfs the first version
|
||||
* 2015-03-27 Bernard code cleanup.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup NRF52832
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#ifdef RT_USING_FINSH
|
||||
#include <finsh.h>
|
||||
#include <shell.h>
|
||||
#endif
|
||||
|
||||
void rt_init_thread_entry(void* parameter)
|
||||
{
|
||||
extern rt_err_t ble_init(void);
|
||||
|
||||
ble_init();
|
||||
}
|
||||
|
||||
int rt_application_init(void)
|
||||
{
|
||||
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
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* File : startup.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://openlab.rt-thread.com/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2015-03-01 Yangfs the first version
|
||||
* 2015-03-27 Bernard code cleanup.
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "board.h"
|
||||
|
||||
/**
|
||||
* @addtogroup NRF52832
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
|
||||
extern int rt_application_init(void);
|
||||
|
||||
#ifdef __CC_ARM
|
||||
extern int Image$$RW_IRAM1$$ZI$$Limit;
|
||||
#define NRF_SRAM_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit)
|
||||
#elif __ICCARM__
|
||||
#pragma section="HEAP"
|
||||
#define NRF_SRAM_BEGIN (__segment_end("HEAP"))
|
||||
#else
|
||||
extern int __bss_end;
|
||||
#define NRF_SRAM_BEGIN (&__bss_end)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This function will startup RT-Thread RTOS.
|
||||
*/
|
||||
void rtthread_startup(void)
|
||||
{
|
||||
/* init board */
|
||||
rt_hw_board_init();
|
||||
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* init tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* init kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
rt_system_heap_init((void*)NRF_SRAM_BEGIN, (void*)CHIP_SRAM_END);
|
||||
#endif
|
||||
|
||||
/* init scheduler system */
|
||||
rt_system_scheduler_init();
|
||||
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
rt_components_init();
|
||||
#endif
|
||||
|
||||
/* init application */
|
||||
rt_application_init();
|
||||
|
||||
/* init timer thread */
|
||||
rt_system_timer_thread_init();
|
||||
|
||||
/* init idle thread */
|
||||
rt_thread_idle_init();
|
||||
|
||||
/* start scheduler */
|
||||
rt_system_scheduler_start();
|
||||
|
||||
/* never reach here */
|
||||
return ;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* disable interrupt first */
|
||||
// rt_hw_interrupt_disable();
|
||||
|
||||
/* startup RT-Thread RTOS */
|
||||
rtthread_startup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
@@ -1,14 +0,0 @@
|
||||
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
@@ -1,13 +0,0 @@
|
||||
#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);
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,19 +0,0 @@
|
||||
#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
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
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, './components/softdevice/common/softdevice_handler/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')
|
||||
@@ -1,52 +0,0 @@
|
||||
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')
|
||||
-86
@@ -1,86 +0,0 @@
|
||||
/**
|
||||
* 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)
|
||||
-98
@@ -1,98 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
/** @} */
|
||||
-239
File diff suppressed because it is too large.
Load diff
-255
File diff suppressed because it is too large.
Load diff
-189
@@ -1,189 +0,0 @@
|
||||
/**
|
||||
* 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)
|
||||
-140
@@ -1,140 +0,0 @@
|
||||
/**
|
||||
* 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
@@ -1,98 +0,0 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
|
||||
/**
|
||||
*@}
|
||||
**/
|
||||
@@ -1,109 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
|
||||
/**
|
||||
*@}
|
||||
**/
|
||||
@@ -1,67 +0,0 @@
|
||||
/**
|
||||
* 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)
|
||||
-104
@@ -1,104 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
-89
@@ -1,89 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
-98
@@ -1,98 +0,0 @@
|
||||
/**
|
||||
* 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)
|
||||
-99
@@ -1,99 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
/** @} */
|
||||
-285
File diff suppressed because it is too large.
Load diff
-136
@@ -1,136 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
/** @} */
|
||||
-116
@@ -1,116 +0,0 @@
|
||||
/**
|
||||
* 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)
|
||||
-111
@@ -1,111 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
/** @} */
|
||||
-76
@@ -1,76 +0,0 @@
|
||||
/**
|
||||
* 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)
|
||||
-89
@@ -1,89 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
/** @} */
|
||||
-76
@@ -1,76 +0,0 @@
|
||||
/**
|
||||
* 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)
|
||||
-89
@@ -1,89 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
/** @} */
|
||||
-112
@@ -1,112 +0,0 @@
|
||||
/**
|
||||
* 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)
|
||||
-106
@@ -1,106 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
/** @} */
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
/** @} */
|
||||
-201
File diff suppressed because it is too large.
Load diff
-123
@@ -1,123 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
/** @} */
|
||||
-74
@@ -1,74 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
-86
@@ -1,86 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
-83
@@ -1,83 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
-128
@@ -1,128 +0,0 @@
|
||||
/**
|
||||
* 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)
|
||||
-99
@@ -1,99 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
/** @} */
|
||||
-110
@@ -1,110 +0,0 @@
|
||||
/**
|
||||
* 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)
|
||||
-95
@@ -1,95 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
/** @} */
|
||||
-93
@@ -1,93 +0,0 @@
|
||||
/**
|
||||
* 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)
|
||||
|
||||
-93
@@ -1,93 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
/** @} */
|
||||
-95
@@ -1,95 +0,0 @@
|
||||
/**
|
||||
* 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)
|
||||
-95
@@ -1,95 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
/** @} */
|
||||
-93
@@ -1,93 +0,0 @@
|
||||
/**
|
||||
* 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)
|
||||
-97
@@ -1,97 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
/** @} */
|
||||
-103
@@ -1,103 +0,0 @@
|
||||
/**
|
||||
* 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)
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
/** @} */
|
||||
-96
@@ -1,96 +0,0 @@
|
||||
/**
|
||||
* 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)
|
||||
-95
@@ -1,95 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
/** @} */
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
/**
|
||||
* 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
|
||||
/** @} */
|
||||
-280
File diff suppressed because it is too large.
Load diff
-120
@@ -1,120 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
/** @} */
|
||||
-79
@@ -1,79 +0,0 @@
|
||||
/**
|
||||
* 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__
|
||||
Loaded 100 of 1436 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user