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 
9 #pragma once
10 
23 #include <stdint.h>
24 
25 #include "isrpipe.h"
26 #include "periph/gpio.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
35 typedef struct {
36  uint8_t addr;
37  uint8_t cmd;
38 } ir_nec_cmd_t;
39 
43 typedef struct {
44  gpio_t pin;
46 
50 typedef struct {
51  gpio_t pin;
54  uint32_t last_rising;
55  uint32_t data;
56  uint8_t read_bits;
58  uint8_t isrpipe_buf[2 * sizeof(ir_nec_cmd_t)];
59 } ir_nec_t;
60 
69 int ir_nec_init(ir_nec_t *dev, const ir_nec_params_t *params);
70 
80 int ir_nec_read(ir_nec_t *dev, ir_nec_cmd_t *command);
81 
82 #ifdef __cplusplus
83 }
84 #endif
85 
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:35
uint8_t cmd
Command.
Definition: ir_nec.h:37
uint8_t addr
Address (usually 0, depends on the remote)
Definition: ir_nec.h:36
Device initialization parameters.
Definition: ir_nec.h:43
gpio_t pin
Input pin.
Definition: ir_nec.h:44
Device descriptor for the driver.
Definition: ir_nec.h:50
uint8_t read_bits
Number of bits read so far.
Definition: ir_nec.h:56
uint32_t last_rising
Timestamp of the last rising edge.
Definition: ir_nec.h:54
gpio_t pin
Input pin.
Definition: ir_nec.h:51
uint32_t data
Data packet being received.
Definition: ir_nec.h:55
isrpipe_t isrpipe
Internal pipe for commands.
Definition: ir_nec.h:52
Context structure for isrpipe.
Definition: isrpipe.h:36