Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros 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  {
19  {{512, 1023, 512, 1},
20  {512 ,1 , 512 , 1023}},
21  {{512, 874, 1023, 874},
22  {512 ,150 ,1 , 150}}
23  };
24 
27 
28 
29 static inline uint8_t get_next_bit( void ) {
30  uint8_t ret;
31  /* start bit */
32  if (tx_bit_idx == 0)
33  ret = 0;
34  /* data bits */
35  else if (tx_bit_idx < 9) {
36  ret = tx_byte & 0x01;
37  tx_byte >>= 1;
38  }
39  /* stop_bit */
40  else {
41  ret = 1;
42  }
43  tx_bit_idx++;
44 
45  if (tx_bit_idx >= 10) {
46  /* if we have nothing left to transmit */
47  if( tx_head == tx_tail ) {
48  /* hack to stay with data = 1 */
49  tx_bit_idx--;
50  } else {
51  /* else load next byte */
53  tx_bit_idx = 0;
54  tx_tail++;
55  if( tx_tail >= TX_BUF_SIZE )
56  tx_tail = 0;
57  }
58  }
59  return ret;
60 }
61 
62 void TIMER1_ISR ( void ) {
63  ISR_ENTRY();
64  static uint8_t audio_telemetry_bit;
65 
70  audio_telemetry_phase ^= audio_telemetry_bit;
71  audio_telemetry_bit = get_next_bit();
72  }
73 
74  /* clear interrupt */
75  T1IR = TIR_MR0I;
76  VICVectAddr = 0x00000000;
77  ISR_EXIT();
78 }
79 
80 
81 
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:357
#define VICVectAddr
Definition: LPC21xx.h:404
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