robocon_2016
/
2016_slave_touch_photo
SE1
Diff: main.cpp
- Revision:
- 0:51438a7d7c37
- Child:
- 1:9c35cd14067d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Sep 10 08:03:25 2016 +0000 @@ -0,0 +1,35 @@ +#include "mbed.h" +#include "i2cslave.h" +#include "define.h" + +char Registar[128] = {}; + +void check(); + +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); + Ticker tic; + tic.attach(check, 0.1); + BusIn pins(dp1, dp6, dp9, dp14, dp17, dp24, dp18, dp2); + i2cslave myi2c(dp5, dp27, Registar); + myi2c.address(SE1_addr); + myi2c.frequency(1000000); + while(1) + { + Registar[0] = pins.read(); + } +} + +void check() +{ + Registar[check_reg]++; + if(Registar[check_reg] > 2) + { + NVIC_SystemReset(); + } +}