📄 interface.s
字号:
.module interface.c
.area text(rom, con, rel)
.dbfile E:\ICCAVR\project\avrisp\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 89
; #ifndef __iom88v_h /*meag8*/
; UCSRB = (1<<RXEN) | (1<<TXEN);
ldi R24,24
out 0xa,R24
.dbline 90
; UBRRL = 1;
ldi R24,1
out 0x9,R24
.dbline 91
; UBRRH = 0;
clr R2
out 0x20,R2
.dbline -2
L2:
.dbline 0 ; func end
ret
.dbend
.dbfunc e interface_getc _interface_getc fI
.even
_interface_getc::
.dbline -1
.dbline 106
; #else /*mega88*/
; UCSR0B = (1<<RXEN0) | (1<<TXEN0);
; UBRR0L = 1;
; UBRR0H = 0;
; #endif
; }
;
; /**
; 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 109
;
; #ifndef __iom88v_h /*meag8*/
; if (UCSRA & (1<<RXC)) {
sbis 0xb,7
rjmp L4
.dbline 109
.dbline 110
; return UDR;
in R16,0xc
clr R17
rjmp L3
L4:
.dbline 112
; }
; else {
.dbline 113
; 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 132
; }
; #else /*mega88*/
; if (UCSR0A & (1<<RXC0)) {
; return UDR0;
; }
; else {
; return -1;
; }
; #endif
; }
;
; /**
; Writes a byte to the UART
;
; Autor: Lukas Salzburger
;
; @param t Byte to be written
; */
; void interface_putc(unsigned char t) {
L7:
.dbline 135
L8:
.dbline 135
;
; #ifndef __iom88v_h /*meag8*/
; while (!(UCSRA & (1<<UDRE)));
sbis 0xb,5
rjmp L7
.dbline 137
;
; UDR = t;
out 0xc,R16
.dbline 138
; 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 155
; #else /*mega88*/
; while (!(UCSR0A & (1<<UDRE0)));
;
; UDR0 = t;
; checksum ^= t;
; #endif
; }
;
; #endif
;
; /**
; Writes a string to USB
;
; @param s The string to be send
; */
; void interface_print(unsigned char *s)
; {
rjmp L12
L11:
.dbline 157
.dbline 158
movw R30,R20
ldd R16,z+0
rcall _interface_putc
.dbline 159
subi R20,255 ; offset = 1
sbci R21,255
.dbline 160
L12:
.dbline 156
; 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 170
; {
; 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 171
; interface_putc((t>>8)&0xFF);
movw R16,R20
mov R16,R17
clr R17
andi R17,0
rcall _interface_putc
.dbline 172
; 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 179
; }
;
; /**
; Resets the checksum accumulator
; */
; void interface_reset_check(void)
; {
.dbline 180
; 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 187
; }
;
; /**
; Sends the accumulated checksum
; */
; void interface_send_check(void)
; {
.dbline 188
; interface_putc(checksum);
lds R16,_checksum
rcall _interface_putc
.dbline 189
; checksum=0;
clr R2
sts _checksum,R2
.dbline -2
L16:
.dbline 0 ; func end
ret
.dbend
.area bss(ram, con, rel)
.dbfile E:\ICCAVR\project\avrisp\interface.c
_checksum::
.blkb 1
.dbsym e checksum _checksum c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -