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.
Dependencies: BitAccess GVD mbed
Revision 0:0a51d4f7c853, committed 2016-08-04
- Comitter:
- moneneholic
- Date:
- Thu Aug 04 00:47:15 2016 +0000
- Commit message:
- FirstVer
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BitAccess.lib Thu Aug 04 00:47:15 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/moneneholic/code/BitAccess/#0ee1a4a231ac
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GVD.lib Thu Aug 04 00:47:15 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/moneneholic/code/GVD/#a5d388a0355c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Aug 04 00:47:15 2016 +0000 @@ -0,0 +1,43 @@ +#include "mbed.h" +#include "GVD.hpp" +#include "BitAccess.h" + +char read_address() { + const size_t din_num = 4; + DigitalIn din[] = { + DigitalIn(dp26), + DigitalIn(dp25), + DigitalIn(dp18), + DigitalIn(dp17) + }; + + char address = 0; + size_t address_offset = 0x08 << 1; + for (size_t i = 0; i < din_num; ++i) { + address |= din[i].read() << (i + 1); + } + return address + address_offset; +} + +int main(){ + I2CSlave i2c(dp5, dp27); + i2c.address(read_address()); + GVD vd(dp11,dp2,dp9,dp6,dp4,dp10,dp1,dp13); + BitAccess byte; + while (true){ + char buf; + switch (i2c.receive()){ + case I2CSlave::ReadAddressed: + break; + case I2CSlave::WriteGeneral: + break; + case I2CSlave::WriteAddressed: + i2c.read(&buf, 1); + byte.setByte(buf); + vd.write(byte.b0,byte.b1,byte.b2,byte.b3,byte.b4,byte.b5,byte.b6,byte.b7); + break; + case I2CSlave::NoData: + break; + } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Aug 04 00:47:15 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/f9eeca106725 \ No newline at end of file