Ext driver example

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Ext driver example

Post by Giovanni »

You signal the thread using that variable "tp", do you assign it with the pointer to the thread?

It would be easier if you just post your whole main, we cant' continue guessing what you possibly do wrong.

Giovanni
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: Ext driver example

Post by Tectu »

Sorry, here you go, but be warned, that's just code to play arround with chibios, so much of trash arround there:

https://gist.github.com/2877114

(I am open for all kinds of improvements)


~ Tectu
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Ext driver example

Post by Giovanni »

That code does not contain the code you posted before, I can't find that chEvtSignalFlagsI() anywhere, I am bit lost...

I can only recommend that you split the problems in smaller parts, make them all work separately and then put everything together.

Giovanni
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: Ext driver example

Post by barthess »

Does your code have something like?

Code: Select all

chEvtInit(&modem_event);
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: Ext driver example

Post by Tectu »

Okay, this was my bad, I am very sorry for that confusion. I stripped everything down now.

Now, let's play with open cards:

This works great: https://gist.github.com/2877845
It does just toggle the LED in the ISR, so no Thread wakeup stuff or something else.

This does not work anymore: https://gist.github.com/2877871
It lands in unhandled exception.


Sorry for the trouble with the changing/wrong code snippets


~ Tectu
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: Ext driver example

Post by barthess »

Is compiler not warn you on this line?

Code: Select all

chEvtSignalFlagsI(Thread2, (eventmask_t)1);

I can not see where you initialize Thread2 pointer. Function chThdCreateStatic() returns pointer that must be passed to signaling function. Signaller in your code tries to write somewhere "in space" and traps in unhandled exception.
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: Ext driver example

Post by Tectu »

okay, I really have to go this way now: I don't kow how to initialize that pointer the correct way? I read througth the wiki, but couldn't find something helping.

This article here http://chibios.org/dokuwiki/doku.php?id=chibios:howtos:wakeup#waking_up_a_specific_thread1 "does use another kind of threads". But I guess I can modify my code somehow to bring it to work?
Sorry for this nooby question, but I really don't have any clue.


~ Tectu
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: Ext driver example

Post by barthess »

for example:
define pointer to some thread

Code: Select all

Thread *thread2_p = NULL;

init it:

Code: Select all

thread2_p = chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL);

now it points to Thread2
send event:

Code: Select all

chEvtSignalFlagsI(thread2_p, (eventmask_t)1);


If it will not work than try to use semaphores instead of events, they are much easy to understand.
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: Ext driver example

Post by Tectu »

Aaaah, Volia!

This works: https://gist.github.com/2880420

But now we get back to the problem we had before.
This dosen't work again: https://gist.github.com/2880389 (line 34)
As soon as I press the touchpad, the LED3 in does start blinking over and over again (It does not go to sleep anymore).

Not sure where the problem is here again. That was the same problem before I started waking up a thread.
As I said before, tpReadX() and tpReadY() do work great within any thread, which does not get controlled over the EXT driver.

any ideas?


~ Tectu
Post Reply