any printf method in ext driver call back functoin?

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
yushanh
Posts: 31
Joined: Mon Jul 29, 2013 6:23 pm

any printf method in ext driver call back functoin?

Post by yushanh »

Hi all,

I tried to implement an EXT callback function and would like to print some messages thru usb serial driver in it.
I just found that whenever I go into the ISR callback function, the kernel was stuck. In this case, is there any other way to print?

Code: Select all

static void extcb1(EXTDriver *extp, expchannel_t channel) {
  chprintf((BaseSequentialStream *)&SDU1, "hello\r\n");
  static VirtualTimer vt4;

  (void)extp;
  (void)channel;
  palSetPad(GPIOB, GPIOB_LED4);
  chSysLockFromIsr();
  if (chVTIsArmedI(&vt4))
    chVTResetI(&vt4);
  /* LED4 set to OFF after 200mS.*/
  chVTSetI(&vt4, MS2ST(200), led4off, NULL);
  chSysUnlockFromIsr();
}




Thanks!

Shan.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: any printf method in ext driver call back functoin?

Post by Giovanni »

Hi,

You can't use streams from a callback context, the state checker stops you, you have to wakeup a thread that then does your I/O on the stream.

Giovanni
yushanh
Posts: 31
Joined: Mon Jul 29, 2013 6:23 pm

Re: any printf method in ext driver call back functoin?

Post by yushanh »

Thanks Giovanni,

Following your instructions here (http://chibios.org/dokuwiki/doku.php?id ... tos:wakeup), now it gets to work!

~S
Post Reply