phyplus first submit

This commit is contained in:
fenghang
2021-10-29 16:39:12 +08:00
committed by Xiang Xiao
parent 565964a12f
commit 073c9880a3
122 changed files with 50027 additions and 0 deletions
+371
View File
@@ -0,0 +1,371 @@
/****************************************************************************
* arch/arm/include/armv6-m/irq.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* This file should never be included directly but, rather, only indirectly
* through nuttx/irq.h
*/
#ifndef __ARCH_ARM_INCLUDE_ARMV6_M_IRQ_H
#define __ARCH_ARM_INCLUDE_ARMV6_M_IRQ_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/irq.h>
#ifndef __ASSEMBLY__
# include <nuttx/compiler.h>
# include <stdint.h>
#endif
#include <arch/chip/chip.h>
/****************************************************************************
* Pre-processor Prototypes
****************************************************************************/
/* Configuration ************************************************************/
/* If this is a kernel build,
* how many nested system calls should we support?
*/
#ifndef CONFIG_SYS_NNEST
# define CONFIG_SYS_NNEST 2
#endif
/* IRQ Stack Frame Format ***************************************************
*
* The following additional registers are stored by the interrupt handling
* logic.
*/
#define REG_R13 (0) /* R13 = SP at time of interrupt */
#define REG_PRIMASK (1) /* PRIMASK */
#define REG_R4 (2) /* R4 */
#define REG_R5 (3) /* R5 */
#define REG_R6 (4) /* R6 */
#define REG_R7 (5) /* R7 */
#define REG_R8 (6) /* R8 */
#define REG_R9 (7) /* R9 */
#define REG_R10 (8) /* R10 */
#define REG_R11 (9) /* R11 */
/* In the kernel build, we may return to either privileged or unprivileged
* modes.
*/
#ifdef CONFIG_BUILD_PROTECTED
# define REG_EXC_RETURN (10) /* EXC_RETURN */
# define SW_XCPT_REGS (11)
#else
# define SW_XCPT_REGS (10)
#endif
/* The total number of registers saved by software */
#define SW_XCPT_SIZE (4 * SW_XCPT_REGS)
/* On entry into an IRQ, the hardware automatically saves the following
* registers on the stack in this (address) order:
*/
#define REG_DUMMY0 (SW_XCPT_REGS+0) /* DUMMY */
#define REG_DUMMY1 (SW_XCPT_REGS+1) /* DUMMY */
#define REG_R0 (SW_XCPT_REGS+0+2) /* R0 */
#define REG_R1 (SW_XCPT_REGS+1+2) /* R1 */
#define REG_R2 (SW_XCPT_REGS+2+2) /* R2 */
#define REG_R3 (SW_XCPT_REGS+3+2) /* R3 */
#define REG_R12 (SW_XCPT_REGS+4+2) /* R12 */
#define REG_R14 (SW_XCPT_REGS+5+2) /* R14 = LR */
#define REG_R15 (SW_XCPT_REGS+6+2) /* R15 = PC */
#define REG_XPSR (SW_XCPT_REGS+7+2) /* xPSR */
#define HW_XCPT_REGS (10)
#define HW_XCPT_SIZE (4 * HW_XCPT_REGS)
#define XCPTCONTEXT_REGS (HW_XCPT_REGS + SW_XCPT_REGS)
#define XCPTCONTEXT_SIZE (4 * XCPTCONTEXT_REGS)
/* Alternate register names */
#define REG_A1 REG_R0
#define REG_A2 REG_R1
#define REG_A3 REG_R2
#define REG_A4 REG_R3
#define REG_V1 REG_R4
#define REG_V2 REG_R5
#define REG_V3 REG_R6
#define REG_V4 REG_R7
#define REG_V5 REG_R8
#define REG_V6 REG_R9
#define REG_V7 REG_R10
#define REG_SB REG_R9
#define REG_SL REG_R10
#define REG_FP REG_R7
#define REG_IP REG_R12
#define REG_SP REG_R13
#define REG_LR REG_R14
#define REG_PC REG_R15
/* The PIC register is usually R10. It can be R9 is stack checking is enabled
* or if the user changes it with -mpic-register on the GCC command line.
*/
#define REG_PIC REG_R10
/* CONTROL register */
#define CONTROL_FPCA (1 << 2) /* Bit 2: Floating-point context active */
#define CONTROL_SPSEL (1 << 1) /* Bit 1: Stack-pointer select */
#define CONTROL_NPRIV (1 << 0) /* Bit 0: Not privileged */
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
/* This structure represents the return state from a system call */
#ifdef CONFIG_LIB_SYSCALL
struct xcpt_syscall_s
{
uint32_t excreturn; /* The EXC_RETURN value */
uint32_t sysreturn; /* The return PC */
};
#endif
/* The following structure is included in the TCB and defines the complete
* state of the thread.
*/
struct xcptcontext
{
/* The following function pointer is non-zero if there
* are pending signals to be processed.
*/
void *sigdeliver; /* Actual type is sig_deliver_t */
/* These are saved copies of LR, PRIMASK, and xPSR used during
* signal processing.
*
* REVISIT: Because there is only one copy of these save areas,
* only a single signal handler can be active. This precludes
* queuing of signal actions. As a result, signals received while
* another signal handler is executing will be ignored!
*/
uint32_t saved_pc;
uint32_t saved_primask;
uint32_t saved_xpsr;
#ifdef CONFIG_BUILD_PROTECTED
uint32_t saved_lr;
/* This is the saved address to use when returning from a user-space
* signal handler.
*/
uint32_t sigreturn;
#endif
#ifdef CONFIG_LIB_SYSCALL
/* The following array holds the return address and the exc_return value
* needed to return from each nested system call.
*/
uint8_t nsyscalls;
struct xcpt_syscall_s syscall[CONFIG_SYS_NNEST];
#endif
/* Register save area */
uint32_t regs[XCPTCONTEXT_REGS];
};
#endif
/****************************************************************************
* Inline functions
****************************************************************************/
#ifndef __ASSEMBLY__
/* Name: up_irq_save, up_irq_restore, and friends.
*
* NOTE: This function should never be called from application code and,
* as a general rule unless you really know what you are doing, this
* function should not be called directly from operation system code either:
* Typically, the wrapper functions, enter_critical_section() and
* leave_critical section(), are probably what you really want.
*/
/* Get/set the PRIMASK register */
static inline uint8_t getprimask(void) inline_function;
static inline uint8_t getprimask(void)
{
uint32_t primask;
__asm__ __volatile__
(
"\tmrs %0, primask\n"
: "=r" (primask)
:
: "memory");
return (uint8_t)primask;
}
static inline void setprimask(uint32_t primask) inline_function;
static inline void setprimask(uint32_t primask)
{
__asm__ __volatile__
(
"\tmsr primask, %0\n"
:
: "r" (primask)
: "memory");
}
/* Disable IRQs */
static inline void up_irq_disable(void) inline_function;
static inline void up_irq_disable(void)
{
__asm__ __volatile__ ("\tcpsid i\n");
}
/* Save the current primask state & disable IRQs */
static inline irqstate_t up_irq_save(void) inline_function;
static inline irqstate_t up_irq_save(void)
{
unsigned short primask;
/* Return the current value of primask register and set
* bit 0 of the primask register to disable interrupts
*/
__asm__ __volatile__
(
"\tmrs %0, primask\n"
"\tcpsid i\n"
: "=r" (primask)
:
: "memory");
return primask;
}
/* Enable IRQs */
static inline void up_irq_enable(void) inline_function;
static inline void up_irq_enable(void)
{
__asm__ __volatile__ ("\tcpsie i\n");
}
/* Restore saved primask state */
static inline void up_irq_restore(irqstate_t flags) inline_function;
static inline void up_irq_restore(irqstate_t flags)
{
/* If bit 0 of the primask is 0, then we need to restore
* interrupts.
*/
__asm__ __volatile__
(
"\tmsr primask, %0\n"
:
: "r" (flags)
: "memory");
}
/* Get/set IPSR */
static inline uint32_t getipsr(void) inline_function;
static inline uint32_t getipsr(void)
{
uint32_t ipsr;
__asm__ __volatile__
(
"\tmrs %0, ipsr\n"
: "=r" (ipsr)
:
: "memory");
return ipsr;
}
/* Get/set CONTROL */
static inline uint32_t getcontrol(void) inline_function;
static inline uint32_t getcontrol(void)
{
uint32_t control;
__asm__ __volatile__
(
"\tmrs %0, control\n"
: "=r" (control)
:
: "memory");
return control;
}
static inline void setcontrol(uint32_t control) inline_function;
static inline void setcontrol(uint32_t control)
{
__asm__ __volatile__
(
"\tmsr control, %0\n"
:
: "r" (control)
: "memory");
}
#endif /* __ASSEMBLY__ */
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifndef __ASSEMBLY__
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif
#endif /* __ARCH_ARM_INCLUDE_ARMV6_M_IRQ_H */
+40
View File
@@ -0,0 +1,40 @@
/****************************************************************************
* arch/arm/include/phy62xx/chip.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __ARCH_ARM_INCLUDE_PHY62XX_CHIP_H
#define __ARCH_ARM_INCLUDE_PHY62XX_CHIP_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Pre-processor Prototypes
****************************************************************************/
#define NVIC_SYSH_PRIORITY_MIN 0xc0 /* All bits[7:6] set is minimum priority */
#define NVIC_SYSH_PRIORITY_DEFAULT 0x80 /* Midpoint is the default */
#define NVIC_SYSH_PRIORITY_MAX 0x00 /* Zero is maximum priority */
#define NVIC_SYSH_PRIORITY_STEP 0x40 /* Two bits of interrupt priority used */
/* Get customizations for each supported chip */
#endif /* __ARCH_ARM_INCLUDE_STM32F0L0G0_CHIP_H */
+107
View File
@@ -0,0 +1,107 @@
/****************************************************************************
* arch/arm/include/phy62xx/irq.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* This file should never be included directly but, rather, only indirectly
* through nuttx/irq.h
*/
#ifndef __ARCH_ARM_INCLUDE_PHY62XX_IRQ_H
#define __ARCH_ARM_INCLUDE_PHY62XX_IRQ_H
/****************************************************************************
* Included Files
****************************************************************************/
# include <arch/phy62xx/phy62xx_irq.h>
#ifndef __ASSEMBLY__
# include <stdint.h>
#endif
/****************************************************************************
* Pre-processor Prototypes
****************************************************************************/
/* IRQ numbers. The IRQ number corresponds vector number and hence map
* directly to bits in the NVIC. This does, however, waste several words of
* memory in the IRQ to handle mapping tables.
*/
/* Common Processor Exceptions (vectors 0-15) */
#define PHY62XX_IRQ_RESERVED (0) /* Reserved vector (only used with CONFIG_DEBUG_FEATURES) */
/* Vector 0: Reset stack pointer value */
/* Vector 1: Reset (not handler as an IRQ) */
#define PHY62XX_IRQ_NMI (2) /* Vector 2: Non-Maskable Interrupt (NMI) */
#define PHY62XX_IRQ_HARDFAULT (3) /* Vector 3: Hard fault */
/* Vectors 4-10: Reserved */
#define PHY62XX_IRQ_SVCALL (11) /* Vector 11: SVC call */
/* Vector 12-13: Reserved */
#define PHY62XX_IRQ_PENDSV (14) /* Vector 14: Pendable system service request */
#define PHY62XX_IRQ_SYSTICK (15) /* Vector 15: System tick */
/* External interrupts (vectors >= 16) */
#define PHY62XX_IRQ_EXTINT (16) /* Vector number of the first external interrupt */
/****************************************************************************
* Included Files
****************************************************************************/
/* Include MCU-specific external interrupt definitions */
#define NR_IRQS (PHY62XX_IRQ_EXTINT + PHY62XX_IRQ_NEXTINT)
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
typedef void (*vic_vector_t)(uint32_t *regs);
/****************************************************************************
* Inline functions
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef __cplusplus
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_INCLUDE_STM32F0L0G0_IRQ_H */
+104
View File
@@ -0,0 +1,104 @@
/****************************************************************************
* arch/arm/include/phy62xx/phy62xx_irq.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* This file should never be included directly but, rather, only indirectly
* through nuttx/irq.h
*/
#ifndef __ARCH_ARM_INCLUDE_STM32F0L0G0_STM32F0_IRQ_H
#define __ARCH_ARM_INCLUDE_STM32F0L0G0_STM32F0_IRQ_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/irq.h>
#include <arch/phy62xx/chip.h>
/****************************************************************************
* Pre-processor Prototypes
****************************************************************************/
/* IRQ numbers. The IRQ number corresponds vector number and hence map
* directly to bits in the NVIC. This does, however, waste several words of
* memory in the IRQ to handle mapping tables.
*
* Processor Exceptions (vectors 0-15). These common definitions can be
* found in nuttx/arch/arm/include/stm32f0l0g0/irq.h
*/
#define PHY62XX_IRQ_BB_IRQn (PHY62XX_IRQ_EXTINT + 4) /* 4: RCC and CRS */
#define PHY62XX_IRQ_KSCAN_IRQn (PHY62XX_IRQ_EXTINT + 5) /* 5: EXTI0_1 */
#define PHY62XX_IRQ_RTC_IRQn (PHY62XX_IRQ_EXTINT + 6) /* 6: EXTI2_3 */
#define PHY62XX_IRQ_WDT_IRQn (PHY62XX_IRQ_EXTINT + 10) /* 10: DMA2_CH2 */
#define PHY62XX_IRQ_UART0_IRQn (PHY62XX_IRQ_EXTINT + 11) /* 11: DMA1_CH4 */
#define PHY62XX_IRQ_I2C0_IRQn (PHY62XX_IRQ_EXTINT + 12) /* 12: ADC */
#define PHY62XX_IRQ_I2C1_IRQn (PHY62XX_IRQ_EXTINT + 13) /* 13: TIM1_BRK_UP_TRG_COM */
#define PHY62XX_IRQ_SPI0_IRQn (PHY62XX_IRQ_EXTINT + 14) /* 14: TIM1_CC */
#define PHY62XX_IRQ_SPI1_IRQn (PHY62XX_IRQ_EXTINT + 15) /* 15: TIM2 */
#define PHY62XX_IRQ_GPIO_IRQn (PHY62XX_IRQ_EXTINT + 16) /* 16: TIM3 */
#define PHY62XX_IRQ_UART1_IRQn (PHY62XX_IRQ_EXTINT + 17) /* 17: TIM6 */
#define PHY62XX_IRQ_SPIF_IRQn (PHY62XX_IRQ_EXTINT + 18) /* 17: DAC */
#define PHY62XX_IRQ_DMAC_IRQn (PHY62XX_IRQ_EXTINT + 19) /* 18: TIM7 */
#define PHY62XX_IRQ_TIM1_IRQn (PHY62XX_IRQ_EXTINT + 20) /* 20: TIM15 */
#define PHY62XX_IRQ_TIM2_IRQn (PHY62XX_IRQ_EXTINT + 21) /* 21: TIM16 */
#define PHY62XX_IRQ_TIM3_IRQn (PHY62XX_IRQ_EXTINT + 22) /* 22: TIM17 */
#define PHY62XX_IRQ_TIM4_IRQn (PHY62XX_IRQ_EXTINT + 23) /* 23: I2C1 */
#define PHY62XX_IRQ_TIM5_IRQn (PHY62XX_IRQ_EXTINT + 24) /* 24: I2C2 */
#define PHY62XX_IRQ_TIM6_IRQn (PHY62XX_IRQ_EXTINT + 25) /* 25: SPI1 */
#define PHY62XX_IRQ_AES_IRQn (PHY62XX_IRQ_EXTINT + 28) /* 28: USART2 */
#define PHY62XX_IRQ_ADCC_IRQn (PHY62XX_IRQ_EXTINT + 29) /* 29: USART3 */
#define PHY62XX_IRQ_QDEC_IRQn (PHY62XX_IRQ_EXTINT + 30) /* 30: HDMI CAN */
#define PHY62XX_IRQ_RNG_IRQn (PHY62XX_IRQ_EXTINT + 31) /* 31: USB */
#define PHY62XX_IRQ_NEXTINT (32) /* 32 external interrupts */
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
typedef void (*vic_vector_t)(uint32_t *regs);
/****************************************************************************
* Inline functions
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef __cplusplus
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_INCLUDE_STM32F0L0G0_STM32F0_IRQ_H */
+27
View File
@@ -0,0 +1,27 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
comment "PHY62xx Configuration Options"
choice
prompt "only PHY 6222 Chip Selection"
default ARCH_CHIP_PHY6222
depends on ARCH_CHIP_PHY62XX
config ARCH_CHIP_PHY6222
bool "PHY6222"
endchoise
config PHY6222_BLE
bool "enable ble"
default n
config PHYPLUS_STUB
bool "enable phyplus stub"
default y
#config PHYPLUS_DOWNLOAD
# bool "enable phyplus ble lib file download from server"
# default n
+112
View File
@@ -0,0 +1,112 @@
############################################################################
# arch/arm/src/phy62xx/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
CMN_ASRCS = phy62xx_exception.S phy62xx_start.S arm_saveusercontext.S arm_fullcontextrestore.S
CMN_ASRCS += arm_switchcontext.S vfork.S
CMN_CSRCS = arm_allocateheap.c arm_assert.c arm_blocktask.c arm_copyfullstate.c
CMN_CSRCS += arm_createstack.c arm_mdelay.c arm_udelay.c arm_exit.c
CMN_CSRCS += arm_initialize.c arm_initialstate.c arm_interruptcontext.c
CMN_CSRCS += arm_puts.c arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c
CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c
CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_stackframe.c
CMN_CSRCS += arm_systemreset.c arm_unblocktask.c arm_usestack.c arm_doirq.c
#CMN_CSRCS += arm_hardfault.c arm_svcall.c arm_vectors.c arm_vfork.c
CMN_CSRCS += phy62xx_hardfault.c arm_svcall.c arm_vectors.c arm_vfork.c
#CMN_CSRCS += arm_etherstub.c
ifeq ($(CONFIG_BUILD_PROTECTED),y)
CMN_CSRCS += arm_task_start.c arm_pthread_start.c
CMN_CSRCS += arm_pthread_exit.c
CMN_CSRCS += arm_signal_dispatch.c
CMN_UASRCS += arm_signal_handler.S
endif
ifeq ($(CONFIG_STACK_COLORATION),y)
CMN_CSRCS += arm_checkstack.c
endif
ifeq ($(CONFIG_DEBUG_FEATURES),y)
CMN_CSRCS += arm_dumpnvic.c
endif
CHIP_CSRCS = start.c gpio.c irq.c timer.c clock.c uart.c pwrmgr.c idle.c my_printf.c flash.c
CHIP_CSRCS += jump_table.c
CHIP_CSRCS += pplus_mtd_flash.c
ifeq ($(CONFIG_PHY6222_BLE),y)
#CHIP_CSRCS += phy62xx_ble.c phy62xx_ble_hcitl.c
#CHIP_CSRCS += phy62xx_ble_patch.c phy62xx_ble_hci_event_patch.c rf_phy_driver.c
CHIP_CSRCS += phy62xx_ble.c phy62xx_ble_patch.c rf_phy_driver.c
endif
ifeq ($(CONFIG_TIMER),y)
CHIP_CSRCS += phyplus_tim.c
CHIP_CSRCS += phyplus_timer_lowerhalf.c
CHIP_CSRCS += phyplus_timerisr.c
endif
ifeq ($(CONFIG_DEV_GPIO),y)
CHIP_CSRCS += phyplus_gpio.c
endif
ifeq ($(CONFIG_PHYPLUS_STUB),y)
CHIP_CSRCS += phyplus_stub.c
endif
INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)include)
INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)ble$(DELIM)controller)
INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)ble$(DELIM)hci)
INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)ble$(DELIM)include)
INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)osal$(DELIM)include)
CFLAGS += -ffunction-sections
CFLAGS += -DCFG_CP
CFLAGS += -DPHY_MCU_TYPE=MCU_BUMBEE_M0
CFLAGS += -DHOST_CONFIG=4
CFLAGS += -DHCI_TL_NONE=1
CFLAGS += -DMTU_SIZE=247
CFLAGS += -DENABLE_LOG_ROMx=0
CFLAGS += -DPHY_MCU_TYPE=MCU_BUMBEE_M0
CFLAGS += -DCFG_SLEEP_MODE=PWR_MODE_NO_SLEEP
CFLAGS += -DDEBUG_INFO=1
CFLAGS += -DUSE_SYS_TICK
CFLAGS += -DHUGE_MODE=0
CFLAGS += -DMAX_NUM_LL_CONN=1
CFLAGS += -DUSE_ROMSYM_ALIAS
#LDFLAGS += "$(ARCH_SRCDIR)$(DELIM)board$(DELIM)bb_rom_sym_m0.gdbsym"
LDFLAGS += "$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)bb_rom_sym_m0.gdbsym"
LDFLAGS += -Wl,-Map="../../../phyplus_build.map"
LDFLAGS += -Wl,--gc-sections
.buildlib:
$(Q) if [ -d ../../../../../phy62xxble ]; then \
echo "##############build lib internally##############"; \
make -C ../../../../../phy62xxble; \
else \
echo "############download lib form server############"; \
curl -L -o libphy62xxble.a http://www.phyplusinc.com/phyplus/libphy62xxble.a; \
cp -a libphy62xxble.a ../../../staging; \
fi
context:: .buildlib
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,137 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
#ifndef _LL_BUF_H_
#define _LL_BUF_H_
#include <stdint.h>
#define MAX_ADV_BUF 1 // buffer advertisement packet
#define TYP_CONN_BUF_LEN 4 // typical packet number per connection event
#define MAX_LL_BUF_LEN 8 // maximum LL buffer for Rx/Tx packet
//#define LL_CTRL_PDU_LEN 29 //V4.0/4.2: 2octets header + 27 octets payload
//#define LL_ADV_PDU_LEN 39 //V4.0/4.2: 2octets header + 37 octets payload
//#define LL_DATA_PDU_LEN 33 //V4.0 : 2octets header + 31 octets payload
// for Rx FIFO, HW will pack zero bytes to align 4bytes boarder
// BLE 4.0, PDU length < 39, 3Bytes CRC will also be read.
// note that PDU head is write in "rxheader/txheader" field, the buffer need (39 + 3 - 2) = 40 bytes,
// add 2 bytes to align 4 bytes edge
//#define BLE_PACKET_BUF_LEN 42
//257+3-2=256
// BLE5.0, PDU length: maximum 257 octets, 3 octets CRC, 2 octets PDU head is write in "rxheader/txheader" field
//#define BLE_PACKET_BUF_LEN 258 //(257+3-2)
// BLE 5.1, PDU length: 2-258 octets, 3 octets CRC, 2 octets PDU head is write in "rxheader/txheader" field
// length should align to word edge, so + 3 octet
#define BLE_PACKET_BUF_LEN 262 //(258+3-2) + 3
#define RX_BUF_LEN BLE_PACKET_BUF_LEN
#define TX_BUF_LEN BLE_PACKET_BUF_LEN
#define TX_CTRL_BUF_LEN 34 //(27+4+3)
#define LL_PDU_LENGTH_SUPPORTED_MAX_TX_OCTECTS 251
#define LL_PDU_LENGTH_SUPPORTED_MAX_RX_OCTECTS 251
#define LL_PDU_LENGTH_SUPPORTED_MAX_TX_TIME 2120
#define LL_PDU_LENGTH_SUPPORTED_MAX_RX_TIME 2120
#define LL_PDU_LENGTH_INITIAL_MAX_TX_OCTECTS 27
#define LL_PDU_LENGTH_INITIAL_MAX_RX_OCTECTS 27
#define LL_PDU_LENGTH_INITIAL_MAX_TX_TIME 328
#define LL_PDU_LENGTH_INITIAL_MAX_RX_TIME 328
// BBB update
struct ll_pkt_desc
{
uint32_t valid; // mean a valid data received from ble
uint16_t header;
uint8_t data[2];
};
struct buf_rx_desc
{
uint32_t valid; // mean a valid data received from ble
/// rx header
uint16_t rxheader;
uint8_t data[RX_BUF_LEN ]; // for v4.2 BLE, set to 256
};
struct buf_tx_desc
{
uint32_t valid; // means a valid data to wait for send to ble
//uint32_t sent; // means tha data has been sent before
/// tx header
uint16_t txheader;
/// data
uint8_t data[TX_BUF_LEN];
};
typedef struct
{
uint16_t header;
//uint8_t data[TX_BUF_LEN];
uint8_t data[TX_CTRL_BUF_LEN];
} __attribute__((aligned(4))) ctrl_packet_buf;
typedef struct
{
#if 0
struct buf_tx_desc tx_conn_desc[MAX_LL_BUF_LEN]; // new Tx data buffer
struct buf_rx_desc rx_conn_desc[MAX_LL_BUF_LEN];
struct buf_tx_desc tx_not_ack_pkt;
struct buf_tx_desc tx_ntrm_pkts[MAX_LL_BUF_LEN];
#endif
struct ll_pkt_desc* tx_conn_desc[MAX_LL_BUF_LEN]; // new Tx data buffer
struct ll_pkt_desc* rx_conn_desc[MAX_LL_BUF_LEN];
struct ll_pkt_desc* tx_not_ack_pkt;
struct ll_pkt_desc* tx_ntrm_pkts[MAX_LL_BUF_LEN];
uint8_t ntrm_cnt; // number of packets not transmit
uint8_t tx_write;
uint8_t tx_read;
uint8_t tx_loop; // flag for write ptr & read ptr work in the same virtual buffer bank
uint8_t rx_write;
uint8_t rx_read;
uint8_t rx_loop; // flag for write ptr & read ptr work in the same virtual buffer bank
} llLinkBuf_t;
#endif
@@ -0,0 +1,372 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
#ifndef _LL_H_
#define _LL_H_
#include "types.h"
#include "mcu.h"
#include "ll.h"
#include "ll_def.h"
#define LL_DATA_PDU( pktHdr ) ((pktHdr) != LL_DATA_PDU_HDR_LLID_CONTROL_PKT)
#define LL_CTRL_PDU( pktHdr ) ((pktHdr) == LL_DATA_PDU_HDR_LLID_CONTROL_PKT)
#define LL_INVALID_LLID( pktHdr ) ((pktHdr) == LL_DATA_PDU_HDR_LLID_RESERVED)
void LL_IRQHandler(void);
void move_to_slave_function(void);
void LL_slave_conn_event(void);
void LL_master_conn_event(void);
void LL_set_default_conn_params(llConnState_t* connPtr);
//void ll_setMem(uint8_t *buf, uint8_t v, int n);
//void ll_cpyMem(uint8_t *dst, uint8_t *src, int n);
void LL_evt_schedule(void);
llStatus_t llSetupAdv( void );
void llConvertLstoToEvent( llConnState_t* connPtr,
connParam_t* connParams );
void llSlaveEvt_TaskEndOk( void );
// for master process
void llMasterEvt_TaskEndOk( void );
// Connection Management
extern llConnState_t* llAllocConnId( void );
extern void llReleaseConnId( llConnState_t* connPtr );
extern void llReleaseAllConnId( void );
extern uint16 llGetMinCI( uint16 connInterval );
extern uint8 llGetNextConn( void );
extern void llConnCleanup( llConnState_t* connPtr );
extern void llConnTerminate( llConnState_t* connPtr, uint8 reason );
extern uint8 llPendingUpdateParam( void );
extern void llInitFeatureSet( void );
extern uint32 llGenerateValidAccessAddr( void );
extern uint32 llGenerateCRC( void );
extern uint8 llEventInRange( uint16 curEvent, uint16 nextEvent, uint16 updateEvent );
extern uint16 llEventDelta( uint16 eventA, uint16 eventB );
extern void llConvertLstoToEvent( llConnState_t* connPtr, connParam_t* connParams );
extern void llConvertCtrlProcTimeoutToEvent( llConnState_t* connPtr );
// Task Setup
extern llStatus_t llSetupAdv( void );
extern void llSetupDirectedAdvEvt( void );
extern void llSetupUndirectedAdvEvt( void );
extern void llSetupNonConnectableAdvEvt( void );
extern void llSetupScannableAdvEvt( void );
extern void llSetupScan( uint8 chan );
extern void llSetupScanInit( void );
extern void llSetupInit( uint8 connId );
extern void llSetupConn( void );
// A2 added
extern uint8 llSetupSecNonConnectableAdvEvt( void );
// A2 multi-connection
extern uint8 llSetupSecConnectableAdvEvt( void );
extern uint8 llSetupSecScannableAdvEvt( void );
extern void llSetupSecScan( uint8 chan );
extern uint32 llCalcMaxScanTime(void);
extern uint8 llSecAdvAllow(void);
// A2 multi-connection
extern uint8 llSetupSecAdvEvt( void );
extern void llSetupSecInit( uint8 chan );
extern uint8_t ll_get_next_active_conn(uint8_t current_conn_id);
extern uint32 ll_get_next_timer(uint8 current_conn_id);
extern void ll_scheduler(uint32 time);
extern void ll_addTask(uint8 connId, uint32 time);
extern void ll_deleteTask(uint8 connId);
// extended adv scheduler functions
void ll_adv_scheduler(void);
void ll_add_adv_task(extAdvInfo_t* pExtAdv);
void ll_delete_adv_task(uint8 index);
uint8 llSetupExtAdvEvent(extAdvInfo_t* pAdvInfo);
// periodic adv functions
void ll_add_adv_task_periodic(periodicAdvInfo_t* pPrdAdv, extAdvInfo_t* pExtAdv);
void ll_add_adv_task_periodic(periodicAdvInfo_t* pPrdAdv, extAdvInfo_t* pExtAdv);
void ll_delete_adv_task_periodic(uint8 index);
uint8 llSetupPrdAdvEvent(periodicAdvInfo_t* pPrdAdv, extAdvInfo_t* pExtAdv);
void ll_adv_scheduler_periodic(void);
// extended scan functions
extern void llSetupExtScan( uint8 chan );
extern void llSetupExtInit(void);
extern void llSetupPrdScan( void );
extern uint16 llAllocateSyncHandle(void);
extern uint8 llDeleteSyncHandle(uint16 sync_handle);
// Data Management
extern uint8 llEnqueueDataQ( llDataQ_t* pDataQ, txData_t* pTxData );
extern uint8 llEnqueueHeadDataQ( llDataQ_t* pDataQ, txData_t* pTxData );
extern txData_t* llDequeueDataQ( llDataQ_t* pDataQ );
extern uint8 llDataQEmpty( llDataQ_t* pDataQ );
extern uint8 llWriteTxData ( llConnState_t* connPtr, uint8 pktHdr, uint8 pktLen, uint8* pBuf );
extern uint8* llMemCopySrc( uint8* pDst, uint8* pSrc, uint8 len );
extern uint8* llMemCopyDst( uint8* pDst, uint8* pSrc, uint8 len );
extern void llProcessMasterControlPacket( llConnState_t* connPtr, uint8* pBuf );
extern void llProcessSlaveControlPacket( llConnState_t* connPtr, uint8* pBuf );
extern void llProcessTxData( llConnState_t* connPtr, uint8 context );
extern uint8 llProcessRxData( void );
// Control Procedure Setup
extern uint8 llSetupUpdateParamReq( llConnState_t* connPtr ); // M
extern uint8 llSetupUpdateChanReq( llConnState_t* connPtr ); // M
extern uint8 llSetupEncReq( llConnState_t* connPtr ); // M
extern uint8 llSetupEncRsp( llConnState_t* connPtr ); // S
extern uint8 llSetupStartEncReq( llConnState_t* connPtr ); // S
extern uint8 llSetupStartEncRsp( llConnState_t* connPtr ); // M, S
extern uint8 llSetupPauseEncReq( llConnState_t* connPtr ); // M
extern uint8 llSetupPauseEncRsp( llConnState_t* connPtr ); // S
extern uint8 llSetupRejectInd( llConnState_t* connPtr,uint8 errCode); // S
extern uint8 llSetupFeatureSetReq( llConnState_t* connPtr ); // M, S
extern uint8 llSetupFeatureSetRsp( llConnState_t* connPtr ); // M, S
extern uint8 llSetupVersionIndReq( llConnState_t* connPtr ); // M
extern uint8 llSetupTermInd( llConnState_t* connPtr ); // M, S
extern uint8 llSetupUnknownRsp( llConnState_t* connPtr ); // M, S
extern uint8 llSetupDataLenghtReq( llConnState_t* connPtr );//M,S
extern uint8 llSetupDataLenghtRsp( llConnState_t* connPtr );//M,S
extern uint8 llSetupPhyReq( llConnState_t* connPtr ); //M,S
extern uint8 llSetupPhyRsp( llConnState_t* connPtr ); //M,S
extern uint8 llSetupPhyUpdateInd( llConnState_t* connPtr );//M
extern uint8 llSetupRejectExtInd( llConnState_t* connPtr,uint8 errCode);
// Control Procedure Management
extern void llEnqueueCtrlPkt( llConnState_t* connPtr, uint8 ctrlType );
extern void llDequeueCtrlPkt( llConnState_t* connPtr );
extern void llReplaceCtrlPkt( llConnState_t* connPtr, uint8 ctrlType );
// Data Channel Management
extern void llProcessChanMap( llConnState_t* connPtr, uint8* chanMap );
extern uint8 llGetNextDataChan( llConnState_t* connPtr, uint16 numEvents );
extern void llSetNextDataChan( llConnState_t* connPtr );
extern uint8 llAtLeastTwoChans( uint8* chanMap );
//2020-01-20 add for LL CTE
extern uint8 llSetupCTEReq( llConnState_t* connPtr );
extern uint8 llSetupCTERsp( llConnState_t* connPtr );
uint8_t llTimeCompare(int base_time, int fine_time);
uint32_t calculateTimeDelta(int base_time, int fine_time);
void llSetNextDataChan( llConnState_t* connPtr );
// White List Related
extern llStatus_t llCheckWhiteListUsage( void );
// function add by HZF
void llResetConnId( uint8 connId );
void llResetRfCounters(void);
extern void llInitFeatureSet( void );
extern uint16 llCalcScaFactor( uint8 masterSCA );
extern void llCalcTimerDrift( uint32 connInterval,
uint16 slaveLatency,
uint8 sleepClkAccuracy,
uint32* timerDrift );
// add by HZF
uint8 llGetNextAdvChn(uint8 cur_chn);
// Tx loop buffer process
void update_tx_write_ptr(llConnState_t* connPtr);
void update_tx_read_ptr(llConnState_t* connPtr);
uint8_t getTxBufferSize(llConnState_t* connPtr);
uint8_t getTxBufferFree(llConnState_t* connPtr);
uint8_t get_tx_read_ptr(llConnState_t* connPtr);
uint8_t get_tx_write_ptr(llConnState_t* connPtr);
// Rx loop buffer process
void update_rx_write_ptr(llConnState_t* connPtr);
void update_rx_read_ptr(llConnState_t* connPtr);
uint8_t getRxBufferSize(llConnState_t* connPtr);
uint8_t getRxBufferFree(llConnState_t* connPtr);
uint8_t get_rx_read_ptr(llConnState_t* connPtr);
uint8_t get_rx_write_ptr(llConnState_t* connPtr);
// reset buffer
void reset_conn_buf(uint8 index);
void ll_schedule_next_event(int time);
uint16 ll_generateTxBuffer(int txFifo_vacancy, uint16* pSave_ptr);
void ll_read_rxfifo(void);
void ll_hw_read_tfifo_rtlp(void);
int ll_hw_read_tfifo_packet(uint8* pkt);
// function in ll_slaveEndCause.c
uint8 llSetupNextSlaveEvent( void );
uint8 llProcessSlaveControlProcedures( llConnState_t* connPtr );
uint8 llCheckForLstoDuringSL( llConnState_t* connPtr );
// function in ll_hwItf.c
void ll_hw_process_RTO(uint32 ack_num);
void ll_debug_output(uint32 state);
void llAdjSlaveLatencyValue( llConnState_t* connPtr );
//function for DLE add by ZQ
void llPduLengthManagmentReset(void);
void llTrxNumAdaptiveConfig(void);
void llPduLengthUpdate(uint16 connHandle);
//uint8 LL_PLUS_GetLocalPduDataLength(ll_pdu_length_ctrl_t * pduLen);
//function for PHY UPDATE add by ZQ
void llPhyModeCtrlReset(void);
void llPhyModeCtrlUpdateNotify(llConnState_t* connPtr, uint8 status);
//llStatus_t LL_PLUS_GetLocalPhyMode(ll_phy_ctrl_t * phyCtrl);
void llSetNextPhyMode( llConnState_t* connPtr );
extern void llInitFeatureSetDLE(uint8 enable);
extern void llInitFeatureSet2MPHY(uint8 enable);
extern void llInitFeatureSetCodedPHY(uint8 enable);
// function for whitelist
extern uint8 ll_isAddrInWhiteList(uint8 addrType, uint8* addr);
// function for resolving list
uint8 ll_readLocalIRK(uint8** localIrk, uint8* peerAddr, uint8 peerAddrType);
uint8 ll_readPeerIRK(uint8** peerIrk, uint8* peerAddr, uint8 peerAddrType);
uint8_t ll_getRPAListEntry(uint8* peerAddr);
uint8_t ll_isIrkAllZero(uint8* irk);
uint8_t ll_CalcRandomAddr( uint8* pIRK, uint8* pNewAddr );
uint8_t ll_ResolveRandomAddrs(uint8* pIRK, uint8* pAddr);
uint16 ll_generateExtAdvDid(uint16 old);
// extended advertiser process
uint8 LL_extAdvTimerExpProcess(void);
uint8 LL_prdAdvTimerExpProcess(void);
uint8 LL_prdScanTimerExpProcess(void);
uint8 ll_isFirstAdvChn(uint8 chnMap, uint8 chan);
uint8 ll_getFirstAdvChn(uint8 chnMap);
void ll_ext_adv_schedule_next_event(int time);
void ll_prd_adv_schedule_next_event(int time);
void ll_ext_scan_schedule_next_event(int time);
void ll_ext_init_schedule_next_event(int time);
void ll_prd_scan_schedule_next_event(int time);
uint8 ll_allocAuxAdvTimeSlot(uint8 index);
void ll_updateAuxAdvTimeSlot(uint8 index);
void ll_updateExtAdvRemainderTime(uint32 time);
uint8 ll_allocAuxAdvTimeSlot_prd(uint8 index);
void LL_extScanTimerExpProcess(void);
void LL_extInitTimerExpProcess(void);
void ll_parseExtHeader(uint8* payload, uint16 length);
uint8 llGetNextAuxAdvChn(uint8 current);
/******************************************************************************
fn: llGetNextDataChanCSA2
brief: 2020-01-07 add for CSA 2
input parameters: counter : event counter( PA Counter or connection counter)
chan_id : current data or periodic advertising channel Identifier,
calculate from Access Address
chan_map: PA or connection channel map
cMap_tab: current chan map table that is in use for connection or PA event
chanCnt : used channel count
output parameters: None
return uint8 : next channel index
******************************************************************************/
uint8 llGetNextDataChanCSA2(uint16_t counter,uint16_t chan_id,uint8* chan_map,uint8* cMap_tab,uint8 chanCnt);
#endif
@@ -0,0 +1,101 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/**
****************************************************************************************
@file ll_debug.h
@brief This file defines the status used for debug
$Rev: $
****************************************************************************************
*/
#ifndef _LL_DEBUG_H_
#define _LL_DEBUG_H_
#define DEBUG_ENTER_SYSTEM_SLEEP 0
#define DEBUG_ENTER_MCU_SLEEP 1
#define DEBUG_WAKEUP 2
#define DEBUG_ISR_EXIT 3
#define DEBUG_ISR_ENTRY 4
#define DEBUG_LL_HW_STX 5
#define DEBUG_LL_HW_SRX 6
#define DEBUG_LL_HW_TRX 7
#define DEBUG_LL_HW_RTX 8
#define DEBUG_LL_HW_TRLP 9
#define DEBUG_LL_HW_TRLP_EMPT 10
#define DEBUG_LL_HW_RTLP 11
#define DEBUG_LL_HW_RTLP_1ST 12
#define DEBUG_LL_HW_RTLP_EMPT 13
#define DEBUG_LL_HW_SET_STX 14
#define DEBUG_LL_HW_SET_SRX 15
#define DEBUG_LL_HW_SET_TRX 16
#define DEBUG_LL_HW_SET_RTX 17
#define DEBUG_LL_HW_SET_TRLP 18
#define DEBUG_LL_HW_SET_TRLP_EMPT 19
#define DEBUG_LL_HW_SET_RTLP 20
#define DEBUG_LL_HW_SET_RTLP_1ST 21
#define DEBUG_LL_HW_SET_RTLP_EMPT 22
#define DEBUG_LL_STATE_IDLE 30
#define DEBUG_LL_STATE_ADV_UNDIRECTED 31
#define DEBUG_LL_STATE_ADV_DIRECTED 32
#define DEBUG_LL_STATE_ADV_SCAN 33
#define DEBUG_LL_STATE_ADV_NONCONN 34
#define DEBUG_LL_STATE_SCAN 35
#define DEBUG_LL_STATE_INIT 36
#define DEBUG_LL_STATE_CONN_SLAVE 37
#define DEBUG_LL_STATE_CONN_MASTER 38
#define DEBUG_LL_STATE_DIRECT_TEST_MODE_TX 39
#define DEBUG_LL_STATE_DIRECT_TEST_MODE_RX 40
#define DEBUG_LL_STATE_MODEM_TEST_TX 41
#define DEBUG_LL_STATE_MODEM_TEST_RX 42
#define DEBUG_LL_STATE_MODEM_TEST_TX_FREQ_HOPPING 43
#define DEBUG_LL_SEND_ADV 44
#define DEBUG_LL_TIMER_EXPIRY_ENTRY 50
#define DEBUG_LL_TIMER_EXPIRY_EXIT 51
#endif // _LL_DEBUG_H_
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,124 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/*******************************************************************************
Filename: ll_enc.h
Revised:
Revision:
Description: This file contains the Link Layer (LL) types, contants,
API's etc. for the Bluetooth Low Energy (BLE) Controller
CCM encryption and decryption.
This API is based on ULP BT LE D09R23.
*******************************************************************************/
#ifndef LL_ENC_H
#define LL_ENC_H
#ifdef __cplusplus
extern "C"
{
#endif
/*******************************************************************************
INCLUDES
*/
#include "bcomdef.h"
#include "ll_def.h"
/*******************************************************************************
MACROS
*/
/*******************************************************************************
CONSTANTS
*/
#define LL_ENC_TX_DIRECTION_MASTER 1
#define LL_ENC_TX_DIRECTION_SLAVE 0
#define LL_ENC_RX_DIRECTION_MASTER 0
#define LL_ENC_RX_DIRECTION_SLAVE 1
#define LL_ENC_DATA_BANK_MASK 0xFF7F
#define LL_ENC_TRUE_RAND_BUF_SIZE ((LL_ENC_IV_LEN/2) + (LL_ENC_SKD_LEN/2))
// Generate Session Key using LTK for key and SKD for plaintext.
#define LL_ENC_GenerateSK LL_ENC_AES128_Encrypt
/*******************************************************************************
TYPEDEFS
*/
/*******************************************************************************
LOCAL VARIABLES
*/
/*******************************************************************************
GLOBAL VARIABLES
*/
extern uint8 dataPkt[2*LL_ENC_BLOCK_LEN];
extern uint8 cachedTRNGdata[ LL_ENC_TRUE_RAND_BUF_SIZE ];
/*******************************************************************************
Functions
*/
// Random Number Generation
extern uint8 LL_ENC_GeneratePseudoRandNum( void );
extern uint8 LL_ENC_GenerateTrueRandNum( uint8* buf, uint8 len );
// CCM Encryption
extern void LL_ENC_AES128_Encrypt( uint8* key, uint8* plaintext, uint8* ciphertext );
extern void LL_ENC_AES128_Decrypt( uint8* key, uint8* ciphertext, uint8* plaintext );
extern void LL_ENC_LoadEmptyIV( void );
extern void LL_ENC_ReverseBytes( uint8* buf, uint8 len );
extern void LL_ENC_GenDeviceSKD( uint8* SKD );
extern void LL_ENC_GenDeviceIV( uint8* IV );
extern void LL_ENC_GenerateNonce( uint32 pktCnt, uint8 direction, uint8* nonce );
extern void LL_ENC_EncryptMsg( uint8* nonce, uint8 pktLen, uint8* pbuf, uint8* mic );
extern void LL_ENC_DecryptMsg( uint8* nonce, uint8 pktLen, uint8* pBuf, uint8* mic );
extern void LL_ENC_Encrypt( llConnState_t* connPtr, uint8 pktHdr, uint8 pktLen, uint8* pBuf );
extern uint8 LL_ENC_Decrypt( llConnState_t* connPtr, uint8 pktHdr, uint8 pktLen, uint8* pBuf );
extern void LL_ENC_sm_ah( uint8* pK, uint8* pR, uint8* pAh );
//
extern void LL_ENC_MoveData( uint8* pDst, uint8* pSrc, uint16 len );
#ifdef __cplusplus
}
#endif
#endif /* LL_ENC_H */
@@ -0,0 +1,244 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
#ifndef _LL_HW_DRV_H_
#define _LL_HW_DRV_H_
#include "types.h"
#include "ll_def.h"
#include "bus_dev.h"
#include "rf_phy_driver.h"
// LL_HW_REGISTER_ADDRESS
#define BB_HW_BASE 0x40030000 //BB_HW Base address
#define LL_HW_BASE 0x40031000 //LL_HW Base address
#define LL_HW_TFIFO (LL_HW_BASE+0x400)
#define LL_HW_RFIFO (LL_HW_BASE+0xC00)
#define LL_HW_WRT_EMPTY_PKT *(volatile uint32_t *)(LL_HW_TFIFO) = 0x00000001
//LL_HW_MODE
#define LL_HW_STX 0x0000
#define LL_HW_SRX 0x0001
#define LL_HW_TRX 0x0010
#define LL_HW_RTX 0x0012
#define LL_HW_TRLP 0x0020
#define LL_HW_TRLP_EMPT 0x0022
#define LL_HW_RTLP 0x0030
#define LL_HW_RTLP_1ST 0x0031
#define LL_HW_RTLP_EMPT 0x0032
#define HCLK16M
//#define LL_HW_CYCLES_PER_US CYCLES_PER_US
#ifdef HCLK16M
#define LL_HW_HCLK_PER_US 16 //
#define LL_HW_HCLK_PER_US_BITS 4
#else
#define LL_HW_HCLK_PER_US 32 //
#define LL_HW_HCLK_PER_US_BITS 5
#endif
#define LL_HW_FIFO_MARGIN 70 //
// LL_HW_IRQ_STATUS
#define LIRQ_MD 0x0001 //bit00
#define LIRQ_CERR 0x0002 //bit01
#define LIRQ_RTO 0x0004 //bit02
#define LIRQ_RFULL 0x0008 //bit03
#define LIRQ_RHALF 0x0010 //bit04
#define LIRQ_BIT5 0x0020 //bit05
#define LIRQ_BIT6 0x0040 //bit06
#define LIRQ_BIT7 0x0080 //bit07
#define LIRQ_TD 0x0100 //bit08
#define LIRQ_RD 0x0200 //bit09
#define LIRQ_COK 0x0400 //bit10
#define LIRQ_CERR2 0x0800 //bit11
#define LIRQ_LTO 0x1000 //bit12
#define LIRQ_NACK 0x2000 //bit13
#define LIRQ_BIT14 0x4000 //bit14
#define LIRQ_BIT15 0x8000 //bit15
#define LL_HW_IRQ_MASK 0x3FFF //total 14bit
// LL_HW_RFIFO_CTRL
#define LL_HW_IGN_EMP 0x0001 //bit0
#define LL_HW_IGN_CRC 0x0002 //bit1
#define LL_HW_IGN_SSN 0x0004 //bit2
#define LL_HW_IGN_ALL 0x0007 //bit2
#define LL_HW_IGN_NONE 0x0000
// LL_MD_RX_INI
#define LL_HW_MD_RX_SET0 0x4000 //set md_rx ini=0 and md_rx_soft=0
#define LL_HW_MD_RX_SET1 0x4440 //set md_rx ini=1 and md_rx_soft=1
//LL FIFO DEPTH CONFIG
#define LL_HW_FIFO_TX_2K_RX_2K 0x0200 //TX FIFO 512 Word
#define LL_HW_FIFO_TX_3K_RX_1K 0x0300 //TX FIFO 768 Word
#define LL_HW_FIFO_TX_1K_RX_3K 0x0100 //TX FIFO 256 Word
//BB CRC Format Setting
#define LL_HW_CRC_BLE_FMT 0x02
#define LL_HW_CRC_ZB_FMT 0x03
#define LL_HW_CRC_16_FMT 0x04
#define LL_HW_CRC_NULL 0x00
//ANT SWITCH SLOT
#define LL_HW_ANT_WIN_1us 4
#define LL_HW_ANT_SW_CTE_OFF 0x00
#define LL_HW_ANT_SW_CTE_AUTO 0x01
#define LL_HW_ANT_SW_TX_MANU 0x02
#define LL_HW_ANT_SW_RX_MANU 0x04
//CTE Supplement Config
#define CTE_SUPP_AUTO 0xC0
#define CTE_SUPP_LEN_SET 0x00
#define CTE_SUPP_NULL 0x00
#define CONNLESS_CTE_TYPE_AOA 0x00
#define CONNLESS_CTE_TYPE_AOD_1us 0x01
#define CONNLESS_CTE_TYPE_AOD_2us 0x02
#define CONN_CTE_TYPE_AOA 0x01
#define CONN_CTE_TYPE_AOD_1us 0x02
#define CONN_CTE_TYPE_AOD_2us 0x04
// 2020-01-21 add for CONN CTE REQ TYPE
#define CTE_REQ_TYPE_AOA 0x00
#define CTE_REQ_TYPE_AOD_1US 0x01
#define CTE_REQ_TYPE_AOD_2US 0x02
#define BLE_HEAD_WITH_CTE(x) (((x & 0x20)==0x00) ? 0:1)
void ll_hw_set_stx(void);
void ll_hw_set_srx(void);
void ll_hw_set_trx(void);
void ll_hw_set_rtx(void);
void ll_hw_set_trlp(uint8_t snNesn,uint8_t txPktNum,uint8_t rxPktNum,uint8_t mdRx);
void ll_hw_set_rtlp(uint8_t snNesn,uint8_t txPktNum,uint8_t rxPktNum,uint8_t mdRx,uint32_t rdCntIni);
void ll_hw_set_rtlp_1st(uint8_t snNesn,uint8_t txPktNum,uint8_t rxPktNum,uint8_t mdRx);
void ll_hw_config(uint8_t ll_mode,uint8_t snNesn,uint8_t txPktNum,uint8_t rxPktNum,uint8_t mdRx,uint32_t rdCntIni);
void ll_hw_go(void);
void ll_hw_trigger(void);
void ll_hw_clr_irq(void);
void ll_hw_set_irq(uint32_t mask);
void ll_hw_set_empty_head(uint16_t txHeader);
void ll_hw_set_rx_timeout_1st(uint32_t rxTimeOut);
void ll_hw_set_rx_timeout(uint32_t rxTimeOut);
void ll_hw_set_tx_rx_release(uint16_t txTime,uint16_t rxTime);
void ll_hw_set_rx_tx_interval(uint32_t intvTime);
void ll_hw_set_tx_rx_interval(uint32_t intvTime);
void ll_hw_set_trx_settle(uint8_t tmBb,uint8_t tmAfe,uint8_t tmPll);
void ll_hw_set_loop_timeout(uint32_t loopTimeOut);
void ll_hw_set_loop_nack_num(uint8_t nAckNum);
void ll_hw_set_timing(uint8_t pktFmt);
void ll_hw_set_tfifo_space(uint16 space);
void ll_hw_set_ant_switch_mode(uint8_t mode);
void ll_hw_set_ant_switch_timing(uint8_t antWin,uint8_t antDly);
void ll_hw_set_ant_pattern(uint32_t ant1, uint32_t ant0);
void ll_hw_set_cte_rxSupp(uint8_t rxSupp);
void ll_hw_set_cte_txSupp(uint8_t txSupp);
uint8_t ll_hw_get_iq_RawSample(uint16_t* p_iSample, uint16_t* p_qSample);
void ll_hw_rst_rfifo(void);
void ll_hw_rst_tfifo(void);
void ll_hw_ign_rfifo(uint8_t ignCtrl);
void ll_hw_get_tfifo_info(int* rdPtr,int* wrPtr,int* wrDepth);
void ll_hw_get_rfifo_info(int* rdPtr,int* wrPtr,int* rdDepth);
void ll_hw_get_rxPkt_stats(uint8_t* crcErrNum,uint8_t* rxTotalNum,uint8_t* rxPktNum);
uint8_t ll_hw_read_rfifo(uint8_t* rxPkt, uint16_t* pktLen, uint32_t* pktFoot0, uint32_t* pktFoot1);
uint8_t ll_hw_read_rfifo_zb(uint8_t* rxPkt, uint16_t* pktLen, uint32_t* pktFoot0, uint32_t* pktFoot1);
uint8_t ll_hw_read_rfifo_pplus(uint8_t* rxPkt, uint16_t* pktLen, uint32_t* pktFoot0, uint32_t* pktFoot1);
uint8_t ll_hw_write_tfifo(uint8_t* rxPkt, uint16_t pktLen);
void ll_hw_set_crc_fmt(uint8_t txCrc,uint8_t rxCrc);
void ll_hw_set_pplus_pktfmt(uint8_t plen);
uint8_t ll_hw_get_snNesn(void);
uint8_t ll_hw_get_txAck(void);
uint8_t ll_hw_get_nAck(void);
uint8_t ll_hw_get_rxPkt_num(void);
uint32_t ll_hw_get_anchor(void);
uint32_t ll_hw_get_irq_status(void);
uint8_t ll_hw_get_fsm_status(void);
uint8_t ll_hw_get_last_ack(void);
uint32_t ll_hw_get_loop_cycle(void);
uint8_t ll_hw_get_rxPkt_Total_num(void);
uint8_t ll_hw_get_rxPkt_CrcErr_num(void);
uint8_t ll_hw_get_rxPkt_CrcOk_num(void);
uint8_t ll_hw_get_iq_RawSample(uint16_t* p_iSample, uint16_t* p_qSample);
uint8_t ll_hw_update_rtlp_mode(uint8_t llMode);
uint8_t ll_hw_update_trlp_mode(uint8_t llMode);
uint8_t ll_hw_update(uint8_t llMode,uint8_t* txAck,uint8_t* rxRec,uint8_t* snNesn);
void byte_to_bit(uint8_t byteIn,uint8_t* bitOut);
void bit_to_byte(uint8_t* bitIn,uint8_t* byteOut);
void zigbee_crc16_gen(uint8_t* dataIn,int length,uint8_t* seed,uint8_t* crcCode);
// copy from rf.h by Zeng jiaping
void set_tx_rx_mode(uint8_t mode);
void set_channel(uint32_t channel);
void set_access_address( uint32_t access);
void set_crc_seed(uint32_t seed);
void set_whiten_seed(uint32_t channel);
void set_max_length(uint32_t length);
void calculate_whiten_seed(void);
#endif
@@ -0,0 +1,124 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
#ifndef LL_SLEEP__H_
#define LL_SLEEP__H_
#include "OSAL_PwrMgr.h"
#include "ll_def.h"
#include "ll_common.h"
/*******************************************************************************
MACROS
*/
// convert 625us units to 32kHz units without round: the ratio of 32 kHz ticks
// to 625 usec ticks is 32768/1600 = 20.48 or 512/25
#define LL_SLEEP_625US_TO_32KHZ( us ) ((((uint32) (us)) * 512) / 25)
// convert 31.25ns units to 32kHz units without round: the ratio of 31.25ns usec
// ticks to 32 kHz ticks is 32M/32768 = 976.5625 or 15625/16, but using 976 is
// close enough given the accuracy
#define LL_SLEEP_31_25NS_TO_32KHZ( ns ) (((uint32) (ns)) / 976)
// 32KHz timer:
// crystal: 32768Hz
// RC : 32768Hz Should be same as Xtal
// timer1 - 4 : 4MHz
#define TIMER_TO_32K_CRYSTAL 122 // 122.0703
#define TIMER_TO_32K_RC 122 // 125
#define STD_RC32_8_CYCLE_16MHZ_CYCLE 3906 // standard 16Mhz cycles for 8 RC32KHz tick
#define STD_CRY32_8_CYCLE_16MHZ_CYCLE 3906 // standard 16Mhz cycles for 8 crystal 32KHz tick
#define ERR_THD_RC32_CYCLE 200 // error threshold for N+x rcosc tracking cycle
#define CRY32_8_CYCLE_16MHZ_CYCLE_MAX (3906 + 196) // tracking value range std +/- 5%
#define CRY32_8_CYCLE_16MHZ_CYCLE_MIN (3906 - 196)
#define STD_RC32_16_CYCLE_16MHZ_CYCLE (7812) // standard 16Mhz cycles for 16 RC32KHz tick
#define STD_CRY32_16_CYCLE_16MHZ_CYCLE (7812) // standard 16Mhz cycles for 16 crystal 32KHz tick
#define CRY32_16_CYCLE_16MHZ_CYCLE_MAX (7812 + 391) // tracking value range std +/- 5%
#define CRY32_16_CYCLE_16MHZ_CYCLE_MIN (7812 - 391)
#define SLEEP_MAGIC 0x032141B6
/*******************************************************************************
TYPEDEFS
*/
typedef enum
{
MCU_SLEEP_MODE,
SYSTEM_SLEEP_MODE,
SYSTEM_OFF_MODE
} Sleep_Mode;
/*******************************************************************************
Functions
*/
// is sleep allow
uint8 isSleepAllow(void);
void enableSleep(void);
void disableSleep(void);
void setSleepMode(Sleep_Mode mode);
Sleep_Mode getSleepMode(void);
void enterSleepProcess(uint32 time);
void wakeupProcess(void);
void set_sleep_flag(int flag);
unsigned int get_sleep_flag(void);
void config_RTC(uint32 time);
void enter_sleep_off_mode(Sleep_Mode mode);
#endif // LL_SLEEP__H_
File diff suppressed because it is too large Load Diff
+109
View File
@@ -0,0 +1,109 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/*******************************************************************************
Filename: hci_c_data.h
Revised: $Date: 2011-08-22 08:41:40 -0700 (Mon, 22 Aug 2011) $
Revision: $Revision: 27235 $
Description: This file handles HCI data for the BLE Controller.
*******************************************************************************/
#ifndef HCI_C_DATA_H
#define HCI_C_DATA_H
#ifdef __cplusplus
extern "C"
{
#endif
/*******************************************************************************
INCLUDES
*/
/*******************************************************************************
MACROS
*/
/*******************************************************************************
CONSTANTS
*/
/*******************************************************************************
TYPEDEFS
*/
/*******************************************************************************
LOCAL VARIABLES
*/
/*******************************************************************************
GLOBAL VARIABLES
*/
/*
** HCI Data API
*/
/*******************************************************************************
@fn HCI_ReverseBytes
@brief This function is used to reverse the order of the bytes in
an array in place.
input parameters
@param *buf - Pointer to buffer containing bytes to be reversed.
@param len - Number of bytes in buffer.
Note: The length must be even.
Note: The maximum length is 128 bytes.
output parameters
@param None.
@return None.
*/
extern void HCI_ReverseBytes( uint8* buf,
uint8 len );
#ifdef __cplusplus
}
#endif
#endif /* HCI_C_DATA_H */
+303
View File
@@ -0,0 +1,303 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/*******************************************************************************
Filename: hci_c_event.h
Revised: $Date: 2012-05-01 12:13:50 -0700 (Tue, 01 May 2012) $
Revision: $Revision: 30418 $
Description: This file contains the HCI Event types, contants,
external functions etc. for the BLE Controller.
*******************************************************************************/
#ifndef HCI_C_EVENT_H
#define HCI_C_EVENT_H
#ifdef __cplusplus
extern "C"
{
#endif
/*******************************************************************************
INCLUDES
*/
#include "hci_tl.h"
extern uint32 bleEvtMask;
extern uint8 pHciEvtMask[];
/*******************************************************************************
MACROS
*/
/*******************************************************************************
CONSTANTS
*/
// Event Mask Default Values
#define BT_EVT_MASK_BYTE0 0xFF
#define BT_EVT_MASK_BYTE1 0xFF
#define BT_EVT_MASK_BYTE2 0xFF
#define BT_EVT_MASK_BYTE3 0xFF
#define BT_EVT_MASK_BYTE4 0xFF
#define BT_EVT_MASK_BYTE5 0x9F
#define BT_EVT_MASK_BYTE6 0x00
#define BT_EVT_MASK_BYTE7 0x20
//
#define LE_EVT_MASK_DEFAULT 0x00005F
/*******************************************************************************
TYPEDEFS
*/
/*******************************************************************************
LOCAL VARIABLES
*/
/*******************************************************************************
GLOBAL VARIABLES
*/
/*
** Internal Functions
*/
extern void hciInitEventMasks( void );
/*
** HCI Controller Events
*/
/*******************************************************************************
@fn HCI_DataBufferOverflowEvent
@brief This function sends the Data Buffer Overflow Event to the Host.
input parameters
@param linkType - HCI_LINK_TYPE_SCO_BUFFER_OVERFLOW,
HCI_LINK_TYPE_ACL_BUFFER_OVERFLOW
output parameters
@param None.
@return None.
*/
extern void HCI_DataBufferOverflowEvent( uint8 linkType );
/*******************************************************************************
@fn HCI_NumOfCompletedPacketsEvent
@brief This function sends the Number of Completed Packets Event to
the Host.
Note: Currently, the number of handles is always one.
input parameters
@param numHandles - Number of handles.
@param handlers - Array of connection handles.
@param numCompletedPkts - Array of number of completed packets for
each handle.
output parameters
@param None.
@return None.
*/
extern void HCI_NumOfCompletedPacketsEvent( uint8 numHandles,
uint16* handlers,
uint16* numCompletedPackets );
/*******************************************************************************
@fn HCI_CommandCompleteEvent
@brief This function sends a Command Complete Event to the Host.
input parameters
@param opcode - The opcode of the command that generated this event.
@param numParam - The number of parameters in the event.
@param param - The event parameters associated with the command.
output parameters
@param None.
@return None.
*/
extern void HCI_CommandCompleteEvent( uint16 opcode,
uint8 numParam,
uint8* param );
/*******************************************************************************
@fn HCI_VendorSpecifcCommandCompleteEvent
@brief This function sends a Vendor Specific Command Complete Event to
the Host.
input parameters
@param opcode - The opcode of the command that generated this event.
@param numParam - The number of parameters in the event.
@param param - The event parameters associated with the command.
output parameters
@param None.
@return None.
*/
extern void HCI_VendorSpecifcCommandCompleteEvent( uint16 opcode,
uint8 len,
uint8* param );
/*******************************************************************************
@fn HCI_CommandStatusEvent
@brief This function sends a Command Status Event to the Host.
input parameters
@param status - The resulting status of the comamnd.
@param opcode - The opcode of the command that generated this event.
output parameters
@param None.
@return None.
*/
extern void HCI_CommandStatusEvent( uint8 status,
uint16 opcode );
/*******************************************************************************
@fn HCI_HardwareErrorEvent
@brief This function sends a Hardware Error Event to the Host.
input parameters
@param hwErrorCode - The hardware error code.
output parameters
@param None.
@return None.
*/
extern void HCI_HardwareErrorEvent( uint8 hwErrorCode );
/*******************************************************************************
@fn HCI_SendCommandStatusEvent
@brief This generic function sends a Command Status event to the Host.
It is provided as a direct call so the Host can use it directly.
input parameters
@param eventCode - The event code.
@param status - The resulting status of the comamnd.
@param opcode - The opcode of the command that generated this event.
output parameters
@param None.
@return None.
*/
extern void HCI_SendCommandStatusEvent ( uint8 eventCode,
uint16 status,
uint16 opcode );
/*******************************************************************************
@fn HCI_SendCommandCompleteEvent
@brief This generic function sends a Command Complete or a Vendor
Specific Command Complete Event to the Host.
input parameters
@param eventCode - The event code.
@param opcode - The opcode of the command that generated this event.
@param numParam - The number of parameters in the event.
@param param - The event parameters associated with the command.
output parameters
@param None.
@return None.
*/
extern void HCI_SendCommandCompleteEvent ( uint8 eventCode,
uint16 opcode,
uint8 numParam,
uint8* param );
/*******************************************************************************
@fn HCI_SendControllerToHostEvent
@brief This generic function sends a Controller to Host Event.
input parameters
@param eventCode - Bluetooth event code.
@param dataLen - Length of dataField.
@param pData - Pointer to data.
output parameters
@param None.
@return None.
*/
extern void HCI_SendControllerToHostEvent( uint8 eventCode,
uint8 dataLen,
uint8* pData );
#ifdef __cplusplus
}
#endif
#endif /* HCI_C_EVENT_H */
+91
View File
@@ -0,0 +1,91 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/*************************************************************************************************
**************************************************************************************************/
#ifndef HCI_HOST_H
#define HCI_HOST_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
INCLUDES
*/
#include "OSAL.h"
#include "osal_bufmgr.h"
#include "hci.h"
#include "hci_task.h"
/*********************************************************************
MACROS
*/
/*********************************************************************
CONSTANTS
*/
/* HCI packet header length */
#define HCI_EVT_HEADER_LEN 3 /* packet type + evt code(1) + len(1) */
#define HCI_DATA_HEADER_LEN 5 /* packet type + connection handle(2) + len(2) */
/* First 12 bits of the HCI data packet is connection handle */
#define HCI_CONNECTION_HANDLE_MASK 0x0FFF
#define HCI_PB_MASK 0x03
/*********************************************************************
TYPEDEFS
*/
/*********************************************************************
GLOBAL VARIABLES
*/
/*********************************************************************
FUNCTIONS - API
*/
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* HCI_HOST_H */
+116
View File
@@ -0,0 +1,116 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/*************************************************************************************************
**************************************************************************************************/
#ifndef HCI_TASK_H
#define HCI_TASK_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
INCLUDES
*/
#include "OSAL.h"
#include "hci.h"
#include "uart.h"
#include "hci_host.h"
#include "hal.h" // added by ZJP
/*********************************************************************
MACROS
*/
/*********************************************************************
CONSTANTS
*/
/* UART port */
#define HCI_UART_PORT HAL_UART_PORT_0
#define HCI_UART_BR HAL_UART_BR_38400
#define HCI_UART_FC TRUE
#define HCI_UART_FC_THRESHOLD 48
#define HCI_UART_RX_BUF_SIZE 128
#define HCI_UART_TX_BUF_SIZE 128
#define HCI_UART_IDLE_TIMEOUT 6
#define HCI_UART_INT_ENABLE TRUE
/* HCI Event List */
#define HCI_EVENT_SEND_DATA 0x01
#define HCI_EVENT_SEND_CMD 0x02
#define HCI_HOST_PARSE_EVT 0x04
#define HCI_HOST_INCOMING_EVT 0x08
#define HCI_HOST_INCOMING_DATA 0x10
/* Define the osal queue size for data and cmd */
#define HCI_HOST_MAX_DATAQUEUE_SIZE 20
#define HCI_HOST_MAX_CMDQUEUE_SIZE 20
/*********************************************************************
TYPEDEFS
*/
/*********************************************************************
GLOBAL VARIABLES
*/
osal_msg_q_t HCI_HostDataQueue;
uint8 hciHostNumQueuedData; /* Number of data packets queued */
const uint8 hciHostMaxNumDataQueue; /* Max number of data packets queued */
/*********************************************************************
FUNCTIONS - API
*/
extern Status_t HCI_AddDataQueue( void* buf );
extern Status_t HCI_AddCmdQueue( void* buf );
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* HCI_TASK_H */
+430
View File
@@ -0,0 +1,430 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/*******************************************************************************
Filename: hci_tl.h
Revised: $Date: 2012-04-20 15:24:45 -0700 (Fri, 20 Apr 2012) $
Revision: $Revision: 30292 $
Description: This file contains the types, contants, external functions
etc. for the BLE HCI Transport Layer.
*******************************************************************************/
#ifndef HCI_TL_H
#define HCI_TL_H
#ifdef __cplusplus
extern "C"
{
#endif
/*******************************************************************************
INCLUDES
*/
#include "hci.h"
#include "OSAL.h"
#include "uart.h"
#include "hci_data.h"
#include "hci_event.h"
extern uint8 hciTaskID;
//
extern uint8 hciTestTaskID;
extern uint8 hciGapTaskID;
extern uint8 hciL2capTaskID;
extern uint8 hciSmpTaskID;
/*******************************************************************************
MACROS
*/
#define HCI_ASSERT(condition) HAL_ASSERT(condition)
/*******************************************************************************
CONSTANTS
*/
// OSAL Task Events
#define HCI_TX_PROCESS_EVENT 0x0001
#define HCI_TEST_UART_SEND_EVENT 0x0002
#define HCI_BDADDR_UPDATED_EVENT 0x4000
#define HCI_OSAL_MSG_EVENT SYS_EVENT_MSG
// OSAL Message Header Events
#define HCI_CTRL_TO_HOST_EVENT 0x01
#define HCI_HOST_TO_CTRL_CMD_EVENT 0x02
#define HCI_HOST_TO_CTRL_DATA_EVENT 0x03
#define HCI_BDADDR_LEN 6
// Max Allowed HCI Packet
#define HCI_MAX_CMD_PKT_SIZE 0xFF
#define HCI_MAX_DATA_PKT_SIZE 0xFFFF
// Max Data Length in Packet
#define HCI_DATA_MAX_DATA_LENGTH 27
//
// Minimum length for CMD packet is 1+2+1
// | Packet Type (1) | OPCode(2) | Length(1) |
//
#define HCI_CMD_MIN_LENGTH 4
//
// Minimum length for EVENT packet is 1+1+1
// | Packet Type (1) | Event Code(1) | Length(1) |
//
#define HCI_EVENT_MIN_LENGTH 3
//
// Minimum length for DATA packet is 1+2+2
// | Packet Type (1) | Handler(2) | Length(2) |
//
#define HCI_DATA_MIN_LENGTH 5
// Max Number of Connections
#define HCI_MAX_NUM_CONNECTIONS 0x03
//
#define HCI_TX_DATA_ANY_CONNECTION 0xFF
// HCI Packet Types
#define HCI_CMD_PACKET 0x01
#define HCI_ACL_DATA_PACKET 0x02
#define HCI_SCO_DATA_PACKET 0x03
#define HCI_EVENT_PACKET 0x04
/*
** HCI Command Opcodes
*/
// Link Control Commands
#define HCI_DISCONNECT 0x0406
#define HCI_READ_REMOTE_VERSION_INFO 0x041D
// Controller and Baseband Commands
#define HCI_SET_EVENT_MASK 0x0C01
#define HCI_RESET 0x0C03
#define HCI_READ_TRANSMIT_POWER 0x0C2D
#define HCI_SET_CONTROLLER_TO_HOST_FLOW_CONTROL 0x0C31
#define HCI_HOST_BUFFER_SIZE 0x0C33
#define HCI_HOST_NUM_COMPLETED_PACKETS 0x0C35
// Information Parameters
#define HCI_READ_LOCAL_VERSION_INFO 0x1001
#define HCI_READ_LOCAL_SUPPORTED_COMMANDS 0x1002
#define HCI_READ_LOCAL_SUPPORTED_FEATURES 0x1003
#define HCI_READ_BDADDR 0x1009
// Status Parameters
#define HCI_READ_RSSI 0x1405
// LE Commands
#define HCI_LE_SET_EVENT_MASK 0x2001
#define HCI_LE_READ_BUFFER_SIZE 0x2002
#define HCI_LE_READ_LOCAL_SUPPORTED_FEATURES 0x2003
#define HCI_LE_SET_RANDOM_ADDR 0x2005
#define HCI_LE_SET_ADV_PARAM 0x2006
#define HCI_LE_READ_ADV_CHANNEL_TX_POWER 0x2007
#define HCI_LE_SET_ADV_DATA 0x2008
#define HCI_LE_SET_SCAN_RSP_DATA 0x2009
#define HCI_LE_SET_ADV_ENABLE 0x200A
#define HCI_LE_SET_SCAN_PARAM 0x200B
#define HCI_LE_SET_SCAN_ENABLE 0x200C
#define HCI_LE_CREATE_CONNECTION 0x200D
#define HCI_LE_CREATE_CONNECTION_CANCEL 0x200E
#define HCI_LE_READ_WHITE_LIST_SIZE 0x200F
#define HCI_LE_CLEAR_WHITE_LIST 0x2010
#define HCI_LE_ADD_WHITE_LIST 0x2011
#define HCI_LE_REMOVE_WHITE_LIST 0x2012
#define HCI_LE_CONNECTION_UPDATE 0x2013
#define HCI_LE_SET_HOST_CHANNEL_CLASSIFICATION 0x2014
#define HCI_LE_READ_CHANNEL_MAP 0x2015
#define HCI_LE_READ_REMOTE_USED_FEATURES 0x2016
#define HCI_LE_ENCRYPT 0x2017
#define HCI_LE_RAND 0x2018
#define HCI_LE_START_ENCRYPTION 0x2019
#define HCI_LE_LTK_REQ_REPLY 0x201A
#define HCI_LE_LTK_REQ_NEG_REPLY 0x201B
#define HCI_LE_READ_SUPPORTED_STATES 0x201C
#define HCI_LE_RECEIVER_TEST 0x201D
#define HCI_LE_TRANSMITTER_TEST 0x201E
#define HCI_LE_TEST_END 0x201F
#define HCI_LE_SET_DATA_LENGTH 0x2022
#define HCI_LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH 0x2023
#define HCI_LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH 0x2024
// 0x2025, 0x2026 for P256 & DHkey
#define HCI_LE_ADD_DEVICE_TO_RESOLVING_LIST 0x2027
#define HCI_LE_REMOVE_DEVICE_FROM_RESOLVING_LIST 0x2028
#define HCI_LE_CLEAR_RESOLVING_LIST 0x2029
#define HCI_LE_READ_RESOLVING_LIST_SIZE 0x202A
#define HCI_LE_READ_PEER_RESOLVABLE_ADDRESS 0x202B // optional
#define HCI_LE_READ_LOCAL_RESOLVABLE_ADDRESS 0x202C // optional
#define HCI_LE_SET_ADDRESS_RESOLUTION_ENABLE 0x202D
#define HCI_LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TO 0x202E
#define HCI_LE_READ_MAXIMUM_DATA_LENGTH 0x202F
#define HCI_LE_READ_PHY 0x2030
#define HCI_LE_SET_DEFAULT_PHY 0x2031
#define HCI_LE_SET_PHY 0x2032
#define HCI_LE_SET_ADVERTISING_SET_RANDOM_ADDRESS 0x2035
#define HCI_LE_SET_EXTENDER_ADVERTISING_PARAMETERS 0x2036
#define HCI_LE_SET_EXTENDED_ADVERTISING_DATA 0x2037
#define HCI_LE_Set_EXTENDED_SCAN_RESPONSE_DATA 0x2038
#define HCI_LE_Set_EXTENDED_ADVERTISING_ENABLE 0x2039
#define HCI_LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH 0x203A
#define HCI_LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS 0x203B
#define HCI_LE_REMOVE_ADVERTISING_SET 0x203C
#define HCI_LE_CLEAR_ADVERTISING_SETS 0x203D
#define HCI_LE_SET_PERIODIC_ADVERTISING_PARAMETERS 0x203E
#define HCI_LE_SET_PERIODIC_ADVERTISING_DATA 0x203F
#define HCI_LE_Set_PERIODIC_ADVERTISING_ENABLE 0x2040
#define HCI_LE_SET_EXTENDED_SCAN_PARAMETERS 0x2041
#define HCI_LE_SET_EXTENDED_SCAN_ENABLE 0x2042
#define HCI_LE_EXTENDED_CREATE_CONNECTION 0x2043
#define HCI_LE_PERIODIC_ADVERTISING_CREATE_SYNC 0x2044
#define HCI_LE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL 0x2045
#define HCI_LE_PERIODIC_ADVERTISING_TERMINATE_SYNC 0x2046
#define HCI_LE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST 0x2047
#define HCI_LE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST 0x2048
#define HCI_LE_CLEAR_PERIODIC_ADVERTISER_LIST 0x2049
#define HCI_LE_READ_PERIODIC_ADVERTISER_LIST_SIZE 0x204A
/* Power config */
#define HCI_LE_READ_TRANSMIT_POWER 0x204B
#define HCI_LE_READ_RF_PATH_COMPENSATION 0x204C
#define HCI_LE_WRITE_RF_PATH_COMPENSATION 0x204D
/* privacy mode */
#define HCI_LE_SET_PRIVACY_MODE 0x204E
/* CTE */
#define HCI_LE_SET_CONNLESS_CTE_TRANS_PARAMETER 0x2051
#define HCI_LE_SET_CONNLESS_CTE_TRANS_ENABLE 0x2052
#define HCI_LE_SET_CONNLESS_IQ_SAMPLE_ENABLE 0x2053
#define HCI_LE_SET_CONNCTE_RECV_PARAMETER 0x2054
#define HCI_LE_SET_CONN_CTE_TRANSMIT_PARAMETER 0x2055
#define HCI_LE_CONN_CTE_REQUEST_ENABLE 0x2056
#define HCI_LE_CONN_CTE_RESPONSE_ENABLE 0x2057
#define HCI_LE_READ_ANTENNA_INFO 0x2058
// LE Vendor Specific LL Extension Commands
#define HCI_EXT_SET_RX_GAIN 0xFC00
#define HCI_EXT_SET_TX_POWER 0xFC01
#define HCI_EXT_ONE_PKT_PER_EVT 0xFC02
#define HCI_EXT_CLK_DIVIDE_ON_HALT 0xFC03
#define HCI_EXT_DECLARE_NV_USAGE 0xFC04
#define HCI_EXT_DECRYPT 0xFC05
#define HCI_EXT_SET_LOCAL_SUPPORTED_FEATURES 0xFC06
#define HCI_EXT_SET_FAST_TX_RESP_TIME 0xFC07
#define HCI_EXT_MODEM_TEST_TX 0xFC08
#define HCI_EXT_MODEM_HOP_TEST_TX 0xFC09
#define HCI_EXT_MODEM_TEST_RX 0xFC0A
#define HCI_EXT_END_MODEM_TEST 0xFC0B
#define HCI_EXT_SET_BDADDR 0xFC0C
#define HCI_EXT_SET_SCA 0xFC0D
#define HCI_EXT_ENABLE_PTM 0xFC0E // Not a supported HCI command! Application only.
#define HCI_EXT_SET_FREQ_TUNE 0xFC0F
#define HCI_EXT_SAVE_FREQ_TUNE 0xFC10
#define HCI_EXT_SET_MAX_DTM_TX_POWER 0xFC11
#define HCI_EXT_MAP_PM_IO_PORT 0xFC12
#define HCI_EXT_DISCONNECT_IMMED 0xFC13
#define HCI_EXT_PER 0xFC14
#define HCI_EXT_PER_BY_CHAN 0xFC15 // Not a supported HCI command! Application only.
#define HCI_EXT_EXTEND_RF_RANGE 0xFC16
#define HCI_EXT_ADV_EVENT_NOTICE 0xFC17 // Not a supported HCI command! Application only.
#define HCI_EXT_CONN_EVENT_NOTICE 0xFC18 // Not a supported HCI command! Application only.
#define HCI_EXT_HALT_DURING_RF 0xFC19
#define HCI_EXT_OVERRIDE_SL 0xFC1A
#define HCI_EXT_BUILD_REVISION 0xFC1B
#define HCI_EXT_DELAY_SLEEP 0xFC1C
#define HCI_EXT_RESET_SYSTEM 0xFC1D
#define HCI_EXT_OVERLAPPED_PROCESSING 0xFC1E
#define HCI_EXT_NUM_COMPLETED_PKTS_LIMIT 0xFC1F
/*
** HCI Event Codes
*/
// BT Events
#define HCI_DISCONNECTION_COMPLETE_EVENT_CODE 0x05
#define HCI_ENCRYPTION_CHANGE_EVENT_CODE 0x08
#define HCI_READ_REMOTE_INFO_COMPLETE_EVENT_CODE 0x0C
#define HCI_COMMAND_COMPLETE_EVENT_CODE 0x0E
#define HCI_COMMAND_STATUS_EVENT_CODE 0x0F
#define HCI_BLE_HARDWARE_ERROR_EVENT_CODE 0x10
#define HCI_NUM_OF_COMPLETED_PACKETS_EVENT_CODE 0x13
#define HCI_DATA_BUFFER_OVERFLOW_EVENT 0x1A
#define HCI_KEY_REFRESH_COMPLETE_EVENT_CODE 0x30
// LE Event Code (for LE Meta Events)
#define HCI_LE_EVENT_CODE 0x3E
// LE Meta Event Codes
#define HCI_BLE_CONNECTION_COMPLETE_EVENT 0x01
#define HCI_BLE_ADV_REPORT_EVENT 0x02
#define HCI_BLE_CONN_UPDATE_COMPLETE_EVENT 0x03
#define HCI_BLE_READ_REMOTE_FEATURE_COMPLETE_EVENT 0x04
#define HCI_BLE_LTK_REQUESTED_EVENT 0x05
#define HCI_BLE_REMOTE_CONN_PARAMETER_REQUEST_EVENT 0X06
#define HCI_BLE_DATA_LENGTH_CHANGE_EVENT 0x07
#define HCI_BLE_READ_LOCAL_P256_PUB_KEY_COMPLETE_EVENT 0x08
#define HCI_BLE_GENERATE_DHKEY_COMPLETE_EVENT 0x09
#define HCI_BLE_ENHANCED_CONNECTION_COMPLETE_EVENT 0x0A
#define HCI_BLE_DIRECTED_ADVERTISING_REPORT_EVENT 0x0B
#define HCI_BLE_PHY_UPDATE_COMPLETE_EVENT 0x0C
#define HCI_BLE_EXT_ADV_REPORT_EVENT 0x0D
#define HCI_BLE_PERIODIC_ADV_SYNC_ESTABLISHED_EVENT 0x0E
#define HCI_BLE_PERIODIC_ADV_REPORT_EVENT 0x0F
#define HCI_BLE_PERIODIC_ADV_SYNC_LOST_EVENT 0x10
#define HCI_LE_ADVERTISING_SET_TERMINATED 0x12
#define HCI_LE_SCAN_REQUEST_RECEIVED 0x13
#define HCI_LE_CHANNEL_SELECTION_ALGORITHM_EVENT 0x14
//2020-01-14 AOA/AOD Report event
#define HCI_LE_CONNECTIONLESS_IQ_REPORT_EVENT 0x15
#define HCI_LE_CONNECTION_IQ_REPORT_EVENT 0x16
#define HCI_LE_CTE_REQUEST_FAILED_REPORT 0x17
// Vendor Specific Event Code
#define HCI_VE_EVENT_CODE 0xFF
// LE Vendor Specific LL Extension Events
#define HCI_EXT_SET_RX_GAIN_EVENT 0x0400
#define HCI_EXT_SET_TX_POWER_EVENT 0x0401
#define HCI_EXT_ONE_PKT_PER_EVT_EVENT 0x0402
#define HCI_EXT_CLK_DIVIDE_ON_HALT_EVENT 0x0403
#define HCI_EXT_DECLARE_NV_USAGE_EVENT 0x0404
#define HCI_EXT_DECRYPT_EVENT 0x0405
#define HCI_EXT_SET_LOCAL_SUPPORTED_FEATURES_EVENT 0x0406
#define HCI_EXT_SET_FAST_TX_RESP_TIME_EVENT 0x0407
#define HCI_EXT_MODEM_TEST_TX_EVENT 0x0408
#define HCI_EXT_MODEM_HOP_TEST_TX_EVENT 0x0409
#define HCI_EXT_MODEM_TEST_RX_EVENT 0x040A
#define HCI_EXT_END_MODEM_TEST_EVENT 0x040B
#define HCI_EXT_SET_BDADDR_EVENT 0x040C
#define HCI_EXT_SET_SCA_EVENT 0x040D
#define HCI_EXT_ENABLE_PTM_EVENT 0x040E // Not a supported HCI command! Application only.
#define HCI_EXT_SET_FREQ_TUNE_EVENT 0x040F
#define HCI_EXT_SAVE_FREQ_TUNE_EVENT 0x0410
#define HCI_EXT_SET_MAX_DTM_TX_POWER_EVENT 0x0411
#define HCI_EXT_MAP_PM_IO_PORT_EVENT 0x0412
#define HCI_EXT_DISCONNECT_IMMED_EVENT 0x0413
#define HCI_EXT_PER_EVENT 0x0414
#define HCI_EXT_PER_BY_CHAN_EVENT 0x0415 // Not a supported HCI command! Application only.
#define HCI_EXT_EXTEND_RF_RANGE_EVENT 0x0416
#define HCI_EXT_ADV_EVENT_NOTICE_EVENT 0x0417 // Not a supported HCI command! Application only.
#define HCI_EXT_CONN_EVENT_NOTICE_EVENT 0x0418 // Not a supported HCI command! Application only.
#define HCI_EXT_HALT_DURING_RF_EVENT 0x0419
#define HCI_EXT_OVERRIDE_SL_EVENT 0x041A
#define HCI_EXT_BUILD_REVISION_EVENT 0x041B
#define HCI_EXT_DELAY_SLEEP_EVENT 0x041C
#define HCI_EXT_RESET_SYSTEM_EVENT 0x041D
#define HCI_EXT_OVERLAPPED_PROCESSING_EVENT 0x041E
#define HCI_EXT_NUM_COMPLETED_PKTS_LIMIT_EVENT 0x041F
/*******************************************************************************
TYPEDEFS
*/
/*******************************************************************************
LOCAL VARIABLES
*/
/*******************************************************************************
GLOBAL VARIABLES
*/
/*
** HCI OSAL API
*/
/*******************************************************************************
@fn HCI_Init
@brief This is the HCI OSAL task initialization routine.
input parameters
@param taskID - The HCI OSAL task identifer.
output parameters
@param None.
@return None.
*/
extern void HCI_Init( uint8 taskID );
/*******************************************************************************
@fn HCI_ProcessEvent
@brief This is the HCI OSAL task process event handler.
input parameters
@param taskID - The HCI OSAL task identifer.
@param events - HCI OSAL task events.
output parameters
@param None.
@return Unprocessed events.
*/
extern uint16 HCI_ProcessEvent( uint8 task_id,
uint16 events );
#ifdef __cplusplus
}
#endif
#endif /* HCI_TL_H */
@@ -0,0 +1,91 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/**************************************************************************************************
**************************************************************************************************/
#ifndef ATT_INTERNAL_H
#define ATT_INTERNAL_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
INCLUDES
*/
#include "osal_cbTimer.h"
#include "l2cap.h"
#include "att.h"
/*********************************************************************
MACROS
*/
/*********************************************************************
CONSTANTS
*/
/*********************************************************************
TYPEDEFS
*/
// Function prototype to build an attribute protocol message
typedef uint16 (*attBuildMsg_t)( uint8* pBuf, uint8* pMsg );
/*********************************************************************
VARIABLES
*/
/*********************************************************************
FUNCTIONS
*/
extern uint16 attBuildExecuteWriteRsp( uint8* pBuf, uint8* pMsg );
extern uint16 attBuildHandleValueCfm( uint8* pBuf, uint8* pMsg );
extern bStatus_t attSendMsg( uint16 connHandle, attBuildMsg_t pfnBuildMsg,
uint8 opcode, uint8* pMsg );
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* ATT_INTERNAL_H */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,212 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/**************************************************************************************************
Filename: gapgattserver.h
Revised:
Revision:
Description: This file contains GAP GATT attribute definitions
and prototypes.
**************************************************************************************************/
#ifndef GAPGATTSERVER_H
#define GAPGATTSERVER_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
INCLUDES
*/
/*********************************************************************
CONSTANTS
*/
#define GAP_DEVICE_NAME_LEN (20+1)
// Privacy Flag States
#define GAP_PRIVACY_DISABLED 0x00
#define GAP_PRIVACY_ENABLED 0x01
// GAP GATT Server Parameters
#define GGS_DEVICE_NAME_ATT 0 // RW uint8[GAP_DEVICE_NAME_LEN]
#define GGS_APPEARANCE_ATT 1 // RW uint16
#define GGS_PERI_PRIVACY_FLAG_ATT 2 // RW uint8
#define GGS_RECONNCT_ADDR_ATT 3 // RW uint8[B_ADDR_LEN]
#define GGS_PERI_CONN_PARAM_ATT 4 // RW sizeof(gapPeriConnectParams_t)
#define GGS_PERI_PRIVACY_FLAG_PROPS 5 // RW uint8
#define GGS_W_PERMIT_DEVICE_NAME_ATT 6 // W uint8
#define GGS_W_PERMIT_APPEARANCE_ATT 7 // W uint8
#define GGS_W_PERMIT_PRIVACY_FLAG_ATT 8 // W uint8
// GAP Services bit fields
#define GAP_SERVICE 0x00000001
// Attribute ID used with application's callback when attribute value is changed OTA
#define GGS_DEVICE_NAME_ID 0
#define GGS_APPEARANCE_ID 1
#if defined ( TESTMODES )
// GGS TestModes
#define GGS_TESTMODE_OFF 0 // No Test mode
#define GGS_TESTMODE_W_PERMIT_DEVICE_NAME 1 // Make Device Name attribute writable
#define GGS_TESTMODE_W_PERMIT_APPEARANCE 2 // Make Appearance attribute writable
#define GGS_TESTMODE_W_PERMIT_PRIVACY_FLAG 3 // Make Peripheral Privacy Flag attribute writable with authentication
#endif // TESTMODES
/*********************************************************************
TYPEDEFS
*/
// Callback to notify when attribute value is changed over the air.
typedef void (*ggsAttrValueChange_t)( uint8 attrId );
// GAP GATT Server callback structure
typedef struct
{
ggsAttrValueChange_t pfnAttrValueChange; // When attribute value is changed OTA
} ggsAppCBs_t;
/*********************************************************************
MACROS
*/
/*********************************************************************
Profile Callbacks
*/
/*********************************************************************
API FUNCTIONS
*/
/**
@brief Set a GAP GATT Server parameter.
@param param - Profile parameter ID<BR>
@param len - length of data to right
@param value - pointer to data to write. This is dependent on
the parameter ID and WILL be cast to the appropriate
data type (example: data type of uint16 will be cast to
uint16 pointer).<BR>
@return bStatus_t
*/
extern bStatus_t GGS_SetParameter( uint8 param, uint8 len, void* value );
/**
@brief Get a GAP GATT Server parameter.
@param param - Profile parameter ID<BR>
@param value - pointer to data to put. This is dependent on
the parameter ID and WILL be cast to the appropriate
data type (example: data type of uint16 will be cast to
uint16 pointer).<BR>
@return bStatus_t
*/
extern bStatus_t GGS_GetParameter( uint8 param, void* value );
/**
@brief Add function for the GAP GATT Service.
@param services - services to add. This is a bit map and can
contain more than one service.
@return SUCCESS: Service added successfully.<BR>
INVALIDPARAMETER: Invalid service field.<BR>
FAILURE: Not enough attribute handles available.<BR>
bleMemAllocError: Memory allocation error occurred.<BR>
*/
extern bStatus_t GGS_AddService( uint32 services );
/**
@brief Delete function for the GAP GATT Service.
@param services - services to delete. This is a bit map and can
contain more than one service.
@return SUCCESS: Service deleted successfully.<BR>
FAILURE: Service not found.<BR>
*/
extern bStatus_t GGS_DelService( uint32 services );
/**
@brief Registers the application callback function.
Note: Callback registration is needed only when the
Device Name is made writable. The application
will be notified when the Device Name is changed
over the air.
@param appCallbacks - pointer to application callbacks.
@return none
*/
extern void GGS_RegisterAppCBs( ggsAppCBs_t* appCallbacks );
/**
@brief Set a GGS Parameter value. Use this function to change
the default GGS parameter values.
@param value - new GGS param value
@return void
*/
extern void GGS_SetParamValue( uint16 value );
/**
@brief Get a GGS Parameter value.
@param none
@return GGS Parameter value
*/
extern uint16 GGS_GetParamValue( void );
/*********************************************************************
TASK FUNCTIONS - Don't call these. These are system functions.
*/
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* GAPGATTSERVER_H */
@@ -0,0 +1,115 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/**************************************************************************************************
**************************************************************************************************/
#ifndef GATT_INTERNAL_H
#define GATT_INTERNAL_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
INCLUDES
*/
#include "osal_cbTimer.h"
#include "att.h"
#include "gatt.h"
/*********************************************************************
MACROS
*/
#define TIMER_VALID( id ) ( ( (id) != INVALID_TIMER_ID ) && \
( (id) != TIMEOUT_TIMER_ID ) )
#define TIMER_STATUS( id ) ( (id) == TIMEOUT_TIMER_ID ? bleTimeout : \
(id) == INVALID_TIMER_ID ? SUCCESS : blePending )
/*********************************************************************
CONSTANTS
*/
/*********************************************************************
TYPEDEFS
*/
// Srtucture for Attribute Version Information attribute
typedef struct
{
uint8 attVersion; // Attribute Protocol Version
uint8 gattVersion; // Generic Attribute Profile Version
uint16 manufacturerName; // Manufacturer Name
} gattVersionInfo_t;
// Function prototype to parse an attribute protocol request message
typedef bStatus_t (*gattParseReq_t)( uint8 sig, uint8 cmd, uint8* pParams, uint16 len, attMsg_t* pMsg );
// Function prototype to parse an attribute protocol response message
typedef bStatus_t (*gattParseRsp_t)( uint8* pParams, uint16 len, attMsg_t* pMsg );
// Function prototype to process an attribute protocol message
typedef bStatus_t (*gattProcessMsg_t)( uint16 connHandle, attPacket_t* pPkt );
// Function prototype to process an attribute protocol request message
typedef bStatus_t (*gattProcessReq_t)( uint16 connHandle, attMsg_t* pMsg );
/*********************************************************************
VARIABLES
*/
extern uint8 gattTaskID;
/*********************************************************************
FUNCTIONS
*/
extern void gattRegisterServer( gattProcessMsg_t pfnProcessMsg );
extern void gattRegisterClient( gattProcessMsg_t pfnProcessMsg );
extern bStatus_t gattNotifyEvent( uint8 taskId, uint16 connHandle, uint8 status,
uint8 method, gattMsg_t* pMsg );
extern void gattStartTimer( pfnCbTimer_t pfnCbTimer, uint8* pData,
uint16 timeout, uint8* pTimerId );
extern void gattStopTimer( uint8* pTimerId );
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* GATT_INTERNAL_H */
@@ -0,0 +1,265 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/**************************************************************************************************
Filename: gatt_profile_uuid.h
Revised:
Revision:
Description: This file contains GATT Profile UUID types.
**************************************************************************************************/
#ifndef GATT_PROFILE_UUID_H
#define GATT_PROFILE_UUID_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
INCLUDES
*/
/*********************************************************************
CONSTANTS
*/
/*
WARNING: The 16-bit UUIDs are assigned by the Bluetooth SIG and published
in the Bluetooth Assigned Numbers page. Do not change these values.
Changing them will cause Bluetooth interoperability issues.
*/
/**
GATT Service UUIDs
*/
#define IMMEDIATE_ALERT_SERV_UUID 0x1802 // Immediate Alert
#define LINK_LOSS_SERV_UUID 0x1803 // Link Loss
#define TX_PWR_LEVEL_SERV_UUID 0x1804 // Tx Power
#define CURRENT_TIME_SERV_UUID 0x1805 // Current Time Service
#define REF_TIME_UPDATE_SERV_UUID 0x1806 // Reference Time Update Service
#define NEXT_DST_CHANGE_SERV_UUID 0x1807 // Next DST Change Service
#define GLUCOSE_SERV_UUID 0x1808 // Glucose
#define THERMOMETER_SERV_UUID 0x1809 // Health Thermometer
#define DEVINFO_SERV_UUID 0x180A // Device Information
#define NWA_SERV_UUID 0x180B // Network Availability
#define HEARTRATE_SERV_UUID 0x180D // Heart Rate
#define PHONE_ALERT_STS_SERV_UUID 0x180E // Phone Alert Status Service
#define BATT_SERV_UUID 0x180F // Battery Service
#define BLOODPRESSURE_SERV_UUID 0x1810 // Blood Pressure
#define ALERT_NOTIF_SERV_UUID 0x1811 // Alert Notification Service
#define HID_SERV_UUID 0x1812 // Human Interface Device
#define SCAN_PARAM_SERV_UUID 0x1813 // Scan Parameters
#define RSC_SERV_UUID 0x1814 // Running Speed and Cadence
#define CSC_SERV_UUID 0x1816 // Cycling Speed and Cadence
#define CYCPWR_SERV_UUID 0x1818 // Cycling Power
#define LOC_NAV_SERV_UUID 0x1819 // Location and Navigation
/**
GATT Characteristic UUIDs
*/
#define ALERT_LEVEL_UUID 0x2A06 // Alert Level
#define TX_PWR_LEVEL_UUID 0x2A07 // Tx Power Level
#define DATE_TIME_UUID 0x2A08 // Date Time
#define DAY_OF_WEEK_UUID 0x2A09 // Day of Week
#define DAY_DATE_TIME_UUID 0x2A0A // Day Date Time
#define EXACT_TIME_256_UUID 0x2A0C // Exact Time 256
#define DST_OFFSET_UUID 0x2A0D // DST Offset
#define TIME_ZONE_UUID 0x2A0E // Time Zone
#define LOCAL_TIME_INFO_UUID 0x2A0F // Local Time Information
#define TIME_WITH_DST_UUID 0x2A11 // Time with DST
#define TIME_ACCURACY_UUID 0x2A12 // Time Accuracy
#define TIME_SOURCE_UUID 0x2A13 // Time Source
#define REF_TIME_INFO_UUID 0x2A14 // Reference Time Information
#define TIME_UPDATE_CTRL_PT_UUID 0x2A16 // Time Update Control Point
#define TIME_UPDATE_STATE_UUID 0x2A17 // Time Update State
#define GLUCOSE_MEAS_UUID 0x2A18 // Glucose Measurement
#define BATT_LEVEL_UUID 0x2A19 // Battery Level
#define TEMP_MEAS_UUID 0x2A1C // Temperature Measurement
#define TEMP_TYPE_UUID 0x2A1D // Temperature Type
#define IMEDIATE_TEMP_UUID 0x2A1E // Intermediate Temperature
#define MEAS_INTERVAL_UUID 0x2A21 // Measurement Interval
#define BOOT_KEY_INPUT_UUID 0x2A22 // Boot Keyboard Input Report
#define SYSTEM_ID_UUID 0x2A23 // System ID
#define MODEL_NUMBER_UUID 0x2A24 // Model Number String
#define SERIAL_NUMBER_UUID 0x2A25 // Serial Number String
#define FIRMWARE_REV_UUID 0x2A26 // Firmware Revision String
#define HARDWARE_REV_UUID 0x2A27 // Hardware Revision String
#define SOFTWARE_REV_UUID 0x2A28 // Software Revision String
#define MANUFACTURER_NAME_UUID 0x2A29 // Manufacturer Name String
#define IEEE_11073_CERT_DATA_UUID 0x2A2A // IEEE 11073-20601 Regulatory Certification Data List
#define CURRENT_TIME_UUID 0x2A2B // Current Time
#define SCAN_REFRESH_UUID 0x2A31 // Scan Refresh
#define BOOT_KEY_OUTPUT_UUID 0x2A32 // Boot Keyboard Output Report
#define BOOT_MOUSE_INPUT_UUID 0x2A33 // Boot Mouse Input Report
#define GLUCOSE_CONTEXT_UUID 0x2A34 // Glucose Measurement Context
#define BLOODPRESSURE_MEAS_UUID 0x2A35 // Blood Pressure Measurement
#define IMEDIATE_CUFF_PRESSURE_UUID 0x2A36 // Intermediate Cuff Pressure
#define HEARTRATE_MEAS_UUID 0x2A37 // Heart Rate Measurement
#define BODY_SENSOR_LOC_UUID 0x2A38 // Body Sensor Location
#define HEARTRATE_CTRL_PT_UUID 0x2A39 // Heart Rate Control Point
#define NETWORK_AVAIL_UUID 0x2A3E // Network Availability
#define ALERT_STATUS_UUID 0x2A3F // Alert Status
#define RINGER_CTRL_PT_UUID 0x2A40 // Ringer Control Point
#define RINGER_SETTING_UUID 0x2A41 // Ringer Setting
#define ALERT_CAT_ID_BMASK_UUID 0x2A42 // Alert Category ID Bit Mask
#define ALERT_CAT_ID_UUID 0x2A43 // Alert Category ID
#define ALERT_NOTIF_CTRL_PT_UUID 0x2A44 // Alert Notification Control Point
#define UNREAD_ALERT_STATUS_UUID 0x2A45 // Unread Alert Status
#define NEW_ALERT_UUID 0x2A46 // New Alert
#define SUP_NEW_ALERT_CAT_UUID 0x2A47 // Supported New Alert Category
#define SUP_UNREAD_ALERT_CAT_UUID 0x2A48 // Supported Unread Alert Category
#define BLOODPRESSURE_FEATURE_UUID 0x2A49 // Blood Pressure Feature
#define HID_INFORMATION_UUID 0x2A4A // HID Information
#define REPORT_MAP_UUID 0x2A4B // Report Map
#define HID_CTRL_PT_UUID 0x2A4C // HID Control Point
#define REPORT_UUID 0x2A4D // Report
#define PROTOCOL_MODE_UUID 0x2A4E // Protocol Mode
#define SCAN_INTERVAL_WINDOW_UUID 0x2A4F // Scan Interval Window
#define PNP_ID_UUID 0x2A50 // PnP ID
#define GLUCOSE_FEATURE_UUID 0x2A51 // Glucose Feature
#define RECORD_CTRL_PT_UUID 0x2A52 // Record Access Control Point
#define RSC_MEAS_UUID 0x2A53 // RSC Measurement
#define RSC_FEATURE_UUID 0x2A54 // RSC Feature
#define SC_CTRL_PT_UUID 0x2A55 // SC Control Point
#define CSC_MEAS_UUID 0x2A5B // CSC Measurement
#define CSC_FEATURE_UUID 0x2A5C // CSC Feature
#define SENSOR_LOC_UUID 0x2A5D // Sensor Location
#define CYCPWR_MEAS_UUID 0x2A63 // Cycling Power Measurement
#define CYCPWR_VECTOR_UUID 0x2A64 // Cycling Power Vector
#define CYCPWR_FEATURE_UUID 0x2A65 // Cycling Power Feature
#define CYCPWR_CTRL_PT_UUID 0x2A66 // Cycling Power Control Point
#define LOC_SPEED_UUID 0x2A67 // Location and Speed
#define NAV_UUID 0x2A68 // Navigation
#define POS_QUALITY_UUID 0x2A69 // Position Quality
#define LN_FEATURE_UUID 0x2A6A // LN Feature
#define LN_CTRL_PT_UUID 0x2A6B // LN Control Point
/**
GATT Unit UUIDs
*/
#define GATT_UNITLESS_UUID 0x2700 // <Symbol>, <Expressed in terms of SI base units>
#define GATT_UNIT_LENGTH_METER_UUID 0x2701 // m, m
#define GATT_UNIT_MASS_KGRAM_UUID 0x2702 // kg, kg
#define GATT_UNIT_TIME_SECOND_UUID 0x2703 // s, s
#define GATT_UNIT_ELECTRIC_CURRENT_A_UUID 0x2704 // A, A
#define GATT_UNIT_THERMODYN_TEMP_K_UUID 0x2705 // K, K
#define GATT_UNIT_AMOUNT_SUBSTANCE_M_UUID 0x2706 // mol, mol
#define GATT_UNIT_LUMINOUS_INTENSITY_C_UUID 0x2707 // cd, cd
#define GATT_UNIT_AREA_SQ_MTR_UUID 0x2710 // m^2, m^2
#define GATT_UNIT_VOLUME_CUBIC_MTR_UUID 0x2711 // m^3, m^3
#define GATT_UNIT_VELOCITY_MPS_UUID 0x2712 // m/s, m s^-1
#define GATT_UNIT_ACCELERATION_MPS_SQ_UUID 0x2713 // m/s^2, m s^-2
#define GATT_UNIT_WAVENUMBER_RM_UUID 0x2714 // ó, m^-1
#define GATT_UNIT_DENSITY_KGPCM_UUID 0x2715 // p, kg m^-3
#define GATT_UNIT_SURFACE_DENSITY_KGPSM_UUID 0x2716 // pA, kg m^-2
#define GATT_UNIT_SPECIFIC_VOLUME_CMPKG_UUID 0x2717 // v, m^3 kg^-1
#define GATT_UNIT_CURRENT_DENSITY_APSM_UUID 0x2718 // j, A m^-2
#define GATT_UNIT_MAG_FIELD_STRENGTH_UUID 0x2719 // H, A m
#define GATT_UNIT_AMOUNT_CONC_MPCM_UUID 0x271A // c, mol m^-3
#define GATT_UNIT_MASS_CONC_KGPCM_UUID 0x271B // c, kg m^-3
#define GATT_UNIT_LUMINANCE_CPSM_UUID 0x271C // Lv, cd m^-2
#define GATT_UNIT_REFRACTIVE_INDEX_UUID 0x271D // n, 1
#define GATT_UNIT_RELATIVE_PERMEABLILTY_UUID 0x271E // u, 1
#define GATT_UNIT_PLANE_ANGLE_RAD_UUID 0x2720 // rad, m m-1
#define GATT_UNIT_SOLID_ANGLE_STERAD_UUID 0x2721 // sr, m2 m-2
#define GATT_UNIT_FREQUENCY_HTZ_UUID 0x2722 // Hz, s-1
#define GATT_UNIT_FORCE_NEWTON_UUID 0x2723 // N, m kg s-2
#define GATT_UNIT_PRESSURE_PASCAL_UUID 0x2724 // Pa, N/m2 = m2 kg s-2
#define GATT_UNIT_ENERGY_JOULE_UUID 0x2725 // J, N m = m2 kg s-2
#define GATT_UNIT_POWER_WATT_UUID 0x2726 // W, J/s = m2 kg s-3
#define GATT_UNIT_E_CHARGE_C_UUID 0x2727 // C, sA
#define GATT_UNIT_E_POTENTIAL_DIF_V_UUID 0x2728 // V, W/A = m2 kg s-3 A-1
#define GATT_UNIT_CELSIUS_TEMP_DC_UUID 0x272F // oC, t/oC = T/K - 273.15
#define GATT_UNIT_TIME_MINUTE_UUID 0x2760 // min, 60 s
#define GATT_UNIT_TIME_HOUR_UUID 0x2761 // h, 3600 s
#define GATT_UNIT_TIME_DAY_UUID 0x2762 // d, 86400 s
#define GATT_UNIT_PLANE_ANGLE_DEGREE_UUID 0x2763 // o, (pi/180) rad
#define GATT_UNIT_PLANE_ANGLE_MINUTE_UUID 0x2764 // ', (pi/10800) rad
#define GATT_UNIT_PLANE_ANGLE_SECOND_UUID 0x2765 // '', (pi/648000) rad
#define GATT_UNIT_AREA_HECTARE_UUID 0x2766 // ha, 10^4 m^2
#define GATT_UNIT_VOLUME_LITRE_UUID 0x2767 // l, 10^-3 m^3
#define GATT_UNIT_MASS_TONNE_UUID 0x2768 // t, 10^3 kg
#define GATT_UINT_LENGTH_YARD_UUID 0x27A0 // yd, 0.9144 m
#define GATT_UNIT_LENGTH_PARSEC_UUID 0x27A1 // pc, 3.085678 × 1016 m
#define GATT_UNIT_LENGTH_INCH_UUID 0x27A2 // in, 0.0254 m
#define GATT_UNIT_LENGTH_FOOT_UUID 0x27A3 // ft, 0.3048 m
#define GATT_UNIT_LENGTH_MILE_UUID 0x27A4 // mi, 1609.347 m
#define GATT_UNIT_PRESSURE_PFPSI_UUID 0x27A5 // psi, 6.894757 × 103 Pa
#define GATT_UNIT_VELOCITY_KMPH_UUID 0x27A6 // km/h, 0.2777778 m^s-1
#define GATT_UNIT_VELOCITY_MPH_UUID 0x27A7 // mi/h, 0.44704 m^ s-1
#define GATT_UNIT_ANGULAR_VELOCITY_RPM_UUID 0x27A8 // r/min, 0.1047198 rad s-1
#define GATT_UNIT_ENERGY_GCAL_UUID 0x27A9 //
#define GATT_UNIT_ENERGY_KCAL_UUID 0x27AA // kcal, 4190.02 J
#define GATT_UNIT_ENERGY_KWH_UUID 0x27AB // kWh, 3600000 J
#define GATT_UNIT_THERMODYN_TEMP_DF_UUID 0x27AC // oF, t/oF = T/K × 1.8 - 459.67
#define GATT_UNIT_PERCENTAGE_UUID 0x27AD // %
#define GATT_UNIT_PER_MILE_UUID 0x27AE //
#define GATT_UNIT_PERIOD_BPM_UUID 0x27AF //
#define GATT_UNIT_E_CHARGE_AH_UUID 0x27B0 //
#define GATT_UNIT_MASS_DENSITY_MGPD_UUID 0x27B1 //
#define GATT_UNIT_MASS_DENSITY_MMPL_UUID 0x27B2 //
#define GATT_UNIT_TIME_YEAR_UUID 0x27B3 //
#define GATT_UNIT_TIME_MONTH_UUID 0x27B4 //
/*********************************************************************
MACROS
*/
/*********************************************************************
TYPEDEFS
*/
/*********************************************************************
VARIABLES
*/
/*********************************************************************
FUNCTIONS
*/
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* GATT_PROFILE_UUID_H */
File diff suppressed because it is too large Load Diff
+180
View File
@@ -0,0 +1,180 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/**************************************************************************************************
**************************************************************************************************/
#ifndef GATTTEST_H
#define GATTTEST_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
INCLUDES
*/
#include "bcomdef.h"
#include "OSAL.h"
/*********************************************************************
CONSTANTS
*/
// Length of attribute
#define GATT_TEST_ATTR_LEN 20
// Length of long attribute
#define GATT_TEST_LONG_ATTR_LEN 50
// GATT Test Services bit fields
#define GATT_TEST_SERVICE 0x00000001 // GATT Test
#define GATT_BATT_STATE_SERVICE 0x00000002 // Battery State
#define GATT_THERMO_HUMID_SERVICE 0x00000004 // Thermometer Humidity
#define GATT_WEIGHT_SERVICE 0x00000008 // Weight
#define GATT_POSITION_SERVICE 0x00000010 // Position
#define GATT_ALERT_SERVICE 0x00000020 // Alert
#define GATT_MANUFACT_SENSOR_SERVICE 0x00000040 // Sensor Manufacturer
#define GATT_MANUFACT_SCALES_SERVICE 0x00000080 // Scales Manufacturer
#define GATT_ADDRESS_SERVICE 0x00000100 // Address
#define GATT_128BIT_UUID1_SERVICE 0x00000200 // 128-bit UUID 1
#define GATT_128BIT_UUID2_SERVICE 0x00000400 // 128-bit UUID 2
#define GATT_128BIT_UUID3_SERVICE 0x00000800 // 128-bit UUID 3
/*********************************************************************
VARIABLES
*/
/*********************************************************************
MACROS
*/
/*********************************************************************
TYPEDEFS
*/
/*********************************************************************
VARIABLES
*/
/*********************************************************************
FUNCTIONS
*/
/**
@brief Add function for the GATT Test Services.
@param services - services to add. This is a bit map and can
contain more than one service.
@return SUCCESS: Service added successfully.
INVALIDPARAMETER: Invalid service field.
FAILURE: Not enough attribute handles available.
bleMemAllocError: Memory allocation error occurred.
*/
extern bStatus_t GATTTest_AddService( uint32 services );
/**
@brief Delete function for the GATT Test Services.
@param services - services to delete. This is a bit map and can
contain more than one service.
@return SUCCESS: Service deleted successfully.
FAILURE: Service not found.
*/
extern bStatus_t GATTTest_DelService( uint32 services );
/* -------------------------------------------------------------------
TASK API - These functions must only be called by OSAL.
*/
/**
@internal
@brief Initialize the GATT Test Application.
@param taskId - Task identifier for the desired task
@return void
*/
extern void GATTTest_Init( uint8 taskId );
/**
@internal
@brief GATT Test Application Task event processor. This function
is called to process all events for the task. Events include
timers, messages and any other user defined events.
@param task_id - The OSAL assigned task ID.
@param events - events to process. This is a bit map and can
contain more than one event.
@return none
*/
extern uint16 GATTTest_ProcessEvent( uint8 task_id, uint16 events );
/**
@brief Add function for the GATT Qualification Services.
@param services - services to add. This is a bit map and can
contain more than one service.
@return SUCCESS: Service added successfully.
INVALIDPARAMETER: Invalid service field.
FAILURE: Not enough attribute handles available.
bleMemAllocError: Memory allocation error occurred.
*/
extern bStatus_t GATTQual_AddService( uint32 services );
/**
@brief Delete function for the GATT Qualification Services.
@param services - services to delete. This is a bit map and can
contain more than one service.
@return SUCCESS: Service deleted successfully.
FAILURE: Service not found.
*/
extern bStatus_t GATTQual_DelService( uint32 services );
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* GATTTEST_H */
@@ -0,0 +1,304 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/**************************************************************************************************
**************************************************************************************************/
#ifndef L2CAP_INTERNAL_H
#define L2CAP_INTERNAL_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
INCLUDES
*/
#include "hci.h"
#include "l2cap.h"
/*********************************************************************
MACROS
*/
// Macro to see if a given channel is a fixed channel
#define FIX_CHANNEL( CID ) ( (CID) == L2CAP_CID_GENERIC ||\
(CID) == L2CAP_CID_SIG ||\
(CID) == L2CAP_CID_ATT ||\
(CID) == L2CAP_CID_SMP )
// Marco to convert a channel ID to an index into L2CAP Channel table
#define CID_TO_INDEX( CID ) ( (CID) - BASE_DYNAMIC_CID )
// Marco to convert a fixed channel ID to an index into L2CAP Fixed Channel table
#define FCID_TO_INDEX( CID ) ( (CID) - L2CAP_CID_ATT )
// Macro to return the record maintained a given fix channel
#define FIX_CHANNEL_REC( CID ) ( l2capFixedChannels[FCID_TO_INDEX( CID )] )
/*********************************************************************
CONSTANTS
*/
// Signaling command header: Code (1 byte) + Identifier (1 byte) + Length (2 bytes)
#define SIGNAL_HDR_SIZE 4
// Maximum size of data field of Signaling commands
#define SIGNAL_DATA_SIZE ( L2CAP_SIG_MTU_SIZE - SIGNAL_HDR_SIZE )
/*********************************************************************
L2CAP Channel States: states used for l2capChannel 'state' field
*/
// Closed - no channel associated with this CID
#define L2CAP_CLOSED 0x00
// Waiting for Echo Response
#define L2CAP_W4_ECHO_RSP 0x01
// Waiting for Info Response
#define L2CAP_W4_INFO_RSP 0x02
// Waiting for Connection Parameter Update Response
#define L2CAP_W4_PARAM_UPDATE_RSP 0x03
/*********************************************************************
TYPEDEFS
*/
// L2CAP Channel structure. Allocated one per application connection
// between two devices. CID assignment is relative to a particular device
// and a device can assign CIDs independently from other devices (except
// for the reserved CIDs). The CIDs are dynamically allocated in the range
// from 0x0040 to 0xFFFF.
typedef struct
{
// Channel info
uint8 state; // Channel connection state
uint16 CID; // Local channel id
uint8 id; // Local identifier - matches responses with requests
// Link info
uint16 connHandle; // link connection handle
// Application info
uint8 taskId; // task that channel belongs to
// Timer id
uint8 timerId;
} l2capChannel_t;
// L2CAP Fixed Channel structure. Allocated one for each fixed channel.
typedef struct
{
uint16 CID; // channel id
uint8 taskId; // task registered with channel
} l2capFixedChannel_t;
// Signaling packet header format
typedef struct
{
uint8 opcode; // type of command
uint8 id; // identifier - matches responses with requests
uint16 len; // length of data field (doesn't cover Code, Identifier and Length fields)
} l2capSignalHdr_t;
/**
@brief Callback function prototype for building a Signaling command.
@param pBuf - pointer to buffer to hold command data
@param pData - pointer to command data
@return length of the command data
*/
typedef uint16 (*pfnL2CAPBuildCmd_t)( uint8* pBuf, uint8* pData );
/*********************************************************************
GLOBAL VARIABLES
*/
extern uint8 l2capTaskID;
extern l2capChannel_t l2capChannels[];
extern l2capFixedChannel_t l2capFixedChannels[];
/*********************************************************************
FUNCTIONS - API
*/
/*
Send L2CAP Command.
*/
extern bStatus_t l2capSendCmd( uint16 connHandle, uint8 opcode, uint8 id,
uint8* pCmd, pfnL2CAPBuildCmd_t pfnBuildCmd );
/*
Send L2CAP Request.
*/
extern bStatus_t l2capSendReq( uint16 connHandle, uint8 opcode, uint8* pReq,
pfnL2CAPBuildCmd_t pfnBuildCmd, uint8 state, uint8 taskId );
/*
Build Echo Request.
*/
extern uint16 l2capBuildEchoReq( uint8* pBuf, uint8* pCmd );
/*
Build Info Request.
*/
extern uint16 l2capBuildInfoReq( uint8* pBuf, uint8* pCmd );
/*
Build Parameter Update Request.
*/
extern uint16 l2capBuildParamUpdateReq( uint8* pBuf, uint8* pData );
/*
Encapsulate and send L2CAP packet.
*/
extern bStatus_t l2capEncapSendData( uint16 connHandle, l2capPacket_t* pPkt );
/*
Parse L2CAP packet.
*/
extern uint8 l2capParsePacket( l2capPacket_t* pPkt, hciDataEvent_t* pHciMsg );
/*
Parse L2CAP Signaling header.
*/
extern void l2capParseSignalHdr( l2capSignalHdr_t* pHdr, uint8* pData );
/*
Build Echo Response.
*/
extern uint16 l2capBuildEchoRsp( uint8* pBuf, uint8* pCmd );
/*
Parse Command Reject.
*/
extern bStatus_t l2capParseCmdReject( l2capSignalCmd_t* pCmd, uint8* pData, uint16 len );
/*
Parse Echo Response.
*/
extern bStatus_t l2capParseEchoRsp( l2capSignalCmd_t* pCmd, uint8* pData, uint16 len );
/*
Parse Information Response.
*/
extern bStatus_t l2capParseInfoRsp( l2capSignalCmd_t* pCmd, uint8* pData, uint16 len );
/*
Parse Connection Parameter Update Response.
*/
extern bStatus_t l2capParseParamUpdateRsp( l2capSignalCmd_t* pCmd, uint8* pData, uint16 len );
/*
Find a channel using the local identifier.
*/
extern l2capChannel_t* l2capFindLocalId( uint8 id );
/*
Free a channel.
*/
extern void l2capFreeChannel( l2capChannel_t* pChannel );
/*
Stop an active timer for a given channel.
*/
extern void l2capStopTimer( l2capChannel_t* pChannel );
/*
Handle an incoming packet error.
*/
extern void l2capHandleRxError( uint16 connHandle );
/*
Forward a data message to upper layer application.
*/
extern bStatus_t l2capNotifyData( uint8 taskId, uint16 connHandle, l2capPacket_t* pPkt );
/*
Send a Signaling command to upper layer application.
*/
extern void l2capNotifySignal( uint8 taskId, uint16 connHandle, uint8 status,
uint8 opcode, uint8 id, l2capSignalCmd_t* pCmd );
extern void* L2CAP_Fragment_bm_alloc( uint16 size );
extern uint8 L2CAP_Fragment_SendDataPkt( uint16 connHandle, uint8 fragFlg,uint16 pktLen, uint8* pBuf );
/*********************************************************************
@fn l2capInfoRsp
@brief Send Info Response.
Use like: l2capInfoRsp( uint16 connHandle, uint8 id, l2capInfoRsp_t *pInfoRsp );
@param connHandle - connection to use
@param id - identifier received in request
@param pInfoRsp - pointer to Info Response to be sent
@return SUCCESS: Request was sent successfully.
INVALIDPARAMETER: Data can not fit into one packet.
MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
bleNotConnected: Connection is down.
bleMemAllocError: Memory allocation error occurred.
*/
#define l2capInfoRsp( connHandle, id, pInfoRsp ) l2capSendCmd( (connHandle), L2CAP_INFO_RSP, (id),\
(uint8 *)(pInfoRsp), L2CAP_BuildInfoRsp )
/*********************************************************************
@fn l2capEchoRsp
@brief Send Ehco Response.
Use like: l2capEchoRsp( uint16 connHandle, uint8 id, l2capEchoRsp_t *pEchoRsp );
@param connHandle - connection to use
@param id - identifier received in request
@param pEchoRsp - pinter to Echo Response to be sent
@return SUCCESS: Request was sent successfully.
INVALIDPARAMETER: Data can not fit into one packet.
MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
bleNotConnected: Connection is down.
bleMemAllocError: Memory allocation error occurred.
*/
#define l2capEchoRsp( connHandle, id, pEchoRsp ) l2capSendCmd( (connHandle), L2CAP_ECHO_RSP, (id),\
(uint8 *)(pEchoRsp), l2capBuildEchoRsp )
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* L2CAP_INTERNAL_H */
+236
View File
@@ -0,0 +1,236 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/**************************************************************************************************
Filename: linkdb.h
Revised:
Revision:
Description: This file contains the linkDB interface.
**************************************************************************************************/
#ifndef LINKDB_H
#define LINKDB_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
INCLUDES
*/
/*********************************************************************
MACROS
*/
/*********************************************************************
CONSTANTS
*/
// Special case connection handles
#define INVALID_CONNHANDLE 0xFFFF // Invalid connection handle, used for no connection handle
#define LOOPBACK_CONNHANDLE 0xFFFE // Loopback connection handle, used to loopback a message
// Link state flags
#define LINK_NOT_CONNECTED 0x00 // Link isn't connected
#define LINK_CONNECTED 0x01 // Link is connected
#define LINK_AUTHENTICATED 0x02 // Link is authenticated
#define LINK_BOUND 0x04 // Link is bonded
#define LINK_ENCRYPTED 0x10 // Link is encrypted
// Link Database Status callback changeTypes
#define LINKDB_STATUS_UPDATE_NEW 0 // New connection created
#define LINKDB_STATUS_UPDATE_REMOVED 1 // Connection was removed
#define LINKDB_STATUS_UPDATE_STATEFLAGS 2 // Connection state flag changed
// Link Authentication Errors
#define LINKDB_ERR_INSUFFICIENT_AUTHEN 0x05 // Link isn't even encrypted
#define LINBDB_ERR_INSUFFICIENT_KEYSIZE 0x0c // Link is encrypted but the key size is too small
#define LINKDB_ERR_INSUFFICIENT_ENCRYPTION 0x0f // Link is encrypted but it's not authenticated
/*********************************************************************
TYPEDEFS
*/
typedef struct
{
uint8 srk[KEYLEN]; // Signature Resolving Key
uint32 signCounter; // Sign Counter
} linkSec_t;
typedef struct
{
uint8 ltk[KEYLEN]; // Long Term Key
uint16 div; // Diversifier
uint8 rand[B_RANDOM_NUM_SIZE]; // random number
uint8 keySize; // LTK Key Size
} encParams_t;
typedef struct
{
uint8 taskID; // Application that controls the link
uint16 connectionHandle; // Controller connection handle
uint8 stateFlags; // LINK_CONNECTED, LINK_AUTHENTICATED...
uint8 role; // 2020-04-22 add (case for multi-role SMP )
uint8 addrType; // Address type of connected device
uint8 addr[B_ADDR_LEN]; // Other Device's address
uint16 connInterval; // The connection's interval (n * 1.23 ms)
linkSec_t sec; // Connection Security related items
encParams_t* pEncParams; // pointer to LTK, ediv, rand. if needed.
} linkDBItem_t;
// function pointer used to register for a status callback
typedef void (*pfnLinkDBCB_t)( uint16 connectionHandle, uint8 changeType );
// function pointer used to perform specialized link database searches
typedef void (*pfnPerformFuncCB_t)( linkDBItem_t* pLinkItem );
/*********************************************************************
GLOBAL VARIABLES
*/
/*********************************************************************
PUBLIC FUNCTIONS
*/
/*
linkDB_Init - Initialize the Link Database.
*/
extern void linkDB_Init( void );
/*
linkDB_Register - Register with this function to receive a callback when
status changes on a connection.
*/
extern uint8 linkDB_Register( pfnLinkDBCB_t pFunc );
/*
linkDB_Add - Adds a record to the link database.
*/
extern uint8 linkDB_Add( uint8 taskID, uint16 connectionHandle, uint8 stateFlags, uint8 role,
uint8 addrType, uint8* pAddr, uint16 connInterval );
/*
linkDB_Remove - Removes a record from the link database.
*/
extern uint8 linkDB_Remove( uint16 connectionHandle );
/*
linkDB_Update - This function is used to update the stateFlags of
a link record.
*/
extern uint8 linkDB_Update( uint16 connectionHandle, uint8 newState );
/*
linkDB_NumActive - returns the number of active connections.
*/
extern uint8 linkDB_NumActive( void );
/*
linkDB_Find - Find link database item (link information)
returns a pointer to the link item, NULL if not found
*/
extern linkDBItem_t* linkDB_Find( uint16 connectionHandle );
/*
linkDB_FindFirst - Find the first link that matches the taskID.
returns a pointer to the link item, NULL if not found
*/
extern linkDBItem_t* linkDB_FindFirst( uint8 taskID );
/*
linkDB_State - Check to see if a physical link is in a specific state.
returns TRUE is the link is in state. FALSE, otherwise.
*/
extern uint8 linkDB_State( uint16 connectionHandle, uint8 state );
/*
linkDB_Authen - Check to see if the physical link is encrypted and authenticated.
returns SUCCESS if the link is authenticated or
bleNotConnected - connection handle is invalid,
LINKDB_ERR_INSUFFICIENT_AUTHEN - link is not encrypted,
LINBDB_ERR_INSUFFICIENT_KEYSIZE - key size encrypted is not large enough,
LINKDB_ERR_INSUFFICIENT_ENCRYPTION - link is encrypted, but not authenticated
*/
extern uint8 linkDB_Authen( uint16 connectionHandle, uint8 keySize, uint8 mitmRequired );
/*
linkDB_PerformFunc - Perform a function of each connection in the link database.
*/
extern void linkDB_PerformFunc( pfnPerformFuncCB_t cb );
/*
linkDB_Up - Check to see if a physical link is up (connected).
Use like: uint8 linkDB_Up( uint16 connectionHandle );
connectionHandle - controller link connection handle.
returns TRUE if the link is up. FALSE, otherwise.
*/
#define linkDB_Up( connectionHandle ) linkDB_State( (connectionHandle), LINK_CONNECTED )
/*
linkDB_Encrypted - Check to see if the physical link is encrypted.
Use like: linkDB_Encrypted( uint16 connectionHandle );
connectionHandle - controller link connection handle.
returns TRUE if the link is encrypted. FALSE, otherwise.
*/
#define linkDB_Encrypted( connectionHandle ) linkDB_State( (connectionHandle), LINK_ENCRYPTED )
/*
linkDB_Authenticated - Check to see if the physical link is authenticated.
Use like: linkDB_Authenticated( uint16 connectionHandle );
connectionHandle - controller link connection handle.
returns TRUE if the link is authenticated. FALSE, otherwise.
*/
#define linkDB_Authenticated( connectionHandle ) linkDB_State( (connectionHandle), LINK_AUTHENTICATED )
/*
linkDB_Bonded - Check to see if the physical link is bonded.
Use like: linkDB_Bonded( uint16 connectionHandle );
connectionHandle - controller link connection handle.
returns TRUE if the link is bonded. FALSE, otherwise.
*/
#define linkDB_Bonded( connectionHandle ) linkDB_State( (connectionHandle), LINK_BOUND )
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* LINKDB_H */
+392
View File
@@ -0,0 +1,392 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/**************************************************************************************************
**************************************************************************************************/
#ifndef SM_INTERNAL_H
#define SM_INTERNAL_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
INCLUDES
*/
#include "bcomdef.h"
#include "l2cap.h"
#include "smp.h"
#include "linkdb.h"
/*********************************************************************
MACROS
*/
/*********************************************************************
CONSTANTS
*/
// Security Manager Task Events
#define SM_TIMEOUT_EVT 0x0001 // Message timeout event
#define SM_PAIRING_STATE_EVT 0x0002 // Event used to progress to the next pairing state
// Pairing states
#define SM_PAIRING_STATE_INITIALIZE 0 // Pairing has started
#define SM_PAIRING_STATE_PAIRING_REQ_SENT 1 // Initiator: Pairing Request has been sent, Responder: waiting for Pairing Request.
#define SM_PAIRING_STATE_WAIT_CONFIRM 2 // Waiting for Confirm message
#define SM_PAIRING_STATE_WAIT_PASSKEY 3 // Waiting for Passkey from app/profile
#define SM_PAIRING_STATE_WAIT_CONFIRM_PASSKEY 4 // Received Initiator Confirm message and waiting for Passkey from app/profile (responder only)
#define SM_PAIRING_STATE_WAIT_RANDOM 5 // Waiting for Random message
#define SM_PAIRING_STATE_WAIT_STK 6 // Waiting for STK process to finish
#define SM_PAIRING_STATE_WAIT_SLAVE_ENCRYPTION_INFO 7 // Waiting for Slave Encryption Info to be sent
#define SM_PAIRING_STATE_WAIT_SLAVE_MASTER_INFO 8 // Waiting for Slave Master Info to be sent
#define SM_PAIRING_STATE_WAIT_SLAVE_IDENTITY_INFO 9 // Waiting for Slave Identity Info to be sent
#define SM_PAIRING_STATE_WAIT_SLAVE_IDENTITY_ADDR_INFO 10 // Waiting for Slave Identity Addr Info to be sent
#define SM_PAIRING_STATE_WAIT_SLAVE_SIGNING_INFO 11 // Waiting for Slave Signing Info to be sent
#define SM_PAIRING_STATE_WAIT_MASTER_ENCRYPTION_INFO 12 // Waiting for Master Encryption Info to be sent
#define SM_PAIRING_STATE_WAIT_MASTER_MASTER_INFO 13 // Waiting for Master Master Info to be sent
#define SM_PAIRING_STATE_WAIT_MASTER_IDENTITY_INFO 14 // Waiting for Master Identity Info to be sent
#define SM_PAIRING_STATE_WAIT_MASTER_IDENTITY_ADDR_INFO 15 // Waiting for Master Identity Addr Info to be sent
#define SM_PAIRING_STATE_WAIT_MASTER_SIGNING_INFO 16 // Waiting for Master Signing Info to be sent
#define SM_PAIRING_STATE_WAIT_ENCRYPT 17 // Waiting for LTK process to finish
#define SM_PAIRING_STATE_DONE 18 // Closing out the pairing process
#if defined ( TESTMODES )
// SM TestModes
#define SM_TESTMODE_OFF 0 // No Test mode
#define SM_TESTMODE_NO_RESPONSE 1 // Don't respond to any SM message
#define SM_TESTMODE_SEND_BAD_CONFIRM 2 // Force a bad confirm value in the Confirm Message
#define SM_TESTMODE_BAD_CONFIRM_VERIFY 3 // Force a bad confirm check of the received Confirm Message
#define SM_TESTMODE_SEND_CONFIRM 4 // Force a SMP Confirm message
#endif // TESTMODES
// Pairing Types
#define SM_PAIRING_TYPE_INIT 0 // Pairing has been started but the type hasn't been determined yet
#define SM_PAIRING_TYPE_JUST_WORKS 1 // Pairing is Just Works
#define SM_PAIRING_TYPE_PASSKEY_INITIATOR_INPUTS 2 // Pairing is MITM Passkey with initiator inputs passkey
#define SM_PAIRING_TYPE_PASSKEY_RESPONDER_INPUTS 3 // Pairing is MITM Passkey with responder inputs passkey
#define SM_PAIRING_TYPE_PASSKEY_BOTH_INPUTS 4 // Pairing is MITM Passkey with both initiator and responder input passkey
#define SM_PAIRING_TYPE_OOB 5 // Pairing is MITM OOB
#define SM_PAIRING_STATE_WAIT 500 // The default wait time between key distribution messages.
/*********************************************************************
TYPEDEFS
*/
typedef struct
{
uint8 confirm[KEYLEN]; // calculated confirm value
uint8 rand[SMP_RANDOM_LEN]; // First MRand or Srand, then RAND
} devPairing_t;
typedef struct
{
// From the start
uint8 initiator; // TRUE if initiator
uint8 state; // Pairing state
uint8 taskID; // Task ID of the app/profile that requested the pairing
uint8 timerID; // 2021-03-29 add , timerid for simultaneously SMP for multi-role(the same as single connection )
uint8 stateID; // 2021-03-29 add , stateid for simultaneously SMP pairing state change idx
uint16 connectionHandle; // Connection Handle from controller,
smLinkSecurityReq_t* pSecReqs; // Pairing Control info
uint8 tk[KEYLEN]; // Holds tk from app
uint8 authState; // uses SM_AUTH_STATE_AUTHENTICATED & SM_AUTH_STATE_BONDING
// During pairing
smpPairingReq_t* pPairDev; // Info of paired device.
uint8 type; // ie. SM_PAIRING_TYPE_JUST_WORKS
// device information
devPairing_t myComp; // This device's pairing components
devPairing_t devComp; // The other device's components
// Encrypt Params
smSecurityInfo_t* pEncParams; // Your (device's) encryption parameters
smSecurityInfo_t* pDevEncParams; // Connected device's encryption parameters
smIdentityInfo_t* pIdInfo; // Connected device's identity parameters
smSigningInfo_t* pSigningInfo; // Connected device's signing parameters
} smPairingParams_t;
// Callback when an SMP message has been received on the Initiator or Responder.
typedef uint8 (*smProcessMsg_t)( linkDBItem_t* pLinkItem, uint8 cmdID, smpMsgs_t* pParsedMsg );
// Callback to send next key message, and sets state for next event on the Initiator or Responder.
typedef void (*smSendNextKeyInfo_t)( uint16 connectionHandle );
// Callback to send Start Encrypt through HCI on the Initiator.
typedef bStatus_t (*smStartEncryption_t)( uint16 connHandle, uint8* pLTK, uint16 div,
uint8* pRandNum, uint8 keyLen );
// Callback when an HCI BLE LTK Request has been received on the Responder.
typedef uint8 (*smProcessLTKReq_t)( uint16 connectionHandle, uint8* pRandom, uint16 encDiv );
// Initiator callback structure - must be setup by the Initiator.
typedef struct
{
smProcessMsg_t pfnProcessMsg; // When SMP message received
smSendNextKeyInfo_t pfnSendNextKeyInfo; // When need to send next key message
smStartEncryption_t pfnStartEncryption; // When Start Encrypt requested
} smInitiatorCBs_t;
// Responder callback structure - must be setup by the Initiator.
typedef struct
{
smProcessMsg_t pfnProcessMsg; // When SMP message received
smSendNextKeyInfo_t pfnSendNextKeyInfo; // When need to send next key message
smProcessLTKReq_t pfnProcessLTKReq; // When HCI BLE LTK Request received
} smResponderCBs_t;
/*********************************************************************
GLOBAL VARIABLES
*/
// Security Manager's OSAL task ID
extern uint8 smTaskID;
extern smPairingParams_t* pPairingParams[];
extern smResponderCBs_t* pfnResponderCBs;
/*********************************************************************
FUNCTIONS - API
*/
/*********************************************************************
Application Level Functions
*/
/*
smLinkCheck - link database callback function.
*/
extern void smLinkCheck( uint16 connectionHandle, uint8 changeType );
/*
smProcessRandComplete - Process the HCI Random Complete Event.
*/
extern uint8 smProcessRandComplete( uint8 status, uint8* rand );
/*
smTimedOut - Process the SM timeout.
*/
extern void smTimedOut( uint16 connectionHandle );
/*
smStartRspTimer - Start the SM Response Timer.
*/
extern void smStartRspTimer( uint16 connectionHandle );
/*
smStopRspTimer - Stop the SM Response Timer.
*/
extern void smStopRspTimer( uint16 connectionHandle );
/*
smProcessDataMsg - Process incoming L2CAP messages.
*/
extern void smProcessDataMsg( l2capDataEvent_t* pMsg );
/*
smProcessEncryptChange - Process the HCI BLE Encrypt Change Event.
*/
extern uint8 smProcessEncryptChange( uint16 connectionHandle, uint8 reason );
/*
smInProcess - Is SM already processing something?
*/
extern uint8 smInProcess( void );
/*
sm_d1 - SM diversifying function d1
*/
extern bStatus_t sm_d1( uint8* pK, uint16 d, uint8* pD1 );
/*
sm_ah - Random address hash function
*/
extern bStatus_t sm_ah( uint8* pK, uint8* pR, uint8* pAh );
/*
sm_dm - SM DIV Maxk generation function dm
*/
extern bStatus_t sm_dm( uint8* pK, uint8* pR, uint16* pDm );
/*
sm_c1 - SM Confirm value generation function c1
*/
extern bStatus_t sm_c1( uint16 connectionHandle,uint8* pK, uint8* pR, uint8* pC1 );
/*
sm_c1new - SM Confirm value generation function c1
*/
extern bStatus_t sm_c1new( uint8* pK, uint8* pR, uint8* pRes, uint8* pReq,
uint8 iat, uint8* pIA, uint8 rat, uint8* pRA, uint8* pC1 );
/*
sm_s1 - SM key generation function s1
*/
extern bStatus_t sm_s1( uint8* pK, uint8* pR1, uint8* pR2, uint8* pS1 );
/*
smGenerateRandBuf - generate a buffer of random numbers
*/
extern void smGenerateRandBuf( uint8* pRandNum, uint8 len );
/*
smEncLTK - start LTK Encryption
*/
extern void smEncLTK( uint16 connectionHandle );
/*
smNextPairingState - trigger next state machine
*/
extern void smNextPairingState( uint16 connectionHandle );
/*
smAuthReqToUint8 - conversion function
*/
extern uint8 smAuthReqToUint8( authReq_t* pAuthReq );
/*
smUint8ToAuthReq - conversion function
*/
extern void smUint8ToAuthReq( authReq_t* pAuthReq, uint8 authReqUint8 );
/*
smpResponderProcessPairingReq - Process an incoming Pairing Request message
*/
extern uint8 smpResponderProcessPairingReq( uint16 connectionHandle,smpPairingReq_t* pParsedMsg );
/*
smSendFailAndEnd - Send the pairing failed message and end existing pairing
*/
extern bStatus_t smSendFailAndEnd( uint16 connHandle, smpPairingFailed_t* pFailedMsg );
/*
generateRandMsg - Generate a Pairing Random
*/
extern bStatus_t smGenerateRandMsg( uint16 connectionHandle);
/*
smSavePairInfo - Save the Pairing Req or Rsp information
*/
extern bStatus_t smSavePairInfo( uint16 connectionHandle,smpPairingReq_t* pPair );
/*
generateConfirm - Generate a Pairing Confirm
*/
extern bStatus_t smGenerateConfirm( uint16 connectionHandle );
/*
smEndPairing - Pairing mode has ended. Yeah. Notify the GAP and free
up the memory used.
*/
extern void smEndPairing( uint16 connectionHandle,uint8 status );
/*
determineKeySize - Determine the maximum encryption key size
*/
extern uint8 smDetermineKeySize( uint16 connectionHandle );
/*
smGeneratePairingReqRsp - Generate a pairing req or response
*/
extern bStatus_t smGeneratePairingReqRsp( uint16 connectionHandle );
/*
smPairingSendEncInfo - Send SM Encryption Information message
*/
extern void smPairingSendEncInfo( uint16 connHandle, uint8* pLTK );
/*
smPairingSendMasterID - Send SM Master Identification message
*/
extern void smPairingSendMasterID( uint16 connHandle, uint16 ediv, uint8* pRand );
/*
smPairingSendIdentityInfo - Send SM Identity Information message
*/
extern void smPairingSendIdentityInfo( uint16 connHandle, uint8* pIRK );
/*
smPairingSendIdentityAddrInfo - Send SM Identity Addr Information message
*/
extern void smPairingSendIdentityAddrInfo( uint16 connHandle, uint8 addrType, uint8* pMACAddr );
/*
smPairingSendSingingInfo - Send SM Signing Information message
*/
extern void smPairingSendSingingInfo( uint16 connHandle, uint8* pSRK );
/*
smPairingSendEncInfo - Send SM Encryption Information message
*/
extern void smPairingSendEncInfo( uint16 connHandle, uint8* pLTK );
/*
smProcessPairingReq - Process Pairing Request
*/
extern void smProcessPairingReq( linkDBItem_t* pLinkItem, gapPairingReq_t* pPairReq );
/*
smStartEncryption - Perform Encrypt through HCI
*/
extern bStatus_t smStartEncryption( uint16 connHandle, uint8* pLTK, uint16 div,
uint8* pRandNum, uint8 keyLen );
/*
smRegisterInitiator - egister Initiator's processing function with SM task
*/
extern void smRegisterInitiator( smInitiatorCBs_t* pfnCBs );
/*
smRegisterResponder - Register Responder's processing function with SM task
*/
extern void smRegisterResponder( smResponderCBs_t* pfnCBs );
/*
smp timerout callback for SMP Timeout and pairing state
*/
extern void smTo_timerCB( uint8* pData );
extern void smState_timerCB( uint8* pData );
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* SM_INTERNAL_H */
+408
View File
@@ -0,0 +1,408 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/**************************************************************************************************
**************************************************************************************************/
#ifndef SMP_H
#define SMP_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
INCLUDES
*/
#include "bcomdef.h"
#include "sm_internal.h"
/*********************************************************************
MACROS
*/
/*********************************************************************
CONSTANTS
*/
// Code field of the SMP Command format
#define SMP_PAIRING_REQ 0x01
#define SMP_PAIRING_RSP 0x02
#define SMP_PAIRING_CONFIRM 0x03
#define SMP_PAIRING_RANDOM 0x04
#define SMP_PAIRING_FAILED 0x05
#define SMP_ENCRYPTION_INFORMATION 0x06
#define SMP_MASTER_IDENTIFICATION 0x07
#define SMP_IDENTITY_INFORMATION 0x08
#define SMP_IDENTITY_ADDR_INFORMATION 0x09
#define SMP_SIGNING_INFORMATION 0x0A
#define SMP_SECURITY_REQUEST 0x0B
// Pairing Request & Response - IO Capabilities
#define SMP_IO_CAP_DISPLAY_ONLY 0x00
#define SMP_IO_CAP_DISPLAY_YES_NO 0x01
#define SMP_IO_CAP_KEYBOARD_ONLY 0x02
#define SMP_IO_CAP_NO_INPUT_NO_OUTPUT 0x03
#define SMP_IO_CAP_KEYBOARD_DISPLAY 0x04
// Pairing Request & Response - Out Of Bound (OOB) data flag values
#define SMP_OOB_AUTH_DATA_NOT_PRESENT 0x00
#define SMP_OOB_AUTH_DATA_REMOTE_DEVICE_PRESENT 0x01
// Pairing Request & Response - authReq field
// - This field contains 2 sub-fields:
// bonding flags - bits 1 & 0
#define SMP_AUTHREQ_BONDING 0x01
// Man-In-The-Middle (MITM) - bit 2
#define SMP_AUTHREQ_MITM 0x04
#define SMP_CONFIRM_LEN 16
#define SMP_RANDOM_LEN 16
// Pairing Failed - "reason" field
#define SMP_PAIRING_FAILED_PASSKEY_ENTRY_FAILED 0x01 //!< The user input of the passkey failed, for example, the user cancelled the operation.
#define SMP_PAIRING_FAILED_OOB_NOT_AVAIL 0x02 //!< The OOB data is not available
#define SMP_PAIRING_FAILED_AUTH_REQ 0x03 //!< The pairing procedure can't be performed as authentication requirements can't be met due to IO capabilities of one or both devices
#define SMP_PAIRING_FAILED_CONFIRM_VALUE 0x04 //!< The confirm value doesn't match the calculated compare value
#define SMP_PAIRING_FAILED_NOT_SUPPORTED 0x05 //!< Pairing isn't supported by the device
#define SMP_PAIRING_FAILED_ENC_KEY_SIZE 0x06 //!< The resultant encryption key size is insufficient for the security requirements of this device.
#define SMP_PAIRING_FAILED_CMD_NOT_SUPPORTED 0x07 //!< The SMP command received is not supported on this device.
#define SMP_PAIRING_FAILED_UNSPECIFIED 0x08 //!< Pairing failed due to an unspecified reason
#define SMP_PAIRING_FAILED_REPEATED_ATTEMPTS 0x09 //!< Pairing or authenication procedure is disallowed because too little time has elapsed since the last pairing request or security request.
#define SMP_PAIRING_FAILED_LOCAL_KEY_FAILURE 0x0A // Local value - not sent over the air
// Message lengths
#define SMP_PAIRING_REQ_LEN 7
#define SMP_PAIRING_RSP_LEN 7
#define SMP_PAIRING_CONFIRM_LEN 17
#define SMP_PAIRING_RANDOM_LEN 17
#define SMP_PAIRING_FAILED_LEN 2
#define SMP_ENCRYPTION_INFORMATION_LEN 17
#define SMP_MASTER_IDENTIFICATION_LEN 11
#define SMP_IDENTITY_INFORMATION_LEN 17
#define SMP_IDENTITY_ADDR_INFORMATION_LEN 8
#define SMP_SIGNING_INFORMATION_LEN 17
#define SMP_SECURITY_REQUEST_LEN 2
// Macros to use the smSendSMMsg() function to send all of the Security Manager Protocol messages
#define smSendPairingReq( connHandle, msgStruct ) \
smSendSMMsg( (connHandle), SMP_PAIRING_REQ_LEN, \
(smpMsgs_t *)(msgStruct), \
(pfnSMBuildCmd_t)(smpBuildPairingReq) )
#define smSendPairingRsp( connHandle, msgStruct ) \
smSendSMMsg( (connHandle), SMP_PAIRING_RSP_LEN, \
(smpMsgs_t *)(msgStruct), \
(pfnSMBuildCmd_t)(smpBuildPairingRsp) )
#define smSendPairingConfirm( connHandle, msgStruct ) \
smSendSMMsg( (connHandle), SMP_PAIRING_CONFIRM_LEN, \
(smpMsgs_t *)(msgStruct), \
(pfnSMBuildCmd_t)(smpBuildPairingConfirm) )
#define smSendPairingRandom( connHandle, msgStruct ) \
smSendSMMsg( (connHandle), SMP_PAIRING_RANDOM_LEN, \
(smpMsgs_t *)(msgStruct), \
(pfnSMBuildCmd_t)(smpBuildPairingRandom) )
#define smSendPairingFailed( connHandle, msgStruct ) \
smSendSMMsg( (connHandle), SMP_PAIRING_FAILED_LEN, \
(smpMsgs_t *)(msgStruct), \
(pfnSMBuildCmd_t)(smpBuildPairingFailed) )
#define smSendEncInfo( connHandle, msgStruct ) \
smSendSMMsg( (connHandle), SMP_ENCRYPTION_INFORMATION_LEN, \
(smpMsgs_t *)(msgStruct), \
(pfnSMBuildCmd_t)(smpBuildEncInfo) )
#define smSendMasterID( connHandle, msgStruct ) \
smSendSMMsg( (connHandle), SMP_MASTER_IDENTIFICATION_LEN, \
(smpMsgs_t *)(msgStruct), \
(pfnSMBuildCmd_t)(smpBuildMasterID) )
#define smSendIdentityInfo( connHandle, msgStruct ) \
smSendSMMsg( (connHandle), SMP_IDENTITY_INFORMATION_LEN, \
(smpMsgs_t *)(msgStruct), \
(pfnSMBuildCmd_t)(smpBuildIdentityInfo) )
#define smSendIdentityAddrInfo( connHandle, msgStruct ) \
smSendSMMsg( (connHandle), SMP_IDENTITY_ADDR_INFORMATION_LEN, \
(smpMsgs_t *)(msgStruct), \
(pfnSMBuildCmd_t)(smpBuildIdentityAddrInfo) )
#define smSendSigningInfo( connHandle, msgStruct ) \
smSendSMMsg( (connHandle), SMP_SIGNING_INFORMATION_LEN, \
(smpMsgs_t *)(msgStruct), \
(pfnSMBuildCmd_t)(smpBuildSigningInfo) )
#define smSendSecurityReq( connHandle, msgStruct ) \
smSendSMMsg( (connHandle), SMP_SECURITY_REQUEST_LEN, \
(smpMsgs_t *)(msgStruct), \
(pfnSMBuildCmd_t)(smpBuildSecurityReq) )
/*********************************************************************
TYPEDEFS
*/
// Pairing Request
typedef struct
{
uint8 ioCapability; // ex. SMP_IO_CAP_DISPLAY_YES_NO
uint8 oobDataFlag; // Out of Bound data flag
authReq_t authReq; // Authentication fields
uint8 maxEncKeySize; // Encryption Key size max bytes (7 - 16)
keyDist_t keyDist; // Key Distribution Field - bit struct
} smpPairingReq_t;
// Pairing Response - same as Pairing Request
typedef smpPairingReq_t smpPairingRsp_t;
// Pairing Confirm
typedef struct
{
uint8 confirmValue[SMP_CONFIRM_LEN];
} smpPairingConfirm_t;
// Pairing Random
typedef struct
{
uint8 randomValue[SMP_RANDOM_LEN];
} smpPairingRandom_t;
// Pairing Failed
typedef struct
{
uint8 reason;
} smpPairingFailed_t;
// Encryption Information
typedef struct
{
uint8 ltk[KEYLEN];
} smpEncInfo_t;
// Master Identification
typedef struct
{
uint16 ediv;
uint16 rand[B_RANDOM_NUM_SIZE];
} smpMasterID_t;
// Identity Information
typedef struct
{
uint8 irk[KEYLEN];
} smpIdentityInfo_t;
// Identity Address Information
typedef struct
{
uint8 addrType;
uint8 bdAddr[B_ADDR_LEN];
} smpIdentityAddrInfo_t;
// Signing Information
typedef struct
{
uint8 signature[KEYLEN];
} smpSigningInfo_t;
// Slave Security Request
typedef struct
{
authReq_t authReq;
} smpSecurityReq_t;
// Union with all of the SM messages.
typedef union
{
smpPairingReq_t pairingReq;
smpPairingReq_t pairingRsp;
smpPairingConfirm_t pairingConfirm;
smpPairingRandom_t pairingRandom;
smpPairingFailed_t pairingFailed;
smpEncInfo_t encInfo;
smpMasterID_t masterID;
smpIdentityInfo_t idInfo;
smpIdentityAddrInfo_t idAddrInfo;
smpSigningInfo_t signingInfo;
smpSecurityReq_t secReq;
} smpMsgs_t;
typedef uint8 (*pfnSMBuildCmd_t)( smpMsgs_t* pMsgStruct, uint8* pBuf );
/*********************************************************************
GLOBAL VARIABLES
*/
extern smpPairingReq_t pairingReg;
/*********************************************************************
FUNCTIONS
*/
/*
smpBuildPairingReq - Build an SM Pairing Request
*/
extern bStatus_t smpBuildPairingReq( smpPairingReq_t* pPairingReq, uint8* pBuf );
/*
smpBuildPairingRsp - Build an SM Pairing Response
*/
extern bStatus_t smpBuildPairingRsp( smpPairingRsp_t* pPairingRsp, uint8* pBuf );
/*
smpBuildPairingReqRsp - Build an SM Pairing Request or Response
*/
extern bStatus_t smpBuildPairingReqRsp( uint8 opCode, smpPairingReq_t* pPairingReq, uint8* pBuf );
/*
smpParsePairingReq - Parse an SM Pairing Request
*/
extern bStatus_t smpParsePairingReq( uint8* pBuf, smpPairingReq_t* pPairingReq );
/*
smpParsePairingRsp - Parse an SM Pairing Response
*/
#define smpParsePairingRsp( a, b ) smpParsePairingReq( (a), (b) )
/*
smpBuildPairingConfirm - Build an SM Pairing Confirm
*/
extern bStatus_t smpBuildPairingConfirm( smpPairingConfirm_t* pPairingConfirm,
uint8* pBuf );
/*
smpParsePairingConfirm - Parse an SM Pairing Confirm
*/
extern bStatus_t smpParsePairingConfirm( uint8* pBuf,
smpPairingConfirm_t* pPairingConfirm );
/*
smpBuildPairingRandom - Build an SM Pairing Random
*/
extern bStatus_t smpBuildPairingRandom( smpPairingRandom_t* pPairingRandom,
uint8* pBuf );
/*
smpParsePairingRandom - Parse an SM Pairing Random
*/
extern bStatus_t smpParsePairingRandom( uint8* pBuf,
smpPairingRandom_t* pPairingRandom );
/*
smpBuildPairingFailed - Build an SM Pairing Failed
*/
extern bStatus_t smpBuildPairingFailed( smpPairingFailed_t* pPairingFailed,
uint8* pBuf );
/*
smpParsePairingFailed - Parse an SM Pairing Failed
*/
extern bStatus_t smpParsePairingFailed( uint8* pBuf,
smpPairingFailed_t* pPairingFailed );
/*
smpBuildEncInfo - Build an SM Encryption Information
*/
extern bStatus_t smpBuildEncInfo( smpEncInfo_t* pEncInfo, uint8* pBuf );
/*
smpParseEncInfo - Parse an SM Encryption Information
*/
extern bStatus_t smpParseEncInfo( uint8* buf, smpEncInfo_t* encInfo );
/*
smpBuildMasterID - Build an SM Master Identification
*/
extern bStatus_t smpBuildMasterID( smpMasterID_t* pMasterID, uint8* pBuf );
/*
smpParseMasterID - Parse an SM Master Identification
*/
extern bStatus_t smpParseMasterID( uint8* pBuf, smpMasterID_t* pMasterID );
/*
smpBuildIdentityInfo - Build an SM Identity Information
*/
extern bStatus_t smpBuildIdentityInfo( smpIdentityInfo_t* pIdInfo, uint8* pBuf );
/*
smpBuildIdentityAddrInfo - Build an SM Identity Address Information
*/
extern bStatus_t smpBuildIdentityAddrInfo( smpIdentityAddrInfo_t* pIdInfo, uint8* pBuf );
/*
smpParseIdentityInfo - Parse an SM Identity Information
*/
extern bStatus_t smpParseIdentityInfo( uint8* pBuf, smpIdentityInfo_t* pIdInfo );
/*
smpParseIdentityAddrInfo - Parse an SM Identity Address Information
*/
extern bStatus_t smpParseIdentityAddrInfo( uint8* pBuf, smpIdentityAddrInfo_t* pIdInfo );
/*
smpBuildSigningInfo - Build an SM Signing Information
*/
extern bStatus_t smpBuildSigningInfo( smpSigningInfo_t* pSigningInfo, uint8* pBuf );
/*
smpParseSigningInfo - Parse an SM Signing Information
*/
extern bStatus_t smpParseSigningInfo( uint8* pBuf, smpSigningInfo_t* pSigningInfo );
/*
smpBuildSecurityReq - Build an SM Slave Security Request
*/
extern bStatus_t smpBuildSecurityReq( smpSecurityReq_t* pSecReq, uint8* pBuf );
/*
smpParseSecurityReq - Parse an SM Slave Security Request
*/
extern bStatus_t smpParseSecurityReq( uint8* pBuf, smpSecurityReq_t* pSecReq );
/*
smSendSMMsg - Generic Send L2CAP SM message function
*/
extern bStatus_t smSendSMMsg( uint16 connHandle, uint8 bufLen, smpMsgs_t* pMsg, pfnSMBuildCmd_t buildFn );
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* SMP_H */
File diff suppressed because it is too large Load Diff
+281
View File
@@ -0,0 +1,281 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/**
@headerfile: bcomdef.h
<!--
Revised:
Revision:
Description: Type definitions and macros for BLE stack.
-->
**************************************************************************************************/
#ifndef BCOMDEF_H
#define BCOMDEF_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
INCLUDES
*/
#include "rom_sym_def.h"
#include "comdef.h"
#include "log.h"
//#define LOG_DEBUG(...)
//#define LOG(...)
//#define OM_LOG(...)
/*********************************************************************
CONSTANTS
*/
#define CTRL_CONFIG ( ADV_NCONN_CFG | ADV_CONN_CFG | SCAN_CFG | INIT_CFG )
//#if defined ( HOST_CONFIG )
// // Set the Controller Configuration
/*
// #if ( HOST_CONFIG == ( CENTRAL_CFG | PERIPHERAL_CFG ) )
// #define CTRL_CONFIG ( ADV_NCONN_CFG | ADV_CONN_CFG | SCAN_CFG | INIT_CFG )
// #elif ( HOST_CONFIG == ( CENTRAL_CFG | BROADCASTER_CFG ) )
// #define CTRL_CONFIG ( ADV_NCONN_CFG | SCAN_CFG | INIT_CFG )
// #elif ( HOST_CONFIG == ( PERIPHERAL_CFG | OBSERVER_CFG ) )
// #define CTRL_CONFIG ( ADV_NCONN_CFG | ADV_CONN_CFG | SCAN_CFG )
// #elif ( HOST_CONFIG == ( BROADCASTER_CFG | OBSERVER_CFG ) )
// #define CTRL_CONFIG ( ADV_NCONN_CFG | SCAN_CFG )
// #elif ( HOST_CONFIG == CENTRAL_CFG )
// #define CTRL_CONFIG ( SCAN_CFG | INIT_CFG )
// #elif ( HOST_CONFIG == PERIPHERAL_CFG )
// #define CTRL_CONFIG ( ADV_NCONN_CFG | ADV_CONN_CFG )
// #elif ( HOST_CONFIG == OBSERVER_CFG )
// #define CTRL_CONFIG SCAN_CFG
// #elif ( HOST_CONFIG == BROADCASTER_CFG )
// #define CTRL_CONFIG ADV_NCONN_CFG
// #else
// #error "Build Configuration Error: Invalid Host Role!"
// #endif
//#else
// // Controller Sanity Check: Stop build when no configuration is defined.
// #if !defined( CTRL_CONFIG ) || !( CTRL_CONFIG & ( ADV_NCONN_CFG | \
// ADV_CONN_CFG | \
// SCAN_CFG | \
// INIT_CFG ) )
// #error "Build Configuration Error: At least one Controller build component required!"
// #endif // no Controller build components defined
//#endif
*/
#if !defined ( MAX_NUM_LL_CONN )
#if ( CTRL_CONFIG & INIT_CFG )
#define MAX_NUM_LL_CONN 8
#elif ( !( CTRL_CONFIG & INIT_CFG ) && ( CTRL_CONFIG & ADV_CONN_CFG ) )
#define MAX_NUM_LL_CONN 1
#else // no connection needed
#define MAX_NUM_LL_CONN 0
#endif // CTRL_CONFIG=INIT_CFG
#endif // !MAX_NUM_LL_CONN
#define MAX_NUM_LL_CONN_ROM_LIMT 16 //hard code for BBB ROM define
#if (MAX_NUM_LL_CONN_ROM_LIMT<MAX_NUM_LL_CONN)
#warning "MAX_NUM_LL_CONN > MAX_NUM_LL_CONN_ROM"
#endif
/** @defgroup BLE_COMMON_DEFINES BLE Common Defines
@{
*/
//! Default Public and Random Address Length
#define B_ADDR_LEN 6
//! Default key length
#define KEYLEN 16
//! BLE Channel Map length
#define B_CHANNEL_MAP_LEN 5
//! BLE Event mask length
#define B_EVENT_MASK_LEN 8
//! BLE Local Name length
#define B_LOCAL_NAME_LEN 248
//! BLE Maximum Advertising Packet Length
#define B_MAX_ADV_LEN 31
#define B_MAX_EXT_ADV_LEN 229
#define B_MAX_PERIOD_ADV_LEN 247
// 2020-01-14 AOA/AOD IQ Sample LEN
#define B_MAX_IQ_LEN 0x52
//! BLE Random Number Size
#define B_RANDOM_NUM_SIZE 8
//! BLE Feature Supported length
#define B_FEATURE_SUPPORT_LENGTH 8
/** @defgroup BLE_STATUS_VALUES BLE Default BLE Status Values
returned as bStatus_t
@{
*/
#define bleInvalidTaskID INVALID_TASK //!< Task ID isn't setup properly
#define bleNotReady 0x10 //!< Not ready to perform task
#define bleAlreadyInRequestedMode 0x11 //!< Already performing that task
#define bleIncorrectMode 0x12 //!< Not setup properly to perform that task
#define bleMemAllocError 0x13 //!< Memory allocation error occurred
#define bleNotConnected 0x14 //!< Can't perform function when not in a connection
#define bleNoResources 0x15 //!< There are no resource available
#define blePending 0x16 //!< Waiting
#define bleTimeout 0x17 //!< Timed out performing function
#define bleInvalidRange 0x18 //!< A parameter is out of range
#define bleLinkEncrypted 0x19 //!< The link is already encrypted
#define bleProcedureComplete 0x1A //!< The Procedure is completed
// GAP Status Return Values - returned as bStatus_t
#define bleGAPUserCanceled 0x30 //!< The user canceled the task
#define bleGAPConnNotAcceptable 0x31 //!< The connection was not accepted
#define bleGAPBondRejected 0x32 //!< The bound information was rejected.
// ATT Status Return Values - returned as bStatus_t
#define bleInvalidPDU 0x40 //!< The attribute PDU is invalid
#define bleInsufficientAuthen 0x41 //!< The attribute has insufficient authentication
#define bleInsufficientEncrypt 0x42 //!< The attribute has insufficient encryption
#define bleInsufficientKeySize 0x43 //!< The attribute has insufficient encryption key size
// L2CAP Status Return Values - returned as bStatus_t
#define INVALID_TASK_ID 0xFF //!< Task ID isn't setup properly
/** @} End BLE_STATUS_VALUES */
/** @defgroup BLE_NV_IDS BLE Non-volatile IDs
@{
*/
// Device NV Items - Range 0 - 0x1F
#define BLE_NVID_IRK 0x02 //!< The Device's IRK
#define BLE_NVID_CSRK 0x03 //!< The Device's CSRK
#define BLE_NVID_SIGNCOUNTER 0x04 //!< The Device's Sign Counter
// Bonding NV Items - Range 0x20 - 0x5F - This allows for 10 bondings
#define BLE_NVID_GAP_BOND_START 0x20 //!< Start of the GAP Bond Manager's NV IDs
#define BLE_NVID_GAP_BOND_END 0x5f //!< End of the GAP Bond Manager's NV IDs Range
// GATT Configuration NV Items - Range 0x70 - 0x79 - This must match the number of Bonding entries
#define BLE_NVID_GATT_CFG_START 0x70 //!< Start of the GATT Configuration NV IDs
#define BLE_NVID_GATT_CFG_END 0x79 //!< End of the GATT Configuration NV IDs
/** @} End BLE_NV_IDS */
/*********************************************************************
BLE OSAL GAP GLOBAL Events
*/
#define GAP_EVENT_SIGN_COUNTER_CHANGED 0x4000 //!< The device level sign counter changed
/** @defgroup BLE_MSG_IDS BLE OSAL Message ID Events
Reserved Message ID Event Values:<BR>
0xC0 - Key Presses<BR>
0xE0 to 0xFC - App<BR>
@{
*/
// GAP - Messages IDs (0xD0 - 0xDF)
#define GAP_MSG_EVENT 0xD0 //!< Incoming GAP message
// SM - Messages IDs (0xC1 - 0xCF)
#define SM_NEW_RAND_KEY_EVENT 0xC1 //!< New Rand Key Event message
// GATT - Messages IDs (0xB0 - 0xBF)
#define GATT_MSG_EVENT 0xB0 //!< Incoming GATT message
#define GATT_SERV_MSG_EVENT 0xB1 //!< Incoming GATT Serv App message
// L2CAP - Messages IDs (0xA0 - 0xAF)
#define L2CAP_DATA_EVENT 0xA0 //!< Incoming data on a channel
#define L2CAP_SIGNAL_EVENT 0xA2 //!< Incoming Signaling message
// HCI - Messages IDs (0x90 - 0x9F)
#define HCI_DATA_EVENT 0x90 //!< HCI Data Event message
#define HCI_GAP_EVENT_EVENT 0x91 //!< GAP Event message
#define HCI_SMP_EVENT_EVENT 0x92 //!< SMP Event message
#define HCI_EXT_CMD_EVENT 0x93 //!< HCI Extended Command Event message
/** @} End BLE_MSG_IDS */
/*********************************************************************
TYPEDEFS
*/
//! BLE Generic Status return: @ref BLE_STATUS_VALUES
typedef Status_t bStatus_t;
/** @} End GAP_MSG_EVENT_DEFINES */
/*********************************************************************
System Events
*/
/*********************************************************************
Global System Messages
*/
/*********************************************************************
MACROS
*/
#define TI_BASE_UUID_128( uuid ) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB0, \
0x00, 0x40, 0x51, 0x04, LO_UINT16( uuid ), HI_UINT16( uuid ), 0x00, 0xF0
/*********************************************************************
GLOBAL VARIABLES
*/
/*********************************************************************
FUNCTIONS
*/
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* BCOMDEF_H */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,167 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/**************************************************************************************************
Filename: gatt_uuid.h
Revised:
Revision:
Description: This file contains Generic Attribute Profile (GATT)
UUID types.
**************************************************************************************************/
#ifndef GATT_UUID_H
#define GATT_UUID_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
INCLUDES
*/
/*********************************************************************
CONSTANTS
*/
/*
WARNING: The 16-bit UUIDs are assigned by the Bluetooth SIG and published
in the Bluetooth Assigned Numbers page. Do not change these values.
Changing them will cause Bluetooth interoperability issues.
*/
/**
GATT Services
*/
#define GAP_SERVICE_UUID 0x1800 // Generic Access Profile
#define GATT_SERVICE_UUID 0x1801 // Generic Attribute Profile
/**
GATT Declarations
*/
#define GATT_PRIMARY_SERVICE_UUID 0x2800 // Primary Service
#define GATT_SECONDARY_SERVICE_UUID 0x2801 // Secondary Service
#define GATT_INCLUDE_UUID 0x2802 // Include
#define GATT_CHARACTER_UUID 0x2803 // Characteristic
/**
GATT Descriptors
*/
#define GATT_CHAR_EXT_PROPS_UUID 0x2900 // Characteristic Extended Properties
#define GATT_CHAR_USER_DESC_UUID 0x2901 // Characteristic User Description
#define GATT_CLIENT_CHAR_CFG_UUID 0x2902 // Client Characteristic Configuration
#define GATT_SERV_CHAR_CFG_UUID 0x2903 // Server Characteristic Configuration
#define GATT_CHAR_FORMAT_UUID 0x2904 // Characteristic Presentation Format
#define GATT_CHAR_AGG_FORMAT_UUID 0x2905 // Characteristic Aggregate Format
#define GATT_VALID_RANGE_UUID 0x2906 // Valid Range
#define GATT_EXT_REPORT_REF_UUID 0x2907 // External Report Reference Descriptor
#define GATT_REPORT_REF_UUID 0x2908 // Report Reference Descriptor
/**
GATT Characteristics
*/
#define DEVICE_NAME_UUID 0x2A00 // Device Name
#define APPEARANCE_UUID 0x2A01 // Appearance
#define PERI_PRIVACY_FLAG_UUID 0x2A02 // Peripheral Privacy Flag
#define RECONNECT_ADDR_UUID 0x2A03 // Reconnection Address
#define PERI_CONN_PARAM_UUID 0x2A04 // Peripheral Preferred Connection Parameters
#define SERVICE_CHANGED_UUID 0x2A05 // Service Changed
/*********************************************************************
MACROS
*/
/*********************************************************************
TYPEDEFS
*/
/*********************************************************************
VARIABLES
*/
/**
GATT Services
*/
extern CONST uint8 gapServiceUUID[];
extern CONST uint8 gattServiceUUID[];
/**
GATT Attribute Types
*/
extern CONST uint8 primaryServiceUUID[];
extern CONST uint8 secondaryServiceUUID[];
extern CONST uint8 includeUUID[];
extern CONST uint8 characterUUID[];
/**
GATT Characteristic Descriptors
*/
extern CONST uint8 charExtPropsUUID[];
extern CONST uint8 charUserDescUUID[];
extern CONST uint8 clientCharCfgUUID[];
extern CONST uint8 servCharCfgUUID[];
extern CONST uint8 charFormatUUID[];
extern CONST uint8 charAggFormatUUID[];
extern CONST uint8 validRangeUUID[];
extern CONST uint8 extReportRefUUID[];
extern CONST uint8 reportRefUUID[];
/**
GATT Characteristic Types
*/
extern CONST uint8 deviceNameUUID[];
extern CONST uint8 appearanceUUID[];
extern CONST uint8 periPrivacyFlagUUID[];
extern CONST uint8 reconnectAddrUUID[];
extern CONST uint8 periConnParamUUID[];
extern CONST uint8 serviceChangedUUID[];
extern CONST uint8 manuNameUUID[];
extern CONST uint8 serialNumUUID[];
extern CONST uint8 manuAddrUUID[];
/*********************************************************************
FUNCTIONS
*/
extern const uint8* GATT_FindUUIDRec( const uint8* pUUID, uint8 len );
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* GATT_UUID_H */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+390
View File
@@ -0,0 +1,390 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/**
@headerfile: sm.h
$Date:
$Revision:
@mainpage BLE SM API
This file contains the interface to the SM.
*/
#ifndef SM_H
#define SM_H
#ifdef __cplusplus
extern "C"
{
#endif
/* -------------------------------------------------------------------
INCLUDES
*/
#include "bcomdef.h"
#include "OSAL.h"
/* -------------------------------------------------------------------
MACROS
*/
/* -------------------------------------------------------------------
CONSTANTS
*/
/** @defgroup SM_IO_CAP_DEFINES SM I/O Capabilities
@{
*/
#define DISPLAY_ONLY 0x00 //!< Display Only Device
#define DISPLAY_YES_NO 0x01 //!< Display and Yes and No Capable
#define KEYBOARD_ONLY 0x02 //!< Keyboard Only
#define NO_INPUT_NO_OUTPUT 0x03 //!< No Display or Input Device
#define KEYBOARD_DISPLAY 0x04 //!< Both Keyboard and Display Capable
/** @} End SM_IO_CAP_DEFINES */
#define SM_AUTH_MITM_MASK(a) (((a) & 0x04) >> 2)
/** @defgroup SM_PASSKEY_TYPE_DEFINES SM Passkey Types (Bit Masks)
@{
*/
#define SM_PASSKEY_TYPE_INPUT 0x01 //!< Input the passkey
#define SM_PASSKEY_TYPE_DISPLAY 0x02 //!< Display the passkey
/** @} End SM_PASSKEY_TYPE_DEFINES */
/** @defgroup SM_BONDING_FLAGS_DEFINES SM AuthReq Bonding Flags
Bonding flags 0x02 and 0x03 are reserved.
@{
*/
#define SM_AUTH_REQ_NO_BONDING 0x00 //!< No bonding
#define SM_AUTH_REQ_BONDING 0x01 //!< Bonding
/** @} End SM_BONDING_FLAGS_DEFINES */
#define PASSKEY_LEN 6 //! Passkey Character Length (ASCII Characters)
#define SM_AUTH_STATE_CT2 0x20
#define SM_AUTH_STATE_KEYPRESS 0x10
#define SM_AUTH_STATE_SC 0x08
#define SM_AUTH_STATE_AUTHENTICATED 0x04 //! Authenticate requested
#define SM_AUTH_STATE_BONDING 0x01 //! Bonding requested
/* -------------------------------------------------------------------
General TYPEDEFS
*/
/**
SM_NEW_RAND_KEY_EVENT message format. This message is sent to the
requesting task.
*/
typedef struct
{
osal_event_hdr_t hdr; //!< SM_NEW_RAND_KEY_EVENT and status
uint8 newKey[KEYLEN]; //!< New key value - if status is SUCCESS
} smNewRandKeyEvent_t;
/**
Key Distribution field - True or False fields
*/
typedef struct
{
unsigned int sEncKey:1; //!< Set to distribute slave encryption key
unsigned int sIdKey:1; //!< Set to distribute slave identity key
unsigned int sSign:1; //!< Set to distribute slave signing key
unsigned int sReserved:5; // bug fixed 2018-11-26, reserved bits should be saved for upward compatibility
unsigned int mEncKey:1; //!< Set to distribute master encryption key
unsigned int mIdKey:1; //!< Set to distribute master identity key
unsigned int mSign:1; //!< Set to distribute master signing key
unsigned int mReserved:5; // bug fixed 2018-11-26, reserved bits should be saved for upward compatibility
} keyDist_t;
/**
Link Security Requirements
*/
typedef struct
{
uint8 ioCaps; //!< I/O Capabilities (ie.
uint8 oobAvailable; //!< True if Out-of-band key available
uint8 oob[KEYLEN]; //!< Out-Of-Bounds key
uint8 authReq; //!< Authentication Requirements
keyDist_t keyDist; //!< Key Distribution mask
uint8 maxEncKeySize; //!< Maximum Encryption Key size (7-16 bytes)
} smLinkSecurityReq_t;
/**
Link Security Information
*/
typedef struct
{
uint8 ltk[KEYLEN]; //!< Long Term Key (LTK)
uint16 div; //!< LTK Diversifier
uint8 rand[B_RANDOM_NUM_SIZE]; //!< LTK random number
uint8 keySize; //!< LTK Key Size (7-16 bytes)
} smSecurityInfo_t;
/**
Link Identity Information
*/
typedef struct
{
uint8 irk[KEYLEN]; //!< Identity Resolving Key (IRK)
uint8 bd_addr[B_ADDR_LEN]; //!< The advertiser may set this to zeroes to not disclose its BD_ADDR (public address).
} smIdentityInfo_t;
/**
Signing Information
*/
typedef struct
{
uint8 srk[KEYLEN]; //!< Signature Resolving Key (CSRK)
uint32 signCounter; //!< Sign Counter
} smSigningInfo_t;
/**
Pairing Request & Response - authReq field
*/
typedef struct
{
unsigned int bonding:2; //!< Bonding flags
unsigned int mitm:1; //!< Man-In-The-Middle (MITM)
unsigned int reserved:5; //!< Reserved - don't use
} authReq_t;
/* -------------------------------------------------------------------
GLOBAL VARIABLES
*/
/**
@defgroup SM_API Security Manager API Functions
@{
*/
/* -------------------------------------------------------------------
FUNCTIONS - MASTER API - Only use these in a master device
*/
/**
@brief Initialize SM Initiator on a master device.
@return SUCCESS
*/
extern bStatus_t SM_InitiatorInit( void );
/**
@brief Start the pairing process. This function is also
called if the device is already bound.
NOTE: Only one pairing process at a time per device.
@param initiator - TRUE to start pairing as Initiator.
@param taskID - task ID to send results.
@param connectionHandle - Link's connection handle
@param pSecReqs - Security parameters for pairing
@return SUCCESS,<BR>
INVALIDPARAMETER,<BR>
bleAlreadyInRequestedMode
*/
extern bStatus_t SM_StartPairing( uint8 initiator,
uint8 taskID,
uint16 connectionHandle,
smLinkSecurityReq_t* pSecReqs );
/**
@brief Send Start Encrypt through HCI
@param connHandle - Connection Handle
@param pLTK - pointer to 16 byte lkt
@param div - div or ediv
@param pRandNum - pointer to 8 byte random number
@param keyLen - length of LTK (bytes)
@return SUCCESS,<BR>
INVALIDPARAMETER,<BR>
other from HCI/LL
*/
extern bStatus_t SM_StartEncryption( uint16 connHandle, uint8* pLTK,
uint16 div, uint8* pRandNum, uint8 keyLen );
/* -------------------------------------------------------------------
FUNCTIONS - SLAVE API - Only use these in a slave device
*/
/**
@brief Initialize SM Responder on a slave device.
@return SUCCESS
*/
extern bStatus_t SM_ResponderInit( void );
/* -------------------------------------------------------------------
FUNCTIONS - GENERAL API - both master and slave
*/
/**
@brief Generate a key with a random value.
@param taskID - task ID to send results.
@return SUCCESS,<BR>
bleNotReady,<BR>
bleMemAllocError,<BR>
FAILURE
*/
extern bStatus_t SM_NewRandKey( uint8 taskID );
/**
@brief Calculate a new Private Resolvable address.
@param pIRK - Identity Root Key.
@param pNewAddr - pointer to place to put new calc'd address
@return SUCCESS - if started,<BR>
INVALIDPARAMETER
*/
extern bStatus_t SM_CalcRandomAddr( uint8* pIRK, uint8* pNewAddr );
/**
@brief Resolve a Private Resolveable Address.
@param pIRK - pointer to the IRK
@param pAddr - pointer to the random address
@return SUCCESS - match,<BR>
FAILURE - don't match,<BR>
INVALIDPARAMETER - parameters invalid
*/
extern bStatus_t SM_ResolveRandomAddrs( uint8* pIRK, uint8* pAddr );
/**
@brief Encrypt the plain text data with the key..
@param pKey - key data
@param pPlainText - Plain text data
@param pResult - place to put the encrypted result
@return SUCCESS - if started,<BR>
INVALIDPARAMETER - one of the parameters are NULL,<BR>
bleAlreadyInRequestedMode,<BR>
bleMemAllocError
*/
extern bStatus_t SM_Encrypt( uint8* pKey, uint8* pPlainText, uint8* pResult );
/**
@brief Generate an outgoing Authentication Signature.
@param pData - message data
@param len - length of pData
@param pAuthenSig - place to put new signature
@return SUCCESS - signature authentication generated,<BR>
INVALIDPARAMETER - pData or pAuthenSig is NULL,<BR>
bleMemAllocError
*/
extern bStatus_t SM_GenerateAuthenSig( uint8* pData, uint8 len, uint8* pAuthenSig );
/**
@brief Verify an Authentication Signature.
@param connHandle - connection to verify against.
@param authentication - TRUE if requires an authenticated CSRK, FALSE if not
@param pData - message data
@param len - length of pData
@param pAuthenSig - message signature to verify
@return SUCCESS - signature authentication verified,<BR>
FAILURE - if not verified,<BR>
bleNotConnected - Connection not found,<BR>
INVALIDPARAMETER - pData or pAuthenSig is NULL, or signCounter is invalid,<BR>
bleMemAllocError
*/
extern bStatus_t SM_VerifyAuthenSig( uint16 connHandle,
uint8 authentication,
uint8* pData,
uint16 len,
uint8* pAuthenSig );
/**
@brief Update the passkey for the pairing process.
@param pPasskey - pointer to the 6 digit passkey
@param connectionHandle - connection handle to link.
@return SUCCESS,<BR>
bleIncorrectMode - Not pairing,<BR>
INVALIDPARAMETER - link is incorrect
*/
extern bStatus_t SM_PasskeyUpdate( uint8* pPasskey, uint16 connectionHandle );
/**
@} End SM_API
*/
/* -------------------------------------------------------------------
TASK API - These functions must only be called OSAL.
*/
/**
@internal
@brief SM Task Initialization Function.
@param taskID - SM task ID.
@return void
*/
extern void SM_Init( uint8 task_id );
/**
@internal
@brief SM Task event processing function.
@param taskID - SM task ID
@param events - SM events.
@return events not processed
*/
extern uint16 SM_ProcessEvent( uint8 task_id, uint16 events );
/* -------------------------------------------------------------------
-------------------------------------------------------------------*/
#ifdef __cplusplus
}
#endif
#endif /* SM_H */
+139
View File
@@ -0,0 +1,139 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/**************************************************************************************************
Filename: bus_dev.h
Revised:
Revision:
Description: This file contains the SoC MCU relate definitions
**************************************************************************************************/
#ifndef __BUS_DEV_H__
#define __BUS_DEV_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "mcu.h"
enum
{
RSTC_COLD_UP = 0,
RSTC_WARM_UP = 1,
RSTC_OFF_MODE = 2,
RSTC_WAKE_IO = 3,
RSTC_WAKE_RTC = 4,
RSTC_WARM_NDWC = 5 //user mode, no dwc
};
/* ------------------------- Interrupt Number Definition ------------------------ */
typedef enum IRQn
{
/* ------------------- Cortex-M0 Processor Exceptions Numbers ------------------- */
NonMaskableInt_IRQn = -14, /* 2 Non Maskable Interrupt */
HardFault_IRQn = -13, /* 3 HardFault Interrupt */
SVCall_IRQn = -5, /* 11 SV Call Interrupt */
PendSV_IRQn = -2, /* 14 Pend SV Interrupt */
SysTick_IRQn = -1, /* 15 System Tick Interrupt */
/* ---------------------- PHY BUMBEE M0 Interrupt Numbers --------------------- */
BB_IRQn = 4, /* Base band Interrupt */
KSCAN_IRQn = 5, /* Key scan Interrupt */
RTC_IRQn = 6, /* RTC Timer Interrupt */
WDT_IRQn = 10, /* Watchdog Timer Interrupt */
UART0_IRQn = 11, /* UART0 Interrupt */
I2C0_IRQn = 12, /* I2C0 Interrupt */
I2C1_IRQn = 13, /* I2C1 Interrupt */
SPI0_IRQn = 14, /* SPI0 Interrupt */
SPI1_IRQn = 15, /* SPI1 Interrupt */
GPIO_IRQn = 16, /* GPIO Interrupt */
UART1_IRQn = 17, /* UART1 Interrupt */
SPIF_IRQn = 18, /* SPIF Interrupt */
DMAC_IRQn = 19, /* DMAC Interrupt */
TIM1_IRQn = 20, /* Timer1 Interrupt */
TIM2_IRQn = 21, /* Timer2 Interrupt */
TIM3_IRQn = 22, /* Timer3 Interrupt */
TIM4_IRQn = 23, /* Timer4 Interrupt */
TIM5_IRQn = 24, /* Timer5 Interrupt */
TIM6_IRQn = 25, /* Timer6 Interrupt */
AES_IRQn = 28, /* AES Interrupt */
ADCC_IRQn = 29, /* ADC Interrupt */
QDEC_IRQn = 30, /* QDEC Interrupt */
RNG_IRQn = 31 /* RNG Interrupt */
} IRQn_Type;
#ifdef __cplusplus
#define __I volatile /*!< Defines 'read only' permissions */
#else
#define __I volatile const /*!< Defines 'read only' permissions */
#endif
#define __O volatile /*!< Defines 'write only' permissions */
#define __IO volatile /*!< Defines 'read / write' permissions */
/* following defines should be used for structure members */
#define __IM volatile const /*! Defines 'read only' structure member permissions */
#define __OM volatile /*! Defines 'write only' structure member permissions */
#define __IOM volatile /*! Defines 'read / write' structure member permissions */
#define NVIC_DisableIRQ(irqid) up_disable_irq(irqid)
#define NVIC_EnableIRQ(irqid) up_enable_irq(irqid)
#define NVIC_SetPriority(i,p)
#if 0
#if (PHY_MCU_TYPE == MCU_BUMBEE_M0)
#define ATTRIBUTE_ISR
#include "core_bumbee_m0.h"
#endif
#if(PHY_MCU_TYPE == MCU_BUMBEE_CK802)
#define ATTRIBUTE_ISR __attribute__((isr))
#include "core_802.h"
#endif
#endif //0
#if (PHY_MCU_TYPE == MCU_BUMBEE_M0 || PHY_MCU_TYPE == MCU_BUMBEE_CK802)
#include "mcu_phy_bumbee.h"
#elif ((PHY_MCU_TYPE == MCU_PRIME_A1) ||(PHY_MCU_TYPE == MCU_PRIME_A2))
#include "mcu_phy_prime.h"
#endif
#endif
+41
View File
@@ -0,0 +1,41 @@
/****************************************************************************
* arch/arm/src/phy62xx/chip.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __ARCH_ARM_SRC_PHY62XX_CHIP_H
#define __ARCH_ARM_SRC_PHY62XX_CHIP_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/* Include the chip capabilities file */
#include <arch/phy62xx/chip.h>
#define ARMV6M_PERIPHERAL_INTERRUPTS 32
/* Include the memory map file.
* Other chip hardware files should then include this file for the proper
* setup.
*/
#endif /* __ARCH_ARM_SRC_PHY62XX_CHIP_H */
+226
View File
@@ -0,0 +1,226 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
#include "clock.h"
#include "gpio.h"
//#include "global_config.h"
#include "error.h"
extern uint32_t hclk,pclk;
extern uint32_t osal_sys_tick;
void hal_clk_gate_enable(MODULE_e module)
{
if(module < MOD_CP_CPU)
{
AP_PCR->SW_CLK |= BIT(module);
}
else if(module < MOD_PCLK_CACHE)
{
AP_PCR->SW_CLK1 |= BIT(module-MOD_CP_CPU);
}
else if(module < MOD_USR0)
{
AP_PCR->CACHE_CLOCK_GATE |= BIT(module-MOD_PCLK_CACHE);
}
}
void hal_clk_gate_disable(MODULE_e module)
{
if(module < MOD_CP_CPU)
{
AP_PCR->SW_CLK &= ~(BIT(module));
}
else if(module < MOD_PCLK_CACHE)
{
AP_PCR->SW_CLK1 &= ~(BIT(module-MOD_CP_CPU));
}
else if(module < MOD_USR0)
{
AP_PCR->CACHE_CLOCK_GATE &= ~(BIT(module-MOD_PCLK_CACHE));
}
}
int hal_clk_gate_get(MODULE_e module)
{
if(module < MOD_CP_CPU)
{
return (AP_PCR->SW_CLK & BIT(module));
}
else if(module < MOD_PCLK_CACHE)
{
return (AP_PCR->SW_CLK1 & BIT(module-MOD_CP_CPU));
}
//else if(module < MOD_USR0)
else
{
return (AP_PCR->CACHE_CLOCK_GATE & BIT(module-MOD_PCLK_CACHE));
}
}
void hal_clk_get_modules_state(uint32_t* buff)
{
*buff = AP_PCR->SW_CLK;
*(buff+1) = AP_PCR->SW_CLK1;
*(buff+2) = AP_PCR->CACHE_CLOCK_GATE;
}
void hal_clk_reset(MODULE_e module)
{
if(module < MOD_CP_CPU)
{
if((module >= MOD_TIMER5) &&(module <= MOD_TIMER6))
{
AP_PCR->SW_RESET0 &= ~BIT(5);
AP_PCR->SW_RESET0 |= BIT(5);
}
else
{
AP_PCR->SW_RESET0 &= ~BIT(module);
AP_PCR->SW_RESET0 |= BIT(module);
}
}
else if(module < MOD_PCLK_CACHE)
{
if((module >= MOD_TIMER1) &&(module <= MOD_TIMER4))
{
AP_PCR->SW_RESET2 &= ~BIT(4);
AP_PCR->SW_RESET2 |= BIT(4);
}
else
{
AP_PCR->SW_RESET2 &= ~BIT(module-MOD_CP_CPU);
AP_PCR->SW_RESET2 |= BIT(module-MOD_CP_CPU);
}
}
else if(module < MOD_USR0)
{
AP_PCR->CACHE_RST &= ~BIT(1-(module-MOD_HCLK_CACHE));
AP_PCR->CACHE_RST |= BIT(1-(module-MOD_HCLK_CACHE));
}
}
void hal_rtc_clock_config(CLK32K_e clk32Mode)
{
if(clk32Mode == CLK_32K_RCOSC)
{
subWriteReg(&(AP_AON->PMCTL0),31,27,0x05);
subWriteReg(&(AP_AON->PMCTL2_0),16,7,0x3fb);
subWriteReg(&(AP_AON->PMCTL2_0),6,6,0x01);
//pGlobal_config[LL_SWITCH]|=RC32_TRACKINK_ALLOW|LL_RC32K_SEL;
}
else if(clk32Mode == CLK_32K_XTAL)
{
// P16 P17 for 32K XTAL input
hal_gpio_pull_set(P16,FLOATING);
hal_gpio_pull_set(P17,FLOATING);
subWriteReg(&(AP_AON->PMCTL2_0),9,8,0x03); //software control 32k_clk
subWriteReg(&(AP_AON->PMCTL2_0),6,6,0x00); //disable software control
subWriteReg(&(AP_AON->PMCTL0),31,27,0x16);
//pGlobal_config[LL_SWITCH]&=0xffffffee;
}
//ZQ 20200812 for rc32k wakeup
subWriteReg(&(AP_AON->PMCTL0),28,28,0x1);//turn on 32kxtal
subWriteReg(&(AP_AON->PMCTL1),18,17,0x0);// reduce 32kxtl bias current
}
uint32_t hal_systick(void)
{
return 10000;//osal_sys_tick;
}
uint32_t hal_ms_intv(uint32_t tick)
{
uint32_t diff = 0;
/*
if(osal_sys_tick < tick)
{
diff = 0xffffffff- tick;
diff = osal_sys_tick + diff;
}
else
{
diff = osal_sys_tick - tick;
}
*/
return diff*625/1000;
}
/**************************************************************************************
@fn WaitMs
@brief This function process for wait program msecond,use RTC
input parameters
@param uint32_t msecond: the msecond value
output parameters
@param None.
@return None.
**************************************************************************************/
void WaitMs(uint32_t msecond)
{
//WaitRTCCount((msecond<<15)/1000);
}
void WaitUs(uint32_t wtTime)
{
uint32_t T0,currTick,deltTick;
//T0 = read_current_time();
T0 =(TIME_BASE - ((AP_TIM3->CurrentCount) >> 2));
while(1)
{
currTick = (TIME_BASE - ((AP_TIM3->CurrentCount) >> 2));
deltTick = TIME_DELTA(currTick,T0);
if(deltTick>wtTime)
break;
}
}
void hal_system_soft_reset(void)
{
_HAL_CS_ALLOC_();
HAL_ENTER_CRITICAL_SECTION();
AP_PCR->SW_RESET1 = 0;
while(1);
}
+136
View File
@@ -0,0 +1,136 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
#ifndef _HAL_CLOCK_H
#define _HAL_CLOCK_H
#ifdef __cplusplus
extern "C" {
#endif
#include "types.h"
#include "bus_dev.h"
//#include "common.h"
typedef enum
{
CLK_32K_XTAL = 0,
CLK_32K_RCOSC = 1,
} CLK32K_e;
typedef enum
{
XTAL_16M = 0,
DBL_B_32M = 1,
DBL_32 = 2,
DLL_32M = 3,
} ClkSrc_e;
typedef enum _SYSCLK_SEL
{
SYS_CLK_RC_32M = 0,
SYS_CLK_DLL_32M = 1,
SYS_CLK_XTAL_16M = 2,
SYS_CLK_DLL_48M = 3,
SYS_CLK_DLL_64M = 4,
SYS_CLK_DLL_96M = 5,
SYS_CLK_8M = 6,
SYS_CLK_4M = 7,
SYS_CLK_NUM = 8,
} sysclk_t;
typedef enum
{
HCLK_CHANGE = 0,
AP_CLK_CHANGE = 1,
CP_CLK_CHANGE = 2,
} clk_update_Type_t;
typedef struct _clk_Evt_t
{
uint8_t flag;
} clk_Evt_t;
typedef void (*clk_Hdl_t)(clk_Evt_t* pev);
typedef struct _clk_Contex_t
{
bool enable;
clk_Hdl_t evt_handler;
} clk_Ctx_t;
#define CLAER_RTC_COUNT AP_AON->RTCCTL |= BIT(1)
#define RUN_RTC AP_AON->RTCCTL |= BIT(0)
#define STOP_RTC AP_AON->RTCCTL &= ~BIT(0)
#define hal_system_init clk_init
extern volatile uint32_t g_hclk;
#define clk_get_hclk() g_hclk
uint32_t clk_get_pclk(void);
void hal_clk_gate_enable(MODULE_e module);
void hal_clk_gate_disable(MODULE_e module);
int hal_clk_gate_get(MODULE_e module);
void hal_clk_get_modules_state(uint32_t* buff);
void hal_clk_reset(MODULE_e module);
void hal_clk_rf_config(ClkSrc_e sel);
void hal_clk_rxadc_config(ClkSrc_e sel);
bool hal_clk_set_pclk(uint32_t div);
int hal_clk_init(sysclk_t hclk_sel,clk_Hdl_t evt_handler);
void hal_rtc_clock_config(CLK32K_e clk32Mode);
uint32_t hal_systick(void);
uint32_t hal_ms_intv(uint32_t tick);
extern uint32_t rtc_get_counter(void);
void WaitMs(uint32_t msecond);
void WaitUs(uint32_t wtTime);
void hal_system_soft_reset(void);
extern int clk_init(sysclk_t h_system_clk_sel);
extern void WaitRTCCount(uint32_t rtcDelyCnt);
extern int clk_spif_ref_clk(sysclk_t spif_ref_sel);
extern uint32_t getMcuPrecisionCount(void);
#ifdef __cplusplus
}
#endif
#endif
+88
View File
@@ -0,0 +1,88 @@
#ifndef PHY_BUMBEE_M0_H
#define PHY_BUMBEE_M0_H
#ifdef __cplusplus
extern "C" {
#endif
/* ================================================================================ */
/* ================ Processor and Core Peripheral Section ================ */
/* ================================================================================ */
/* ------- Start of section using anonymous unions and disabling warnings ------- */
#if defined (__CC_ARM)
#pragma push
#pragma anon_unions
#elif defined (__ICCARM__)
#pragma language=extended
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc11-extensions"
#pragma clang diagnostic ignored "-Wreserved-id-macro"
#elif defined (__GNUC__)
/* anonymous unions are enabled by default */
#elif defined (__TMS470__)
/* anonymous unions are enabled by default */
#elif defined (__TASKING__)
#pragma warning 586
#elif defined (__CSMC__)
/* anonymous unions are enabled by default */
#else
#warning Not supported compiler type
#endif
/* -------- Configuration of the Cortex-M0 Processor and Core Peripherals ------- */
//#define __CM0_REV 0x0000U /* Core revision r0p0 */
//#define __MPU_PRESENT 0U /* MPU present or not */
//#define __VTOR_PRESENT 0U /* no VTOR present*/
#define __NVIC_PRIO_BITS 2U /* Number of Bits used for Priority Levels */
//#define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */
#include "core_cm0.h" /* Processor and core peripherals */
#include "system_ARMCM0.h" /* System Header */
#define NVIC_GetPendingIRQs() (NVIC->ISPR[0U])
#define NVIC_ClearPendingIRQs(icpr) (NVIC->ICPR[0U] = (unsigned int)icpr)
#define NVIC_SetPendingIRQs(ispr) (NVIC->ISPR[0U] = (unsigned int)ispr)
#define NVIC_GetEnableIRQs() (NVIC->ISER[0U])
#define NVIC_DisableIRQs(irqs) (NVIC->ICER[0U] = (unsigned int)irqs)
#define NVIC_EnableIRQs(iser) (NVIC->ISER[0U] = (unsigned int)iser)
#define NVIC_ClearWakeupIRQ(irqn)
#define NVIC_SetWakeupIRQ(irqn)
/* -------- End of section using anonymous unions and disabling warnings -------- */
#if defined (__CC_ARM)
#pragma pop
#elif defined (__ICCARM__)
/* leave anonymous unions enabled */
#elif (__ARMCC_VERSION >= 6010050)
#pragma clang diagnostic pop
#elif defined (__GNUC__)
/* anonymous unions are enabled by default */
#elif defined (__TMS470__)
/* anonymous unions are enabled by default */
#elif defined (__TASKING__)
#pragma warning restore
#elif defined (__CSMC__)
/* anonymous unions are enabled by default */
#else
#warning Not supported compiler type
#endif
#ifdef __cplusplus
}
#endif
#endif /* PHY_BUMBEE_M0 */
+106
View File
@@ -0,0 +1,106 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/*******************************************************************************
@file error.h
@brief Global error definition
@version 0.0
@date 11. Feb. 2018
@author Eagle.Lao
*******************************************************************************/
#ifndef _PPLUS_ERROR_H
#define _PPLUS_ERROR_H
#define PPlus_SUCCESS (0) /*Success*/
#define PPlus_ERR_FATAL (1) /*unrecoverable error*/
#define PPlus_ERR_INTERNAL (2) /*Internal Error*/
#define PPlus_ERR_NO_MEM (3) /*No Memory for operation*/
#define PPlus_ERR_NOT_FOUND (4) /*Not found*/
#define PPlus_ERR_NOT_SUPPORTED (5) /*Not supported*/
#define PPlus_ERR_INVALID_PARAM (6) /*Invalid Parameter*/
#define PPlus_ERR_INVALID_STATE (7) /*Invalid state, operation disallowed in this state*/
#define PPlus_ERR_INVALID_LENGTH (8) /*Invalid Length*/
#define PPlus_ERR_INVALID_FLAGS (9) /*Invalid Flags*/
#define PPlus_ERR_INVALID_DATA (10) /*Invalid Data*/
#define PPlus_ERR_DATA_SIZE (11) /*Data size exceeds limit*/
#define PPlus_ERR_DATA_ALIGN (12) /*Data alignment is not correct*/
#define PPlus_ERR_TIMEOUT (13) /*Operation timed out*/
#define PPlus_ERR_NULL (14) /*Null Pointer*/
#define PPlus_ERR_FORBIDDEN (15) /*Forbidden Operation*/
#define PPlus_ERR_INVALID_ADDR (16) /*Bad Memory Address*/
#define PPlus_ERR_BUSY (17) /*Busy*/
#define PPlus_ERR_NOT_REGISTED (18) /*not registed*/
#define PPlus_ERR_IO_CONFILCT (19) /*IO config error*/
#define PPlus_ERR_IO_FAIL (20) /*IO fail error*/
#define PPlus_ERR_NOT_IMPLEMENTED (22) /*Function is not provide now*/
#define PPlus_ERR_SPI_FLASH (23) /*spi falsh operation error*/
#define PPlus_ERR_UNINITIALIZED (24)
#define PPlus_ERR_FS_WRITE_FAILED (31)
#define PPlus_ERR_FS_CONTEXT (32)
#define PPlus_ERR_FS_FULL (33)
#define PPlus_ERR_FS_PARAMETER (34)
#define PPlus_ERR_FS_NOT_ENOUGH_SIZE (35)
#define PPlus_ERR_FS_EXIST_SAME_ID (36)
#define PPlus_ERR_FS_NOT_FIND_ID (37)
#define PPlus_ERR_FS_BUFFER_TOO_SMALL (38)
#define PPlus_ERR_FS_UNINITIALIZED (39)
#define PPlus_ERR_FS_HAVE_INITED (40)
#define PPlus_ERR_FS_IN_INT (41)
#define PPlus_ERR_FS_RESERVED_ERROR (42)
#define PPlus_ERR_VERSION (43)
#define PPlus_ERR_NO_DEV (44)
#define PPlus_ERR_SECURE_CRYPTO (50)
#define PPlus_ERR_ACCESS_REJECTED (51)
#define PPlus_ERR_BLE_NOT_READY (80) /*BLE not ready error*/
#define PPlus_ERR_BLE_BUSY (81) /*BLE operation failed becuase of busy*/
#define PPlus_ERR_BLE_FAIL (82) /*BLE operation failed*/
#define PPlus_ERR_OTA_INVALID_STATE (100) /*state machine error when OTA*/
#define PPlus_ERR_OTA_DATA_SIZE (101) /*data size is not correct*/
#define PPlus_ERR_OTA_CRC (102) /*bad checksum(crc)*/
#define PPlus_ERR_OTA_NO_APP (103) /*No application data*/
#define PPlus_ERR_OTA_BAD_DATA (104) /*bad application data*/
#define PPlus_ERR_OTA_UNKNOW_CMD (105) /*unknow command*/
#define PPlus_ERR_OTA_CRYPTO (106) /*crypto verify error*/
#define PPlus_ERR_KEY_VERIFY (107) /*security boot key verify fail*/
#define PPlus_ERR_DOUBLE_CONFIRM (108) /*security boot double key verify fail*/
#define PPlus_ERR_OTA_MIC (109) /*bad checksum(mic)*/
#endif
+306
View File
@@ -0,0 +1,306 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/*******************************************************************************
@file flash.c
@brief Contains all functions support for flash driver
@version 0.0
@date 27. Nov. 2017
@author qing.han
*******************************************************************************/
#include "rom_sym_def.h"
#include <string.h>
#include "types.h"
#include "flash.h"
#include "log.h"
#include "pwrmgr.h"
#include "error.h"
#define SPIF_WAIT_IDLE_CYC (32)
#define SPIF_STATUS_WAIT_IDLE(n) \
do \
{ \
while((AP_SPIF->fcmd &0x02)==0x02); \
{ \
volatile int delay_cycle = n; \
while (delay_cycle--){;} \
} \
while ((AP_SPIF->config & 0x80000000) == 0);\
} while (0);
#define HAL_CACHE_ENTER_BYPASS_SECTION() do{ \
_HAL_CS_ALLOC_();\
HAL_ENTER_CRITICAL_SECTION();\
AP_CACHE->CTRL0 = 0x02; \
AP_PCR->CACHE_RST = 0x02;\
AP_PCR->CACHE_BYPASS = 1; \
}while(0);
#define HAL_CACHE_EXIT_BYPASS_SECTION() do{ \
_HAL_CS_ALLOC_();\
HAL_ENTER_CRITICAL_SECTION();\
AP_CACHE->CTRL0 = 0x00;\
AP_PCR->CACHE_RST = 0x03;\
AP_PCR->CACHE_BYPASS = 0;\
HAL_EXIT_CRITICAL_SECTION();\
}while(0);
#define spif_wait_nobusy(flg, tout_ns, return_val) {if(_spif_wait_nobusy_x(flg, tout_ns)){if(return_val){ return return_val;}}}
static xflash_Ctx_t s_xflashCtx = {.spif_ref_clk=SYS_CLK_DLL_64M,.rd_instr=XFRD_FCMD_READ_DUAL};
chipMAddr_t g_chipMAddr;
static void hal_cache_tag_flush(void);
static void __RAMRUN hal_cache_tag_flush(void)
{
_HAL_CS_ALLOC_();
HAL_ENTER_CRITICAL_SECTION();
uint32_t cb = AP_PCR->CACHE_BYPASS;
volatile int dly = 8;
if(cb==0)
{
AP_PCR->CACHE_BYPASS = 1;
}
AP_CACHE->CTRL0 = 0x02;
while (dly--) {;};
AP_CACHE->CTRL0 = 0x03;
dly = 8;
while (dly--) {;};
AP_CACHE->CTRL0 = 0x00;
if(cb==0)
{
AP_PCR->CACHE_BYPASS = 0;
}
HAL_EXIT_CRITICAL_SECTION();
}
static uint8_t __RAMRUN _spif_read_status_reg_x(void)
{
uint8_t status;
spif_cmd(FCMD_RDST, 0, 2, 0, 0, 0);
SPIF_STATUS_WAIT_IDLE(SPIF_WAIT_IDLE_CYC);
spif_rddata(&status, 1);
return status;
}
static int __RAMRUN _spif_wait_nobusy_x(uint8_t flg, uint32_t tout_ns)
{
uint8_t status;
volatile int tout = (int )(tout_ns);
for(; tout ; tout --)
{
status = _spif_read_status_reg_x();
if((status & flg) == 0)
return PPlus_SUCCESS;
//insert polling interval
//5*32us
WaitRTCCount(5);
}
return PPlus_ERR_BUSY;
}
void __RAMRUN hal_spif_init(void)
{
uint32_t tmp = 0;
//*(volatile uint32_t *) 0x4000c800 = 0x80080081; //enable qspi(divisor 4)
*(volatile uint32_t *) 0x4000c804 = 0x801003B; // Device Read Instruction Register , Dual IO
return PPlus_SUCCESS;
#if 0
//*(volatile uint32_t *) 0x4000c800 = 0x80280081; //enable qspi(divisor 12)
//return 0;
*(volatile uint32_t *) 0x4000c890 = 0x6000001; // config flash: WREN 06h
//*(volatile uint32_t *) 0x4000c890 = 0x50000001; // config flash: Write Enable for Volatile Status Reg 50h
*(volatile uint32_t *) 0x4000c8a8 = 0x200; // config Flash Command Write Data Register (Lower)
*(volatile uint32_t *) 0x4000c890 = 0x1009001; // config flash: write status reg 01h QE=1
while ((tmp&2)!= 0x2) // QE = 1 ?
{
*(int *) 0x4000c890 = 0x35900001; // Read Status Reg-2 35h
tmp = *(uint32_t *) 0x4000c8a0;
}
*(volatile uint32_t *) 0x4000c828 = 0x10; // M5-4 Mode Bit Configuration Register
*(volatile uint32_t *) 0x4000c804 = 0x41220EB; // Device Read Instruction Register
return PPlus_SUCCESS;
//load defualt configure
while(1){//wait spif idle
if(AP_SPIF->config &BIT(31)){
WaitUs(1);
break;
}
}
#endif
}
void __RAMRUN hal_cache_init(void)
{
volatile int dly=100;
hal_spif_init();
//clock gate
hal_clk_gate_enable(MOD_HCLK_CACHE);
hal_clk_gate_enable(MOD_PCLK_CACHE);
//cache rst ahp
AP_PCR->CACHE_RST=0x02;
while(dly--) {};
AP_PCR->CACHE_RST=0x03;
hal_cache_tag_flush();
//cache enable
AP_PCR->CACHE_BYPASS = 0;
}
static void __RAMRUN hw_spif_cache_config(void)
{
spif_config(s_xflashCtx.spif_ref_clk,/*div*/1,s_xflashCtx.rd_instr,0,0);
AP_SPIF->wr_completion_ctrl=0xff010005;//set longest polling interval
NVIC_DisableIRQ(SPIF_IRQn);
NVIC_SetPriority((IRQn_Type)SPIF_IRQn, IRQ_PRIO_HAL);
hal_cache_init();
}
int __RAMRUN hal_spif_cache_init(void)//xflash_Ctx_t cfg)
{
//memset(&(s_xflashCtx), 0, sizeof(s_xflashCtx));
//memcpy(&(s_xflashCtx), &cfg, sizeof(s_xflashCtx));
hw_spif_cache_config();
hal_pwrmgr_register(MOD_SPIF, NULL, hw_spif_cache_config);
return PPlus_SUCCESS;
}
int __RAMRUN hal_flash_read(uint32_t addr, uint8_t* data, uint32_t size)
{
volatile uint8_t* u8_spif_addr = (volatile uint8_t*)((addr & 0x7ffff) | FLASH_BASE_ADDR);
uint32_t cb = AP_PCR->CACHE_BYPASS;
#if(SPIF_FLASH_SIZE==FLASH_SIZE_1MB)
uint32_t remap = addr & 0xf80000;
if (remap)
{
AP_SPIF->remap = remap;
AP_SPIF->config |= 0x10000;
}
#endif
//read flash addr direct access
//bypass cache
HAL_CACHE_ENTER_BYPASS_SECTION();
for(int i=0; i<size; i++)
data[i]=u8_spif_addr[i];
//bypass cache
HAL_CACHE_EXIT_BYPASS_SECTION();
#if(SPIF_FLASH_SIZE==FLASH_SIZE_1MB)
if (remap)
{
AP_SPIF->remap = 0;
AP_SPIF->config &= ~0x10000ul;
}
#endif
return PPlus_SUCCESS;
}
int __RAMRUN hal_flash_write(uint32_t addr, uint8_t* data, uint32_t size)
{
uint8_t retval;
HAL_CACHE_ENTER_BYPASS_SECTION();
SPIF_STATUS_WAIT_IDLE(SPIF_WAIT_IDLE_CYC);
spif_wait_nobusy(SFLG_WIP, SPIF_TIMEOUT, PPlus_ERR_BUSY);
retval = spif_write(addr,data,size);
SPIF_STATUS_WAIT_IDLE(SPIF_WAIT_IDLE_CYC);
spif_wait_nobusy(SFLG_WIP, SPIF_TIMEOUT, PPlus_ERR_BUSY);
HAL_CACHE_EXIT_BYPASS_SECTION();
return retval;
}
int __RAMRUN hal_flash_erase_sector(unsigned int addr)
{
uint8_t retval;
uint32_t cb = AP_PCR->CACHE_BYPASS;
HAL_CACHE_ENTER_BYPASS_SECTION();
SPIF_STATUS_WAIT_IDLE(SPIF_WAIT_IDLE_CYC);
spif_wait_nobusy(SFLG_WIP, SPIF_TIMEOUT, PPlus_ERR_BUSY);
retval = spif_erase_sector(addr);
SPIF_STATUS_WAIT_IDLE(SPIF_WAIT_IDLE_CYC);
spif_wait_nobusy(SFLG_WELWIP, SPIF_TIMEOUT, PPlus_ERR_BUSY);
HAL_CACHE_EXIT_BYPASS_SECTION();
if(cb == 0)
{
hal_cache_tag_flush();
}
return retval;
}
int __RAMRUN flash_write_word(unsigned int offset, uint32_t value)
{
uint32_t temp = value;
offset &= 0x00ffffff;
return (hal_flash_write (offset, (uint8_t*) &temp, 4));
}
+174
View File
@@ -0,0 +1,174 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/*******************************************************************************
@file flash.h
@brief Contains all functions support for flash driver
@version 0.0
@date 27. Nov. 2017
@author qing.han
*******************************************************************************/
#ifndef _FLASH_H_
#define _FLASH_H_
#include "rom_sym_def.h"
#include "clock.h"
#include "types.h"
#include "gpio.h"
#define CHIP_MADDR_LEN 6
#define CHIP_ID_FLASH_ADDRESS 0x11000800
#define CHIP_MADDR_FLASH_ADDRESS (CHIP_ID_FLASH_ADDRESS+CHIP_ID_LENGTH*4)
#define FLASH_SIZE_256KB (0)
#define FLASH_SIZE_512KB (1)
#define FLASH_SIZE_1MB (2)
#define SPIF_FLASH_SIZE FLASH_SIZE_512KB
#define SPIF_TIMEOUT (0x7ffffff)//1000000
#define SFLG_WIP 1
#define SFLG_WEL 2
#define SFLG_WELWIP 3
//define flash ucds
#define FLASH_BASE_ADDR (0x11000000)
#define FLASH_UCDS_ADDR_BASE 0x11005000
#define CHIP_ID_LENGTH 64
#define CHIP_ID_PID_LEN 16
#define CHIP_ID_LID_LEN 10
#define CHIP_ID_MID_LEN 16
#define CHIP_ID_TID_LEN 14
#define CHIP_ID_SID_LEN 8
#define CHIP_MADDR_LEN 6
//xip flash read instrcution
#define XFRD_FCMD_READ 0x0000003
#define XFRD_FCMD_READ_DUAL 0x801003B
#define XFRD_FCMD_READ_QUAD 0x801006B
#define FCMD_RESET 0x99 //reset
#define FCMD_ENRST 0x66 //enable reset
#define FCMD_WREN 0x06 //write enable
#define FCMD_WRDIS 0x04 //write disable
#define FCMD_VSRWREN 0x50 //Volatile SR Write Enable
#define FCMD_CERASE 0x60 //(or 0xC7)chip erase
#define FCMD_SERASE 0x20 //sector erase
#define FCMD_BERASE32 0x52 //block erease 32k
#define FCMD_BERASE64 0xD8
#define FCMD_DPWRDN 0xB9 //deep power down
#define FCMD_RLSDPD 0xAB //release from powerdown(and read device id)
#define FCMD_WRST 0x01 //write status
#define FCMD_RDID 0x9F //read ID
#define FCMD_RDST 0x05 //read status
#define FCMD_RDST_H 0x35 //read status high byte
#define FCMD_PPROG 0x02 //page program
#define FCMD_READ 0x03 //read
#define FCMD_READF 0x0B //fast read
#define FCMD_READDO 0x3B //dual output fast read
#define FCMD_READDIO 0xBB //dual I/O fast read
#define FCMD_READQO 0x6B //quad output fast read
#define FCMD_READQIO 0xeB //quad I/O fast read
#define FCMD_READQIOW 0xe7 //quad I/O fast read word
typedef struct
{
sysclk_t spif_ref_clk; //
uint32_t rd_instr;
} xflash_Ctx_t;
typedef enum{
CHIP_ID_UNCHECK,
CHIP_ID_EMPTY,
CHIP_ID_VALID,
CHIP_ID_INVALID,
}CHIP_ID_STATUS_e;
typedef struct{
CHIP_ID_STATUS_e chipMAddrStatus;
uint8_t mAddr[CHIP_MADDR_LEN];
}chipMAddr_t;
extern int _spif_wait_nobusy(uint8_t flg, uint32_t tout_ns);
extern int spif_write(uint32_t addr, uint8_t* data, uint32_t size);
extern int spif_write_dma(uint32_t addr, uint8_t* data, uint32_t size);
extern int spif_read(uint32_t addr, uint8_t* data, uint32_t size);
extern int spif_read_dma(uint32_t addr, uint8_t* data, uint32_t size);
extern int spif_erase_sector(unsigned int addr);
extern int spif_erase_block64(unsigned int addr);
extern int spif_erase_all(void);
extern uint8_t spif_flash_status_reg_0(void);
extern int spif_write_protect(bool en);
extern void spif_cmd(uint8_t op, uint8_t addrlen, uint8_t rdlen, uint8_t wrlen, uint8_t mbit, uint8_t dummy);
extern void spif_rddata(uint8_t* data, uint8_t len);
extern int spif_config(sysclk_t ref_clk, uint8_t div, uint32_t rd_instr, uint8_t mode_bit, uint8_t QE);
int hal_spif_cache_init(void);//xflash_Ctx_t cfg);
int hal_flash_write(uint32_t addr, uint8_t* data, uint32_t size);
int hal_flash_write_by_dma(uint32_t addr, uint8_t* data, uint32_t size);
int hal_flash_read(uint32_t addr, uint8_t* data, uint32_t size);
int hal_flash_erase_sector(unsigned int addr);
int hal_flash_erase_block64(unsigned int addr);
int flash_write_word(unsigned int offset, uint32_t value);
CHIP_ID_STATUS_e chip_id_one_bit_hot_convter(uint8_t* b,uint32_t w);
void LL_PLUS_LoadMACFromFlash(uint32_t addr);
CHIP_ID_STATUS_e LL_PLUS_LoadMACFromChipMAddr(void);
void check_chip_mAddr(void);
void LOG_CHIP_MADDR(void);
#endif
+233
View File
@@ -0,0 +1,233 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/**
****************************************************************************************
@file global_config.h
@brief This file contains the definitions of index of global configuration which
will be configured in APP project.
$Rev: $
****************************************************************************************
*/
#ifndef _GLOBAL_CONFIG_H_
#define _GLOBAL_CONFIG_H_
#include "types.h"
/*******************************************************************************
software configuration parameters definition
*/
#define CONFIG_BASE_ADDR 0x1fff0400
#define SOFT_PARAMETER_NUM 256
// parameter index of configuration array
#define ADV_CHANNEL_INTERVAL 0 // interval between adv channel in the same adv event
#define SCAN_RSP_DELAY 1 // to adjust scan req -> scan rsp delay
#define CONN_REQ_TO_SLAVE_DELAY 2 // to calibrate the delay between conn req & 1st slave conn event
#define SLAVE_CONN_DELAY 3 // to adjust the delay between 2 slave connection events
#define SLAVE_CONN_DELAY_BEFORE_SYNC 4 // to adjust the delay between 2 slave connection events before 1st anchor is acquired
#define MAX_SLEEP_TIME 5 // maximum sleep time in us
#define MIN_SLEEP_TIME 6 // minimum sleep time in us
#define WAKEUP_ADVANCE 7 // wakeup advance time, to cover HW delay, crystal settle time, sw delay, ... etc.
#define WAKEUP_DELAY 8 // cycles of SW delay to wait crystal settle
#define HDC_DIRECT_ADV_INTERVAL 9
#define LDC_DIRECT_ADV_INTERVAL 10
#define LL_SWITCH 11 // Link Layer switch, 1 enable, 0 disable
#define NON_ADV_CHANNEL_INTERVAL 12 // interval between non-adv channel in the same adv event
#define CLOCK_SETTING 14 // HCLK
#define LL_HW_BB_DELAY 15
#define LL_HW_AFE_DELAY 16
#define LL_HW_PLL_DELAY 17
#define LL_HW_RTLP_LOOP_TIMEOUT 18
#define LL_HW_RTLP_1ST_TIMEOUT 19
#define MIN_TIME_TO_STABLE_32KHZ_XOSC 20
#define LL_TX_PKTS_PER_CONN_EVT 21
#define LL_RX_PKTS_PER_CONN_EVT 22
// ============= A1 ROM metal change add
#define DIR_ADV_DELAY 23
#define LL_TX_PWR_TO_REG_BIAS 24
#define LL_SMART_WINDOW_COEF_ALPHA 25
#define LL_SMART_WINDOW_TARGET 26
#define LL_SMART_WINDOW_INCREMENT 27
#define LL_SMART_WINDOW_LIMIT 28
#define LL_SMART_WINDOW_ACTIVE_THD 29
#define LL_SMART_WINDOW_ACTIVE_RANGE 30
#define LL_SMART_WINDOW_FIRST_WINDOW 31
#define LL_HW_Tx_TO_RX_INTV 32
#define LL_HW_Rx_TO_TX_INTV 33
#define INITIAL_STACK_PTR 34
#define ALLOW_TO_SLEEP_TICK_RC32K 35
#define LL_HW_BB_DELAY_ADV 36
#define LL_HW_AFE_DELAY_ADV 37
#define LL_HW_PLL_DELAY_ADV 38
// For scan & master, add 2018-6-15
#define LL_ADV_TO_SCAN_REQ_DELAY 39
#define LL_ADV_TO_CONN_REQ_DELAY 40
#define LL_MOVE_TO_MASTER_DELAY 41
#define LL_HW_TRLP_LOOP_TIMEOUT 42
#define LL_CONN_REQ_WIN_SIZE 43
#define LL_CONN_REQ_WIN_OFFSET 44
#define LL_MASTER_PROCESS_TARGET 45
#define LL_MASTER_TIRQ_DELAY 46
//for PHY updated add 2018-11-07
#define LL_HW_BB_DELAY_2MPHY 47
#define LL_HW_AFE_DELAY_2MPHY 48
#define LL_HW_PLL_DELAY_2MPHY 49
#define LL_HW_Tx_TO_RX_INTV_2MPHY 50
#define LL_HW_Rx_TO_TX_INTV_2MPHY 51
#define LL_HW_BB_DELAY_500KPHY 52
#define LL_HW_AFE_DELAY_500KPHY 53
#define LL_HW_PLL_DELAY_500KPHY 54
#define LL_HW_Tx_TO_RX_INTV_500KPHY 55
#define LL_HW_Rx_TO_TX_INTV_500KPHY 56
#define LL_HW_BB_DELAY_125KPHY 57
#define LL_HW_AFE_DELAY_125KPHY 58
#define LL_HW_PLL_DELAY_125KPHY 59
#define LL_HW_Tx_TO_RX_INTV_125KPHY 60
#define LL_HW_Rx_TO_TX_INTV_125KPHY 61
#define LL_HW_TRLP_TO_GAP 62
#define LL_HW_RTLP_TO_GAP 63
#define LL_TRX_NUM_ADAPTIVE_CONFIG 64
#define OSAL_SYS_TICK_WAKEUP_TRIM 65
// ==== A2 add, for secondary adv/scan
#define LL_NOCONN_ADV_EST_TIME 70
#define LL_NOCONN_ADV_MARGIN 71
#define LL_SEC_SCAN_MARGIN 72
#define LL_MIN_SCAN_TIME 73
// Bumblebee ROM code
#define LL_CONN_ADV_EST_TIME 74
#define LL_SCANABLE_ADV_EST_TIME 75
#define MAC_ADDRESS_LOC 80
// ==== For Extended Adv & Periodic adv
#define LL_EXT_ADV_INTER_PRI_CHN_INT 81
#define LL_EXT_ADV_INTER_AUX_CHN_INT 82
#define LL_EXT_ADV_RSC_POOL_PERIOD 83
#define LL_EXT_ADV_RSC_POOL_UNIT 84
#define LL_EXT_ADV_TASK_DURATION 86
#define LL_PRD_ADV_TASK_DURATION 87
#define LL_CONN_TASK_DURATION 88
#define TIMER_ISR_ENTRY_TIME 90 // time from HW timer expiry to ISR entry, unit: us
#define LL_MULTICONN_MASTER_PREEMP 91
#define LL_MULTICONN_SLAVE_PREEMP 92
#define LL_EXT_ADV_INTER_SEC_CHN_INT 93
#define LL_EXT_ADV_PRI_2_SEC_CHN_INT 94
#define LL_EXT_ADV_RSC_PERIOD 95
#define LL_EXT_ADV_RSC_SLOT_DURATION 96
#define LL_PRD_ADV_RSC_PERIOD 97
#define LL_PRD_ADV_RSC_SLOT_DURATION 98
#define LL_EXT_ADV_PROCESS_TARGET 99
#define LL_PRD_ADV_PROCESS_TARGET 100
// ==============
#define RC32_TRACKINK_ALLOW 0x00000001 // enable tracking RC 32KHz clock with 16MHz hclk
#define SLAVE_LATENCY_ALLOW 0x00000002 // slave latency allow switch
#define LL_DEBUG_ALLOW 0x00000004 // enable invoke RAM project debug output fucntion
#define LL_WHITELIST_ALLOW 0x00000008 // enable whitelist filter
#define LL_RC32K_SEL 0x00000010 // select RC32K RTC, otherwise select crystal 32K RTC
#define SIMUL_CONN_ADV_ALLOW 0x00000020 // allow send adv in connect state
#define SIMUL_CONN_SCAN_ALLOW 0x00000040 // allow scan in connect state
#define GAP_DUP_RPT_FILTER_DISALLOW 0x00000100 // duplicate report filter in GAP layer, allow default
// delete 2018-7-17, should use enum H_SYSCLK_SEL
//enum
//{
// CLOCK_16MHZ = 0,
// CLOCK_32MHZ = 1,
// CLOCK_48MHZ = 2,
// CLOCK_64MHZ = 3,
// CLOCK_96MHZ = 4,
// CLOCK_32MHZ_DBL=5
//};
//extern uint32 global_config[SOFT_PARAMETER_NUM];
extern uint32* pGlobal_config; // note: app project needn't this variable
#endif // _GLOBAL_CONFIG_H_
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More