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