Header Files
7-8
7.2.5 Inport/Outport Macros (ioports.h)
The ioports.h
header defines two macros and their associated functions,
which are used to access the TMS320C2x/C2xx/C5x I/O ports. The macros
are the easiest way to access the I/O ports and include:
-
inport
, a macro that reads a value from the specified port and returns the
value via the pointer
ret
-
outport
, a
macro that writes a value to the specified port and has no return
value
The functions include:
-
_inport x
, functions that access the port of the same number and return
that value as an int. These functions follow this syntax:
_inport
x
( )
where 0
≤
x
≤
15
-
_outport<x>
, functions that access the port of the same number and have
no return value. These functions follow this syntax:
_outport
x
(
int value
)
where 0
≤
x
≤
15
-
_in_port
, a function that reads an int from the specified port and returns
the value the function follows this syntax:
_in_port (int port)
-
_out_port
, a function that writes the output to the specified port and has
no return value. This function follows this syntax:
_out_port (int port, int value)
The _PSWITCH setting determines which method is used to implement the
inport and outport macros. If _PSWITCH is set to 0 (the default), a switch state-
ment is used that selects the correct _inport
x
or _outport
x
function. The 0 set-
ting works well when the port number is a constant, because the compiler opti-
mizes the switch statement into a simple call to the required function. However,
if the port number is a variable, the entire switch remains as you wrote it. There-
fore, when the port number is a variable, set _PSWITCH to 1 to call the correct
_in_port or _out_port function. The macros always work, regardless of the val-
ue of _PSWITCH.
Summary of Contents for TMS320C2x
Page 8: ...viii...
Page 69: ...2 47 C Compiler Description...
Page 159: ...6 36...
Page 226: ...8 6...