Dependencies: DM_FATFileSystem EthernetInterface HTTPClient mbed-rtos mbed-src
Fork of DMSupport by
Diff: Memory/BiosEEPROM.cpp
- Revision:
- 17:4ea2509445ac
diff -r 80f1723b15e2 -r 4ea2509445ac Memory/BiosEEPROM.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Memory/BiosEEPROM.cpp Wed Jan 07 14:02:39 2015 +0100 @@ -0,0 +1,61 @@ +/* + * 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; +}