S5pc100裸奔全攻略之串口

作者:赵孝强,华清远见嵌入式培训中心讲师。

以下是s5pc100的不带系统串口的程序,需要map.lds,Makefile,s5pc100,文件,用v7交叉工具链,以上文件可在www.farsight.com.cn下载到。

#include "s5pc100.h"
        unsigned char *p = "farsight test uart program !";
        void uart_sendbyte(unsigned char data)
        {
                UART0.UTXH0 = data;
                while(!(UART0.UTRSTAT0 & 0X2));
        }
        void uart_sendstring(const unsigned char *pstr)
        {
                while(*pstr != '\0')
                uart_sendbyte(*pstr++);
        }
        int main()
        {
                unsigned int temp = 0;
                GPA0.GPA0CON = 0X22;        // set gpa0 uart mode
                UART0.UFCON0 = 0X00;        //UART channel 0 FIFO control register, FIFO disable
                UART0.UMCON0 = 0X00;        //UART chaneel 0 MODEM control register, AFC disable
                UART0.ULCON0 = 0X03;        //per frame 8 bin
                UART0.UCON0 = 0X305;        //
                UART0.UBRDIV0 = 0X23;        // Baud rate divisior register 0
        //      UART0.UDIVSLOT0 = 0X3;
                GPG3.GPG3DAT = 0X00;
                uart_sendstring(p);
                while(1)
                {
                        while(!(UART0.UTRSTAT0 & 0X1));
                        uart_sendstring("your enter char is");
                        uart_sendbyte('\n');
                        GPG3.GPG3DAT = 0XF;
                        temp = UART0.URXH0;
                        UART0.UTXH0 = temp;
                        while(!(UART0.UTRSTAT0 & 0X2));
                        uart_sendbyte('\n');
                        GPG3.GPG3DAT = 0X0;
                        for(temp = 1000000; temp !=0; temp--);
                }
                return 0;
        }

嵌入式及3G相关资源及学习请点击:嵌入式开发视频 android开发视频 android培训 3G培训 QT培训 QT开发视频 物联网培训 物联网技术视频 嵌入式学习   

你可能感兴趣的:(串口)