A board support package for the LPC4088 Display Module.

Dependencies:   DM_HttpServer DM_USBHost

Dependents:   lpc4088_displaymodule_emwin lpc4088_displaymodule_demo_sphere sampleGUI sampleEmptyGUI ... more

Fork of DMSupport by EmbeddedArtists AB

Committer:
embeddedartists
Date:
Mon Nov 04 14:32:50 2019 +0000
Revision:
42:bbfe299d4a0c
Parent:
34:fc366bab393f
More updates related to mbed OS 5

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 9:a33326afd686 1 /*
embeddedartists 9:a33326afd686 2 * Copyright 2014 Embedded Artists AB
embeddedartists 9:a33326afd686 3 *
embeddedartists 9:a33326afd686 4 * Licensed under the Apache License, Version 2.0 (the "License");
embeddedartists 9:a33326afd686 5 * you may not use this file except in compliance with the License.
embeddedartists 9:a33326afd686 6 * You may obtain a copy of the License at
embeddedartists 9:a33326afd686 7 *
embeddedartists 9:a33326afd686 8 * http://www.apache.org/licenses/LICENSE-2.0
embeddedartists 9:a33326afd686 9 *
embeddedartists 9:a33326afd686 10 * Unless required by applicable law or agreed to in writing, software
embeddedartists 9:a33326afd686 11 * distributed under the License is distributed on an "AS IS" BASIS,
embeddedartists 9:a33326afd686 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
embeddedartists 9:a33326afd686 13 * See the License for the specific language governing permissions and
embeddedartists 9:a33326afd686 14 * limitations under the License.
embeddedartists 9:a33326afd686 15 */
embeddedartists 9:a33326afd686 16
embeddedartists 0:6b68dac0d986 17 #include "RAMFileSystem.h"
embeddedartists 34:fc366bab393f 18 #include "DMBoard.h"
embeddedartists 34:fc366bab393f 19
embeddedartists 0:6b68dac0d986 20
embeddedartists 34:fc366bab393f 21 #define RAMFS_DBG(...)
embeddedartists 34:fc366bab393f 22 //#define RAMFS_DBG(...) DMBoard::instance().logger()->isr_printf(__VA_ARGS__)
embeddedartists 0:6b68dac0d986 23
embeddedartists 0:6b68dac0d986 24 #define SECTOR_SIZE 512
embeddedartists 0:6b68dac0d986 25
embeddedartists 0:6b68dac0d986 26 RAMFileSystem::RAMFileSystem(uint32_t addr, uint32_t size, const char* name) :
embeddedartists 0:6b68dac0d986 27 FATFileSystem(name) {
embeddedartists 0:6b68dac0d986 28 memStart = addr;
embeddedartists 0:6b68dac0d986 29 memSize = size - (size % SECTOR_SIZE);
embeddedartists 0:6b68dac0d986 30 status = 1; //1: disk not initialized
embeddedartists 0:6b68dac0d986 31 }
embeddedartists 0:6b68dac0d986 32
embeddedartists 0:6b68dac0d986 33 int RAMFileSystem::disk_initialize() {
embeddedartists 34:fc366bab393f 34 RAMFS_DBG("init RAM fs\n");
embeddedartists 0:6b68dac0d986 35 status = 0; //OK
embeddedartists 0:6b68dac0d986 36 return status;
embeddedartists 0:6b68dac0d986 37 }
embeddedartists 0:6b68dac0d986 38
embeddedartists 0:6b68dac0d986 39 int RAMFileSystem::disk_write(const uint8_t *buffer, uint64_t sector, uint8_t count) {
embeddedartists 34:fc366bab393f 40 RAMFS_DBG("write to sector(s) %llu..%llu\n", sector, sector+count);
embeddedartists 0:6b68dac0d986 41 if ((sector+count-1) >= disk_sectors()) {
embeddedartists 0:6b68dac0d986 42 return 1;
embeddedartists 0:6b68dac0d986 43 }
embeddedartists 0:6b68dac0d986 44
embeddedartists 0:6b68dac0d986 45 memcpy((uint8_t*)(memStart + SECTOR_SIZE*((uint32_t)sector)), buffer, SECTOR_SIZE*count);
embeddedartists 0:6b68dac0d986 46 return 0;
embeddedartists 0:6b68dac0d986 47 }
embeddedartists 0:6b68dac0d986 48
embeddedartists 0:6b68dac0d986 49 int RAMFileSystem::disk_read(uint8_t *buffer, uint64_t sector, uint8_t count) {
embeddedartists 34:fc366bab393f 50 RAMFS_DBG("read from sector(s) %llu..%llu\n", sector, sector+count);
embeddedartists 0:6b68dac0d986 51 if ((sector+count-1) >= disk_sectors()) {
embeddedartists 0:6b68dac0d986 52 return 1;
embeddedartists 0:6b68dac0d986 53 }
embeddedartists 0:6b68dac0d986 54
embeddedartists 0:6b68dac0d986 55 memcpy(buffer, (uint8_t*)(memStart + SECTOR_SIZE*((uint32_t)sector)), SECTOR_SIZE*count);
embeddedartists 0:6b68dac0d986 56 return 0;
embeddedartists 0:6b68dac0d986 57 }
embeddedartists 0:6b68dac0d986 58
embeddedartists 0:6b68dac0d986 59 int RAMFileSystem::disk_status() {
embeddedartists 34:fc366bab393f 60 RAMFS_DBG("disk status %d\n", status);
embeddedartists 0:6b68dac0d986 61 return status;
embeddedartists 0:6b68dac0d986 62 }
embeddedartists 0:6b68dac0d986 63 int RAMFileSystem::disk_sync() {
embeddedartists 0:6b68dac0d986 64 return 0;
embeddedartists 0:6b68dac0d986 65 }
embeddedartists 0:6b68dac0d986 66 uint64_t RAMFileSystem::disk_sectors() {
embeddedartists 34:fc366bab393f 67 RAMFS_DBG("returning fs has %u sectors\n", memSize/SECTOR_SIZE);
embeddedartists 0:6b68dac0d986 68 return memSize/SECTOR_SIZE;
embeddedartists 0:6b68dac0d986 69 }
embeddedartists 0:6b68dac0d986 70
embeddedartists 0:6b68dac0d986 71 uint64_t RAMFileSystem::disk_size() {
embeddedartists 0:6b68dac0d986 72 return memSize;
embeddedartists 0:6b68dac0d986 73 }