Serial Driver and CHN_INPUT_AVAILABLE

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

Moderators: barthess, RoccoMarco

antoniolinux
Posts: 38
Joined: Thu Dec 19, 2013 12:59 pm

Serial Driver and CHN_INPUT_AVAILABLE

Postby antoniolinux » Mon Oct 26, 2015 12:18 pm

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

User avatar
Giovanni
Site Admin
Posts: 13074
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 758 times
Been thanked: 637 times
Contact:

Re: Serial Driver and CHN_INPUT_AVAILABLE

Postby Giovanni » Mon Oct 26, 2015 2:20 pm

I don't see any obvious problem with the code.

Giovanni

antoniolinux
Posts: 38
Joined: Thu Dec 19, 2013 12:59 pm

Re: Serial Driver and CHN_INPUT_AVAILABLE

Postby antoniolinux » Mon Oct 26, 2015 4:47 pm

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.


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 4 guests