- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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