-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex2.c
executable file
·69 lines (59 loc) · 2.06 KB
/
ex2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <stdint.h>
#include <stdbool.h>
#include "efm32gg.h"
#include "ex2.h"
/* The period between sound samples, in clock cycles */
#define SAMPLE_PERIOD 1270
/* import start and end symbols from sound object files */
SOUND_DECLARE(ahem_x)
SOUND_DECLARE(nokia)
SOUND_DECLARE(call_to_arms)
SOUND_DECLARE(bloop_x)
SOUND_DECLARE(bad_disk_x)
SOUND_DECLARE(applause3)
SOUND_DECLARE(air_raid)
SOUND_DECLARE(bushj_liberty)
/* construct Sound structs from start and end symbols
* sounds[i] corresponds to button i
*/
volatile Sound sounds[8] = {SOUND(ahem_x), SOUND(nokia), SOUND(call_to_arms),
SOUND(bloop_x), SOUND(bad_disk_x), SOUND(applause3), SOUND(air_raid),
SOUND(bushj_liberty)
};
/* Your code will start executing here */
int main(void)
{
/* Call the peripheral setup functions */
setup_gpio();
setup_dac();
setup_timer(SAMPLE_PERIOD);
/* Enable interrupt handling */
setup_nvic();
/* sleep */
*SCR = 2;
__asm volatile ("wfi");
return 0;
}
/* enable interrupts in NVIC */
void setup_nvic(void)
{
*ISER0 = 1<<12 | 1<<11 | 1<<1;
}
/*
* if other interrupt handlers are needed, use the following names:
* NMI_Handler HardFault_Handler MemManage_Handler BusFault_Handler
* UsageFault_Handler Reserved7_Handler Reserved8_Handler
* Reserved9_Handler Reserved10_Handler SVC_Handler DebugMon_Handler
* Reserved13_Handler PendSV_Handler SysTick_Handler DMA_IRQHandler
* GPIO_EVEN_IRQHandler TIMER0_IRQHandler USART0_RX_IRQHandler
* USART0_TX_IRQHandler USB_IRQHandler ACMP0_IRQHandler ADC0_IRQHandler
* DAC0_IRQHandler I2C0_IRQHandler I2C1_IRQHandler GPIO_ODD_IRQHandler
* TIMER1_IRQHandler TIMER2_IRQHandler TIMER3_IRQHandler
* USART1_RX_IRQHandler USART1_TX_IRQHandler LESENSE_IRQHandler
* USART2_RX_IRQHandler USART2_TX_IRQHandler UART0_RX_IRQHandler
* UART0_TX_IRQHandler UART1_RX_IRQHandler UART1_TX_IRQHandler
* LEUART0_IRQHandler LEUART1_IRQHandler LETIMER0_IRQHandler
* PCNT0_IRQHandler PCNT1_IRQHandler PCNT2_IRQHandler RTC_IRQHandler
* BURTC_IRQHandler CMU_IRQHandler VCMP_IRQHandler LCD_IRQHandler
* MSC_IRQHandler AES_IRQHandler EBI_IRQHandler EMU_IRQHandler
*/