説明を見る。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 "OS10A705J00",
00097
00098 "OpenSSM Rev.A",
00099 2670, 5, 12,
00100 1, 0, 0,
00101 "Yosuke FURUSAWA",
00102
00103 "OpenSSM Firmware",
00104 2670, 8, 15,
00105 1, 0, 0,
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
00127 CLKDIV = 0;
00128 OSCTUN = 0b0000000000011111;
00129
00130
00131 SRbits.IPL = 0;
00132
00133
00134
00135 TRISA = 0b0000000000000011;
00136 TRISB = 0b0000111101100001;
00137
00138
00139 RTC_init();
00140 ADC_init();
00141 tick = rtc.tick;
00142 while(RTC_get_ticks(tick, rtc.tick) < 10000) ClrWdt();
00143
00144 LED_OFF();
00145 KXM_ON();
00146
00147
00148 FONTX2_init();
00149 VIDEO_init();
00150 UART1_init(115200);
00151 UART2_init( 4800);
00152 DAC_init();
00153 PS2_init();
00154
00155
00156 SSM_init();
00157 SCREEN_init();
00158 EXTMETER_init(EXTMETER_BOOST);
00159 CONFIG_init();
00160
00161
00162 if (RCONbits.WDTO){
00163 VIDEO_locate( 0, 0);
00164 VIDEO_putstr("WDT Error!");
00165 VIDEO_locate( 0, 1);
00166 VIDEO_putstr("Configuration do not load");
00167 while(RTC_get_ticks(tick, rtc.tick) < 50000) ClrWdt();
00168
00169 } else if (adc.adc[0] < 20 && adc.adc[1] < 20 && adc.adc[2] < 20) {
00170 VIDEO_locate( 0, 0);
00171 VIDEO_putstr("Accelerometer do not connected.");
00172 VIDEO_locate( 0, 1);
00173 VIDEO_putstr("Configuration do not load");
00174 while(RTC_get_ticks(tick, rtc.tick) < 50000) ClrWdt();
00175
00176
00177
00178 } else {
00179 VIDEO_locate( 0, 0);
00180 VIDEO_putstr("Configuration Auto Load...");
00181 VIDEO_locate( 0, 1);
00182 if(CONFIG_load()){
00183 VIDEO_putstr("Success");
00184 while(RTC_get_ticks(tick, rtc.tick) < 5000) ClrWdt();
00185 } else {
00186 VIDEO_putstr("Error");
00187 while(RTC_get_ticks(tick, rtc.tick) < 50000) ClrWdt();
00188 }
00189 }
00190
00191
00192 while(1){
00193 ClrWdt();
00194 GPIO_LED = ‾GPIO_LED;
00195
00196
00197 SSM_main();
00198 SCREEN_main();
00199 PS2_main();
00200 EXTMETER_main();
00201 }
00202
00203
00204 while(1);
00205 return(0);
00206 }
00207
00208