ir_nec.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 Dario Petrillo
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 
21 #ifndef IR_NEC_H
22 #define IR_NEC_H
23 
24 #include <stdint.h>
25 
26 #include "isrpipe.h"
27 #include "periph/gpio.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
36 typedef struct {
37  uint8_t addr;
38  uint8_t cmd;
39 } ir_nec_cmd_t;
40 
44 typedef struct {
45  gpio_t pin;
47 
51 typedef struct {
52  gpio_t pin;
55  uint32_t last_rising;
56  uint32_t data;
57  uint8_t read_bits;
59  uint8_t isrpipe_buf[2 * sizeof(ir_nec_cmd_t)];
60 } ir_nec_t;
61 
70 int ir_nec_init(ir_nec_t *dev, const ir_nec_params_t *params);
71 
81 int ir_nec_read(ir_nec_t *dev, ir_nec_cmd_t *command);
82 
83 #ifdef __cplusplus
84 }
85 #endif
86 
87 #endif /* IR_NEC_H */
Low-level GPIO peripheral driver interface definitions.
int ir_nec_read(ir_nec_t *dev, ir_nec_cmd_t *command)
Read a command packet.
int ir_nec_init(ir_nec_t *dev, const ir_nec_params_t *params)
Initialize the given device.
isrpipe Interface
NEC command structure.
Definition: ir_nec.h:36
uint8_t cmd
Command.
Definition: ir_nec.h:38
uint8_t addr
Address (usually 0, depends on the remote)
Definition: ir_nec.h:37
Device initialization parameters.
Definition: ir_nec.h:44
gpio_t pin
Input pin.
Definition: ir_nec.h:45
Device descriptor for the driver.
Definition: ir_nec.h:51
uint8_t read_bits
Number of bits read so far.
Definition: ir_nec.h:57
uint32_t last_rising
Timestamp of the last rising edge.
Definition: ir_nec.h:55
gpio_t pin
Input pin.
Definition: ir_nec.h:52
uint32_t data
Data packet being received.
Definition: ir_nec.h:56
isrpipe_t isrpipe
Internal pipe for commands.
Definition: ir_nec.h:53
Context structure for isrpipe.
Definition: isrpipe.h:37