forked from df8oe/RS41HUP
-
Notifications
You must be signed in to change notification settings - Fork 9
/
f_rtty.c
41 lines (39 loc) · 777 Bytes
/
f_rtty.c
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
#include "f_rtty.h"
uint8_t start_bits;
rttyStates send_rtty(char *buffer) {
// Step through a supplied charater bit by bit (with each function call), and return
// the current state (one, zero, end)
static uint8_t nr_bit = 0;
nr_bit++;
//
if (start_bits){
start_bits--;
return rttyOne;
}
// Start bit.
if (nr_bit == 1) {
return rttyZero;
}
// Data bits
if (nr_bit > 1 && nr_bit < (RTTY_7BIT ? 9 : 10)) {
if ((*(buffer) >> (nr_bit - 2)) & 0x01) {
return rttyOne;
} else {
return rttyZero;
}
}
#ifdef RTTY_7BIT
nr_bit++;
#endif
// Stop Bit
if (nr_bit == 10) {
return rttyOne;
}
#ifdef RTTY_USE_2_STOP_BITS
if (nr_bit == 11) {
return rttyOne;
}
#endif
nr_bit = 0;
return rttyEnd;
}