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
Fork of WearableDevice_Nucleo by
event.cpp@11:f19020fa18f1, 2017-10-17 (annotated)
- Committer:
- Muglug
- Date:
- Tue Oct 17 09:39:10 2017 +0000
- Revision:
- 11:f19020fa18f1
- Parent:
- 10:577e1fc4453e
Added Test Frame Function;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gusteibolt | 6:939df52d75c9 | 1 | /* |
gusteibolt | 6:939df52d75c9 | 2 | * Los Putacos |
gusteibolt | 6:939df52d75c9 | 3 | * Copyright (C) 2017, All rights reserved. |
gusteibolt | 6:939df52d75c9 | 4 | * ________________________________________ |
gusteibolt | 6:939df52d75c9 | 5 | * |
gusteibolt | 6:939df52d75c9 | 6 | * Created by: Gustavo Campana, Michael Schmidt, Miguel Lopez |
gusteibolt | 6:939df52d75c9 | 7 | * Date: 12-Oct-2017 |
gusteibolt | 6:939df52d75c9 | 8 | * Version: V0.1 |
gusteibolt | 10:577e1fc4453e | 9 | */ |
gusteibolt | 7:ebaaff27840b | 10 | #include "mbed.h" |
gusteibolt | 8:ba93a973f967 | 11 | #include "event.h" |
gusteibolt | 7:ebaaff27840b | 12 | |
gusteibolt | 10:577e1fc4453e | 13 | /* |
gusteibolt | 7:ebaaff27840b | 14 | void print_stinrg(char c = '*') { |
gusteibolt | 7:ebaaff27840b | 15 | pc.putc(c); |
gusteibolt | 7:ebaaff27840b | 16 | } |
gusteibolt | 10:577e1fc4453e | 17 | */ |
gusteibolt | 7:ebaaff27840b | 18 | |
gusteibolt | 10:577e1fc4453e | 19 | /* |
gusteibolt | 10:577e1fc4453e | 20 | void print_event(void const *argv, int i) { |
gusteibolt | 10:577e1fc4453e | 21 | pc.printf("%d ",i); |
gusteibolt | 7:ebaaff27840b | 22 | pc.printf((const char*)argv); |
gusteibolt | 10:577e1fc4453e | 23 | pc.printf("\r\n"); |
gusteibolt | 7:ebaaff27840b | 24 | } |
gusteibolt | 10:577e1fc4453e | 25 | */ |
gusteibolt | 7:ebaaff27840b | 26 | |
gusteibolt | 10:577e1fc4453e | 27 | /* |
gusteibolt | 7:ebaaff27840b | 28 | void blink_event(DigitalOut pin){ |
gusteibolt | 7:ebaaff27840b | 29 | pin = 1; |
gusteibolt | 10:577e1fc4453e | 30 | */ |
gusteibolt | 10:577e1fc4453e | 31 | |
gusteibolt | 10:577e1fc4453e | 32 | void readIMU(){ |
gusteibolt | 10:577e1fc4453e | 33 | //imu.resetMPU9250(); |
gusteibolt | 10:577e1fc4453e | 34 | pc.printf("%d\r\r ",time_stamp.read()); |
Muglug | 11:f19020fa18f1 | 35 | } |
Muglug | 11:f19020fa18f1 | 36 | |
Muglug | 11:f19020fa18f1 | 37 | void TransmitRequest() //(const char* command, const char* data, int length) |
Muglug | 11:f19020fa18f1 | 38 | { |
Muglug | 11:f19020fa18f1 | 39 | int tmp = 22; // length (grandeur du data à envoyer) 4 (API(1), FrameID(1), AT Command(2)) |
Muglug | 11:f19020fa18f1 | 40 | char* trm = new char[tmp]; // 4 (Delimiter(1), Length(2), Checksum(1)) |
Muglug | 11:f19020fa18f1 | 41 | |
Muglug | 11:f19020fa18f1 | 42 | trm[0] = 0x7E; // Start Delimiter |
Muglug | 11:f19020fa18f1 | 43 | // trm[1] = static_cast<char>((tmp >> 8) & 0xFF); // MSB de length |
Muglug | 11:f19020fa18f1 | 44 | // trm[2] = static_cast<char>(tmp & 0xFF); // LSB length |
Muglug | 11:f19020fa18f1 | 45 | trm[1] = 0x00; // Length 1 |
Muglug | 11:f19020fa18f1 | 46 | trm[2] = 0x12; // Length 2 |
Muglug | 11:f19020fa18f1 | 47 | trm[3] = 0x10; // Frame Type |
Muglug | 11:f19020fa18f1 | 48 | trm[4] = 0x01; // Frame ID |
Muglug | 11:f19020fa18f1 | 49 | |
Muglug | 11:f19020fa18f1 | 50 | // 64-bit Destination Address |
Muglug | 11:f19020fa18f1 | 51 | trm[5] = 0x00; |
Muglug | 11:f19020fa18f1 | 52 | trm[6] = 0x00; |
Muglug | 11:f19020fa18f1 | 53 | trm[7] = 0x00; |
Muglug | 11:f19020fa18f1 | 54 | trm[8] = 0x00; |
Muglug | 11:f19020fa18f1 | 55 | trm[9] = 0x00; |
Muglug | 11:f19020fa18f1 | 56 | trm[10] = 0x00; |
Muglug | 11:f19020fa18f1 | 57 | trm[11] = 0x00; |
Muglug | 11:f19020fa18f1 | 58 | trm[12] = 0x00; |
Muglug | 11:f19020fa18f1 | 59 | |
Muglug | 11:f19020fa18f1 | 60 | // 16-bit Destination Address |
Muglug | 11:f19020fa18f1 | 61 | trm[13] = 0xFF; |
Muglug | 11:f19020fa18f1 | 62 | trm[14] = 0xFE; |
Muglug | 11:f19020fa18f1 | 63 | |
Muglug | 11:f19020fa18f1 | 64 | trm[15] = 0x00; // Broadcast Radius |
Muglug | 11:f19020fa18f1 | 65 | trm[16] = 0x00; // Options |
Muglug | 11:f19020fa18f1 | 66 | |
Muglug | 11:f19020fa18f1 | 67 | // RF Data |
Muglug | 11:f19020fa18f1 | 68 | trm[17] = 0x48; // H |
Muglug | 11:f19020fa18f1 | 69 | trm[18] = 0x6F; // o |
Muglug | 11:f19020fa18f1 | 70 | trm[19] = 0x6C; // l |
Muglug | 11:f19020fa18f1 | 71 | trm[20] = 0x61; // a |
Muglug | 11:f19020fa18f1 | 72 | |
Muglug | 11:f19020fa18f1 | 73 | trm[21] = 0x6D; // Checksum |
Muglug | 11:f19020fa18f1 | 74 | |
Muglug | 11:f19020fa18f1 | 75 | // for (int i = 0; i < length; i++) |
Muglug | 11:f19020fa18f1 | 76 | // trm[7+i] = data[i]; //Data |
Muglug | 11:f19020fa18f1 | 77 | // trm[7+length] = crc8(trm, tmp + 3); |
Muglug | 11:f19020fa18f1 | 78 | |
Muglug | 11:f19020fa18f1 | 79 | Serial xbee(tx, rx); |
Muglug | 11:f19020fa18f1 | 80 | for (int i = 0; i < tmp; i++) |
Muglug | 11:f19020fa18f1 | 81 | xbee.putc(trm[i]); //Transmition des donnees |
Muglug | 11:f19020fa18f1 | 82 | |
Muglug | 11:f19020fa18f1 | 83 | wait(0.01); |
Muglug | 11:f19020fa18f1 | 84 | delete trm; |
gusteibolt | 10:577e1fc4453e | 85 | } |