Added missed license header

Change-Id: Id97fec908def3b7b2f5b31cb27f33dbe677caa5a
This commit is contained in:
Andrey Perminov 2020-07-20 10:27:44 -07:00
parent 8d1c2ff0e4
commit a96545ddb1
14 changed files with 245 additions and 126 deletions

View File

@ -12,10 +12,9 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ *
* Modified by Andrey Perminov <andrey.ppp@gmail.com>
/* * for running on microcontrollers
* Modified by Andrey Perminov for running on microcontrollers
*/ */

View File

@ -1,3 +1,19 @@
/*
* Copyright (c) 2020 Andrey Perminov <andrey.ppp@gmail.com>
*
* 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 bmlite_hal.h * @file bmlite_hal.h
* @brief BM-Lite HAL functions. * @brief BM-Lite HAL functions.

View File

@ -1,3 +1,19 @@
/*
* Copyright (c) 2020 Andrey Perminov <andrey.ppp@gmail.com>
*
* 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 BMLITE_IF_H #ifndef BMLITE_IF_H
#define BMLITE_IF_H #define BMLITE_IF_H
@ -5,33 +21,28 @@
#include "bmlite_if_callbacks.h" #include "bmlite_if_callbacks.h"
/** /**
* @brief Build and send command to FPC BM-Lite and receive answer * @brief Enroll finger. Created template must be saved to FLASH storage
* *
* @param[in] chain - HCP com chain * @param[in] chain - HCP com chain
* @param[in] cmd - BM-Lite command
* @param[in] arg_type - Argument without parameters
* set to ARG_NONE if the command has no argument
* *
* @return ::fpc_bep_result_t * @return ::fpc_bep_result_t
*/ */
fpc_bep_result_t bmlite_send_cmd(HCP_comm_t *chain, uint16_t cmd, uint16_t arg_type); fpc_bep_result_t bep_enroll_finger(HCP_comm_t *chain);
/** /**
* @brief Build and send command with additiona argument with parameters * @brief Capture and identify finger against existing templates in Flash storage
* *
* @param[in] chain - HCP com chain * @param[in] chain - HCP com chain
* @param[in] cmd - BM-Lite command * @param[in] timeout - timeout (msec). Maximum timeout 65535 msec
* @param[in] arg1_type - argument 1 without parameters * set to 0 for waiting indefinitely
* set to ARG_NONE if the command has no argument without paramener *
* @param[in] arg2_type - argument 2 * @param[out] template_id - pointer for matched template ID
* @param[in] arg2_data - data pointer for argument 2 * @param[out] match - pointer to match result
* set to 0 if argument 2 has no parameter
* @param[in] arg2_length - length of data for argument 2
* set to 0 if argument 2 has no parameter
* *
* @return ::fpc_bep_result_t * @return ::fpc_bep_result_t
*/ */
fpc_bep_result_t bmlite_send_cmd_arg(HCP_comm_t *chain, uint16_t cmd, uint16_t arg1_type, uint16_t arg2_type, void *arg2_data, uint16_t arg2_length); fpc_bep_result_t bep_identify_finger(HCP_comm_t *chain, uint32_t timeout,
uint16_t *template_id, bool *match);
/** /**
* @brief Wait for finger present on sensor" * @brief Wait for finger present on sensor"
@ -140,30 +151,6 @@ fpc_bep_result_t bep_image_extract(HCP_comm_t *chain);
*/ */
fpc_bep_result_t bep_identify(HCP_comm_t *chain); fpc_bep_result_t bep_identify(HCP_comm_t *chain);
/**
* @brief Enroll finger. Created template must be saved to FLASH storage
*
* @param[in] chain - HCP com chain
*
* @return ::fpc_bep_result_t
*/
fpc_bep_result_t bep_enroll_finger(HCP_comm_t *chain);
/**
* @brief Capture and identify finger against existing templates in Flash storage
*
* @param[in] chain - HCP com chain
* @param[in] timeout - timeout (msec). Maximum timeout 65535 msec
* set to 0 for waiting indefinitely
*
* @param[out] template_id - pointer for matched template ID
* @param[out] match - pointer to match result
*
* @return ::fpc_bep_result_t
*/
fpc_bep_result_t bep_identify_finger(HCP_comm_t *chain, uint32_t timeout,
uint16_t *template_id, bool *match);
/** /**
* @brief Save template after enroll is finished to FLASH storage * @brief Save template after enroll is finished to FLASH storage
* *
@ -344,4 +331,35 @@ fpc_bep_result_t bep_uart_speed_get(HCP_comm_t *chain, uint32_t *speed);
*/ */
fpc_bep_result_t bep_sensor_reset(HCP_comm_t *chain); fpc_bep_result_t bep_sensor_reset(HCP_comm_t *chain);
/**
* @brief Build and send command to FPC BM-Lite and receive answer
*
* @param[in] chain - HCP com chain
* @param[in] cmd - BM-Lite command
* @param[in] arg_type - Argument without parameters
* set to ARG_NONE if the command has no argument
*
* @return ::fpc_bep_result_t
*/
fpc_bep_result_t bmlite_send_cmd(HCP_comm_t *chain, uint16_t cmd, uint16_t arg_type);
/**
* @brief Build and send command with additiona argument with parameters
*
* @param[in] chain - HCP com chain
* @param[in] cmd - BM-Lite command
* @param[in] arg1_type - argument 1 without parameters
* set to ARG_NONE if the command has no argument without paramener
* @param[in] arg2_type - argument 2
* @param[in] arg2_data - data pointer for argument 2
* set to 0 if argument 2 has no parameter
* @param[in] arg2_length - length of data for argument 2
* set to 0 if argument 2 has no parameter
*
* @return ::fpc_bep_result_t
*/
fpc_bep_result_t bmlite_send_cmd_arg(HCP_comm_t *chain, uint16_t cmd, uint16_t arg1_type, uint16_t arg2_type, void *arg2_data, uint16_t arg2_length);
#endif #endif

