Page 1 of 1

Serial Driver and CHN_INPUT_AVAILABLE

Posted: Mon Oct 26, 2015 12:18 pm
by antoniolinux
Hi to all, i connect with a wire PA9 and PA10, i want similate when arrived data on SD1,
when arrived daa on sd1 start a event

if i write this

Code: Select all

static THD_WORKING_AREA(waRead5, 128);
static THD_FUNCTION(Thread5,arg) {
  (void)arg;
  chRegSetThreadName("th_Riempio_Buffer");

  event_listener_t Uart1Data;
  eventmask_t activeEvents;
  eventflags_t flags;
  chEvtRegisterMask((event_source_t *)chnGetEventSource(&SD1), &Uart1Data, EVENT_MASK(1));
  while (TRUE) {
    activeEvents=chEvtWaitAll(EVENT_MASK(1));

       flags =chEvtGetAndClearFlags(&Uart1Data);
 if (flags & CHN_INPUT_AVAILABLE)
                {
              sdWrite(&SD2,"OK\r\n",4);
                }
      }
  return 0;
}


i see only when i reset the board and later i see the event but only just once

if i use this

Code: Select all

 if (flags )
                {
              sdWrite(&SD2,"OK\r\n",4);
                }


All work well but i don't have the control of SD1.
If i disconnect the wired, i see start for every time the event, the thread In WTOREVT state
I see this post viewtopic.php?f=16&t=1394
for me code but i don't know the problem,
bye

Re: Serial Driver and CHN_INPUT_AVAILABLE

Posted: Mon Oct 26, 2015 2:20 pm
by Giovanni
I don't see any obvious problem with the code.

Giovanni

Re: Serial Driver and CHN_INPUT_AVAILABLE

Posted: Mon Oct 26, 2015 4:47 pm
by antoniolinux
i fix it, the code that i write is good but i set the pull UP the pin RX for use it

Code: Select all

  palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(7)); //tx
  palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(7)); //rx
  palSetPadMode(GPIOA,10,PAL_MODE_INPUT_PULLUP);

thanks for all.
A.