This repo contains the libraries of Mbed for LPC1549 with following changes: - IAP commands. - EEPROM write and read. - UART write and read (public) - CAN can_s -> LPC_C_CAN0_Type *can

Committer:
gmatarrubia
Date:
Tue Apr 14 15:00:13 2015 +0200
Revision:
0:820a69dfd200
Initial repo. IAP commands, EEPROM write/read, UART write/read, CAN

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gmatarrubia 0:820a69dfd200 1 /* mbed Microcontroller Library
gmatarrubia 0:820a69dfd200 2 * Copyright (c) 2006-2013 ARM Limited
gmatarrubia 0:820a69dfd200 3 *
gmatarrubia 0:820a69dfd200 4 * Licensed under the Apache License, Version 2.0 (the "License");
gmatarrubia 0:820a69dfd200 5 * you may not use this file except in compliance with the License.
gmatarrubia 0:820a69dfd200 6 * You may obtain a copy of the License at
gmatarrubia 0:820a69dfd200 7 *
gmatarrubia 0:820a69dfd200 8 * http://www.apache.org/licenses/LICENSE-2.0
gmatarrubia 0:820a69dfd200 9 *
gmatarrubia 0:820a69dfd200 10 * Unless required by applicable law or agreed to in writing, software
gmatarrubia 0:820a69dfd200 11 * distributed under the License is distributed on an "AS IS" BASIS,
gmatarrubia 0:820a69dfd200 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
gmatarrubia 0:820a69dfd200 13 * See the License for the specific language governing permissions and
gmatarrubia 0:820a69dfd200 14 * limitations under the License.
gmatarrubia 0:820a69dfd200 15 */
gmatarrubia 0:820a69dfd200 16 #ifndef MBED_LOCALFILESYSTEM_H
gmatarrubia 0:820a69dfd200 17 #define MBED_LOCALFILESYSTEM_H
gmatarrubia 0:820a69dfd200 18
gmatarrubia 0:820a69dfd200 19 #include "platform.h"
gmatarrubia 0:820a69dfd200 20
gmatarrubia 0:820a69dfd200 21 #if DEVICE_LOCALFILESYSTEM
gmatarrubia 0:820a69dfd200 22
gmatarrubia 0:820a69dfd200 23 #include "FileSystemLike.h"
gmatarrubia 0:820a69dfd200 24
gmatarrubia 0:820a69dfd200 25 namespace mbed {
gmatarrubia 0:820a69dfd200 26
gmatarrubia 0:820a69dfd200 27 FILEHANDLE local_file_open(const char* name, int flags);
gmatarrubia 0:820a69dfd200 28
gmatarrubia 0:820a69dfd200 29 class LocalFileHandle : public FileHandle {
gmatarrubia 0:820a69dfd200 30
gmatarrubia 0:820a69dfd200 31 public:
gmatarrubia 0:820a69dfd200 32 LocalFileHandle(FILEHANDLE fh);
gmatarrubia 0:820a69dfd200 33
gmatarrubia 0:820a69dfd200 34 virtual int close();
gmatarrubia 0:820a69dfd200 35
gmatarrubia 0:820a69dfd200 36 virtual ssize_t write(const void *buffer, size_t length);
gmatarrubia 0:820a69dfd200 37
gmatarrubia 0:820a69dfd200 38 virtual ssize_t read(void *buffer, size_t length);
gmatarrubia 0:820a69dfd200 39
gmatarrubia 0:820a69dfd200 40 virtual int isatty();
gmatarrubia 0:820a69dfd200 41
gmatarrubia 0:820a69dfd200 42 virtual off_t lseek(off_t position, int whence);
gmatarrubia 0:820a69dfd200 43
gmatarrubia 0:820a69dfd200 44 virtual int fsync();
gmatarrubia 0:820a69dfd200 45
gmatarrubia 0:820a69dfd200 46 virtual off_t flen();
gmatarrubia 0:820a69dfd200 47
gmatarrubia 0:820a69dfd200 48 protected:
gmatarrubia 0:820a69dfd200 49 FILEHANDLE _fh;
gmatarrubia 0:820a69dfd200 50 int pos;
gmatarrubia 0:820a69dfd200 51 };
gmatarrubia 0:820a69dfd200 52
gmatarrubia 0:820a69dfd200 53 /** A filesystem for accessing the local mbed Microcontroller USB disk drive
gmatarrubia 0:820a69dfd200 54 *
gmatarrubia 0:820a69dfd200 55 * This allows programs to read and write files on the same disk drive that is used to program the
gmatarrubia 0:820a69dfd200 56 * mbed Microcontroller. Once created, the standard C file access functions are used to open,
gmatarrubia 0:820a69dfd200 57 * read and write files.
gmatarrubia 0:820a69dfd200 58 *
gmatarrubia 0:820a69dfd200 59 * Example:
gmatarrubia 0:820a69dfd200 60 * @code
gmatarrubia 0:820a69dfd200 61 * #include "mbed.h"
gmatarrubia 0:820a69dfd200 62 *
gmatarrubia 0:820a69dfd200 63 * LocalFileSystem local("local"); // Create the local filesystem under the name "local"
gmatarrubia 0:820a69dfd200 64 *
gmatarrubia 0:820a69dfd200 65 * int main() {
gmatarrubia 0:820a69dfd200 66 * FILE *fp = fopen("/local/out.txt", "w"); // Open "out.txt" on the local file system for writing
gmatarrubia 0:820a69dfd200 67 * fprintf(fp, "Hello World!");
gmatarrubia 0:820a69dfd200 68 * fclose(fp);
gmatarrubia 0:820a69dfd200 69 * remove("/local/out.txt"); // Removes the file "out.txt" from the local file system
gmatarrubia 0:820a69dfd200 70 *
gmatarrubia 0:820a69dfd200 71 * DIR *d = opendir("/local"); // Opens the root directory of the local file system
gmatarrubia 0:820a69dfd200 72 * struct dirent *p;
gmatarrubia 0:820a69dfd200 73 * while((p = readdir(d)) != NULL) { // Print the names of the files in the local file system
gmatarrubia 0:820a69dfd200 74 * printf("%s\n", p->d_name); // to stdout.
gmatarrubia 0:820a69dfd200 75 * }
gmatarrubia 0:820a69dfd200 76 * closedir(d);
gmatarrubia 0:820a69dfd200 77 * }
gmatarrubia 0:820a69dfd200 78 * @endcode
gmatarrubia 0:820a69dfd200 79 *
gmatarrubia 0:820a69dfd200 80 * @note
gmatarrubia 0:820a69dfd200 81 * If the microcontroller program makes an access to the local drive, it will be marked as "removed"
gmatarrubia 0:820a69dfd200 82 * on the Host computer. This means it is no longer accessible from the Host Computer.
gmatarrubia 0:820a69dfd200 83 *
gmatarrubia 0:820a69dfd200 84 * The drive will only re-appear when the microcontroller program exists. Note that if the program does
gmatarrubia 0:820a69dfd200 85 * not exit, you will need to hold down reset on the mbed Microcontroller to be able to see the drive again!
gmatarrubia 0:820a69dfd200 86 */
gmatarrubia 0:820a69dfd200 87 class LocalFileSystem : public FileSystemLike {
gmatarrubia 0:820a69dfd200 88
gmatarrubia 0:820a69dfd200 89 public:
gmatarrubia 0:820a69dfd200 90 LocalFileSystem(const char* n) : FileSystemLike(n) {
gmatarrubia 0:820a69dfd200 91
gmatarrubia 0:820a69dfd200 92 }
gmatarrubia 0:820a69dfd200 93
gmatarrubia 0:820a69dfd200 94 virtual FileHandle *open(const char* name, int flags);
gmatarrubia 0:820a69dfd200 95 virtual int remove(const char *filename);
gmatarrubia 0:820a69dfd200 96 virtual DirHandle *opendir(const char *name);
gmatarrubia 0:820a69dfd200 97 };
gmatarrubia 0:820a69dfd200 98
gmatarrubia 0:820a69dfd200 99 } // namespace mbed
gmatarrubia 0:820a69dfd200 100
gmatarrubia 0:820a69dfd200 101 #endif
gmatarrubia 0:820a69dfd200 102
gmatarrubia 0:820a69dfd200 103 #endif