硬體平台:jz2440
實現功能:向串列埠軟體實現輸出putchar函式
start.s --> 設定堆疊,關閉看門狗,初始化時鐘,初始化sdram
init.c -->初始化函式
uart.c -->初始化串列埠暫存器
uart.h -->
main.c -->
start.s原始碼:
.externmain
.text
.global
_start
_start:
ldr sp,=4096
bl watchdog_init
bl clock_init
bl sdram_init
bl copy_steppingstone_to_sdram
ldr pc,=sdram
sdram:
ldr sp,=0x34000000
ldr lr,=main_return
ldr pc,=main
main_return:
b main_return
init.c 原始碼:
//watchdog
#define wtcon (*(volatile unsigned long *)0x53000000)
//clock
#define locktime (*(volatile unsigned long *)0x4c000000)
#define mpllcon (*(volatile unsigned long *)0x4c000004)
#define clkdivn (*(volatile unsigned long *)0x4c000014)
//sdram
#define bwscon (*(volatile unsigned long *)0x48000000)
#define bankcon0 (*(volatile unsigned long *)0x48000004)
#define bankcon1 (*(volatile unsigned long *)0x48000008)
#define bankcon2 (*(volatile unsigned long *)0x4800000c)
#define bankcon3 (*(volatile unsigned long *)0x48000010)
#define bankcon4 (*(volatile unsigned long *)0x48000014)
#define bankcon5 (*(volatile unsigned long *)0x48000018)
#define bankcon6 (*(volatile unsigned long *)0x4800001c)
#define bankcon7 (*(volatile unsigned long *)0x48000020)
#define refresh (*(volatile unsigned long *)0x48000024)
#define banksize (*(volatile unsigned long *)0x48000028)
#define mrsrb6 (*(volatile unsigned long *)0x4800002c)
#define mrsrb7 (*(volatile unsigned long *)0x48000030)
void watchdog_init(void
)void clock_init(void
)void sdram_init(void
)void copy_steppingstone_to_sdram(void
)}
uart.c 原始碼:
//uart
#define ulcon0 (*(volatile unsigned long *)0x50000000)
#define ucon0 (*(volatile unsigned long *)0x50000004)
#define ufcon0 (*(volatile unsigned long *)0x50000008)
#define umcon0 (*(volatile unsigned long *)0x5000000c)
#define utrstat0 (*(volatile unsigned long *)0x50000010)
#define uerstat0 (*(volatile unsigned long *)0x50000014)
#define utxh0 (*(volatile unsigned char *)0x50000020)
#define urxh0 (*(volatile unsigned char *)0x50000024)
#define ubrdiv0 (*(volatile unsigned long *)0x50000028)
//gph
#define gphcon (*(volatile unsigned long *)0x56000070)
#define gphdat (*(volatile unsigned long *)0x56000074)
#define gphup (*(volatile unsigned long *)0x56000078)
void uart0_init(void
)unsigned
char getc(void
)void putc(unsigned char
date)
uart.h 原始碼:
#ifndef _uart_h_#define _uart_h_
void uart0_init(void
);unsigned
char getc(void
);void putc(unsigned char
date);
#endif
main.c 原始碼:
#include"uart.h
"int main(void
)
連線指令碼uart.lds :
sections.rodata :
.dtat :
.bss :
}
makefile:
objs:=start.o init.o uart.o main.ouart.bin:$(objs)
arm-linux-ld -tuart.lds -o uart_elf $^arm-linux-objcopy -o binary -s uart_elf $@
arm-linux-objdump -d -m arm uart_elf >uart.dis
%.o:%.s
arm-linux-gcc -o $@ -c $<
%.o:%.c
arm-linux-gcc -o $@ -c $rm -f *.o *.bin *.dis uart_elf
nand flash裸機程式
開發板 mini2440 nand flash k9f2g08u0b2,56m arm處理器裸機開發實戰 機制而非策略 知識點梳理 頁的絕對位址與相對位址 在nand.c中有乙個函式void rdnf2sdram 它的功能是將nand flah的內容複製到sdram,如下 nand flash的頁讀...
Nand Flash 裸機程式
硬體平台 jz2440 實現功能 初始化 nand flash 和 sdram,並將 從 nand flash 拷貝到 sdram。start.s 上電初始化 nand 與sdram nand.c nand flash 初始化函式 sdram.c sdram 初始化函式 leds.c led 閃爍 ...
裸機程式 I2C裸機
1 平時sda和scl常高 2 開始訊號 scl保持高電平,sda有乙個下降沿脈衝 3 資料在scl低電平時變化,在scl高電平時穩定 裝置位址共7bit,其中1010固定,a2a1a0取決於連線。讀寫的確定由第8位確定。在第9 個clk 裡,i2c 主機釋放sda,由從機驅動驅動sda.若從機發現...