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

Memory/BiosEEPROM.cpp

Committer:
embeddedartists
Date:
2019-11-04
Revision:
42:bbfe299d4a0c
Parent:
17:4ea2509445ac

File content as of revision 42:bbfe299d4a0c:

/*
 *  Copyright 2014 Embedded Artists AB
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

#include "mbed.h"
#include "BiosEEPROM.h"

/******************************************************************************
 * Defines and typedefs
 *****************************************************************************/

#define BIOS_EEPROM_ADDR      (0xAC)


/******************************************************************************
 * Local variables
 *****************************************************************************/

/******************************************************************************
 * Private Functions
 *****************************************************************************/


/******************************************************************************
 * Public Functions
 *****************************************************************************/

BiosEEPROM::BiosEEPROM() : _i2c(P0_27, P0_28)
{
    _i2c.frequency(400000);
}

bool BiosEEPROM::read(uint32_t address, char* data, uint32_t size)
{
    bool success = false;
    do {
        char buf[2];
        buf[0] = address >> 8;
        buf[1] = address & 0xff;
        
        if (_i2c.write(BIOS_EEPROM_ADDR, buf, 2) == 0) {
            if (_i2c.read(BIOS_EEPROM_ADDR, data, size) == 0) {
                success = true;
                break;
            }
        }
    } while(false);
    return success;
}