Z
z543g
Guest
/ ** IR_LED BANDYMO už 89c2051 ** /
# define IR_LED P1.0
tuščia delay_us (int tt)
(
while (Tt -);
)
tuščia delay_ms (int tt)
(
while (Tt> 0)
(
delay_us (160);
delay_us (160);
tt -;
)
)
tuščia rc5_send_pulses (tuščia)
(
unsigned char i;
i = 32;
while (i -)
(
IR_LED = 0;
delay_us (7);
IR_LED = 1;
delay_us (19);
)
)
tuščia rc5_send_0 (tuščia)
(
rc5_send_pulses ();
delay_us (889);
)
tuščia rc5_send_1 (tuščia)
(
delay_us (889);
rc5_send_pulses ();
)
tuščia rc5_send (char adresą, char komandą)
(
unsigned int rc5_code;
unsigned char i;
rc5_code = 0x07;
rc5_code <= 5;
rc5_code | = (adresas
ir 0x1f);
rc5_code <= 6;
rc5_code | = (command & 0x3f);
rc5_code <<= 2;
i = 14;
while (i -) (
jei (rc5_code & 0x8000)
rc5_send_1 ();
kitas
rc5_send_0 ();
rc5_code <<= 1;
)
)
void main (void)
(
o (1)
(
rc5_send (5,53);
delay_ms (114);
)
)-------------------------------------------------- -------------------------
/ ** RC5_RECEIVE už 89c2051 ** /
typedef unsigned char byte;
typedef unsigned int WORD;
# define RC5_IN P1.0
tuščia delay_us (int tt)
(
while (Tt -);
)
tuščia delay_ms (int tt)
(
while (Tt> 0)
(
delay_us (160);
delay_us (160);
tt -;
)
)
Byte read_SBUF (tuščia)
(
while (RI == 0) ()
RI = 0;
grįžti SBUF;
)
tuščia write_SBUF (byte ch)
(
o (TI == 0) ()
TI = 0;
SBUF = ch;
)
tuščia scu_str (char s [])
(
Byte i;
i = 0;
while (s ! = '\ 0')
(
write_SBUF (s [i ]);
)
)
tuščia scu_init (tuščia)
(
SCON = 0x52;
TMOD = TMOD & 0x0f;
TMOD = TMOD | 0x20;
TH1 = 0xfd;
TR1 = 1;
)
int rc5_receive (tuščia)
(
int rc5_code;
unsigned char i;
unsigned char k;
rc5_code = 1;
while (RC5_IN) tęsti;
delay_us (444);
jei (RC5_IN) grįžti RC5_ERR;
i = 13;
while (i -)
(
q = 0;
rc5_code <<= 1;
delay_us (889);
jei (RC5_IN) q = 2;
delay_us (889);
jei (RC5_IN) q ;
switch (q)
(
atveju 1: rc5_code | = 0; break;
2 atveju: rc5_code | = 1; break;
defualt: grįžti RC5_ERR;
)
)
grįžti rc5_code & 0x07ff;
)
void main (void)
(
unsigned int i;
scu_init ()
o (1)
(
i = rc5_receive ();
printf ( "% d% d \ n \ r", i> 6, i & 0x003F);
)
)
Answer:
16384 63
0 0
16384 63
16384 63 <- i
don't know about rc5 kodą.prašome kurie
<img src="http://www.edaboard.com/images/smiles/icon_sad.gif" alt="Liūdnas" border="0" />
.klaidos rc5 kodas šaltinis?<img src="http://www.edaboard.com/images/smiles/icon_sad.gif" alt="Liūdnas" border="0" /><img src="http://www.edaboard.com/images/smiles/icon_sad.gif" alt="Liūdnas" border="0" />
Padėkite man ...Padėkite man ...
<img src="http://www.edaboard.com/images/smiles/icon_sad.gif" alt="Liūdnas" border="0" /><img src="http://www.edaboard.com/images/smiles/icon_sad.gif" alt="Liūdnas" border="0" />
# define IR_LED P1.0
tuščia delay_us (int tt)
(
while (Tt -);
)
tuščia delay_ms (int tt)
(
while (Tt> 0)
(
delay_us (160);
delay_us (160);
tt -;
)
)
tuščia rc5_send_pulses (tuščia)
(
unsigned char i;
i = 32;
while (i -)
(
IR_LED = 0;
delay_us (7);
IR_LED = 1;
delay_us (19);
)
)
tuščia rc5_send_0 (tuščia)
(
rc5_send_pulses ();
delay_us (889);
)
tuščia rc5_send_1 (tuščia)
(
delay_us (889);
rc5_send_pulses ();
)
tuščia rc5_send (char adresą, char komandą)
(
unsigned int rc5_code;
unsigned char i;
rc5_code = 0x07;
rc5_code <= 5;
rc5_code | = (adresas
ir 0x1f);
rc5_code <= 6;
rc5_code | = (command & 0x3f);
rc5_code <<= 2;
i = 14;
while (i -) (
jei (rc5_code & 0x8000)
rc5_send_1 ();
kitas
rc5_send_0 ();
rc5_code <<= 1;
)
)
void main (void)
(
o (1)
(
rc5_send (5,53);
delay_ms (114);
)
)-------------------------------------------------- -------------------------
/ ** RC5_RECEIVE už 89c2051 ** /
typedef unsigned char byte;
typedef unsigned int WORD;
# define RC5_IN P1.0
tuščia delay_us (int tt)
(
while (Tt -);
)
tuščia delay_ms (int tt)
(
while (Tt> 0)
(
delay_us (160);
delay_us (160);
tt -;
)
)
Byte read_SBUF (tuščia)
(
while (RI == 0) ()
RI = 0;
grįžti SBUF;
)
tuščia write_SBUF (byte ch)
(
o (TI == 0) ()
TI = 0;
SBUF = ch;
)
tuščia scu_str (char s [])
(
Byte i;
i = 0;
while (s ! = '\ 0')
(
write_SBUF (s [i ]);
)
)
tuščia scu_init (tuščia)
(
SCON = 0x52;
TMOD = TMOD & 0x0f;
TMOD = TMOD | 0x20;
TH1 = 0xfd;
TR1 = 1;
)
int rc5_receive (tuščia)
(
int rc5_code;
unsigned char i;
unsigned char k;
rc5_code = 1;
while (RC5_IN) tęsti;
delay_us (444);
jei (RC5_IN) grįžti RC5_ERR;
i = 13;
while (i -)
(
q = 0;
rc5_code <<= 1;
delay_us (889);
jei (RC5_IN) q = 2;
delay_us (889);
jei (RC5_IN) q ;
switch (q)
(
atveju 1: rc5_code | = 0; break;
2 atveju: rc5_code | = 1; break;
defualt: grįžti RC5_ERR;
)
)
grįžti rc5_code & 0x07ff;
)
void main (void)
(
unsigned int i;
scu_init ()
o (1)
(
i = rc5_receive ();
printf ( "% d% d \ n \ r", i> 6, i & 0x003F);
)
)
Answer:
16384 63
0 0
16384 63
16384 63 <- i
don't know about rc5 kodą.prašome kurie
<img src="http://www.edaboard.com/images/smiles/icon_sad.gif" alt="Liūdnas" border="0" />
.klaidos rc5 kodas šaltinis?<img src="http://www.edaboard.com/images/smiles/icon_sad.gif" alt="Liūdnas" border="0" /><img src="http://www.edaboard.com/images/smiles/icon_sad.gif" alt="Liūdnas" border="0" />
Padėkite man ...Padėkite man ...
<img src="http://www.edaboard.com/images/smiles/icon_sad.gif" alt="Liūdnas" border="0" /><img src="http://www.edaboard.com/images/smiles/icon_sad.gif" alt="Liūdnas" border="0" />