Hi Farhan,
Yes, you can achieve this configuration in simulink.
To begin with you may need to add the following lines of code in the system initialize block under 'System init function execution code' section. These blocks are part of custom code blocks found under simulink coder.
EALLOW;
//enable the pull up
GpioCtrlRegs.GPAPUD.bit.GPIO0 = 0;
//Load output latch and drive pin high
GpioDataRegs.GPASET.bit.GPIO0 = 1;
//Pin muxing selection
GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0;
//Enable output
GpioCtrlRegs.GPADIR.bit.GPIO0 = 1;
EDIS;
As an example using this code I would set GPIO0 pin to output and set it high to begin with.
Lateron you can set the same pin as input by using the memory copy block.
For this to happen we need to update the GPADIR register as below:
//Enable input
EALLOW;
GpioCtrlRegs.GPADIR.bit.GPIO0 = 0;
EDIS;
Using memory copy block we can read-modify-write particular register bitfield.
Attached model is able to acheive the same.
Notice the use of custom code options in the second memory copy block.
Regards,
Venkatesh C
Best Answer