Loading...
Searching...
No Matches
ir_nec.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2022 Dario Petrillo
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
19
20#include <stdint.h>
21
22#include "isrpipe.h"
23#include "periph/gpio.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
32typedef struct {
33 uint8_t addr;
34 uint8_t cmd;
36
40typedef struct {
41 gpio_t pin;
43
47typedef struct {
48 gpio_t pin;
50
51 uint32_t last_rising;
52 uint32_t data;
53 uint8_t read_bits;
54
55 uint8_t isrpipe_buf[2 * sizeof(ir_nec_cmd_t)];
56} ir_nec_t;
57
66int ir_nec_init(ir_nec_t *dev, const ir_nec_params_t *params);
67
77int ir_nec_read(ir_nec_t *dev, ir_nec_cmd_t *command);
78
79#ifdef __cplusplus
80}
81#endif
82
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:32
uint8_t cmd
Command.
Definition ir_nec.h:34
uint8_t addr
Address (usually 0, depends on the remote)
Definition ir_nec.h:33
Device initialization parameters.
Definition ir_nec.h:40
gpio_t pin
Input pin.
Definition ir_nec.h:41
Device descriptor for the driver.
Definition ir_nec.h:47
uint8_t read_bits
Number of bits read so far.
Definition ir_nec.h:53
uint32_t last_rising
Timestamp of the last rising edge.
Definition ir_nec.h:51
gpio_t pin
Input pin.
Definition ir_nec.h:48
uint32_t data
Data packet being received.
Definition ir_nec.h:52
uint8_t isrpipe_buf[2 *sizeof(ir_nec_cmd_t)]
Buffer for the isrpipe.
Definition ir_nec.h:55
isrpipe_t isrpipe
Internal pipe for commands.
Definition ir_nec.h:49
Context structure for isrpipe.
Definition isrpipe.h:36