/[projet1]/public/oric/hardware/cumulus/fw/main.c
Defence Force logotype

Contents of /public/oric/hardware/cumulus/fw/main.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 567 - (show annotations)
Sat Aug 6 19:13:12 2011 UTC (8 years, 2 months ago) by retromaster
File MIME type: text/plain
File size: 2681 byte(s)
Initialization bug fix.
1 /* Cumulus 18F46K20 Firmware
2 * Main.
3 * Copyright 2010 Retromaster.
4 *
5 * This file is part of Cumulus Firmware.
6 *
7 * Cumulus Firmware is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License,
10 * or any later version.
11 *
12 * Cumulus Firmware is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Cumulus Firmware. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "global.h"
22 #include "sd-mmc.h"
23 #include "fat32.h"
24 #include "6610.h"
25 #include "179X.h"
26 #include "UI.h"
27
28 /* Config */
29 #pragma config FOSC = ECIO6
30 #pragma config FCMEN = OFF
31 #pragma config IESO = OFF
32 #pragma config PWRT = ON
33 #pragma config BOREN = OFF
34 #pragma config MCLRE = ON
35 #pragma config WDTEN = OFF
36 #pragma config LPT1OSC = OFF
37 #pragma config PBADEN = OFF
38 #pragma config STVREN = ON
39 #pragma config LVP = OFF
40 #pragma config XINST = OFF
41 #pragma config DEBUG = OFF
42 #pragma config CP0 = OFF
43 #pragma config CP1 = OFF
44 #pragma config CP2 = OFF
45 #pragma config CP3 = OFF
46 #pragma config CPB = OFF
47 #pragma config CPD = OFF
48 #pragma config WRT0 = OFF
49 #pragma config WRT1 = OFF
50 #pragma config WRT2 = OFF
51 #pragma config WRT3 = OFF
52 #pragma config WRTB = OFF
53 #pragma config WRTC = OFF
54 #pragma config WRTD = OFF
55
56 #pragma udata
57 fat32_dir dir;
58 fat32_dir_entry root_dir;
59 fat32_dir_entry image_file;
60
61 /* Vector Remapping */
62 extern void _startup(void);
63 #pragma code _RESET_INTERRUPT_VECTOR = 0x001000
64 void _reset (void)
65 {
66 _asm goto _startup _endasm
67 }
68
69 #pragma code
70 void main(void)
71 {
72 uint8_t i, j, file_cnt;
73
74 OSCCON = 0x60; // IRCFx = 110 (8 MHz)
75 OSCTUNEbits.PLLEN = 1; // x4 PLL enabled = 32MHz
76
77 /* No Analog Pins */
78 ANSELH = 0x00;
79 ANSEL = 0x00;
80
81 // RESET low.
82 PORTAbits.RA6 = 0;
83 TRISAbits.TRISA6 = 0;
84
85 // Initialize WD1793 emulation.
86 wd179x_init();
87
88 // Initialize User Interface.
89 ui_init();
90
91 // Initialize SD Card.
92 card_init();
93 fat32_init();
94
95 /* Release RESET */
96 PORTAbits.RA6 = 1;
97
98 while (1)
99 {
100 /* See if a command request has arrived */
101 if (PORTBbits.RB0 == 0)
102 {
103 /* So handle it */
104 ui_wd1793_command_active();
105 wd179X_handle_command_request();
106 ui_wd1793_command_done();
107 }
108 else
109 {
110 /* Do UI Stuff */
111 ui_run();
112 }
113 }
114 }

  ViewVC Help
Powered by ViewVC 1.1.26