Line No. | Rev | Author | Line |
---|---|---|---|
1 | 3 | kaklik | //////////////////////////////////////////////////////////////// |
2 | // Program pro otestovani funkci knihovny 24XX.C |
||
3 | //////////////////////////////////////////////////////////////// |
||
4 | // |
||
5 | // (c) PEFI 2003 |
||
6 | // Verze 0.00 - uvodni verze |
||
7 | // |
||
8 | //////////////////////////////////////////////////////////////// |
||
9 | #include <16F876.h> |
||
10 | #include <16f877_reg.h> |
||
11 | #include <stdlib.h> |
||
12 | #use delay (clock=4000000) |
||
13 | #use rs232 (baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7) |
||
14 | #fuses XT,NOWDT,NOBROWNOUT,NOPROTECT,NOLVP |
||
15 | |||
16 | |||
17 | #define EXTEE_HW 1 /* zapne(1) / vypne(0) HW podporu i2c */ |
||
18 | #include <24XX.c> |
||
19 | |||
20 | |||
21 | void main() |
||
22 | { |
||
23 | char Adr[4]; |
||
24 | int16 Adr_eeprom; |
||
25 | int8 Data_eeprom; |
||
26 | int16 Len; |
||
27 | int16 i; |
||
28 | char c; |
||
29 | int8 buf[64]; |
||
30 | |||
31 | |||
32 | ExtEE_init(); |
||
33 | for(;;) |
||
34 | { |
||
35 | printf("Cteni(r) Zapis(w) Blok.cteni(e) Blok.zapis(q) Prubezne cteni(t) ?\n\r"); |
||
36 | if((c=getc())=='w') |
||
37 | { |
||
38 | printf("ZAPIS\n\r"); |
||
39 | printf("Zadej adresu(dekadicky)\n\r"); |
||
40 | gets(Adr); |
||
41 | Adr_eeprom=atol(Adr); |
||
42 | printf("Zadej data(dekadicky)\n\r"); |
||
43 | gets(Adr); |
||
44 | Data_eeprom=atol(Adr); |
||
45 | ExtEE_write_byte(Adr_eeprom,Data_eeprom); |
||
46 | printf("Zapsano\n\r"); |
||
47 | } |
||
48 | else if(c=='r') |
||
49 | { |
||
50 | printf("CTENI\n\r"); |
||
51 | printf("Zadej adresu(dekadicky)\n\r"); |
||
52 | gets(Adr); |
||
53 | Adr_eeprom=atol(Adr); |
||
54 | Data_eeprom=ExtEE_read_byte(Adr_eeprom); |
||
55 | printf("Precteno %d\n\r",Data_eeprom); |
||
56 | } |
||
57 | else if(c=='t') |
||
58 | { |
||
59 | printf("PRUBEZNE CTENI\n\r"); |
||
60 | Data_eeprom=ExtEE_read_byte_inc(); |
||
61 | printf("Precteno %d\n\r",Data_eeprom); |
||
62 | } |
||
63 | else if(c=='e') |
||
64 | { |
||
65 | printf("BLOK.CTENI\n\r"); |
||
66 | printf("Zadej adresu(dekadicky)\n\r"); |
||
67 | gets(Adr); |
||
68 | Adr_eeprom=atol(Adr); |
||
69 | printf("Zadej delku bloku\n\r"); |
||
70 | gets(Adr); |
||
71 | len=atol(Adr); |
||
72 | ExtEE_read_array(Adr_eeprom,buf,len) ; |
||
73 | i=0; |
||
74 | do |
||
75 | printf("%d ",buf[i++]); |
||
76 | while(--len); |
||
77 | } |
||
78 | else if(c=='q') |
||
79 | { |
||
80 | printf("BLOK.ZAPIS\n\r"); |
||
81 | printf("Zadej adresu(dekadicky)\n\r"); |
||
82 | gets(Adr); |
||
83 | Adr_eeprom=atol(Adr); |
||
84 | printf("Zadej delku bloku\n\r"); |
||
85 | gets(Adr); |
||
86 | len=atol(Adr); |
||
87 | for(i=0;i<len;i++) |
||
88 | { |
||
89 | buf[i]=i; |
||
90 | } |
||
91 | ExtEE_write_array(Adr_eeprom,buf,len); |
||
92 | printf("Zapsano\n\r"); |
||
93 | } |
||
94 | else printf("SPATNA VOLBA\n\r"); |
||
95 | } |
||
96 | } |
||
97 | // End of File |
Powered by WebSVN v2.8.3