This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Where is Hal_UART_TxBufLen implemented?

Other Parts Discussed in Thread: Z-STACK

Hi,

 

I'm trying to use Hal_UART_TxBufLen function (hal_uart.h), but this function is only defined, and not implemented in hal_uart.c

 

Best regards,

 

Carlos

  • Which version of Z-Stack are you using? For example, Z-Stack-EXP5438-2.2.0 or ??

  • ZStack-1.4.3-1.2.1

    My distributor recommend me this version

    I'm working with CC2430EM and CC2431EM

  • There is no implementation of Hal_UART_TxBufLen in the ZStack-1.4.3-1.2.1, as you know.

    The HalUARTWrite() defined in ZStack-1.4.3-1.2.1\Components\hal\target\CC2430EB\hal_uart.c, implements an all-or-nothing mode of operation when writing a buffer to the UART.  If the UART HAL buffer has enough room for the new data to be written, it will add to the internal software FIFO.  However, if there is not enough room, the HalUARTWrite() will return.

    The HalUARTWrite() function uses the TX_AVAIL() macro to determine if there is enough room.

  • I only need to know when data has been sent. The question is:

     

    If I call HalUARTWrite function, how can I to know where data has been sent?

     

    This is a good way: ???

      HalUARTWrite(port, pBuffer, length);

      do {
      } while ( Hal_UART_TxBufLen(port)>0 );

     

    If yes, what is the implementation of HalUARTWrite ?

     

    Thanks

  • Carlos Codina said:

    If I call HalUARTWrite function, how can I to know where data has been sent?

     HalUARTWrite(port, pBuffer, length);

      do {
      } while ( Hal_UART_TxBufLen(port)>0 );

    If yes, what is the implementation of HalUARTWrite ?

     

    I'm not sure I understand exactly what you are asking.  There is already an implementation of HalUARTWrite().  I think you mean to ask what would be a recommended implementation of Hal_UART_TxBufLen(), correct?

    If so, here is a proposal.  I haven't tested this, but it should be something close.

     

    uint16 Hal_UART_TxBufLen( uint8 port )
    {
      uartCfg_t *cfg = NULL;

    #if HAL_UART_0_ENABLE
      if ( port == HAL_UART_PORT_0 )
      {
        cfg = cfg0;
      }
    #endif
    #if HAL_UART_1_ENABLE
      if ( port == HAL_UART_PORT_1 )
      {
        cfg = cfg1;
      }
    #endif

      HAL_UART_ASSERT( cfg );

      return TX_AVAIL( cfg );
    }