summaryrefslogtreecommitdiff
path: root/firmware/smu.c
blob: 83228c05111acf0c00241fb225a4db3df115e136 (plain)
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
/* Free/Libre SMU firmware
 * Copyright (C) 2015  Damien Zammit <damien@zamaudio.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *-
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * See <http://www.gnu.org/licenses/>.-
 */

#include "smu.h"
#include "delay.h"
#include "interrupts.h"

void main(void)
{
	int ie, mask, im;

	int irq = 1;

	mask = 0x1 << irq; // << irq

	/* disable peripheral interrupts */
	asm volatile ("rcsr %0,ie":"=r"(ie));
	ie &= (~0x1);
	asm volatile ("wcsr ie, %0"::"r"(ie));

	ISREntryTable[irq].Callback = &smu_service_request;
	ISREntryTable[irq].Context = 0; //?

	/* enable mask in the im */
	asm volatile ("rcsr %0, im":"=r"(im));
	im |= mask;
	asm volatile ("wcsr im, %0"::"r"(im));

	/* enable interrupts */
	ie |= 0x1;
	asm volatile ("wcsr ie, %0"::"r"(ie));

	while (1) {
		mdelay(10);
		
		MicoISRHandler();
	}
}