Los Putacos / Mbed OS WearableDevice_Nucleo_New

Dependencies:   MPU9250_SPI

Fork of WearableDevice_Nucleo by Los Putacos

Committer:
gusteibolt
Date:
Thu Oct 12 13:18:11 2017 +0000
Revision:
5:18e89e309715
Parent:
4:56e903769e94
Child:
6:939df52d75c9
Initial

Who changed what in which revision?

UserRevisionLine numberNew 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
Mister_Lopez 4:56e903769e94 31 AnalogIn micro(A0);
Mister_Lopez 4:56e903769e94 32
gusteibolt 3:26aeff25f610 33 //Digital Input
gusteibolt 3:26aeff25f610 34
gusteibolt 1:a6dc717fb060 35 DigitalOut led1(LED1);
gusteibolt 3:26aeff25f610 36
gusteibolt 3:26aeff25f610 37 Timer t; //Timer µS time-stamp
gusteibolt 3:26aeff25f610 38
gusteibolt 3:26aeff25f610 39 EventQueue queue(32 * EVENTS_EVENT_SIZE); //Event
gusteibolt 3:26aeff25f610 40
gusteibolt 3:26aeff25f610 41 Serial pc(USBTX, USBRX); // PC Serial (Debug)
gusteibolt 3:26aeff25f610 42
gusteibolt 3:26aeff25f610 43 MPU9250 mpu9250; // IMU MPU-9255 by Kris Winer
gusteibolt 1:a6dc717fb060 44 //-----------------------------------------------------------------
gusteibolt 1:a6dc717fb060 45
gusteibolt 1:a6dc717fb060 46 //-----------------------------------------------------------------
gusteibolt 1:a6dc717fb060 47 // Global Variables
gusteibolt 3:26aeff25f610 48 // Your code here!
gusteibolt 1:a6dc717fb060 49 //-----------------------------------------------------------------
gusteibolt 1:a6dc717fb060 50
gusteibolt 1:a6dc717fb060 51 //-----------------------------------------------------------------
gusteibolt 3:26aeff25f610 52 void print_stinrg(char c = '*')
gusteibolt 0:73cd0cb02330 53 {
gusteibolt 3:26aeff25f610 54 pc.putc(c);
gusteibolt 0:73cd0cb02330 55 }
gusteibolt 1:a6dc717fb060 56 //-----------------------------------------------------------------
gusteibolt 0:73cd0cb02330 57
gusteibolt 1:a6dc717fb060 58 //-----------------------------------------------------------------
gusteibolt 3:26aeff25f610 59 void print_thread(void const *argv)
gusteibolt 0:73cd0cb02330 60 {
gusteibolt 3:26aeff25f610 61 pc.printf((const char*)argv);
gusteibolt 3:26aeff25f610 62 }
gusteibolt 3:26aeff25f610 63 //-----------------------------------------------------------------
gusteibolt 3:26aeff25f610 64
gusteibolt 3:26aeff25f610 65 //-----------------------------------------------------------------
gusteibolt 3:26aeff25f610 66 void Setup(){
gusteibolt 3:26aeff25f610 67
gusteibolt 3:26aeff25f610 68 // PC Serial (Debug) baudrate
gusteibolt 3:26aeff25f610 69 pc.baud(9600);
gusteibolt 3:26aeff25f610 70 pc.printf("CPU SystemCoreClock is %d Hz\r\n", SystemCoreClock);
gusteibolt 3:26aeff25f610 71
gusteibolt 3:26aeff25f610 72 // Task queue
gusteibolt 3:26aeff25f610 73 int task1_id = queue.call_every(1000, printf, "called every 1 seconds\n");
gusteibolt 3:26aeff25f610 74 int task2_id = queue.call_every(2500, printf, "called every 2.5 seconds\n");
gusteibolt 3:26aeff25f610 75 int task3_id = queue.call_every(3000, print_thread, (void *)"called every 3 seconds\n");
gusteibolt 0:73cd0cb02330 76 }
gusteibolt 1:a6dc717fb060 77 //-----------------------------------------------------------------
gusteibolt 0:73cd0cb02330 78
gusteibolt 1:a6dc717fb060 79 //-----------------------------------------------------------------
Mister_Lopez 4:56e903769e94 80 void initMPU9250()
Mister_Lopez 4:56e903769e94 81 {
Mister_Lopez 4:56e903769e94 82 // Initialize MPU9250 device
Mister_Lopez 4:56e903769e94 83 // wake up device
gusteibolt 5:18e89e309715 84 //writeByte(MPU9250_ADDRESS, PWR_MGMT_1, 0x00); // Clear sleep mode bit (6), enable all sensors
Mister_Lopez 4:56e903769e94 85
Mister_Lopez 4:56e903769e94 86 }
Mister_Lopez 4:56e903769e94 87
Mister_Lopez 4:56e903769e94 88 //-----------------------------------------------------------------
Mister_Lopez 4:56e903769e94 89
Mister_Lopez 4:56e903769e94 90 //-----------------------------------------------------------------
gusteibolt 0:73cd0cb02330 91 int main()
gusteibolt 0:73cd0cb02330 92 {
gusteibolt 3:26aeff25f610 93 Setup(); // Initial setups
gusteibolt 3:26aeff25f610 94
Mister_Lopez 4:56e903769e94 95
Mister_Lopez 4:56e903769e94 96 //Reading the analog input (Microphone) array = micro.read_u16();
Mister_Lopez 4:56e903769e94 97
Mister_Lopez 4:56e903769e94 98
gusteibolt 0:73cd0cb02330 99 while (true) {
gusteibolt 3:26aeff25f610 100 queue.dispatch();
gusteibolt 0:73cd0cb02330 101 }
gusteibolt 0:73cd0cb02330 102 }
gusteibolt 1:a6dc717fb060 103 //-----------------------------------------------------------------