Suga koubou
/
eDES2WD_test
http://mbed.org/users/okini3939/notebook/daisen-edes/
eDES2WD.cpp
- Committer:
- okini3939
- Date:
- 2012-02-23
- Revision:
- 0:141734449aeb
- Child:
- 1:3c8a6bd50779
File content as of revision 0:141734449aeb:
#include "mbed.h" #include "eDES2WD.h" I2C i2c(p28, p27); void eDES2WD_reset (int id) { char cmd[] = {1, I2C_WCMD_RESET}; int adrs; if (0 < id){ adrs = SUB_ADRS + (id - 1) * 2; } else { adrs = 0; } i2c.write(adrs, cmd, 2); } void eDES2WD_motor (int id, int l_speed, int r_speed) { char cmd[] = {3, I2C_WCMD_MOTOR, 0, 0}; int adrs; cmd[2] = l_speed; cmd[3] = r_speed; if (0 < id){ adrs = SUB_ADRS + (id - 1) * 2; } else { adrs = 0; } i2c.write(adrs, cmd, 4); } void eDES2WD_set_led (int id, int led, int sw) { char cmd[] = {3, I2C_WCMD_LED, 0, 0}; int adrs; cmd[2] = led; cmd[3] = sw; if (0 < id){ adrs = SUB_ADRS + (id - 1) * 2; } else { adrs = 0; } i2c.write(adrs, cmd, 4); }