Giter VIP home page Giter VIP logo

bm-lite's Introduction

FPC BM-Lite example application

There are 3 main folders in the project:


Build system

There are some variables controlling application building:

APP - defines application PLATFORM - defines HW plaform with HAL implementation DEBUG - if defined as 'y' will produce debug output and add debug information PORT - if defined as UART, BM-Lite HAL will use UART interface. Else will use SPI interface

Not all applications can be built for a particular platform. To build embedded application for nRF52840 platform with additional debug info use:

make APP=embedded_app PLATFORM=nRF52840 DEBUG=y

There are some useful makefile targets:

  • Show all available applications: make list_apps
  • Show all available platforms: make list_hals
  • Clean output for particular application and platform: make PLATFORM=nRF52840 APP=embedded_app clean
  • Clean output for all applications and platforms: make clean_all

Platform-independent interface functions

Platform-independent interface implemented in platform.c

Platform function Description
fpc_bep_result_t platform_init(void *params) Initilalizes hardware
void platform_bmlite_reset(void) Implements BM-Lite HW Reset
fpc_bep_result_t platform_bmlite_spi_send(uint16_t size, const uint8_t *data, uint32_t timeout)
fpc_bep_result_t platform_bmlite_uart_send(uint16_t size, const uint8_t *data, uint32_t timeout)
Send data packet to FPC BM-Lite
fpc_bep_result_t platform_bmlite_spi_receive(uint16_t size, uint8_t *data, uint32_t timeout)
fpc_bep_result_t platform_bmlite_uart_receive(uint16_t size, uint8_t *data, uint32_t timeout)
Receive data packet from FPC BM-Lite. If timeout = 0, the function will wait for data from BM-Lite indefinitely. The waiting loop will be breaked if hal_check_button_pressed() returns non-zero value. It is recommended to do HW or SW reset of BM-Lite if platform_bmlite_spi_receive() returns **FPC_BEP_RESULT_TIMEOUT** in order to return is into known state.

For UART interface IRQ/READY pin is not used, so in UART mode there is no signal from FPC-BM-Lite indicating that BM-Lite is going to send data. To avoid data loss, all data received from UART must be stored into an incoming circular buffer. I would recommend to use UART interrupt or DMA to receive data from UART and store it to the buffer. platform_bmlite_uart_receive() will read from that buffer when HCP protocol requests to read a data block. Activation UART data reading only inside platform_bmlite_uart_receive() will lead to loosing incoming data and causing HCP protocol errors.


HAL implementation

For porting the project to a new microcontroller, all functions from bmlite_hal.h should be implemented.

Functions must be implemented:

HAL Function Description
fpc_bep_result_t hal_board_init(void *params) Initialize GPIO, System timer, SPI
void hal_bmlite_reset(bool state) Activate/Deactivate BM-Lite RST_N pin (Active Low)
fpc_bep_result_t hal_bmlite_spi_write_read(uint8_t *write, uint8_t *read, size_t size, bool leave_cs_asserted) SPI data exchange
size_t hal_bmlite_uart_write(const uint8_t *data, size_t size); Write data to UART interface
size_t hal_bmlite_uart_read(uint8_t *buff, size_t size); Read data from UART interface
bool hal_bmlite_get_status(void) Return status of BM-Lite IRQ pin (Active High)
void hal_timebase_init(void) Initialize system clock with 1 msec tick
uint32_t hal_timebase_get_tick(void) Read currect system clock value
void hal_timebase_busy_wait(uint32_t ms) Delay for ms msec

Optional functions for implementing user interface in BM-Lite example application:

HAL Function Description
uint32_t hal_get_button_press_time(void) How long UI button was pressed last time. Also it should reset button pressed time counter
uint32_t hal_check_button_pressed(void) Used for breaking waiting in platform_bmlite_spi_receive() if returns non-zero
void hal_set_leds(platform_led_status_t status, uint16_t mode) Set LED(s) state according to status and mode.

Some notes about FPC BM-Lite HW interface

  • BM-Lite support both UART and SPI communication interface. BM-Lite automatically detects the specific communication interface in use. However, it is not possible to use both interfaces at the same time!
  • IRQ pin is used in SPI mode only as FPC BM-Lite Ready-to-Transmit signal. The module set it to High when it has some data to send and set it to Low when data packet is sent.

bm-lite's People

Contributors

andpp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bm-lite's Issues

Various Errors Occuring Randomly

Hello, I was trying to implement the same application on STM32U575 based microcontroller. Enrollment and identification procedure works fine initially. After some testing it fails and gets random errors such as IO errors, CRC errors, General Error etc.
I used the same structure that is implemented here.
My test code lies in the link below and the driver code is in Drivers/Modules folder.
https://github.com/veysiadn/fp-reader-test-base/

Thanks in advance.

Kind regards,
Veysi

HAL for ESP32

Hi, is there any chance to get an HAL implementation for an ESP32?

I tried to implement it myself, but I'm not experienced with HALs and also not with the close to the hardware code on ESP as I mostly use arduino code.

Thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.