Loading...
Searching...
No Matches
pir.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2014 Freie Universität Berlin
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
22#ifndef PIR_H
23#define PIR_H
24
25#include "sched.h"
26#include "periph/gpio.h"
27#include "stdbool.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
36enum {
37 PIR_OK = 0,
41};
42
46typedef struct {
47 gpio_t gpio;
50
62
71#ifndef PIR_MSG_T_STATUS_START
72#define PIR_MSG_T_STATUS_START 150
73#endif
83
100int pir_init(pir_t *dev, const pir_params_t* params);
101
110
122int pir_get_occupancy(pir_t *dev, int16_t *occup);
123
139
140#ifdef __cplusplus
141}
142#endif
143
144#endif /* PIR_H */
Low-level GPIO peripheral driver interface definitions.
int16_t kernel_pid_t
Unique process identifier.
Definition sched.h:139
#define PIR_MSG_T_STATUS_START
Sensitivity of sensor.
Definition pir.h:72
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:79
@ PIR_TIMEERR
errors while getting the time information
Definition pir.h:40
@ PIR_OK
everything went as expected
Definition pir.h:37
@ PIR_NOTHREAD
errors while registering the thread
Definition pir.h:39
@ PIR_NOGPIO
errors while initializing the GPIO
Definition pir.h:38
@ PIR_STATUS_INACTIVE
no motion is detected
Definition pir.h:81
@ PIR_STATUS_ACTIVE
motion was detected
Definition pir.h:80
Scheduler API definition.
Parameters needed for device initialization.
Definition pir.h:46
bool active_high
Active when GPIO pin is high or not.
Definition pir.h:48
gpio_t gpio
GPIO device which is used.
Definition pir.h:47
device descriptor for a PIR sensor
Definition pir.h:54
uint64_t start_active_time
Time when PIR starts to be active.
Definition pir.h:55
kernel_pid_t msg_thread_pid
thread to msg on irq
Definition pir.h:58
uint64_t accum_active_time
Accumulated active time.
Definition pir.h:56
bool active
Indicate PIR is active or not.
Definition pir.h:59
uint64_t last_read_time
Last time when PIR status is read.
Definition pir.h:57
pir_params_t p
Configuration parameters.
Definition pir.h:60