View File

@ -1,3 +1,19 @@
/*
* Copyright (c) 2020 Andrey Perminov <andrey.ppp@gmail.com>
*
* 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 BMLITE_IF_CALLBACKS_H #ifndef BMLITE_IF_CALLBACKS_H
#define BMLITE_IF_CALLBACKS_H #define BMLITE_IF_CALLBACKS_H
#include <stdint.h> #include <stdint.h>

View File

@ -1,3 +1,19 @@
/*
* Copyright (c) 2020 Andrey Perminov <andrey.ppp@gmail.com>
*
* 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 HCP_H #ifndef HCP_H
#define HCP_H #define HCP_H
@ -127,6 +143,4 @@ fpc_bep_result_t bmlite_get_arg(HCP_comm_t *hcp_comm, uint16_t arg_type);
*/ */
fpc_bep_result_t bmlite_copy_arg(HCP_comm_t *hcp_comm, uint16_t arg_key, void *arg_data, uint16_t arg_data_size); fpc_bep_result_t bmlite_copy_arg(HCP_comm_t *hcp_comm, uint16_t arg_key, void *arg_data, uint16_t arg_data_size);
#endif #endif

View File

@ -12,8 +12,12 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
* Modified by Andrey Perminov <andrey.ppp@gmail.com>
* for FPC BM-Lite applications
*/ */
#ifndef PLATFORM_H #ifndef PLATFORM_H
#define PLATFORM_H #define PLATFORM_H

View File

