📄 interface.s
字号:
.module interface.c
.area text(rom, con, rel)
.dbfile E:\ICCAVR\icc\stk500\avrasp\interface.c
.dbfunc e interface_init _interface_init fV
.even
_interface_init::
.dbline -1
.dbline 87
; /** \file
; <b>USB receive and transmit</b><br>
; Autor: Matthias Wei遝r<br>
; Copyright 2005: Matthias Wei遝r<br>
; License: QPL (see license.txt)
; <hr>
; */
; #include "stk500.h"
;
; unsigned char checksum;
;
; //#ifdef CONFIG_INTERFACE_USB
; #if 0
;
; //Hardware
; #define USB_TXE (PINB&BIT6_POS)
; #define USB_RXF (PINC&BIT3_POS)
; #define USB_RD_ON PORTC&=BIT1_NEG
; #define USB_RD_OFF PORTC|=BIT1_POS
; #define USB_WR_ON PORTC|=BIT2_POS
; #define USB_WR_OFF PORTC&=BIT2_NEG
;
; /**
; Initializes the usb interface
; */
; void interface_init(void)
; {
; PORTC |= BIT1_POS; //USB_RD inactive
; DDRC |= BIT1_POS|BIT2_POS; //USB_RD, USB_WR as output
; }
;
; /**
; Reads a byte from the USB interface
;
; @return received character or -1 if no character has been received
; */
; signed int interface_getc(void)
; {
; unsigned char t;
;
; if(!USB_RXF)
; {
; USB_RD_ON;
; asm("NOP");
; t = PIND;
; USB_RD_OFF;
;
; return t;
; }
; else return -1;
; }
;
; /**
; Writes a byte to the USB
;
; @param t Byte to be written
; */
; void interface_putc(unsigned char t)
; {
; while(USB_TXE);
;
; //PORTD auf Ausgang
; DDRD = 0xFF;
; //Daten auf den Port
; PORTD = t;
;
; USB_WR_ON;
; USB_WR_OFF;
;
; //PORTC auf Eingang
; DDRD = 0x00;
; //Pull-Ups ein
; PORTD = 0xFF;
;
; checksum ^= t;
; }
;
; #endif
;
; #ifdef CONFIG_INTERFACE_RS232
;
; /**
; Initializes the rs232 interface
; 3.6864MHz
; Autor: Lukas Salzburger
; */
; void interface_init(void) {
.dbline 88
; UCSR0B = (1<<RXEN0) | (1<<TXEN0);
ldi R24,24
sts 193,R24
.dbline 89
; UBRR0L = 1;
ldi R24,1
sts 196,R24
.dbline 90
; UBRR0H = 0;
clr R2
sts 197,R2
.dbline -2
L2:
.dbline 0 ; func end
ret
.dbend
.dbfunc e interface_getc _interface_getc fI
.even
_interface_getc::
.dbline -1
.dbline 100
; }
;
; /**
; Reads a byte from the UART interface
;
; Autor: Lukas Salzburger
;
; @return received character or -1 if no character has been received
; */
; signed int interface_getc(void) { /*获取PC机发来的一字节信息*/
.dbline 102
;
; if (UCSR0A & (1<<RXC0)) {
lds R2,192
sbrs R2,7
rjmp L4
.dbline 102
.dbline 103
; return UDR0;
lds R16,198
clr R17
rjmp L3
L4:
.dbline 105
; }
; else {
.dbline 106
; return -1;
ldi R16,-1
ldi R17,-1
.dbline -2
L3:
.dbline 0 ; func end
ret
.dbend
.dbfunc e interface_putc _interface_putc fV
; t -> R16
.even
_interface_putc::
.dbline -1
.dbline 117
; }
; }
;
; /**
; Writes a byte to the UART
;
; Autor: Lukas Salzburger
;
; @param t Byte to be written
; */
; void interface_putc(unsigned char t) {
L7:
.dbline 119
L8:
.dbline 119
;
; while (!(UCSR0A & (1<<UDRE0)));
lds R2,192
sbrs R2,5
rjmp L7
.dbline 121
;
; UDR0 = t;
sts 198,R16
.dbline 122
; checksum ^= t;
lds R2,_checksum
eor R2,R16
sts _checksum,R2
.dbline -2
L6:
.dbline 0 ; func end
ret
.dbsym r t 16 c
.dbend
.dbfunc e interface_print _interface_print fV
; s -> R20,R21
.even
_interface_print::
rcall push_gset1
movw R20,R16
.dbline -1
.dbline 133
; }
;
; #endif
;
; /**
; Writes a string to USB
;
; @param s The string to be send
; */
; void interface_print(unsigned char *s)
; {
rjmp L12
L11:
.dbline 135
.dbline 136
movw R30,R20
ldd R16,z+0
rcall _interface_putc
.dbline 137
subi R20,255 ; offset = 1
sbci R21,255
.dbline 138
L12:
.dbline 134
; while(*s)
movw R30,R20
ldd R2,z+0
tst R2
brne L11
.dbline -2
L10:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r s 20 pc
.dbend
.dbfunc e interface_put16 _interface_put16 fV
; t -> R20,R21
.even
_interface_put16::
rcall push_gset1
movw R20,R16
.dbline -1
.dbline 148
; {
; interface_putc(*s);
; s++;
; }
; }
;
; /**
; Sends a 16 bit value over the USB
; MSB first
;
; @param t Value to be send
; */
; void interface_put16(unsigned int t)
; {
.dbline 149
; interface_putc((t>>8)&0xFF);
movw R16,R20
mov R16,R17
clr R17
andi R17,0
rcall _interface_putc
.dbline 150
; interface_putc((t>>0)&0xFF);
mov R16,R20
andi R17,0
rcall _interface_putc
.dbline -2
L14:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r t 20 i
.dbend
.dbfunc e interface_reset_check _interface_reset_check fV
.even
_interface_reset_check::
.dbline -1
.dbline 157
; }
;
; /**
; Resets the checksum accumulator
; */
; void interface_reset_check(void)
; {
.dbline 158
; checksum=0;
clr R2
sts _checksum,R2
.dbline -2
L15:
.dbline 0 ; func end
ret
.dbend
.dbfunc e interface_send_check _interface_send_check fV
.even
_interface_send_check::
.dbline -1
.dbline 165
; }
;
; /**
; Sends the accumulated checksum
; */
; void interface_send_check(void)
; {
.dbline 166
; interface_putc(checksum);
lds R16,_checksum
rcall _interface_putc
.dbline 167
; checksum=0;
clr R2
sts _checksum,R2
.dbline -2
L16:
.dbline 0 ; func end
ret
.dbend
.area bss(ram, con, rel)
.dbfile E:\ICCAVR\icc\stk500\avrasp\interface.c
_checksum::
.blkb 1
.dbsym e checksum _checksum c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -