1 /* 2 * Copyright (c) 2022 Linumiz 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ZEPHYR_INCLUDE_DRIVERS_SENSOR_GROW_R502A_H_ 8 #define ZEPHYR_INCLUDE_DRIVERS_SENSOR_GROW_R502A_H_ 9 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 13 14 #include <zephyr/drivers/sensor.h> 15 16 /*LED color code*/ 17 enum r502a_led_color_idx { 18 R502A_LED_COLOR_RED = 0x01, 19 R502A_LED_COLOR_BLUE, 20 R502A_LED_COLOR_PURPLE, 21 }; 22 23 #define R502A_BAUD_9600 1 24 #define R502A_BAUD_19200 2 25 #define R502A_BAUD_38400 4 26 #define R502A_BAUD_57600 6 27 #define R502A_BAUD_115200 12 28 29 enum r502a_sec_level { 30 R502A_SEC_LEVEL_1 = 1, 31 R502A_SEC_LEVEL_2, 32 R502A_SEC_LEVEL_3, 33 R502A_SEC_LEVEL_4, 34 R502A_SEC_LEVEL_5 35 }; 36 37 enum r502a_data_len { 38 R502A_PKG_LEN_32, 39 R502A_PKG_LEN_64, 40 R502A_PKG_LEN_128, 41 R502A_PKG_LEN_256 42 }; 43 44 enum r502a_sys_param_set { 45 R502A_BAUD_RATE = 4, 46 R502A_SECURITY_LEVEL, 47 R502A_DATA_PKG_LEN 48 }; 49 50 struct r502a_sys_param { 51 uint16_t status_reg; 52 uint16_t system_id; 53 uint16_t lib_size; 54 uint16_t sec_level; 55 uint32_t addr; 56 uint16_t data_pkt_size; 57 uint32_t baud; 58 } __packed; 59 60 struct r502a_template { 61 uint8_t *data; 62 size_t len; 63 }; 64 enum sensor_channel_grow_r502a { 65 /** Fingerprint template count, ID number for enrolling and searching*/ 66 SENSOR_CHAN_FINGERPRINT = SENSOR_CHAN_PRIV_START, 67 }; 68 69 enum sensor_trigger_type_grow_r502a { 70 /** Trigger fires when a touch is detected. */ 71 SENSOR_TRIG_TOUCH = SENSOR_TRIG_PRIV_START, 72 }; 73 74 enum sensor_attribute_grow_r502a { 75 /** To capture finger and store as feature file in 76 * RAM buffers char_buf_1 and char_buf_2. 77 */ 78 SENSOR_ATTR_R502A_CAPTURE = SENSOR_ATTR_PRIV_START, 79 /** create template from feature files at RAM buffers 80 * char_buf_1 & char_buf_2 and store a template data 81 * back in both RAM buffers char_buf_1 and char_buf_2. 82 */ 83 SENSOR_ATTR_R502A_TEMPLATE_CREATE, 84 /** Add template to the sensor record storage */ 85 /** 86 * @param val->val1 record index for template to be 87 * stored in the sensor device's flash 88 * library. 89 */ 90 SENSOR_ATTR_R502A_RECORD_ADD, 91 /** To find requested data in record storage */ 92 /** 93 * @result val->val1 matched record index. 94 * val->val2 matching score. 95 */ 96 SENSOR_ATTR_R502A_RECORD_FIND, 97 /** To delete mentioned data from record storage */ 98 /** 99 * @param val->val1 record start index to be deleted. 100 * @param val->val2 number of records to be deleted. 101 */ 102 SENSOR_ATTR_R502A_RECORD_DEL, 103 /** To get available position to store data on record storage */ 104 SENSOR_ATTR_R502A_RECORD_FREE_IDX, 105 /** To empty the storage record*/ 106 SENSOR_ATTR_R502A_RECORD_EMPTY, 107 /** To load template from storage to RAM buffer of sensor*/ 108 /** 109 * @param val->val1 record start index to be loaded in 110 * device internal RAM buffer. 111 */ 112 SENSOR_ATTR_R502A_RECORD_LOAD, 113 /** To template data stored in sensor's RAM buffer*/ 114 /** 115 * @result 116 * val->val1 match result. 117 * [R502A_FINGER_MATCH_FOUND or 118 * R502A_FINGER_MATCH_NOT_FOUND] 119 * val->val2 matching score. 120 */ 121 SENSOR_ATTR_R502A_COMPARE, 122 /** To read and write device's system parameters */ 123 /** sensor_attr_set 124 * @param val->val1 parameter number from enum r502a_sys_param_set. 125 * @param val->val2 content to be written for the respective parameter. 126 */ 127 /** sensor_attr_get 128 * @result val->ex.data buffer holds the system parameter values. 129 */ 130 SENSOR_ATTR_R502A_SYS_PARAM, 131 }; 132 133 int r502a_read_sys_param(const struct device *dev, struct r502a_sys_param *val); 134 int fps_upload_char_buf(const struct device *dev, struct r502a_template *temp); 135 int fps_download_char_buf(const struct device *dev, uint8_t char_buf_id, 136 const struct r502a_template *temp); 137 138 #ifdef __cplusplus 139 } 140 #endif 141 142 #endif /* ZEPHYR_INCLUDE_ZEPHYR_DRIVERS_SENSOR_GROW_R502A_H_ */ 143