Go Down

Topic: add new function to wiring_digital.c (Read 6430 times) previous topic - next topic

BKNio

Hello!
I am trying to add new function "MydigitalWrite" to wiring_digital.c () (\arduino-0017\hardware\cores\arduino)

When I try to compile:
In function 'void loop()':
error: 'MydigitalWrite' was not declared in this scope

How to win this problem?




retrolefty

#1
Jan 22, 2011, 08:03 pm Last Edit: Jan 22, 2011, 08:06 pm by retrolefty Reason: 1
Hello!
Quote
I am trying to add new function "MydigitalWrite" to wiring_digital.c () (\arduino-0017\hardware\cores\arduino)

When I try to compile:
In function 'void loop()':
error: 'MydigitalWrite' was not declared in this scope

How to win this problem?


There should be no reason to modify the core function in the wiring library.

Just write your new function directly following the loop() function in your sketch:

void MydigitalWrite( int argument1, int argument2, etc.)
{
  //your new code
  // more code
}

Then you can use your new function anywhere in the setup or loop function of your sketch.

Lefty

BKNio

there is one reason
standart digitalwrite spends a lot of time to switch on or switch of massive of pins
i think i can do it, if i modify standart digitalWrite

Coding Badly


Why do you want to modify digitalWrite?  To make it faster?

BKNio

No. i want create new to switch on or off massive of pins
i cant use like this
Code: [Select]

for(int i=0;i<10;i++)
{
digitalWrite(i,HIGH);
}
because it spend a lot of time

BKNio

i only need add new function to \arduino-0017\hardware\cores\arduinowiring_digital.c

Coding Badly

Quote
No. i want create new to switch on or off massive of pins

Have you considered direct port access?

BKNio

Yes but i found nothing
How i can do it? there is special function?

BKNio

i want to do it like this

Code: [Select]
     
out = portOutputRegister(port);
if (val == LOW) *out &= ~bit;
     else *out |= bit;

that is why i need to add new function

Coding Badly

Quote
Yes but i found nothing

http://www.google.com/search?q=arduino+port

Quote
How i can do it? there is special function?

http://www.arduino.cc/en/Reference/PortManipulation


Go Up