This is code is part of a Technion course project in advanced IoT, implementing a device to receive and present sensors data from a Formula racing car built by students at Technion - Israel Institute of Technology.
Fork of DISCO-L072CZ-LRWAN1_LoRa_PingPong by
This is code is part of a Technion course project in advanced IoT, implementing a device to receive sensors data from another L072CZ-LRWAN1 installed on a Formula racing car (built by students at Technion - Israel Institute of Technology), and sends it to a GUI presenting the data (GUI project: github.com/ward-mattar/TechnionFormulaGUI).
How to install
- Create an account on Mbed: https://os.mbed.com/account/signup/
- Import project into Compiler
- In the Program Workspace select "Formula_Nucleo_Receiver"
- Select a Platform like so:
- Click button at top-left
- Add Board
- Search "NUCLEO F103RB" and then "Add to your Mbed Compiler"
- Finally click "Compile", if the build was successful, the binary would download automatically
- To install it on device simply plug it in to a PC, open device drive and drag then drop binary file in it
SDCard/SDFileSystem.h@12:046346a16ff4, 2018-05-19 (annotated)
- Committer:
- wardm
- Date:
- Sat May 19 15:42:38 2018 +0000
- Revision:
- 12:046346a16ff4
V1.0.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wardm | 12:046346a16ff4 | 1 | /* mbed Microcontroller Library - SDFileSystem |
wardm | 12:046346a16ff4 | 2 | * Copyright (c) 2008-2009, sford |
wardm | 12:046346a16ff4 | 3 | */ |
wardm | 12:046346a16ff4 | 4 | |
wardm | 12:046346a16ff4 | 5 | // VERY DRAFT CODE!!! |
wardm | 12:046346a16ff4 | 6 | |
wardm | 12:046346a16ff4 | 7 | #ifndef SDFILESYSTEM_H |
wardm | 12:046346a16ff4 | 8 | #define SDFILESYSTEM_H |
wardm | 12:046346a16ff4 | 9 | #include <cstdint> |
wardm | 12:046346a16ff4 | 10 | #include "mbed.h" |
wardm | 12:046346a16ff4 | 11 | #include "FATFileSystem.h" |
wardm | 12:046346a16ff4 | 12 | |
wardm | 12:046346a16ff4 | 13 | /* Class: SDFileSystem |
wardm | 12:046346a16ff4 | 14 | * Access the filesystem on an SD Card using SPI |
wardm | 12:046346a16ff4 | 15 | * |
wardm | 12:046346a16ff4 | 16 | * Example: |
wardm | 12:046346a16ff4 | 17 | * > SDFileSystem sd(p5, p6, p7, p12, "sd"); |
wardm | 12:046346a16ff4 | 18 | * > |
wardm | 12:046346a16ff4 | 19 | * > int main() { |
wardm | 12:046346a16ff4 | 20 | * > FILE *fp = fopen("/sd/myfile.txt", "w"); |
wardm | 12:046346a16ff4 | 21 | * > fprintf(fp, "Hello World!\n"); |
wardm | 12:046346a16ff4 | 22 | * > fclose(fp); |
wardm | 12:046346a16ff4 | 23 | * > } |
wardm | 12:046346a16ff4 | 24 | */ |
wardm | 12:046346a16ff4 | 25 | class SDFileSystem : public FATFileSystem { |
wardm | 12:046346a16ff4 | 26 | public: |
wardm | 12:046346a16ff4 | 27 | |
wardm | 12:046346a16ff4 | 28 | /* Constructor: SDFileSystem |
wardm | 12:046346a16ff4 | 29 | * Create the File System for accessing an SD Card using SPI |
wardm | 12:046346a16ff4 | 30 | * |
wardm | 12:046346a16ff4 | 31 | * Variables: |
wardm | 12:046346a16ff4 | 32 | * mosi - SPI mosi pin connected to SD Card |
wardm | 12:046346a16ff4 | 33 | * miso - SPI miso pin conencted to SD Card |
wardm | 12:046346a16ff4 | 34 | * sclk - SPI sclk pin connected to SD Card |
wardm | 12:046346a16ff4 | 35 | * cs - DigitalOut pin used as SD Card chip select |
wardm | 12:046346a16ff4 | 36 | * name - The name used to access the filesystem |
wardm | 12:046346a16ff4 | 37 | */ |
wardm | 12:046346a16ff4 | 38 | SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name); |
wardm | 12:046346a16ff4 | 39 | virtual int disk_initialize(); |
wardm | 12:046346a16ff4 | 40 | virtual int disk_write(const char *buffer, int block_number); |
wardm | 12:046346a16ff4 | 41 | virtual int disk_read(char *buffer, int block_number); |
wardm | 12:046346a16ff4 | 42 | virtual int disk_status(); |
wardm | 12:046346a16ff4 | 43 | virtual int disk_sync(); |
wardm | 12:046346a16ff4 | 44 | virtual std::uint32_t disk_sectors(); |
wardm | 12:046346a16ff4 | 45 | |
wardm | 12:046346a16ff4 | 46 | protected: |
wardm | 12:046346a16ff4 | 47 | |
wardm | 12:046346a16ff4 | 48 | int _cmd(int cmd, int arg); |
wardm | 12:046346a16ff4 | 49 | int _cmdx(int cmd, int arg); |
wardm | 12:046346a16ff4 | 50 | int _cmd8(); |
wardm | 12:046346a16ff4 | 51 | int _cmd58(); |
wardm | 12:046346a16ff4 | 52 | int initialise_card(); |
wardm | 12:046346a16ff4 | 53 | int initialise_card_v1(); |
wardm | 12:046346a16ff4 | 54 | int initialise_card_v2(); |
wardm | 12:046346a16ff4 | 55 | |
wardm | 12:046346a16ff4 | 56 | |
wardm | 12:046346a16ff4 | 57 | int _read(char *buffer, int length); |
wardm | 12:046346a16ff4 | 58 | int _write(const char *buffer, int length); |
wardm | 12:046346a16ff4 | 59 | int _sd_sectors(); |
wardm | 12:046346a16ff4 | 60 | int _sectors; |
wardm | 12:046346a16ff4 | 61 | |
wardm | 12:046346a16ff4 | 62 | SPI _spi; |
wardm | 12:046346a16ff4 | 63 | DigitalOut _cs; |
wardm | 12:046346a16ff4 | 64 | }; |
wardm | 12:046346a16ff4 | 65 | |
wardm | 12:046346a16ff4 | 66 | #endif |