Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MPU9250_SPI SDFileSystem XBeeLib
main.cpp@7:ebaaff27840b, 2017-10-12 (annotated)
- Committer:
- gusteibolt
- Date:
- Thu Oct 12 14:32:34 2017 +0000
- Revision:
- 7:ebaaff27840b
- Parent:
- 6:939df52d75c9
- Child:
- 8:ba93a973f967
Separated event from main.cpp, still a bug on that!
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| gusteibolt | 1:a6dc717fb060 | 1 | /* |
| gusteibolt | 1:a6dc717fb060 | 2 | * Los Putacos |
| gusteibolt | 1:a6dc717fb060 | 3 | * Copyright (C) 2017, All rights reserved. |
| gusteibolt | 1:a6dc717fb060 | 4 | * ________________________________________ |
| gusteibolt | 1:a6dc717fb060 | 5 | * |
| gusteibolt | 1:a6dc717fb060 | 6 | * Created by: Gustavo Campana, Michael Schmidt, Miguel Lopez |
| gusteibolt | 1:a6dc717fb060 | 7 | * Date: 11-Oct-2017 |
| gusteibolt | 1:a6dc717fb060 | 8 | * Version: V0.1 |
| gusteibolt | 1:a6dc717fb060 | 9 | */ |
| gusteibolt | 1:a6dc717fb060 | 10 | |
| gusteibolt | 1:a6dc717fb060 | 11 | //----------------------------------------------------------------- |
| gusteibolt | 1:a6dc717fb060 | 12 | // Board: NUCLEO - F401RE |
| gusteibolt | 1:a6dc717fb060 | 13 | // Version: MR1136 rev C |
| gusteibolt | 1:a6dc717fb060 | 14 | //----------------------------------------------------------------- |
| gusteibolt | 1:a6dc717fb060 | 15 | |
| gusteibolt | 1:a6dc717fb060 | 16 | //----------------------------------------------------------------- |
| gusteibolt | 1:a6dc717fb060 | 17 | // Includes |
| gusteibolt | 0:73cd0cb02330 | 18 | #include "mbed.h" |
| gusteibolt | 0:73cd0cb02330 | 19 | #include "rtos.h" |
| gusteibolt | 3:26aeff25f610 | 20 | #include "mbed_events.h" |
| gusteibolt | 3:26aeff25f610 | 21 | |
| gusteibolt | 3:26aeff25f610 | 22 | #include "configuration.h" |
| gusteibolt | 7:ebaaff27840b | 23 | #include "event.h" |
| gusteibolt | 7:ebaaff27840b | 24 | #include "pin.h" |
| gusteibolt | 3:26aeff25f610 | 25 | #include "MPU9250.h" |
| gusteibolt | 1:a6dc717fb060 | 26 | //----------------------------------------------------------------- |
| gusteibolt | 0:73cd0cb02330 | 27 | |
| gusteibolt | 1:a6dc717fb060 | 28 | //----------------------------------------------------------------- |
| gusteibolt | 1:a6dc717fb060 | 29 | // Declarations |
| gusteibolt | 3:26aeff25f610 | 30 | Timer t; //Timer µS time-stamp |
| gusteibolt | 3:26aeff25f610 | 31 | |
| gusteibolt | 3:26aeff25f610 | 32 | EventQueue queue(32 * EVENTS_EVENT_SIZE); //Event |
| gusteibolt | 3:26aeff25f610 | 33 | |
| gusteibolt | 3:26aeff25f610 | 34 | Serial pc(USBTX, USBRX); // PC Serial (Debug) |
| gusteibolt | 3:26aeff25f610 | 35 | |
| gusteibolt | 3:26aeff25f610 | 36 | MPU9250 mpu9250; // IMU MPU-9255 by Kris Winer |
| gusteibolt | 1:a6dc717fb060 | 37 | //----------------------------------------------------------------- |
| gusteibolt | 1:a6dc717fb060 | 38 | |
| gusteibolt | 1:a6dc717fb060 | 39 | //----------------------------------------------------------------- |
| gusteibolt | 1:a6dc717fb060 | 40 | // Global Variables |
| gusteibolt | 3:26aeff25f610 | 41 | // Your code here! |
| gusteibolt | 1:a6dc717fb060 | 42 | //----------------------------------------------------------------- |
| gusteibolt | 1:a6dc717fb060 | 43 | |
| gusteibolt | 1:a6dc717fb060 | 44 | //----------------------------------------------------------------- |
| gusteibolt | 7:ebaaff27840b | 45 | void setup(){ |
| gusteibolt | 3:26aeff25f610 | 46 | |
| gusteibolt | 3:26aeff25f610 | 47 | // PC Serial (Debug) baudrate |
| gusteibolt | 3:26aeff25f610 | 48 | pc.baud(9600); |
| gusteibolt | 3:26aeff25f610 | 49 | pc.printf("CPU SystemCoreClock is %d Hz\r\n", SystemCoreClock); |
| gusteibolt | 3:26aeff25f610 | 50 | |
| gusteibolt | 3:26aeff25f610 | 51 | // Task queue |
| gusteibolt | 3:26aeff25f610 | 52 | int task1_id = queue.call_every(1000, printf, "called every 1 seconds\n"); |
| gusteibolt | 3:26aeff25f610 | 53 | int task2_id = queue.call_every(2500, printf, "called every 2.5 seconds\n"); |
| gusteibolt | 7:ebaaff27840b | 54 | //int task3_id = queue.call_every(3000, print_event, (void *)"called every 3 seconds\n"); |
| gusteibolt | 7:ebaaff27840b | 55 | //int task4_id = queue.call_every(50, blink_event, led1); |
| gusteibolt | 0:73cd0cb02330 | 56 | } |
| gusteibolt | 1:a6dc717fb060 | 57 | //----------------------------------------------------------------- |
| gusteibolt | 0:73cd0cb02330 | 58 | |
| gusteibolt | 1:a6dc717fb060 | 59 | //----------------------------------------------------------------- |
| Mister_Lopez | 4:56e903769e94 | 60 | void initMPU9250() |
| Mister_Lopez | 4:56e903769e94 | 61 | { |
| Mister_Lopez | 4:56e903769e94 | 62 | // Initialize MPU9250 device |
| Mister_Lopez | 4:56e903769e94 | 63 | // wake up device |
| gusteibolt | 5:18e89e309715 | 64 | //writeByte(MPU9250_ADDRESS, PWR_MGMT_1, 0x00); // Clear sleep mode bit (6), enable all sensors |
| Mister_Lopez | 4:56e903769e94 | 65 | |
| Mister_Lopez | 4:56e903769e94 | 66 | } |
| Mister_Lopez | 4:56e903769e94 | 67 | |
| Mister_Lopez | 4:56e903769e94 | 68 | //----------------------------------------------------------------- |
| Mister_Lopez | 4:56e903769e94 | 69 | |
| Mister_Lopez | 4:56e903769e94 | 70 | //----------------------------------------------------------------- |
| gusteibolt | 0:73cd0cb02330 | 71 | int main() |
| gusteibolt | 0:73cd0cb02330 | 72 | { |
| gusteibolt | 7:ebaaff27840b | 73 | setup(); // Initial setups |
| gusteibolt | 3:26aeff25f610 | 74 | |
| Mister_Lopez | 4:56e903769e94 | 75 | |
| Mister_Lopez | 4:56e903769e94 | 76 | //Reading the analog input (Microphone) array = micro.read_u16(); |
| Mister_Lopez | 4:56e903769e94 | 77 | |
| Mister_Lopez | 4:56e903769e94 | 78 | |
| gusteibolt | 0:73cd0cb02330 | 79 | while (true) { |
| gusteibolt | 3:26aeff25f610 | 80 | queue.dispatch(); |
| gusteibolt | 0:73cd0cb02330 | 81 | } |
| gusteibolt | 0:73cd0cb02330 | 82 | } |
| gusteibolt | 1:a6dc717fb060 | 83 | //----------------------------------------------------------------- |

