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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers <title>BiosEEPROM.cpp Source File</title>

BiosEEPROM.cpp

00001 /*
00002  *  Copyright 2014 Embedded Artists AB
00003  *
00004  *  Licensed under the Apache License, Version 2.0 (the "License");
00005  *  you may not use this file except in compliance with the License.
00006  *  You may obtain a copy of the License at
00007  *
00008  *    http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  *  Unless required by applicable law or agreed to in writing, software
00011  *  distributed under the License is distributed on an "AS IS" BASIS,
00012  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *  See the License for the specific language governing permissions and
00014  *  limitations under the License.
00015  */
00016 
00017 #include "mbed.h"
00018 #include "BiosEEPROM.h"
00019 
00020 /******************************************************************************
00021  * Defines and typedefs
00022  *****************************************************************************/
00023 
00024 #define BIOS_EEPROM_ADDR      (0xAC)
00025 
00026 
00027 /******************************************************************************
00028  * Local variables
00029  *****************************************************************************/
00030 
00031 /******************************************************************************
00032  * Private Functions
00033  *****************************************************************************/
00034 
00035 
00036 /******************************************************************************
00037  * Public Functions
00038  *****************************************************************************/
00039 
00040 BiosEEPROM::BiosEEPROM() : _i2c(P0_27, P0_28)
00041 {
00042     _i2c.frequency(400000);
00043 }
00044 
00045 bool BiosEEPROM::read(uint32_t address, char* data, uint32_t size)
00046 {
00047     bool success = false;
00048     do {
00049         char buf[2];
00050         buf[0] = address >> 8;
00051         buf[1] = address & 0xff;
00052         
00053         if (_i2c.write(BIOS_EEPROM_ADDR, buf, 2) == 0) {
00054             if (_i2c.read(BIOS_EEPROM_ADDR, data, size) == 0) {
00055                 success = true;
00056                 break;
00057             }
00058         }
00059     } while(false);
00060     return success;
00061 }