Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write custom versions of arduino functions? #13

Open
dhiltonp opened this issue Jan 10, 2013 · 9 comments
Open

Write custom versions of arduino functions? #13

dhiltonp opened this issue Jan 10, 2013 · 9 comments

Comments

@dhiltonp
Copy link
Owner

Arduino's pinMode, (digital/analog)(Read/Write) take up 850 bytes all together.

Writing non-generalized versions for our library could reduce our flash footprint. Investigate costs/benefits.

@dhiltonp
Copy link
Owner Author

Maybe we can pull in this patch:

http://code.google.com/p/arduino/issues/detail?id=140

@dhiltonp
Copy link
Owner Author

I've pulled in this library, which is the implementation discussed here.

pinMode -> pinModeFast
digitalWrite -> digitalWriteFast
analogWrite -> analogWriteFast

This saves around 250 bytes, and reduces execution time.

@dhiltonp
Copy link
Owner Author

arduino-lite seems to be poorly maintained, but it should have a macro for analogWrite, which could be useful. No such optimization seems to exist for analogRead.

@dhiltonp
Copy link
Owner Author

http://maxembedded.com/2011/06/20/the-adc-of-the-avr/

This link demonstrates how to convert analog to digital on the avr. We currently use similar code in read_avr_voltage.

@dhiltonp
Copy link
Owner Author

adc reading implemented in read_adc.

@joshgoebel
Copy link

If we have those functions now isn't this completed?

@dhiltonp
Copy link
Owner Author

I've not verified that all arduino functions are replaced (doable by compiling the library directly in avr-gcc)

@joshgoebel
Copy link

Well, it's only a replacement if all the pins and values written are constants as determined by the compiler and therefor the dynamic code paths can be optimized out. So I assume you mean confirm that that is the case with the default compile of hexbright.h?

How were you planning to confirm that? Dissassembly?

@dhiltonp
Copy link
Owner Author

Part of the desire was to make this library usable outside of the arduino environment, compiling via avr-gcc while including/linking no arduino code.

At this point, I believe most of the inefficiencies of the arduino libraries have been resolved (interesting catch on the linked ram, by the way), so this is much less of a priority than before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants