I am new to using atxmega chips (atxmega128a1 specifically) so sorry if my question is not worded in a "professional" way!
So far in order to set or clear a pin I use the following programming in C:
PORTA.OUTSET = PIN1_bm;
PORTA.OUTCLR = PIN1_bm;
The problem with this for me, is that the individual pin definition is on the right hand side of the "=" sign. I would like to be able to set a pin individually in this fashion:
PA0 = 1;
This would be useful to me as I have many individual pins on different ports that need to be "virtually grouped" in the code as they are doing related functions.
For example I have four motor "enable" pins set on different pins of 4 separate ports. Currently if i want to turn them on simultaneously I have to do this:
PORTE.OUTSET = PIN5_bm;
PORTH.OUTSET = PIN0_bm;
PORTJ.OUTSET = PIN3_bm;
PORTK.OUTSET = PIN6_bm;
I want to keep my naming conventions and port names clear and easy to read such that I can group these outputs into some sort of structure and simply write:
Motor1_Enable = 1;
How can I manipulate C to do this for me???
Hope this is clear! Thankyou!
motorEnableSet(n,en)
wheren
is your motor index anden
is 0,1 for enabled,disabled. Keeps the code clean and makes your intent clear. \$\endgroup\$