IoT Alarm System with pushbutton for door, webpage for viewing status, and keypad for disabling alarm.

Dependencies:   PinDetect mbed wave_player FATFileSystem

Fork of ESP8266-WEB-Mbed-LPC1768-Controller by jim hamblen

Committer:
gholden3
Date:
Thu Mar 17 12:52:43 2016 +0000
Revision:
6:d5b6ab598544
Parent:
5:28e4c7315a20
fix library dependencies;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gholden3 5:28e4c7315a20 1 /* mbed Microcontroller Library
gholden3 5:28e4c7315a20 2 * Copyright (c) 2006-2012 ARM Limited
gholden3 5:28e4c7315a20 3 *
gholden3 5:28e4c7315a20 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
gholden3 5:28e4c7315a20 5 * of this software and associated documentation files (the "Software"), to deal
gholden3 5:28e4c7315a20 6 * in the Software without restriction, including without limitation the rights
gholden3 5:28e4c7315a20 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
gholden3 5:28e4c7315a20 8 * copies of the Software, and to permit persons to whom the Software is
gholden3 5:28e4c7315a20 9 * furnished to do so, subject to the following conditions:
gholden3 5:28e4c7315a20 10 *
gholden3 5:28e4c7315a20 11 * The above copyright notice and this permission notice shall be included in
gholden3 5:28e4c7315a20 12 * all copies or substantial portions of the Software.
gholden3 5:28e4c7315a20 13 *
gholden3 5:28e4c7315a20 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
gholden3 5:28e4c7315a20 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
gholden3 5:28e4c7315a20 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
gholden3 5:28e4c7315a20 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
gholden3 5:28e4c7315a20 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
gholden3 5:28e4c7315a20 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
gholden3 5:28e4c7315a20 20 * SOFTWARE.
gholden3 5:28e4c7315a20 21 */
gholden3 5:28e4c7315a20 22 #ifndef MBED_SDFILESYSTEM_H
gholden3 5:28e4c7315a20 23 #define MBED_SDFILESYSTEM_H
gholden3 5:28e4c7315a20 24
gholden3 5:28e4c7315a20 25 #include "mbed.h"
gholden3 5:28e4c7315a20 26 #include "FATFileSystem.h"
gholden3 5:28e4c7315a20 27 #include <stdint.h>
gholden3 5:28e4c7315a20 28
gholden3 5:28e4c7315a20 29 /** Access the filesystem on an SD Card using SPI
gholden3 5:28e4c7315a20 30 *
gholden3 5:28e4c7315a20 31 * @code
gholden3 5:28e4c7315a20 32 * #include "mbed.h"
gholden3 5:28e4c7315a20 33 * #include "SDFileSystem.h"
gholden3 5:28e4c7315a20 34 *
gholden3 5:28e4c7315a20 35 * SDFileSystem sd(p5, p6, p7, p12, "sd"); // mosi, miso, sclk, cs
gholden3 5:28e4c7315a20 36 *
gholden3 5:28e4c7315a20 37 * int main() {
gholden3 5:28e4c7315a20 38 * FILE *fp = fopen("/sd/myfile.txt", "w");
gholden3 5:28e4c7315a20 39 * fprintf(fp, "Hello World!\n");
gholden3 5:28e4c7315a20 40 * fclose(fp);
gholden3 5:28e4c7315a20 41 * }
gholden3 5:28e4c7315a20 42 */
gholden3 5:28e4c7315a20 43 class SDFileSystem : public FATFileSystem {
gholden3 5:28e4c7315a20 44 public:
gholden3 5:28e4c7315a20 45
gholden3 5:28e4c7315a20 46 /** Create the File System for accessing an SD Card using SPI
gholden3 5:28e4c7315a20 47 *
gholden3 5:28e4c7315a20 48 * @param mosi SPI mosi pin connected to SD Card
gholden3 5:28e4c7315a20 49 * @param miso SPI miso pin conencted to SD Card
gholden3 5:28e4c7315a20 50 * @param sclk SPI sclk pin connected to SD Card
gholden3 5:28e4c7315a20 51 * @param cs DigitalOut pin used as SD Card chip select
gholden3 5:28e4c7315a20 52 * @param name The name used to access the virtual filesystem
gholden3 5:28e4c7315a20 53 */
gholden3 5:28e4c7315a20 54 SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name);
gholden3 5:28e4c7315a20 55 virtual int disk_initialize();
gholden3 5:28e4c7315a20 56 virtual int disk_status();
gholden3 5:28e4c7315a20 57 virtual int disk_read(uint8_t * buffer, uint64_t block_number);
gholden3 5:28e4c7315a20 58 virtual int disk_write(const uint8_t * buffer, uint64_t block_number);
gholden3 5:28e4c7315a20 59 virtual int disk_sync();
gholden3 5:28e4c7315a20 60 virtual uint64_t disk_sectors();
gholden3 5:28e4c7315a20 61
gholden3 5:28e4c7315a20 62 protected:
gholden3 5:28e4c7315a20 63
gholden3 5:28e4c7315a20 64 int _cmd(int cmd, int arg);
gholden3 5:28e4c7315a20 65 int _cmdx(int cmd, int arg);
gholden3 5:28e4c7315a20 66 int _cmd8();
gholden3 5:28e4c7315a20 67 int _cmd58();
gholden3 5:28e4c7315a20 68 int initialise_card();
gholden3 5:28e4c7315a20 69 int initialise_card_v1();
gholden3 5:28e4c7315a20 70 int initialise_card_v2();
gholden3 5:28e4c7315a20 71
gholden3 5:28e4c7315a20 72 int _read(uint8_t * buffer, uint32_t length);
gholden3 5:28e4c7315a20 73 int _write(const uint8_t *buffer, uint32_t length);
gholden3 5:28e4c7315a20 74 uint64_t _sd_sectors();
gholden3 5:28e4c7315a20 75 uint64_t _sectors;
gholden3 5:28e4c7315a20 76
gholden3 5:28e4c7315a20 77 SPI _spi;
gholden3 5:28e4c7315a20 78 DigitalOut _cs;
gholden3 5:28e4c7315a20 79 int cdv;
gholden3 5:28e4c7315a20 80 };
gholden3 5:28e4c7315a20 81
gholden3 5:28e4c7315a20 82 #endif