Boo0ns / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

RX interrupt for programmers #513

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I currently have modified the source to be able to except a function pointer 
upon calling Serial.begin. I overloaded the function so that both the original 
Serial.begin(baud) and Serial.begin(baud,function pointer). This function will 
then be executed in the store_char function as long as the interrupt Callback 
variable is not = NULL. This edition while i could be a cause to bugs allows 
the programmer to decide if they want to take on the challenge of using the 
interrupts.

We are trying to use an arduino to process data from a bunch of sensors and 
also interact with a bus routine. The bus will request data from the sensors. 
These sensors need to be polled and averaged in order to get accurate readings. 
The best way to implement this is to have a running average and be constantly 
polling the sensors and then upon RX request arrival respond with most up to 
date date then continue polling sensors. The code I have written works but 
hasn't been 100% thoroughly tested.

I see no compatibility issues from previous versions, the only one might have 
been that I changed the parameters of serial.begin but due to overloading this 
has no effect on backwards compatibility. One thing that might be an issue is 
arduino's with multiple usarts. To rectify this simply make the users function 
provided accept and int param which identifies which USART triggered the 
interrupt.

If my code is used my only request is that I be added as a contributor and that 
umassamherstm5.org be added possibly as a link seeing as we are a university 
Establishment and we often use arduino.

FILES INCLUDED
Modified hardwareserial.c and .h
and a test pde file that does a simple test of the interrupt function using the 
serial monitor.

Original issue reported on code.google.com by onlinege...@gmail.com on 26 Mar 2011 at 5:27

Attachments:

GoogleCodeExporter commented 9 years ago
Arduino 1.0 will have a serialEvent() function that works like this.

Original comment by dmel...@gmail.com on 14 May 2011 at 4:41

GoogleCodeExporter commented 9 years ago
Great to hear. Its wicked useful.
Best of luck.

-TJ

Original comment by onlinege...@gmail.com on 15 May 2011 at 10:30