Esempio n. 1
0
/******************************************************************************
 * @fn      HalUARTWrite
 *
 * @brief   Write a buffer to the UART.
 *
 * @param   port - UART port
 *          buf  - pointer to the buffer that will be written, not freed
 *          len  - length of
 *
 * @return  length of the buffer that was sent
 *****************************************************************************/
uint16 HalUARTWrite(uint8 port, uint8 *buf, uint16 len)
{
#if (HAL_UART_DMA == 1)
  if (port == HAL_UART_PORT_0)  return HalUARTWriteDMA(buf, len);
#endif
#if (HAL_UART_DMA == 2)
  if (port == HAL_UART_PORT_1)  return HalUARTWriteDMA(buf, len);
#endif
#if (HAL_UART_ISR == 1)
  if (port == HAL_UART_PORT_0)  return HalUARTWriteISR(buf, len);
#endif
#if (HAL_UART_ISR == 2)
  if (port == HAL_UART_PORT_1)  return HalUARTWriteISR(buf, len);
#endif
#if (HAL_UART_SPI == 1)
  if (port == HAL_UART_PORT_0)  return HalUARTWriteSPI(buf, len);
#endif
#if (HAL_UART_SPI == 2)
  if (port == HAL_UART_PORT_1)  return HalUARTWriteSPI(buf, len);
#endif

#if HAL_UART_USB
  HalUARTTx(buf, len);
  return len;
#else
  #if (HAL_UART_DMA == 0) && (HAL_UART_ISR == 0) && (HAL_UART_SPI == 0)
    // UART is not enabled. Do nothing.
    (void) port;   // unused argument
    (void) buf;   // unused argument
    (void) len;   // unused argument
  #endif
  return 0;
#endif
}
Esempio n. 2
0
/******************************************************************************
 * @fn      HalUARTWrite
 *
 * @brief   Write a buffer to the UART.
 *
 * @param   port - UART port
 *          buf  - pointer to the buffer that will be written, not freed
 *          len  - length of
 *
 * @return  length of the buffer that was sent
 *****************************************************************************/
uint16 HalUARTWrite(uint8 port, uint8 *buf, uint16 len)
{
  (void)port;
  (void)buf;
  (void)len;

#if (HAL_UART_DMA == 1)
  if (port == HAL_UART_PORT_0)  return HalUARTWriteDMA(buf, len);
#endif
#if (HAL_UART_DMA == 2)
  if (port == HAL_UART_PORT_1)  return HalUARTWriteDMA(buf, len);
#endif
#if (HAL_UART_ISR == 1)
  if (port == HAL_UART_PORT_0)  return HalUARTWriteISR(buf, len);
#endif
#if (HAL_UART_ISR == 2)
  if (port == HAL_UART_PORT_1)  return HalUARTWriteISR(buf, len);
#endif

#if HAL_UART_USB
  HalUARTTx(buf, len);
  return len;
#else
  return 0;
#endif
}
Esempio n. 3
0
/**************************************************************************************************
 * @fn          sbTx
 *
 * @brief       Serial Boot loader write API that makes the low-level write according to RPC mode.
 *
 * input parameters
 *
 * @param       buf - Pointer to a buffer of 'len' bytes to write to the serial transport.
 * @param       len - Length in bytes of the 'buf'.
 *
 *
 * output parameters
 *
 * None.
 *
 * @return      The count of the number of bytes written from the 'buf'.
 **************************************************************************************************
 */
uint16 sbTx(uint8 *buf, uint16 len)
{
  if (znpCfg1 == ZNP_CFG1_UART)
  {
    return HalUARTWriteISR(buf, len);
  }
  else
  {
    return HalUARTWriteSPI(buf, len);
  }
}