fearly_uart.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright : (C) 2022 Phytium Information Technology, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is OPEN SOURCE software: you can redistribute it and/or modify it
  6. * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
  7. * either version 1.0 of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
  10. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. * See the Phytium Public License for more details.
  12. *
  13. *
  14. * FilePath: early_uart.c
  15. * Date: 2022-02-11 13:33:28
  16. * LastEditTime: 2022-02-17 17:59:26
  17. * Description:  This files is for
  18. *
  19. * Modify History:
  20. * Ver   Who        Date         Changes
  21. * ----- ------     --------    --------------------------------------
  22. */
  23. /***************************** Include Files *********************************/
  24. #include "fkernel.h"
  25. #include "fio.h"
  26. #include "fparameters.h"
  27. #include "fearly_uart.h"
  28. /**************************** Type Definitions *******************************/
  29. /************************** Constant Definitions *****************************/
  30. /************************** Variable Definitions *****************************/
  31. /***************** Macros (Inline Functions) Definitions *********************/
  32. /*****************************************************************************/
  33. void OutByte(s8 byte)
  34. {
  35. /* wait until tx fifo is not full */
  36. while ((FtIn32(EARLY_UART_UARTFR) & EARLY_UART_TXFF) == EARLY_UART_TXFF)
  37. {
  38. }
  39. FtOut32(EARLY_UART_UARTDR, (((u32)byte) & EARLY_UART_DATA_MASK));
  40. }
  41. char GetByte(void)
  42. {
  43. /* wait until rx fifo is not empty */
  44. while ((FtIn32(EARLY_UART_UARTFR) & EARLY_UART_RXFE) == EARLY_UART_RXFE)
  45. {
  46. }
  47. return (char)(EARLY_UART_DATA_MASK & FtIn32(EARLY_UART_UARTDR));
  48. }