Pages: [1]   Go Down
Author Topic: programmable interrupts  (Read 481 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 118
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I want to use the USART_RX_vect interrupt, but it is used in wiring_serial.c. It seems silly to hobble the hardware like this.

Moving the interrupt definition to a header file would allow for a lot more flexibility.
Code:
#ifndef SERIAL_ISR
#define SERIAL_ISR
  // define USART_RX_vect interrupt
#endif

Putting "#define SERIAL_ISR" at the top of a PDE file would stop the Arduino library from grabbing the interrupt.

Moving the interrupt definition to the header would mean some variables contained in wiring_serial would need to be made global... specifically rx_buffer, rx_buffer_head, and rx_buffer_tail. These could all be put into a single struct to not pollute the namespace too much.

The other option I see is to make the interrupt call another function via a function pointer, and allow that function pointer to be redefined(it would default to the normal serial receive routine). Using a function pointer might cause some performance problems...
« Last Edit: June 16, 2009, 01:19:20 pm by gabebear » Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2857
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It sounds to me like you are ready to "graduate" from the Arduino development environment to a full-fledged C/C++ environment in which nothing is hidden or packaged in third-party libraries.

Yes, it is tempting to fix it with suggestions like yours, but at some point this feature creep would get in the way of what Arduino is supposed to be: simple. There are all sorts of places in the code where things can be customized, pointerized, #define'd, etc. but I think it's best left simple.

EDIT: Ah yes...here is the quote I was looking for:

"Every program in development at MIT expands until it can read mail."
« Last Edit: June 16, 2009, 02:22:52 pm by RuggedCircuits » Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 118
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ya, I already have Eclipse setup with the AVR plugin (which is pretty kick ass). I also have a decent Xcode project setup.

The main reason I want to use the Arduino IDE is because I want to be able to distribute the program... hex files aren't very friendly. I probably just need to bundle avrdude and have a nice GUI to upload the hex file.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 200
Posts: 12779
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I want to use the USART_RX_vect interrupt

This compliles...

Code:
ISR(USART_RX_vect) { }
void setup( void ) { }
void loop( void ) { }

...but I don't have the means to test if it's useful.


Have you tried to set the interrupt handler and then had problems?

Or did you assume it could not be overridden because there's one defined in wiring_serial.c?


If the answer is "yes" to the latter, you may want to muck ahead.

Good luck,
Brian
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 118
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey, that's right. That code compiles because wiring_serial.o isn't linked because nothing in that object file is accessed. I haven't tested it, but it should work as long as no built-in serial functions are ever called. I was using Serial.begin()... but it's easy enough to just roll my own.

Thanks, that is probably the solution I'll use.
« Last Edit: June 16, 2009, 03:23:12 pm by gabebear » Logged

Pages: [1]   Go Up
Jump to: