1 /* 2 * Copyright (c) 2022 Chipsea Technologies (Shenzhen) Corp., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 #ifndef MODEL_SENSOR_DRIVER_PPG_SENSOR_PPG_CONFIG_H 10 #define MODEL_SENSOR_DRIVER_PPG_SENSOR_PPG_CONFIG_H 11 12 #include "device_resource_if.h" 13 #include "hdf_device_desc.h" 14 #include "spi_if.h" 15 #include "gpio_if.h" 16 #include "hdf_log.h" 17 #include "sensor_device_type.h" 18 #include "sensor_platform_if.h" 19 #include "sensor_config_parser.h" 20 21 #define PPG_PIN_CONFIG_MAX_ITEM 30 22 #define PPG_INFO_NAME_MAX_LEN 16 23 #define PPG_TYPE_GPIO 0 24 #define PPG_TYPE_IRQ 1 25 26 enum MultiUsePinSetCfgIndex { 27 PPG_PIN_CFG_ADDR_INDEX = 0, 28 PPG_PIN_CFG_ADDR_LEN_INDEX, 29 PPG_PIN_CFG_ADDR_VALUE_INDEX, 30 PPG_PIN_CFG_INDEX_MAX, 31 }; 32 33 struct MultiUsePinSetCfg { 34 uint32_t regAddr; 35 uint32_t regLen; 36 uint32_t regValue; 37 }; 38 39 struct IrqFuncCfg { 40 uint16_t pinIndex; 41 GpioIrqFunc func; 42 }; 43 44 enum GpiosPinMode { 45 PPG_PIN_LOW = 0, 46 PPG_PIN_HIGH, 47 PPG_PIN_IRQ, 48 }; 49 50 enum GpiosPinSetCfgIndex { 51 PPG_GPIO_PIN_INDEX = 0, 52 PPG_GPIO_NO_INDEX, 53 PPG_GPIO_TYPE_INDEX, 54 PPG_GPIO_DIR_TYPE_INDEX, 55 PPG_GPIO_MODE_INDEX, 56 PPG_GPIOS_INDEX_MAX, 57 }; 58 59 struct GpiosPinSetCfg { 60 uint16_t pinIndex; 61 uint16_t gpioNo; 62 uint16_t gpioType; 63 uint16_t dirType; 64 union { 65 uint16_t gpioValue; 66 uint16_t triggerMode; 67 }; 68 }; 69 70 struct PpgPinCfg { 71 uint32_t gpioNum; 72 struct MultiUsePinSetCfg *multiUsePin; 73 struct GpiosPinSetCfg *gpios; 74 }; 75 76 struct PpgCfgData { 77 struct SensorCfgData sensorCfg; 78 struct PpgPinCfg pinCfg; 79 }; 80 81 int32_t EnablePpgIrq(uint16_t pinIndex); 82 int32_t DisablePpgIrq(uint16_t pinIndex); 83 int32_t SetPpgIrq(uint16_t pinIndex, GpioIrqFunc irqFunc); 84 void ReleasePpgCfgData(void); 85 int32_t ParsePpgCfgData(const struct DeviceResourceNode *node, struct PpgCfgData **cfgData); 86 struct PpgCfgData *GetPpgConfig(void); 87 88 #endif // MODEL_SENSOR_DRIVER_PPG_SENSOR_PPG_CONFIG_H 89