@ -1,3 +1,19 @@
/*
* Copyright (c) 2020 Andrey Perminov <andrey.ppp@gmail.com>
*
* 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.
*/
#include "hcp_tiny.h" #include "hcp_tiny.h"
#include "bmlite_if.h" #include "bmlite_if.h"
#include "bmlite_hal.h" #include "bmlite_hal.h"
@ -33,18 +49,73 @@ __attribute__((weak)) void bmlite_on_identify_start() {}
__attribute__((weak)) void bmlite_on_identify_finish() {} __attribute__((weak)) void bmlite_on_identify_finish() {}
#endif #endif
fpc_bep_result_t bmlite_send_cmd(HCP_comm_t *chain, uint16_t cmd, uint16_t arg_type) fpc_bep_result_t bep_enroll_finger(HCP_comm_t *chain)
{ {
assert(bmlite_init_cmd(chain, cmd, arg_type)); uint32_t samples_remaining = 0;
return bmlite_tranceive(chain); fpc_bep_result_t bep_result = FPC_BEP_RESULT_OK;
bool enroll_done = false;
bmlite_on_start_enroll();
/* Enroll start */
exit_if_err(bmlite_send_cmd(chain, CMD_ENROLL, ARG_START));
for (uint8_t i = 0; i < MAX_CAPTURE_ATTEMPTS; ++i) {
bmlite_on_start_enrollcapture();
bep_result = bep_capture(chain, CAPTURE_TIMEOUT);
bmlite_on_finish_enrollcapture();
if (bep_result != FPC_BEP_RESULT_OK) {
continue;
}
/* Enroll add */
bep_result = bmlite_send_cmd(chain, CMD_ENROLL, ARG_ADD);
if (bep_result != FPC_BEP_RESULT_OK) {
continue;
}
bmlite_get_arg(chain, ARG_COUNT);
samples_remaining = *(uint32_t *)chain->arg.data;
// DEBUG("Enroll samples remaining: %d\n", samples_remaining);
/* Break enrolling if we can't collect enough correct images for enroll*/
if (samples_remaining == 0U) {
enroll_done = true;
break;
}
sensor_wait_finger_not_present(chain, 0);
}
bep_result = bmlite_send_cmd(chain, CMD_ENROLL, ARG_FINISH);
exit:
bmlite_on_finish_enroll();
return (!enroll_done) ? FPC_BEP_RESULT_GENERAL_ERROR : bep_result;
} }
fpc_bep_result_t bmlite_send_cmd_arg(HCP_comm_t *chain, uint16_t cmd, uint16_t arg1_type, uint16_t arg2_type, void *arg2_data, uint16_t arg2_length) fpc_bep_result_t bep_identify_finger(HCP_comm_t *chain, uint32_t timeout, uint16_t *template_id, bool *match)
{ {
assert(bmlite_init_cmd(chain, cmd, arg1_type)); fpc_bep_result_t bep_result;
assert(bmlite_add_arg(chain, arg2_type, arg2_data, arg2_length)); *match = false;
return bmlite_tranceive(chain); bmlite_on_identify_start();
exit_if_err(bep_capture(chain, timeout));
exit_if_err(bep_image_extract(chain));
exit_if_err(bep_identify(chain));
exit_if_err(bmlite_get_arg(chain, ARG_MATCH));
*match = *(bool *)chain->arg.data;
if(*match) {
bmlite_get_arg(chain, ARG_ID);
*template_id = *(uint16_t *)chain->arg.data;
// Delay for possible updating template on BM-Lite
hal_timebase_busy_wait(50);
}
exit:
bmlite_on_identify_finish();
return bep_result;
} }
fpc_bep_result_t sensor_wait_finger_present(HCP_comm_t *chain, uint16_t timeout) fpc_bep_result_t sensor_wait_finger_present(HCP_comm_t *chain, uint16_t timeout)
@ -132,76 +203,6 @@ fpc_bep_result_t bep_identify(HCP_comm_t *chain)
return bmlite_send_cmd(chain, CMD_IDENTIFY, ARG_NONE); return bmlite_send_cmd(chain, CMD_IDENTIFY, ARG_NONE);
} }
fpc_bep_result_t bep_enroll_finger(HCP_comm_t *chain)
{
uint32_t samples_remaining = 0;
fpc_bep_result_t bep_result = FPC_BEP_RESULT_OK;
bool enroll_done = false;
bmlite_on_start_enroll();
/* Enroll start */
exit_if_err(bmlite_send_cmd(chain, CMD_ENROLL, ARG_START));
for (uint8_t i = 0; i < MAX_CAPTURE_ATTEMPTS; ++i) {
bmlite_on_start_enrollcapture();
bep_result = bep_capture(chain, CAPTURE_TIMEOUT);
bmlite_on_finish_enrollcapture();
if (bep_result != FPC_BEP_RESULT_OK) {
continue;
}
/* Enroll add */
bep_result = bmlite_send_cmd(chain, CMD_ENROLL, ARG_ADD);
if (bep_result != FPC_BEP_RESULT_OK) {
continue;
}
bmlite_get_arg(chain, ARG_COUNT);
samples_remaining = *(uint32_t *)chain->arg.data;
// log_info("Enroll samples remaining: %d\n", samples_remaining);
/* Break enrolling if we can't collect enough correct images for enroll*/
if (samples_remaining == 0U) {
enroll_done = true;
break;
}
sensor_wait_finger_not_present(chain, 0);
}
bep_result = bmlite_send_cmd(chain, CMD_ENROLL, ARG_FINISH);
exit:
bmlite_on_finish_enroll();
return (!enroll_done) ? FPC_BEP_RESULT_GENERAL_ERROR : bep_result;
}
fpc_bep_result_t bep_identify_finger(HCP_comm_t *chain, uint32_t timeout, uint16_t *template_id, bool *match)
{
fpc_bep_result_t bep_result;
*match = false;
bmlite_on_identify_start();
exit_if_err(bep_capture(chain, timeout));
exit_if_err(bep_image_extract(chain));
exit_if_err(bep_identify(chain));
exit_if_err(bmlite_get_arg(chain, ARG_MATCH));
*match = *(bool *)chain->arg.data;
if(*match) {
bmlite_get_arg(chain, ARG_ID);
*template_id = *(uint16_t *)chain->arg.data;
// Delay for possible updating template on BM-Lite
hal_timebase_busy_wait(50);
}
exit:
bmlite_on_identify_finish();
return bep_result;
}
fpc_bep_result_t bep_template_save(HCP_comm_t *chain, uint16_t template_id) fpc_bep_result_t bep_template_save(HCP_comm_t *chain, uint16_t template_id)
{ {
return bmlite_send_cmd_arg(chain, CMD_TEMPLATE, ARG_SAVE, ARG_ID, &template_id, sizeof(template_id)); return bmlite_send_cmd_arg(chain, CMD_TEMPLATE, ARG_SAVE, ARG_ID, &template_id, sizeof(template_id));
@ -308,3 +309,17 @@ fpc_bep_result_t bep_sensor_reset(HCP_comm_t *chain)
return bmlite_send_cmd(chain, CMD_SENSOR, ARG_RESET); return bmlite_send_cmd(chain, CMD_SENSOR, ARG_RESET);
} }
fpc_bep_result_t bmlite_send_cmd(HCP_comm_t *chain, uint16_t cmd, uint16_t arg_type)
{
assert(bmlite_init_cmd(chain, cmd, arg_type));
return bmlite_tranceive(chain);
}
fpc_bep_result_t bmlite_send_cmd_arg(HCP_comm_t *chain, uint16_t cmd, uint16_t arg1_type, uint16_t arg2_type, void *arg2_data, uint16_t arg2_length)
{
assert(bmlite_init_cmd(chain, cmd, arg1_type));
assert(bmlite_add_arg(chain, arg2_type, arg2_data, arg2_length));
return bmlite_tranceive(chain);
}

