SD
Dependencies: MPU6050_SIM5320_TEST
Revision 0:203cf529f52a, committed 2017-09-14
- Comitter:
- suads
- Date:
- Thu Sep 14 16:50:16 2017 +0000
- Commit message:
- MPU_SD_CARD
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Thu Sep 14 16:50:16 2017 +0000 @@ -0,0 +1,4 @@ +.build +.mbed +projectfiles +*.py*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MPU6050.lib Thu Sep 14 16:50:16 2017 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/OsmanKameric/code/MPU6050_SIM5320_TEST/#5be37f1eb60c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Thu Sep 14 16:50:16 2017 +0000 @@ -0,0 +1,87 @@ +# Getting started with Blinky on mbed OS + +This guide reviews the steps required to get Blinky working on an mbed OS platform. + +Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli). + +## Import the example application + +From the command-line, import the example: + +``` +mbed import mbed-os-example-blinky +cd mbed-os-example-blinky +``` + +### Now compile + +Invoke `mbed compile`, and specify the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the ARM Compiler 5: + +``` +mbed compile -m K64F -t ARM +``` + +Your PC may take a few minutes to compile your code. At the end, you see the following result: + +``` +[snip] ++----------------------------+-------+-------+------+ +| Module | .text | .data | .bss | ++----------------------------+-------+-------+------+ +| Misc | 13939 | 24 | 1372 | +| core/hal | 16993 | 96 | 296 | +| core/rtos | 7384 | 92 | 4204 | +| features/FEATURE_IPV4 | 80 | 0 | 176 | +| frameworks/greentea-client | 1830 | 60 | 44 | +| frameworks/utest | 2392 | 512 | 292 | +| Subtotals | 42618 | 784 | 6384 | ++----------------------------+-------+-------+------+ +Allocated Heap: unknown +Allocated Stack: unknown +Total Static RAM memory (data + bss): 7168 bytes +Total RAM memory (data + bss + heap + stack): 7168 bytes +Total Flash memory (text + data + misc): 43402 bytes +Image: .\.build\K64F\ARM\mbed-os-example-blinky.bin +``` + +### Program your board + +1. Connect your mbed device to the computer over USB. +1. Copy the binary file to the mbed device. +1. Press the reset button to start the program. + +The LED on your platform turns on and off. + +## Export the project to Keil MDK, and debug your application + +From the command-line, run the following command: + +``` +mbed export -m K64F -i uvision +``` + +To debug the application: + +1. Start uVision. +1. Import the uVision project generated earlier. +1. Compile your application, and generate an `.axf` file. +1. Make sure uVision is configured to debug over CMSIS-DAP (From the Project menu > Options for Target '...' > Debug tab > Use CMSIS-DAP Debugger). +1. Set breakpoints, and start a debug session. + +![Image of uVision](img/uvision.png) + +## Troubleshooting + +1. Make sure `mbed-cli` is working correctly and its version is `>1.0.0` + + ``` + mbed --version + ``` + + If not, you can update it: + + ``` + pip install mbed-cli --upgrade + ``` + +2. If using Keil MDK, make sure you have a license installed. [MDK-Lite](http://www.keil.com/arm/mdk.asp) has a 32 KB restriction on code size. \ No newline at end of file
Binary file img/uvision.png has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Sep 14 16:50:16 2017 +0000 @@ -0,0 +1,191 @@ +#include "mbed.h" +#include "SDFileSystem.h" +#include "SIM5320.h" +#include "MPU6050.h" +#include "SensorBoards.h" +#include "WakeUp.h" + + + +uint8_t write_sd_buffer[12]; +void create_sensor_data(uint8_t *write_sd_buffer, uint8_t *sensor_board_readings, uint8_t b_id, uint8_t s_id); +//SIM5320 sim5320(PA_9,PA_10); +DigitalOut SIM5320_PWR(PA_1); +DigitalOut SIM_PWR_KEY(PA_15); +InterruptIn mpuInterrupt(PB_6); +uint8_t sensor_board_readings[4]; +bool test = false; +// MOSI, MISO, SCLK, CS, name +SDFileSystem sd(PA_7, PA_6, PA_5, PA_4, "sd"); + +int go_to_sleep = 0; +void mpuInterruptCallback() +{ + test=!test; + +} +void rtc_wakeup() +{ + go_to_sleep = 1; +} + +MPU6050 mpu; +int main() +{ +/////////////////////////////////////////////////MPU_DEEP_SLEEP_WAKEUP//////////////////////////// +/* + mpuInterrupt.fall(mpuInterruptCallback); + wait(2); + mpu.calibrate(accelBias, gyroBias); + mpu.initialize(); + mpu.setSleepEnabled(0); + wait(2); + mpu.setIntFreefallEnabled(1); + mpu.setIntZeroMotionEnabled(0); + mpu.setIntMotionEnabled(1); + printf("Setting mpu parameters...\r\n"); + mpu.setMotionDetectionThreshold(1); + mpu.setMotionDetectionDuration(15); + + while(1){ + printf("sleep\r\n"); + deepsleep(); + if(test){ + wait(1); + printf("Desio se motion\r\n"); + test = 0; + } + } +*/ + +/////////////////////////////////////////////////////////////////////////////////////////// + + // wait(3); + // SIM5320_PWR = 1; + // SIM_PWR_KEY = 1; + // wait(1); + // SIM_PWR_KEY = 0; + /* + wait(25); + wait(2); + printf("Starting...\r\n"); + printf("Starting...\r\n"); + printf("Starting...\r\n"); + printf("Starting...\r\n"); + sim5320.sendCommand("AT+CNUM",2); + printf("Checking credit balance...\r\n"); + sim5320.sendCommand("AT+CUSD=1, \"*100#\",15",5); + //Testing GPS + + sim5320.enableGPS(true); + wait(30); + + //Gettting GPS location + sim5320.sendCommand("AT+CGPSINFO",2); + sim5320.sendCommand("AT+CGPSINFO",2); + sim5320.sendCommand("AT+CGPSINFO",2); + + + + //Testing network connection and disconnection + sim5320.connect("active.bhmobile.ba","",""); + wait(2); + if(sim5320.disconnect()) { + printf("Disconnected\r\n"); + } + + else { + printf("Still connected or error occured!\r\n"); + } + + + + while(1) { + wait(1); + sim5320.sendCommand("AT",1); + } + */ + + + +/////////////////////////////////////////////////RTC_DEEP_SLEEP_WAKEUP//////////////////////////// + /* + set_time(1495040081); // Set RTC time to Wed, 28 Oct 2009 11:35:37 + WakeUp::attach(&rtc_wakeup); + WakeUp::calibrate(); + while (1) { + WakeUp::set_ms(5000); + time_t seconds = time(NULL); + printf("Time = %s\n", ctime(&seconds)); + wait(1); + printf("sleep\n"); + deepsleep(); + if (go_to_sleep == 1) { + wait(1); + printf("Wake_up\n"); + go_to_sleep=0; + } + } +*/ +//////////////////////////////////////////////////////////////////////////////////////////////// + + + +//////////////////////////////////////////////CODE FOR SENDOR_BOARDS//////////////////////////////////////////////////////////////// + /* + uint8_t IDBuffer[8]; + uint8_t IDMeasure[4]; + float measure=0.0; + float measure2=0.0; + + + SensorBoards B1; + B1.getSensorReadings(0x4a,0x10,IDMeasure); + printf("number_of__boards= %d\n",B1.numberOfBoards); + B1.sensorBoardScanner(); + printf("SnesorBoardAdress= %d\n",B1.boards[0].I2CAddress); + B1.getSensorNumbers(); + printf("SensorBoardsensors= %d\n",B1.boards[0].numberOfSensors); + B1.getSensorIDs(); + printf("SensorBoardIDs=%d %d \n",B1.boards[0].sensorIDs[0],B1.boards[0].sensorIDs[1]); + + B1.getSensorReadings(0x4a,0x10,IDMeasure); + + for(int k=0; k<1; k++) { + printf("broj senzora %d \n",B1.boards[k].numberOfSensors); + for(int i=0; i<B1.boards[k].numberOfSensors; i++){ + B1.getSensorReadings(B1.boards[k].I2CAddress,B1.boards[k].sensorIDs[i],IDMeasure); + printf("measure=%d %d %d %d keaj\n",IDMeasure[0],IDMeasure[1],IDMeasure[2],IDMeasure[3]); + //create_sensor_data(write_sd_buffer,IDMeasure,B1.boards[k].I2CAddress,B1.boards[k].sensorIDs[i]); + } + } + + for(int i=0;i<12;i++) + printf("_%d\n",write_sd_buffer[i]); + */ + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + + +return 0; +} +void create_sensor_data(uint8_t *write_sd_buffer, uint8_t *sensor_board_readings, uint8_t b_id, uint8_t s_id) +{ + //pcf8563_read(&rtc); + + write_sd_buffer[0]=0; + write_sd_buffer[1]=1; + write_sd_buffer[2]=2; + write_sd_buffer[3]=3; + write_sd_buffer[4]=4; + write_sd_buffer[5] =b_id; //sensor boaard id + write_sd_buffer[6] =s_id; //sensor id + write_sd_buffer[7] =sensor_board_readings[3]; //sensor reading + write_sd_buffer[8] =sensor_board_readings[2]; //sensor reading + write_sd_buffer[9] =sensor_board_readings[1]; //sensor reading + write_sd_buffer[10]=sensor_board_readings[0]; //sensor reading + write_sd_buffer[11]=0xFF; + write_sd_buffer[12]=0xFF; + +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Thu Sep 14 16:50:16 2017 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#c9e63f14085f5751ff5ead79a7c0382d50a813a2