PinMux-API to set pin mode (Output/Input)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PinMux-API to set pin mode (Output/Input)

973 Views
bdharma96
Contributor II

Hi 

  I'm working with MPC5775E in S32 studio (FreeRTOS SDK),

By selecting the PinMux functional properties I can set the pin mode as either OUTPUT or INPUT. But I need to change the mode during run time, in order to write and read the same pin. Is there any API available for setting Pin Mode ?

Labels (1)
Tags (1)
3 Replies

843 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

there are following functions:

pastedImage_1.png

And here is an example from hello world project:

pastedImage_2.png

Regards,

Lukas

0 Kudos

843 Views
bdharma96
Contributor II

Hi Lukas Zadrapa,
                            I'm trying to mimic I2C on MPC5775E using bitbang method. for that i need two gpio's(SCL,SDA) in which one is continued to be used as output, the other one has to be set as output and input during runtime to read the ACK signal from the slave.
for example 

void I2C_out(unsigned char j) //I2C Output
{
int n;
unsigned char d;
d = j;

for(n = 0; n < 8; n++)
{
if ( (d & 0x80u) == 0x80u)
{
PINS_DRV_SetPins(ports[SDA_pin], (1 << I2C[SDA]));
}
else
{
PINS_DRV_ClearPins(ports[SDA_pin], (1 << I2C[SDA]));
}
d = (d << 1);
PINS_DRV_ClearPins(ports[SCL_pin], (1 << I2C[SCL]));
vTaskDelay(CMD_DELAY);
PINS_DRV_SetPins(ports[SCL_pin], (1 << I2C[SCL]));
vTaskDelay(CMD_DELAY);
PINS_DRV_ClearPins(ports[SCL_pin], (1 << I2C[SCL]));
}

// ? setPinModeInput(&MODULE_P15,5,IfxPort_InputMode_pullUp);

PINS_DRV_SetPins(ports[SCL_pin], (1 << I2C[SCL]));
while (PINS_DRV_ReadPins(ports[SDA_pin]) == 1);

// ? setPinModeOutput(&MODULE_P15,5,IfxPort_OutputMode_pushPull,IfxPort_OutputIdx_general);

vTaskDelay(CMD_DELAY);
PINS_DRV_ClearPins(ports[SCL_pin], (1 << I2C[SCL]));
vTaskDelay(CMD_DELAY);

}



I need to know whether there is any api to set PIN MODE in our s32ds. please reply if u can help me out.

0 Kudos

843 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

the "mode" of GPIO is controlled by input buffer enable bit IBE and by output buffer enable bit (OBE) in SIU_PCRn registers. This can be done using the functions mentioned above. Notice output buffer and input buffer can be enabled at the same time.

And also notice that GPIO can be configured as open drain using ODE bit in SIU_PCRn register. So, in fact, you don't need to reconfigure the pins in runtime.

Regards,

Lukas