-
1. Re: Need help with component gpio definition
BoTa_264741 Jul 21, 2018 2:44 PM (in response to JoMe_264151)Hi Bob,
Attached is a demo component with variable number of buried pins (1 to 10).
Have a nice weekend
/odissey1
-
2. Re: Need help with component gpio definition
JoMe_264151 Jul 22, 2018 5:23 AM (in response to BoTa_264741)Thank you odissey1! That will do the trick.
Bob
-
3. Re: Need help with component gpio definition
BoTa_264741 Jul 27, 2018 11:43 PM (in response to JoMe_264151)Bob,
there is another solution available (project attached).
I have a question though. In such arrangement, pins can be accessed like
CyPins_SetPin(myPins_1_REG_0_0);
which is not very convenient.
Is there any way to access pins through their index? like
CyPins_SetPin(myPins_1_REG_0[0]); // this won't work
odissey1
-
4. Re: Need help with component gpio definition
JoMe_264151 Jul 28, 2018 2:55 AM (in response to BoTa_264741)1 of 1 people found this helpfulAs a standard there is not an option as you want.
My workaround is to define an array of pointers to functions and assign the wanted Pin_Write() APIs.
typedef void (*PinWrite)(uint8);
PinWrite const WritePins[] = {
{ &Servo_0_Write, &Servo_1_Write, &Servo_2_Write, &Servo_3_Write, &Servo_4_Write, &Servo_5_Write, }; Bob
-
5. Re: Need help with component gpio definition
BoTa_264741 Jul 29, 2018 8:36 PM (in response to JoMe_264151)Bob,
I managed to itemize pins in non-contiguous (spanning) mode. It is not quite the same as you mentioned above, but it works. Demo Project attached. The pointer array declaration came out way ugly, but it was the only way I managed it to work. Problem was due to the fact that the number of pins is variable, so its impossible to make pointers to non-existing pins.
Appreciate if you can point to a better solution.
/odissey1
-
6. Re: Need help with component gpio definition
JoMe_264151 Jul 30, 2018 3:00 AM (in response to BoTa_264741)As you could see in my attached project regarding the text-field expansion. My solution does not differ much from your approach.
Bob
-
7. Re: Need help with component gpio definition
pevoc_1249246 Aug 6, 2018 5:41 AM (in response to JoMe_264151)It is matter of taste of-course: you could use one control register of PSOC3/5 and wire connect the bits to the pins you want. Then you may need to modify the specific bit of the control register or can modify several bits at once.
-
8. Re: Need help with component gpio definition
JoMe_264151 Aug 6, 2018 7:22 AM (in response to pevoc_1249246)Thank you for the hint, but here I am working to create a component where the user will specify how many pins the component is actually using. The control register does not help in this case.
Bob
-
9. Re: Need help with component gpio definition
pevoc_1249246 Aug 6, 2018 8:37 AM (in response to JoMe_264151)It will get much more difficult as needed indeed but SHOULD still be possible for up to 32 IO-s. Some more hints: combining UDB-s and preprogrammed muxes which can be configured according to the selection from user. Never mind if no help from it.