Added support for the WNC M14A2A Cellular LTE Data Module.
Dependencies: WNC14A2AInterface
at24mac.cpp
00001 /* 00002 * Copyright (c) 2016-2016 ARM Limited. All rights reserved. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * Licensed under the Apache License, Version 2.0 (the License); you may 00005 * 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, WITHOUT 00012 * 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 #include "at24mac.h" 00017 00018 /* Device addressing */ 00019 #define AT24MAC_EEPROM_ADDRESS (0x0A<<4) 00020 #define AT24MAC_RW_PROTECT_ADDRESS (0x06<<4) 00021 #define AT24MAC_SERIAL_ADDRESS (0x0B<<4) 00022 00023 /* Known memory blocks */ 00024 #define AT24MAC_SERIAL_OFFSET (0x80) 00025 #define AT24MAC_EUI64_OFFSET (0x98) 00026 #define AT24MAC_EUI48_OFFSET (0x9A) 00027 00028 #define SERIAL_LEN 16 00029 #define EUI64_LEN 8 00030 #define EUI48_LEN 6 00031 00032 AT24Mac::AT24Mac(PinName sda, PinName scl) : _i2c(sda, scl) 00033 { 00034 // Do nothing 00035 } 00036 00037 int AT24Mac::read_serial(void *buf) 00038 { 00039 char offset = AT24MAC_SERIAL_OFFSET; 00040 if (_i2c.write(AT24MAC_SERIAL_ADDRESS, &offset, 1, true)) 00041 return -1; //No ACK 00042 return _i2c.read(AT24MAC_SERIAL_ADDRESS, (char*)buf, SERIAL_LEN); 00043 } 00044 00045 int AT24Mac::read_eui64(void *buf) 00046 { 00047 char offset = AT24MAC_EUI64_OFFSET; 00048 if (_i2c.write(AT24MAC_SERIAL_ADDRESS, &offset, 1, true)) 00049 return -1; //No ACK 00050 return _i2c.read(AT24MAC_SERIAL_ADDRESS, (char*)buf, EUI64_LEN); 00051 } 00052 00053 int AT24Mac::read_eui48(void *buf) 00054 { 00055 char offset = AT24MAC_EUI48_OFFSET; 00056 if (_i2c.write(AT24MAC_SERIAL_ADDRESS, &offset, 1, true)) 00057 return -1; //No ACK 00058 return _i2c.read(AT24MAC_SERIAL_ADDRESS, (char*)buf, EUI48_LEN); 00059 }
Generated on Tue Jul 12 2022 19:09:03 by 1.7.2