Paparazzi UAS  v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
 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 
7 volatile uint8_t tx_tail;
12 
13 
14 #define NB_STATE 2
15 #define NB_PHASE 2
16 
18  { {512, 1023, 512, 1},
19  {512 , 1 , 512 , 1023}
20  },
21  { {512, 874, 1023, 874},
22  {512 , 150 , 1 , 150}
23  }
24 };
25 
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 */
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 
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 
unsigned short uint16_t
Definition: types.h:16
static const uint16_t audio_telemetry_sample[NB_STATE][NB_PHASE][SAMPLES_PER_PERIOD]
#define NB_PHASE
static uint8_t audio_telemetry_phase
#define T1IR
Definition: LPC21xx.h:72
static uint8_t get_next_bit(void)
uint8_t tx_bit_idx
uint8_t tx_head
#define SAMPLES_PER_PERIOD
#define NB_STATE
#define DACR
Definition: LPC21xx.h:389
#define VICVectAddr
Definition: LPC21xx.h:436
uint8_t tx_buf[TX_BUF_SIZE]
#define TIR_MR0I
Definition: lpcTMR.h:44
uint8_t ck_a
static uint8_t audio_telemetry_sample_idx
#define TX_BUF_SIZE
void TIMER1_ISR(void)
unsigned char uint8_t
Definition: types.h:14
uint8_t ck_b
#define ISR_EXIT()
Definition: armVIC.h:61
volatile uint8_t tx_tail
uint8_t tx_byte
uint8_t audio_telemetry_nb_ovrn
#define ISR_ENTRY()
Definition: armVIC.h:40