function Serial.attach()

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

Re: function Serial.attach()

Postby antoniolinux » Wed Oct 14, 2015 1:02 pm

hI AlSith my code is here:

Code: Select all

static THD_WORKING_AREA(waRead5, 128);
static THD_FUNCTION(Thread5,arg) {
  chRegSetThreadName("th_Riempio_Buffer");
  msg_t charbuf;
//  int count=0;
 // char B2[] = "E_2";
 // char B3[] = "E_3";
  uint8_t c;
  event_listener_t Uart1Data;
  eventmask_t flags;
 chEvtRegisterMask((event_source_t *)chnGetEventSource(&SD1), &Uart1Data, EVENT_MASK(1));

  while (TRUE) {
       chEvtWaitOneTimeout(EVENT_MASK(1), MS2ST(10));
       chSysLock();
      // flags = chEvtGetAndClearFlags(&Uart1Data);
       flags =chEvtGetAndClearFlags(&Uart1Data);
      chSysUnlock();
       if (flags & CHN_INPUT_AVAILABLE)
                {
       //  sdWrite(&SD2, (uint8_t *)B2,4); // va bene
                   do
                   {
                     charbuf = chnGetTimeout(&SD1,TIME_IMMEDIATE);
                      if (charbuf != Q_TIMEOUT)
                             {
                         while((charbuf != '\n') && (count < 128)) {
                           sdWrite(&SD2, (uint8_t *)B3,4); // va bene
                            bufferMsg[count]= charbuf;
                                     count++;
                                   }
                                }
                   //  uint8_t c = sdGet(&SD1); //questo prende il carattere
                     if ( charbuf != Q_TIMEOUT )
                                  {
                                        chprintf(chp,(char)charbuf);
                                     }
                         }
                   while (charbuf != Q_TIMEOUT);
                }
      }
}


i see this situetion if i avtive this thread

Code: Select all

/* Periodic thread for reading data */
/*Spara i dati */
static THD_WORKING_AREA(waRead, 128);
static THD_FUNCTION(Thread,arg) {
  (void)arg;
    chRegSetThreadName("th_callback");

    while (TRUE){
        /* This will wait for a character to be received */
        uint8_t c = sdGet(&SD1); //questo prende il carattere
        sdPut(&SD2, c);  // questo lo spara alla terminale

    }
}

the event start but if i don't active this threads the event don't start, for this situetion now i see the uart driver.
bye
A.


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 5 guests