Page 3 of 3
Re: Ext driver example
Posted: Tue Jun 05, 2012 8:08 pm
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
Re: Ext driver example
Posted: Tue Jun 05, 2012 8:20 pm
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
Re: Ext driver example
Posted: Tue Jun 05, 2012 8:53 pm
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
Re: Ext driver example
Posted: Tue Jun 05, 2012 8:59 pm
by barthess
Does your code have something like?
Re: Ext driver example
Posted: Tue Jun 05, 2012 10:04 pm
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/2877845It 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/2877871It lands in unhandled exception.
Sorry for the trouble with the changing/wrong code snippets
~ Tectu
Re: Ext driver example
Posted: Tue Jun 05, 2012 10:56 pm
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.
Re: Ext driver example
Posted: Tue Jun 05, 2012 11:29 pm
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
Re: Ext driver example
Posted: Wed Jun 06, 2012 6:59 am
by barthess
for example:
define pointer to some thread
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.
Re: Ext driver example
Posted: Wed Jun 06, 2012 8:25 am
by Tectu
Aaaah, Volia!
This works:
https://gist.github.com/2880420But 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