关键词ioport的作用是什么

The ioport keyword enables access to the I/O port space of the C54x devices. The keyword has the form:

ioport type port hex_num

ioport is the keyword that indicates this is a port variable.
type must be char, short, int, or the unsigned variable.
porthex_num  refers to the port number. The hex_num argument is a hexadecimal number.

All declarations of port variables must be done at the file level. Port variables declared at the function level are not supported. Do not use the ioport keyword in a function prototype.
For example, the following code declares the I/O port as unsigned port 10h, writes a to port 10h, then reads port 10h into b:

 ioport unsigned port10; /* variable to access I/O port 10h */
 int func ()
 {
     ...
     port10 = a;         /* write a to port 10h             */
     ...
     b = port10;         /* read port 10h into b            */
     ...
 }
The use of port variables is not limited to assignments. Port variables can be used in expressions like any other variable. Following are examples:

 a = port10 + b;  /* read port 10h, add b, assign to a       */
 port10 += a;     /* read port 10h, add a, write to port 10h */
In calls, port variables are passed by value, not by reference:

call(port10);    /* read port 10h and pass (by value) to call */
call(&port10);    /* invalid pass by reference! */

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值