-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathnrf24_if.h
89 lines (66 loc) · 1.45 KB
/
nrf24_if.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2017 Marcin Ciupak <[email protected]>
*
*/
#ifndef NRF24_IF_H
#define NRF24_IF_H
#include "nRF24L01.h"
#define FIFO_SIZE 65536
struct nrf24_pipe_cfg {
u64 address;
u8 ack;
ssize_t plw;
};
struct nrf24_pipe {
dev_t devt;
struct device *dev;
struct cdev cdev;
int id;
struct nrf24_pipe_cfg cfg;
DECLARE_KFIFO(rx_fifo, u8, FIFO_SIZE);
struct mutex rx_fifo_mutex;
wait_queue_head_t read_wait_queue;
wait_queue_head_t write_wait_queue;
struct list_head list;
u32 sent;
bool write_done;
};
struct nrf24_device_cfg {
u16 data_rate;
u8 crc;
u8 retr_count;
u16 retr_delay;
u8 rf_power;
u8 address_width;
};
struct nrf24_tx_data {
struct nrf24_pipe *pipe;
u8 size;
u8 pload[PLOAD_MAX];
};
struct nrf24_device {
u32 id;
struct device dev;
struct spi_device *spi;
struct list_head pipes;
struct gpio_desc *ce;
struct nrf24_device_cfg cfg;
/* for irqsave */
spinlock_t lock;
struct work_struct isr_work;
struct work_struct rx_work;
/* tx */
STRUCT_KFIFO_REC_1(FIFO_SIZE) tx_fifo;
struct mutex tx_fifo_mutex;
struct task_struct *tx_task_struct;
wait_queue_head_t tx_wait_queue;
wait_queue_head_t tx_done_wait_queue;
bool tx_done;
bool tx_failed;
/* rx */
struct timer_list rx_active_timer;
bool rx_active;
};
#define to_nrf24_device(device) container_of(device, struct nrf24_device, dev)
#endif /* NRF24_IF_H */