/***************************************************************************** * @fn HalUARTRead * * @brief Read a buffer from the UART * * @param port - USART module designation * buf - valid data buffer at least 'len' bytes in size * len - max length number of bytes to copy to 'buf' * * @return length of buffer that was read *****************************************************************************/ uint16 HalUARTRead(uint8 port, uint8 *buf, uint16 len) { #if (HAL_UART_DMA == 1) if (port == HAL_UART_PORT_0) return HalUARTReadDMA(buf, len); #endif #if (HAL_UART_DMA == 2) if (port == HAL_UART_PORT_1) return HalUARTReadDMA(buf, len); #endif #if (HAL_UART_ISR == 1) if (port == HAL_UART_PORT_0) return HalUARTReadISR(buf, len); #endif #if (HAL_UART_ISR == 2) if (port == HAL_UART_PORT_1) return HalUARTReadISR(buf, len); #endif #if (HAL_UART_SPI == 1) if (port == HAL_UART_PORT_0) return HalUARTReadSPI(buf, len); #endif #if (HAL_UART_SPI == 2) if (port == HAL_UART_PORT_1) return HalUARTReadSPI(buf, len); #endif #if HAL_UART_USB return HalUARTRx(buf, 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 }
/************************************************************************************************** * @fn sbRx * * @brief Serial Boot loader read API that makes the low-level read according to RPC mode. * * input parameters * * @param buf - Pointer to a buffer to fill with up to 'len' bytes. * @param len - Maximum count of bytes to fill into the 'buf'. * * * output parameters * * None. * * @return The count of the number of bytes filled into the 'buf'. ************************************************************************************************** */ uint16 sbRx(uint8 *buf, uint16 len) { if (znpCfg1 == ZNP_CFG1_UART) { return HalUARTReadISR(buf, len); } else { if (spiPoll) { if (URXxIF) { *buf = UxDBUF; return 1; } else { return 0; } } else { return HalUARTReadSPI(buf, len); } } }
uint16 HalUARTRead(uint8 port, uint8 *pBuffer, uint16 length) { (void)port; return HalUARTReadSPI(pBuffer, length); }
/************************************************************************************************** * @fn sbRx * * @brief Serial Boot loader write API that makes the low-level read 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 sbRx(uint8 *buf, uint16 len) { return HalUARTReadSPI(buf, len); }