drv_spi.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2020-10-28 0xcccccccccccc Initial Version
  9. */
  10. /**
  11. * @addtogroup ls2k
  12. */
  13. /*@{*/
  14. #ifndef LS2K_DRV_SPI_H
  15. #define LS2K_DRV_SPI_H
  16. // kseg1 byte operation
  17. #define KSEG1_STORE8(addr,val) *(volatile char *)(0xffffffffa0000000 | addr) = val
  18. #define KSEG1_LOAD8(addr) *(volatile char *)(0xffffffffa0000000 | addr)
  19. // clock configurations
  20. #define APB_MAX_SPEED 125000000U
  21. #define APB_FREQSCALE (((KSEG1_LOAD8(0xffffffffbfe104d2)>>4)&0x7)+1)
  22. // base addrs
  23. #define SPI_BASE 0x1fff0220
  24. #define PMON_ADDR 0xa1000000
  25. #define FLASH_ADDR 0x000000
  26. // bit bias
  27. #define SPCR 0x0
  28. #define SPSR 0x1
  29. #define FIFO 0x2
  30. #define TXFIFO 0x2
  31. #define RXFIFO 0x2
  32. #define SPER 0x3
  33. #define PARAM 0x4
  34. #define SOFTCS 0x5
  35. #define PARAM2 0x6
  36. #define RFEMPTY 1
  37. // SPI controller operaion macros
  38. #define SET_SPI(addr,val) KSEG1_STORE8(SPI_BASE+addr,val)
  39. #define GET_SPI(addr) KSEG1_LOAD8(SPI_BASE+addr)
  40. #endif
  41. /*@}*/