How to input port information into Cy_GPIO_Read()?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
air
Level 2
Level 2
First like given 50 sign-ins 10 questions asked

 

readVal  =  Cy_GPIO_Read(P12_0_PORT,  P12_2_PIN);

readVal = Cy_GPIO_Read((GPIO_PRT_Type *)base , pin);

 

The MCU I use is CY8c6136.
I am using Cy_GPIO_Read().

 - readVal = Cy_GPIO_Read(P12_0_PORT, P12_2_PIN);
I can do this when I know the port information of the corresponding pin.

If I do not know the port information of the pin, I am wondering how to enter the port information.

Port mapping is done in modus_toolbox,
This problem occurred while porting from another MCU.
May I get some information about this?

thanks.

 

 

 

0 Likes
1 Solution
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

air,

Using "Device Configurator" you select and assign a pin name. (See example below.)

Len_CONSULTRON_0-1658328283512.png

This pin name can be used as a port and pin name substitute (Alias) using the Cy_GPIO_xxxx() function calls.  In the case above for P13[7] there are three Aliases.

As an example, you would then use this Alias as a means to reference the pin.   (See code example below.)

 

readVal = Cy_GPIO_Read(CYBSP_USER_LED_PORT_NUM, CYBSP_USER_LED_PIN_NUM);

 

Len
"Engineering is an Art. The Art of Compromise."

View solution in original post

0 Likes
2 Replies
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

air,

Using "Device Configurator" you select and assign a pin name. (See example below.)

Len_CONSULTRON_0-1658328283512.png

This pin name can be used as a port and pin name substitute (Alias) using the Cy_GPIO_xxxx() function calls.  In the case above for P13[7] there are three Aliases.

As an example, you would then use this Alias as a means to reference the pin.   (See code example below.)

 

readVal = Cy_GPIO_Read(CYBSP_USER_LED_PORT_NUM, CYBSP_USER_LED_PIN_NUM);

 

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
air
Level 2
Level 2
First like given 50 sign-ins 10 questions asked

 

 

What I wanted to know is how to know the port name by pin name.
For example, using CYHAL_GET_PORT

or  __STATIC_INLINE GPIO_PRT_Type* Cy_GPIO_PortToAddr(uint32_t portNum);

Is the expression below correct?

static uint8_t in_gpio_read(void *port, uint32_t pin)
{
  return (uint8_t)(Cy_GPIO_Read(Cy_GPIO_PortToAddr(pin), pin));
}

 

thanks.

0 Likes