forked from gioblu/PJON
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTiming.h
91 lines (71 loc) · 2.47 KB
/
Timing.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
90
91
/* PJON OverSampling strategy Transmission Timing table
Copyright 2018, Giovanni Blu Mitolo All rights reserved.
All benchmarks are executed with NetworkAnalysis and SpeedTest examples.
The following constants setup is quite conservative and determined only
with a huge amount of time testing tweaking values and analysing results.
Theese can be changed to obtain faster speed. Probably you will need
experience, time and an oscilloscope. */
#pragma once
/* ATmega88/168/328 - Arduino Duemilanove, Uno, Nano, Mini, Pro, Pro mini */
#if defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || \
defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__)
#if OS_MODE == 1
#if F_CPU == 16000000L
#define OS_BIT_WIDTH 512
#define OS_BIT_SPACER 328
#define OS_ACCEPTANCE 78
#endif
#endif
#endif
/* ATmega1280/2560 - Arduino Mega/Mega-nano ------------------------------- */
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#if OS_MODE == 1
#define OS_BIT_WIDTH 508
#define OS_BIT_SPACER 332
#define OS_ACCEPTANCE 82
#endif
#endif
/* ATmega16/32U4 - Arduino Leonardo/Micro --------------------------------- */
#if defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)
#if OS_MODE == 1
#define OS_BIT_WIDTH 508
#define OS_BIT_SPACER 332
#define OS_ACCEPTANCE 82
#endif
#endif
/* NodeMCU, generic ESP8266 ----------------------------------------------- */
#if defined(ESP8266)
#if OS_MODE == 1
#if F_CPU == 80000000L
#define OS_BIT_WIDTH 520
#define OS_BIT_SPACER 332
#define OS_ACCEPTANCE 82
#endif
#endif
#endif
#ifndef OS_BIT_WIDTH
#define OS_BIT_WIDTH 512 // 520 microseconds detected by oscilloscope
#endif
#ifndef OS_BIT_SPACER
#define OS_BIT_SPACER 328 // 340 microseconds detected by oscilloscope
#endif
#ifndef OS_ACCEPTANCE
#define OS_ACCEPTANCE 78 // 340 microseconds detected by oscilloscope
#endif
#define OS_TIMEOUT 10000 // 10 milliseconds maximum sync ack timeout
/* Maximum initial delay in milliseconds: */
#ifndef OS_INITIAL_DELAY
#define OS_INITIAL_DELAY 1000
#endif
/* Maximum delay in case of collision in microseconds: */
#ifndef OS_COLLISION_DELAY
#define OS_COLLISION_DELAY 64
#endif
/* Maximum transmission attempts */
#ifndef OS_MAX_ATTEMPTS
#define OS_MAX_ATTEMPTS 10
#endif
/* Back-off exponential degree */
#ifndef OS_BACK_OFF_DEGREE
#define OS_BACK_OFF_DEGREE 5
#endif