// eDisk.h // Runs on either MSP432 or TM4C123 // Mid-level implementation of the solid state disk device // driver. Below this is the low level, hardware-specific // flash memory interface. Above this is the high level // file system implementation. // Daniel and Jonathan Valvano // August 29, 2016 /* This example accompanies the books "Embedded Systems: Real Time Interfacing to ARM Cortex M Microcontrollers", ISBN: 978-1463590154, Jonathan Valvano, copyright (c) 2016 "Embedded Systems: Real-Time Operating Systems for ARM Cortex-M Microcontrollers", ISBN: 978-1466468863, Jonathan Valvano, copyright (c) 2016 "Embedded Systems: Introduction to the MSP432 Microcontroller", ISBN: 978-1512185676, Jonathan Valvano, copyright (c) 2016 "Embedded Systems: Real-Time Interfacing to the MSP432 Microcontroller", ISBN: 978-1514676585, Jonathan Valvano, copyright (c) 2016 Copyright 2016 by Jonathan W. Valvano, valvano@mail.utexas.edu You may use, edit, run or distribute this file as long as the above copyright notice remains THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. VALVANO SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. For more information about my classes, my research, and my books, see http://users.ece.utexas.edu/~valvano/ */ #define EDISK_ADDR_MIN 0x00020000 // Flash Bank1 minimum address #define EDISK_ADDR_MAX 0x0003FFFF // Flash Bank1 maximum address enum DRESULT{ RES_OK = 0, // Successful RES_ERROR = 1, // R/W Error RES_WRPRT = 2, // Write Protected RES_NOTRDY = 3, // Not Ready RES_PARERR = 4 // Invalid Parameter }; //*************** eDisk_Init *********** // Initialize the interface between microcontroller and disk // Inputs: drive number (only drive 0 is supported) // Outputs: status // RES_OK 0: Successful // RES_ERROR 1: Drive not initialized enum DRESULT eDisk_Init(uint32_t drive); //*************** eDisk_ReadSector *********** // Read 1 sector of 512 bytes from the disk, data goes to RAM // Inputs: pointer to an empty RAM buffer // sector number of disk to read: 0,1,2,...255 // Outputs: result // RES_OK 0: Successful // RES_ERROR 1: R/W Error // RES_WRPRT 2: Write Protected // RES_NOTRDY 3: Not Ready // RES_PARERR 4: Invalid Parameter enum DRESULT eDisk_ReadSector( uint8_t *buff, // Pointer to a RAM buffer into which to store uint8_t sector); // sector number to read from //*************** eDisk_WriteSector *********** // Write 1 sector of 512 bytes of data to the disk, data comes from RAM // Inputs: pointer to RAM buffer with information // sector number of disk to write: 0,1,2,...,255 // Outputs: result // RES_OK 0: Successful // RES_ERROR 1: R/W Error // RES_WRPRT 2: Write Protected // RES_NOTRDY 3: Not Ready // RES_PARERR 4: Invalid Parameter enum DRESULT eDisk_WriteSector( const uint8_t *buff, // Pointer to the data to be written uint8_t sector); // sector number //*************** eDisk_Format *********** // Erase all files and all data by resetting the flash to all 1's // Inputs: none // Outputs: result // RES_OK 0: Successful // RES_ERROR 1: R/W Error // RES_WRPRT 2: Write Protected // RES_NOTRDY 3: Not Ready // RES_PARERR 4: Invalid Parameter enum DRESULT eDisk_Format(void);