View File

@ -1,3 +1,19 @@
/*
* Copyright (c) 2020 Andrey Perminov <andrey.ppp@gmail.com>
*
* 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.
*/
#include <string.h> #include <string.h>
#include "platform.h" #include "platform.h"
@ -261,7 +277,7 @@ fpc_bep_result_t bmlite_send(HCP_comm_t *hcp_comm)
return bep_result; return bep_result;
} }
fpc_bep_result_t _tx_link(HCP_comm_t *hcp_comm) static fpc_bep_result_t _tx_link(HCP_comm_t *hcp_comm)
{ {
fpc_bep_result_t bep_result; fpc_bep_result_t bep_result;

View File

@ -12,14 +12,17 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
* Modified by Andrey Perminov <andrey.ppp@gmail.com>
* for BM-Lite applications
*/ */
/** /**
* @file platform.c * @file platform.c
* @brief Platform specific functions * @brief Platform specific functions
*/ */
#include "fpc_bep_types.h" #include "fpc_bep_types.h"
#include "platform.h" #include "platform.h"
#include "bmlite_hal.h" #include "bmlite_hal.h"

View File

@ -13,6 +13,11 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
#
# Modified by Andrey Perminov <andrey.ppp@gmail.com>
# for FPC BM-Lite applications
#
CPU = cortex_m4 CPU = cortex_m4
LOG := LOG :=

View File

@ -12,6 +12,9 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
* Modified by Andrey Perminov <andrey.ppp@gmail.com>
* for FPC BM-Lite applications
*/ */
/** /**

View File

@ -12,8 +12,12 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
* Modified by Andrey Perminov <andrey.ppp@gmail.com>
* for FPC BM-Lite applications
*/ */
/** /**
* @file board_leds.c * @file board_leds.c
* @brief Leds control functions. * @brief Leds control functions.

View File

@ -12,6 +12,9 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
* Modified by Andrey Perminov <andrey.ppp@gmail.com>
* for FPC BM-Lite applications
*/ */
/** /**

View File

@ -12,6 +12,9 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
* Modified by Andrey Perminov <andrey.ppp@gmail.com>
* for FPC BM-Lite applications
*/ */
/** /**