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: ConfigFile FATFileSystem mbed
Revision 4:b62b40563944, committed 2015-05-24
- Comitter:
- va009039
- Date:
- Sun May 24 21:29:48 2015 +0900
- Parent:
- 3:9f526f0d9720
- Commit message:
- fix I2C
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbedAPI.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat May 23 09:14:47 2015 +0000
+++ b/main.cpp Sun May 24 21:29:48 2015 +0900
@@ -7,13 +7,17 @@
#include "IPS-Mmbed_bin.h"
#include "mbedAPI.h"
#include "ConfigFile.h"
+#include "SDFileSystem.h"
const char* CFG_FILE = "/local/ips.cfg";
#if defined(TARGET_MBED_LPC1768)
-LocalFileSystem local("local");
+#if defined(TOOLCHAIN_GCC)||defined(TOOLCHAIN_GCC_ARM)
+SDFileSystem local(MBED_SPI0, "local"); // mosi, miso, sclk, cs, name
#else
-#include "SDFileSystem.h"
+LocalFileSystem local("local");
+#endif
+#else
SDFileSystem local(D11, D12, D13, D4, "local"); // mosi, miso, sclk, cs, name
#endif
--- a/mbedAPI.cpp Sat May 23 09:14:47 2015 +0000
+++ b/mbedAPI.cpp Sun May 24 21:29:48 2015 +0900
@@ -204,23 +204,23 @@
void mbedAPI::code_method_I2C(int f, mbedObj& obj) {
if (f == mbed_read) {
- uint16_t a3 = ips.pull_ps(); // addr
- uint16_t a2 = ips.pull_ps(); // data length
- uint16_t a1 = ips.pull_ps(); // data pointer
- char buf[a2];
- reinterpret_cast<I2C*>(obj.p)->read(a3, buf, a1);
- for(int i = 0; i < a2; i++) {
- ips.pokeB(a1 + i, buf[i]);
+ uint16_t addr = ips.pull_ps();
+ uint16_t len = ips.pull_ps();
+ uint16_t ptr = ips.pull_ps();
+ char buf[len];
+ reinterpret_cast<I2C*>(obj.p)->read(addr, buf, len);
+ for(int i = 0; i < len; i++) {
+ ips.pokeB(ptr + i, buf[i]);
}
} else if (f == mbed_write) {
- uint16_t a3 = ips.pull_ps(); // addr
- uint16_t a2 = ips.pull_ps(); // data length
- uint16_t a1 = ips.pull_ps(); // data pointer
- char buf[a2];
- for(int i = 0; i < a2; i++) {
- buf[i] = ips.peekB(a1 + i);
+ uint16_t addr = ips.pull_ps();
+ uint16_t len = ips.pull_ps();
+ uint16_t ptr = ips.pull_ps();
+ char buf[len];
+ for(int i = 0; i < len; i++) {
+ buf[i] = ips.peekB(ptr + i);
}
- reinterpret_cast<I2C*>(obj.p)->write(a3, buf, a1);
+ reinterpret_cast<I2C*>(obj.p)->write(addr, buf, len);
} else {
error("%s %d", __LINE__, f);
}