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: Ib0e441fac2a0f276d4adead0e588ac656276d20e
This commit is contained in:
Andrey Perminov 2020-05-07 16:04:31 -07:00
parent 11ea486986
commit 03d2ba88e1
21 changed files with 441 additions and 138 deletions

View File

@ -27,6 +27,7 @@ OUT := out
DEPTH :=
HCP_PATH := ../hcp
RPIHAL_PATH := ../HAL_Driver
BMLITE_PATH := ../BMLite_sdk
# Main target
TARGET := $(OUT)/$(PRODUCT)
@ -46,7 +47,9 @@ CFLAGS +=\
-Wno-unused-result
CFLAGS +=\
-DBMLITE_USE_CALLBACK
-DBMLITE_USE_CALLBACK \
-DDEBUG
# C source files
C_SRCS = $(wildcard src/*.c)
@ -56,6 +59,8 @@ PATH_INC += inc
C_INC = $(addprefix -I,$(PATH_INC))
# Include BM-Lite SDK
include $(BMLITE_PATH)/bmlite.mk
# Include HAL driver
include $(RPIHAL_PATH)/raspberry.mk

View File

@ -1,32 +0,0 @@
/*
* Copyright (c) 2020 Fingerprint Cards AB
*
* Licensed 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
*
* https://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.
*/
/**
* @file Raspberry_pi_hal.h
* @brief Raspberry Pi HAL.
*/
#ifndef RASPBERRYPI_HAL_H
#define RASPBERRYPI_HAL_H
/*
* Pin definitions for RPI 3
*/
#define BMLITE_RESET_PIN 0
#define BMLITE_IRQ_PIN 22
#define SPI_CHANNEL 0
#endif /* RASPBERRYPI_HAL_H */

View File

@ -32,15 +32,18 @@
#include <string.h>
#include "bmlite_if.h"
#include "hcp_tiny.h"
#include "platform.h"
#include "bmlite_hal.h"
#include "platform_rpi.h"
#define DATA_BUFFER_SIZE 102400
static uint8_t hcp_txrx_buffer[MTU];
static uint8_t hcp_data_buffer[DATA_BUFFER_SIZE];
static HCP_comm_t hcp_chain = {
.read = platform_spi_receive,
.write = platform_spi_send,
.read = platform_bmlite_receive,
.write = platform_bmlite_send,
.pkt_buffer = hcp_data_buffer,
.txrx_buffer = hcp_txrx_buffer,
.pkt_size = 0,
@ -106,30 +109,33 @@ void save_to_pgm(FILE *f, uint8_t *image, int res_x, int res_y)
int main (int argc, char **argv)
{
char *port = NULL;
int baudrate = 921600;
int timeout = 5;
int index;
int c;
interface_t iface = COM_INTERFACE;
rpi_initparams_t rpi_params;
rpi_params.iface = COM_INTERFACE;
rpi_params.hcp_comm = &hcp_chain;
rpi_params.baudrate = 921600;
rpi_params.timeout = 5;
rpi_params.port = NULL;
opterr = 0;
while ((c = getopt (argc, argv, "sb:p:t:")) != -1) {
switch (c) {
case 's':
iface = SPI_INTERFACE;
if(baudrate == 921600)
baudrate = 1000000;
rpi_params.iface = SPI_INTERFACE;
if(rpi_params.baudrate == 921600)
rpi_params.baudrate = 1000000;
break;
case 'b':
baudrate = atoi(optarg);
rpi_params.baudrate = atoi(optarg);
break;
case 'p':
port = optarg;
rpi_params.port = optarg;
break;
case 't':
timeout = atoi(optarg);
rpi_params.timeout = atoi(optarg);
break;
case '?':
if (optopt == 'b')
@ -147,7 +153,7 @@ int main (int argc, char **argv)
}
}
if (iface == COM_INTERFACE && port == NULL) {
if (rpi_params.iface == COM_INTERFACE && rpi_params.port == NULL) {
printf("port must be specified\n");
help();
exit(1);
@ -157,46 +163,24 @@ int main (int argc, char **argv)
printf ("Non-option argument %s\n", argv[index]);
}
switch (iface) {
case SPI_INTERFACE:
if(!platform_spi_init(baudrate)) {
printf("SPI initialization failed\n");
exit(1);
}
break;
case COM_INTERFACE:
if (!platform_com_init(port, baudrate, timeout)) {
printf("Com initialization failed\n");
exit(1);
}
break;
default:
printf("Interface not specified'n");
if(platform_init(&rpi_params) != FPC_BEP_RESULT_OK) {
help();
exit(1);
}
if (iface == COM_INTERFACE) {
hcp_chain.read = platform_com_receive;
hcp_chain.write = platform_com_send;
} else {
hcp_chain.read = platform_spi_receive;
hcp_chain.write = platform_spi_send;
}
while(1) {
char cmd[100];
fpc_bep_result_t res = FPC_BEP_RESULT_OK;
uint16_t template_id;
bool match;
// platform_clear_screen();
rpi_clear_screen();
printf("BM-Lite Interface\n");
if (iface == SPI_INTERFACE)
printf("SPI port: speed %d Hz\n", baudrate);
if (rpi_params.iface == SPI_INTERFACE)
printf("SPI port: speed %d Hz\n", rpi_params.baudrate);
else
printf("Com port: %s [speed: %d]\n", port, baudrate);
printf("Timeout: %ds\n", timeout);
printf("Com port: %s [speed: %d]\n", rpi_params.port, rpi_params.baudrate);
printf("Timeout: %ds\n", rpi_params.timeout);
printf("-------------------\n\n");
printf("Possible options:\n");
printf("a: Enroll finger\n");

13
BMLite_sdk/bmlite.mk Normal file
View File

@ -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))

116
BMLite_sdk/inc/bmlite_hal.h Executable file
View File

@ -0,0 +1,116 @@
/**
* @file bmlite_hal.h
* @brief BM-Lite HAL functions.
*
* All functions must be implemented in order to support BM-Lite on a Board
*/
#ifndef BMLITE_H
#define BMLITE_H
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "fpc_bep_types.h"
#ifdef __arm__
typedef uint32_t hal_tick_t;
#else
typedef uint64_t hal_tick_t;
#endif
/**
* @brief LED status.
*
* Different LED status.
*/
typedef enum {
BMLITE_LED_STATUS_READY = 0,
BMLITE_LED_STATUS_MATCH,
BMLITE_LED_STATUS_WAITTOUCH,
BMLITE_LED_STATUS_ENROLL,
BMLITE_LED_STATUS_DELETE_TEMPLATES,
BMLITE_LED_STATUS_ERROR,
} platform_led_status_t;
/*
* @brief Board initialization
* @param[in] params - pointer to additional parameters
*/
fpc_bep_result_t hal_board_init(void *params);
/*
* @brief Control BM-Lite Reset pin
* @param[in] True - Activate RESET
* False - Deactivate RESET
*/
void hal_bmlite_reset(bool state);
/*
* @brief SPI write-read
* @param[in] Write buffer
* @param[in] Read buffer
* @param[in] Size
* @param[in] Leave CS asserted
* @return ::fpc_bep_result_t
*/
fpc_bep_result_t hal_bmlite_spi_write_read(uint8_t *write, uint8_t *read, size_t size,
bool leave_cs_asserted);
/*
* @brief Check if BM-Lite IRQ pin is set
* @return ::bool
*/
bool hal_bmlite_get_status(void);
/**
* @brief Initializes timebase. Starts system tick counter.
*/
void hal_timebase_init(void);
/**
* @brief Reads the system tick counter.
*
* @return Tick count since hal_timebase_init() call. [ms]
*/
hal_tick_t hal_timebase_get_tick(void);
/**
* @brief Busy wait.
*
* @param[in] ms Time to wait [ms].
* 0 => return immediately
* 1 => wait at least 1ms etc.
*/
void hal_timebase_busy_wait(uint32_t ms);
/**
* Optional functions for Buttons & Leds control
*/
/**
* @brief Get button press time (msec)
*
* @return ::uint32_t
*/
uint32_t hal_get_button_press_time(void);
/**
* @brief Check if button was pressed and released.
*
* @return Button press time in milli seconds.
*/
uint32_t hal_check_button_pressed(void);
/**
* @brief Set LED(s) status
* @param[in] Status
* @param[in] Status modifier
*/
void hal_set_leds(platform_led_status_t status, uint16_t mode);
#endif /* BMLITE_H */

View File

@ -17,8 +17,9 @@
#ifndef FPC_BEP_TYPES_H
#define FPC_BEP_TYPES_H
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
/**
* @file fpc_bep_types.h
* @brief Biometric Embedded Platform types.

78
BMLite_sdk/inc/platform.h Normal file
View File

@ -0,0 +1,78 @@
/*
* Copyright (c) 2020 Fingerprint Cards AB
*
* Licensed 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
*
* https://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 PLATFORM_H
#define PLATFORM_H
/**
* @file platform.h
* @brief Platform specific function interface
*/
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "fpc_bep_types.h"
/**
* @brief Initializes board
*
* @param[in] params - pointer to additional parameters.
*/
fpc_bep_result_t platform_init(void *params);
/**
* @brief Does BM-Lite HW Reset
*
*/
void platform_bmlite_reset(void);
/**
* @brief Sends data over communication port in blocking mode.
*
* @param[in] size Number of bytes to send.
* @param[in] data Data buffer to send.
* @param[in] timeout Timeout in ms. Use 0 for infinity.
*
* @return ::fpc_com_result_t
*/
fpc_bep_result_t platform_bmlite_send(uint16_t size, const uint8_t *data, uint32_t timeout,
void *session);
/**
* @brief Receives data from communication port in blocking mode.
*
* @param[in] size Number of bytes to receive.
* @param[in, out] data Data buffer to fill.
* @param[in] timeout Timeout in ms. Use 0 for infinity.
*
* @return ::fpc_com_result_t
*/
fpc_bep_result_t platform_bmlite_receive(uint16_t size, uint8_t *data, uint32_t timeout,
void *session);
/**
* @brief Stops execution if a debug interface is attached.
*/
void platform_halt_if_debug(void);
/**
* @brief Performs a software reset.
*/
void platform_sw_reset(void) __attribute__((__noreturn__));
#endif /* PLATFORM_H */

View File

@ -1,14 +1,16 @@
#include "hcp_tiny.h"
#include "bmlite_if.h"
#include "bmlite_hal.h"
#include "platform.h"
#include <stdio.h>
#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; }
@ -78,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;
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();

View File

@ -7,8 +7,6 @@
#include "bmlite_if_callbacks.h"
#define DEBUG
#ifdef DEBUG
#include <stdio.h>
#include <stdlib.h>
@ -87,7 +85,7 @@ fpc_bep_result_t bmlite_get_arg(HCP_comm_t *hcp_comm, uint16_t arg_type)
uint8_t *buffer = hcp_comm->pkt_buffer;
uint16_t args_nr = ((_HCP_cmd_t *)(buffer))->args_nr;
uint8_t *pdata = (uint8_t *)&((_HCP_cmd_t *)(buffer))->args;
while (i < args_nr && (pdata - buffer) <= hcp_comm->pkt_size) {
while (i < args_nr && (uint32_t)(pdata - buffer) <= hcp_comm->pkt_size) {
_CMD_arg_t *parg = (_CMD_arg_t *)pdata;
if(parg->arg == arg_type) {
hcp_comm->arg.size = parg->size;

78
BMLite_sdk/src/platform.c Normal file
View File

@ -0,0 +1,78 @@
/*
* Copyright (c) 2020 Fingerprint Cards AB
*
* Licensed 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
*
* https://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.
*/
/**
* @file platform.c
* @brief Platform specific functions
*/
#include "fpc_bep_types.h"
#include "platform.h"
#include "bmlite_hal.h"
fpc_bep_result_t platform_init(void *params)
{
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)
{
hal_bmlite_reset(true);
hal_timebase_busy_wait(100);
hal_bmlite_reset(false);
hal_timebase_busy_wait(100);
}
fpc_bep_result_t platform_bmlite_send(uint16_t size, const uint8_t *data, uint32_t timeout,
void *session)
{
uint8_t buff[size];
return hal_bmlite_spi_write_read((uint8_t *)data, buff, size, false);
}
fpc_bep_result_t platform_bmlite_receive(uint16_t size, uint8_t *data, uint32_t timeout,
void *session)
{
volatile uint32_t start_time = hal_timebase_get_tick();
volatile uint32_t curr_time = start_time;
// Wait for BM_Lite Ready for timeout or indefinitely if timeout is 0
while (!hal_bmlite_get_status() &&
(!timeout || (curr_time = hal_timebase_get_tick()) - start_time < timeout)) {
if(hal_check_button_pressed()) {
return FPC_BEP_RESULT_TIMEOUT;
}
}
if(timeout && curr_time - start_time >= timeout) {
return FPC_BEP_RESULT_TIMEOUT;
}
uint8_t buff[size];
return hal_bmlite_spi_write_read(buff, data, size, false);
}
__attribute__((weak)) uint32_t hal_check_button_pressed()
{
return 0;
}

View File

@ -14,8 +14,8 @@
* limitations under the License.
*/
#ifndef PLATFORM_H
#define PLATFORM_H
#ifndef PLATFORM_RPI_H
#define PLATFORM_RPI_H
/**
* @file platform.h
@ -26,12 +26,27 @@
#include <stdbool.h>
#include "fpc_bep_types.h"
#include "hcp_tiny.h"
typedef enum {
COM_INTERFACE = 0,
SPI_INTERFACE
} interface_t;
typedef struct {
interface_t iface;
char *port;
uint32_t baudrate;
uint32_t timeout;
HCP_comm_t *hcp_comm;
} rpi_initparams_t;
/*
* Pin definitions for RPI 3
*/
#define BMLITE_RESET_PIN 0
#define BMLITE_IRQ_PIN 22
#define SPI_CHANNEL 0
/**
* @brief Initializes COM Physical layer.
@ -40,7 +55,7 @@ typedef enum {
* @param[in] baudrate Baudrate.
* @param[in] timeout Timeout in ms. Use 0 for infinity.
*/
bool platform_com_init(char *port, int baudrate, int timeout);
bool rpi_com_init(char *port, int baudrate, int timeout);
/**
* @brief Sends data over communication port in blocking mode.
@ -51,7 +66,7 @@ bool platform_com_init(char *port, int baudrate, int timeout);
*
* @return ::fpc_bep_result_t
*/
fpc_bep_result_t platform_com_send(uint16_t size, const uint8_t *data, uint32_t timeout,
fpc_bep_result_t rpi_com_send(uint16_t size, const uint8_t *data, uint32_t timeout,
void *session);
/**
@ -63,7 +78,7 @@ fpc_bep_result_t platform_com_send(uint16_t size, const uint8_t *data, uint32_t
*
* @return ::fpc_bep_result_t
*/
fpc_bep_result_t platform_com_receive(uint16_t size, uint8_t *data, uint32_t timeout,
fpc_bep_result_t rpi_com_receive(uint16_t size, uint8_t *data, uint32_t timeout,
void *session);
/**
@ -71,7 +86,7 @@ fpc_bep_result_t platform_com_receive(uint16_t size, uint8_t *data, uint32_t tim
*
* @param[in] speed_hz Baudrate.
*/
bool platform_spi_init(uint32_t speed_hz);
bool rpi_spi_init(uint32_t speed_hz);
/**
* @brief Sends data over communication port in blocking mode.
@ -102,12 +117,12 @@ fpc_bep_result_t platform_spi_receive(uint16_t size, uint8_t *data, uint32_t tim
*
* @return time in us.
*/
uint64_t platform_get_time(void);
// uint64_t platform_get_time(void);
/**
* @brief Clear console screen
*/
void platform_clear_screen(void);
void rpi_clear_screen(void);
/**
* @brief Busy wait.
@ -119,4 +134,4 @@ void platform_clear_screen(void);
void hal_timebase_busy_wait(uint32_t ms);
#endif /* PLATFORM_H */
#endif /* PLATFORM_RPI_H */

View File

@ -1,6 +1,15 @@
# Binary sources
VPATH += $(DEPTH)../HAL_Driver
C_INC += -I$(DEPTH)../HAL_Driver/inc
NHAL = $(DEPTH)../HAL_Driver
LDFLAGS += -lwiringPi -L$(DEPTH)../HAL_Driver/lib/
VPATH += $(NHAL)
C_INC += -I$(NHAL)/inc
LDFLAGS += -lwiringPi -L$(NHAL)/lib/
# Source Folders
VPATH += $(NHAL)/src/
# C Sources
C_SRCS += $(notdir $(wildcard $(NHAL)/src/*.c))

View File

@ -30,9 +30,11 @@
#include <sys/time.h>
#include <unistd.h>
#include "bmlite_hal.h"
#include "platform_rpi.h"
#include "platform.h"
uint64_t platform_get_time(void)
hal_tick_t hal_timebase_get_tick(void)
{
struct timeval current_time;
uint64_t time_in_ms;
@ -44,12 +46,50 @@ uint64_t platform_get_time(void)
return time_in_ms;
}
void platform_clear_screen(void)
{
system("clear");
}
void hal_timebase_busy_wait(uint32_t ms)
{
usleep(ms * 1000);
}
void rpi_clear_screen(void)
{
system("clear");
}
void hal_timebase_init()
{
}
fpc_bep_result_t hal_board_init(void *params)
{
rpi_initparams_t *p = (rpi_initparams_t *)params;
switch (p->iface) {
case SPI_INTERFACE:
if(!rpi_spi_init(p->baudrate)) {
printf("SPI initialization failed\n");
return FPC_BEP_RESULT_INTERNAL_ERROR;
}
break;
case COM_INTERFACE:
if (!rpi_com_init(p->port, p->baudrate, p->timeout)) {
printf("Com initialization failed\n");
return FPC_BEP_RESULT_INTERNAL_ERROR;
}
break;
default:
printf("Interface not specified'n");
return FPC_BEP_RESULT_INTERNAL_ERROR;
}
if (p->iface == COM_INTERFACE) {
p->hcp_comm->read = rpi_com_receive;
p->hcp_comm->write = rpi_com_send;
} else {
p->hcp_comm->read = platform_bmlite_receive;
p->hcp_comm->write = platform_bmlite_send;
}
p->hcp_comm->phy_rx_timeout = p->timeout*1000;
return FPC_BEP_RESULT_OK;
}

View File

@ -29,7 +29,7 @@
#include <termios.h>
#include <sys/time.h>
#include "platform.h"
#include "platform_rpi.h"
static int fd = -1;
@ -63,7 +63,7 @@ static int set_interface_attribs(int fd, int speed, int timeout)
return 0;
}
bool platform_com_init(char *port, int baudrate, int timeout)
bool rpi_com_init(char *port, int baudrate, int timeout)
{
int baud;
@ -84,7 +84,7 @@ bool platform_com_init(char *port, int baudrate, int timeout)
return true;
}
fpc_bep_result_t platform_com_send(uint16_t size, const uint8_t *data, uint32_t timeout,
fpc_bep_result_t rpi_com_send(uint16_t size, const uint8_t *data, uint32_t timeout,
void *session)
{
fpc_bep_result_t res = FPC_BEP_RESULT_OK;
@ -104,7 +104,7 @@ fpc_bep_result_t platform_com_send(uint16_t size, const uint8_t *data, uint32_t
return res;
}
fpc_bep_result_t platform_com_receive(uint16_t size, uint8_t *data, uint32_t timeout,
fpc_bep_result_t rpi_com_receive(uint16_t size, uint8_t *data, uint32_t timeout,
void *session)
{
fpc_bep_result_t res = FPC_BEP_RESULT_OK;

View File

@ -39,7 +39,7 @@
#include "wiringPi.h"
#include "wiringPiSPI.h"
#include "raspberry_pi_hal.h"
#include "platform_rpi.h"
#define SPI_BUF_MIN_SIZE 40000
// This path is used to determine the SPI buffer size.
@ -52,7 +52,7 @@ uint32_t speed_hz_int;
void fpc_sensor_spi_reset(bool state);
void raspberryPi_init()
static void raspberryPi_init()
{
/* Start wiringPi functions. */
wiringPiSetup();
@ -66,15 +66,7 @@ void raspberryPi_init()
}
void platform_spi_sensor_reset(void)
{
fpc_sensor_spi_reset(true);
usleep(100);
fpc_sensor_spi_reset(false);
usleep(10);
}
void fpc_sensor_spi_reset(bool state)
void hal_bmlite_reset(bool state)
{
/* The reset pin is controlled by WiringPis digitalWrite function*/
if (state) {
@ -90,7 +82,7 @@ bool hal_bmlite_get_status(void)
}
bool platform_spi_init(uint32_t speed_hz)
bool rpi_spi_init(uint32_t speed_hz)
{
raspberryPi_init();
@ -143,7 +135,7 @@ bool platform_spi_init(uint32_t speed_hz)
return true;
}
static fpc_bep_result_t platform_spi_write_read(const uint8_t *write, uint8_t *read, size_t size,
fpc_bep_result_t hal_bmlite_spi_write_read(const uint8_t *write, uint8_t *read, size_t size,
bool leave_cs_asserted)
{
/*
@ -179,28 +171,28 @@ static fpc_bep_result_t platform_spi_write_read(const uint8_t *write, uint8_t *r
}
fpc_bep_result_t platform_spi_send(uint16_t size, const uint8_t *data, uint32_t timeout,
void *session)
{
uint8_t buff[size];
// fpc_bep_result_t platform_spi_send(uint16_t size, const uint8_t *data, uint32_t timeout,
// void *session)
// {
// uint8_t buff[size];
return platform_spi_write_read(data, buff, size, false);
}
// return platform_spi_write_read(data, buff, size, false);
// }
fpc_bep_result_t platform_spi_receive(uint16_t size, uint8_t *data, uint32_t timeout,
void *session)
{
volatile uint64_t start_time = platform_get_time();
volatile uint64_t curr_time = start_time;
// Wait for BM_Lite Ready for timeout or indefinitely if timeout is 0
while (!hal_bmlite_get_status() &&
(!timeout || (curr_time = platform_get_time()) - start_time < timeout)) {
//usleep(1);
}
if(timeout && curr_time - start_time >= timeout) {
return FPC_BEP_RESULT_TIMEOUT;
}
// fpc_bep_result_t platform_spi_receive(uint16_t size, uint8_t *data, uint32_t timeout,
// void *session)
// {
// volatile uint64_t start_time = platform_get_time();
// volatile uint64_t curr_time = start_time;
// // Wait for BM_Lite Ready for timeout or indefinitely if timeout is 0
// while (!hal_bmlite_get_status() &&
// (!timeout || (curr_time = platform_get_time()) - start_time < timeout)) {
// //usleep(1);
// }
// if(timeout && curr_time - start_time >= timeout) {
// return FPC_BEP_RESULT_TIMEOUT;
// }
uint8_t buff[size];
return platform_spi_write_read(buff, data, size, false);
}
// uint8_t buff[size];
// return platform_spi_write_read(buff, data, size, false);
// }