Paparazzi UAS
v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
audio_telemetry_hw.c
Go to the documentation of this file.
1
#include "
audio_telemetry.h
"
2
#include "
types.h
"
3
#include "
armVIC.h
"
4
5
uint8_t
audio_telemetry_nb_ovrn
;
6
uint8_t
tx_head
;
7
volatile
uint8_t
tx_tail
;
8
uint8_t
tx_buf
[
TX_BUF_SIZE
];
9
uint8_t
ck_a
,
ck_b
;
10
uint8_t
tx_byte
;
11
uint8_t
tx_bit_idx
;
12
13
14
#define NB_STATE 2
15
#define NB_PHASE 2
16
17
static
const
uint16_t
audio_telemetry_sample
[
NB_STATE
][
NB_PHASE
][
SAMPLES_PER_PERIOD
] = {
18
{ {512, 1023, 512, 1},
19
{512 , 1 , 512 , 1023}
20
},
21
{ {512, 874, 1023, 874},
22
{512 , 150 , 1 , 150}
23
}
24
};
25
26
static
uint8_t
audio_telemetry_sample_idx
= 0;
27
static
uint8_t
audio_telemetry_phase
= 0;
28
29
30
static
inline
uint8_t
get_next_bit
(
void
)
31
{
32
uint8_t
ret;
33
/* start bit */
34
if
(
tx_bit_idx
== 0) {
35
ret = 0;
36
}
37
/* data bits */
38
else
if
(
tx_bit_idx
< 9) {
39
ret =
tx_byte
& 0x01;
40
tx_byte
>>= 1;
41
}
42
/* stop_bit */
43
else
{
44
ret = 1;
45
}
46
tx_bit_idx
++;
47
48
if
(
tx_bit_idx
>= 10) {
49
/* if we have nothing left to transmit */
50
if
(
tx_head
==
tx_tail
) {
51
/* hack to stay with data = 1 */
52
tx_bit_idx
--;
53
}
else
{
54
/* else load next byte */
55
tx_byte
=
tx_buf
[
tx_tail
];
56
tx_bit_idx
= 0;
57
tx_tail
++;
58
if
(
tx_tail
>=
TX_BUF_SIZE
) {
59
tx_tail
= 0;
60
}
61
}
62
}
63
return
ret;
64
}
65
66
void
TIMER1_ISR
(
void
)
67
{
68
ISR_ENTRY
();
69
static
uint8_t
audio_telemetry_bit;
70
71
DACR
=
audio_telemetry_sample
[audio_telemetry_bit][
audio_telemetry_phase
][
audio_telemetry_sample_idx
] << 6;
72
audio_telemetry_sample_idx
++;
73
if
(
audio_telemetry_sample_idx
==
SAMPLES_PER_PERIOD
) {
74
audio_telemetry_sample_idx
= 0;
75
audio_telemetry_phase
^= audio_telemetry_bit;
76
audio_telemetry_bit =
get_next_bit
();
77
}
78
79
/* clear interrupt */
80
T1IR
=
TIR_MR0I
;
81
VICVectAddr
= 0x00000000;
82
ISR_EXIT
();
83
}
84
85
86
uint16_t
unsigned short uint16_t
Definition:
types.h:16
audio_telemetry_sample
static const uint16_t audio_telemetry_sample[NB_STATE][NB_PHASE][SAMPLES_PER_PERIOD]
Definition:
audio_telemetry_hw.c:17
types.h
NB_PHASE
#define NB_PHASE
Definition:
audio_telemetry_hw.c:15
audio_telemetry_phase
static uint8_t audio_telemetry_phase
Definition:
audio_telemetry_hw.c:27
T1IR
#define T1IR
Definition:
LPC21xx.h:72
get_next_bit
static uint8_t get_next_bit(void)
Definition:
audio_telemetry_hw.c:30
tx_bit_idx
uint8_t tx_bit_idx
Definition:
audio_telemetry_hw.c:11
tx_head
uint8_t tx_head
Definition:
audio_telemetry_hw.c:6
SAMPLES_PER_PERIOD
#define SAMPLES_PER_PERIOD
Definition:
audio_telemetry_hw.h:28
NB_STATE
#define NB_STATE
Definition:
audio_telemetry_hw.c:14
DACR
#define DACR
Definition:
LPC21xx.h:389
VICVectAddr
#define VICVectAddr
Definition:
LPC21xx.h:436
tx_buf
uint8_t tx_buf[TX_BUF_SIZE]
Definition:
audio_telemetry_hw.c:8
audio_telemetry.h
TIR_MR0I
#define TIR_MR0I
Definition:
lpcTMR.h:44
ck_a
uint8_t ck_a
Definition:
audio_telemetry_hw.c:9
audio_telemetry_sample_idx
static uint8_t audio_telemetry_sample_idx
Definition:
audio_telemetry_hw.c:26
TX_BUF_SIZE
#define TX_BUF_SIZE
Definition:
audio_telemetry.h:36
armVIC.h
TIMER1_ISR
void TIMER1_ISR(void)
Definition:
audio_telemetry_hw.c:66
uint8_t
unsigned char uint8_t
Definition:
types.h:14
ck_b
uint8_t ck_b
Definition:
audio_telemetry_hw.c:9
ISR_EXIT
#define ISR_EXIT()
Definition:
armVIC.h:61
tx_tail
volatile uint8_t tx_tail
Definition:
audio_telemetry_hw.c:7
tx_byte
uint8_t tx_byte
Definition:
audio_telemetry_hw.c:10
audio_telemetry_nb_ovrn
uint8_t audio_telemetry_nb_ovrn
Definition:
audio_telemetry_hw.c:5
ISR_ENTRY
#define ISR_ENTRY()
Definition:
armVIC.h:40
sw
airborne
arch
lpc21
subsystems
datalink
audio_telemetry_hw.c
Generated on Tue Jun 21 2016 14:01:10 for Paparazzi UAS by
1.8.8