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.h
Go to the documentation of this file.
1 #ifndef AUDIO_TELEMETRY_HW_H
2 #define AUDIO_TELEMETRY_HW_H
3 
4 #include "LPC21xx.h"
5 #include BOARD_CONFIG
6 
7 void TIMER1_ISR(void) __attribute__((naked));
8 
9 /* T1 prescaler, set T1_CLK to 5MHz, T1_CLK = PCLK / T1PCLK_DIV */
10 
11 #if (PCLK == 15000000)
12 #define T1_PCLK_DIV 3
13 #else
14 
15 #if (PCLK == 30000000)
16 #define T1_PCLK_DIV 6
17 #else
18 
19 #if (PCLK == 60000000)
20 #define T1_PCLK_DIV 12
21 #else
22 
23 #error unknown PCLK frequency
24 #endif
25 #endif
26 #endif
27 
28 #define SAMPLES_PER_PERIOD 4
29 #define SAMPLE_PERIOD (PCLK/4762/SAMPLES_PER_PERIOD/T1_PCLK_DIV)
30 
31 static inline void audio_telemetry_init(void)
32 {
33  /* turn on DAC pins */
34  PINSEL1 &= 1 << 19;
35  PINSEL1 |= ~(1 << 18);
36  /* reset & disable timer 1 */
37  T1TCR = TCR_RESET;
38  /* set the prescale divider */
39  T1PR = T1_PCLK_DIV - 1;
40  /* select TIMER1 as IRQ */
42  /* enable TIMER1 interrupt */
44  /* on slot vic slot 1 */
46  /* address of the ISR */
48  /* trigger initial match in a long time from now */
50  /* enable interrupt on match register 0 */
52  /* enable timer 1 */
53  T1TCR = TCR_ENABLE;
54 }
55 
56 
57 #define AUDIO_TELEMETRY_CHECK_RUNNING() {}
58 
59 
60 #endif /* AUDIO_TELEMETRY_HW_H */
#define VICIntSelect
Definition: LPC21xx.h:430
void TIMER1_ISR(void)
#define T1TCR
Definition: LPC21xx.h:73
#define T1MR0
Definition: LPC21xx.h:78
#define TCR_RESET
Definition: lpcTMR.h:55
#define T1MCR
Definition: LPC21xx.h:77
static void audio_telemetry_init(void)
#define T1PR
Definition: LPC21xx.h:75
unsigned long uint32_t
Definition: types.h:18
#define TCR_ENABLE
Definition: lpcTMR.h:54
#define VIC_BIT(chan)
Definition: lpcVIC.h:105
#define SAMPLE_PERIOD
#define VICIntEnable
Definition: LPC21xx.h:431
#define TMCR_MR0_R
Definition: lpcTMR.h:60
#define PINSEL1
Definition: LPC21xx.h:348
#define VICVectAddr1
Definition: LPC21xx.h:439
#define TMCR_MR0_I
Definition: lpcTMR.h:59
#define VICVectCntl1
Definition: LPC21xx.h:455
#define VIC_TIMER1
Definition: lpcVIC.h:73
#define VIC_ENABLE
Definition: lpcVIC.h:102