hal_data.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. /* generated HAL source file - do not edit */
  2. #include "hal_data.h"
  3. #if defined(BSP_MCU_GROUP_RZT2M) || defined(BSP_MCU_GROUP_RZN2L)
  4. #define ETHER_BUFFER_PLACE_IN_SECTION BSP_PLACE_IN_SECTION(".noncache_buffer.eth")
  5. #else
  6. #define ETHER_BUFFER_PLACE_IN_SECTION
  7. #endif
  8. ethsw_instance_ctrl_t g_ethsw0_ctrl;
  9. const ethsw_extend_cfg_t g_ethsw0_extend_cfg =
  10. {
  11. .specific_tag = ETHSW_SPECIFIC_TAG_DISABLE,
  12. .specific_tag_id = 0xE001,
  13. .phylink = ETHSW_PHYLINK_DISABLE,
  14. };
  15. const ether_switch_cfg_t g_ethsw0_cfg =
  16. {
  17. .channel = 0,
  18. #if defined(VECTOR_NUMBER_ETHSW_INTR)
  19. .irq = VECTOR_NUMBER_ETHSW_INTR,
  20. #else
  21. .irq = FSP_INVALID_VECTOR,
  22. #endif
  23. .ipl = (12),
  24. .p_callback = gmac_callback_ethsw,
  25. .p_context = &g_ether0_ctrl,
  26. .p_extend = &g_ethsw0_extend_cfg
  27. };
  28. /* Instance structure to use this module. */
  29. const ether_switch_instance_t g_ethsw0 =
  30. {
  31. .p_ctrl = &g_ethsw0_ctrl,
  32. .p_cfg = &g_ethsw0_cfg,
  33. .p_api = &g_ether_switch_on_ethsw
  34. };
  35. ether_selector_instance_ctrl_t g_ether_selector1_ctrl;
  36. const ether_selector_cfg_t g_ether_selector1_cfg =
  37. {
  38. .channel = 1,
  39. .phylink = ETHER_SELECTOR_PHYLINK_POLARITY_LOW,
  40. .interface = ETHER_SELECTOR_INTERFACE_RGMII,
  41. .speed = ETHER_SELECTOR_SPEED_100_MBPS,
  42. .duplex = ETHER_SELECTOR_DUPLEX_FULL,
  43. .ref_clock = ETHER_SELECTOR_REF_CLOCK_INPUT,
  44. .p_extend = NULL,
  45. };
  46. /* Instance structure to use this module. */
  47. const ether_selector_instance_t g_ether_selector1 =
  48. {
  49. .p_ctrl = &g_ether_selector1_ctrl,
  50. .p_cfg = &g_ether_selector1_cfg,
  51. .p_api = &g_ether_selector_on_ether_selector
  52. };
  53. ether_phy_instance_ctrl_t g_ether_phy1_ctrl;
  54. const ether_phy_extend_cfg_t g_ether_phy1_extend =
  55. {
  56. .port_type = ETHER_PHY_PORT_TYPE_ETHERNET,
  57. .mdio_type = ETHER_PHY_MDIO_GMAC,
  58. .bps = ETHER_PHY_SPEED_100,
  59. .duplex = ETHER_PHY_DUPLEX_FULL,
  60. .auto_negotiation = ETHER_PHY_AUTO_NEGOTIATION_ON,
  61. .phy_reset_pin = BSP_IO_PORT_13_PIN_4,
  62. .phy_reset_time = 15000,
  63. .p_selector_instance = (ether_selector_instance_t *)&g_ether_selector1,
  64. .p_target_init = ether_phy_targets_initialize_rtl8211_rgmii,
  65. };
  66. const ether_phy_cfg_t g_ether_phy1_cfg =
  67. {
  68. .channel = 1,
  69. .phy_lsi_address = 2,
  70. .phy_reset_wait_time = 0x00020000,
  71. .mii_bit_access_wait_time = 0, // Unused
  72. .phy_lsi_type = ETHER_PHY_LSI_TYPE_CUSTOM,
  73. .flow_control = ETHER_PHY_FLOW_CONTROL_DISABLE,
  74. .mii_type = (ether_phy_mii_type_t) 0, // Unused
  75. .p_context = NULL,
  76. .p_extend = &g_ether_phy1_extend
  77. };
  78. /* Instance structure to use this module. */
  79. const ether_phy_instance_t g_ether_phy1 =
  80. {
  81. .p_ctrl = &g_ether_phy1_ctrl,
  82. .p_cfg = &g_ether_phy1_cfg,
  83. .p_api = &g_ether_phy_on_ether_phy
  84. };
  85. ether_selector_instance_ctrl_t g_ether_selector0_ctrl;
  86. const ether_selector_cfg_t g_ether_selector0_cfg =
  87. {
  88. .channel = 0,
  89. .phylink = ETHER_SELECTOR_PHYLINK_POLARITY_LOW,
  90. .interface = ETHER_SELECTOR_INTERFACE_RGMII,
  91. .speed = ETHER_SELECTOR_SPEED_100_MBPS,
  92. .duplex = ETHER_SELECTOR_DUPLEX_FULL,
  93. .ref_clock = ETHER_SELECTOR_REF_CLOCK_INPUT,
  94. .p_extend = NULL,
  95. };
  96. /* Instance structure to use this module. */
  97. const ether_selector_instance_t g_ether_selector0 =
  98. {
  99. .p_ctrl = &g_ether_selector0_ctrl,
  100. .p_cfg = &g_ether_selector0_cfg,
  101. .p_api = &g_ether_selector_on_ether_selector
  102. };
  103. ether_phy_instance_ctrl_t g_ether_phy0_ctrl;
  104. const ether_phy_extend_cfg_t g_ether_phy0_extend =
  105. {
  106. .port_type = ETHER_PHY_PORT_TYPE_ETHERNET,
  107. .mdio_type = ETHER_PHY_MDIO_GMAC,
  108. .bps = ETHER_PHY_SPEED_100,
  109. .duplex = ETHER_PHY_DUPLEX_FULL,
  110. .auto_negotiation = ETHER_PHY_AUTO_NEGOTIATION_ON,
  111. .phy_reset_pin = BSP_IO_PORT_13_PIN_4,
  112. .phy_reset_time = 15000,
  113. .p_selector_instance = (ether_selector_instance_t *)&g_ether_selector0,
  114. .p_target_init = ether_phy_targets_initialize_rtl8211_rgmii,
  115. };
  116. const ether_phy_cfg_t g_ether_phy0_cfg =
  117. {
  118. .channel = 0,
  119. .phy_lsi_address = 1,
  120. .phy_reset_wait_time = 0x00020000,
  121. .mii_bit_access_wait_time = 0, // Unused
  122. .phy_lsi_type = ETHER_PHY_LSI_TYPE_CUSTOM,
  123. .flow_control = ETHER_PHY_FLOW_CONTROL_DISABLE,
  124. .mii_type = (ether_phy_mii_type_t) 0, // Unused
  125. .p_context = NULL,
  126. .p_extend = &g_ether_phy0_extend
  127. };
  128. /* Instance structure to use this module. */
  129. const ether_phy_instance_t g_ether_phy0 =
  130. {
  131. .p_ctrl = &g_ether_phy0_ctrl,
  132. .p_cfg = &g_ether_phy0_cfg,
  133. .p_api = &g_ether_phy_on_ether_phy
  134. };
  135. const ether_phy_instance_t *g_ether0_phy_instance[BSP_FEATURE_GMAC_MAX_PORTS] =
  136. {
  137. #define FSP_NOT_DEFINED (1)
  138. #if (FSP_NOT_DEFINED == g_ether_phy0)
  139. NULL,
  140. #else
  141. &g_ether_phy0,
  142. #endif
  143. #if (FSP_NOT_DEFINED == g_ether_phy1)
  144. NULL,
  145. #else
  146. &g_ether_phy1,
  147. #endif
  148. #if (FSP_NOT_DEFINED == FSP_NOT_DEFINED)
  149. NULL,
  150. #else
  151. &FSP_NOT_DEFINED,
  152. #endif
  153. #undef FSP_NOT_DEFINED
  154. };
  155. gmac_instance_ctrl_t g_ether0_ctrl;
  156. #define ETHER_MAC_ADDRESS_INVALID (0)
  157. #define ETHER_MAC_ADDRESS_VALID (1)
  158. uint8_t g_ether0_mac_address[6] = { 0x00,0x11,0x22,0x33,0x44,0x55 };
  159. #if ETHER_MAC_ADDRESS_INVALID == ETHER_MAC_ADDRESS_VALID
  160. uint8_t g_ether0_mac_address_1[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
  161. #endif
  162. #if ETHER_MAC_ADDRESS_INVALID == ETHER_MAC_ADDRESS_VALID
  163. uint8_t g_ether0_mac_address_2[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
  164. #endif
  165. __attribute__((__aligned__(16))) gmac_instance_descriptor_t g_ether0_tx_descriptors[8] ETHER_BUFFER_PLACE_IN_SECTION;
  166. __attribute__((__aligned__(16))) gmac_instance_descriptor_t g_ether0_rx_descriptors[8] ETHER_BUFFER_PLACE_IN_SECTION;
  167. __attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer0[1524]ETHER_BUFFER_PLACE_IN_SECTION;
  168. __attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer1[1524]ETHER_BUFFER_PLACE_IN_SECTION;
  169. __attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer2[1524]ETHER_BUFFER_PLACE_IN_SECTION;
  170. __attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer3[1524]ETHER_BUFFER_PLACE_IN_SECTION;
  171. __attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer4[1524]ETHER_BUFFER_PLACE_IN_SECTION;
  172. __attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer5[1524]ETHER_BUFFER_PLACE_IN_SECTION;
  173. __attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer6[1524]ETHER_BUFFER_PLACE_IN_SECTION;
  174. __attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer7[1524]ETHER_BUFFER_PLACE_IN_SECTION;
  175. __attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer8[1524]ETHER_BUFFER_PLACE_IN_SECTION;
  176. __attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer9[1524]ETHER_BUFFER_PLACE_IN_SECTION;
  177. __attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer10[1524]ETHER_BUFFER_PLACE_IN_SECTION;
  178. __attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer11[1524]ETHER_BUFFER_PLACE_IN_SECTION;
  179. __attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer12[1524]ETHER_BUFFER_PLACE_IN_SECTION;
  180. __attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer13[1524]ETHER_BUFFER_PLACE_IN_SECTION;
  181. __attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer14[1524]ETHER_BUFFER_PLACE_IN_SECTION;
  182. __attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer15[1524]ETHER_BUFFER_PLACE_IN_SECTION;
  183. uint8_t *pp_g_ether0_ether_buffers[( 8 + 8 )] = {
  184. (uint8_t *) &g_ether0_ether_buffer0[0],
  185. (uint8_t *) &g_ether0_ether_buffer1[0],
  186. (uint8_t *) &g_ether0_ether_buffer2[0],
  187. (uint8_t *) &g_ether0_ether_buffer3[0],
  188. (uint8_t *) &g_ether0_ether_buffer4[0],
  189. (uint8_t *) &g_ether0_ether_buffer5[0],
  190. (uint8_t *) &g_ether0_ether_buffer6[0],
  191. (uint8_t *) &g_ether0_ether_buffer7[0],
  192. (uint8_t *) &g_ether0_ether_buffer8[0],
  193. (uint8_t *) &g_ether0_ether_buffer9[0],
  194. (uint8_t *) &g_ether0_ether_buffer10[0],
  195. (uint8_t *) &g_ether0_ether_buffer11[0],
  196. (uint8_t *) &g_ether0_ether_buffer12[0],
  197. (uint8_t *) &g_ether0_ether_buffer13[0],
  198. (uint8_t *) &g_ether0_ether_buffer14[0],
  199. (uint8_t *) &g_ether0_ether_buffer15[0],
  200. };
  201. const gmac_extend_cfg_t g_ether0_extend_cfg =
  202. {
  203. .p_rx_descriptors = g_ether0_rx_descriptors,
  204. .p_tx_descriptors = g_ether0_tx_descriptors,
  205. .phylink = GMAC_PHYLINK_DISABLE,
  206. #if defined(VECTOR_NUMBER_GMAC_PMT)
  207. .pmt_irq = VECTOR_NUMBER_GMAC_PMT,
  208. #else
  209. .pmt_irq = FSP_INVALID_VECTOR,
  210. #endif
  211. .pmt_interrupt_priority = (12),
  212. .pp_phy_instance = (ether_phy_instance_t const *(*)[BSP_FEATURE_GMAC_MAX_PORTS]) g_ether0_phy_instance,
  213. #if defined(GMAC_IMPLEMENT_ETHSW)
  214. .p_ethsw_instance = &g_ethsw0,
  215. #endif // GMAC_IMPLEMENT_ETHSW
  216. #if ETHER_MAC_ADDRESS_INVALID == ETHER_MAC_ADDRESS_VALID
  217. .p_mac_address1 = g_ether0_mac_address_1,
  218. #else
  219. .p_mac_address1 = NULL,
  220. #endif
  221. #if ETHER_MAC_ADDRESS_INVALID == ETHER_MAC_ADDRESS_VALID
  222. .p_mac_address2 = g_ether0_mac_address_2
  223. #else
  224. .p_mac_address2 = NULL,
  225. #endif
  226. };
  227. const ether_cfg_t g_ether0_cfg =
  228. {
  229. .channel = 0,
  230. .zerocopy = ETHER_ZEROCOPY_DISABLE,
  231. .multicast = (ether_multicast_t) 0, // Unused
  232. .promiscuous = ETHER_PROMISCUOUS_ENABLE,
  233. .flow_control = ETHER_FLOW_CONTROL_DISABLE,
  234. .broadcast_filter = 0, // Unused
  235. .p_mac_address = g_ether0_mac_address,
  236. .num_tx_descriptors = 8,
  237. .num_rx_descriptors = 8,
  238. .pp_ether_buffers = pp_g_ether0_ether_buffers,
  239. .ether_buffer_size = 1524,
  240. #if defined(VECTOR_NUMBER_GMAC_SBD)
  241. .irq = VECTOR_NUMBER_GMAC_SBD,
  242. #else
  243. .irq = FSP_INVALID_VECTOR,
  244. #endif
  245. .interrupt_priority = (12),
  246. .p_callback = user_ether0_callback,
  247. .p_ether_phy_instance = (ether_phy_instance_t *) 0, // Unused
  248. .p_context = NULL,
  249. .p_extend = &g_ether0_extend_cfg
  250. };
  251. /* Instance structure to use this module. */
  252. const ether_instance_t g_ether0 =
  253. {
  254. .p_ctrl = &g_ether0_ctrl,
  255. .p_cfg = &g_ether0_cfg,
  256. .p_api = &g_ether_on_gmac
  257. };
  258. sci_uart_instance_ctrl_t g_uart0_ctrl;
  259. #define FSP_NOT_DEFINED (1)
  260. #if (FSP_NOT_DEFINED) != (FSP_NOT_DEFINED)
  261. /* If the transfer module is DMAC, define a DMAC transfer callback. */
  262. extern void sci_uart_tx_dmac_callback(sci_uart_instance_ctrl_t * p_instance_ctrl);
  263. void g_uart0_tx_transfer_callback (transfer_callback_args_t * p_args)
  264. {
  265. FSP_PARAMETER_NOT_USED(p_args);
  266. sci_uart_tx_dmac_callback(&g_uart0_ctrl);
  267. }
  268. #endif
  269. #if (FSP_NOT_DEFINED) != (FSP_NOT_DEFINED)
  270. /* If the transfer module is DMAC, define a DMAC transfer callback. */
  271. extern void sci_uart_rx_dmac_callback(sci_uart_instance_ctrl_t * p_instance_ctrl);
  272. void g_uart0_rx_transfer_callback (transfer_callback_args_t * p_args)
  273. {
  274. FSP_PARAMETER_NOT_USED(p_args);
  275. sci_uart_rx_dmac_callback(&g_uart0_ctrl);
  276. }
  277. #endif
  278. #undef FSP_NOT_DEFINED
  279. sci_baud_setting_t g_uart0_baud_setting =
  280. {
  281. /* Baud rate calculated with 0.160% error. */ .baudrate_bits_b.abcse = 0, .baudrate_bits_b.abcs = 0, .baudrate_bits_b.bgdm = 1, .baudrate_bits_b.cks = 0, .baudrate_bits_b.brr = 51, .baudrate_bits_b.mddr = (uint8_t) 256, .baudrate_bits_b.brme = false
  282. };
  283. /** UART extended configuration for UARTonSCI HAL driver */
  284. const sci_uart_extended_cfg_t g_uart0_cfg_extend =
  285. {
  286. .clock = SCI_UART_CLOCK_INT,
  287. .rx_edge_start = SCI_UART_START_BIT_FALLING_EDGE,
  288. .noise_cancel = SCI_UART_NOISE_CANCELLATION_DISABLE,
  289. .rx_fifo_trigger = SCI_UART_RX_FIFO_TRIGGER_MAX,
  290. .p_baud_setting = &g_uart0_baud_setting,
  291. #if 1
  292. .clock_source = SCI_UART_CLOCK_SOURCE_SCI0ASYNCCLK,
  293. #else
  294. .clock_source = SCI_UART_CLOCK_SOURCE_PCLKM,
  295. #endif
  296. .flow_control = SCI_UART_FLOW_CONTROL_RTS,
  297. #if 0xFF != 0xFF
  298. .flow_control_pin = BSP_IO_PORT_FF_PIN_0xFF,
  299. #else
  300. .flow_control_pin = (bsp_io_port_pin_t) UINT16_MAX,
  301. #endif
  302. .rs485_setting = {
  303. .enable = SCI_UART_RS485_DISABLE,
  304. .polarity = SCI_UART_RS485_DE_POLARITY_HIGH,
  305. .assertion_time = 1,
  306. .negation_time = 1,
  307. },
  308. };
  309. /** UART interface configuration */
  310. const uart_cfg_t g_uart0_cfg =
  311. {
  312. .channel = 0,
  313. .data_bits = UART_DATA_BITS_8,
  314. .parity = UART_PARITY_OFF,
  315. .stop_bits = UART_STOP_BITS_1,
  316. .p_callback = user_uart0_callback,
  317. .p_context = NULL,
  318. .p_extend = &g_uart0_cfg_extend,
  319. .p_transfer_tx = g_uart0_P_TRANSFER_TX,
  320. .p_transfer_rx = g_uart0_P_TRANSFER_RX,
  321. .rxi_ipl = (12),
  322. .txi_ipl = (12),
  323. .tei_ipl = (12),
  324. .eri_ipl = (12),
  325. #if defined(VECTOR_NUMBER_SCI0_RXI)
  326. .rxi_irq = VECTOR_NUMBER_SCI0_RXI,
  327. #else
  328. .rxi_irq = FSP_INVALID_VECTOR,
  329. #endif
  330. #if defined(VECTOR_NUMBER_SCI0_TXI)
  331. .txi_irq = VECTOR_NUMBER_SCI0_TXI,
  332. #else
  333. .txi_irq = FSP_INVALID_VECTOR,
  334. #endif
  335. #if defined(VECTOR_NUMBER_SCI0_TEI)
  336. .tei_irq = VECTOR_NUMBER_SCI0_TEI,
  337. #else
  338. .tei_irq = FSP_INVALID_VECTOR,
  339. #endif
  340. #if defined(VECTOR_NUMBER_SCI0_ERI)
  341. .eri_irq = VECTOR_NUMBER_SCI0_ERI,
  342. #else
  343. .eri_irq = FSP_INVALID_VECTOR,
  344. #endif
  345. };
  346. /* Instance structure to use this module. */
  347. const uart_instance_t g_uart0 =
  348. {
  349. .p_ctrl = &g_uart0_ctrl,
  350. .p_cfg = &g_uart0_cfg,
  351. .p_api = &g_uart_on_sci
  352. };
  353. void g_hal_init(void) {
  354. g_common_init();
  355. }