新聞中心

        EEPW首頁 > 嵌入式系統 > 設計應用 > s3c2440的簡單BOOTLOADER

        s3c2440的簡單BOOTLOADER

        作者: 時間:2016-11-10 來源:網絡 收藏
        調試了很久終于成功啟動了板子,這個程序分兩個部分,一個是啟動代碼boot.s負責初始化硬件并拷貝前4k的程序到內存中執行。另外一個是主程序文件main.c,main設置UART并使用串口循環輸出打印一個類似于shell的界面,可以接收命令,但暫時沒做命令解釋,功能還不全,主要是為了看看能不能實現基本的BOOTLOADER功能。

        本文引用地址:http://www.104case.com/article/201611/317181.htm

        mian.c
        #define BUF_SIZE 100
        #define GPHCON (*(volatile unsigned long *)0x56000070)
        #define GPHUP (*(volatile unsigned long *)0x56000078)

        #define ULCON0 (*(volatile unsigned long *)0x50000000)
        #define UCON0 (*(volatile unsigned long *)0x50000004)
        #define UFCON0 (*(volatile unsigned long *)0x50000008)
        #define UTRSTAT0 (*(volatile unsigned long *)0x50000010)
        #define UTXH0 (*(volatile unsigned long *)0x50000020)
        #define URXH0 (*(volatile unsigned long *)0x50000024)
        #define UBRDIV0 (*(volatile unsigned long *)0x50000028)

        void init_uart();
        void newline();
        void bzero(char *buf,int size);
        void do_cmd(char *s);
        void send_char(char ch);
        void send_msg(char *s);
        void get_msg(char *buf,int size);
        void print_shell();
        void delay(int i);

        void main(void)
        {
        init_uart();

        char msg[BUF_SIZE];

        while(1)
        {
        bzero(msg,BUF_SIZE);
        newline();
        print_shell();
        get_msg(msg,BUF_SIZE - 2);
        do_cmd(msg);
        // delay(4);
        }
        }


        void init_uart()
        {
        GPHCON &= ~(0xf0);
        GPHCON |= 0xa0;
        GPHUP = 0xc;

        ULCON0 = 0x03;
        UCON0 = 0x05;
        UFCON0 = 0;
        UBRDIV0 = 27;
        }

        void newline()
        {
        send_char(r);
        send_char(n);
        }

        void bzero(char *buf,int size)
        {
        int i;

        for(i = 0;i < size;i++)
        buf[i] = 0;
        }

        void send_char(char ch)
        {
        while(!((UTRSTAT0 >> 1) & 1));
        UTXH0 = ch;
        }

        void send_msg(char *s)
        {
        while(*s !=

        主站蜘蛛池模板: 卓资县| 海安县| 东莞市| 图木舒克市| 石阡县| 平度市| 安庆市| 米林县| 深泽县| 分宜县| 文登市| 常宁市| 江孜县| 炉霍县| 扶绥县| 谷城县| 浙江省| 南和县| 防城港市| 京山县| 清徐县| 香格里拉县| 黄平县| 张家港市| 邯郸县| 红安县| 恭城| 当涂县| 施甸县| 保定市| 宣威市| 承德县| 湖州市| 乐业县| 彩票| 沙湾县| 延边| 舒城县| 法库县| 根河市| 巴林右旗|