chuwangmvp 发表于 2012-3-23 19:35:33

s3c2440头文件的一些问题

自己在看国嵌视频的时候,在写裸机程序时,视频里都是直接把那些.c   .s.h的文件直接拷到自己所创的工程目录下的(我用的是ADS1.2),那以后自己写程序的时候还是要这么拷的吗?感觉这么写心里很没底的,这些文件是要理解的呢还是说自己也能写的?

wgyoume 发表于 2012-4-19 19:04:29

你自己写裸机程序时,要用到的函数或寄存器等,如果没有定义能用么?一般就定义在头文件里了。还是自己写吧,这样自己也熟悉一下

chuwangmvp 发表于 2012-4-22 10:23:03

wgyoume 发表于 2012-4-19 19:04 static/image/common/back.gif
你自己写裸机程序时,要用到的函数或寄存器等,如果没有定义能用么?一般就定义在头文件里了。还是自己写吧 ...

恩。。。当时是写到后来越写越虚了的。。。

wgyoume 发表于 2012-4-22 17:34:38

chuwangmvp 发表于 2012-4-22 10:23 static/image/common/back.gif
恩。。。当时是写到后来越写越虚了的。。。

呵呵,慢慢来吧。推荐一本书《嵌入式Linux应用开发完全手册》韦东山

chuwangmvp 发表于 2012-4-23 20:55:16

wgyoume 发表于 2012-4-22 17:34 static/image/common/back.gif
呵呵,慢慢来吧。推荐一本书《嵌入式Linux应用开发完全手册》韦东山

恩。。。这本买了,,,正在学习中。。。。

wgyoume 发表于 2012-4-25 12:28:03

本帖最后由 wgyoume 于 2012-4-25 12:40 编辑

可以在网上下电子书的,不过就是不是太清晰,不过将就了。
我最近遇到一个问题,就是在对S3C2440A进行串口调试的时候,使用串口1,对他进行发送一个字符,这是可以的。源码:
#define    TXD1READY    (1 << 2)
extern void putc(char c)
{
    while(!(UTRSTAT1 & TXD1READY))
      ;
    UTXH0L = c;
}
和PC机通信,一个一个的字符发送,能正常通信
但是,如果用成这样
extern void puts(const char *str)
{
      while(*str)
         putc(*str++);
}

也就是发送字符串的时候,在PC机上接收的字符全是乱码,不知道是怎么回事。
就算是这样
char str[] = "abcdefg";
int i;
for(i = 0;i < 5;i++)
      putc(str[ i   ]);

   一样的,在PC机上接收的数据还是全部都是乱码。很郁闷,不知道你遇到过这种问题没有


chuwangmvp 发表于 2012-4-27 13:38:12

wgyoume 发表于 2012-4-25 12:28 static/image/common/back.gif
可以在网上下电子书的,不过就是不是太清晰,不过将就了。
我最近遇到一个问题,就是在对S3C2440A进行串口 ...

看了下国嵌的示例,它在发送字符串的时候,用的是:
void Uart_Printf(char *fmt,...)
{
    va_list ap;
    char string;

    va_start(ap,fmt);
    vsprintf(string,fmt,ap);
    Uart_SendString(string);
    va_end(ap);
}
其中几个调用的函数如下:
typedef int *va_list;
   /*
    * an array type suitable for holding information needed by the macro va_arg
    * and the function va_end. The called function shall declare a variable
    * (referred to as ap) having type va_list. The variable ap may be passed as
    * an argument to another function.
    * Note: va_list is an array type so that when an object of that type
    * is passed as an argument it gets passed by reference.
    */


#define va_start(ap, parmN) (void)(*(ap) = __va_start(parmN))
   /*
    * The va_start macro shall be executed before any access to the unnamed
    * arguments. The parameter ap points to an object that has type va_list.
    * The va_start macro initialises ap for subsequent use by va_arg and
    * va_end. The parameter parmN is the identifier of the rightmost parameter
    * in the variable parameter list in the function definition (the one just
    * before the '...'). If the parameter parmN is declared with the register
    * storage class an error is given.
    * If parmN is a narrow type (char, short, float) an error is given in
    * strict ANSI mode, or a warning otherwise.
    * Returns: no value.
    */

void Uart_SendString(char *pt)
{
    while(*pt)
      Uart_SendByte(*pt++);
}

#define va_end(ap) ((void)(*(ap) = 0))
   /*
    * The va_end macro facilitates a normal return from the function whose
    * variable argument list was referenced by the expansion of va_start that
    * initialised the va_list ap. If the va_end macro is not invoked before
    * the return, the behaviour is undefined.
    * Returns: no value.
    */

    #ifdef __cplusplus
      }/* extern "C" */
    #endif

    #ifdef __EDG_RUNTIME_USES_NAMESPACES
      }/* namespace std */
    #endif
#endif /* __STDARG_DECLS */

#ifdef __EDG_RUNTIME_USES_NAMESPACES
    #ifndef __STDARG_NO_EXPORTS
      using std::va_list;
    #endif
#endif

#endif


就照视频试验过次,,对于这个的解释忘了,好像是va_end(ap);va_start(ap,fmt);很重要,,,我在看看视频,再理解下再和你讨论下咯。。。

chuwangmvp 发表于 2012-4-27 14:48:56

wgyoume 发表于 2012-4-25 12:28 static/image/common/back.gif
可以在网上下电子书的,不过就是不是太清晰,不过将就了。
我最近遇到一个问题,就是在对S3C2440A进行串口 ...

刚弄你的代码替换申嵌的代码,还是可以的咯,暂时还不知道是个什么情况

wgyoume 发表于 2012-4-27 16:10:05

感觉和书上说的IO重定向有一点相仿,不知道是不是。
页: [1]
查看完整版本: s3c2440头文件的一些问题