USART(Serial) interrupt

Post your cool example code here.
miki
Posts: 30
Joined: Wed May 18, 2016 10:22 pm

Re: USART(Serial) interrupt

Postby miki » Fri Jun 03, 2016 8:04 pm

I tries to use maple own handler .
declaring extern in usartf1.c file ,....and calling it in my sketch but I received error "expected identifier or '(' before string constant extern "c" void....."

Code: Select all

extern "C" void __irq_usart3(void);


I tried also to move the same line in my sketch but I have again another compile error of " previous declaration" but there is none.I removed the function from usartF1 file and there is no other.
I want to be able to use my handler or maple handler in my sketch.

User avatar
mrburnette
Posts: 1774
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: USART(Serial) interrupt

Postby mrburnette » Fri Jun 03, 2016 11:04 pm

miki wrote:<...>
I want to be able to use my handler or maple handler in my sketch.


I think this is the point where one of the other members should step in to show how to properly prototype the function(s). My raw C skills are fair but there is some magic that must be done when working directly within the Arduino sketch code and that requires experience.

In closing this post, I'll leave you with a forum link to some discussions we had in the past on advanced programming of the STM32F1 under Arduino... definitely not where you are wanting to go, but maybe some light before-bed reading.
http://www.stm32duino.com/viewtopic.php?t=364&start=10#p3441


Ray

PS: I will continue to look through my Linux machine ... I may have captured some of the Leaflabs Forum examples before the forum went off-line.

PPS: You may wish to look into how RTOS products certified to run on the STM32F103 Maple Mini board abstracts the USARTS.

miki
Posts: 30
Joined: Wed May 18, 2016 10:22 pm

Re: USART(Serial) interrupt

Postby miki » Sat Jun 04, 2016 12:56 am

Thanks!
for your effort.
I solved the problem It was so simple.
And it think the some modification can be made permanent in maple core for all versions.
Now I can play whatever I want in my sketch.I already test it and working ok.

miki
Posts: 30
Joined: Wed May 18, 2016 10:22 pm

Re: USART(Serial) interrupt

Postby miki » Tue Aug 30, 2016 4:40 pm

From maple library maker 4 yers ago just in case.
mbolivar
"In general, IRQ handlers need C linkage. Within a C++ file, this means you either put them within an extern "C" block, or you declare them extern "C" with

extern "C" void __irq_whatever(void) { ... }

Within a C file, they'll have C linkage already, so the extern linkage specifier is unnecessary.

Regarding how to release code which overrides IRQ handlers as a library, this is currently a pain, since you have to get your users to comment out the handlers in the copy of libmaple that comes with the IDE. That's obviously not ideal, so in the next version, we'll be making the libmaple IRQ handlers weak, so you can override them just by declaring your own."

He never did that.So how about now?

Riva
Posts: 33
Joined: Fri May 06, 2016 6:42 am

Re: USART(Serial) interrupt

Postby Riva » Thu Feb 09, 2017 8:53 am

Sorry for dragging an old post up but did the weak IRQ thing ever happen so it's easy to replace the default IRQ handler without resorting to core file editing?

EDIT: I have answered my own question by trying a sample sketch and the answer is no, the weak attribute did not get implemented.
What likely problems would it cause to the core to add the __weak attribute to the usart_f1.c interrupt definitions and would it allow a user to implement there own service routines using something like below in there code.

Code: Select all

extern "C" void __irq_usart1(void)
{
    // etc.
}

miki
Posts: 30
Joined: Wed May 18, 2016 10:22 pm

Re: USART(Serial) interrupt

Postby miki » Thu Feb 09, 2017 12:11 pm

In the end I commented original usart2 and 3 functions in usart_f1.c ,and used my own serial interrupt handlers in main program.
Now they are included in multiprotocol.And working excellent.
If you want to see more ,is here.
The serial handlers are in multiprotocol.ino/telemetry.ino
https://github.com/pascallanger/DIY-Mul ... rduino-ide
https://github.com/pascallanger/DIY-Mul ... -TX-Module


Return to “Code snipplets”

Who is online

Users browsing this forum: No registered users and 1 guest