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@3:26aeff25f610, 2017-10-12 (annotated)
- Committer:
- gusteibolt
- Date:
- Thu Oct 12 00:45:41 2017 +0000
- Revision:
- 3:26aeff25f610
- Parent:
- 1:a6dc717fb060
- Child:
- 4:56e903769e94
- Add Object Declarations; - Add task schedule
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 | 3:26aeff25f610 | 23 | #include "MPU9250.h" |
| gusteibolt | 1:a6dc717fb060 | 24 | //----------------------------------------------------------------- |
| gusteibolt | 0:73cd0cb02330 | 25 | |
| gusteibolt | 1:a6dc717fb060 | 26 | //----------------------------------------------------------------- |
| gusteibolt | 1:a6dc717fb060 | 27 | // Declarations |
| gusteibolt | 3:26aeff25f610 | 28 | |
| gusteibolt | 3:26aeff25f610 | 29 | //Analog Input |
| gusteibolt | 3:26aeff25f610 | 30 | |
| gusteibolt | 3:26aeff25f610 | 31 | //Digital Input |
| gusteibolt | 3:26aeff25f610 | 32 | |
| gusteibolt | 1:a6dc717fb060 | 33 | DigitalOut led1(LED1); |
| gusteibolt | 3:26aeff25f610 | 34 | |
| gusteibolt | 3:26aeff25f610 | 35 | Timer t; //Timer µS time-stamp |
| gusteibolt | 3:26aeff25f610 | 36 | |
| gusteibolt | 3:26aeff25f610 | 37 | EventQueue queue(32 * EVENTS_EVENT_SIZE); //Event |
| gusteibolt | 3:26aeff25f610 | 38 | |
| gusteibolt | 3:26aeff25f610 | 39 | Serial pc(USBTX, USBRX); // PC Serial (Debug) |
| gusteibolt | 3:26aeff25f610 | 40 | |
| gusteibolt | 3:26aeff25f610 | 41 | MPU9250 mpu9250; // IMU MPU-9255 by Kris Winer |
| gusteibolt | 1:a6dc717fb060 | 42 | //----------------------------------------------------------------- |
| gusteibolt | 1:a6dc717fb060 | 43 | |
| gusteibolt | 1:a6dc717fb060 | 44 | //----------------------------------------------------------------- |
| gusteibolt | 1:a6dc717fb060 | 45 | // Global Variables |
| gusteibolt | 3:26aeff25f610 | 46 | // Your code here! |
| gusteibolt | 1:a6dc717fb060 | 47 | //----------------------------------------------------------------- |
| gusteibolt | 1:a6dc717fb060 | 48 | |
| gusteibolt | 1:a6dc717fb060 | 49 | //----------------------------------------------------------------- |
| gusteibolt | 3:26aeff25f610 | 50 | void print_stinrg(char c = '*') |
| gusteibolt | 0:73cd0cb02330 | 51 | { |
| gusteibolt | 3:26aeff25f610 | 52 | pc.putc(c); |
| gusteibolt | 0:73cd0cb02330 | 53 | } |
| gusteibolt | 1:a6dc717fb060 | 54 | //----------------------------------------------------------------- |
| gusteibolt | 0:73cd0cb02330 | 55 | |
| gusteibolt | 1:a6dc717fb060 | 56 | //----------------------------------------------------------------- |
| gusteibolt | 3:26aeff25f610 | 57 | void print_thread(void const *argv) |
| gusteibolt | 0:73cd0cb02330 | 58 | { |
| gusteibolt | 3:26aeff25f610 | 59 | pc.printf((const char*)argv); |
| gusteibolt | 3:26aeff25f610 | 60 | } |
| gusteibolt | 3:26aeff25f610 | 61 | //----------------------------------------------------------------- |
| gusteibolt | 3:26aeff25f610 | 62 | |
| gusteibolt | 3:26aeff25f610 | 63 | //----------------------------------------------------------------- |
| gusteibolt | 3:26aeff25f610 | 64 | void Setup(){ |
| gusteibolt | 3:26aeff25f610 | 65 | |
| gusteibolt | 3:26aeff25f610 | 66 | // PC Serial (Debug) baudrate |
| gusteibolt | 3:26aeff25f610 | 67 | pc.baud(9600); |
| gusteibolt | 3:26aeff25f610 | 68 | pc.printf("CPU SystemCoreClock is %d Hz\r\n", SystemCoreClock); |
| gusteibolt | 3:26aeff25f610 | 69 | |
| gusteibolt | 3:26aeff25f610 | 70 | // Task queue |
| gusteibolt | 3:26aeff25f610 | 71 | int task1_id = queue.call_every(1000, printf, "called every 1 seconds\n"); |
| gusteibolt | 3:26aeff25f610 | 72 | int task2_id = queue.call_every(2500, printf, "called every 2.5 seconds\n"); |
| gusteibolt | 3:26aeff25f610 | 73 | int task3_id = queue.call_every(3000, print_thread, (void *)"called every 3 seconds\n"); |
| gusteibolt | 0:73cd0cb02330 | 74 | } |
| gusteibolt | 1:a6dc717fb060 | 75 | //----------------------------------------------------------------- |
| gusteibolt | 0:73cd0cb02330 | 76 | |
| gusteibolt | 1:a6dc717fb060 | 77 | //----------------------------------------------------------------- |
| gusteibolt | 0:73cd0cb02330 | 78 | int main() |
| gusteibolt | 0:73cd0cb02330 | 79 | { |
| gusteibolt | 3:26aeff25f610 | 80 | Setup(); // Initial setups |
| gusteibolt | 3:26aeff25f610 | 81 | |
| gusteibolt | 0:73cd0cb02330 | 82 | while (true) { |
| gusteibolt | 3:26aeff25f610 | 83 | queue.dispatch(); |
| gusteibolt | 0:73cd0cb02330 | 84 | } |
| gusteibolt | 0:73cd0cb02330 | 85 | } |
| gusteibolt | 1:a6dc717fb060 | 86 | //----------------------------------------------------------------- |

