Subversion Repositories svnkaklik

Rev

Rev 410 | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
#include "D:\KAKLIK\programy\PIC_C\mereni\mys\PIC16F88\mys.h"
2
 
3
#define LCD_RS          PIN_B3      // rizeni registru LCD displeje
4
#define LCD_E           PIN_B0      // enable LCD displeje
5
#define LCD_DATA_LSB    PIN_A0      // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou)
6
#include "C:\library\CCS\lcd.c"
7
 
8
#include "C:\library\kaklik\CCS\mys_chip_SPI.c" // modul umoznujici komunikaci s cidlem v mysi
9
 
10
void main()
11
{
12
unsigned int8 hodnota;
13
signed int16 x=0,y=0;
14
signed int8 xd,yd;
15
 
16
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
17
   setup_adc(ADC_OFF);
18
   setup_spi(SPI_MASTER|SPI_H_TO_L|SPI_XMIT_L_TO_H|SPI_CLK_DIV_64);
19
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
20
   setup_timer_1(T1_DISABLED);
21
   setup_timer_2(T2_DISABLED,0,1);
22
   setup_comparator(NC_NC_NC_NC);
23
   setup_vref(FALSE);
24
 
25
   chip_write(OPERATION_MODE);
26
   chip_write(0x00);       // vypne sleep mode
27
 
28
   chip_write(CONFIGURATION);
29
   chip_write(0b00000110);       // nastavi rozliseni na 600cpi
30
 
31
   lcd_init();
32
   Delay_ms(200);
33
 
34
   While(true)
35
   {
36
      LCD_gotoxy(1,1);
37
      printf(lcd_putc,"status: %X", hodnota);
38
      delay_ms(20);
39
 
40
      LCD_gotoxy(1,2);
41
      printf(lcd_putc,"X=%ld Y=%ld", x, y);
42
      delay_ms(20);
43
 
44
      hodnota=chip_read(MOTION_STATUS);
45
 
46
      xd=chip_read(DELTA_X);
47
      yd=chip_read(DELTA_Y);
48
 
49
      x+=xd;
50
      y+=yd;
51
   }  
52
}