Loading...
Searching...
No Matches
pir.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2014 Freie Universität Berlin
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
20
21#include "sched.h"
22#include "periph/gpio.h"
23#include "stdbool.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
32enum {
33 PIR_OK = 0,
37};
38
42typedef struct {
43 gpio_t gpio;
46
58
67#ifndef PIR_MSG_T_STATUS_START
68#define PIR_MSG_T_STATUS_START 150
69#endif
71
79
96int pir_init(pir_t *dev, const pir_params_t* params);
97
106
118int pir_get_occupancy(pir_t *dev, int16_t *occup);
119
135
136#ifdef __cplusplus
137}
138#endif
139
Low-level GPIO peripheral driver interface definitions.
int16_t kernel_pid_t
Unique process identifier.
Definition sched.h:134
#define PIR_MSG_T_STATUS_START
Sensitivity of sensor.
Definition pir.h:68
int pir_get_occupancy(pir_t *dev, int16_t *occup)
Read OCCUPANCY value.
pir_event_t pir_get_status(const pir_t *dev)
Read the current status of the motion sensor.
int pir_register_thread(pir_t *dev)
Register a thread for notification when state changes on the motion sensor.
int pir_init(pir_t *dev, const pir_params_t *params)
Initialize a PIR motion sensor.
pir_event_t
event type for a PIR sensor
Definition pir.h:75
@ PIR_STATUS_INACTIVE
no motion is detected
Definition pir.h:77
@ PIR_STATUS_ACTIVE
motion was detected
Definition pir.h:76
@ PIR_TIMEERR
errors while getting the time information
Definition pir.h:36
@ PIR_OK
everything went as expected
Definition pir.h:33
@ PIR_NOTHREAD
errors while registering the thread
Definition pir.h:35
@ PIR_NOGPIO
errors while initializing the GPIO
Definition pir.h:34
Parameters needed for device initialization.
Definition pir.h:42
bool active_high
Active when GPIO pin is high or not.
Definition pir.h:44
gpio_t gpio
GPIO device which is used.
Definition pir.h:43
device descriptor for a PIR sensor
Definition pir.h:50
uint64_t start_active_time
Time when PIR starts to be active.
Definition pir.h:51
kernel_pid_t msg_thread_pid
thread to msg on irq
Definition pir.h:54
uint64_t accum_active_time
Accumulated active time.
Definition pir.h:52
bool active
Indicate PIR is active or not.
Definition pir.h:55
uint64_t last_read_time
Last time when PIR status is read.
Definition pir.h:53
pir_params_t p
Configuration parameters.
Definition pir.h:56