Defining pins-PSOC 6

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

cross mob
lock attach
Attachments are accessible only for community members.
aliissa02
Level 4
Level 4
100 sign-ins 50 replies posted 5 likes given

Hello,

I am trying to assign a list of pins to a variable. Is it possible to do it like this?(Please see picture attached)

Thank you

0 Likes
1 Solution
Arpit_S
Moderator
Moderator
Moderator
50 likes received 250 replies posted 100 solutions authored

Hi @aliissa02 ,

 

You can do it. This won't be an issue but if you assign the port macros as an element in the Array, while calling a function you cannot simply write LED_ports[i]. You always have to check what that macro is pointing to, Sometimes it may point to some memory location through a pointer, then you have to type cast the the argument.

Refer to below mentioned code:
int LED_PORT[2]={LED_Blue_P11_1_PORT, LED_Blue_P11_1_NUM};

Cy_GPIO_Clr((GPIO_PRT_Type*)LED_PORT[0], LED_PORT[1]);

Cy_GPIO_Set((GPIO_PRT_Type*)LED_PORT[0], LED_PORT[1]);



Above mentioned line is code is equivalent to below mentioned code:

Cy_GPIO_Clr(LED_Blue_P11_1_PORT, LED_Blue_P11_1_NUM);

Cy_GPIO_Set(LED_Blue_P11_1_PORT, LED_Blue_P11_1_NUM);

 

Kind regards

Arpit Srivastav

View solution in original post

0 Likes
1 Reply
Arpit_S
Moderator
Moderator
Moderator
50 likes received 250 replies posted 100 solutions authored

Hi @aliissa02 ,

 

You can do it. This won't be an issue but if you assign the port macros as an element in the Array, while calling a function you cannot simply write LED_ports[i]. You always have to check what that macro is pointing to, Sometimes it may point to some memory location through a pointer, then you have to type cast the the argument.

Refer to below mentioned code:
int LED_PORT[2]={LED_Blue_P11_1_PORT, LED_Blue_P11_1_NUM};

Cy_GPIO_Clr((GPIO_PRT_Type*)LED_PORT[0], LED_PORT[1]);

Cy_GPIO_Set((GPIO_PRT_Type*)LED_PORT[0], LED_PORT[1]);



Above mentioned line is code is equivalent to below mentioned code:

Cy_GPIO_Clr(LED_Blue_P11_1_PORT, LED_Blue_P11_1_NUM);

Cy_GPIO_Set(LED_Blue_P11_1_PORT, LED_Blue_P11_1_NUM);

 

Kind regards

Arpit Srivastav

0 Likes