SE1

Dependencies:   i2cslave mbed

Committer:
sgrsn
Date:
Sat Sep 10 08:03:25 2016 +0000
Revision:
0:51438a7d7c37
Child:
1:9c35cd14067d
SE1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sgrsn 0:51438a7d7c37 1 #include "mbed.h"
sgrsn 0:51438a7d7c37 2 #include "i2cslave.h"
sgrsn 0:51438a7d7c37 3 #include "define.h"
sgrsn 0:51438a7d7c37 4
sgrsn 0:51438a7d7c37 5 char Registar[128] = {};
sgrsn 0:51438a7d7c37 6
sgrsn 0:51438a7d7c37 7 void check();
sgrsn 0:51438a7d7c37 8
sgrsn 0:51438a7d7c37 9 int main()
sgrsn 0:51438a7d7c37 10 {
sgrsn 0:51438a7d7c37 11 NVIC_SetPriority(TIMER_16_0_IRQn, 20);
sgrsn 0:51438a7d7c37 12 NVIC_SetPriority(TIMER_16_1_IRQn, 20);
sgrsn 0:51438a7d7c37 13 NVIC_SetPriority(TIMER_32_0_IRQn, 20);
sgrsn 0:51438a7d7c37 14 NVIC_SetPriority(TIMER_32_1_IRQn, 20);
sgrsn 0:51438a7d7c37 15 NVIC_SetPriority(I2C_IRQn, 10);
sgrsn 0:51438a7d7c37 16 Ticker tic;
sgrsn 0:51438a7d7c37 17 tic.attach(check, 0.1);
sgrsn 0:51438a7d7c37 18 BusIn pins(dp1, dp6, dp9, dp14, dp17, dp24, dp18, dp2);
sgrsn 0:51438a7d7c37 19 i2cslave myi2c(dp5, dp27, Registar);
sgrsn 0:51438a7d7c37 20 myi2c.address(SE1_addr);
sgrsn 0:51438a7d7c37 21 myi2c.frequency(1000000);
sgrsn 0:51438a7d7c37 22 while(1)
sgrsn 0:51438a7d7c37 23 {
sgrsn 0:51438a7d7c37 24 Registar[0] = pins.read();
sgrsn 0:51438a7d7c37 25 }
sgrsn 0:51438a7d7c37 26 }
sgrsn 0:51438a7d7c37 27
sgrsn 0:51438a7d7c37 28 void check()
sgrsn 0:51438a7d7c37 29 {
sgrsn 0:51438a7d7c37 30 Registar[check_reg]++;
sgrsn 0:51438a7d7c37 31 if(Registar[check_reg] > 2)
sgrsn 0:51438a7d7c37 32 {
sgrsn 0:51438a7d7c37 33 NVIC_SystemReset();
sgrsn 0:51438a7d7c37 34 }
sgrsn 0:51438a7d7c37 35 }