mcu_init.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /***********************************************************************************************************************
  2. * DISCLAIMER
  3. * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No
  4. * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all
  5. * applicable laws, including copyright laws.
  6. * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
  7. * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY,
  8. * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM
  9. * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES
  10. * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS
  11. * SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  12. * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of
  13. * this software. By using this software, you agree to the additional terms and conditions found by accessing the
  14. * following link:
  15. * http://www.renesas.com/disclaimer
  16. *
  17. * Copyright (C) 2016 Renesas Electronics Corporation. All rights reserved.
  18. ***********************************************************************************************************************/
  19. /***********************************************************************************************************************
  20. * File Name : mcu_init.c
  21. * Description : Performs initialization common to all MCUs in this Group
  22. ***********************************************************************************************************************/
  23. /**********************************************************************************************************************
  24. * History : DD.MM.YYYY Version Description
  25. * : 01.10.2016 1.00 First Release
  26. * : 15.05.2017 2.00 Added port setting of 177 pins and 176 pins.
  27. * Added setting of PORTG.
  28. ***********************************************************************************************************************/
  29. /***********************************************************************************************************************
  30. Includes <System Includes> , "Project Includes"
  31. ***********************************************************************************************************************/
  32. /* Get specifics on this MCU. */
  33. #include "platform.h"
  34. /***********************************************************************************************************************
  35. Macro definitions
  36. ***********************************************************************************************************************/
  37. /* RX MCUs come in different packages and different pin counts. For MCUs that do not have the maximum number of pins
  38. * for their group (e.g. MCU with 100 pins when maximum is 177 pins) these 'non-existent' pins that are not bonded out
  39. * need to be initialized to save power. The macros below define the non-existent pins on each port for smaller
  40. * pin count MCUs. If a pin is non-existent then its value is set to a 1. These values are then ORed into the
  41. * direction registers to set non-existent pins as outputs which can help save power.
  42. */
  43. #if ((BSP_PACKAGE_PINS == 177) || (BSP_PACKAGE_PINS == 176))
  44. #define BSP_PRV_PORT0_NE_PIN_MASK (0x50) /* Missing pins: P04 P06 */
  45. #define BSP_PRV_PORT1_NE_PIN_MASK (0x00) /* Missing pins: None */
  46. #define BSP_PRV_PORT2_NE_PIN_MASK (0x00) /* Missing pins: None */
  47. #define BSP_PRV_PORT3_NE_PIN_MASK (0x00) /* Missing pins: None */
  48. #define BSP_PRV_PORT4_NE_PIN_MASK (0x00) /* Missing pins: None */
  49. #define BSP_PRV_PORT5_NE_PIN_MASK (0x00) /* Missing pins: None */
  50. #define BSP_PRV_PORT6_NE_PIN_MASK (0x00) /* Missing pins: None */
  51. #define BSP_PRV_PORT7_NE_PIN_MASK (0x00) /* Missing pins: None */
  52. #define BSP_PRV_PORT8_NE_PIN_MASK (0x00) /* Missing pins: None */
  53. #define BSP_PRV_PORT9_NE_PIN_MASK (0x00) /* Missing pins: None */
  54. #define BSP_PRV_PORTA_NE_PIN_MASK (0x00) /* Missing pins: None */
  55. #define BSP_PRV_PORTB_NE_PIN_MASK (0x00) /* Missing pins: None */
  56. #define BSP_PRV_PORTC_NE_PIN_MASK (0x00) /* Missing pins: None */
  57. #define BSP_PRV_PORTD_NE_PIN_MASK (0x00) /* Missing pins: None */
  58. #define BSP_PRV_PORTE_NE_PIN_MASK (0x00) /* Missing pins: None */
  59. #define BSP_PRV_PORTF_NE_PIN_MASK (0xC0) /* Missing pins: PF6 PF7 */
  60. #define BSP_PRV_PORTG_NE_PIN_MASK (0x00) /* Missing pins: None */
  61. #define BSP_PRV_PORTJ_NE_PIN_MASK (0xD0) /* Missing pins: PJ4 PJ6 PJ7 */
  62. #elif ((BSP_PACKAGE_PINS == 145) || (BSP_PACKAGE_PINS == 144))
  63. #define BSP_PRV_PORT0_NE_PIN_MASK (0x50) /* Missing pins: P04 P06 */
  64. #define BSP_PRV_PORT1_NE_PIN_MASK (0x03) /* Missing pins: P10 P11 */
  65. #define BSP_PRV_PORT2_NE_PIN_MASK (0x00) /* Missing pins: None */
  66. #define BSP_PRV_PORT3_NE_PIN_MASK (0x00) /* Missing pins: None */
  67. #define BSP_PRV_PORT4_NE_PIN_MASK (0x00) /* Missing pins: None */
  68. #define BSP_PRV_PORT5_NE_PIN_MASK (0x80) /* Missing pins: P57 */
  69. #define BSP_PRV_PORT6_NE_PIN_MASK (0x00) /* Missing pins: None */
  70. #define BSP_PRV_PORT7_NE_PIN_MASK (0x00) /* Missing pins: None */
  71. #define BSP_PRV_PORT8_NE_PIN_MASK (0x30) /* Missing pins: P84 P85 */
  72. #define BSP_PRV_PORT9_NE_PIN_MASK (0xF0) /* Missing pins: P94 P95 P96 P97 */
  73. #define BSP_PRV_PORTA_NE_PIN_MASK (0x00) /* Missing pins: None */
  74. #define BSP_PRV_PORTB_NE_PIN_MASK (0x00) /* Missing pins: None */
  75. #define BSP_PRV_PORTC_NE_PIN_MASK (0x00) /* Missing pins: None */
  76. #define BSP_PRV_PORTD_NE_PIN_MASK (0x00) /* Missing pins: None */
  77. #define BSP_PRV_PORTE_NE_PIN_MASK (0x00) /* Missing pins: None */
  78. #define BSP_PRV_PORTF_NE_PIN_MASK (0xDF) /* Missing pins: PF0 PF1 PF2 PF3 PF4 PF6 PF7 */
  79. #if defined(BSP_MCU_RX65N_2MB)
  80. #define BSP_PRV_PORTG_NE_PIN_MASK (0xFF) /* Missing pins: PG0 PG1 PG2 PG3 PG4 PG5 PG6 PG7 */
  81. #endif
  82. #define BSP_PRV_PORTJ_NE_PIN_MASK (0xD7) /* Missing pins: PJ0 PJ1 PJ2 PJ4 PJ6 PJ7 */
  83. #elif (BSP_PACKAGE_PINS == 100)
  84. #define BSP_PRV_PORT0_NE_PIN_MASK (0x5F) /* Missing pins: P00 P01 P02 P03 P04 P06 */
  85. #define BSP_PRV_PORT1_NE_PIN_MASK (0x03) /* Missing pins: P10 P11 */
  86. #define BSP_PRV_PORT2_NE_PIN_MASK (0x00) /* Missing pins: None */
  87. #define BSP_PRV_PORT3_NE_PIN_MASK (0x00) /* Missing pins: None */
  88. #define BSP_PRV_PORT4_NE_PIN_MASK (0x00) /* Missing pins: None */
  89. #define BSP_PRV_PORT5_NE_PIN_MASK (0xC0) /* Missing pins: P56 P57 */
  90. #define BSP_PRV_PORT6_NE_PIN_MASK (0xFF) /* Missing pins: P60 P61 P62 P63 P64 P65 P66 P67 */
  91. #define BSP_PRV_PORT7_NE_PIN_MASK (0xFF) /* Missing pins: P70 P71 P72 P73 P74 P75 P76 P77 */
  92. #define BSP_PRV_PORT8_NE_PIN_MASK (0xFF) /* Missing pins: P80 P81 P82 P83 P84 P85 P86 P87 */
  93. #define BSP_PRV_PORT9_NE_PIN_MASK (0xFF) /* Missing pins: P90 P91 P92 P93 P94 P95 P96 P97 */
  94. #define BSP_PRV_PORTA_NE_PIN_MASK (0x00) /* Missing pins: None */
  95. #define BSP_PRV_PORTB_NE_PIN_MASK (0x00) /* Missing pins: None */
  96. #define BSP_PRV_PORTC_NE_PIN_MASK (0x00) /* Missing pins: None */
  97. #define BSP_PRV_PORTD_NE_PIN_MASK (0x00) /* Missing pins: None */
  98. #define BSP_PRV_PORTE_NE_PIN_MASK (0x00) /* Missing pins: None */
  99. #define BSP_PRV_PORTF_NE_PIN_MASK (0xFF) /* Missing pins: PF0 PF1 PF2 PF3 PF4 PF5 PF6 PF7 */
  100. #if defined(BSP_MCU_RX65N_2MB)
  101. #define BSP_PRV_PORTG_NE_PIN_MASK (0xFF) /* Missing pins: PG0 PG1 PG2 PG3 PG4 PG5 PG6 PG7 */
  102. #endif
  103. #define BSP_PRV_PORTJ_NE_PIN_MASK (0xF7) /* Missing pins: PJ0 PJ1 PJ2 PJ4 PJ5 PJ6 PJ7 */
  104. #else
  105. #error "ERROR - This package is not defined in mcu_init.c"
  106. #endif
  107. /***********************************************************************************************************************
  108. Typedef definitions
  109. ***********************************************************************************************************************/
  110. /***********************************************************************************************************************
  111. Exported global variables (to be accessed by other files)
  112. ***********************************************************************************************************************/
  113. /***********************************************************************************************************************
  114. Private global variables and functions
  115. ***********************************************************************************************************************/
  116. /***********************************************************************************************************************
  117. * Function Name: bsp_non_existent_port_init
  118. * Description : For MCUs that do not have the maximum number of pins for their group (e.g. MCU with 100 pins when
  119. * maximum is 177 pins) these 'non-existent' pins that are not bonded out need to be initialized to save
  120. * power.
  121. * Arguments : none
  122. * Return Value : none
  123. ***********************************************************************************************************************/
  124. void bsp_non_existent_port_init (void)
  125. {
  126. /* OR in missing pin masks from above. */
  127. PORT0.PDR.BYTE |= BSP_PRV_PORT0_NE_PIN_MASK;
  128. PORT1.PDR.BYTE |= BSP_PRV_PORT1_NE_PIN_MASK;
  129. PORT2.PDR.BYTE |= BSP_PRV_PORT2_NE_PIN_MASK;
  130. PORT3.PDR.BYTE |= BSP_PRV_PORT3_NE_PIN_MASK;
  131. PORT4.PDR.BYTE |= BSP_PRV_PORT4_NE_PIN_MASK;
  132. PORT5.PDR.BYTE |= BSP_PRV_PORT5_NE_PIN_MASK;
  133. PORT6.PDR.BYTE |= BSP_PRV_PORT6_NE_PIN_MASK;
  134. PORT7.PDR.BYTE |= BSP_PRV_PORT7_NE_PIN_MASK;
  135. PORT8.PDR.BYTE |= BSP_PRV_PORT8_NE_PIN_MASK;
  136. PORT9.PDR.BYTE |= BSP_PRV_PORT9_NE_PIN_MASK;
  137. PORTA.PDR.BYTE |= BSP_PRV_PORTA_NE_PIN_MASK;
  138. PORTB.PDR.BYTE |= BSP_PRV_PORTB_NE_PIN_MASK;
  139. PORTC.PDR.BYTE |= BSP_PRV_PORTC_NE_PIN_MASK;
  140. PORTD.PDR.BYTE |= BSP_PRV_PORTD_NE_PIN_MASK;
  141. PORTE.PDR.BYTE |= BSP_PRV_PORTE_NE_PIN_MASK;
  142. PORTF.PDR.BYTE |= BSP_PRV_PORTF_NE_PIN_MASK;
  143. #if defined(BSP_MCU_RX65N_2MB)
  144. PORTG.PDR.BYTE |= BSP_PRV_PORTG_NE_PIN_MASK;
  145. #endif
  146. PORTJ.PDR.BYTE |= BSP_PRV_PORTJ_NE_PIN_MASK;
  147. }