Reem M
/
http-server-example1
http
easy-connect/atmel-rf-driver/source/at24mac.h@0:a49e37a83a7a, 2019-04-15 (annotated)
- Committer:
- DuaaAbusharkh
- Date:
- Mon Apr 15 08:30:22 2019 +0000
- Revision:
- 0:a49e37a83a7a
blink
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DuaaAbusharkh | 0:a49e37a83a7a | 1 | /* |
DuaaAbusharkh | 0:a49e37a83a7a | 2 | * Copyright (c) 2014-2015 ARM Limited. All rights reserved. |
DuaaAbusharkh | 0:a49e37a83a7a | 3 | * SPDX-License-Identifier: Apache-2.0 |
DuaaAbusharkh | 0:a49e37a83a7a | 4 | * Licensed under the Apache License, Version 2.0 (the License); you may |
DuaaAbusharkh | 0:a49e37a83a7a | 5 | * not use this file except in compliance with the License. |
DuaaAbusharkh | 0:a49e37a83a7a | 6 | * You may obtain a copy of the License at |
DuaaAbusharkh | 0:a49e37a83a7a | 7 | * |
DuaaAbusharkh | 0:a49e37a83a7a | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
DuaaAbusharkh | 0:a49e37a83a7a | 9 | * |
DuaaAbusharkh | 0:a49e37a83a7a | 10 | * Unless required by applicable law or agreed to in writing, software |
DuaaAbusharkh | 0:a49e37a83a7a | 11 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
DuaaAbusharkh | 0:a49e37a83a7a | 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
DuaaAbusharkh | 0:a49e37a83a7a | 13 | * See the License for the specific language governing permissions and |
DuaaAbusharkh | 0:a49e37a83a7a | 14 | * limitations under the License. |
DuaaAbusharkh | 0:a49e37a83a7a | 15 | */ |
DuaaAbusharkh | 0:a49e37a83a7a | 16 | #ifndef AT24MAC_H |
DuaaAbusharkh | 0:a49e37a83a7a | 17 | #define AT24MAC_H |
DuaaAbusharkh | 0:a49e37a83a7a | 18 | |
DuaaAbusharkh | 0:a49e37a83a7a | 19 | #include "PinNames.h" |
DuaaAbusharkh | 0:a49e37a83a7a | 20 | #include "I2C.h" |
DuaaAbusharkh | 0:a49e37a83a7a | 21 | #include "drivers/DigitalInOut.h" |
DuaaAbusharkh | 0:a49e37a83a7a | 22 | #include "platform/mbed_wait_api.h" |
DuaaAbusharkh | 0:a49e37a83a7a | 23 | |
DuaaAbusharkh | 0:a49e37a83a7a | 24 | /* |
DuaaAbusharkh | 0:a49e37a83a7a | 25 | * AT24MAC drivers. |
DuaaAbusharkh | 0:a49e37a83a7a | 26 | * |
DuaaAbusharkh | 0:a49e37a83a7a | 27 | * This is a EEPROM chip designed to contain factory programmed read-only EUI-64 or EUI-48, |
DuaaAbusharkh | 0:a49e37a83a7a | 28 | * a 128bit serial number and some user programmable EEPROM. |
DuaaAbusharkh | 0:a49e37a83a7a | 29 | * |
DuaaAbusharkh | 0:a49e37a83a7a | 30 | * AT24MAC602 contains EUI-64, use read_eui64() |
DuaaAbusharkh | 0:a49e37a83a7a | 31 | * AT24MAC402 contains EUI-64, use read_eui48() |
DuaaAbusharkh | 0:a49e37a83a7a | 32 | * |
DuaaAbusharkh | 0:a49e37a83a7a | 33 | * NOTE: You cannot use both EUI-64 and EUI-48. Chip contains only one of those. |
DuaaAbusharkh | 0:a49e37a83a7a | 34 | */ |
DuaaAbusharkh | 0:a49e37a83a7a | 35 | |
DuaaAbusharkh | 0:a49e37a83a7a | 36 | class AT24Mac { |
DuaaAbusharkh | 0:a49e37a83a7a | 37 | public: |
DuaaAbusharkh | 0:a49e37a83a7a | 38 | AT24Mac(PinName sda, PinName scl); |
DuaaAbusharkh | 0:a49e37a83a7a | 39 | |
DuaaAbusharkh | 0:a49e37a83a7a | 40 | /** |
DuaaAbusharkh | 0:a49e37a83a7a | 41 | * Read unique serial number from chip. |
DuaaAbusharkh | 0:a49e37a83a7a | 42 | * \param buf pointer to write serial number to. Must have space for 16 bytes. |
DuaaAbusharkh | 0:a49e37a83a7a | 43 | * \return zero on success, negative number on failure |
DuaaAbusharkh | 0:a49e37a83a7a | 44 | */ |
DuaaAbusharkh | 0:a49e37a83a7a | 45 | int read_serial(void *buf); |
DuaaAbusharkh | 0:a49e37a83a7a | 46 | |
DuaaAbusharkh | 0:a49e37a83a7a | 47 | /** |
DuaaAbusharkh | 0:a49e37a83a7a | 48 | * Read EUI-64 from chip. |
DuaaAbusharkh | 0:a49e37a83a7a | 49 | * \param buf pointer to write EUI-64 to. Must have space for 8 bytes. |
DuaaAbusharkh | 0:a49e37a83a7a | 50 | * \return zero on success, negative number on failure |
DuaaAbusharkh | 0:a49e37a83a7a | 51 | */ |
DuaaAbusharkh | 0:a49e37a83a7a | 52 | int read_eui64(void *buf); |
DuaaAbusharkh | 0:a49e37a83a7a | 53 | |
DuaaAbusharkh | 0:a49e37a83a7a | 54 | /** |
DuaaAbusharkh | 0:a49e37a83a7a | 55 | * Read EUI-48 from chip. |
DuaaAbusharkh | 0:a49e37a83a7a | 56 | * \param buf pointer to write EUI-48 to. Must have space for 6 bytes. |
DuaaAbusharkh | 0:a49e37a83a7a | 57 | * \return zero on success, negative number on failure |
DuaaAbusharkh | 0:a49e37a83a7a | 58 | */ |
DuaaAbusharkh | 0:a49e37a83a7a | 59 | int read_eui48(void *buf); |
DuaaAbusharkh | 0:a49e37a83a7a | 60 | |
DuaaAbusharkh | 0:a49e37a83a7a | 61 | private: |
DuaaAbusharkh | 0:a49e37a83a7a | 62 | /* |
DuaaAbusharkh | 0:a49e37a83a7a | 63 | * Dummy class to allow us to reset I2C before the I2C constructor is called in |
DuaaAbusharkh | 0:a49e37a83a7a | 64 | * the initializer list of AT24Mac's constructor |
DuaaAbusharkh | 0:a49e37a83a7a | 65 | */ |
DuaaAbusharkh | 0:a49e37a83a7a | 66 | class I2CReset { |
DuaaAbusharkh | 0:a49e37a83a7a | 67 | public: |
DuaaAbusharkh | 0:a49e37a83a7a | 68 | I2CReset(PinName sda, PinName scl); |
DuaaAbusharkh | 0:a49e37a83a7a | 69 | }; |
DuaaAbusharkh | 0:a49e37a83a7a | 70 | I2CReset i2c_reset; |
DuaaAbusharkh | 0:a49e37a83a7a | 71 | mbed::I2C _i2c; |
DuaaAbusharkh | 0:a49e37a83a7a | 72 | }; |
DuaaAbusharkh | 0:a49e37a83a7a | 73 | |
DuaaAbusharkh | 0:a49e37a83a7a | 74 | #endif /* AT24MAC_H */ |