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
|
#include "arch.h"
#include "driver/gpio.h"
#include "driver/stdout.h"
#include "driver/nrf24l01.h"
#include "driver/counter.h"
#define TIMEIT(index, functioncall) \
counter.start(); \
functioncall; \
counter.stop(); \
kout << endl << index << " :: " << dec << counter.value << "/" << counter.overflow << endl;
void loop(void)
{
gpio.led_toggle(1);
uint8_t status = nrf24l01.getStatus();
kout << "status: " << hex << status;
if (status & 0x40) {
kout << " RX_DR";
}
if (status & 0x20) {
kout << " TX_DS";
}
if (status & 0x10) {
kout << " MAX_RT";
}
if ((status & 0x0e) == 0x0e) {
kout << " RX_EMPTY";
}
if (status & 0x01) {
kout << " TX_FULL";
}
kout << endl;
kout << "write: ";
nrf24l01.setRetries(0, 0);
nrf24l01.setDynamicPayloads(false);
nrf24l01.setDynamicAck(false);
TIMEIT("blocking write(3)", nrf24l01.write("foo", 3, true, true));
TIMEIT("blocking write(10)", nrf24l01.write("123456789", 10, true, true));
TIMEIT("blocking write(20)", nrf24l01.write("123456789123456789", 20, true, true));
//TIMEIT("blocking write(30)", nrf24l01.write("123456789123456789123456789", 30, true, true));
nrf24l01.startListening();
arch.delay_ms(10);
nrf24l01.stopListening();
}
int main(void)
{
arch.setup();
gpio.setup();
kout.setup();
kout << "nrf24l01.setup() ...";
nrf24l01.setup();
kout << " OK" << endl;
gpio.led_on(0);
arch.idle_loop();
return 0;
}
|