zoukankan      html  css  js  c++  java
  • [原创].HAL的不同方式访问字符器件的空间开销简单比较

    注:本文所述皆为查询方式的比对,中断方式下请读者自习研究比对。

    范例:/dev/jtag_uart

    Unix类型

    图1 系统库属性设置

    图1 系统库属性设置

    源代码:

    #include "system.h"
    #include "fcntl.h"
    #include "unistd.h"
    
    int main(void)
    {
      int fd; // file descriptor
      char msg[] = "Hello Nios!";
      
      fd = open("/dev/jtag_uart", O_WRONLY);
      write(fd, msg, sizeof(msg)-1);
      close(fd);
    
      return 0;
    }

    编译结果:

    Info: (hello_nios.elf) 2608 Bytes program size (code + initialized data).
    Info:                     8189 KBytes free for stack + heap.

    ANSI C

    图2 系统库属性设置

    图2 系统库属性设置

    源代码:

    #include "system.h"
    #include <stdio.h>
    
    int main (void)
    {
      FILE *fp; // file pointer
      char msg[] = "Hello Nios!";
      
      fp = fopen("/dev/jtag_uart", "w");
      fprintf(fp, msg);
      fclose(fp);
      
      return 0;
    }

    编译结果:

    Info: (hello_nios.elf) 43 KBytes program size (code + initialized data).
    Info:                     8148 KBytes free for stack + heap.

    C++流

    (略)

    参考

    1. Altera, HAL API Reference, 200905

    2. 李兰英等, NiosII嵌入式软核SOPC设计原理及应用, 200611, 北京航空航天大学出版社

  • 相关阅读:
    vue.api
    v-resource
    vue.js路由
    computed watch methods
    vue.js生命周期
    flex布局
    字符截取 slice substr substring
    原生Ajax书写
    jq动画
    css 3动画
  • 原文地址:https://www.cnblogs.com/yuphone/p/1617892.html
Copyright © 2011-2022 走看看