説明を見る。00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <p24FJ64GA002.h>
00019
00020 #include "types.h"
00021 #include "table.h"
00022 #include "ssm.h"
00023 #include "extmeter.h"
00024 #include "main.h"
00025
00026 #include "libadc.h"
00027 #include "libdac.h"
00028 #include "librtc.h"
00029 #include "libuart.h"
00030 #include "libps2.h"
00031 #include "libfontx2.h"
00032 #include "libvideo.h"
00033
00034
00035
00036
00037
00038 _CONFIG1( JTAGEN_OFF &
00039 GCP_OFF &
00040 GWRP_OFF &
00041 BKBUG_OFF &
00042 WINDIS_OFF &
00043 COE_OFF &
00044 ICS_PGx1 &
00045 FWDTEN_ON &
00046 WDTPS_PS256)
00047
00048 _CONFIG2( IESO_OFF &
00049 FNOSC_FRCPLL &
00050 FCKSM_CSDCMD &
00051 OSCIOFNC_ON &
00052 IOL1WAY_OFF &
00053 I2C1SEL_PRI &
00054 POSCMOD_NONE)
00055
00056
00057
00058
00059
00060
00061
00062 const INFO_T info = {
00063 "OS10A708M01",
00064
00065 "OpenSSM Rev.A",
00066 2010, 5, 12,
00067 1, 0, 0,
00068 "Yosuke FURUSAWA",
00069
00070 "OpenSSM Firmware",
00071 2010, 11, 21,
00072 1, 0, 5,
00073 "Yosuke FURUSAWA",
00074
00075 "Project WinSSM & OpenSSM",
00076 "http://ssm.nextfoods.jp/",
00077 "g-ssm@nextfoods.jp",
00078 "(C) 2007 - 2010 Y.FURUSAWA",
00079 };
00080
00081
00082
00083
00084
00085 int main(void){
00086 unsigned int tick;
00087
00088
00089
00090 TRISA = 0b0000000000000011;
00091 TRISB = 0b0000111101100001;
00092 LED_OFF();
00093 KXM_OFF();
00094
00095
00096
00097 CLKDIV = 0;
00098
00099 OSCTUN = 0b0000000000000000;
00100
00101
00102 SRbits.IPL = 0;
00103
00104
00105 RTC_init();
00106 ADC_init();
00107 tick = rtc.tick;
00108 while(RTC_get_ticks(tick, rtc.tick) < 1000) ClrWdt();
00109
00110 KXM_ON();
00111
00112
00113 FONTX2_init();
00114 VIDEO_init();
00115 UART1_init(115200);
00116 UART2_init( 4800);
00117 DAC_init();
00118 PS2_init();
00119
00120
00121 SSM_init();
00122 SCREEN_init();
00123 EXTMETER_init(EXTMETER_BOOST);
00124 CONFIG_init();
00125
00126
00127 if (RCONbits.WDTO){
00128 VIDEO_locate( 2, 1);
00129 VIDEO_putstr("WDT Error!");
00130 VIDEO_locate( 2, 2);
00131 VIDEO_putstr("Initializing systems...");
00132 while(RTC_get_ticks(tick, rtc.tick) < 50000) ClrWdt();
00133
00134
00135 } else if (adc.adc[0] < 20 && adc.adc[1] < 20 && adc.adc[2] < 20) {
00136 VIDEO_locate( 2, 1);
00137 VIDEO_putstr("Can't find Accelerometer.");
00138 VIDEO_locate( 2, 2);
00139 VIDEO_putstr("Initializing systems...");
00140 while(RTC_get_ticks(tick, rtc.tick) < 50000) ClrWdt();
00141
00142
00143
00144 } else {
00145 VIDEO_locate( 2, 1);
00146 VIDEO_putstr("Now loading configurations...");
00147 VIDEO_locate( 2, 2);
00148 if(CONFIG_load()){
00149 VIDEO_putstr("Success");
00150 while(RTC_get_ticks(tick, rtc.tick) < 5000) ClrWdt();
00151 } else {
00152 VIDEO_putstr("Error");
00153 while(RTC_get_ticks(tick, rtc.tick) < 50000) ClrWdt();
00154 }
00155 }
00156
00157
00158 while(1){
00159 ClrWdt();
00160
00161
00162 GPIO_LED = ‾GPIO_LED;
00163
00164
00165 SSM_main();
00166 SCREEN_main();
00167 PS2_main();
00168 EXTMETER_main();
00169 }
00170
00171
00172 while(1);
00173 return(0);
00174 }
00175
00176