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.

Dependencies:   mbed Buffer

Fork of DISCO-L072CZ-LRWAN1_LoRa_PingPong by ST

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:
  1. Click button at top-left
  2. Add Board
  3. 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
Committer:
wardm
Date:
Sat May 19 15:42:38 2018 +0000
Revision:
12:046346a16ff4
V1.0.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wardm 12:046346a16ff4 1 /*-----------------------------------------------------------------------*/
wardm 12:046346a16ff4 2 /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2014 */
wardm 12:046346a16ff4 3 /*-----------------------------------------------------------------------*/
wardm 12:046346a16ff4 4 /* If a working storage control module is available, it should be */
wardm 12:046346a16ff4 5 /* attached to the FatFs via a glue function rather than modifying it. */
wardm 12:046346a16ff4 6 /* This is an example of glue functions to attach various exsisting */
wardm 12:046346a16ff4 7 /* storage control modules to the FatFs module with a defined API. */
wardm 12:046346a16ff4 8 /*-----------------------------------------------------------------------*/
wardm 12:046346a16ff4 9
wardm 12:046346a16ff4 10 #include "diskio.h"
wardm 12:046346a16ff4 11 #include "mbed_debug.h"
wardm 12:046346a16ff4 12 #include "FATFileSystem.h"
wardm 12:046346a16ff4 13
wardm 12:046346a16ff4 14 using namespace mbed;
wardm 12:046346a16ff4 15
wardm 12:046346a16ff4 16 /*-----------------------------------------------------------------------*/
wardm 12:046346a16ff4 17 /* Get Drive Status */
wardm 12:046346a16ff4 18 /*-----------------------------------------------------------------------*/
wardm 12:046346a16ff4 19
wardm 12:046346a16ff4 20 DSTATUS disk_status (
wardm 12:046346a16ff4 21 BYTE pdrv /* Physical drive nmuber to identify the drive */
wardm 12:046346a16ff4 22 )
wardm 12:046346a16ff4 23 {
wardm 12:046346a16ff4 24 debug_if(FFS_DBG, "disk_status on pdrv [%d]\n", pdrv);
wardm 12:046346a16ff4 25 return (DSTATUS)FATFileSystem::_ffs[pdrv]->disk_status();
wardm 12:046346a16ff4 26 }
wardm 12:046346a16ff4 27
wardm 12:046346a16ff4 28 /*-----------------------------------------------------------------------*/
wardm 12:046346a16ff4 29 /* Inidialize a Drive */
wardm 12:046346a16ff4 30 /*-----------------------------------------------------------------------*/
wardm 12:046346a16ff4 31
wardm 12:046346a16ff4 32 DSTATUS disk_initialize (
wardm 12:046346a16ff4 33 BYTE pdrv /* Physical drive nmuber to identify the drive */
wardm 12:046346a16ff4 34 )
wardm 12:046346a16ff4 35 {
wardm 12:046346a16ff4 36 debug_if(FFS_DBG, "disk_initialize on pdrv [%d]\n", pdrv);
wardm 12:046346a16ff4 37 return (DSTATUS)FATFileSystem::_ffs[pdrv]->disk_initialize();
wardm 12:046346a16ff4 38 }
wardm 12:046346a16ff4 39
wardm 12:046346a16ff4 40 /*-----------------------------------------------------------------------*/
wardm 12:046346a16ff4 41 /* Read Sector(s) */
wardm 12:046346a16ff4 42 /*-----------------------------------------------------------------------*/
wardm 12:046346a16ff4 43
wardm 12:046346a16ff4 44 DRESULT disk_read (
wardm 12:046346a16ff4 45 BYTE pdrv, /* Physical drive nmuber to identify the drive */
wardm 12:046346a16ff4 46 BYTE* buff, /* Data buffer to store read data */
wardm 12:046346a16ff4 47 DWORD sector, /* Sector address in LBA */
wardm 12:046346a16ff4 48 UINT count /* Number of sectors to read */
wardm 12:046346a16ff4 49 )
wardm 12:046346a16ff4 50 {
wardm 12:046346a16ff4 51 debug_if(FFS_DBG, "disk_read(sector %d, count %d) on pdrv [%d]\n", sector, count, pdrv);
wardm 12:046346a16ff4 52 if (FATFileSystem::_ffs[pdrv]->disk_read((uint8_t*)buff, sector, count))
wardm 12:046346a16ff4 53 return RES_PARERR;
wardm 12:046346a16ff4 54 else
wardm 12:046346a16ff4 55 return RES_OK;
wardm 12:046346a16ff4 56 }
wardm 12:046346a16ff4 57
wardm 12:046346a16ff4 58 /*-----------------------------------------------------------------------*/
wardm 12:046346a16ff4 59 /* Write Sector(s) */
wardm 12:046346a16ff4 60 /*-----------------------------------------------------------------------*/
wardm 12:046346a16ff4 61
wardm 12:046346a16ff4 62 #if _USE_WRITE
wardm 12:046346a16ff4 63 DRESULT disk_write (
wardm 12:046346a16ff4 64 BYTE pdrv, /* Physical drive nmuber to identify the drive */
wardm 12:046346a16ff4 65 const BYTE* buff, /* Data to be written */
wardm 12:046346a16ff4 66 DWORD sector, /* Sector address in LBA */
wardm 12:046346a16ff4 67 UINT count /* Number of sectors to write */
wardm 12:046346a16ff4 68 )
wardm 12:046346a16ff4 69 {
wardm 12:046346a16ff4 70 debug_if(FFS_DBG, "disk_write(sector %d, count %d) on pdrv [%d]\n", sector, count, pdrv);
wardm 12:046346a16ff4 71 if (FATFileSystem::_ffs[pdrv]->disk_write((uint8_t*)buff, sector, count))
wardm 12:046346a16ff4 72 return RES_PARERR;
wardm 12:046346a16ff4 73 else
wardm 12:046346a16ff4 74 return RES_OK;
wardm 12:046346a16ff4 75 }
wardm 12:046346a16ff4 76 #endif
wardm 12:046346a16ff4 77
wardm 12:046346a16ff4 78 /*-----------------------------------------------------------------------*/
wardm 12:046346a16ff4 79 /* Miscellaneous Functions */
wardm 12:046346a16ff4 80 /*-----------------------------------------------------------------------*/
wardm 12:046346a16ff4 81
wardm 12:046346a16ff4 82 #if _USE_IOCTL
wardm 12:046346a16ff4 83 DRESULT disk_ioctl (
wardm 12:046346a16ff4 84 BYTE pdrv, /* Physical drive nmuber (0..) */
wardm 12:046346a16ff4 85 BYTE cmd, /* Control code */
wardm 12:046346a16ff4 86 void* buff /* Buffer to send/receive control data */
wardm 12:046346a16ff4 87 )
wardm 12:046346a16ff4 88 {
wardm 12:046346a16ff4 89 debug_if(FFS_DBG, "disk_ioctl(%d)\n", cmd);
wardm 12:046346a16ff4 90 switch(cmd) {
wardm 12:046346a16ff4 91 case CTRL_SYNC:
wardm 12:046346a16ff4 92 if(FATFileSystem::_ffs[pdrv] == NULL) {
wardm 12:046346a16ff4 93 return RES_NOTRDY;
wardm 12:046346a16ff4 94 } else if(FATFileSystem::_ffs[pdrv]->disk_sync()) {
wardm 12:046346a16ff4 95 return RES_ERROR;
wardm 12:046346a16ff4 96 }
wardm 12:046346a16ff4 97 return RES_OK;
wardm 12:046346a16ff4 98 case GET_SECTOR_COUNT:
wardm 12:046346a16ff4 99 if(FATFileSystem::_ffs[pdrv] == NULL) {
wardm 12:046346a16ff4 100 return RES_NOTRDY;
wardm 12:046346a16ff4 101 } else {
wardm 12:046346a16ff4 102 DWORD res = FATFileSystem::_ffs[pdrv]->disk_sectors();
wardm 12:046346a16ff4 103 if(res > 0) {
wardm 12:046346a16ff4 104 *((DWORD*)buff) = res; // minimum allowed
wardm 12:046346a16ff4 105 return RES_OK;
wardm 12:046346a16ff4 106 } else {
wardm 12:046346a16ff4 107 return RES_ERROR;
wardm 12:046346a16ff4 108 }
wardm 12:046346a16ff4 109 }
wardm 12:046346a16ff4 110 case GET_BLOCK_SIZE:
wardm 12:046346a16ff4 111 *((DWORD*)buff) = 1; // default when not known
wardm 12:046346a16ff4 112 return RES_OK;
wardm 12:046346a16ff4 113
wardm 12:046346a16ff4 114 }
wardm 12:046346a16ff4 115 return RES_PARERR;
wardm 12:046346a16ff4 116 }
wardm 12:046346a16ff4 117 #endif