![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
CY1_9/30
Revision 0:347fe1fcc3d3, committed 2016-09-30
- Comitter:
- sgrsn
- Date:
- Fri Sep 30 12:29:55 2016 +0000
- Commit message:
- CE1_9/30
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/define.h Fri Sep 30 12:29:55 2016 +0000 @@ -0,0 +1,46 @@ +/*Registar group*************************************/ + +#define motor1_state 0x01 +#define motor2_state 0x02 +#define motor1_pwm 0x03 +#define motor2_pwm 0x04 +#define check_reg 0x05 +#define PM_target_reg 0x10 +#define RE_target_reg 0x20 +#define Kp 0x30 +#define pid_start 0x40 +#define machine_state 0x45 +#define PM_ofset_reg 0x50 +#define wheel_start 0x60 +#define PM_start 0x70 + +/*Address group*************************************/ +//MD : MotorDriver +#define MD1_addr 0x12 +#define MD2_addr 0x14 +#define MD3_addr 0x16 +#define MD4_addr 0x18 +#define MD5_addr 0x20 +#define MD6_addr 0x22 +#define MD7_addr 0x24 +#define MD8_addr 0x26 +#define MD9_addr 0x28 +#define MD10_addr 0x30 +#define MD11_addr 0x32 +#define MD12_addr 0x34 +#define MD13_addr 0x36 +#define MD14_addr 0x38 +#define MD15_addr 0x40 + +//CY : Cylinder +#define CY1_addr 0x50 + +//SE : Sensor +#define SE1_addr 0x90 +#define SE2_addr 0xA0 + +/*Motor movement***********************************/ + +#define Nomal 5 +#define Reverse 10 +#define Stop 3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/i2cslave.lib Fri Sep 30 12:29:55 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/sgrsn/code/i2cslave/#69b088a9899b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Sep 30 12:29:55 2016 +0000 @@ -0,0 +1,34 @@ +#include "mbed.h" +#include "i2cslave.h" +#include "define.h" + +char Registar[128]= {}; +void check(); +BusOut cylinders(dp2, dp6, dp10, dp14, dp17, dp18, dp25, dp28); + +int main() +{ + NVIC_SetPriority(TIMER_16_0_IRQn, 20); + NVIC_SetPriority(TIMER_16_1_IRQn, 20); + NVIC_SetPriority(TIMER_32_0_IRQn, 20); + NVIC_SetPriority(TIMER_32_1_IRQn, 20); + NVIC_SetPriority(I2C_IRQn, 10); + i2cslave i2c(dp5, dp27, Registar); + i2c.address(CY1_addr); + i2c.frequency(1000000); + Ticker tic; + tic.attach(check, 0.1); + while(1) + { + cylinders = Registar[motor1_state]; + } +} + +void check() +{ + Registar[check_reg]++; + if(Registar[check_reg] > 2) + { + NVIC_SystemReset(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Sep 30 12:29:55 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/abea610beb85 \ No newline at end of file