void GpioInit(void) { // Set to inputs FIO0DIR = \ FIO1DIR = \ FIO2DIR = \ FIO3DIR = \ FIO4DIR = 0;
// clear mask registers FIO0MASK =\ FIO1MASK =\ FIO2MASK =\ FIO3MASK =\ FIO4MASK = 0;
// Reset all GPIO pins to default primary function PINSEL0 =\ PINSEL1 =\ PINSEL2 =\ PINSEL3 =\ PINSEL4 =\ PINSEL7 =\ PINSEL8 =\ PINSEL9 =\ PINSEL10 = 0; }
How can I change PINSEL1 with this code?
A much better question. What problem do you see with changing PINSEL1 - exactly why are you stuck? It isn't exactly hard to change the value of any of the configuration registers...
void GpioInit(void) { // Set to inputs FIO0DIR = \ FIO1DIR = \ FIO2DIR = \ FIO3DIR = \ FIO4DIR = 0; // clear mask registers FIO0MASK =\ FIO1MASK =\ FIO2MASK =\ FIO3MASK =\ FIO4MASK = 0; // Reset all GPIO pins to default primary function PINSEL0 =\ PINSEL1 =55; PINSEL2 =\ PINSEL3 =\ PINSEL4 =\ PINSEL7 =\ PINSEL8 =\ PINSEL9 =\ PINSEL10 = 0; } compiler boms out with an error.
And what "error", exactly, does it "bomb-out" with?
Read the error message;
Think what it is telling you;
Fix the mistakes in your source code.
Simples!
Hint: you should have a 'C' textbook to hand - check the usage of the backslash...
Well, he just has read his textbook but missed the difference between the preprocessor requirements and the C compiler requirements. So he wants the preprocessor to merge multiple lines even when there is no need.
You girls are so smart.
But you have now taken a second look at the requirements/needs for the \ character when used last on a text line? And how the requirements differs between preprocessor lines like a long #define and a really long C expression that is too long to fit on a single line?
But why even do that?
Well, it isn't too common that a C expression might be long.
But the OP should by now have figured out that the C compiler does not need any \ at the end of the lines to concatenate individual text lines into a single line. Not even when someone needs to print a very long text string is it needed to use any \ to split the text string over multiple lines.
I feel increasingly superfluous to this discussion. You are free to discuss it amongst yourselves.
We are.
It is very pleasing to hear you acknowledge the fact. You two are sure to both learn something new from your discussion.
And have you learned anything - like how to deal with compiler messages, where the backspace is & isn't used for line continuation, and whether those huge long expressions are necessary or desirable...?
Actually, I rather doubt that backspace is used anywhere for line continuation!!
(yawn)
you two carry on without me.
K Panjaab,
You should first remove all spaces behind \.
void GpioInit(void) { // Set to inputs FIO0DIR = \ // ^ A space at above position.
Then
PINSEL0 =\ PINSEL1 =55;
You set both PINSEL0 and PINSEL1 to 55. (0x37)