24FC1025

Dependents:   Hybrid_EEPROM

Committer:
Gaku0606
Date:
Mon Mar 13 07:03:05 2017 +0000
Revision:
0:d6cc210c71cc
??;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Gaku0606 0:d6cc210c71cc 1 /*********************************************************
Gaku0606 0:d6cc210c71cc 2 開発理念
Gaku0606 0:d6cc210c71cc 3 内部でバッファを持って,そのバッファに値を次々に入れていく
Gaku0606 0:d6cc210c71cc 4 関数を作って,送信関数をつかうと送信するようにする.
Gaku0606 0:d6cc210c71cc 5
Gaku0606 0:d6cc210c71cc 6 **********************************************************/
Gaku0606 0:d6cc210c71cc 7
Gaku0606 0:d6cc210c71cc 8 #ifndef _24FC1025_I2C_H_
Gaku0606 0:d6cc210c71cc 9 #define _24FC1025_I2C_H_
Gaku0606 0:d6cc210c71cc 10 #include "mbed.h"
Gaku0606 0:d6cc210c71cc 11 #define CONTROL_BYTE 0xA0
Gaku0606 0:d6cc210c71cc 12 #define SEGMENT0 0x00
Gaku0606 0:d6cc210c71cc 13 #define SEGMENT1 0x08//0b00001000
Gaku0606 0:d6cc210c71cc 14 /**
Gaku0606 0:d6cc210c71cc 15 * @bref Class to use 24FC1025 EEPROM
Gaku0606 0:d6cc210c71cc 16 */
Gaku0606 0:d6cc210c71cc 17 class EEPROM_24FC1025{
Gaku0606 0:d6cc210c71cc 18 public:
Gaku0606 0:d6cc210c71cc 19 /**
Gaku0606 0:d6cc210c71cc 20 * @bref EEPROM 24FC1025 Class's constructor
Gaku0606 0:d6cc210c71cc 21 * @param i2cBus user's using I2C bus constructor
Gaku0606 0:d6cc210c71cc 22 * @param A0 A0 pin connection, HIGH:1, LOW:0
Gaku0606 0:d6cc210c71cc 23 * @param A1 A1 pin connection, HIGH:1, LOW:0
Gaku0606 0:d6cc210c71cc 24 */
Gaku0606 0:d6cc210c71cc 25 EEPROM_24FC1025(I2C &i2cBus, int A0, int A1);
Gaku0606 0:d6cc210c71cc 26 private:
Gaku0606 0:d6cc210c71cc 27 I2C *_i2c;
Gaku0606 0:d6cc210c71cc 28 uint8_t uniqueAddr;
Gaku0606 0:d6cc210c71cc 29 int page_number;
Gaku0606 0:d6cc210c71cc 30 uint32_t size;
Gaku0606 0:d6cc210c71cc 31
Gaku0606 0:d6cc210c71cc 32 public:
Gaku0606 0:d6cc210c71cc 33 /**
Gaku0606 0:d6cc210c71cc 34 * @bref check whether address can use or not
Gaku0606 0:d6cc210c71cc 35 * @return OK:1 NG:0
Gaku0606 0:d6cc210c71cc 36 */
Gaku0606 0:d6cc210c71cc 37 int checkAddr(uint32_t addr);
Gaku0606 0:d6cc210c71cc 38
Gaku0606 0:d6cc210c71cc 39 /**
Gaku0606 0:d6cc210c71cc 40 * @bref read bytes
Gaku0606 0:d6cc210c71cc 41 * @return 0:success, -1:failure
Gaku0606 0:d6cc210c71cc 42 */
Gaku0606 0:d6cc210c71cc 43 int read(uint32_t regAddr, uint8_t *data, int length);
Gaku0606 0:d6cc210c71cc 44
Gaku0606 0:d6cc210c71cc 45 /**
Gaku0606 0:d6cc210c71cc 46 * @bref write 1byte
Gaku0606 0:d6cc210c71cc 47 *
Gaku0606 0:d6cc210c71cc 48 */
Gaku0606 0:d6cc210c71cc 49 int write(uint32_t regAddr, uint8_t data);
Gaku0606 0:d6cc210c71cc 50
Gaku0606 0:d6cc210c71cc 51 /**
Gaku0606 0:d6cc210c71cc 52 * @bref write 4 bytes
Gaku0606 0:d6cc210c71cc 53 */
Gaku0606 0:d6cc210c71cc 54 int write4Bytes(uint32_t regAddr, uint8_t *data);
Gaku0606 0:d6cc210c71cc 55
Gaku0606 0:d6cc210c71cc 56 /**
Gaku0606 0:d6cc210c71cc 57 *
Gaku0606 0:d6cc210c71cc 58 */
Gaku0606 0:d6cc210c71cc 59 int write8Bytes(uint32_t regAddr, uint8_t *data);
Gaku0606 0:d6cc210c71cc 60
Gaku0606 0:d6cc210c71cc 61 /**
Gaku0606 0:d6cc210c71cc 62 * @bref write 1 page
Gaku0606 0:d6cc210c71cc 63 */
Gaku0606 0:d6cc210c71cc 64 int write1Page(uint32_t pageNumber, uint8_t *data);
Gaku0606 0:d6cc210c71cc 65 };
Gaku0606 0:d6cc210c71cc 66
Gaku0606 0:d6cc210c71cc 67 #endif