forked from szczys/kicon19-badge-sw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
100 lines (84 loc) · 2.18 KB
/
main.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* Copyright (c) 2019 Maciej Suminski <orson@orson.net.pl>
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "asf.h"
#include "buttons.h"
#include "io_capture.h"
#include "logic_analyzer.h"
#include "udc.h"
#include "udi_cdc.h"
#include "commands.h"
#include "spi_master.h"
#include "lcd.h"
#include "gfx.h"
#include "SSD1306_commands.h"
#include "scope.h"
#include "serial.h"
#include "menu.h"
#include "led.h"
#include "buffer.h"
/* Global large buffer */
buffer_t buffer;
volatile bool g_interrupt_enabled = true;
/**
* \brief Handler for System Tick interrupt.
*
* Process System Tick Event
*/
void SysTick_Handler(void)
{
}
/**
* \brief initialize pins, watchdog, etc.
*/
static void init_system(void)
{
/* Disable the watchdog */
wdt_disable(WDT);
irq_initialize_vectors();
cpu_irq_enable();
/* Initialize the system clock */
sysclk_init();
/* Configure timer ISR to fire regularly (100 ms) */
/* SysTick_Config((sysclk_get_cpu_hz() / 1000) * 100); */
serial_init(115200);
led_init();
btn_init();
spi_init(1000000, 0);
SSD1306_init();
ioc_init();
la_init();
udc_start();
led_blink(LED2, 4);
}
int main(void)
{
init_system();
/* Splash screen */
SSD1306_drawBitmap(0, 0, kicon_logo, 128, 32);
SSD1306_drawBufferDMA();
/* wait ~3s or till a button is pressed */
for(int i = 0; i < (1 << 20); ++i) {
if (btn_state()) {
break;
}
}
while(1) {
menu();
}
}