From 02bf23c840a102ed262d712a107d94882f26432a Mon Sep 17 00:00:00 2001 From: Andrey Perminov Date: Thu, 7 May 2020 16:06:05 -0700 Subject: [PATCH] Moved FPC BM-Lite SDK to a separate folder Moved FPC BM-Lite SDK to a reparate folder Checking result of execution of every command on BM-Lite Change-Id: I10ef898673dd2250b8e287ace86e7d7574ab40fc --- .vscode/c_cpp_properties.json | 1 + BMLite_example/Makefile | 3 +++ BMLite_example/src/main.c | 3 +-- BMLite_sdk/bmlite.mk | 13 +++++++++++++ {BMLite_example => BMLite_sdk}/inc/bmlite_hal.h | 16 ++++++++++++---- {BMLite_example => BMLite_sdk}/inc/bmlite_if.h | 0 .../inc/bmlite_if_callbacks.h | 0 .../inc/fpc_bep_types.h | 3 ++- {BMLite_example => BMLite_sdk}/inc/fpc_crc.h | 0 .../inc/fpc_hcp_common.h | 0 {BMLite_example => BMLite_sdk}/inc/hcp_tiny.h | 2 +- {BMLite_example => BMLite_sdk}/inc/platform.h | 4 ++-- {BMLite_example => BMLite_sdk}/src/bmlite_if.c | 9 +++++++-- {BMLite_example => BMLite_sdk}/src/fpc_crc.c | 0 {BMLite_example => BMLite_sdk}/src/hcp_tiny.c | 0 {BMLite_example => BMLite_sdk}/src/platform.c | 14 ++++++++------ HAL_Driver/src/hal_board.c | 8 +++++--- 17 files changed, 55 insertions(+), 21 deletions(-) create mode 100644 BMLite_sdk/bmlite.mk rename {BMLite_example => BMLite_sdk}/inc/bmlite_hal.h (86%) rename {BMLite_example => BMLite_sdk}/inc/bmlite_if.h (100%) rename {BMLite_example => BMLite_sdk}/inc/bmlite_if_callbacks.h (100%) rename {BMLite_example => BMLite_sdk}/inc/fpc_bep_types.h (98%) rename {BMLite_example => BMLite_sdk}/inc/fpc_crc.h (100%) rename {BMLite_example => BMLite_sdk}/inc/fpc_hcp_common.h (100%) rename {BMLite_example => BMLite_sdk}/inc/hcp_tiny.h (99%) rename {BMLite_example => BMLite_sdk}/inc/platform.h (94%) rename {BMLite_example => BMLite_sdk}/src/bmlite_if.c (96%) rename {BMLite_example => BMLite_sdk}/src/fpc_crc.c (100%) rename {BMLite_example => BMLite_sdk}/src/hcp_tiny.c (100%) rename {BMLite_example => BMLite_sdk}/src/platform.c (89%) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 492ad70..000602b 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -20,6 +20,7 @@ "/usr/arm-none-eabi/include/c++/7.3.1/arm-none-eabi", "/usr/arm-none-eabi/include/c++/7.3.1/backward", "${workspaceFolder}/BMLite_example/inc", + "${workspaceFolder}/BMLite_sdk/inc", "${workspaceFolder}/HAL_Driver/CMSIS/Include", "${workspaceFolder}/HAL_Driver/inc", "${workspaceFolder}/HAL_Driver/sdk", diff --git a/BMLite_example/Makefile b/BMLite_example/Makefile index 2d6aaed..61de159 100644 --- a/BMLite_example/Makefile +++ b/BMLite_example/Makefile @@ -27,6 +27,7 @@ OUT := out DEPTH := HCP_PATH := ../hcp MCUHAL_PATH := ../HAL_Driver +BMLITE_PATH := ../BMLite_sdk # Main target TARGET := $(OUT)/$(PRODUCT) @@ -72,6 +73,8 @@ PATH_INC += inc C_INC = $(addprefix -I,$(PATH_INC)) +# Include BM-Lite SDK +include $(BMLITE_PATH)/bmlite.mk # Include HAL include $(MCUHAL_PATH)/nordic.mk diff --git a/BMLite_example/src/main.c b/BMLite_example/src/main.c index 1a3c3aa..587300a 100644 --- a/BMLite_example/src/main.c +++ b/BMLite_example/src/main.c @@ -89,8 +89,7 @@ void bmlite_on_identify_start() int main (int argc, char **argv) { - int baudrate = 4000000; - platform_init(baudrate); + platform_init(NULL); { char version[100]; diff --git a/BMLite_sdk/bmlite.mk b/BMLite_sdk/bmlite.mk new file mode 100644 index 0000000..781c687 --- /dev/null +++ b/BMLite_sdk/bmlite.mk @@ -0,0 +1,13 @@ +# Binary sources + +BMLITE_SDK = $(DEPTH)../BMLite_sdk + +VPATH += $(BMLITE_SDK) + +C_INC += -I$(BMLITE_SDK)/inc + +# Source Folders +VPATH += $(BMLITE_SDK)/src/ + +# C Sources +C_SRCS += $(notdir $(wildcard $(BMLITE_SDK)/src/*.c)) \ No newline at end of file diff --git a/BMLite_example/inc/bmlite_hal.h b/BMLite_sdk/inc/bmlite_hal.h similarity index 86% rename from BMLite_example/inc/bmlite_hal.h rename to BMLite_sdk/inc/bmlite_hal.h index 5763f83..b926941 100755 --- a/BMLite_example/inc/bmlite_hal.h +++ b/BMLite_sdk/inc/bmlite_hal.h @@ -1,5 +1,5 @@ /** - * @file bmlite.h + * @file bmlite_hal.h * @brief BM-Lite HAL functions. * * All functions must be implemented in order to support BM-Lite on a Board @@ -8,10 +8,18 @@ #ifndef BMLITE_H #define BMLITE_H +#include +#include #include #include "fpc_bep_types.h" +#ifdef __arm__ +typedef uint32_t hal_tick_t; +#else +typedef uint64_t hal_tick_t; +#endif + /** * @brief LED status. * @@ -29,10 +37,10 @@ typedef enum { /* * @brief Board initialization - * @param[in] SPI CLK speed + * @param[in] params - pointer to additional parameters */ -void hal_board_init(uint32_t speed_hz); +fpc_bep_result_t hal_board_init(void *params); /* * @brief Control BM-Lite Reset pin @@ -68,7 +76,7 @@ void hal_timebase_init(void); * * @return Tick count since hal_timebase_init() call. [ms] */ -uint32_t hal_timebase_get_tick(void); +hal_tick_t hal_timebase_get_tick(void); /** * @brief Busy wait. diff --git a/BMLite_example/inc/bmlite_if.h b/BMLite_sdk/inc/bmlite_if.h similarity index 100% rename from BMLite_example/inc/bmlite_if.h rename to BMLite_sdk/inc/bmlite_if.h diff --git a/BMLite_example/inc/bmlite_if_callbacks.h b/BMLite_sdk/inc/bmlite_if_callbacks.h similarity index 100% rename from BMLite_example/inc/bmlite_if_callbacks.h rename to BMLite_sdk/inc/bmlite_if_callbacks.h diff --git a/BMLite_example/inc/fpc_bep_types.h b/BMLite_sdk/inc/fpc_bep_types.h similarity index 98% rename from BMLite_example/inc/fpc_bep_types.h rename to BMLite_sdk/inc/fpc_bep_types.h index e9a187e..31f310d 100644 --- a/BMLite_example/inc/fpc_bep_types.h +++ b/BMLite_sdk/inc/fpc_bep_types.h @@ -17,8 +17,9 @@ #ifndef FPC_BEP_TYPES_H #define FPC_BEP_TYPES_H +#include #include - +#include /** * @file fpc_bep_types.h * @brief Biometric Embedded Platform types. diff --git a/BMLite_example/inc/fpc_crc.h b/BMLite_sdk/inc/fpc_crc.h similarity index 100% rename from BMLite_example/inc/fpc_crc.h rename to BMLite_sdk/inc/fpc_crc.h diff --git a/BMLite_example/inc/fpc_hcp_common.h b/BMLite_sdk/inc/fpc_hcp_common.h similarity index 100% rename from BMLite_example/inc/fpc_hcp_common.h rename to BMLite_sdk/inc/fpc_hcp_common.h diff --git a/BMLite_example/inc/hcp_tiny.h b/BMLite_sdk/inc/hcp_tiny.h similarity index 99% rename from BMLite_example/inc/hcp_tiny.h rename to BMLite_sdk/inc/hcp_tiny.h index fcfbb1f..2bbf3b4 100644 --- a/BMLite_example/inc/hcp_tiny.h +++ b/BMLite_sdk/inc/hcp_tiny.h @@ -129,4 +129,4 @@ fpc_bep_result_t bmlite_copy_arg(HCP_comm_t *hcp_comm, uint16_t arg_key, void *a -#endif +#endif \ No newline at end of file diff --git a/BMLite_example/inc/platform.h b/BMLite_sdk/inc/platform.h similarity index 94% rename from BMLite_example/inc/platform.h rename to BMLite_sdk/inc/platform.h index ae18628..a3f2495 100644 --- a/BMLite_example/inc/platform.h +++ b/BMLite_sdk/inc/platform.h @@ -31,9 +31,9 @@ /** * @brief Initializes board * - * @param[in] speed_hz Baudrate. + * @param[in] params - pointer to additional parameters. */ -bool platform_init(uint32_t speed_hz); +fpc_bep_result_t platform_init(void *params); /** * @brief Does BM-Lite HW Reset diff --git a/BMLite_example/src/bmlite_if.c b/BMLite_sdk/src/bmlite_if.c similarity index 96% rename from BMLite_example/src/bmlite_if.c rename to BMLite_sdk/src/bmlite_if.c index dcd8947..c20ea70 100644 --- a/BMLite_example/src/bmlite_if.c +++ b/BMLite_sdk/src/bmlite_if.c @@ -7,9 +7,10 @@ #include "bmlite_if_callbacks.h" #define MAX_CAPTURE_ATTEMPTS 15 +#define MAX_SINGLE_CAPTURE_ATTEMPTS 3 #define CAPTURE_TIMEOUT 3000 -#define exit_if_err(c) { bep_result = c; if(bep_result) goto exit; } +#define exit_if_err(c) { bep_result = c; if(bep_result || chain->bep_result) goto exit; } #define assert(c) { fpc_bep_result_t res = c; if(res) return res; } @@ -79,7 +80,11 @@ fpc_bep_result_t bep_capture(HCP_comm_t *chain, uint16_t timeout) bmlite_on_start_capture(); chain->phy_rx_timeout = timeout; - bep_result = bmlite_send_cmd_arg(chain, CMD_CAPTURE, ARG_NONE, ARG_TIMEOUT, &timeout, sizeof(timeout)); + for(int i=0; i< MAX_SINGLE_CAPTURE_ATTEMPTS; i++) { + bep_result = bmlite_send_cmd_arg(chain, CMD_CAPTURE, ARG_NONE, ARG_TIMEOUT, &timeout, sizeof(timeout)); + if( !(bep_result || chain->bep_result)) + break; + } chain->phy_rx_timeout = prev_timeout; bmlite_on_finish_capture(); diff --git a/BMLite_example/src/fpc_crc.c b/BMLite_sdk/src/fpc_crc.c similarity index 100% rename from BMLite_example/src/fpc_crc.c rename to BMLite_sdk/src/fpc_crc.c diff --git a/BMLite_example/src/hcp_tiny.c b/BMLite_sdk/src/hcp_tiny.c similarity index 100% rename from BMLite_example/src/hcp_tiny.c rename to BMLite_sdk/src/hcp_tiny.c diff --git a/BMLite_example/src/platform.c b/BMLite_sdk/src/platform.c similarity index 89% rename from BMLite_example/src/platform.c rename to BMLite_sdk/src/platform.c index 1141e40..5d28d6a 100644 --- a/BMLite_example/src/platform.c +++ b/BMLite_sdk/src/platform.c @@ -24,13 +24,15 @@ #include "platform.h" #include "bmlite_hal.h" -bool platform_init(uint32_t speed_hz) +fpc_bep_result_t platform_init(void *params) { - hal_board_init(4000000); - hal_timebase_init(); - - platform_bmlite_reset(); - return true; + fpc_bep_result_t result; + result = hal_board_init(params); + if(result == FPC_BEP_RESULT_OK) { + hal_timebase_init(); + platform_bmlite_reset(); + } + return result; } void platform_bmlite_reset(void) diff --git a/HAL_Driver/src/hal_board.c b/HAL_Driver/src/hal_board.c index 3ec6ecf..3af8d72 100755 --- a/HAL_Driver/src/hal_board.c +++ b/HAL_Driver/src/hal_board.c @@ -37,9 +37,10 @@ static void nordic_bmlite_gpio_init(void); void nordic_bmlite_spi_init(uint32_t speed_hz); -void hal_board_init(uint32_t speed_hz) +fpc_bep_result_t hal_board_init(void *params) { - + (void)params; + if (NRF_UICR->REGOUT0 != UICR_REGOUT0_VOUT_3V3) { NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; @@ -52,9 +53,10 @@ void hal_board_init(uint32_t speed_hz) NRF_USBD->ENABLE = 1; nordic_bmlite_gpio_init(); - nordic_bmlite_spi_init(speed_hz); + nordic_bmlite_spi_init(4000000); bsp_board_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS); + return FPC_BEP_RESULT_OK; } void hal_bmlite_reset(bool state)