diff options
author | Perry Hung <iperry@gmail.com> | 2011-03-10 00:04:58 -0500 |
---|---|---|
committer | Perry Hung <iperry@gmail.com> | 2011-03-11 00:45:33 -0500 |
commit | 9872b3975bd40c55652bb9dead5f54e2be9740d0 (patch) | |
tree | 0937d0416fc307d0de10e4c3e0916b03fb525872 /main.cpp | |
parent | 4651227fa9f7dece1dd24d2170db16c2e35dc04e (diff) | |
download | librambutan-9872b3975bd40c55652bb9dead5f54e2be9740d0.tar.gz librambutan-9872b3975bd40c55652bb9dead5f54e2be9740d0.zip |
Fix merge error and compile error.
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
@@ -6,19 +6,29 @@ static const uint8 slave_address = 0b1010001; -#define NR_ELEMENTS 64 +#define NR_ELEMENTS 4 uint8 buf0[NR_ELEMENTS + 2] = {0x0, 0x0}; uint8 buf1[] = {0x0, 0x0}; uint8 buf2[NR_ELEMENTS]; +i2c_msg msgs[3]; + +void toggle(void) { + digitalWrite(2, HIGH); + digitalWrite(2, LOW); +} + void setup() { - i2c_msg msgs[3]; uint32 i; pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(2, OUTPUT); + Serial2.begin(9600); + Serial2.println("Hello!"); + digitalWrite(2, LOW); - for (i = 0; i < sizeof buf0; i++) { - buf0[i + 2] = i & 0xFF; + for (i = 2; i < sizeof buf0; i++) { + buf0[i] = i - 2; } i2c_master_enable(I2C1, 0); @@ -31,6 +41,11 @@ void setup() { i2c_master_xfer(I2C1, msgs, 1); delay(5); +} + +void loop() { + delay(100); + toggleLED(); /* Write slave address to read */ msgs[1].addr = slave_address; msgs[1].flags = 0; @@ -45,11 +60,6 @@ void setup() { i2c_master_xfer(I2C1, msgs + 1, 2); } -void loop() { - toggleLED(); - delay(100); -} - // Force init to be called *first*, i.e. before static object allocation. // Otherwise, statically allocated object that need libmaple may fail. __attribute__(( constructor )) void premain() { |