i2c_master.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _I2C_MASTER_H_
  13. #define _I2C_MASTER_H_
  14. // Auto generated by dtools(see dtools.txt for its version).
  15. // Don't edit it manually!
  16. #define REG_I2C_MASTER1_BASE (0x04807000)
  17. #define REG_I2C_MASTER2_BASE (0x04808000)
  18. #define REG_I2C_MASTER3_BASE (0x51504000)
  19. typedef volatile struct
  20. {
  21. uint32_t ctrl; // 0x00000000
  22. uint32_t status; // 0x00000004
  23. uint32_t txrx_buffer; // 0x00000008
  24. uint32_t cmd; // 0x0000000c
  25. uint32_t irq_clr; // 0x00000010
  26. } HWP_I2C_MASTER_T;
  27. #define hwp_i2cMaster1 ((HWP_I2C_MASTER_T *)REG_ACCESS_ADDRESS(REG_I2C_MASTER1_BASE))
  28. #define hwp_i2cMaster2 ((HWP_I2C_MASTER_T *)REG_ACCESS_ADDRESS(REG_I2C_MASTER2_BASE))
  29. #define hwp_i2cMaster3 ((HWP_I2C_MASTER_T *)REG_ACCESS_ADDRESS(REG_I2C_MASTER3_BASE))
  30. // ctrl
  31. typedef union {
  32. uint32_t v;
  33. struct
  34. {
  35. uint32_t en : 1; // [0]
  36. uint32_t __7_1 : 7; // [7:1]
  37. uint32_t irq_mask : 1; // [8]
  38. uint32_t __15_9 : 7; // [15:9]
  39. uint32_t clock_prescale : 16; // [31:16]
  40. } b;
  41. } REG_I2C_MASTER_CTRL_T;
  42. // status
  43. typedef union {
  44. uint32_t v;
  45. struct
  46. {
  47. uint32_t irq_cause : 1; // [0], read only
  48. uint32_t __3_1 : 3; // [3:1]
  49. uint32_t irq_status : 1; // [4], read only
  50. uint32_t __7_5 : 3; // [7:5]
  51. uint32_t tip : 1; // [8], read only
  52. uint32_t __11_9 : 3; // [11:9]
  53. uint32_t al : 1; // [12], read only
  54. uint32_t __15_13 : 3; // [15:13]
  55. uint32_t busy : 1; // [16], read only
  56. uint32_t __19_17 : 3; // [19:17]
  57. uint32_t rxack : 1; // [20], read only
  58. uint32_t __31_21 : 11; // [31:21]
  59. } b;
  60. } REG_I2C_MASTER_STATUS_T;
  61. // txrx_buffer
  62. typedef union {
  63. uint32_t v;
  64. struct
  65. {
  66. uint32_t tx_data : 8; // [7:0]
  67. uint32_t rx_data : 8; // [7:0], read only
  68. uint32_t __31_8 : 24; // [31:8]
  69. } b;
  70. } REG_I2C_MASTER_TXRX_BUFFER_T;
  71. // cmd
  72. typedef union {
  73. uint32_t v;
  74. struct
  75. {
  76. uint32_t ack : 1; // [0]
  77. uint32_t __3_1 : 3; // [3:1]
  78. uint32_t rd : 1; // [4]
  79. uint32_t __7_5 : 3; // [7:5]
  80. uint32_t sto : 1; // [8]
  81. uint32_t __11_9 : 3; // [11:9]
  82. uint32_t rw : 1; // [12]
  83. uint32_t __15_13 : 3; // [15:13]
  84. uint32_t sta : 1; // [16]
  85. uint32_t __31_17 : 15; // [31:17]
  86. } b;
  87. } REG_I2C_MASTER_CMD_T;
  88. // irq_clr
  89. typedef union {
  90. uint32_t v;
  91. struct
  92. {
  93. uint32_t irq_clr : 1; // [0], write clear
  94. uint32_t __31_1 : 31; // [31:1]
  95. } b;
  96. } REG_I2C_MASTER_IRQ_CLR_T;
  97. // ctrl
  98. #define I2C_MASTER_EN (1 << 0)
  99. #define I2C_MASTER_IRQ_MASK (1 << 8)
  100. #define I2C_MASTER_CLOCK_PRESCALE(n) (((n)&0xffff) << 16)
  101. // status
  102. #define I2C_MASTER_IRQ_CAUSE (1 << 0)
  103. #define I2C_MASTER_IRQ_STATUS (1 << 4)
  104. #define I2C_MASTER_TIP (1 << 8)
  105. #define I2C_MASTER_AL (1 << 12)
  106. #define I2C_MASTER_BUSY (1 << 16)
  107. #define I2C_MASTER_RXACK (1 << 20)
  108. // txrx_buffer
  109. #define I2C_MASTER_TX_DATA(n) (((n)&0xff) << 0)
  110. #define I2C_MASTER_RX_DATA(n) (((n)&0xff) << 0)
  111. // cmd
  112. #define I2C_MASTER_ACK (1 << 0)
  113. #define I2C_MASTER_RD (1 << 4)
  114. #define I2C_MASTER_STO (1 << 8)
  115. #define I2C_MASTER_RW (1 << 12)
  116. #define I2C_MASTER_STA (1 << 16)
  117. // irq_clr
  118. #define I2C_MASTER_IRQ_CLR (1 << 0)
  119. #endif // _I2C_MASTER_H_