⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basic_gpio_init.s

📁 linux下的jtag调试软件
💻 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 */@@ Initialize the pxa 250@ Julien Pilet & Stephane Magnenat, 7 2002@#include "pxa250regs.S"@ macros for led control#include "led.S".text@ Exception vectors@ 0x00, Reset	b Reset@ 0x04, Undefined instructions	b HandleUndef@ 0x08, Software interrupt (SWI)	b HandleSWI@ 0x0c, Prefetch Abort (instruction fetch memory abort)	b HandlePrefetchAbort@ 0x10, Data Abord (data access memory abort)	b HandleDataAbort@ 0x14, Reserved	nop@ 0x18, IRQ (interrupt)	b HandleIRQ@ 0x1c, FIQ (fast interrupt)	b HandleFIQ@ CPU jump here just after reset Reset:	@ during the initialisation, the Global Enable bit	@ of the DCSR is set. It s cleared on reset.	@ This way, we can differenciate between a normal boot	@ and a debug event.	mrc p14, 0, r13, c10, c0	@ get DCSR	andS r13, r13, #(1 << 31)	@ check for Global Enable	bne DebugHandler		@ this is a debug event.	@ Set the Global Enable bit of the Debug and Control Status Register	@ (DCSR)	mov r0, #(1 << 31)	mcr p14, 0, r0, c10, c0, 0@ Disable watchdog, clear OS Timer@ OS Timer: base address 0x40A00000	mov r0, #0x40000000	add r0, r0, #0x00A00000	mov r1, #0	str r1, [r0]		@ OSMR0 = 0 Match Register 0	str r1, [r0, #4]	@ OSMR1 = 0	str r1, [r0, #8]	@ OSMR2 = 0	str r1, [r0, #0xC]	@ OSMR3 = 0	str r1, [r0, #0x10]	@ OSCR = 0 Counter Register	str r1, [r0, #0x14]	@ OSSR = 0 Status Register 	str r1, [r0, #0x18]	@ OWER = 0 Watchdog Enable Register	str r1, [r0, #0x1C]	@ OIER = 0 Interupt Enable Register@ GPIO init@ Every GPIO in output mode	mov r0, #0x40000000	add r0, r0, #0x00E00000 @ r0 = GPIO base = 0x40E00000	sub r2, r1, #1		@ r1 = 0, r2 = -1	add r3, r1, #1		@ r3 = 1@ direction: output	@bic r4, r2, r3, asl #27 @ USB Detect in input	@str r4, [r0, #0xC]	@ GPDR0 = 0xf7ffffff	bic r4, r2, #( 1 << (34-32))	str r4, [r0, #0x10]	@ GPDR1 = 0xffffffff	@str r2, [r0, #0x14]	@ GPDR2 = 0xffffffff	str r1, [r0, #0xC]	@ GPDR0 = 0x0	orr r4, r1, r3, asl #1	orr r4, r4, r3, asl #7	@str r4, [r0, #0x10]	@ GPDR1 = 0x84	str r1, [r0, #0x14]	@ GPDR2 = 0x0	mov r4, #0x10			@ Clear USB connect	str r4, [r0, #GPCR1_OFFSET]	@ because we dont know the reset value	@ Configure FFUART GPIOs to alternate function	@ set to alternate mode gpio pins 34 & 39.	@ bit 5:	0 	@ bit 4:	1 	@ bit 15:	1 	@ bit 14:	0		@ Mubus: select alternate function (CS) for chip select 5 (GPIO 33)	@ alt func code: 10 in bits 3 and 2	ldr r1, [r0, #GAFR1_L_OFFSET]	orr r1, r1, #GP34_FFRXD	orr r1, r1, #GP39_FFTXD	orr r1, r1, #GP33_nCS5	str r1, [r0, #GAFR1_L_OFFSET]	@ Select the output value '1' for these GPIO, others are '0'@	mov r4, r3, asl #15	@	orr r4, r4, r3, asl #23@	orr r4, r4, r3, asl #24@	orr r4, r4, r3, asl #25@	orr r4, r4, r3, asl #26@	str r4, [r0, #0x18]	@ GPSR0 = ...@	mov r4, r3, asl #1@	orr r4, r4, r3, asl #2@	orr r4, r4, r3, asl #7@	orr r4, r4, r3, asl #14@	orr r4, r4, r3, asl #15@	str r4, [r0, #0x1C]	@ GPSR1 = ...@	mov r4, r3, asl #14@	orr r4, r4, r3, asl #15@	orr r4, r4, r3, asl #16@	str r4, [r0, #0x20]	@ GPSR2 = ...@ Globally enable GPIO in Power Manager and Reset Control	mov r0, #0x40000000	add r0, r0, #0x00F00000	orr r4, r1, r3, asl #4	orr r4, r4, r3, asl #5	str r4, [r0, #0x4]	@ initialisation of a serial port	bl InitSerial	@ continue with initialisation 	bl InitSDRAM	@ cool ! We are ready to listen to the debugger	b DebugHandler@ Well.. we dont really take care of these.HandleUndef:	mov r5, #4	b FatalErrorHandleSWI:	mov r5, #8	b FatalErrorHandlePrefetchAbort:	mov r5, #0xC	b FatalErrorHandleDataAbort:	mov r5, #0x10	b FatalErrorHandleIRQ:	mov r5, #0x18	b FatalErrorHandleFIQ:	mov r5, #0x1C@ Error, blink LED and do not return.global FatalErrorFatalError:ErrorLp:    LED_RED_ON    mov r0, #0xFF000.ErrorLightOn:    subS r0, r0, #1    bne .ErrorLightOn    LED_RED_OFF    mov r0, #0xFF000.ErrorLightOff:    subS r0, r0, #1    bne .ErrorLightOff    b ErrorLp

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -