Rev 410 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download
#include "D:\KAKLIK\programy\PIC_C\mereni\mys\PIC16F88\mys.h"
#define LCD_RS PIN_B3 // rizeni registru LCD displeje
#define LCD_E PIN_B0 // enable LCD displeje
#define LCD_DATA_LSB PIN_A0 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou)
#include "C:\library\CCS\lcd.c"
#include "C:\library\kaklik\CCS\mys_chip_SPI.c" // modul umoznujici komunikaci s cidlem v mysi
void main()
{
unsigned int8 hodnota;
signed int16 x=0,y=0;
signed int8 xd,yd;
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_spi(SPI_MASTER|SPI_H_TO_L|SPI_XMIT_L_TO_H|SPI_CLK_DIV_64);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
chip_write(OPERATION_MODE);
chip_write(0x00); // vypne sleep mode
chip_write(CONFIGURATION);
chip_write(0b00000110); // nastavi rozliseni na 600cpi
lcd_init();
Delay_ms(200);
While(true)
{
LCD_gotoxy(1,1);
printf(lcd_putc,"status: %X", hodnota);
delay_ms(20);
LCD_gotoxy(1,2);
printf(lcd_putc,"X=%ld Y=%ld", x, y);
delay_ms(20);
hodnota=chip_read(MOTION_STATUS);
xd=chip_read(DELTA_X);
yd=chip_read(DELTA_Y);
x+=xd;
y+=yd;
}
}