code
Dependencies: MPU6050_SIM5320_TEST SDFileSystem WakeUp
Fork of Nucleo_L476RG_SDCard_WorkingSample by
Diff: main.cpp
- Revision:
- 1:d5774258d18b
- Parent:
- 0:fdd58267bc13
- Child:
- 2:f745f2656606
--- a/main.cpp Fri Apr 07 10:33:54 2017 +0000 +++ b/main.cpp Sat Sep 09 14:36:17 2017 +0000 @@ -1,34 +1,89 @@ #include "mbed.h" #include "SDFileSystem.h" -//Nucleo L476RG_SDCARD test +#include "SIM5320.h" +#include "MPU6050.h" +#include "SensorBoards.h" + +#define APN "active.bhmobile.ba" +#define USERNAME "" +#define PASSWORD "" +SIM5320 sim5320(PA_9, PA_10); +DigitalOut SIM5320_PWR(PA_1); +DigitalOut SIM_PWR_KEY(PA_15); + +// MOSI, MISO, SCLK, CS, name +//SDFileSystem sd(PA_7, PA_6, PA_5, PA_4, "sd"); + +int main() { + wait(1); + + printf("POCETAK...\r\n"); + SIM5320_PWR = 1; + SIM_PWR_KEY = 1; + wait(1); + SIM_PWR_KEY = 0; + printf("Start\n"); + wait(10); + printf("Starting...\r\n"); + sim5320.sendCommand("AT+CNUM",2); + printf("Checking credit balance...\r\n"); + sim5320.sendCommand("AT+CUSD=1, \"*100#\",15",5); + sim5320.connect(APN,USERNAME,PASSWORD); + + + + + + + +// sim5320.enableGPS(true); +//wait(30); +//****************************Code for GPS*********************************** +/*if(sim5320.getGPS()) + printf("Imam koordinate a=%s krahj\n",sim5320.rx_response); +else + printf("Nemam koordinate\n"); + +printf("\nWait for new connection...\n");*/ -/* SD: Description nucleo PINNR (from top to down of the right-connector-left pins): - 1 CS PB_6 9 - 2 MOSI PA_7 8 - 3 GND GND - 4 3.3V 3.3V - 5 SCLK PA_5 6 - 6 - - 7 MISO PA_6 7 - 8 - -*/ -// MOSI, MISO, SCLK, CS, name -SDFileSystem sd(PA_7, PA_6, PA_5, PB_6, "sd"); + + -int main() { - printf("\nWait for new connection...\n"); - - mkdir("/sd/mydir", 0777); - printf("\nDirectory created\n"); - FILE *fp = fopen("/sd/mydir/sdtest.txt", "w"); - if(fp == NULL) { - printf("Could not open file for write\n"); +//*************************Code for SD card read and write************************************ +/* +mkdir("/sd/mydir8", 0777); +printf("\nDirectory created\n"); +sd.writeSD("/sd/mydir3/sdtest.txt", "1111111\n"); +sd.writeSD("/sd/mydir3/sdtest.txt", "2222222\n"); +sd.writeSD("/sd/mydir3/sdtest.txt", "3333333\n"); +sd.writeSD("/sd/mydir3/sdtest.txt", "4444444\n"); +sd.writeSD("/sd/mydir3/sdtest.txt", "5555555\n"); +char buf[9]; +sd.writeSD("/sd/mydir3/sdtest2.txt", "1111111\n"); +sd.writeSD("/sd/mydir3/sdtest2.txt", "2111111\n"); +sd.writeSD("/sd/mydir3/sdtest2.txt", "3111111\n"); +printf("Upisao 1,2 i3\n"); +sd.readSD("/sd/mydir3/sdtest2.txt",buf); +printf("line=%s\n",buf); +sd.readSD("/sd/mydir3/sdtest2.txt",buf); +printf("line=%s\n",buf); +sd.readSD("/sd/mydir3/sdtest2.txt",buf); +printf("line=%s\n",buf); +*/ + + + + + +/*********************Code for scanning I2C Boards************************* +SensorBoards b1; + uint8_t flag=b1.sensorBoardScanner(); + if (flag) { + printf("nadjena ploca sa adresom %d\n", b1.returnBoardAdd()); } - fprintf(fp, "Hello fun SD Card World!"); - fclose(fp); - printf("Text written to the SD-CARD\n"); -} + else + printf("Nije nadjena ploca\n");*/ +} \ No newline at end of file