2926 |
jacho |
1 |
#include "main.h" |
2984 |
kaklik |
2 |
#include "HMC5883L.h" |
2926 |
jacho |
3 |
|
|
|
4 |
void main() |
|
|
5 |
{ |
2984 |
kaklik |
6 |
signed int16 X,Y,Z; |
|
|
7 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
|
|
8 |
setup_adc(ADC_CLOCK_DIV_2); |
|
|
9 |
setup_spi(SPI_SS_DISABLED); |
|
|
10 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
|
|
11 |
setup_timer_1(T1_DISABLED); |
|
|
12 |
setup_timer_2(T2_DISABLED,0,1); |
|
|
13 |
setup_ccp1(CCP_OFF); |
|
|
14 |
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard |
2926 |
jacho |
15 |
|
2984 |
kaklik |
16 |
set_mag(); |
2926 |
jacho |
17 |
|
2984 |
kaklik |
18 |
printf("Magnetometr: \r\n",); |
|
|
19 |
printf("(c)mlab JACHO 2013: \r\n",); |
|
|
20 |
printf("X, Y, Z \r\n",); |
2926 |
jacho |
21 |
|
2984 |
kaklik |
22 |
while(true) |
|
|
23 |
{ |
|
|
24 |
X = mag_readX(); |
|
|
25 |
Y = mag_readY(); |
|
|
26 |
Z = mag_readZ(); |
|
|
27 |
printf("%4Ld %4Ld %4Ld \r\n", X, Y, Z); |
|
|
28 |
Delay_ms(50); |
2926 |
jacho |
29 |
|
2984 |
kaklik |
30 |
} |
2926 |
jacho |
31 |
} |