2016年7月28日 星期四

mt7688 duo i2c study



首先要先了解7688duo 的架構





















in arduino  ->   Serial1

in   mpu    -> /dev/ttyS0


=======================================================
in arduino side
=======================================================


void setup() {
Serial.begin(115200); // open serial connection to USB Serial port (connected to your computer)
Serial1.begin(57600); // open internal serial connection to MT7688AN
// in MT7688AN, this maps to device
pinMode(13, OUTPUT);
}
void loop() {
int c = Serial1.read(); // read from MT7688AN
if (c != -1) {
switch(c) {
case '0': // turn off D13 when receiving "0"
digitalWrite(13, 0);
break;
case '1': // turn off D13 when receiving "1"
digitalWrite(13, 1);
break;
}
}
}


=======================================================
 7688 side
=======================================================


import serial
import time
s = None
def setup():
    global s
   # open serial COM port to /dev/ttyS0, which maps to UART0(D0/D1)
   # the baudrate is set to 57600 and should be the same as the one
   # specified in the Arduino sketch uploaded to ATmega32U4.
   s = serial.Serial("/dev/ttyS0", 57600)
def loop():
  # send "1" to the Arduino sketch on ATmega32U4.
  # the sketch will turn on the LED attached to D13 on the board
  s.write("1")
  time.sleep(1)
  # send "0" to the sketch to turn off the LED
  s.write("0")
  time.sleep(1)
if __name__ == '__main__':
   setup()
   while True:
        loop()


沒有留言:

張貼留言