Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: eeprom_test eeprom_test MCP3204_test
Revision 0:8047024a08c2, committed 2019-11-20
- Comitter:
- sashida_h
- Date:
- Wed Nov 20 03:55:16 2019 +0000
- Child:
- 1:41cf2e3bb7f3
- Commit message:
- initial commit; ;
Changed in this revision
| 24LC1025.cpp | Show annotated file Show diff for this revision Revisions of this file |
| 24LC1025.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/24LC1025.cpp Wed Nov 20 03:55:16 2019 +0000
@@ -0,0 +1,37 @@
+#include "24LC1025.h"
+// 24LC64 の書き込み、読み込みテスト
+
+//I2C i2c(p9, p10); //p9: data, p10: clock
+
+I2CEEprom::I2CEEprom():I2C(PB_7,PB_6)
+{
+ addr = 0xA0;
+}
+I2CEEprom::I2CEEprom(PinName data, PinName clock, int address):I2C(data, clock)
+{
+ addr = address;
+}
+
+void I2CEEprom::write(unsigned int address, unsigned char data)
+{
+ start();
+ ((I2C*)this)->write(addr);
+ ((I2C*)this)->write((address>>8));
+ ((I2C*)this)->write(address);
+ ((I2C*)this)->write(data);
+ stop();
+}
+
+unsigned char I2CEEprom::read(unsigned int address)
+{
+ unsigned char x;
+ start();
+ ((I2C*)this)->write(addr);
+ ((I2C*)this)->write((address>>8));
+ ((I2C*)this)->write(address);
+ start();
+ ((I2C*)this)->write(addr+1);
+ x = ((I2C*)this)->read(0);
+ stop();
+ return x;
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/24LC1025.h Wed Nov 20 03:55:16 2019 +0000
@@ -0,0 +1,13 @@
+#include "mbed.h"
+// 24LC64 の書き込み、読み込みテスト
+
+class I2CEEprom : public I2C
+{
+private:
+ unsigned char addr;
+public:
+ I2CEEprom();
+ I2CEEprom(PinName data, PinName clock, int address);
+ void write(unsigned int address, unsigned char data);
+ unsigned char read(unsigned int address);
+};
\ No newline at end of file