• R/O
  • HTTP
  • SSH
  • HTTPS

cpu2010: Commit

サブCPU2010のPICプログラム
ADデータ取得とGPS時刻付けを行いLinux部にデータを出力します。


Commit MetaInfo

Revisão4789d84e0e125c3cce1e5ead0d7c59eab3642b60 (tree)
Hora2011-11-28 17:09:31
AutorNaoya Takamura <ntaka206@user...>
CommiterNaoya Takamura

Mensagem de Log

ring.c inline化
GPS 1PPS INT0 handler: ad pps sync.
sts.c add

Mudança Sumário

Diff

--- a/build/default/debug/byte2var.o.d
+++ /dev/null
@@ -1 +0,0 @@
1-build/default/debug/byte2var.o: byte2var.c
--- a/build/default/debug/debug_print.o.d
+++ /dev/null
@@ -1 +0,0 @@
1-build/default/debug/debug_print.o: debug_print.c myuart.h
--- a/build/default/debug/main.o.d
+++ /dev/null
@@ -1,2 +0,0 @@
1-build/default/debug/main.o: main.c myuart.h myspi.h debug_print.h ublox.h \
2- myad.h delay.h ring.h byte2var.h
--- a/build/default/debug/myad.o.d
+++ /dev/null
@@ -1 +0,0 @@
1-build/default/debug/myad.o: myad.c delay.h myspi.h myad.h
--- a/build/default/debug/myspi.o.d
+++ /dev/null
@@ -1 +0,0 @@
1-build/default/debug/myspi.o: myspi.c myspi.h
--- a/build/default/debug/myuart.o.d
+++ /dev/null
@@ -1 +0,0 @@
1-build/default/debug/myuart.o: myuart.c myuart.h
--- a/build/default/debug/ring.o.d
+++ /dev/null
@@ -1 +0,0 @@
1-build/default/debug/ring.o: ring.c ring.h
--- a/build/default/debug/ublox.o.d
+++ /dev/null
@@ -1 +0,0 @@
1-build/default/debug/ublox.o: ublox.c ublox.h myuart.h byte2var.h
--- a/build/default/production/main.o.d
+++ b/build/default/production/main.o.d
@@ -1,2 +1,2 @@
11 build/default/production/main.o: main.c myuart.h myspi.h debug_print.h \
2- ublox.h myad.h delay.h ring.h byte2var.h myint.h
2+ ublox.h myad.h delay.h ring.h byte2var.h myint.h mysts.h
--- a/main.c
+++ b/main.c
@@ -22,6 +22,7 @@
2222 #include "ring.h"
2323 #include "byte2var.h"
2424 #include "myint.h"
25+#include "mysts.h"
2526
2627 _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2 )
2728 //_CONFIG2( FCKSM_CSDCMD & OSCIOFNC_ON & POSCMOD_OFF & FNOSC_FRC)
@@ -36,14 +37,41 @@ _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2 )
3637 // UART1 GPS
3738 #define BAUDRATE1 9600L
3839
39-/*** ADBUF **************************************************/
40-#define ADBUF_BYTE 3 // AD 1dataのbyte数
40+/*** ADバッファ *************************************************
41+ * 50Hzデータ
42+ * 1秒平均データ
43+ * タイムスタンプ
44+ */
45+#define ADBUF_BYTE 3 // AD 1CH 1sample dataのbyte数
4146
4247 // SPI外部送信用バッファ AD_SAMPLE[Hz]
4348 static char adbuf[RING_NUM][AD_CHNUM][ADBUF_BYTE*AD_SAMPLE];
4449 // 1sec平均値
4550 static long adbuf_1sec[RING_NUM][AD_CHNUM];
51+// timestamp
52+static UbloxNavTimeUtc adbuf_t[RING_NUM];
53+
54+inline void my_memcpy(void *dest0, void *src0, int len)
55+{
56+ int i;
57+ char *dest, *src;
4658
59+ dest = (char*)dest0;
60+ src = (char*)src0;
61+ for(i = 0; i < len; i++) {
62+ *dest++ = *src++;
63+ }
64+}
65+inline void my_memset(void *dest0, unsigned char data, int len)
66+{
67+ int i;
68+ char *dest;
69+
70+ dest = (char*)dest0;
71+ for(i = 0; i < len; i++) {
72+ *dest++ = data;
73+ }
74+}
4775 inline void adbuf_write(unsigned char buf_no, unsigned char ch, int cnt, long *data)
4876 {
4977 unsigned char *ptr = (unsigned char*)data;
@@ -52,16 +80,21 @@ inline void adbuf_write(unsigned char buf_no, unsigned char ch, int cnt, long *d
5280 adbuf[buf_no][ch][ADBUF_BYTE*cnt + i] = *(ptr++);
5381 }
5482 }
83+// 1
5584 inline void adbuf_1sec_write(char buf_no, long *data)
5685 {
57- memcpy(adbuf_1sec[buf_no], data, sizeof(long) * AD_CHNUM);
86+ my_memcpy(adbuf_1sec[buf_no], data, sizeof(long) * AD_CHNUM);
5887 /* char ch;
5988 for(ch = 0; ch < AD_CHNUM; ch++)
6089 adbuf_1sec[buf_no][ch] = data[ch];
6190 */
6291 }
92+inline void adbuf_time_write(char buf_no, UbloxNavTimeUtc *t)
93+{
94+ my_memcpy(&adbuf_t[buf_no], t, sizeof(UbloxNavTimeUtc));
95+}
6396
64-/*****************************************************/
97+/**** ublox *************************************************/
6598
6699 void test_ublox_rcv_mon(void)
67100 {
@@ -146,7 +179,7 @@ int main(int argc, char** argv) {
146179 char sz[128];
147180 UbloxNavTimeUtc *gps = &gpsNow;
148181
149- // 割り込み禁止
182+ /**** 割り込み禁止 ****/
150183 SET_CPU_IPL( 7 );
151184 __builtin_write_OSCCONL(OSCCON & 0xbf); //clear the bit 6 of OSCCONL to unlock Pin Re-map
152185
@@ -186,6 +219,7 @@ int main(int argc, char** argv) {
186219
187220 adint_cnt = 0;
188221 ad_cs_dis();
222+ sts_set(STS_NOSYNC);
189223 pps_intf_clear();
190224
191225 // GPS UART1初期設定 BRGH=Standard mode
@@ -268,8 +302,15 @@ int main(int argc, char** argv) {
268302 int0_int_enable(); // Int enable
269303
270304 while(1) {
305+ // GPSから受信してデコード
271306 ublox_rcv();
307+ if (gpsNow.valid == 0x07 && sts_get() == STS_NOSYNC) {
308+ // 時刻有効
309+ sts_set(STS_SYNCNOW0);
310+ }
272311 if (ring_read_get() != ring_write_get()) {
312+ // タイムスタンプget
313+ gps = &adbuf_t[ring_read_get()];
273314 sprintf(sz, "%04u/%02d/%02d %02d:%02d:%02d.%09ld %6lums %6luns %02X\r\n",
274315 gps->year, gps->month, gps->day, gps->hour, gps->min, gps->sec, gps->nano,
275316 gps->tow, gps->tacc, gps->valid
@@ -277,7 +318,7 @@ int main(int argc, char** argv) {
277318 PDEBUG(sz);
278319
279320 #if 1
280- //
321+ // AD data get
281322 char ch;
282323 for(ch=0; ch<AD_CHNUM; ch++) {
283324 sprintf(sz, "%+7ld,", adbuf_1sec[ring_read_get()][ch]);
@@ -317,17 +358,30 @@ int main(int argc, char** argv) {
317358 */
318359 void __attribute__((interrupt, no_auto_psv)) _INT0Interrupt(void)
319360 {
361+ // AD STARTピン=H
362+ ad_start_ena();
363+
320364 int0_intf_clear();
321365 pps_intf_set();
322-/****AD同期!!!!!!!!!!!!!!!
323- * とりあえず 要修正
324- */
325-// カウンタの同期
326- adint_cnt = 0;
327-
328-// AD START信号による同期
329-
330-
366+ /****AD同期!!!!!!!!!!!!!!!*/
367+ // AD個数カウンタ=SAMP_FREQ-1
368+ adint_cnt = AD_SAMPLE - 1;
369+
370+ // ADバッファにタイムスタンプ付ける
371+ adbuf_time_write(ring_read_get(), &gpsNow);
372+
373+ // AD START信号による同期
374+ if (sts_get() == STS_SYNCNOW0) {
375+ // AD STARTピン=L
376+ ad_start_dis();
377+ sts_set(STS_SYNCNOW1);
378+ } else if (sts_get() == STS_SYNCNOW1) {
379+ // AD STARTピン=H
380+// ad_start_ena();
381+ sts_set(STS_SYNCWAIT);
382+ } else if (sts_get() == STS_SYNCWAIT) {
383+ sts_set(STS_SYNCED);
384+ }
331385 }
332386
333387 /*
@@ -343,12 +397,11 @@ void __attribute__((interrupt, no_auto_psv)) _INT1Interrupt(void)
343397 if (!ad_is_drdy0_enable()) {
344398 return;
345399 }
346-// ad_drdy0_intf_set();
347400
348401 adint_ch = 0;
349402 adint_sts = ADSTS_H;
350403 if (adint_cnt == 0) {
351- memset(adint_add, 0, sizeof(adint_add));
404+ my_memset(adint_add, 0, sizeof(adint_add));
352405 }
353406
354407 ad_cs(adint_ch); // CSx=L
@@ -399,7 +452,7 @@ void __attribute__((interrupt, auto_psv)) _SPI1Interrupt(void)
399452 l = byte3_to_long(in);
400453 // バッファに書きこみ
401454 adbuf_write(ring_write_get(), adint_ch, adint_cnt, &l);
402- // 平均用加算
455+ // 1秒平均用加算
403456 adint_add[adint_ch] += l;
404457 // CH進める
405458 adint_ch++;
--- a/myad.c
+++ b/myad.c
@@ -1,3 +1,8 @@
1+/*
2+ * ADS1259
3+ *
4+ * ADデータSPIエンディアン MSB first
5+ */
16 #include <p24FJ64GA004.h>
27 #include <libpic30.h>
38
@@ -5,9 +10,6 @@
510 #include "myspi.h"
611 #include "myad.h"
712
8-#define CS_RCLK PORTAbits.RA7
9-#define CS_CLK PORTAbits.RA8
10-#define CS_DATA PORTAbits.RA9
1113
1214 #if 0
1315 // AD DRDY0 INTフラグ 1=INTかかった 0=なし
@@ -39,6 +41,7 @@ void ad_cs_init(void)
3941 asm("NOP");
4042 CS_DATA = 0;
4143 }
44+# if 0
4245 /*
4346 int cs: 0〜15
4447 */
@@ -64,6 +67,7 @@ void ad_cs(unsigned char cs)
6467 asm("NOP");
6568 CS_RCLK = 0;
6669 }
70+
6771 void ad_cs_dis(void)
6872 {
6973 unsigned char i;
@@ -80,6 +84,7 @@ void ad_cs_dis(void)
8084 asm("NOP");
8185 CS_RCLK = 0;
8286 }
87+#endif
8388
8489 void ad_reset(void)
8590 {
--- a/myad.h
+++ b/myad.h
@@ -4,6 +4,10 @@
44
55 #define __MYAD_H__
66
7+#define CS_RCLK PORTAbits.RA7
8+#define CS_CLK PORTAbits.RA8
9+#define CS_DATA PORTAbits.RA9
10+
711 #define AD_CHNUM 6
812 #define AD_CH1_CS 0 // AD CH1のCS番号
913 #define PGA_CH1_CS 6 // PGA CH1のCS番号
@@ -24,14 +28,51 @@
2428 //char ad_is_drdy0_intf(void);
2529
2630 void ad_cs_init(void);
27-void ad_cs(unsigned char adr);
28-void ad_cs_dis(void);
31+inline extern void ad_cs(unsigned char cs)
32+{
33+ unsigned char i;
34+
35+//CS_CLK = 1;
36+ for(i = 16; i > 0; i--) {
37+ if (i == cs+1) {
38+ CS_DATA = 0;
39+ } else {
40+ CS_DATA = 1;
41+ }
42+ asm("NOP");
43+ CS_CLK = 1;
44+ CS_CLK = 0;
45+ }
46+ asm("NOP");
47+ CS_RCLK = 1;
48+ asm("NOP");
49+ CS_DATA = 0;
50+ asm("NOP");
51+ CS_RCLK = 0;
52+}
53+
54+inline extern void ad_cs_dis(void){
55+ unsigned char i;
56+
57+ CS_DATA = 1;
58+ for(i = 16; i > 0; i--) {
59+ CS_CLK = 1;
60+ CS_CLK = 0;
61+ }
62+ asm("NOP");
63+ CS_RCLK = 1;
64+ asm("NOP");
65+ CS_DATA = 0;
66+ asm("NOP");
67+ CS_RCLK = 0;
68+}
69+
2970
30-#define ad_reset_dis() PORTBbits.RB10 = 1; __delay32(1)
31-#define ad_reset_ena() PORTBbits.RB10 = 0; __delay32(1)
71+#define ad_reset_dis() PORTBbits.RB10 = 1; asm("NOP")
72+#define ad_reset_ena() PORTBbits.RB10 = 0; asm("NOP")
3273
33-#define ad_start_dis() PORTBbits.RB11 = 0; __delay32(1)
34-#define ad_start_ena() PORTBbits.RB11 = 1; __delay32(1)
74+#define ad_start_dis() PORTBbits.RB11 = 0; asm("NOP")
75+#define ad_start_ena() PORTBbits.RB11 = 1; asm("NOP")
3576
3677 #define ad_is_drdy0_enable() (PORTBbits.RB12 == 0)
3778
--- /dev/null
+++ b/mysts.c
@@ -0,0 +1,6 @@
1+/*
2+ * main status
3+ */
4+
5+char main_sts;
6+
--- /dev/null
+++ b/mysts.h
@@ -0,0 +1,21 @@
1+/*
2+ * main status
3+ */
4+#ifndef __MYSTS_H__
5+#define __MYSTS_H__
6+
7+#define STS_NOSYNC 0 // GPS TIME NOT FIXED
8+#define STS_SYNCNOW0 1
9+#define STS_SYNCNOW1 2
10+#define STS_SYNCWAIT 3
11+#define STS_SYNCED 4 // GPS TIME FIXED, AD SYNCED
12+
13+extern char main_sts;
14+
15+#define sts_set(s) main_sts = s
16+#define sts_get() main_sts
17+
18+#endif
19+
20+
21+
--- a/nbproject/Makefile-default.mk
+++ b/nbproject/Makefile-default.mk
@@ -35,10 +35,10 @@ OBJECTDIR=build/${CND_CONF}/${IMAGE_TYPE}
3535 DISTDIR=dist/${CND_CONF}/${IMAGE_TYPE}
3636
3737 # Object Files Quoted if spaced
38-OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/byte2var.o ${OBJECTDIR}/debug_print.o ${OBJECTDIR}/main.o ${OBJECTDIR}/myad.o ${OBJECTDIR}/myspi.o ${OBJECTDIR}/myuart.o ${OBJECTDIR}/ring.o ${OBJECTDIR}/ublox.o
38+OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/byte2var.o ${OBJECTDIR}/debug_print.o ${OBJECTDIR}/main.o ${OBJECTDIR}/myad.o ${OBJECTDIR}/myspi.o ${OBJECTDIR}/mysts.o ${OBJECTDIR}/myuart.o ${OBJECTDIR}/ring.o ${OBJECTDIR}/ublox.o
3939
4040 # Object Files
41-OBJECTFILES=${OBJECTDIR}/byte2var.o ${OBJECTDIR}/debug_print.o ${OBJECTDIR}/main.o ${OBJECTDIR}/myad.o ${OBJECTDIR}/myspi.o ${OBJECTDIR}/myuart.o ${OBJECTDIR}/ring.o ${OBJECTDIR}/ublox.o
41+OBJECTFILES=${OBJECTDIR}/byte2var.o ${OBJECTDIR}/debug_print.o ${OBJECTDIR}/main.o ${OBJECTDIR}/myad.o ${OBJECTDIR}/myspi.o ${OBJECTDIR}/mysts.o ${OBJECTDIR}/myuart.o ${OBJECTDIR}/ring.o ${OBJECTDIR}/ublox.o
4242
4343
4444 CFLAGS=
@@ -93,98 +93,110 @@ ${OBJECTDIR}/byte2var.o: byte2var.c nbproject/Makefile-${CND_CONF}.mk
9393 @${MKDIR} ${OBJECTDIR}
9494 @${RM} ${OBJECTDIR}/byte2var.o.d
9595 @${RM} ${OBJECTDIR}/byte2var.o.ok ${OBJECTDIR}/byte2var.o.err
96- @${FIXDEPS} "${OBJECTDIR}/byte2var.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/byte2var.o.d" -o ${OBJECTDIR}/byte2var.o byte2var.c
96+ @${FIXDEPS} "${OBJECTDIR}/byte2var.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/byte2var.o.d" -o ${OBJECTDIR}/byte2var.o byte2var.c -Winline
97+
98+${OBJECTDIR}/myuart.o: myuart.c nbproject/Makefile-${CND_CONF}.mk
99+ @${MKDIR} ${OBJECTDIR}
100+ @${RM} ${OBJECTDIR}/myuart.o.d
101+ @${RM} ${OBJECTDIR}/myuart.o.ok ${OBJECTDIR}/myuart.o.err
102+ @${FIXDEPS} "${OBJECTDIR}/myuart.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/myuart.o.d" -o ${OBJECTDIR}/myuart.o myuart.c -Winline
97103
98104 ${OBJECTDIR}/debug_print.o: debug_print.c nbproject/Makefile-${CND_CONF}.mk
99105 @${MKDIR} ${OBJECTDIR}
100106 @${RM} ${OBJECTDIR}/debug_print.o.d
101107 @${RM} ${OBJECTDIR}/debug_print.o.ok ${OBJECTDIR}/debug_print.o.err
102- @${FIXDEPS} "${OBJECTDIR}/debug_print.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/debug_print.o.d" -o ${OBJECTDIR}/debug_print.o debug_print.c
108+ @${FIXDEPS} "${OBJECTDIR}/debug_print.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/debug_print.o.d" -o ${OBJECTDIR}/debug_print.o debug_print.c -Winline
103109
104-${OBJECTDIR}/myuart.o: myuart.c nbproject/Makefile-${CND_CONF}.mk
110+${OBJECTDIR}/mysts.o: mysts.c nbproject/Makefile-${CND_CONF}.mk
105111 @${MKDIR} ${OBJECTDIR}
106- @${RM} ${OBJECTDIR}/myuart.o.d
107- @${RM} ${OBJECTDIR}/myuart.o.ok ${OBJECTDIR}/myuart.o.err
108- @${FIXDEPS} "${OBJECTDIR}/myuart.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/myuart.o.d" -o ${OBJECTDIR}/myuart.o myuart.c
112+ @${RM} ${OBJECTDIR}/mysts.o.d
113+ @${RM} ${OBJECTDIR}/mysts.o.ok ${OBJECTDIR}/mysts.o.err
114+ @${FIXDEPS} "${OBJECTDIR}/mysts.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/mysts.o.d" -o ${OBJECTDIR}/mysts.o mysts.c -Winline
109115
110116 ${OBJECTDIR}/ublox.o: ublox.c nbproject/Makefile-${CND_CONF}.mk
111117 @${MKDIR} ${OBJECTDIR}
112118 @${RM} ${OBJECTDIR}/ublox.o.d
113119 @${RM} ${OBJECTDIR}/ublox.o.ok ${OBJECTDIR}/ublox.o.err
114- @${FIXDEPS} "${OBJECTDIR}/ublox.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/ublox.o.d" -o ${OBJECTDIR}/ublox.o ublox.c
120+ @${FIXDEPS} "${OBJECTDIR}/ublox.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/ublox.o.d" -o ${OBJECTDIR}/ublox.o ublox.c -Winline
115121
116122 ${OBJECTDIR}/myad.o: myad.c nbproject/Makefile-${CND_CONF}.mk
117123 @${MKDIR} ${OBJECTDIR}
118124 @${RM} ${OBJECTDIR}/myad.o.d
119125 @${RM} ${OBJECTDIR}/myad.o.ok ${OBJECTDIR}/myad.o.err
120- @${FIXDEPS} "${OBJECTDIR}/myad.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/myad.o.d" -o ${OBJECTDIR}/myad.o myad.c
126+ @${FIXDEPS} "${OBJECTDIR}/myad.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/myad.o.d" -o ${OBJECTDIR}/myad.o myad.c -Winline
121127
122128 ${OBJECTDIR}/main.o: main.c nbproject/Makefile-${CND_CONF}.mk
123129 @${MKDIR} ${OBJECTDIR}
124130 @${RM} ${OBJECTDIR}/main.o.d
125131 @${RM} ${OBJECTDIR}/main.o.ok ${OBJECTDIR}/main.o.err
126- @${FIXDEPS} "${OBJECTDIR}/main.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/main.o.d" -o ${OBJECTDIR}/main.o main.c
127-
128-${OBJECTDIR}/myspi.o: myspi.c nbproject/Makefile-${CND_CONF}.mk
129- @${MKDIR} ${OBJECTDIR}
130- @${RM} ${OBJECTDIR}/myspi.o.d
131- @${RM} ${OBJECTDIR}/myspi.o.ok ${OBJECTDIR}/myspi.o.err
132- @${FIXDEPS} "${OBJECTDIR}/myspi.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/myspi.o.d" -o ${OBJECTDIR}/myspi.o myspi.c
132+ @${FIXDEPS} "${OBJECTDIR}/main.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/main.o.d" -o ${OBJECTDIR}/main.o main.c -Winline
133133
134134 ${OBJECTDIR}/ring.o: ring.c nbproject/Makefile-${CND_CONF}.mk
135135 @${MKDIR} ${OBJECTDIR}
136136 @${RM} ${OBJECTDIR}/ring.o.d
137137 @${RM} ${OBJECTDIR}/ring.o.ok ${OBJECTDIR}/ring.o.err
138- @${FIXDEPS} "${OBJECTDIR}/ring.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/ring.o.d" -o ${OBJECTDIR}/ring.o ring.c
138+ @${FIXDEPS} "${OBJECTDIR}/ring.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/ring.o.d" -o ${OBJECTDIR}/ring.o ring.c -Winline
139+
140+${OBJECTDIR}/myspi.o: myspi.c nbproject/Makefile-${CND_CONF}.mk
141+ @${MKDIR} ${OBJECTDIR}
142+ @${RM} ${OBJECTDIR}/myspi.o.d
143+ @${RM} ${OBJECTDIR}/myspi.o.ok ${OBJECTDIR}/myspi.o.err
144+ @${FIXDEPS} "${OBJECTDIR}/myspi.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/myspi.o.d" -o ${OBJECTDIR}/myspi.o myspi.c -Winline
139145
140146 else
141147 ${OBJECTDIR}/byte2var.o: byte2var.c nbproject/Makefile-${CND_CONF}.mk
142148 @${MKDIR} ${OBJECTDIR}
143149 @${RM} ${OBJECTDIR}/byte2var.o.d
144150 @${RM} ${OBJECTDIR}/byte2var.o.ok ${OBJECTDIR}/byte2var.o.err
145- @${FIXDEPS} "${OBJECTDIR}/byte2var.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/byte2var.o.d" -o ${OBJECTDIR}/byte2var.o byte2var.c
151+ @${FIXDEPS} "${OBJECTDIR}/byte2var.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/byte2var.o.d" -o ${OBJECTDIR}/byte2var.o byte2var.c -Winline
152+
153+${OBJECTDIR}/myuart.o: myuart.c nbproject/Makefile-${CND_CONF}.mk
154+ @${MKDIR} ${OBJECTDIR}
155+ @${RM} ${OBJECTDIR}/myuart.o.d
156+ @${RM} ${OBJECTDIR}/myuart.o.ok ${OBJECTDIR}/myuart.o.err
157+ @${FIXDEPS} "${OBJECTDIR}/myuart.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/myuart.o.d" -o ${OBJECTDIR}/myuart.o myuart.c -Winline
146158
147159 ${OBJECTDIR}/debug_print.o: debug_print.c nbproject/Makefile-${CND_CONF}.mk
148160 @${MKDIR} ${OBJECTDIR}
149161 @${RM} ${OBJECTDIR}/debug_print.o.d
150162 @${RM} ${OBJECTDIR}/debug_print.o.ok ${OBJECTDIR}/debug_print.o.err
151- @${FIXDEPS} "${OBJECTDIR}/debug_print.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/debug_print.o.d" -o ${OBJECTDIR}/debug_print.o debug_print.c
163+ @${FIXDEPS} "${OBJECTDIR}/debug_print.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/debug_print.o.d" -o ${OBJECTDIR}/debug_print.o debug_print.c -Winline
152164
153-${OBJECTDIR}/myuart.o: myuart.c nbproject/Makefile-${CND_CONF}.mk
165+${OBJECTDIR}/mysts.o: mysts.c nbproject/Makefile-${CND_CONF}.mk
154166 @${MKDIR} ${OBJECTDIR}
155- @${RM} ${OBJECTDIR}/myuart.o.d
156- @${RM} ${OBJECTDIR}/myuart.o.ok ${OBJECTDIR}/myuart.o.err
157- @${FIXDEPS} "${OBJECTDIR}/myuart.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/myuart.o.d" -o ${OBJECTDIR}/myuart.o myuart.c
167+ @${RM} ${OBJECTDIR}/mysts.o.d
168+ @${RM} ${OBJECTDIR}/mysts.o.ok ${OBJECTDIR}/mysts.o.err
169+ @${FIXDEPS} "${OBJECTDIR}/mysts.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/mysts.o.d" -o ${OBJECTDIR}/mysts.o mysts.c -Winline
158170
159171 ${OBJECTDIR}/ublox.o: ublox.c nbproject/Makefile-${CND_CONF}.mk
160172 @${MKDIR} ${OBJECTDIR}
161173 @${RM} ${OBJECTDIR}/ublox.o.d
162174 @${RM} ${OBJECTDIR}/ublox.o.ok ${OBJECTDIR}/ublox.o.err
163- @${FIXDEPS} "${OBJECTDIR}/ublox.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/ublox.o.d" -o ${OBJECTDIR}/ublox.o ublox.c
175+ @${FIXDEPS} "${OBJECTDIR}/ublox.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/ublox.o.d" -o ${OBJECTDIR}/ublox.o ublox.c -Winline
164176
165177 ${OBJECTDIR}/myad.o: myad.c nbproject/Makefile-${CND_CONF}.mk
166178 @${MKDIR} ${OBJECTDIR}
167179 @${RM} ${OBJECTDIR}/myad.o.d
168180 @${RM} ${OBJECTDIR}/myad.o.ok ${OBJECTDIR}/myad.o.err
169- @${FIXDEPS} "${OBJECTDIR}/myad.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/myad.o.d" -o ${OBJECTDIR}/myad.o myad.c
181+ @${FIXDEPS} "${OBJECTDIR}/myad.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/myad.o.d" -o ${OBJECTDIR}/myad.o myad.c -Winline
170182
171183 ${OBJECTDIR}/main.o: main.c nbproject/Makefile-${CND_CONF}.mk
172184 @${MKDIR} ${OBJECTDIR}
173185 @${RM} ${OBJECTDIR}/main.o.d
174186 @${RM} ${OBJECTDIR}/main.o.ok ${OBJECTDIR}/main.o.err
175- @${FIXDEPS} "${OBJECTDIR}/main.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/main.o.d" -o ${OBJECTDIR}/main.o main.c
176-
177-${OBJECTDIR}/myspi.o: myspi.c nbproject/Makefile-${CND_CONF}.mk
178- @${MKDIR} ${OBJECTDIR}
179- @${RM} ${OBJECTDIR}/myspi.o.d
180- @${RM} ${OBJECTDIR}/myspi.o.ok ${OBJECTDIR}/myspi.o.err
181- @${FIXDEPS} "${OBJECTDIR}/myspi.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/myspi.o.d" -o ${OBJECTDIR}/myspi.o myspi.c
187+ @${FIXDEPS} "${OBJECTDIR}/main.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/main.o.d" -o ${OBJECTDIR}/main.o main.c -Winline
182188
183189 ${OBJECTDIR}/ring.o: ring.c nbproject/Makefile-${CND_CONF}.mk
184190 @${MKDIR} ${OBJECTDIR}
185191 @${RM} ${OBJECTDIR}/ring.o.d
186192 @${RM} ${OBJECTDIR}/ring.o.ok ${OBJECTDIR}/ring.o.err
187- @${FIXDEPS} "${OBJECTDIR}/ring.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/ring.o.d" -o ${OBJECTDIR}/ring.o ring.c
193+ @${FIXDEPS} "${OBJECTDIR}/ring.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/ring.o.d" -o ${OBJECTDIR}/ring.o ring.c -Winline
194+
195+${OBJECTDIR}/myspi.o: myspi.c nbproject/Makefile-${CND_CONF}.mk
196+ @${MKDIR} ${OBJECTDIR}
197+ @${RM} ${OBJECTDIR}/myspi.o.d
198+ @${RM} ${OBJECTDIR}/myspi.o.ok ${OBJECTDIR}/myspi.o.err
199+ @${FIXDEPS} "${OBJECTDIR}/myspi.o.d" $(SILENT) -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -omf=elf -x c -c -mcpu=$(MP_PROCESSOR_OPTION) -O1 -MMD -MF "${OBJECTDIR}/myspi.o.d" -o ${OBJECTDIR}/myspi.o myspi.c -Winline
188200
189201 endif
190202
--- a/nbproject/Makefile-genesis.properties
+++ b/nbproject/Makefile-genesis.properties
@@ -1,5 +1,5 @@
11 #
2-#Tue Nov 22 21:08:51 JST 2011
2+#Mon Nov 28 11:11:47 JST 2011
33 default.languagetoolchain.dir=/opt/microchip/mplabc30/v3.30c/bin
44 com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=11bb82e71763925c87fa30f6c65473b1
55 default.languagetoolchain.version=3_30
--- a/nbproject/configurations.xml
+++ b/nbproject/configurations.xml
@@ -31,6 +31,8 @@
3131 <itemPath>myint.h</itemPath>
3232 <itemPath>myspi.c</itemPath>
3333 <itemPath>myspi.h</itemPath>
34+ <itemPath>mysts.c</itemPath>
35+ <itemPath>mysts.h</itemPath>
3436 <itemPath>myuart.c</itemPath>
3537 <itemPath>myuart.h</itemPath>
3638 <itemPath>ring.c</itemPath>
@@ -93,14 +95,15 @@
9395 <property key="pre-instruction-scheduling" value="default"/>
9496 <property key="enable-large-arrays" value="false"/>
9597 <property key="scalar-model" value="default"/>
98+ <appendMe value="-Winline"/>
9699 </C30>
97100 <C30-AS>
98101 <property key="omit-debug-dirs" value="false"/>
99102 <property key="extra-include-directories-for-assembler" value=""/>
100103 <property key="preprocessor-macros" value=""/>
101104 <property key="list-file" value=""/>
102- <property key="list-source" value="false"/>
103105 <property key="list-assembly" value="false"/>
106+ <property key="list-source" value="false"/>
104107 <property key="relax" value="false"/>
105108 <property key="extra-include-directories-for-preprocessor" value=""/>
106109 <property key="warning-level" value="emit-warnings"/>
--- a/ring.c
+++ b/ring.c
@@ -5,9 +5,9 @@
55 write位置
66 read位置
77 */
8-static unsigned char r_write;
9-static unsigned char r_read;
10-static unsigned char r_num;
8+unsigned char r_write;
9+unsigned char r_read;
10+unsigned char r_num;
1111
1212 /*
1313 */
@@ -20,29 +20,16 @@ void ring_init(void)
2020 /*
2121 読み出し位置
2222 */
23-unsigned char ring_read_get(void)
24-{
25- return r_read;
26-}
2723 void ring_read_set(unsigned char i)
2824 {
29- r_read = i;
25+ r_read = i;
3026 }
3127 void ring_read_plus(void)
3228 {
33- r_read++;
34- if (r_read >= r_num) r_read = 0;
35-}
36-// 書き込み位置
37-unsigned char ring_write_get(void)
38-{
39- return r_write;
40-}
41-void ring_write_plus(void)
42-{
43- r_write++;
44- if (r_write >= r_num) r_write = 0;
29+ r_read++;
30+ if (r_read >= r_num) r_read = 0;
4531 }
32+
4633 // 読み込んでいないデータ数
4734 unsigned char ring_num_get()
4835 {
--- a/ring.h
+++ b/ring.h
@@ -5,17 +5,26 @@
55
66 #define RING_NUM 6
77
8+extern unsigned char r_write;
9+extern unsigned char r_read;
10+extern unsigned char r_num;
11+
812 #define ring_clear() ring_read_set(ring_write_get(t))
913
1014 void ring_init(void);
15+
1116 //読み出し位置
12-unsigned char ring_read_get(void);
17+#define ring_read_get() r_read
1318 void ring_read_set(unsigned char i);
1419 void ring_read_plus(void);
1520
1621 // 書き込み位置
17-unsigned char ring_write_get(void);
18-void ring_write_plus(void);
22+#define ring_write_get() r_write
23+inline extern void ring_write_plus(void)
24+{
25+ r_write++;
26+ if (r_write >= r_num) r_write = 0;
27+}
1928
2029 unsigned char ring_num_get();
2130 unsigned char ring_is_full(void);
Show on old repository browser