Page 1 of 1
chMBPost ??
Posted: Sat May 03, 2014 8:17 am
by Tabulous
if i want to post a message from a EXTDriver callback which chMBPost would i use I-interrupt ?
i.e.
Code: Select all
static void extcb1(EXTDriver *extp, expchannel_t channel)
{
struct iom m;
static VirtualTimer vt4;
(void)extp;
(void)channel;
m.id = IOM_OUTPUT1;
m.state = IOM_OUTPUT_ON;
chMBPostI(&mbox, (msg_t)&m);
chSysLockFromIsr();
if (chVTIsArmedI(&vt4))
{
chVTResetI(&vt4);
}
/* LED4 set to OFF after 200mS.*/
chVTSetI(&vt4, MS2ST(200), led1off, NULL);
chSysUnlockFromIsr();
}
If so why would i be getting SV#10 panics ?
Re: chMBPost ??
Posted: Sat May 03, 2014 8:24 am
by Giovanni
Because you call the I-class function before chSysLockFromIsr(), it is supposed to be called within the critical zone.
Giovanni
Re: chMBPost ??
Posted: Sat May 03, 2014 8:32 am
by Tabulous
Giovanni wrote:Because you call the I-class function before chSysLockFromIsr(), it is supposed to be called within the critical zone.
Giovanni
Ok so if i used chMBPostS(&mbox, (msg_t)&m); i get SV#11
and
if i used chMBPost(&mbox, (msg_t)&m); i get SV#4
so how do i post to a message box from the EXTDriver Callback ?
Re: chMBPost ??
Posted: Sat May 03, 2014 8:37 am
by Giovanni
You need to use chMBPostI(), callbacks are called from ISR context.
Giovanni
Re: chMBPost ??
Posted: Sat May 03, 2014 8:44 am
by Tabulous
Giovanni wrote:You need to use chMBPostI(), callbacks are called from ISR context.
Giovanni
it doesnt work, this is what i have
Code: Select all
static void extcb1(EXTDriver *extp, expchannel_t channel)
{
struct iom m;
static VirtualTimer vt4;
(void)extp;
(void)channel;
m.id = IOM_OUTPUT1;
m.state = IOM_OUTPUT_ON;
chMBPostI(&mbox, (msg_t)&m);
chSysLockFromIsr();
if (chVTIsArmedI(&vt4))
{
chVTResetI(&vt4);
}
/* LED4 set to OFF after 200mS.*/
chVTSetI(&vt4, MS2ST(200), led1off, NULL);
chSysUnlockFromIsr();
}
I get debug panic SV#10, dbg_isr_cnt = 1 and dbg_lock_cnt = 0
Re: chMBPost ??
Posted: Sat May 03, 2014 8:48 am
by Giovanni
Because you call the I-class function (chMBPostI()) before chSysLockFromIsr(), it is supposed to be called within the critical zone.
Giovanni
Re: chMBPost ??
Posted: Sat May 03, 2014 9:00 am
by Tabulous
Giovanni wrote:Because you call the I-class function (chMBPostI()) before chSysLockFromIsr(), it is supposed to be called within the critical zone.
Giovanni
so if i move the call to chMBPostI() outside the chSysLockFromIsr() lock zone, would i call just chMBPost ?
Re: chMBPost ??
Posted: Sat May 03, 2014 9:06 am
by Giovanni
You can only call I-class functions from ISRs and callbacks.
Code: Select all
static void extcb1(EXTDriver *extp, expchannel_t channel)
{
struct iom m;
static VirtualTimer vt4;
(void)extp;
(void)channel;
m.id = IOM_OUTPUT1;
m.state = IOM_OUTPUT_ON;
chSysLockFromIsr();
chMBPostI(&mbox, (msg_t)&m);
if (chVTIsArmedI(&vt4))
{
chVTResetI(&vt4);
}
/* LED4 set to OFF after 200mS.*/
chVTSetI(&vt4, MS2ST(200), led1off, NULL);
chSysUnlockFromIsr();
}
This.
Giovanni