Rev Author Line No. Line
2962 jacho 1 //Akcelerometr IMU01A
2 //(c) MLAB Jan Chroust 2013
3  
4  
5 #include <main.h>
6  
7 #define PIN_SDA PIN_C4
8 #define PIN_SCL PIN_C3
9 #use i2c(master, sda=PIN_SDA, scl=PIN_SCL) //I2C
10 #use rs232(baud=9600,parity=N,xmit=PIN_C7,rcv=PIN_C6,bits=8) //rcv TXD xmit RXD
11 #include <math.h>
12 #include <MMA8451Q.h>
13  
14 signed int16 X, Y, Z; //promenne pro akcelerometr
15  
16 void main()
17 {
18 setup_adc_ports(NO_ANALOGS|VSS_VDD);
19 setup_adc(ADC_CLOCK_DIV_2);
20 setup_spi(SPI_SS_DISABLED);
21 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
22 setup_timer_1(T1_DISABLED);
23 setup_timer_2(T2_DISABLED,0,1);
24 setup_ccp1(CCP_OFF);
25 setup_comparator(NC_NC_NC_NC);
26  
27 setAK(); //nastaveni akcelerometru
28  
29 printf("Akcelerometr IMU01A - MMA8451Q \r\n",);
30 printf("(c) MLAB JACHO 2013 \r\n",);
31  
32 while(TRUE)
33 {
34 X=akX ();
35 Y=akY ();
36 Z=akZ ();
37 printf("Namerene hodnoty: \r\n",);
38 printf("Osa X: %Ld \r\n",X);
39 printf("Osa Y: %Ld \r\n",Y);
40 printf("Osa Z: %Ld \r\n",Z);
41 delay_ms (2000);
42  
43 }
44 }
45