📄 serial.s
字号:
/* * This file is part of Jelie, * (c) 2002 Julien Pilet <julien.pilet@epfl.ch> and * Stephane Magnenat <stephane.magnenat@epfl.ch> * * Jelie is free software; you can redistribute it * and/or modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * * Jelie is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Foobar; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#ifndef __SERIAL_S#define __SERIAL_S #include "pxa250regs.S".text .global InitSerialInitSerial: @ assumes GPOI 34 & 39 are in FFUART alt func. @ Load the FF UART base in r0 mov r0, #0x40000000 add r0, r0, #0x00100000 @ Configure the speed to 115000 bps @ Set the DLAB (Divisor Latch Access) bit of LCR (Line Control Register) @ of UART 0 mov r1, #SIO_LCR_DLAB str r1, [r0, #UART_LCR] @ Write the requested divisor (0x8 (115200)) mov r1, #0x8 str r1, [r0, #UART_DLL] mov r1, #0 str r1, [r0, #UART_DLH] @ Clear the DLAB bit and @ set the 8 bit character mode mov r1, #(SIO_LCR_WLS0 | SIO_LCR_WLS1) str r1, [r0, #UART_LCR] @ Enable the UART mov r1, #SIO_IER_UUE str r1, [r0, #UART_IER] @ returns mov pc, lr @ Send a byte@ @ In : r0, value to transmit@ Out : -@ Mod : r1, r2 .global SendByteSendByte: @ Load the FF UART base in r0 mov r1, #0x40000000 add r1, r1, #0x00100000.sendByteLoop: ldr r2, [r1, #UART_LSR] tst r2, #SIO_LSR_THRE beq .sendByteLoop str r0, [r1, #UART_THR] mov pc, lr@ Get a byte@@ In : -@ Out : r0, received value@ Mod : r1.global GetByteGetByte: @ Load the FF UART base in r0 mov r1, #0x40000000 add r1, r1, #0x00100000 ldr r0, [r1, #UART_LSR] tst r0, #SIO_LSR_DR beq GetByte ldr r0, [r1, #UART_RBR] mov pc, lr@ Convert the 4 lsbits of r0 into ascii@@ In : r0@ Out : r0@ Mod : -.global toAsciitoAscii: and r0, r0, #0x0F cmp r0, #9 addgt r0, r0, #('A' - '0' - 10) add r0, r0, #'0' mov pc, lr @ Send an int32 to the serial line@ LSB first@@ In : r0@ Out : -@ Mod : r0, r1, r2, r3, r13 .global SendASCIIWordSendASCIIWord: mov r13, lr mov r3, r0 mov r0, r3, asr #28 bl toAscii bl SendByte @ modifies r1, r2 mov r0, r3, asr #24 bl toAscii bl SendByte @ modifies r1, r2 mov r0, r3, asr #20 bl toAscii bl SendByte @ modifies r1, r2 mov r0, r3, asr #16 bl toAscii bl SendByte @ modifies r1, r2 mov r0, r3, asr #12 bl toAscii bl SendByte @ modifies r1, r2 mov r0, r3, asr #8 bl toAscii bl SendByte @ modifies r1, r2 mov r0, r3, asr #4 bl toAscii bl SendByte @ modifies r1, r2 mov r0, r3 bl toAscii bl SendByte @ modifies r1, r2 mov r0, #'\r' bl SendByte mov r0, #'\n' bl SendByte mov pc, r13#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -