• R/O
  • HTTP
  • SSH
  • HTTPS

cpu2010: Commit

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


Commit MetaInfo

Revisãofdf2a337333a5a2f7b88ca5d27a0debae6c9a019 (tree)
Hora2011-11-30 11:57:49
AutorNaoya Takamura <ntaka206@user...>
CommiterNaoya Takamura

Mensagem de Log

11/11/30 12H serial csv out.

Mudança Sumário

Diff

--- a/main.c
+++ b/main.c
@@ -44,12 +44,24 @@ _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2 )
4444 */
4545 #define ADBUF_BYTE 3 // AD 1CH 1sample dataのbyte数
4646
47+typedef struct {
48+ UbloxNavTimeUtc t; // タイムスタンプ
49+ long data1sec[AD_CHNUM]; // 1sec平均値
50+ unsigned char data[AD_CHNUM][ADBUF_BYTE*AD_SAMPLE]; // AD_SAMPLE[Hz]のデータ
51+} ADbufType;
52+static ADbufType adbuf[RING_NUM];
53+
4754 // SPI外部送信用バッファ AD_SAMPLE[Hz]
48-static char adbuf[RING_NUM][AD_CHNUM][ADBUF_BYTE*AD_SAMPLE];
55+//static char adbuf[RING_NUM][AD_CHNUM][ADBUF_BYTE*AD_SAMPLE];
4956 // 1sec平均値
50-static long adbuf_1sec[RING_NUM][AD_CHNUM];
57+//static long adbuf_1sec[RING_NUM][AD_CHNUM];
5158 // timestamp
52-static UbloxNavTimeUtc adbuf_t[RING_NUM];
59+//static UbloxNavTimeUtc adbuf_t[RING_NUM];
60+
61+#define adbuf_get(buf_no) (&adbuf[buf_no])
62+#define adbuf_data_get(buf_no) (adbuf[buf_no].data)
63+#define adbuf_1sec_get(buf_no) (adbuf[buf_no].data1sec)
64+#define adbuf_time_get(buf_no) (&(adbuf[buf_no].t))
5365
5466 inline void my_memcpy(void *dest0, void *src0, int len)
5567 {
@@ -76,14 +88,15 @@ inline void adbuf_write(unsigned char buf_no, unsigned char ch, int cnt, long *d
7688 {
7789 unsigned char *ptr = (unsigned char*)data;
7890 unsigned char i;
91+
7992 for(i = 0; i < ADBUF_BYTE; i++) {
80- adbuf[buf_no][ch][ADBUF_BYTE*cnt + i] = *(ptr++);
93+ adbuf->data[ch][ADBUF_BYTE*cnt + i] = *(ptr++);
8194 }
8295 }
8396 // 1
8497 inline void adbuf_1sec_write(char buf_no, long *data)
8598 {
86- my_memcpy(adbuf_1sec[buf_no], data, sizeof(long) * AD_CHNUM);
99+ my_memcpy(adbuf_1sec_get(buf_no), data, sizeof(long) * AD_CHNUM);
87100 /* char ch;
88101 for(ch = 0; ch < AD_CHNUM; ch++)
89102 adbuf_1sec[buf_no][ch] = data[ch];
@@ -91,7 +104,8 @@ inline void adbuf_1sec_write(char buf_no, long *data)
91104 }
92105 inline void adbuf_time_write(char buf_no, UbloxNavTimeUtc *t)
93106 {
94- my_memcpy(&adbuf_t[buf_no], t, sizeof(UbloxNavTimeUtc));
107+// my_memcpy(&adbuf_t[buf_no], t, sizeof(UbloxNavTimeUtc));
108+ my_memcpy(adbuf_time_get(buf_no), t, sizeof(UbloxNavTimeUtc));
95109 }
96110
97111 /**** ublox *************************************************/
@@ -166,6 +180,9 @@ static char pps_intf;
166180 #define pps_intf_set() pps_intf = 1
167181 #define pps_is_intf_enable() (pps_intf != 0)
168182
183+/*
184+ * main()
185+ */
169186 int main(int argc, char** argv) {
170187 unsigned int i;
171188 // UART2 DebugPort
@@ -310,8 +327,8 @@ int main(int argc, char** argv) {
310327 }
311328 if (ring_read_get() != ring_write_get()) {
312329 // タイムスタンプget
313- gps = &adbuf_t[ring_read_get()];
314- sprintf(sz, "%04u/%02d/%02d %02d:%02d:%02d.%09ld %6lums %6luns %02X\r\n",
330+ gps = adbuf_time_get(ring_read_get());
331+ sprintf(sz, "%04u/%02d/%02d %02d:%02d:%02d.%09ld,%6lums,%6luns,%02X",
315332 gps->year, gps->month, gps->day, gps->hour, gps->min, gps->sec, gps->nano,
316333 gps->tow, gps->tacc, gps->valid
317334 );
@@ -320,8 +337,10 @@ int main(int argc, char** argv) {
320337 #if 1
321338 // AD data get
322339 char ch;
340+ long *lp;
341+ lp = adbuf_1sec_get(ring_read_get());
323342 for(ch=0; ch<AD_CHNUM; ch++) {
324- sprintf(sz, "%+7ld,", adbuf_1sec[ring_read_get()][ch]);
343+ sprintf(sz, ",%+7ld", lp[ch]);
325344 PDEBUG(sz);
326345 }
327346 PDEBUG("\r\n");
Show on old repository browser