Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros 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  /* turn on DAC pins */
33  PINSEL1 &= 1 << 19;
34  PINSEL1 |= ~(1 << 18);
35  /* reset & disable timer 1 */
36  T1TCR = TCR_RESET;
37  /* set the prescale divider */
38  T1PR = T1_PCLK_DIV - 1;
39  /* select TIMER1 as IRQ */
41  /* enable TIMER1 interrupt */
43  /* on slot vic slot 1 */
45  /* address of the ISR */
47  /* trigger initial match in a long time from now */
49  /* enable interrupt on match register 0 */
51  /* enable timer 1 */
52  T1TCR = TCR_ENABLE;
53 }
54 
55 
56 #define AUDIO_TELEMETRY_CHECK_RUNNING() {}
57 
58 
59 #endif /* AUDIO_TELEMETRY_HW_H */
#define VICIntSelect
Definition: LPC21xx.h:398
#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)
void TIMER1_ISR(void) __attribute__((naked))
#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:399
#define TMCR_MR0_R
Definition: lpcTMR.h:60
#define PINSEL1
Definition: LPC21xx.h:316
#define VICVectAddr1
Definition: LPC21xx.h:407
#define TMCR_MR0_I
Definition: lpcTMR.h:59
#define VICVectCntl1
Definition: LPC21xx.h:423
#define VIC_TIMER1
Definition: lpcVIC.h:73
__attribute__((always_inline))
Definition: i2c_arch.c:35
#define VIC_ENABLE
Definition: lpcVIC.h:102