#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#define CARD_PRESENT 1
#define CARD_NOT_PRESENT 0
char helloFile[] = "hello.txt";
void main()
{
char cardInfo; // Card information
char fp; // File Pointer
BYTE CardState, oldCardState; // Card inserted state variables
LED_1_Start();
LED_1_Switch(0); // Make sure LED is Off
oldCardState = CARD_NOT_PRESENT; // Initialize card insertion state
SDCard_1_Start(); // initialize hardware and SDCard_lib buffers
while(1)
{
CardState = SDCard_1_Present(); // Get current card insertion state
if(CardState != oldCardState) // Check for a change
{
oldCardState = CardState; // Save last state
if(CardState == CARD_PRESENT) // Card inserted
{
LED_1_Switch(1); // About to talk to card, turn on busy LED
SDCard_1_Select(SDCard_1_ENABLE); // Select card
cardInfo = 0;
while ( ! cardInfo ) // Wait for card to communicate
{
// initialize card, determine card type and file system type
cardInfo = SDCard_1_InitCard();
}
fp = SDCard_1_fopen(helloFile,"a"); // Open file to append data
SDCard_1_fputcs("Hello World\r\n", fp); // Write string
SDCard_1_fclose(fp); // Close file
SDCard_1_Select(SDCard_1_DISABLE); // Deselect card
LED_1_Switch(0); // Turn off busy LED
}
}
}
}
uchar status = SDCard_FAIL; // Set status to fail (until cleared by success)
uchar status = SDCard_FAIL; →こうなっていたので、
↓
uchar status = `@INSTANCE_NAME`_FAIL; →インスタンス名になるように修正
#include "psocdynamic.h"
UnloadConfig_Total(); // 設定を全てクリア
LoadConfig_GPS(); // GPS設定に切替え
PRT1DM0 &= 0x20; // Port1[5]を入力ポートに(GOO_5→GIO_5に切替え)
PRT1DM1 |= ~0x20; // (mode = 010)
PRT1DM2 &= ~0x20;
PRT1DM0 |= 0x08; // Port1[3]を出力ポートに(GIO_3→GOO_3に切替え)
PRT1DM1 &= ~0x08; // (mode = 001)
PRT1DM2 &= ~0x08;
OSC_CR4 = 52*2-1; // 24M/6/52/2/8=4800bpsに変更(グローバルリソース VC3 Divider変更)
$GPGGA,,2458.9724,N,12125.6550,E,0,00,00.00,000025.0,M,0015.9,M,,*79
$GPZDA,005416,01,10,2005,+00,00*62
$GPGSV,2,1,08,05,44,057,29,06,05,165,29,09,37,033,29,14,43,335,29*7E
$GPGSV,2,2,08,17,12,191,29,18,58,309,31,21,55,314,31,30,38,189,27*70
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,,V,2458.9724,N,12125.6550,E,,,,003.5,W,N*17
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#define CARD_PRESENT 1
#define CARD_NOT_PRESENT 0
char gps_file[] = "hhmmss.gps";
void main()
{
char cardInfo; // Card information
char fp; // File Pointer
BYTE CardState, oldCardState; // Card inserted state variables
char c;
int i=0;
// ---- UART setup
UART_1_IntCntl(UART_1_ENABLE_RX_INT); // Enable RX interrupts
UART_1_Start(UART_1_PARITY_NONE); // Enable UART
M8C_EnableGInt ; // Turn on interrupts
LED_1_Start();
LED_1_Switch(0); // Make sure LED is Off
oldCardState = CARD_NOT_PRESENT; // Initialize card insertion state
SDCard_1_Start(); // initialize hardware and SDCard_lib buffers
while(1) {
CardState = SDCard_1_Present(); // Get current card insertion state
if(CardState != oldCardState) { // Check for a change
oldCardState = CardState; // Save last state
if(CardState == CARD_PRESENT) { // Card inserted
LED_1_Switch(1); // About to talk to card, turn on busy LED
SDCard_1_Select(SDCard_1_ENABLE); // Select card
cardInfo = 0;
while ( ! cardInfo ) { // Wait for card to communicate
cardInfo = SDCard_1_InitCard();
}
fp = SDCard_1_fopen(gps_file,"a"); // Open file to append data
while (UART_1_bReadRxData()!='$');
SDCard_1_fputc('$',fp); // Write char
while (1) {
c = UART_1_bReadRxData(); // Read char
if (c == '$') if (i++>10) break;
SDCard_1_fputc(c,fp); // Write char
}
SDCard_1_fclose(fp); // Close file
SDCard_1_Select(SDCard_1_DISABLE); // Deselect card
LED_1_Switch(0); // Turn off busy LED
}
}
}
}
$,,,0000.0,W,,N*1F
$GPGGGA,,33659.00372,,N,139955.26686,E,,0,00,,00.000,0004492.7,,M,00339.4,MM,,*7BB
$GPPZDA,11341077,31,110,20006,+000,00*664
$GGPGSV,,3,1,111,02,,70,3440,299,04,774,0666,27,007,46,,212,229,08,,06,1446,27**77
$$GPGSVV,3,2,,11,100,20,2261,299,13,552,0599,29,117,14,,319,333,23,,17,0441,29**76
$$GPGSVV,3,3,,11,244,44,1104,299,27,115,1344,29,331,11,,169,331*43
$GPVVTG,,TT,,M,,,N,,K,,N*2C
$GPRRMC,,VV,36599.03722,N,133955.22686,EE,,,,0007.5,,W,N*11D
$00.00,00097.M34
P39,3
G3769,,GT$GPRM,,,5357,$,0,0
P,,060046,3*
83,6,,7
,,V6525,$.809*
6206,,63201C017571,*,,GM2,,,D$N,0,04,D10,
P,,6350470173,71,,,*
,556,NGGGA,,3693,9004.,B20+,,1,,0073GS7069,,7
,,PC3,E,
$56,04,,20,*18,,3,272,2240,9GTC$GPRM,,5.76,1
$G,5600039,1,,,0,9,C
$G135,13,705,0727,3*3
,,,K,,V35995.68*1
$69..0,D,1
GP33,GV,5,3,9*GRM,,0G69.,00136,,0,5,,,23,2
$VT,,,*2,V35995.68.5WN*GA,35.05.66,000049.,,,A,26106+0,$GV,63424,19,135,K,2N,D
UART_1_bReadRxData:
mov A, REG[UART_1_RX_BUFFER_REG]
ret
UART_1_bReadRxStatus:
mov A, REG[UART_1_RX_CONTROL_REG]
ret
UART_1_cGetChar:
tst REG[UART_1_RX_CONTROL_REG],UART_1_RX_REG_FULL ; Check if a character is ready
jz UART_1_cGetChar ; If not loop
mov A, REG[UART_1_RX_BUFFER_REG] ; Get character
ret
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#define CARD_PRESENT 1
#define CARD_NOT_PRESENT 0
char gps_file[] = "hhmmss.gps";
void main()
{
char cardInfo; // Card information
char fp; // File Pointer
BYTE CardState, oldCardState; // Card inserted state variables
char c;
int i=0;
// ---- UART setup
UART_1_Start(UART_1_PARITY_NONE); // Enable UART
LED_1_Start();
LED_1_Switch(0); // Make sure LED is Off
oldCardState = CARD_NOT_PRESENT; // Initialize card insertion state
SDCard_1_Start(); // initialize hardware and SDCard_lib buffers
while(1) {
CardState = SDCard_1_Present(); // Get current card insertion state
if(CardState != oldCardState) { // Check for a change
oldCardState = CardState; // Save last state
if(CardState == CARD_PRESENT) { // Card inserted
LED_1_Switch(1); // About to talk to card, turn on busy LED
SDCard_1_Select(SDCard_1_ENABLE); // Select card
cardInfo = 0;
while ( ! cardInfo ) { // Wait for card to communicate
cardInfo = SDCard_1_InitCard();
}
while (1) {
while (UART_1_cGetChar() != '$');
if (UART_1_cGetChar() != 'G') continue;
if (UART_1_cGetChar() != 'P') continue;
if (UART_1_cGetChar() != 'Z') continue;
if (UART_1_cGetChar() != 'D') continue;
if (UART_1_cGetChar() != 'A') continue;
if (UART_1_cGetChar() == ',') break;
}
// gps_file[0] = UART_1_cGetChar(); // Read hour
// gps_file[1] = UART_1_cGetChar();
// gps_file[2] = UART_1_cGetChar(); // Read minute
// gps_file[3] = UART_1_cGetChar();
// gps_file[4] = UART_1_cGetChar(); // Read second
// gps_file[5] = UART_1_cGetChar();
fp = SDCard_1_fopen(gps_file,"a"); // Open file to append data
while (UART_1_cGetChar() != '$');
SDCard_1_fputc('$',fp); // Write char
while (1) {
c = UART_1_cGetChar(); // Read char
if (c == '$') if (i++>10) break;
SDCard_1_fputc(c,fp); // Write char
}
SDCard_1_fclose(fp); // Close file
SDCard_1_Select(SDCard_1_DISABLE); // Deselect card
LED_1_Switch(0); // Turn off busy LED
}
}
}
}
74 d5 4b a0 75 18 →なんでこうなるの?
char gps_file[] = "hhmmss.gps";
:
gps_file[0] = 'A';
gps_file[1] = 'B';
gps_file[2] = 'C';
gps_file[3] = 'D';
gps_file[4] = 'E';
gps_file[5] = 'F';
char gps_file[11];
:
cstrcpy(gps_file,"hhmmss.gps");
gps_file[0] = 'A';
gps_file[1] = 'B';
gps_file[2] = 'C';
gps_file[3] = 'D';
gps_file[4] = 'E';
gps_file[5] = 'F';
!W ./main.c(55):[warning] calling function without prototype may cause errors
$GPGGA,,3659.0372,N,13955.2686,E,0,00,00.00,000492.7,M,0039.4,M,,*7B
$GPZDA,043245,05,11,2006,+00,00*66
$GPGSV,3,1,09,03,74,320,33,11,06,207,29,13,16,274,31,15,15,041,33*78^M
$GPGSV,3,2,09,16,44,089,29,19,32,249,29,21,28,050,29,23,11,238,SV,3,3,09,25,37,1
78,29*46
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,,V,3659.0372,N,13955.2686,E,,,,007.5,W,N*1D
#!/usr/local/bin/perl
# gpstrim -- gps NMEA data trimming program by K.I 061106
# GPSのNMEAフォーマットデータのチェックサムを計算し、
# 正しいデータのみ出力するプログラム
while(<>) {
if (/^\$(GP(GGA|ZDA|GSV|VTG|RMC)[^\$]+)\*(\w\w)\r$/) {
@data = unpack("C*", $1);
$sum = 0;
foreach $x (@data) {
$sum ^= $x;
}
if (hex($3)==$sum) { print; }
}
}