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:
17:4ea2509445ac
More updates related to mbed OS 5

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 17:4ea2509445ac 1 /*
embeddedartists 17:4ea2509445ac 2 * Copyright 2014 Embedded Artists AB
embeddedartists 17:4ea2509445ac 3 *
embeddedartists 17:4ea2509445ac 4 * Licensed under the Apache License, Version 2.0 (the "License");
embeddedartists 17:4ea2509445ac 5 * you may not use this file except in compliance with the License.
embeddedartists 17:4ea2509445ac 6 * You may obtain a copy of the License at
embeddedartists 17:4ea2509445ac 7 *
embeddedartists 17:4ea2509445ac 8 * http://www.apache.org/licenses/LICENSE-2.0
embeddedartists 17:4ea2509445ac 9 *
embeddedartists 17:4ea2509445ac 10 * Unless required by applicable law or agreed to in writing, software
embeddedartists 17:4ea2509445ac 11 * distributed under the License is distributed on an "AS IS" BASIS,
embeddedartists 17:4ea2509445ac 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
embeddedartists 17:4ea2509445ac 13 * See the License for the specific language governing permissions and
embeddedartists 17:4ea2509445ac 14 * limitations under the License.
embeddedartists 17:4ea2509445ac 15 */
embeddedartists 17:4ea2509445ac 16
embeddedartists 17:4ea2509445ac 17 #include "mbed.h"
embeddedartists 17:4ea2509445ac 18 #include "BiosEEPROM.h"
embeddedartists 17:4ea2509445ac 19
embeddedartists 17:4ea2509445ac 20 /******************************************************************************
embeddedartists 17:4ea2509445ac 21 * Defines and typedefs
embeddedartists 17:4ea2509445ac 22 *****************************************************************************/
embeddedartists 17:4ea2509445ac 23
embeddedartists 17:4ea2509445ac 24 #define BIOS_EEPROM_ADDR (0xAC)
embeddedartists 17:4ea2509445ac 25
embeddedartists 17:4ea2509445ac 26
embeddedartists 17:4ea2509445ac 27 /******************************************************************************
embeddedartists 17:4ea2509445ac 28 * Local variables
embeddedartists 17:4ea2509445ac 29 *****************************************************************************/
embeddedartists 17:4ea2509445ac 30
embeddedartists 17:4ea2509445ac 31 /******************************************************************************
embeddedartists 17:4ea2509445ac 32 * Private Functions
embeddedartists 17:4ea2509445ac 33 *****************************************************************************/
embeddedartists 17:4ea2509445ac 34
embeddedartists 17:4ea2509445ac 35
embeddedartists 17:4ea2509445ac 36 /******************************************************************************
embeddedartists 17:4ea2509445ac 37 * Public Functions
embeddedartists 17:4ea2509445ac 38 *****************************************************************************/
embeddedartists 17:4ea2509445ac 39
embeddedartists 17:4ea2509445ac 40 BiosEEPROM::BiosEEPROM() : _i2c(P0_27, P0_28)
embeddedartists 17:4ea2509445ac 41 {
embeddedartists 17:4ea2509445ac 42 _i2c.frequency(400000);
embeddedartists 17:4ea2509445ac 43 }
embeddedartists 17:4ea2509445ac 44
embeddedartists 17:4ea2509445ac 45 bool BiosEEPROM::read(uint32_t address, char* data, uint32_t size)
embeddedartists 17:4ea2509445ac 46 {
embeddedartists 17:4ea2509445ac 47 bool success = false;
embeddedartists 17:4ea2509445ac 48 do {
embeddedartists 17:4ea2509445ac 49 char buf[2];
embeddedartists 17:4ea2509445ac 50 buf[0] = address >> 8;
embeddedartists 17:4ea2509445ac 51 buf[1] = address & 0xff;
embeddedartists 17:4ea2509445ac 52
embeddedartists 17:4ea2509445ac 53 if (_i2c.write(BIOS_EEPROM_ADDR, buf, 2) == 0) {
embeddedartists 17:4ea2509445ac 54 if (_i2c.read(BIOS_EEPROM_ADDR, data, size) == 0) {
embeddedartists 17:4ea2509445ac 55 success = true;
embeddedartists 17:4ea2509445ac 56 break;
embeddedartists 17:4ea2509445ac 57 }
embeddedartists 17:4ea2509445ac 58 }
embeddedartists 17:4ea2509445ac 59 } while(false);
embeddedartists 17:4ea2509445ac 60 return success;
embeddedartists 17:4ea2509445ac 61 }