iLLD_TC27xC  1.0
How to use the PORT I/O driver?
Collaboration diagram for How to use the PORT I/O driver?:

The PORT I/O driver provides several functions to easily configure and read pins. The configuration includes input/output, mode, pad driver strength and state. For referencing the pins and their ports a IfxPort_PinMap is available as well.

In the following sections it will be described, how to integrate the driver into the application framework.

Preparation

Include Files

Include following header file into your C code:

Conifguration Table

Specify the used pins, their modes and (for outputs) the pad driver strength:
Note: For inputs the pad driver strength is only a dummy.

Note: the IfxPort_* pins are defined in IfxPort_PinMap

Port Initialisation

Assemble the final configuration structure:

const IfxPort_Io_Config conf = {
sizeof(configPin)/sizeof(IfxPort_Io_ConfigPin),
(IfxPort_Io_ConfigPin *)configPin
};

Call the initialisation function:

Now the pins are configured as specified.

Misc. Functions of the Standard Layer

Pin Mode Configuration

Generally, you can use one function for both inputs and outputs to set the desired mode.

// configure P33.0 as general output

For inputs use the IfxPort_setPinModeInput function:

// configure P33.0 as input with pullUp

For outputs use the IfxPort_setModeOutput function:

// configure P33.0 as output in general pushPull mode

If the pin is an output, the pad driver should be configured as well:

Reading Input State

Read the state of a single pin:

uint8 state = IfxPort_getPinState(&MODULE_P33, 0); // read P33.0

Setting Output State

Generally, you can use one function to set an output pin high or low or to toggle it.

IfxPort_setPinState(&MODULE_P33, 0, IfxPort_State_toggled); // toggle P33.0

An output pin can be set high as following:

IfxPort_setPinHigh(&MODULE_P33, 0); // P33.0 = 1

An output pin can be set low as following:

IfxPort_setPinLow(&MODULE_P33, 0); // P33.0 = 0

Configure Emergency Function

Enable emergency stop for P33.0:

The driver also provides a function to disable this feature.