1 /* i2cwritetest.c */
\r
3 #include "kernel_id.h"
\r
4 #include "ecrobot_interface.h"
\r
6 /* OSEK declarations */
\r
7 DeclareCounter(SysTimerCnt);
\r
11 /* LEJOS OSEK hooks */
\r
12 void ecrobot_device_terminate()
\r
14 i2c_disable(NXT_PORT_S2);
\r
17 /* LEJOS OSEK hook to be invoked from an ISR in category 2 */
\r
18 void user_1ms_isr_type2(void)
\r
22 ercd = SignalCounter(SysTimerCnt); /* Increment OSEK Alarm Counter */
\r
29 /* Task1 executed only once at initialization */
\r
32 nxt_avr_set_input_power(NXT_PORT_S2,2);
\r
33 i2c_enable(NXT_PORT_S2);
\r
38 /* Task2 executed every 500msec */
\r
43 while (i2c_busy(NXT_PORT_S2) != 0);
\r
44 /* write Single shot command */
\r
46 i2c_start_transaction(NXT_PORT_S2,1,0x41,1,&data,1,1);
\r
48 systick_wait_ms(50);
\r
50 if (i2c_busy(NXT_PORT_S2) == 0)
\r
52 /* read mesurement data */
\r
53 i2c_start_transaction(NXT_PORT_S2,1,0x42,1,&data,1,0);
\r
55 systick_wait_ms(50);
\r
58 display_goto_xy(0, 0);
\r
59 display_int(data, 0);
\r