This is a part of the Kinetiszer project.

Dependents:   SoundEngine

Committer:
Clemo
Date:
Tue Oct 28 12:19:22 2014 +0000
Revision:
0:5a419ba2726d
Error & warning free (I believe as I don't know how to clean).

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Clemo 0:5a419ba2726d 1 #ifndef __SAMPLE_RATE_H__
Clemo 0:5a419ba2726d 2 #define __SAMPLE_RATE_H__
Clemo 0:5a419ba2726d 3
Clemo 0:5a419ba2726d 4
Clemo 0:5a419ba2726d 5 #include "timers.h"
Clemo 0:5a419ba2726d 6
Clemo 0:5a419ba2726d 7 #define SAMPLE_RATE_FREQUENCY_REGISTER (3) /* Choose the MR register that will determine the frequency. */
Clemo 0:5a419ba2726d 8 #define SAMPLE_RATE_MAT_OUTPUT SAMPLE_RATE_FREQUENCY_REGISTER
Clemo 0:5a419ba2726d 9
Clemo 0:5a419ba2726d 10 /*
Clemo 0:5a419ba2726d 11 #if SAMPLE_RATE_TIMER_NR == TIMER16_0
Clemo 0:5a419ba2726d 12 #define SAMPLE_RATE_TIMER LPC_TIMER16_0
Clemo 0:5a419ba2726d 13 #define SAMPLE_RATE_TIMER_IRQ (TIMER_16_0_IRQn)
Clemo 0:5a419ba2726d 14 #if SAMPLE_RATE_MAT_OUTPUT == 0
Clemo 0:5a419ba2726d 15 #define SAMPLE_RATE_MAT_PORT (0)
Clemo 0:5a419ba2726d 16 #define SAMPLE_RATE_MAT_PIN (8)
Clemo 0:5a419ba2726d 17 #define SAMPLE_RATE_IOCON IOCON_PIO0_8
Clemo 0:5a419ba2726d 18 #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC2
Clemo 0:5a419ba2726d 19 #elif SAMPLE_RATE_MAT_OUTPUT == 1
Clemo 0:5a419ba2726d 20 #define SAMPLE_RATE_MAT_PORT (0)
Clemo 0:5a419ba2726d 21 #define SAMPLE_RATE_MAT_PIN (9)
Clemo 0:5a419ba2726d 22 #define SAMPLE_RATE_IOCON IOCON_PIO0_9
Clemo 0:5a419ba2726d 23 #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC2
Clemo 0:5a419ba2726d 24 #elif SAMPLE_RATE_MAT_OUTPUT == 2
Clemo 0:5a419ba2726d 25 #define SAMPLE_RATE_MAT_PORT (0)
Clemo 0:5a419ba2726d 26 #define SAMPLE_RATE_MAT_PIN (10)
Clemo 0:5a419ba2726d 27 #define SAMPLE_RATE_IOCON IOCON_PIO0_10
Clemo 0:5a419ba2726d 28 #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC3
Clemo 0:5a419ba2726d 29 #else
Clemo 0:5a419ba2726d 30 // Does not exist.
Clemo 0:5a419ba2726d 31 #pragma GCC error "Match output pin MATx does not exist."
Clemo 0:5a419ba2726d 32 #endif
Clemo 0:5a419ba2726d 33 #elif SAMPLE_RATE_TIMER_NR == TIMER16_1
Clemo 0:5a419ba2726d 34 #define SAMPLE_RATE_TIMER LPC_TIMER16_1
Clemo 0:5a419ba2726d 35 #define SAMPLE_RATE_TIMER_IRQ (TIMER_16_1_IRQn)
Clemo 0:5a419ba2726d 36 #if SAMPLE_RATE_MAT_OUTPUT == 0
Clemo 0:5a419ba2726d 37 #define SAMPLE_RATE_MAT_PORT (1)
Clemo 0:5a419ba2726d 38 #define SAMPLE_RATE_MAT_PIN (9)
Clemo 0:5a419ba2726d 39 #define SAMPLE_RATE_IOCON IOCON_PIO1_9
Clemo 0:5a419ba2726d 40 #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC1
Clemo 0:5a419ba2726d 41 #elif SAMPLE_RATE_MAT_OUTPUT == 1
Clemo 0:5a419ba2726d 42 #define SAMPLE_RATE_MAT_PORT (1)
Clemo 0:5a419ba2726d 43 #define SAMPLE_RATE_MAT_PIN (10)
Clemo 0:5a419ba2726d 44 #define SAMPLE_RATE_IOCON IOCON_PIO1_10
Clemo 0:5a419ba2726d 45 #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC2
Clemo 0:5a419ba2726d 46 #else
Clemo 0:5a419ba2726d 47 // Does not exist.
Clemo 0:5a419ba2726d 48 #pragma GCC error "Match output pin MATx does not exist."
Clemo 0:5a419ba2726d 49 #endif
Clemo 0:5a419ba2726d 50 #elif SAMPLE_RATE_TIMER_NR == TIMER32_0
Clemo 0:5a419ba2726d 51 #define SAMPLE_RATE_TIMER LPC_TIMER32_0
Clemo 0:5a419ba2726d 52 #define SAMPLE_RATE_TIMER_IRQ (TIMER_32_0_IRQn)
Clemo 0:5a419ba2726d 53 #if SAMPLE_RATE_MAT_OUTPUT == 0
Clemo 0:5a419ba2726d 54 #define SAMPLE_RATE_MAT_PORT (1)
Clemo 0:5a419ba2726d 55 #define SAMPLE_RATE_MAT_PIN (6)
Clemo 0:5a419ba2726d 56 #define SAMPLE_RATE_IOCON IOCON_PIO1_6
Clemo 0:5a419ba2726d 57 #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC2
Clemo 0:5a419ba2726d 58 #elif SAMPLE_RATE_MAT_OUTPUT == 1
Clemo 0:5a419ba2726d 59 #define SAMPLE_RATE_MAT_PORT (1)
Clemo 0:5a419ba2726d 60 #define SAMPLE_RATE_MAT_PIN (7)
Clemo 0:5a419ba2726d 61 #define SAMPLE_RATE_IOCON IOCON_PIO1_7
Clemo 0:5a419ba2726d 62 #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC2
Clemo 0:5a419ba2726d 63 #elif SAMPLE_RATE_MAT_OUTPUT == 2
Clemo 0:5a419ba2726d 64 #define SAMPLE_RATE_MAT_PORT (0)
Clemo 0:5a419ba2726d 65 #define SAMPLE_RATE_MAT_PIN (1)
Clemo 0:5a419ba2726d 66 #define SAMPLE_RATE_IOCON IOCON_PIO0_1
Clemo 0:5a419ba2726d 67 #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC2
Clemo 0:5a419ba2726d 68 #elif SAMPLE_RATE_MAT_OUTPUT == 3
Clemo 0:5a419ba2726d 69 #define SAMPLE_RATE_MAT_PORT (0)
Clemo 0:5a419ba2726d 70 #define SAMPLE_RATE_MAT_PIN (11)
Clemo 0:5a419ba2726d 71 #define SAMPLE_RATE_IOCON IOCON_PIO0_11
Clemo 0:5a419ba2726d 72 #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC3
Clemo 0:5a419ba2726d 73 #else
Clemo 0:5a419ba2726d 74 // Does not exist.
Clemo 0:5a419ba2726d 75 #pragma GCC error "Match output pin MATx does not exist."
Clemo 0:5a419ba2726d 76 #endif
Clemo 0:5a419ba2726d 77 #elif SAMPLE_RATE_TIMER_NR == TIMER32_1
Clemo 0:5a419ba2726d 78 #define SAMPLE_RATE_TIMER LPC_TIMER32_1
Clemo 0:5a419ba2726d 79 #define SAMPLE_RATE_TIMER_IRQ (TIMER_32_1_IRQn)
Clemo 0:5a419ba2726d 80 #if SAMPLE_RATE_MAT_OUTPUT == 0
Clemo 0:5a419ba2726d 81 #define SAMPLE_RATE_MAT_PORT (1)
Clemo 0:5a419ba2726d 82 #define SAMPLE_RATE_MAT_PIN (1)
Clemo 0:5a419ba2726d 83 #define SAMPLE_RATE_IOCON IOCON_PIO1_1
Clemo 0:5a419ba2726d 84 #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC3
Clemo 0:5a419ba2726d 85 #elif SAMPLE_RATE_MAT_OUTPUT == 1
Clemo 0:5a419ba2726d 86 #define SAMPLE_RATE_MAT_PORT (1)
Clemo 0:5a419ba2726d 87 #define SAMPLE_RATE_MAT_PIN (2)
Clemo 0:5a419ba2726d 88 #define SAMPLE_RATE_IOCON IOCON_PIO1_2
Clemo 0:5a419ba2726d 89 #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC3
Clemo 0:5a419ba2726d 90 #elif SAMPLE_RATE_MAT_OUTPUT == 2
Clemo 0:5a419ba2726d 91 #define SAMPLE_RATE_MAT_PORT (1)
Clemo 0:5a419ba2726d 92 #define SAMPLE_RATE_MAT_PIN (3)
Clemo 0:5a419ba2726d 93 #define SAMPLE_RATE_IOCON IOCON_PIO1_3
Clemo 0:5a419ba2726d 94 #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC3
Clemo 0:5a419ba2726d 95 #elif SAMPLE_RATE_MAT_OUTPUT == 3
Clemo 0:5a419ba2726d 96 #define SAMPLE_RATE_MAT_PORT (1)
Clemo 0:5a419ba2726d 97 #define SAMPLE_RATE_MAT_PIN (4)
Clemo 0:5a419ba2726d 98 #define SAMPLE_RATE_IOCON IOCON_PIO1_4
Clemo 0:5a419ba2726d 99 #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC2
Clemo 0:5a419ba2726d 100 #else
Clemo 0:5a419ba2726d 101 // Does not exist.
Clemo 0:5a419ba2726d 102 #pragma GCC error "Match output pin MATx does not exist."
Clemo 0:5a419ba2726d 103 #endif
Clemo 0:5a419ba2726d 104 #else
Clemo 0:5a419ba2726d 105 // Does not exist.
Clemo 0:5a419ba2726d 106 #pragma GCC error "Selected SAMPLE_RATE timer does not exist."
Clemo 0:5a419ba2726d 107 #endif
Clemo 0:5a419ba2726d 108 */
Clemo 0:5a419ba2726d 109
Clemo 0:5a419ba2726d 110 void SampleRate_Init(uint32_t default_rate, uint32_t samples_per_period);
Clemo 0:5a419ba2726d 111
Clemo 0:5a419ba2726d 112
Clemo 0:5a419ba2726d 113 #endif // __SAMPLE_RATE_H__