Sensor interrupt initialization function */
| 96 | |
| 97 | /* Sensor interrupt initialization function */ |
| 98 | static rt_err_t _sensor_irq_init(rt_sensor_t sensor) |
| 99 | { |
| 100 | if (sensor->config.irq_pin.pin == PIN_IRQ_PIN_NONE) |
| 101 | { |
| 102 | return -RT_EINVAL; |
| 103 | } |
| 104 | |
| 105 | rt_pin_mode(sensor->config.irq_pin.pin, sensor->config.irq_pin.mode); |
| 106 | |
| 107 | if (sensor->config.irq_pin.mode == PIN_MODE_INPUT_PULLDOWN) |
| 108 | { |
| 109 | rt_pin_attach_irq(sensor->config.irq_pin.pin, PIN_IRQ_MODE_RISING, _irq_callback, (void *)sensor); |
| 110 | } |
| 111 | else if (sensor->config.irq_pin.mode == PIN_MODE_INPUT_PULLUP) |
| 112 | { |
| 113 | rt_pin_attach_irq(sensor->config.irq_pin.pin, PIN_IRQ_MODE_FALLING, _irq_callback, (void *)sensor); |
| 114 | } |
| 115 | else if (sensor->config.irq_pin.mode == PIN_MODE_INPUT) |
| 116 | { |
| 117 | rt_pin_attach_irq(sensor->config.irq_pin.pin, PIN_IRQ_MODE_RISING_FALLING, _irq_callback, (void *)sensor); |
| 118 | } |
| 119 | |
| 120 | rt_pin_irq_enable(sensor->config.irq_pin.pin, RT_TRUE); |
| 121 | |
| 122 | LOG_I("interrupt init success"); |
| 123 | |
| 124 | return 0; |
| 125 | } |
| 126 | |
| 127 | /* sensor local ops */ |
| 128 | static rt_ssize_t _local_fetch_data(rt_sensor_t sensor, rt_sensor_data_t buf, rt_size_t len) |
no test coverage detected