From 42e6162e4ee9c687313564896d34b035af735ebe Mon Sep 17 00:00:00 2001 From: SuguruHarada Date: Fri, 27 Oct 2023 11:18:02 +0900 Subject: [PATCH] [update] RL78/G22_FPB related files for Arduino library. --- cores/rl78g22/Arduino.h | 9 +- cores/rl78g22/HardwareUart.cpp | 2607 +++++------ cores/rl78g22/HardwareUart.h | 9 + cores/rl78g22/WInterrupts.c | 224 +- cores/rl78g22/WMath.cpp | 148 +- cores/rl78g22/api/ArduinoAPI.h | 57 + cores/rl78g22/api/Binary.h | 552 +++ cores/rl78g22/api/Client.h | 46 + cores/rl78g22/api/Common.cpp | 10 + cores/rl78g22/api/Common.h | 171 + cores/rl78g22/api/Compat.h | 16 + cores/rl78g22/api/HardwareI2C.h | 47 + cores/rl78g22/api/HardwareSPI.h | 130 + cores/rl78g22/api/HardwareSerial.h | 105 + cores/rl78g22/api/IPAddress.cpp | 341 ++ cores/rl78g22/api/IPAddress.h | 119 + cores/rl78g22/api/Interrupts.h | 44 + cores/rl78g22/api/PluggableUSB.cpp | 101 + cores/rl78g22/api/PluggableUSB.h | 78 + cores/rl78g22/api/Print.cpp | 381 ++ cores/rl78g22/api/Print.h | 96 + cores/rl78g22/api/Printable.h | 39 + cores/rl78g22/api/RingBuffer.h | 141 + cores/rl78g22/api/Server.h | 31 + cores/rl78g22/api/Stream.cpp | 321 ++ cores/rl78g22/api/Stream.h | 133 + cores/rl78g22/api/String.cpp | 756 ++++ cores/rl78g22/api/String.h | 260 ++ cores/rl78g22/api/USBAPI.h | 64 + cores/rl78g22/api/Udp.h | 92 + cores/rl78g22/api/WCharacter.h | 171 + .../deprecated-avr-comp/avr/dtostrf.c.impl | 37 + .../api/deprecated-avr-comp/avr/dtostrf.h | 34 + .../api/deprecated-avr-comp/avr/interrupt.h | 23 + .../api/deprecated-avr-comp/avr/pgmspace.h | 122 + cores/rl78g22/api/deprecated/Client.h | 25 + cores/rl78g22/api/deprecated/HardwareSerial.h | 25 + cores/rl78g22/api/deprecated/IPAddress.h | 25 + cores/rl78g22/api/deprecated/Print.h | 24 + cores/rl78g22/api/deprecated/Printable.h | 24 + cores/rl78g22/api/deprecated/Server.h | 25 + cores/rl78g22/api/deprecated/Stream.h | 25 + cores/rl78g22/api/deprecated/Udp.h | 25 + cores/rl78g22/api/deprecated/WString.h | 24 + cores/rl78g22/api/itoa.h | 37 + cores/rl78g22/dtostrf.c | 142 + cores/rl78g22/itoa.c | 125 + cores/rl78g22/main.cpp | 270 +- cores/rl78g22/smc_gen/Config_ADC/Config_ADC.c | 750 ++-- cores/rl78g22/smc_gen/Config_ADC/Config_ADC.h | 186 +- .../smc_gen/Config_ADC/Config_ADC_user.c | 152 +- .../smc_gen/Config_CSI20/Config_CSI20.c | 595 +-- .../smc_gen/Config_CSI20/Config_CSI20.h | 134 +- .../smc_gen/Config_CSI20/Config_CSI20_user.c | 354 +- .../smc_gen/Config_IICA0/Config_IICA0.c | 608 +-- .../smc_gen/Config_IICA0/Config_IICA0.h | 130 +- .../smc_gen/Config_IICA0/Config_IICA0_user.c | 454 +- .../rl78g22/smc_gen/Config_INTC/Config_INTC.c | 1224 ++---- .../rl78g22/smc_gen/Config_INTC/Config_INTC.h | 144 +- .../smc_gen/Config_INTC/Config_INTC_user.c | 365 +- .../smc_gen/Config_ITL000/Config_ITL000.c | 282 +- .../smc_gen/Config_ITL000/Config_ITL000.h | 126 +- .../Config_ITL000/Config_ITL000_user.c | 180 +- .../smc_gen/Config_ITL001/Config_ITL001.c | 262 +- .../smc_gen/Config_ITL001/Config_ITL001.h | 126 +- .../Config_ITL001/Config_ITL001_user.c | 210 +- .../smc_gen/Config_ITL012/Config_ITL012.c | 240 +- .../smc_gen/Config_ITL012/Config_ITL012.h | 120 +- .../Config_ITL012/Config_ITL012_user.c | 166 +- .../smc_gen/Config_ITL013/Config_ITL013.c | 260 +- .../smc_gen/Config_ITL013/Config_ITL013.h | 122 +- .../Config_ITL013/Config_ITL013_user.c | 165 +- cores/rl78g22/smc_gen/Config_RTC/Config_RTC.c | 934 ++-- cores/rl78g22/smc_gen/Config_RTC/Config_RTC.h | 218 +- .../smc_gen/Config_RTC/Config_RTC_user.c | 240 +- .../Config_TAU0_01_PWM_user.c | 86 - .../Config_TAU0_0_Measure_Signal.c | 280 -- .../Config_TAU0_0_Measure_Signal.h | 85 - .../Config_TAU0_0_Measure_Signal_user.c | 85 - .../Config_TAU0_0_PWM.c} | 358 +- .../Config_TAU0_0_PWM.h} | 139 +- .../Config_TAU0_0_PWM_user.c} | 153 +- .../Config_TAU0_1_Measure_Signal.c | 127 - .../Config_TAU0_1_Measure_Signal.h | 58 - .../Config_TAU0_1_Measure_Signal_user.c | 110 - .../Config_TAU0_1_Servo/Config_TAU0_1_Servo.c | 113 - .../Config_TAU0_1_Servo/Config_TAU0_1_Servo.h | 58 - .../Config_TAU0_1_Servo_user.c | 74 - .../Config_TAU0_1_Square_Wave.c | 226 +- .../Config_TAU0_1_Square_Wave.h | 116 +- .../Config_TAU0_1_Square_Wave_user.c | 148 +- .../Config_TAU0_23_PWM/Config_TAU0_23_PWM.c | 128 - .../Config_TAU0_23_PWM/Config_TAU0_23_PWM.h | 60 - .../Config_TAU0_23_PWM_user.c | 86 - .../Config_TAU0_2_Measure_Signal.c | 126 - .../Config_TAU0_2_Measure_Signal.h | 58 - .../Config_TAU0_2_Measure_Signal_user.c | 107 - .../Config_TAU0_2_Servo/Config_TAU0_2_Servo.c | 114 - .../Config_TAU0_2_Servo/Config_TAU0_2_Servo.h | 58 - .../Config_TAU0_2_Servo_user.c | 74 - .../Config_TAU0_2_Square_Wave.c | 228 +- .../Config_TAU0_2_Square_Wave.h | 116 +- .../Config_TAU0_2_Square_Wave_user.c | 148 +- .../Config_TAU0_3_Measure_Signal.c | 126 - .../Config_TAU0_3_Measure_Signal.h | 58 - .../Config_TAU0_3_Measure_Signal_user.c | 107 - .../Config_TAU0_3_Servo/Config_TAU0_3_Servo.c | 114 - .../Config_TAU0_3_Servo/Config_TAU0_3_Servo.h | 58 - .../Config_TAU0_3_Servo_user.c | 74 - .../Config_TAU0_3_Square_Wave.c | 226 +- .../Config_TAU0_3_Square_Wave.h | 116 +- .../Config_TAU0_3_Square_Wave_user.c | 148 +- .../Config_TAU0_4_Servo/Config_TAU0_4_Servo.c | 114 - .../Config_TAU0_4_Servo/Config_TAU0_4_Servo.h | 58 - .../Config_TAU0_5_Servo/Config_TAU0_5_Servo.c | 114 - .../Config_TAU0_5_Servo/Config_TAU0_5_Servo.h | 58 - .../Config_TAU0_5_Servo_user.c | 74 - .../Config_TAU0_67_PWM/Config_TAU0_67_PWM.c | 127 - .../Config_TAU0_67_PWM/Config_TAU0_67_PWM.h | 60 - .../Config_TAU0_67_PWM_user.c | 86 - .../Config_TAU0_6_Micros.c | 214 +- .../Config_TAU0_6_Micros.h | 116 +- .../Config_TAU0_6_Micros_user.c | 152 +- .../Config_TAU0_6_Servo/Config_TAU0_6_Servo.c | 114 - .../Config_TAU0_6_Servo/Config_TAU0_6_Servo.h | 58 - .../Config_TAU0_6_Servo_user.c | 74 - .../Config_TAU0_7_MSTimer2.c | 114 - .../Config_TAU0_7_MSTimer2.h | 59 - .../Config_TAU0_7_MSTimer2_user.c | 85 - .../Config_TAU0_7_Measure_Signal.c | 127 - .../Config_TAU0_7_Measure_Signal.h | 58 - .../Config_TAU0_7_user.c | 108 - .../Config_TAU0_7_Servo/Config_TAU0_7_Servo.c | 114 - .../Config_TAU0_7_Servo/Config_TAU0_7_Servo.h | 58 - .../Config_TAU0_7_Servo_user.c | 74 - .../Config_TAU0_7_Square_Wave.c | 224 +- .../Config_TAU0_7_Square_Wave.h | 116 +- .../Config_TAU0_7_Square_Wave_user.c | 148 +- .../smc_gen/Config_UART0/Config_UART0.c | 456 +- .../smc_gen/Config_UART0/Config_UART0.h | 126 +- .../smc_gen/Config_UART0/Config_UART0_user.c | 395 +- .../smc_gen/Config_UART1/Config_UART1.c | 454 +- .../smc_gen/Config_UART1/Config_UART1.h | 126 +- .../smc_gen/Config_UART1/Config_UART1_user.c | 394 +- .../smc_gen/Config_UART2/Config_UART2.c | 452 +- .../smc_gen/Config_UART2/Config_UART2.h | 126 +- .../smc_gen/Config_UART2/Config_UART2_user.c | 394 +- cores/rl78g22/smc_gen/general/r_cg_ad.h | 328 +- .../rl78g22/smc_gen/general/r_cg_ad_common.c | 188 +- .../rl78g22/smc_gen/general/r_cg_ad_common.h | 104 +- cores/rl78g22/smc_gen/general/r_cg_iica.h | 350 +- .../smc_gen/general/r_cg_iica_common.c | 188 +- .../smc_gen/general/r_cg_iica_common.h | 108 +- cores/rl78g22/smc_gen/general/r_cg_intc.h | 230 +- .../smc_gen/general/r_cg_interrupt_handlers.h | 616 ++- .../rl78g22/smc_gen/general/r_cg_inthandler.c | 504 +-- cores/rl78g22/smc_gen/general/r_cg_itl.h | 424 +- .../rl78g22/smc_gen/general/r_cg_itl_common.c | 272 +- .../rl78g22/smc_gen/general/r_cg_itl_common.h | 110 +- .../smc_gen/general/r_cg_itl_common_user.c | 166 +- .../smc_gen/general/r_cg_macrodriver.h | 156 +- cores/rl78g22/smc_gen/general/r_cg_rtc.h | 228 +- .../rl78g22/smc_gen/general/r_cg_rtc_common.c | 154 +- .../rl78g22/smc_gen/general/r_cg_rtc_common.h | 102 +- cores/rl78g22/smc_gen/general/r_cg_sau.h | 711 ++- .../rl78g22/smc_gen/general/r_cg_sau_common.c | 448 +- .../rl78g22/smc_gen/general/r_cg_sau_common.h | 120 +- .../rl78g22/smc_gen/general/r_cg_systeminit.c | 160 +- cores/rl78g22/smc_gen/general/r_cg_tau.h | 860 ++-- .../rl78g22/smc_gen/general/r_cg_tau_common.c | 221 +- .../rl78g22/smc_gen/general/r_cg_tau_common.h | 108 +- .../rl78g22/smc_gen/general/r_cg_userdefine.h | 122 +- .../rl78g22/smc_gen/general/r_cg_vect_table.c | 896 ++-- cores/rl78g22/smc_gen/general/r_cg_wdt.h | 98 +- cores/rl78g22/smc_gen/general/r_smc_entry.h | 176 +- .../r_bsp/board/generic_rl78_g22/hdwinit.c | 266 +- .../r_bsp/board/generic_rl78_g22/hdwinit.h | 90 +- .../r_bsp/board/generic_rl78_g22/r_bsp.h | 122 +- .../generic_rl78_g22/r_bsp_config_reference.h | 1122 ++--- .../r_bsp_config_reference_ccrl.inc | 72 +- .../r_bsp_config_reference_iccrl.inc | 72 +- .../r_bsp_config_reference_llvm.inc | 72 +- .../r_bsp/board/generic_rl78_g22/r_bsp_init.c | 226 +- .../smc_gen/r_bsp/mcu/all/fsp_common_api.h | 352 +- .../smc_gen/r_bsp/mcu/all/r_bsp_common.c | 516 +-- .../smc_gen/r_bsp/mcu/all/r_bsp_common.h | 268 +- .../smc_gen/r_bsp/mcu/all/r_bsp_common_llvm.S | 112 +- .../r_bsp/mcu/all/r_bsp_rl78_compiler.h | 368 +- .../smc_gen/r_bsp/mcu/all/r_fsp_error.h | 144 +- cores/rl78g22/smc_gen/r_bsp/mcu/all/r_rtos.h | 110 +- cores/rl78g22/smc_gen/r_bsp/mcu/all/start.S | 550 +-- .../smc_gen/r_bsp/mcu/rl78_g22/mcu_clocks.c | 1822 ++++---- .../smc_gen/r_bsp/mcu/rl78_g22/mcu_clocks.h | 122 +- .../smc_gen/r_bsp/mcu/rl78_g22/mcu_info.h | 106 +- .../rl78_g22/register_access/llvm/iodefine.h | 1850 ++++---- .../register_access/llvm/iodefine_ext.h | 2018 ++++----- cores/rl78g22/smc_gen/r_bsp/platform.h | 124 +- cores/rl78g22/smc_gen/r_bsp/readme.txt | 8 +- cores/rl78g22/smc_gen/r_config/r_bsp_config.h | 1126 ++--- .../rl78g22/smc_gen/r_config/r_bsp_config.inc | 74 +- cores/rl78g22/utilities.cpp | 1360 +++--- cores/rl78g22/utilities.h | 149 +- cores/rl78g22/wiring.c | 828 ++-- cores/rl78g22/wiring_analog.c | 940 ++-- cores/rl78g22/wiring_digital.c | 741 ++-- cores/rl78g22/wiring_private.h | 154 +- cores/rl78g22/wiring_pulse.c | 357 +- cores/rl78g22/wiring_pulse_long.c | 92 + cores/rl78g22/wiring_shift.c | 212 +- cores/rl78g22/wiring_tone.cpp | 280 +- libraries/Ethernet3/.gitignore | 2 + libraries/Ethernet3/README.md | 275 ++ libraries/Ethernet3/__library.json__ | 14 + .../AdvancedChatServer/AdvancedChatServer.ino | 110 + .../examples/ChatServer/ChatServer.ino | 79 + .../DhcpAddressPrinter/DhcpAddressPrinter.ino | 62 + .../DhcpChatServer/DhcpChatServer.ino | 89 + .../examples/TelnetClient/TelnetClient.ino | 95 + .../examples/WebClient/WebClient.ino | 89 + .../examples/WebServer/WebServer.ino | 103 + libraries/Ethernet3/keywords.txt | 73 + libraries/Ethernet3/library.properties | 9 + libraries/Ethernet3/src/Dhcp.cpp | 489 +++ libraries/Ethernet3/src/Dhcp.h | 180 + libraries/Ethernet3/src/Dns.cpp | 421 ++ libraries/Ethernet3/src/Dns.h | 41 + libraries/Ethernet3/src/Ethernet3.cpp | 398 ++ libraries/Ethernet3/src/Ethernet3.h | 114 + libraries/Ethernet3/src/EthernetClient.cpp | 202 + libraries/Ethernet3/src/EthernetClient.h | 54 + libraries/Ethernet3/src/EthernetServer.cpp | 91 + libraries/Ethernet3/src/EthernetServer.h | 22 + libraries/Ethernet3/src/EthernetUdp3.cpp | 293 ++ libraries/Ethernet3/src/EthernetUdp3.h | 116 + libraries/Ethernet3/src/utility/socket.cpp | 416 ++ libraries/Ethernet3/src/utility/socket.h | 48 + libraries/Ethernet3/src/utility/util.h | 14 + libraries/Ethernet3/src/utility/w5500.cpp | 240 ++ libraries/Ethernet3/src/utility/w5500.h | 427 ++ libraries/LiquidCrystal/README.adoc | 25 + .../examples/Autoscroll/Autoscroll.ino | 78 + .../LiquidCrystal/examples/Blink/Blink.ino | 65 + .../LiquidCrystal/examples/Cursor/Cursor.ino | 65 + .../CustomCharacter/CustomCharacter.ino | 147 + .../examples/Display/Display.ino | 65 + .../examples/HelloWorld/HelloWorld.ino | 65 + .../LiquidCrystal/examples/Scroll/Scroll.ino | 90 + .../examples/SerialDisplay/SerialDisplay.ino | 69 + .../examples/TextDirection/TextDirection.ino | 90 + .../examples/setCursor/setCursor.ino | 76 + libraries/LiquidCrystal/keywords.txt | 38 + libraries/LiquidCrystal/library.properties | 9 + libraries/LiquidCrystal/src/LiquidCrystal.cpp | 326 ++ libraries/LiquidCrystal/src/LiquidCrystal.h | 108 + libraries/MsTimer2/MsTimer2.cpp | 60 + libraries/MsTimer2/MsTimer2.h | 15 + libraries/MsTimer2/README.md | 7 + .../MsTimer2/examples/FlashLed/FlashLed.ino | 32 + libraries/MsTimer2/keywords.txt | 4 + libraries/MsTimer2/library.properties | 9 + libraries/SPI/SPI.cpp | 97 + libraries/SPI/SPI.h | 279 ++ libraries/SPI/SPI_CSI.cpp | 341 ++ libraries/SPI/SPI_CSI.h | 53 + libraries/SPI/library.properties | 9 + .../SoftwareSerialExample.ino | 54 + libraries/SoftwareSerial/keywords.txt | 30 + libraries/SoftwareSerial/library.properties | 9 + .../SoftwareSerial/src/SoftwareSerial.cpp | 572 +++ libraries/SoftwareSerial/src/SoftwareSerial.h | 129 + libraries/Wire/examples/i2c-lcd/i2c-lcd.ino | 123 + libraries/Wire/library.properties | 2 +- libraries/Wire/src/Wire.h | 5 +- libraries/Wire/src/Wire_IICA.cpp | 1 - platform.txt | 68 +- .../linker_scripts/gcc/linker_script.ld | 497 ++- variants/g22-fpb-48p/pins_variant.h | 12 +- variants/g22-fpb-48p/pintable.c | 1950 ++++----- variants/g22-fpb-48p/pintable.h | 124 +- variants/g22-fpb-48p/r_mmc_sfr.h | 3802 ++++++++--------- variants/g22-fpb-48p/r_mmc_user_config.h | 288 +- variants/g22-fpb-48p/wiring_private_tone.h | 210 +- variants/g22-fpb-48p/wiring_variant.h | 153 +- variants/g22-fpb-48p/wiring_variant_pwm.c | 86 +- 284 files changed, 37504 insertions(+), 29603 deletions(-) create mode 100644 cores/rl78g22/api/ArduinoAPI.h create mode 100644 cores/rl78g22/api/Binary.h create mode 100644 cores/rl78g22/api/Client.h create mode 100644 cores/rl78g22/api/Common.cpp create mode 100644 cores/rl78g22/api/Common.h create mode 100644 cores/rl78g22/api/Compat.h create mode 100644 cores/rl78g22/api/HardwareI2C.h create mode 100644 cores/rl78g22/api/HardwareSPI.h create mode 100644 cores/rl78g22/api/HardwareSerial.h create mode 100644 cores/rl78g22/api/IPAddress.cpp create mode 100644 cores/rl78g22/api/IPAddress.h create mode 100644 cores/rl78g22/api/Interrupts.h create mode 100644 cores/rl78g22/api/PluggableUSB.cpp create mode 100644 cores/rl78g22/api/PluggableUSB.h create mode 100644 cores/rl78g22/api/Print.cpp create mode 100644 cores/rl78g22/api/Print.h create mode 100644 cores/rl78g22/api/Printable.h create mode 100644 cores/rl78g22/api/RingBuffer.h create mode 100644 cores/rl78g22/api/Server.h create mode 100644 cores/rl78g22/api/Stream.cpp create mode 100644 cores/rl78g22/api/Stream.h create mode 100644 cores/rl78g22/api/String.cpp create mode 100644 cores/rl78g22/api/String.h create mode 100644 cores/rl78g22/api/USBAPI.h create mode 100644 cores/rl78g22/api/Udp.h create mode 100644 cores/rl78g22/api/WCharacter.h create mode 100644 cores/rl78g22/api/deprecated-avr-comp/avr/dtostrf.c.impl create mode 100644 cores/rl78g22/api/deprecated-avr-comp/avr/dtostrf.h create mode 100644 cores/rl78g22/api/deprecated-avr-comp/avr/interrupt.h create mode 100644 cores/rl78g22/api/deprecated-avr-comp/avr/pgmspace.h create mode 100644 cores/rl78g22/api/deprecated/Client.h create mode 100644 cores/rl78g22/api/deprecated/HardwareSerial.h create mode 100644 cores/rl78g22/api/deprecated/IPAddress.h create mode 100644 cores/rl78g22/api/deprecated/Print.h create mode 100644 cores/rl78g22/api/deprecated/Printable.h create mode 100644 cores/rl78g22/api/deprecated/Server.h create mode 100644 cores/rl78g22/api/deprecated/Stream.h create mode 100644 cores/rl78g22/api/deprecated/Udp.h create mode 100644 cores/rl78g22/api/deprecated/WString.h create mode 100644 cores/rl78g22/api/itoa.h create mode 100644 cores/rl78g22/dtostrf.c create mode 100644 cores/rl78g22/itoa.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_01_PWM/Config_TAU0_01_PWM_user.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_0_Measure_Signal/Config_TAU0_0_Measure_Signal.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_0_Measure_Signal/Config_TAU0_0_Measure_Signal.h delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_0_Measure_Signal/Config_TAU0_0_Measure_Signal_user.c rename cores/rl78g22/smc_gen/{Config_TAU0_01_PWM/Config_TAU0_01_PWM.c => Config_TAU0_0_PWM/Config_TAU0_0_PWM.c} (52%) rename cores/rl78g22/smc_gen/{Config_TAU0_01_PWM/Config_TAU0_01_PWM.h => Config_TAU0_0_PWM/Config_TAU0_0_PWM.h} (68%) rename cores/rl78g22/smc_gen/{Config_TAU0_4_Servo/Config_TAU0_4_Servo_user.c => Config_TAU0_0_PWM/Config_TAU0_0_PWM_user.c} (77%) delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_1_Measure_Signal/Config_TAU0_1_Measure_Signal.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_1_Measure_Signal/Config_TAU0_1_Measure_Signal.h delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_1_Measure_Signal/Config_TAU0_1_Measure_Signal_user.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_1_Servo/Config_TAU0_1_Servo.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_1_Servo/Config_TAU0_1_Servo.h delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_1_Servo/Config_TAU0_1_Servo_user.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_23_PWM/Config_TAU0_23_PWM.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_23_PWM/Config_TAU0_23_PWM.h delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_23_PWM/Config_TAU0_23_PWM_user.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_2_Measure_Signal/Config_TAU0_2_Measure_Signal.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_2_Measure_Signal/Config_TAU0_2_Measure_Signal.h delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_2_Measure_Signal/Config_TAU0_2_Measure_Signal_user.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_2_Servo/Config_TAU0_2_Servo.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_2_Servo/Config_TAU0_2_Servo.h delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_2_Servo/Config_TAU0_2_Servo_user.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_3_Measure_Signal/Config_TAU0_3_Measure_Signal.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_3_Measure_Signal/Config_TAU0_3_Measure_Signal.h delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_3_Measure_Signal/Config_TAU0_3_Measure_Signal_user.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_3_Servo/Config_TAU0_3_Servo.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_3_Servo/Config_TAU0_3_Servo.h delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_3_Servo/Config_TAU0_3_Servo_user.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_4_Servo/Config_TAU0_4_Servo.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_4_Servo/Config_TAU0_4_Servo.h delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_5_Servo/Config_TAU0_5_Servo.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_5_Servo/Config_TAU0_5_Servo.h delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_5_Servo/Config_TAU0_5_Servo_user.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_67_PWM/Config_TAU0_67_PWM.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_67_PWM/Config_TAU0_67_PWM.h delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_67_PWM/Config_TAU0_67_PWM_user.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_6_Servo/Config_TAU0_6_Servo.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_6_Servo/Config_TAU0_6_Servo.h delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_6_Servo/Config_TAU0_6_Servo_user.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_7_MSTimer2/Config_TAU0_7_MSTimer2.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_7_MSTimer2/Config_TAU0_7_MSTimer2.h delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_7_MSTimer2/Config_TAU0_7_MSTimer2_user.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_7_Measure_Signal/Config_TAU0_7_Measure_Signal.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_7_Measure_Signal/Config_TAU0_7_Measure_Signal.h delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_7_Measure_Signal/Config_TAU0_7_user.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_7_Servo/Config_TAU0_7_Servo.c delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_7_Servo/Config_TAU0_7_Servo.h delete mode 100644 cores/rl78g22/smc_gen/Config_TAU0_7_Servo/Config_TAU0_7_Servo_user.c create mode 100644 cores/rl78g22/wiring_pulse_long.c create mode 100644 libraries/Ethernet3/.gitignore create mode 100644 libraries/Ethernet3/README.md create mode 100644 libraries/Ethernet3/__library.json__ create mode 100644 libraries/Ethernet3/examples/AdvancedChatServer/AdvancedChatServer.ino create mode 100644 libraries/Ethernet3/examples/ChatServer/ChatServer.ino create mode 100644 libraries/Ethernet3/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino create mode 100644 libraries/Ethernet3/examples/DhcpChatServer/DhcpChatServer.ino create mode 100644 libraries/Ethernet3/examples/TelnetClient/TelnetClient.ino create mode 100644 libraries/Ethernet3/examples/WebClient/WebClient.ino create mode 100644 libraries/Ethernet3/examples/WebServer/WebServer.ino create mode 100644 libraries/Ethernet3/keywords.txt create mode 100644 libraries/Ethernet3/library.properties create mode 100644 libraries/Ethernet3/src/Dhcp.cpp create mode 100644 libraries/Ethernet3/src/Dhcp.h create mode 100644 libraries/Ethernet3/src/Dns.cpp create mode 100644 libraries/Ethernet3/src/Dns.h create mode 100644 libraries/Ethernet3/src/Ethernet3.cpp create mode 100644 libraries/Ethernet3/src/Ethernet3.h create mode 100644 libraries/Ethernet3/src/EthernetClient.cpp create mode 100644 libraries/Ethernet3/src/EthernetClient.h create mode 100644 libraries/Ethernet3/src/EthernetServer.cpp create mode 100644 libraries/Ethernet3/src/EthernetServer.h create mode 100644 libraries/Ethernet3/src/EthernetUdp3.cpp create mode 100644 libraries/Ethernet3/src/EthernetUdp3.h create mode 100644 libraries/Ethernet3/src/utility/socket.cpp create mode 100644 libraries/Ethernet3/src/utility/socket.h create mode 100644 libraries/Ethernet3/src/utility/util.h create mode 100644 libraries/Ethernet3/src/utility/w5500.cpp create mode 100644 libraries/Ethernet3/src/utility/w5500.h create mode 100644 libraries/LiquidCrystal/README.adoc create mode 100644 libraries/LiquidCrystal/examples/Autoscroll/Autoscroll.ino create mode 100644 libraries/LiquidCrystal/examples/Blink/Blink.ino create mode 100644 libraries/LiquidCrystal/examples/Cursor/Cursor.ino create mode 100644 libraries/LiquidCrystal/examples/CustomCharacter/CustomCharacter.ino create mode 100644 libraries/LiquidCrystal/examples/Display/Display.ino create mode 100644 libraries/LiquidCrystal/examples/HelloWorld/HelloWorld.ino create mode 100644 libraries/LiquidCrystal/examples/Scroll/Scroll.ino create mode 100644 libraries/LiquidCrystal/examples/SerialDisplay/SerialDisplay.ino create mode 100644 libraries/LiquidCrystal/examples/TextDirection/TextDirection.ino create mode 100644 libraries/LiquidCrystal/examples/setCursor/setCursor.ino create mode 100644 libraries/LiquidCrystal/keywords.txt create mode 100644 libraries/LiquidCrystal/library.properties create mode 100644 libraries/LiquidCrystal/src/LiquidCrystal.cpp create mode 100644 libraries/LiquidCrystal/src/LiquidCrystal.h create mode 100644 libraries/MsTimer2/MsTimer2.cpp create mode 100644 libraries/MsTimer2/MsTimer2.h create mode 100644 libraries/MsTimer2/README.md create mode 100644 libraries/MsTimer2/examples/FlashLed/FlashLed.ino create mode 100644 libraries/MsTimer2/keywords.txt create mode 100644 libraries/MsTimer2/library.properties create mode 100644 libraries/SPI/SPI.cpp create mode 100644 libraries/SPI/SPI.h create mode 100644 libraries/SPI/SPI_CSI.cpp create mode 100644 libraries/SPI/SPI_CSI.h create mode 100644 libraries/SPI/library.properties create mode 100644 libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino create mode 100644 libraries/SoftwareSerial/keywords.txt create mode 100644 libraries/SoftwareSerial/library.properties create mode 100644 libraries/SoftwareSerial/src/SoftwareSerial.cpp create mode 100644 libraries/SoftwareSerial/src/SoftwareSerial.h create mode 100644 libraries/Wire/examples/i2c-lcd/i2c-lcd.ino diff --git a/cores/rl78g22/Arduino.h b/cores/rl78g22/Arduino.h index c302587..d349d39 100644 --- a/cores/rl78g22/Arduino.h +++ b/cores/rl78g22/Arduino.h @@ -23,8 +23,15 @@ #include "api/ArduinoAPI.h" #include #include "utilities.h" +#ifdef __cplusplus +extern "C" { +#endif #include "r_cg_macrodriver.h" +#ifdef __cplusplus +} +#endif #include "pintable.h" +#include "pins_variant.h" #define RLDUINO78_VERSION 0x0203 #define INTERRUPT @@ -70,10 +77,8 @@ extern "C"{ #define INPUT_TTL 0x5 #define INPUT_TTL_PULLUP 0x6 -// 2023/02/17 need confirm /* PWM setting. */ #define PWM_MASTER_CLOCK (32000000) -//#define PWM_MASTER_CLOCK (1000000) #if PWM_MASTER_CLOCK == 32000000 #define PWM_MASTER_MODE (0x0801) // CK0を選択 #define PWM_SLAVE_MODE (0x0409) diff --git a/cores/rl78g22/HardwareUart.cpp b/cores/rl78g22/HardwareUart.cpp index c01b739..62e0bcf 100644 --- a/cores/rl78g22/HardwareUart.cpp +++ b/cores/rl78g22/HardwareUart.cpp @@ -1,1286 +1,1321 @@ -/* - HardwareUart.cpp - Hardware serial library for Wiring - Copyright (c) 2006 Nicholas Zambetti. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Modified 23 November 2006 by David A. Mellis - Modified 28 September 2010 by Mark Sproul - Modified 14 August 2012 by Alarus - Modified 7 March 2013 by masahiko.nagata.cj@renesas.com - Modified 30 June 2013 by yuuki.okamiya.yn@renesas.com - Modified 13 Mar 2018 by yuuki.okamiya.yn@renesas.com -*/ -/* - * FIXME: Temporary: Debug Display Mode - * Remove this macro definition and macro use later, - * if `Serial.write()` is fixed to work. - */ -/* #define DEBUGDISP_MODE */ - - -#include -#include -#include -#include - -extern "C" { - uint32_t R_BSP_GetFclkFreqHz(void); - void Set_Char_Serial_from_buf(uint8_t chn); -} - -#include "Arduino.h" -#include "platform.h" - - -extern "C" { - #include "pintable.h" - extern const PinTableType * pinTablelist[NUM_DIGITAL_PINS]; -} - -extern "C" { -#if ( UART_CHANNEL == 0 ) - #include "Config_UART0.h" -#endif /* ( UART_CHANNEL == 0 ) */ -#if ( UART1_CHANNEL == 1 ) - #include "Config_UART1.h" -#endif /* ( UART1_CHANNEL == 1 ) */ -#if ( UART2_CHANNEL == 2 ) - #include "Config_UART2.h" -#endif /* ( UART2_CHANNEL == 2 ) */ - - -}; - -#if ( UART_CHANNEL == 0 ) /* ( UART_CHANNEL == 2 ) */ -#define URT_RXDx RXD0 -#define URT_TXDx TXD0 -#define URT_PERx PER0.per0 -#define URT_SAUxEN SAU0EN /* :PER0.2 */ -#define URT_SPSx SPS0 -#define URT_STx ST0 -#define URT_MKxx MK0H.mk0h -#define URT_IFxx IF0H.if0h -#define URT_PR1xx PR10H.pr10h -#define URT_PR0xx PR00H.pr00h -#define URT_STMKx STMK0 /* :MK0H.5 */ -#define URT_STIFx STIF0 /* :IF0H.5 */ -#define URT_SRMKx SRMK0 /* :MK0H.6 */ -#define URT_SRIFx SRIF0 /* :IF0H.6 */ -#define URT_SREMKx SREMK0 /* :MK0H.7 */ -#define URT_SREIFx SREIF0 /* :IF0H.7 */ -#define URT_STPR1x STPR10 /* :PR10H.5 */ -#define URT_STPR0x STPR00 /* :PR00H.5 */ -#define URT_SRPR1x SRPR10 /* :PR10H.6 */ -#define URT_SRPR0x SRPR00 /* :PR00H.6 */ -#define URT_SREPR1x SREPR10 /* :PR10H.7 */ -#define URT_SREPR0x SREPR00 /* :PR00H.7 */ -#define URT_SMRx0 SMR00 -#define URT_SCRx0 SCR00 -#define URT_SDRx0 SDR00 -#define URT_NFENx NFEN0 -#define URT_SNFENxx SNFEN00 /* :NFEN0.0 */ -#define URT_SIRx1 SIR01 -#define URT_SMRx1 SMR01 -#define URT_SCRx1 SCR01 -#define URT_SDRx1 SDR01 -#define URT_SOx SO0.so0 -#define URT_SOxx SO00 /* :SO0.0 */ -#define URT_SOLx SOL0 -#define URT_SOLxx SOL00 /* :SOL0.0 */ -#define URT_SOEx SOE0 -#define URT_SOExx SOE00 /* :SOE0.0 */ -#define URT_SSx SS0 -#define URT_SSxx SS00 /* :SS0.0 */ -#define URT_SSRx SSR00 -#define URT_Px P1 -#define URT_PMx PM1 -#define URT_TXD_Px 0x04 -#define URT_RXD_Px 0x02 -#endif /* ( UART_CHANNEL == 2 ) */ - -#if ( UART1_CHANNEL == 1 ) -#define URT1_RXDx RXD1 -#define URT1_TXDx TXD1 -#define URT1_PERx PER0.per0 -#define URT1_SAUxEN SAU0EN /* :PER0.2 */ -#define URT1_SPSx SPS0 -#define URT1_STx ST0 -#define URT1_MKxx MK1L.mk1l -#define URT1_IFxx IF1L.if1l -#define URT1_PR1xx PR11L.pr11l -#define URT1_PR0xx PR01L.pr01l -#define URT1_STMKx STMK1 /* :MK1L.0 */ -#define URT1_STIFx STIF1 /* :IF1L.0 */ -#define URT1_SRMKx SRMK1 /* :MK1L.1 */ -#define URT1_SRIFx SRIF1 /* :IF1L.1 */ -#define URT1_SREMKx SREMK1 /* :MK1L.2 */ -#define URT1_SREIFx SREIF1 /* :IF1L.2 */ -#define URT1_STPR1x STPR11 /* :PR11L.0 */ -#define URT1_STPR0x STPR01 /* :PR01L.0 */ -#define URT1_SRPR1x SRPR11 /* :PR11L.1 */ -#define URT1_SRPR0x SRPR01 /* :PR01L.1 */ -#define URT1_SREPR1x SREPR11 /* :PR11L.2 */ -#define URT1_SREPR0x SREPR01 /* :PR01L.2 */ -#define URT1_SMRx0 SMR02 -#define URT1_SCRx0 SCR02 -#define URT1_SDRx0 SDR02 -#define URT1_NFENx NFEN0 -#define URT1_SNFENxx SNFEN10 /* :NFEN0.2 */ -#define URT1_SIRx1 SIR03 -#define URT1_SMRx1 SMR03 -#define URT1_SCRx1 SCR03 -#define URT1_SDRx1 SDR03 -#define URT1_SOx SO0.so0 -#define URT1_SOxx SO02 /* :SO0.2 */ -#define URT1_SOLx SOL0.sol0 -#define URT1_SOLxx SOL02 /* :SOL0.2 */ -#define URT1_SOEx SOE0 -#define URT1_SOExx SOE02 /* :SOE0.2 */ -#define URT1_SSx SS0 -#define URT1_SSxx SS02 /* :SS0.2 */ -#define URT1_SSRx SSR02 -#define URT1_Px P0 -#define URT1_PMx PM0 -#ifdef GRCOTTON -#define URT1_TXD_Px 0x04 -#define URT1_RXD_Px 0x08 -#define URT1_PMCx PMC0.pmc0 -#else /* GRCOTTON */ -#define URT1_TXD_Px 0x01 -#define URT1_RXD_Px 0x02 -#endif /* GRCOTTON */ -#endif /* ( UART1_CHANNEL == 1 ) */ -#if ( UART2_CHANNEL == 2 ) -#define URT2_RXDx RXD2 -#define URT2_TXDx TXD2 -#define URT2_PERx PER0.per0 -#define URT2_SAUxEN SAU1EN /* :PER0.3 */ -#define URT2_SPSx SPS1 -#define URT2_STx ST1 -#define URT2_MKxx MK0H.mk0h -#define URT2_IFxx IF0H.if0h -#define URT2_PR1xx PR10H.pr10h -#define URT2_PR0xx PR00H.pr00h -#define URT2_STMKx STMK2 /* :MK0H.0 */ -#define URT2_STIFx STIF2 /* :IF0H.0 */ -#define URT2_SRMKx SRMK2 /* :MK0H.1 */ -#define URT2_SRIFx SRIF2 /* :IF0H.1 */ -#define URT2_SREMKx SREMK2 /* :MK0H.2 */ -#define URT2_SREIFx SREIF2 /* :IF0H.2 */ -#define URT2_STPR1x STPR12 /* :PR10H.0 */ -#define URT2_STPR0x STPR02 /* :PR00H.0 */ -#define URT2_SRPR1x SRPR12 /* :PR10H.1 */ -#define URT2_SRPR0x SRPR02 /* :PR00H.1 */ -#define URT2_SREPR1x SREPR12 /* :PR10H.2 */ -#define URT2_SREPR0x SREPR02 /* :PR00H.2 */ -#define URT2_SMRx0 SMR10 -#define URT2_SCRx0 SCR10 -#define URT2_SDRx0 SDR10 -#define URT2_NFENx NFEN0 -#define URT2_SNFENxx SNFEN20 /* :NFEN0.4 */ -#define URT2_SIRx1 SIR11 -#define URT2_SMRx1 SMR11 -#define URT2_SCRx1 SCR11 -#define URT2_SDRx1 SDR11 -#define URT2_SOx SO1.so1 -#define URT2_SOxx SO10 /* :SO1.0 */ -#define URT2_SOLx SOL1.sol1 -#define URT2_SOLxx SOL10 /* :SOL1.0 */ -#define URT2_SOEx SOE1 -#define URT2_SOExx SOE10 /* :SOE1.0 */ -#define URT2_SSx SS1 -#define URT2_SSxx SS10 /* :SS1.0 */ -#define URT2_SSRx SSR10 -#define URT2_Px P1 -#define URT2_PMx PM1 -#define URT2_TXD_Px 0x08 -#define URT2_RXD_Px 0x10 -#endif /* ( UART2_CHANNEL == 2 ) */ - -#if ( UART_CHANNEL == 0 ) /* ( UART_CHANNEL == 2 ) */ -#define URT_SFR_RXDx 0xfff12 /* RXD0.rxd0 */ -#define URT_SFR_TXDx 0xfff10 /* TXD0.txd0 */ -#define URT_SFR2_PERx 0xf00f0 /* PER0.per0 */ -#define URT_SFR2_BIT_SAUxEN 2 /* SAU0EN :PER0.2 */ -#define URT_SFR2_SPSx 0xf0126 /* SPS0.sps0 */ -#define URT_SFR2_STx 0xf0124 /* ST0.st0 */ -#define URT_SFR2_BIT_STxx0 0 /* ST00 :ST0.0 */ -#define URT_SFR2_BIT_STxx1 1 /* ST01 :ST0.1 */ -#define URT_SFR_MKxx 0xfffe5 /* MK0H.mk0h */ -#define URT_SFR_IFxx 0xfffe1 /* IF0H.if0h */ -#define URT_SFR_PR1xx 0xfffed /* PR10H.pr10h */ -#define URT_SFR_PR0xx 0xfffe9 /* PR00H.pr00h */ -#define URT_SFR_BIT_STMKx 5 /* STMK0 :MK0H.5 */ -#define URT_SFR_BIT_STIFx 5 /* STIF0 :IF0H.5 */ -#define URT_SFR_BIT_SRMKx 6 /* SRMK0 :MK0H.6 */ -#define URT_SFR_BIT_SRIFx 6 /* SRIF0 :IF0H.6 */ -#define URT_SFR_BIT_SREMKx 7 /* SREMK0 :MK0H.7 */ -#define URT_SFR_BIT_SREIFx 7 /* SREIF0 :IF0H.7 */ -#define URT_SFR_BIT_STPR1x 5 /* STPR10 :PR10H.5 */ -#define URT_SFR_BIT_STPR0x 5 /* STPR00 :PR00H.5 */ -#define URT_SFR_BIT_SRPR1x 6 /* SRPR10 :PR10H.6 */ -#define URT_SFR_BIT_SRPR0x 6 /* SRPR00 :PR00H.6 */ -#define URT_SFR_BIT_SREPR1x 7 /* SREPR10:PR10H.7 */ -#define URT_SFR_BIT_SREPR0x 7 /* SREPR00:PR00H.7 */ -#define URT_SFR2_SMRx0 0xf0110 /* SMR00.smr00 */ -#define URT_SFR2_SCRx0 0xf0118 /* SCR00.scr00 */ -#define URT_SFR_SDRx0 0xfff10 /* SDR00.sdr00 */ -#define URT_SFR2_NFENx 0xf0070 /* NFEN0.nfen0 */ -#define URT_SFR2_BIT_SNFENxx 0 /* SNFEN00:NFEN0.0 */ -#define URT_SFR2_SIRx1 0xf010a /* SIR01.sir01 */ -#define URT_SFR2_SMRx1 0xf0112 /* SMR01.smr01 */ -#define URT_SFR2_SCRx1 0xf011a /* SCR01.scr01 */ -#define URT_SFR2_SDRx1 0xfff12 /* SDR01.sdr01 */ -#define URT_SFR2_SOx 0xf0128 /* SO0.so0 */ -#define URT_SFR2_BIT_SOxx 0 /* SO00 :SO0.0 */ -#define URT_SFR2_SOLx 0xf0134 /* SOL0.sol0 */ -#define URT_SFR2_BIT_SOLxx 0 /* SOL00 :SOL0.0 */ -#define URT_SFR2_SOEx 0xf012a /* SOE0.soe0 */ -#define URT_SFR2_BIT_SOExx 0 /* SOE00 :SOE0.0 */ -#define URT_SFR2_SSx 0xf0122 /* SS0.ss0 */ -#define URT_SFR2_BIT_SSxx0 0 /* SS00 :SS0.0 */ -#define URT_SFR2_BIT_SSxx1 1 /* SS01 :SS0.1 */ -#endif /* ( UART_CHANNEL == 2 ) */ - -#if ( UART1_CHANNEL == 1 ) -#define URT1_SFR_RXDx 0xfff46 /* RXD1.rxd1 */ -#define URT1_SFR_TXDx 0xfff44 /* TXD1.txd1 */ -#define URT1_SFR2_PERx 0xf00f0 /* PER0.per0 */ -#define URT1_SFR2_BIT_SAUxEN 2 /* SAU0EN :PER0.2 */ -#define URT1_SFR2_SPSx 0xf0126 /* SPS0.sps0 */ -#define URT1_SFR2_STx 0xf0124 /* ST0.st0 */ -#define URT1_SFR2_BIT_STxx0 2 /* ST02 :ST0.2 */ -#define URT1_SFR2_BIT_STxx1 3 /* ST03 :ST0.3 */ -#define URT1_SFR_MKxx 0xfffe6 /* MK1L.mk1l */ -#define URT1_SFR_IFxx 0xfffe2 /* IF1L.if1l */ -#define URT1_SFR_PR1xx 0xfffee /* PR11L.pr11l */ -#define URT1_SFR_PR0xx 0xfffea /* PR01L.pr01l */ -#define URT1_SFR_BIT_STMKx 0 /* STMK1 :MK1L.0 */ -#define URT1_SFR_BIT_STIFx 0 /* STIF1 :IF1L.0 */ -#define URT1_SFR_BIT_SRMKx 1 /* SRMK1 :MK1L.1 */ -#define URT1_SFR_BIT_SRIFx 1 /* SRIF1 :IF1L.1 */ -#define URT1_SFR_BIT_SREMKx 2 /* SREMK1 :MK1L.2 */ -#define URT1_SFR_BIT_SREIFx 2 /* SREIF1 :IF1L.2 */ -#define URT1_SFR_BIT_STPR1x 0 /* STPR11 :PR11L.0 */ -#define URT1_SFR_BIT_STPR0x 0 /* STPR01 :PR01L.0 */ -#define URT1_SFR_BIT_SRPR1x 1 /* SRPR11 :PR11L.1 */ -#define URT1_SFR_BIT_SRPR0x 1 /* SRPR01 :PR01L.1 */ -#define URT1_SFR_BIT_SREPR1x 2 /* SREPR11:PR11L.2 */ -#define URT1_SFR_BIT_SREPR0x 2 /* SREPR01:PR01L.2 */ -#define URT1_SFR2_SMRx0 0xf0114 /* SMR02.smr02 */ -#define URT1_SFR2_SCRx0 0xf011c /* SCR02.scr02 */ -#define URT1_SFR_SDRx0 0xfff44 /* SDR02.sdr02 */ -#define URT1_SFR2_NFENx 0xf0070 /* NFEN0.nfen0 */ -#define URT1_SFR2_BIT_SNFENxx 2 /* SNFEN10:NFEN0.2 */ -#define URT1_SFR2_SIRx1 0xf010e /* SIR03.sir03 */ -#define URT1_SFR2_SMRx1 0xf0116 /* SMR03.smr03 */ -#define URT1_SFR2_SCRx1 0xf011e /* SCR03.scr03 */ -#define URT1_SFR2_SDRx1 0xfff46 /* SDR03.sdr03 */ -#define URT1_SFR2_SOx 0xf0128 /* SO0.so0 */ -#define URT1_SFR2_BIT_SOxx 2 /* SO02 :SO0.2 */ -#define URT1_SFR2_SOLx 0xf0134 /* SOL0.sol0 */ -#define URT1_SFR2_BIT_SOLxx 2 /* SOL02 :SOL0.2 */ -#define URT1_SFR2_SOEx 0xf012a /* SOE0.soe0 */ -#define URT1_SFR2_BIT_SOExx 2 /* SOE02 :SOE0.2 */ -#define URT1_SFR2_SSx 0xf0122 /* SS0.ss0 */ -#define URT1_SFR2_BIT_SSxx0 2 /* SS02 :SS0.2 */ -#define URT1_SFR2_BIT_SSxx1 3 /* SS03 :SS0.3 */ -#endif /* ( UART1_CHANNEL == 1 ) */ -#if ( UART2_CHANNEL == 2 ) -#define URT2_SFR_RXDx 0xfff4a /* RXD2.rxd2 */ -#define URT2_SFR_TXDx 0xfff48 /* TXD2.txd2 */ -#define URT2_SFR2_PERx 0xf00f0 /* PER0.per0 */ -#define URT2_SFR2_BIT_SAUxEN 3 /* SAU1EN :PER0.3 */ -#define URT2_SFR2_SPSx 0xf0166 /* SPS1.sps1 */ -#define URT2_SFR2_STx 0xf0164 /* ST1.st1 */ -#define URT2_SFR2_BIT_STxx0 0 /* ST10 :ST1.0 */ -#define URT2_SFR2_BIT_STxx1 1 /* ST11 :ST1.1 */ -#define URT2_SFR_MKxx 0xfffe5 /* MK0H.mk0h */ -#define URT2_SFR_IFxx 0xfffe1 /* IF0H.if0h */ -#define URT2_SFR_PR1xx 0xfffed /* PR10H.pr10h */ -#define URT2_SFR_PR0xx 0xfffe9 /* PR00H.pr00h */ -#define URT2_SFR_BIT_STMKx 0 /* STMK2 :MK0H.0 */ -#define URT2_SFR_BIT_STIFx 0 /* STIF2 :IF0H.0 */ -#define URT2_SFR_BIT_SRMKx 1 /* SRMK2 :MK0H.1 */ -#define URT2_SFR_BIT_SRIFx 1 /* SRIF2 :IF0H.1 */ -#define URT2_SFR_BIT_SREMKx 2 /* SREMK2 :MK0H.2 */ -#define URT2_SFR_BIT_SREIFx 2 /* SREIF2 :IF0H.2 */ -#define URT2_SFR_BIT_STPR1x 0 /* STPR12 :PR10H.0 */ -#define URT2_SFR_BIT_STPR0x 0 /* STPR02 :PR00H.0 */ -#define URT2_SFR_BIT_SRPR1x 1 /* SRPR12 :PR10H.1 */ -#define URT2_SFR_BIT_SRPR0x 1 /* SRPR02 :PR00H.1 */ -#define URT2_SFR_BIT_SREPR1x 2 /* SREPR12:PR10H.2 */ -#define URT2_SFR_BIT_SREPR0x 2 /* SREPR02:PR00H.2 */ -#define URT2_SFR2_SMRx0 0xf0150 /* SMR10.smr10 */ -#define URT2_SFR2_SCRx0 0xf0158 /* SCR10.scr10 */ -#define URT2_SFR_SDRx0 0xfff48 /* SDR10.sdr10 */ -#define URT2_SFR2_NFENx 0xf0070 /* NFEN0.nfen0 */ -#define URT2_SFR2_BIT_SNFENxx 4 /* SNFEN20:NFEN0.4 */ -#define URT2_SFR2_SIRx1 0xf014a /* SIR11.sir11 */ -#define URT2_SFR2_SMRx1 0xf0152 /* SMR11.smr11 */ -#define URT2_SFR2_SCRx1 0xf015a /* SCR11.scr11 */ -#define URT2_SFR_SDRx1 0xfff4a /* SDR11.sdr11 */ -#define URT2_SFR2_SOx 0xf0168 /* SO1.so1 */ -#define URT2_SFR2_BIT_SOxx 0 /* SO10 :SO1.0 */ -#define URT2_SFR2_SOLx 0xf0174 /* SOL1.sol1 */ -#define URT2_SFR2_BIT_SOLxx 0 /* SOL10 :SOL1.0 */ -#define URT2_SFR2_SOEx 0xf016a /* SOE1.soe1 */ -#define URT2_SFR2_BIT_SOExx 0 /* SOE10 :SOE1.0 */ -#define URT2_SFR2_SSx 0xf0162 /* SS1.ss1 */ -#define URT2_SFR2_BIT_SSxx0 0 /* SS10 :SS1.0 */ -#define URT2_SFR2_BIT_SSxx1 1 /* SS11 :SS1.1 */ -#endif /* ( UART2_CHANNEL == 2 ) */ - -/* - * this next line disables the entire HardwareUart.cpp, - * this is so I can support Attiny series and any other chip without a uart - */ - -#include "HardwareUart.h" - -/* - * Define constants and variables for buffering incoming serial data. We're - * using a ring buffer (I think), in which head is the index of the location - * to which to write the next incoming character and tail is the index of the - * location from which to read. - */ -#define SERIAL_BUFFER_SIZE 256 - -void serialEventRun(void) -{ - -} - -fInterruptFunc_t uart_receive_callback_table[3] __attribute__((weak)); -fInterruptFunc_t uart_transmit_callback_table[3] __attribute__((weak)); - -// Constructors //////////////////////////////////////////////////////////////// - -/********************************************************************************************************************** - * Function Name: HardwareUart::HardwareUart - * Description : Constructor - * Arguments : rxen - UART channel - * Return Value : void - *********************************************************************************************************************/ -HardwareUart::HardwareUart(uint8_t rxen) -{ - _urt_channel = rxen; - _rx_buffer_head = 0; - _rx_buffer_tail = 0; - _tx_buffer_head = 0; - _tx_buffer_tail = 0; - _rx_buf_size = 0; - _tx_buf_size = 0; - _rx_buffer = 0; - _tx_buffer = 0; - transmitting = 0; - receive_buffer = 0; -} - -// Public Methods ////////////////////////////////////////////////////////////// - -/********************************************************************************************************************** - * Function Name: HardwareUart::begin - * Description : Initialize and configure the serial port. - * Arguments : baud - baud rate - * : { 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 57600, 115200 } - * Return Value : void - *********************************************************************************************************************/ -void HardwareUart::begin(unsigned long baud) -{ - begin(baud, SERIAL_8N1); -} - -/********************************************************************************************************************** - * Function Name: HardwareUart::begin - * Description : Initialize and configure the serial port. - * Arguments : baud - baud rate - * : { 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 57600, 115200 } - * : config - serial port setting - * : SERIAL_{ 8, 7 }{ N, E }{ 1, 2 } - * Return Value : void - *********************************************************************************************************************/ -void HardwareUart::begin(unsigned long baud, uint16_t config){ - begin(baud, config, SERIAL_BUFFER_SIZE, SERIAL_BUFFER_SIZE); -} - -/********************************************************************************************************************** - * Function Name: HardwareUart::begin - * Description : Initialize and configure the serial port. - * Arguments : baud - baud rate - * : { 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 57600, 115200 } - * : rx_buf - receive buffer size - * : tx_buf - transmit buffer size - * Return Value : void - *********************************************************************************************************************/ -void HardwareUart::begin(unsigned long baud, int rx_buf, int tx_buf){ - begin(baud, SERIAL_8N1, rx_buf, tx_buf); -} - -/********************************************************************************************************************** - * Function Name: HardwareUart::begin - * Description : Initialize and configure the serial port. - * Arguments : baud - baud rate - * : { 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 57600, 115200 } - * : config - serial port setting - * : SERIAL_{ 8, 7 }{ N, E }{ 1, 2 } - * : rx_buf - receive buffer size - * : tx_buf - transmit buffer size - * Return Value : void - *********************************************************************************************************************/ -void HardwareUart::begin(unsigned long baud, uint16_t config, int rx_buf, int tx_buf) -{ - /* Initialize Unit */ - /* begin executed. end call */ - if ((0 != _rx_buffer) || (0 != _tx_buffer)){ - return; - } - if ((1 == rx_buf) || (1 == tx_buf)){ - return; - } - _rx_buffer = (uint8_t *)malloc((size_t)(rx_buf * (int)sizeof(uint8_t))); - if (0 == _rx_buffer){ - _rx_buf_size = 0; - _tx_buf_size = 0; - return; - } - _tx_buffer = (uint8_t *)malloc((size_t)(tx_buf * (int)sizeof(uint8_t))); - if (0 == _tx_buffer){ - free((uint8_t *)_rx_buffer); - _rx_buffer = 0; - _rx_buf_size = 0; - _tx_buf_size = 0; - return; - } - _rx_buf_size = rx_buf; - _tx_buf_size = tx_buf; - _rx_buffer_head = 0; - _rx_buffer_tail = 0; - _tx_buffer_head = 0; - _tx_buffer_tail = 0; - - switch (_urt_channel) - { - case 0: -#if (UART_CHANNEL==0) - R_Config_UART0_Create(); - Set_Baudrate(baud); - Set_SerialPort(SERIAL_TXD0,SERIAL_RXD0); - Set_Config(config); - R_Config_UART0_Start(); - R_Config_UART0_Receive((uint8_t * const)&receive_buffer,1); -#endif /* UART_CHANNEL==0 */ - break; - case 1: -#if (UART1_CHANNEL==1) - R_Config_UART1_Create(); - Set_Baudrate(baud); - Set_SerialPort(SERIAL_TXD1,SERIAL_RXD1); - Set_Config(config); - R_Config_UART1_Start(); - R_Config_UART1_Receive((uint8_t * const)&receive_buffer,1); -#endif /* UART1_CHANNEL==1 */ - break; - case 2: -#if (UART2_CHANNEL==2) - R_Config_UART2_Create(); - Set_Baudrate(baud); - Set_SerialPort(SERIAL_TXD2,SERIAL_RXD2); - Set_Config(config); - R_Config_UART2_Start(); - R_Config_UART2_Receive((uint8_t * const)&receive_buffer,1); -#endif /* UART2_CHANNEL==2 */ - break; - case 3: - break; - default : - /* Do nothing */ - break; - } -} - -/********************************************************************************************************************** - * Function Name: HardwareUart::end - * Description : Terminate the serial port processing. - * Arguments : - - * Return Value : void - *********************************************************************************************************************/ -void HardwareUart::end() -{ - switch (_urt_channel) - { - case 0: -#if (UART_CHANNEL == 0 ) - R_Config_UART0_Stop(); -#endif /* (UART_CHANNEL == 0 ) */ - break; - case 1: -#if (UART1_CHANNEL == 1 ) - R_Config_UART1_Stop(); -#endif /* (UART1_CHANNEL == 1 ) */ - break; - case 2: -#if (UART2_CHANNEL == 2 ) - R_Config_UART2_Stop(); -#endif /* (UART2_CHANNEL == 2 ) */ - break; - case 3: - break; - } - if(_rx_buffer!= 0) - { - free((uint8_t *)_rx_buffer); - _rx_buffer = 0; - } - if(_tx_buffer!= 0) - { - free((uint8_t *)_tx_buffer); - _tx_buffer = 0; - } - _rx_buffer_head = 0; - _rx_buffer_tail = 0; - _tx_buffer_head = 0; - _tx_buffer_tail = 0; - _rx_buf_size = 0; - _tx_buf_size = 0; -} - -/********************************************************************************************************************** - * Function Name: HardwareUart::available - * Description : Get the number of readable data bytes of received data. - * Arguments : - - * Return Value : size of readable data - *********************************************************************************************************************/ -int HardwareUart::available(void) -{ - int head = 0; - int tail = 0; - noInterrupts(); - head = _rx_buffer_head; - tail = _rx_buffer_tail; - interrupts(); - if (head >= tail) return head - tail; - return (_rx_buf_size - tail + head ); -} - -/********************************************************************************************************************** - * Function Name: HardwareUart::peek - * Description : Read received data by 1 byte and do not change the buffer position. - * Arguments : - - * Return Value : -1 - no read data - * : other - read data - *********************************************************************************************************************/ -int HardwareUart::peek(void) -{ - if (_rx_buffer_head == _rx_buffer_tail) { - return -1; - } else { - return _rx_buffer[_rx_buffer_tail]; - } -} - -/********************************************************************************************************************** - * Function Name: HardwareUart::read - * Description : Read received data by 1 byte and advance the buffer position by 1 byte. - * Arguments : - - * Return Value : -1 - no read data - * : other - read data - *********************************************************************************************************************/ -int HardwareUart::read(void) -{ - /* if the head isn't ahead of the tail, we don't have any characters */ - noInterrupts(); - if (_rx_buffer_head == _rx_buffer_tail) { - interrupts(); - return -1; - } - unsigned char c = _rx_buffer[_rx_buffer_tail]; - _rx_buffer_tail = (_rx_buffer_tail + 1) % _rx_buf_size; - interrupts(); - - return c; -} - -/********************************************************************************************************************** - * Function Name: HardwareUart::flush - * Description : Wait for all data transmission in the transmission buffer to be completed. - * Arguments : - - * Return Value : void - *********************************************************************************************************************/ -void HardwareUart::flush() -{ - /* buffer is none */ - if (0 == _tx_buf_size || 0 == _tx_buffer){ - return; - } - if (_urt_channel == 0) { - while (SSR00 & (_0040_SAU_UNDER_EXECUTE | _0020_SAU_VALID_STORED)) { /* check TSF00 and BFF00 */ - ; - } - } - else if (_urt_channel == 1) { - while (SSR02 & (_0040_SAU_UNDER_EXECUTE | _0020_SAU_VALID_STORED)) { /* check TSF02 and BFF02 */ - ; - } - } - else if (_urt_channel == 2) { - while (SSR10 & (_0040_SAU_UNDER_EXECUTE | _0020_SAU_VALID_STORED)) { /* check TSF10 and BFF10 */ - ; - } - } - while(_tx_buf_size-1!=availableForWrite()) - { - NOP(); - } -} - -/********************************************************************************************************************** - * Function Name: HardwareUart::UART_Send - * Description : Transmit data to the target serial port (actual implementation of write operation). - * Arguments : c - transmission data - * Return Value : -1 - write failed with the transmission buffer overflow - * : other - written data size - *********************************************************************************************************************/ -size_t HardwareUart::UART_Send(uint8_t c) -{ - MD_STATUS err = MD_OK; - int i; - uint8_t isp; - size_t ret = 0; - - /* buffer is none */ - if (0 == _tx_buf_size){ - return ret; - } - - isp = (uint8_t)GET_PSW_ISP(); - - noInterrupts(); - if(_tx_buffer_tail == _tx_buffer_head){ - /* Unsent */ - //int head = (_tx_buffer_head + 1); - i = (_tx_buffer_head + 1) % _tx_buf_size; - _tx_buffer[_tx_buffer_head] = c; - _tx_buffer_head = i; - interrupts(); - - switch (_urt_channel) - { - case 0: - if((SSR00 & _0020_SAU_VALID_STORED) != 0)/*BFF00*/ - { - return 0; - } - err = R_Config_UART0_Send((uint8_t * const)&c,1); - break; - case 1: - if((SSR02 & _0020_SAU_VALID_STORED) != 0)/*BFF02*/ - { - return 0; - } - err = R_Config_UART1_Send((uint8_t * const)&c,1); - break; - case 2: - if((SSR10 & _0020_SAU_VALID_STORED) != 0)/*BFF10*/ - { - return 0; - } - err = R_Config_UART2_Send((uint8_t * const)&c,1); - break; - case 3: - break; - } - } - else - { - /* only buffer copy during transmission process */ - i = (_tx_buffer_head + 1) % _tx_buf_size; - if(i == _tx_buffer_tail) - { - /* buffer over */ - if(ISP_LEVEL_3 == isp) - { - /* When called from main program(setup() or loop() */ - interrupts(); - while(i == _tx_buffer_tail) - { - ; - } - noInterrupts(); - } - else - { - /* When called from interuupt function (ex. callback routine for periodic processing */ - switch (_urt_channel) - { - case 0: - #if ( UART_CHANNEL == 0 ) - while((SSR00 & _0020_SAU_VALID_STORED) != 0)/*BFF00*/ - { - ; - } - STIF0 = 0; - #endif /* ( UART_CHANNEL == 0 ) */ - break; - case 1: - #if ( UART1_CHANNEL == 1 ) - while((SSR02 & _0020_SAU_VALID_STORED) != 0)/*BFF02*/ - { - ; - } - STIF1 = 0; - #endif /* ( UART1_CHANNEL == 1 ) */ - break; - case 2: - #if ( UART2_CHANNEL == 2 ) - while((SSR10 & _0020_SAU_VALID_STORED) != 0)/*BFF10*/ - { - ; - } - STIF2 = 0; - #endif /* ( UART2_CHANNEL == 2 ) */ - break; - case 3: - break; - } - Set_Char_Serial_from_buf(_urt_channel); - if(0 != uart_transmit_callback_table[_urt_channel]) - { - (*uart_transmit_callback_table[_urt_channel])(); - } - } - } - _tx_buffer[_tx_buffer_head] = c; - _tx_buffer_head = i; - interrupts(); - } - if(err == MD_OK){ - return 1; - } - return ret; -} - -/********************************************************************************************************************** - * Function Name: HardwareUart::write - * Description : Transmit data to the target serial port. - * Arguments : c - transmission data - * Return Value : -1 - write failed with the transmission buffer overflow - * : other - written data size - *********************************************************************************************************************/ - -size_t HardwareUart::write(uint8_t c) -{ - size_t err = 0; - err = UART_Send(c); - return err; -} - - -/********************************************************************************************************************** - * Function Name: HardwareUart::availableForWrite - * Description : Get the number of available transmit buffer space for write. - * Arguments : - - * Return Value : size of transmit buffer free space - *********************************************************************************************************************/ -int HardwareUart::availableForWrite(void) -{ - int head = 0; - int tail = 0; - noInterrupts(); - head = _tx_buffer_head; - tail = _tx_buffer_tail; - interrupts(); - if (head >= tail) return _tx_buf_size - 1 - head + tail; - return (tail - head - 1); -} - -/********************************************************************************************************************** - * Function Name: HardwareUart::availableForRead - * Description : Get the number of available receive buffer space for read. - * Arguments : - - * Return Value : size of receive buffer free space - *********************************************************************************************************************/ -int HardwareUart::availableForRead(void) -{ - int head = 0; - int tail = 0; - noInterrupts(); - head = _rx_buffer_head; - tail = _rx_buffer_tail; - interrupts(); - if (head >= tail) return _rx_buf_size - 1 - head + tail; - return (tail - head - 1); - -} - -HardwareUart::operator bool() { - return true; -} - -/* Load Send data from Send Buffer & Start New Send Function */ -/********************************************************************************************************************** - * Function Name: HardwareUart::load_char - * Description : Extract 1 byte from the transmit buffer and send it. - * : Called from the transmission complete interrupt handler. - * : Unavailable for the other purpose. - * Arguments : - - * Return Value : - - *********************************************************************************************************************/ -void HardwareUart::load_char(void){ - int i = (_tx_buffer_tail + 1) % _tx_buf_size; - _tx_buffer_tail = i; - if (i != _tx_buffer_head) { - uint8_t send_buffer = _tx_buffer[i]; - switch (_urt_channel) - { - case 0: -#if (UART_CHANNEL == 0) - R_Config_UART0_Send((uint8_t * const)&send_buffer,1); -#endif /* (UART_CHANNEL == 0) */ - break; - case 1: -#if (UART1_CHANNEL == 1) - R_Config_UART1_Send((uint8_t * const)&send_buffer,1); -#endif /* (UART1_CHANNEL == 1) */ - break; - case 2: -#if (UART2_CHANNEL == 2) - R_Config_UART2_Send((uint8_t * const)&send_buffer,1); -#endif /* (UART2_CHANNEL == 2) */ - break; - case 3: - break; - } - } -} - - -/* Store Received data to Receive Buffer & Start New Receive Function */ -/********************************************************************************************************************** - * Function Name: HardwareUart::store_char - * Description : Store 1 byte of the last received data in the receive buffer - * : and continue the receive process for the following bytes. - * : Called from the receive complete interrupt handler. - * : Unavailable for the other purpose. - * Arguments : - - * Return Value : - - *********************************************************************************************************************/ -void HardwareUart::store_char(void){ - store_char(receive_buffer); - receive_buffer = 0; - switch (_urt_channel) - { - case 0: - #if (UART_CHANNEL == 0) - R_Config_UART0_Receive((uint8_t * const)&receive_buffer,1); - #endif /* (UART_CHANNEL == 0) */ - break; - case 1: - #if (UART1_CHANNEL == 1) - R_Config_UART1_Receive((uint8_t * const)&receive_buffer,1); - #endif /* (UART1_CHANNEL == 1) */ - break; - case 2: - #if (UART2_CHANNEL == 2) - R_Config_UART2_Receive((uint8_t * const)&receive_buffer,1); - #endif /* (UART2_CHANNEL == 2) */ - break; - break; - } -} - -/********************************************************************************************************************** - * Function Name: HardwareUart::store_char - * Description : Store 1 byte of the last received data in the receive buffer - * : and continue the receive process for the following bytes. - * : Make sure to disable interrupts before calling this from outside of the interrupt handler. - * Arguments : c - byte to store - * Return Value : - - *********************************************************************************************************************/ -void HardwareUart::store_char(unsigned char c){ - int i = (_rx_buffer_head + 1) % _rx_buf_size; - if (i != _rx_buffer_tail) { - _rx_buffer[_rx_buffer_head] = c; - _rx_buffer_head = i; - } -} - -/* Add for RL78/G23 */ -/********************************************************************************************************************** - * Function Name: HardwareUart::Set_Baudrate - * Description : Set baud rate for the serial port. - * Arguments : baudrate - baud rate - * : { 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 57600, 115200 } - * Return Value : void - *********************************************************************************************************************/ -void HardwareUart::Set_Baudrate(unsigned long baudrate) -{ - uint32_t fclk_frequency; - uint32_t peri_clk ; - uint8_t sdr ; - uint16_t tmp_sdr ; - uint8_t prs = 0U; - fclk_frequency = R_BSP_GetFclkFreqHz(); - - peri_clk = (fclk_frequency) ; /* SPSmk0\[3:0] = 0x0 */ - - tmp_sdr = (uint16_t)(((peri_clk/baudrate) >> 1) -1) ; - while(0x007F> 1); - tmp_sdr = (uint16_t)(((peri_clk/baudrate) >> 1) -1) ; - } - - sdr = (uint8_t)(tmp_sdr & 0x007F) ; - - switch (_urt_channel) - { - case 0: -#if ( UART_CHANNEL == 0 ) - SPS0 &= (_00F0_SAU_CK00_CLEAR) ; - SPS0 |= prs ; - SDR00 = ((uint16_t)sdr) << 9 ; - SDR01 = ((uint16_t)sdr) << 9 ; -#endif /* ( UART_CHANNEL == 0 ) */ - break; - case 1: -#if ( UART1_CHANNEL == 1 ) - SPS0 &= (_000F_SAU_CK01_CLEAR) ; - SPS0 |= ((uint16_t)prs << 4); - SDR02 = ((uint16_t)sdr) << 9 ; - SDR03 = ((uint16_t)sdr) << 9 ; -#endif /* ( UART1_CHANNEL == 1 ) */ - break; - case 2: -#if ( UART2_CHANNEL == 2 ) - SPS1 &= (_00F0_SAU_CK00_CLEAR) ; - SPS1 |= prs ; - SDR10 = ((uint16_t)sdr) << 9 ; - SDR11 = ((uint16_t)sdr) << 9 ; -#endif /* ( UART2_CHANNEL == 2 ) */ - break; - case 3: - break; - default : - /* Do nothing */ - break; - } -} - -#ifdef __RL78__ -/********************************************************************************************************************** - * Function Name: HardwareUart::Set_Config - * Description : Set the serial data length, parity, and stop bit. - * Arguments : config - serial port setting - * : SERIAL_{ 8, 7 }{ N, E }{ 1, 2 } - * Return Value : void - *********************************************************************************************************************/ -void HardwareUart::Set_Config(uint16_t config ) -{ - uint16_t converted_config = 0; - - switch(config) - { - case SERIAL_7N1: - case SERIAL_8N1: - case SERIAL_7N2: - case SERIAL_8N2: - case SERIAL_7E1: - case SERIAL_8E1: - case SERIAL_7E2: - case SERIAL_8E2: - case SERIAL_7O1: - case SERIAL_8O1: - case SERIAL_7O2: - case SERIAL_8O2: - /* Do nothing */ - break; - default: - config = SERIAL_8N1; - break; - } - if(SERIAL_DATA_7 == (SERIAL_DATA_MASK & config)) - { - converted_config |= _0002_SAU_LENGTH_7; - } - else - { - /* All other settings are treated as SERIAL_DATA_8(default). */ - converted_config |= _0003_SAU_LENGTH_8; - } - - if(SERIAL_STOP_BIT_2 == (SERIAL_STOP_BIT_MASK & config)) - { - converted_config |= _0020_SAU_STOP_2; - } - else - { - /* All other settings are treated as SERIAL_STOP_BIT_1(default). */ - converted_config |= _0010_SAU_STOP_1; - } - - if(SERIAL_PARITY_EVEN == (SERIAL_PARITY_MASK & config)) - { - converted_config |= _0200_SAU_PARITY_EVEN; - } - else if(SERIAL_PARITY_ODD == (SERIAL_PARITY_MASK & config)) - { - converted_config |= _0300_SAU_PARITY_ODD; - } - else - { - /* All other settings are treated as SERIAL_PARITY_NONE(default). */ - converted_config |= _0000_SAU_PARITY_NONE; - } - - switch (_urt_channel) - { - /* Rewriting prohibited when SEmn = 1 / Set_Config is called between R_Config_UART0_Create () and R_Config_UART0_Start (), so SEmn = 0*/ - case 0: - { - /* SCR00 16bit*/ -#if ( UART_CHANNEL == 0 ) - unsigned short SCR00data=_8000_SAU_TRANSMISSION |_0000_SAU_INTSRE_MASK |_0004_SAU_SCRMN_INITIALVALUE |_0080_SAU_LSB | converted_config; - /* When sending, _0000_SAU_INTSRE_MASK :EOCmn = 0*/ - unsigned short SCR01data=_4000_SAU_RECEPTION |_0400_SAU_INTSRE_ENABLE |_0004_SAU_SCRMN_INITIALVALUE |_0080_SAU_LSB | converted_config; - /* _0400_SAU_INTSRE_ENABLE: EOCmn = 1 Allow the occurrence of the error interrupt INTSREx */ - - /* SLCmn1: 0 SLCmn0: 1 when receiving XXXXXXXXXX01XXXX*/ - SCR01data &= ~(_0020_SAU_STOP_2); - SCR01data |= _0010_SAU_STOP_1; - - SCR00 = SCR00data; - SCR01 = SCR01data; -#endif /* ( UART_CHANNEL == 0 ) */ - } - break; - - case 1: - { -#if ( UART1_CHANNEL == 1 ) - unsigned short SCR02data=_8000_SAU_TRANSMISSION| _0000_SAU_INTSRE_MASK |_0004_SAU_SCRMN_INITIALVALUE |_0080_SAU_LSB |converted_config; - unsigned short SCR03data=_4000_SAU_RECEPTION| _0400_SAU_INTSRE_ENABLE |_0004_SAU_SCRMN_INITIALVALUE |_0080_SAU_LSB |converted_config; - /* SLCmn1: 0 SLCmn0: 1 when receiving XXXXXXXXXX01XXXX*/ - SCR03data &= ~(_0020_SAU_STOP_2); - SCR03data |= _0010_SAU_STOP_1; - - SCR02 = SCR02data; - SCR03 = SCR03data; -#endif /* ( UART1_CHANNEL == 1 ) */ - } - break; - case 2: - { -#if ( UART2_CHANNEL == 2 ) - unsigned short SCR10data=_8000_SAU_TRANSMISSION| _0000_SAU_INTSRE_MASK |_0004_SAU_SCRMN_INITIALVALUE |_0080_SAU_LSB |converted_config; - unsigned short SCR11data=_4000_SAU_RECEPTION| _0400_SAU_INTSRE_ENABLE |_0004_SAU_SCRMN_INITIALVALUE |_0080_SAU_LSB |converted_config; - /* SLCmn1: 0 SLCmn0: 1 when receiving XXXXXXXXXX01XXXX*/ - SCR11data &= ~(_0020_SAU_STOP_2); - SCR11data |= _0010_SAU_STOP_1; - SCR10 = SCR10data; - SCR11 = SCR11data; -#endif /* ( UART2_CHANNEL == 2 ) */ - } - break; - case 3: - { - - } - break; - } -} -/********************************************************************************************************************** - End of function Set_Config - *********************************************************************************************************************/ -#endif /* __RL78__ */ - -/********************************************************************************************************************** - * Function Name: HardwareUart::Set_SerialPort - * Description : Set serial port pins for the target port. - * Arguments : txd_pin - transmit pin no. - * : rxd_pin - receive pin no. - * Return Value : void - *********************************************************************************************************************/ -void HardwareUart::Set_SerialPort(uint8_t txd_pin,uint8_t rxd_pin) -{ - //PinTableType* p; - //PinTableType pin_tbl; - //p = (PinTableType*)&pin_tbl; - - - const PinTableType ** pp; - PinTableType * p; - - /* Set RxD pin */ - //getPinTable(rxd_pin,p); - pp = &pinTablelist[rxd_pin]; - p = (PinTableType *)*pp; - /* Set PM Register for Input */ - *p->portModeRegisterAddr |= (unsigned long)(0x1 << p->bit); - - /* Set PMCA Register */ - if (0!=p->pmca){ - *p->portModeControlARegisterAddr &= (unsigned long)~(p->pmca); - } - - /* Set PMCT Register */ - if (0!=p->pmct){ - *p->portModeControlTRegisterAddr &= (unsigned long)~(p->pmct); - } - - /* Set PMCE Register for Output */ -#if defined(G23_FPB) - if (0!=p->pmce){ - *p->portModeControlERegisterAddr &= (unsigned long)~(p->pmce); - } -#endif // G23_FPB - /* Set CCDE Register for Digital InOut */ -#if defined(G23_FPB) - if (0!=p->ccde){ - CCDE &= (uint8_t)~(p->ccde); - } -#endif // G23_FPB - - /* Set TxD pin */ - //getPinTable(txd_pin,p); - pp = &pinTablelist[txd_pin]; - p = (PinTableType *)*pp; - /* Set PMCE Register t */ -#if defined(G23_FPB) - if (0!=p->pmce){ - *p->portModeControlERegisterAddr &= (unsigned long)~(p->pmce); - } -#endif // G23_FPB - - /* Set P Register for Set "H" Output Port*/ - *p->portRegisterAddr |= (unsigned long)(0x1 << p->bit); - - /* Set PM Register for Output */ - *p->portModeRegisterAddr &= (unsigned long)~(0x1 << p->bit); - - /* Set PMCA Register */ - if (0!=p->pmca){ - *p->portModeControlARegisterAddr &= (unsigned long)~(p->pmca); - } - - /* Set PMCT Register */ - if (0!=p->pmct){ - *p->portModeControlTRegisterAddr &= (unsigned long)~(p->pmct); - } - - /* Set PMCE Register t */ -#if defined(G23_FPB) - if (0!=p->pmce){ - *p->portModeControlERegisterAddr &= (unsigned long)~(p->pmce); - } -#endif // G23_FPB - /* Set CCDE Register for Digital InOut */ -#if defined(G23_FPB) - if (0!=p->ccde){ - CCDE &= (uint8_t)~(p->ccde); - } -#endif // G23_FPB -} - - -void HardwareUart::setReceiveCallback(void (*userFunc)(void)) -{ - uart_receive_callback_table[_urt_channel] = userFunc; -} -void HardwareUart::setTransmitCallback(void (*userFunc)(void)) -{ - uart_transmit_callback_table[_urt_channel] = userFunc; -} - -extern "C" { -/********************************************************************************************************************** - * Function Name: Set_Char_Serial_to_buf - * Description : Store the received data in the buffer. - * : Called from the receive interrupt handler. - * Arguments : chn - UART channel - * Return Value : void - *********************************************************************************************************************/ -void Set_Char_Serial_to_buf(uint8_t chn) -{ - switch (chn) - { - case 0: -#if (UART_CHANNEL == 0) - Serial.store_char(); -#endif /* (UART_CHANNEL == 0) */ - break; - case 1: -#if (UART1_CHANNEL == 1) - Serial1.store_char(); -#endif /* (UART1_CHANNEL == 1) */ - break; - case 2: -#if (UART2_CHANNEL == 2) - Serial2.store_char(); -#endif /* (UART2_CHANNEL == 2) */ - break; - case 3: - break; - } -} - -/********************************************************************************************************************** - * Function Name: Set_Char_Serial_from_buf - * Description : Load write data from the buffer. - * Arguments : chn - UART_CHANNEL - * Return Value : void - - *********************************************************************************************************************/ - -void Set_Char_Serial_from_buf(uint8_t chn) -{ - switch (chn) - { - case 0: -#if (UART_CHANNEL == 0) - Serial.load_char(); -#endif /* (UART_CHANNEL == 0) */ - break; - case 1: -#if (UART1_CHANNEL == 1) - Serial1.load_char(); -#endif /* (UART1_CHANNEL == 1) */ - break; - case 2: -#if (UART2_CHANNEL == 2) - Serial2.load_char(); -#endif /* (UART2_CHANNEL == 2) */ - break; - case 3: - break; - } -} - -} - -// Preinstantiate Objects ////////////////////////////////////////////////////// - -#if ( UART_CHANNEL == 0 ) - HardwareUart Serial(0); -#endif /* ( UART_CHANNEL == 0 ) */ -#if ( UART1_CHANNEL == 1 ) - HardwareUart Serial1(1); -#endif /* ( UART1_CHANNEL == 1 ) */ -#if ( UART2_CHANNEL == 2 ) - HardwareUart Serial2(2); -#endif /* ( UART2_CHANNEL == 2 ) */ - - +/* + HardwareUart.cpp - Hardware serial library for Wiring + Copyright (c) 2006 Nicholas Zambetti. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Modified 23 November 2006 by David A. Mellis + Modified 28 September 2010 by Mark Sproul + Modified 14 August 2012 by Alarus + Modified 7 March 2013 by masahiko.nagata.cj@renesas.com + Modified 30 June 2013 by yuuki.okamiya.yn@renesas.com + Modified 13 Mar 2018 by yuuki.okamiya.yn@renesas.com +*/ +/* + * FIXME: Temporary: Debug Display Mode + * Remove this macro definition and macro use later, + * if `Serial.write()` is fixed to work. + */ +/* #define DEBUGDISP_MODE */ + + +#include +#include +#include +#include + +extern "C" { + uint32_t R_BSP_GetFclkFreqHz(void); + void Set_Char_Serial_from_buf(uint8_t chn); +} + +#include "Arduino.h" +// #include "platform.h" + + +extern "C" { + #include "pintable.h" + extern const PinTableType * pinTablelist[NUM_DIGITAL_PINS]; +} + +extern "C" { +#if ( UART_CHANNEL == 0 ) + #include "Config_UART0.h" +#endif /* ( UART_CHANNEL == 0 ) */ +#if ( UART1_CHANNEL == 1 ) + #include "Config_UART1.h" +#endif /* ( UART1_CHANNEL == 1 ) */ +#if ( UART2_CHANNEL == 2 ) + #include "Config_UART2.h" +#endif /* ( UART2_CHANNEL == 2 ) */ + + +}; + +#if ( UART_CHANNEL == 0 ) /* ( UART_CHANNEL == 2 ) */ +#define URT_RXDx RXD0 +#define URT_TXDx TXD0 +#define URT_PERx PER0.per0 +#define URT_SAUxEN SAU0EN /* :PER0.2 */ +#define URT_SPSx SPS0 +#define URT_STx ST0 +#define URT_MKxx MK0H.mk0h +#define URT_IFxx IF0H.if0h +#define URT_PR1xx PR10H.pr10h +#define URT_PR0xx PR00H.pr00h +#define URT_STMKx STMK0 /* :MK0H.5 */ +#define URT_STIFx STIF0 /* :IF0H.5 */ +#define URT_SRMKx SRMK0 /* :MK0H.6 */ +#define URT_SRIFx SRIF0 /* :IF0H.6 */ +#define URT_SREMKx SREMK0 /* :MK0H.7 */ +#define URT_SREIFx SREIF0 /* :IF0H.7 */ +#define URT_STPR1x STPR10 /* :PR10H.5 */ +#define URT_STPR0x STPR00 /* :PR00H.5 */ +#define URT_SRPR1x SRPR10 /* :PR10H.6 */ +#define URT_SRPR0x SRPR00 /* :PR00H.6 */ +#define URT_SREPR1x SREPR10 /* :PR10H.7 */ +#define URT_SREPR0x SREPR00 /* :PR00H.7 */ +#define URT_SMRx0 SMR00 +#define URT_SCRx0 SCR00 +#define URT_SDRx0 SDR00 +#define URT_NFENx NFEN0 +#define URT_SNFENxx SNFEN00 /* :NFEN0.0 */ +#define URT_SIRx1 SIR01 +#define URT_SMRx1 SMR01 +#define URT_SCRx1 SCR01 +#define URT_SDRx1 SDR01 +#define URT_SOx SO0.so0 +#define URT_SOxx SO00 /* :SO0.0 */ +#define URT_SOLx SOL0 +#define URT_SOLxx SOL00 /* :SOL0.0 */ +#define URT_SOEx SOE0 +#define URT_SOExx SOE00 /* :SOE0.0 */ +#define URT_SSx SS0 +#define URT_SSxx SS00 /* :SS0.0 */ +#define URT_SSRx SSR00 +#define URT_Px P1 +#define URT_PMx PM1 +#define URT_TXD_Px 0x04 +#define URT_RXD_Px 0x02 +#endif /* ( UART_CHANNEL == 2 ) */ + +#if ( UART1_CHANNEL == 1 ) +#define URT1_RXDx RXD1 +#define URT1_TXDx TXD1 +#define URT1_PERx PER0.per0 +#define URT1_SAUxEN SAU0EN /* :PER0.2 */ +#define URT1_SPSx SPS0 +#define URT1_STx ST0 +#define URT1_MKxx MK1L.mk1l +#define URT1_IFxx IF1L.if1l +#define URT1_PR1xx PR11L.pr11l +#define URT1_PR0xx PR01L.pr01l +#define URT1_STMKx STMK1 /* :MK1L.0 */ +#define URT1_STIFx STIF1 /* :IF1L.0 */ +#define URT1_SRMKx SRMK1 /* :MK1L.1 */ +#define URT1_SRIFx SRIF1 /* :IF1L.1 */ +#define URT1_SREMKx SREMK1 /* :MK1L.2 */ +#define URT1_SREIFx SREIF1 /* :IF1L.2 */ +#define URT1_STPR1x STPR11 /* :PR11L.0 */ +#define URT1_STPR0x STPR01 /* :PR01L.0 */ +#define URT1_SRPR1x SRPR11 /* :PR11L.1 */ +#define URT1_SRPR0x SRPR01 /* :PR01L.1 */ +#define URT1_SREPR1x SREPR11 /* :PR11L.2 */ +#define URT1_SREPR0x SREPR01 /* :PR01L.2 */ +#define URT1_SMRx0 SMR02 +#define URT1_SCRx0 SCR02 +#define URT1_SDRx0 SDR02 +#define URT1_NFENx NFEN0 +#define URT1_SNFENxx SNFEN10 /* :NFEN0.2 */ +#define URT1_SIRx1 SIR03 +#define URT1_SMRx1 SMR03 +#define URT1_SCRx1 SCR03 +#define URT1_SDRx1 SDR03 +#define URT1_SOx SO0.so0 +#define URT1_SOxx SO02 /* :SO0.2 */ +#define URT1_SOLx SOL0.sol0 +#define URT1_SOLxx SOL02 /* :SOL0.2 */ +#define URT1_SOEx SOE0 +#define URT1_SOExx SOE02 /* :SOE0.2 */ +#define URT1_SSx SS0 +#define URT1_SSxx SS02 /* :SS0.2 */ +#define URT1_SSRx SSR02 +#define URT1_Px P0 +#define URT1_PMx PM0 +#ifdef GRCOTTON +#define URT1_TXD_Px 0x04 +#define URT1_RXD_Px 0x08 +#define URT1_PMCx PMC0.pmc0 +#else /* GRCOTTON */ +#define URT1_TXD_Px 0x01 +#define URT1_RXD_Px 0x02 +#endif /* GRCOTTON */ +#endif /* ( UART1_CHANNEL == 1 ) */ +#if ( UART2_CHANNEL == 2 ) +#define URT2_RXDx RXD2 +#define URT2_TXDx TXD2 +#define URT2_PERx PER0.per0 +#define URT2_SAUxEN SAU1EN /* :PER0.3 */ +#define URT2_SPSx SPS1 +#define URT2_STx ST1 +#define URT2_MKxx MK0H.mk0h +#define URT2_IFxx IF0H.if0h +#define URT2_PR1xx PR10H.pr10h +#define URT2_PR0xx PR00H.pr00h +#define URT2_STMKx STMK2 /* :MK0H.0 */ +#define URT2_STIFx STIF2 /* :IF0H.0 */ +#define URT2_SRMKx SRMK2 /* :MK0H.1 */ +#define URT2_SRIFx SRIF2 /* :IF0H.1 */ +#define URT2_SREMKx SREMK2 /* :MK0H.2 */ +#define URT2_SREIFx SREIF2 /* :IF0H.2 */ +#define URT2_STPR1x STPR12 /* :PR10H.0 */ +#define URT2_STPR0x STPR02 /* :PR00H.0 */ +#define URT2_SRPR1x SRPR12 /* :PR10H.1 */ +#define URT2_SRPR0x SRPR02 /* :PR00H.1 */ +#define URT2_SREPR1x SREPR12 /* :PR10H.2 */ +#define URT2_SREPR0x SREPR02 /* :PR00H.2 */ +#define URT2_SMRx0 SMR10 +#define URT2_SCRx0 SCR10 +#define URT2_SDRx0 SDR10 +#define URT2_NFENx NFEN0 +#define URT2_SNFENxx SNFEN20 /* :NFEN0.4 */ +#define URT2_SIRx1 SIR11 +#define URT2_SMRx1 SMR11 +#define URT2_SCRx1 SCR11 +#define URT2_SDRx1 SDR11 +#define URT2_SOx SO1.so1 +#define URT2_SOxx SO10 /* :SO1.0 */ +#define URT2_SOLx SOL1.sol1 +#define URT2_SOLxx SOL10 /* :SOL1.0 */ +#define URT2_SOEx SOE1 +#define URT2_SOExx SOE10 /* :SOE1.0 */ +#define URT2_SSx SS1 +#define URT2_SSxx SS10 /* :SS1.0 */ +#define URT2_SSRx SSR10 +#define URT2_Px P1 +#define URT2_PMx PM1 +#define URT2_TXD_Px 0x08 +#define URT2_RXD_Px 0x10 +#endif /* ( UART2_CHANNEL == 2 ) */ + +#if ( UART_CHANNEL == 0 ) /* ( UART_CHANNEL == 2 ) */ +#define URT_SFR_RXDx 0xfff12 /* RXD0.rxd0 */ +#define URT_SFR_TXDx 0xfff10 /* TXD0.txd0 */ +#define URT_SFR2_PERx 0xf00f0 /* PER0.per0 */ +#define URT_SFR2_BIT_SAUxEN 2 /* SAU0EN :PER0.2 */ +#define URT_SFR2_SPSx 0xf0126 /* SPS0.sps0 */ +#define URT_SFR2_STx 0xf0124 /* ST0.st0 */ +#define URT_SFR2_BIT_STxx0 0 /* ST00 :ST0.0 */ +#define URT_SFR2_BIT_STxx1 1 /* ST01 :ST0.1 */ +#define URT_SFR_MKxx 0xfffe5 /* MK0H.mk0h */ +#define URT_SFR_IFxx 0xfffe1 /* IF0H.if0h */ +#define URT_SFR_PR1xx 0xfffed /* PR10H.pr10h */ +#define URT_SFR_PR0xx 0xfffe9 /* PR00H.pr00h */ +#define URT_SFR_BIT_STMKx 5 /* STMK0 :MK0H.5 */ +#define URT_SFR_BIT_STIFx 5 /* STIF0 :IF0H.5 */ +#define URT_SFR_BIT_SRMKx 6 /* SRMK0 :MK0H.6 */ +#define URT_SFR_BIT_SRIFx 6 /* SRIF0 :IF0H.6 */ +#define URT_SFR_BIT_SREMKx 7 /* SREMK0 :MK0H.7 */ +#define URT_SFR_BIT_SREIFx 7 /* SREIF0 :IF0H.7 */ +#define URT_SFR_BIT_STPR1x 5 /* STPR10 :PR10H.5 */ +#define URT_SFR_BIT_STPR0x 5 /* STPR00 :PR00H.5 */ +#define URT_SFR_BIT_SRPR1x 6 /* SRPR10 :PR10H.6 */ +#define URT_SFR_BIT_SRPR0x 6 /* SRPR00 :PR00H.6 */ +#define URT_SFR_BIT_SREPR1x 7 /* SREPR10:PR10H.7 */ +#define URT_SFR_BIT_SREPR0x 7 /* SREPR00:PR00H.7 */ +#define URT_SFR2_SMRx0 0xf0110 /* SMR00.smr00 */ +#define URT_SFR2_SCRx0 0xf0118 /* SCR00.scr00 */ +#define URT_SFR_SDRx0 0xfff10 /* SDR00.sdr00 */ +#define URT_SFR2_NFENx 0xf0070 /* NFEN0.nfen0 */ +#define URT_SFR2_BIT_SNFENxx 0 /* SNFEN00:NFEN0.0 */ +#define URT_SFR2_SIRx1 0xf010a /* SIR01.sir01 */ +#define URT_SFR2_SMRx1 0xf0112 /* SMR01.smr01 */ +#define URT_SFR2_SCRx1 0xf011a /* SCR01.scr01 */ +#define URT_SFR2_SDRx1 0xfff12 /* SDR01.sdr01 */ +#define URT_SFR2_SOx 0xf0128 /* SO0.so0 */ +#define URT_SFR2_BIT_SOxx 0 /* SO00 :SO0.0 */ +#define URT_SFR2_SOLx 0xf0134 /* SOL0.sol0 */ +#define URT_SFR2_BIT_SOLxx 0 /* SOL00 :SOL0.0 */ +#define URT_SFR2_SOEx 0xf012a /* SOE0.soe0 */ +#define URT_SFR2_BIT_SOExx 0 /* SOE00 :SOE0.0 */ +#define URT_SFR2_SSx 0xf0122 /* SS0.ss0 */ +#define URT_SFR2_BIT_SSxx0 0 /* SS00 :SS0.0 */ +#define URT_SFR2_BIT_SSxx1 1 /* SS01 :SS0.1 */ +#endif /* ( UART_CHANNEL == 2 ) */ + +#if ( UART1_CHANNEL == 1 ) +#define URT1_SFR_RXDx 0xfff46 /* RXD1.rxd1 */ +#define URT1_SFR_TXDx 0xfff44 /* TXD1.txd1 */ +#define URT1_SFR2_PERx 0xf00f0 /* PER0.per0 */ +#define URT1_SFR2_BIT_SAUxEN 2 /* SAU0EN :PER0.2 */ +#define URT1_SFR2_SPSx 0xf0126 /* SPS0.sps0 */ +#define URT1_SFR2_STx 0xf0124 /* ST0.st0 */ +#define URT1_SFR2_BIT_STxx0 2 /* ST02 :ST0.2 */ +#define URT1_SFR2_BIT_STxx1 3 /* ST03 :ST0.3 */ +#define URT1_SFR_MKxx 0xfffe6 /* MK1L.mk1l */ +#define URT1_SFR_IFxx 0xfffe2 /* IF1L.if1l */ +#define URT1_SFR_PR1xx 0xfffee /* PR11L.pr11l */ +#define URT1_SFR_PR0xx 0xfffea /* PR01L.pr01l */ +#define URT1_SFR_BIT_STMKx 0 /* STMK1 :MK1L.0 */ +#define URT1_SFR_BIT_STIFx 0 /* STIF1 :IF1L.0 */ +#define URT1_SFR_BIT_SRMKx 1 /* SRMK1 :MK1L.1 */ +#define URT1_SFR_BIT_SRIFx 1 /* SRIF1 :IF1L.1 */ +#define URT1_SFR_BIT_SREMKx 2 /* SREMK1 :MK1L.2 */ +#define URT1_SFR_BIT_SREIFx 2 /* SREIF1 :IF1L.2 */ +#define URT1_SFR_BIT_STPR1x 0 /* STPR11 :PR11L.0 */ +#define URT1_SFR_BIT_STPR0x 0 /* STPR01 :PR01L.0 */ +#define URT1_SFR_BIT_SRPR1x 1 /* SRPR11 :PR11L.1 */ +#define URT1_SFR_BIT_SRPR0x 1 /* SRPR01 :PR01L.1 */ +#define URT1_SFR_BIT_SREPR1x 2 /* SREPR11:PR11L.2 */ +#define URT1_SFR_BIT_SREPR0x 2 /* SREPR01:PR01L.2 */ +#define URT1_SFR2_SMRx0 0xf0114 /* SMR02.smr02 */ +#define URT1_SFR2_SCRx0 0xf011c /* SCR02.scr02 */ +#define URT1_SFR_SDRx0 0xfff44 /* SDR02.sdr02 */ +#define URT1_SFR2_NFENx 0xf0070 /* NFEN0.nfen0 */ +#define URT1_SFR2_BIT_SNFENxx 2 /* SNFEN10:NFEN0.2 */ +#define URT1_SFR2_SIRx1 0xf010e /* SIR03.sir03 */ +#define URT1_SFR2_SMRx1 0xf0116 /* SMR03.smr03 */ +#define URT1_SFR2_SCRx1 0xf011e /* SCR03.scr03 */ +#define URT1_SFR2_SDRx1 0xfff46 /* SDR03.sdr03 */ +#define URT1_SFR2_SOx 0xf0128 /* SO0.so0 */ +#define URT1_SFR2_BIT_SOxx 2 /* SO02 :SO0.2 */ +#define URT1_SFR2_SOLx 0xf0134 /* SOL0.sol0 */ +#define URT1_SFR2_BIT_SOLxx 2 /* SOL02 :SOL0.2 */ +#define URT1_SFR2_SOEx 0xf012a /* SOE0.soe0 */ +#define URT1_SFR2_BIT_SOExx 2 /* SOE02 :SOE0.2 */ +#define URT1_SFR2_SSx 0xf0122 /* SS0.ss0 */ +#define URT1_SFR2_BIT_SSxx0 2 /* SS02 :SS0.2 */ +#define URT1_SFR2_BIT_SSxx1 3 /* SS03 :SS0.3 */ +#endif /* ( UART1_CHANNEL == 1 ) */ +#if ( UART2_CHANNEL == 2 ) +#define URT2_SFR_RXDx 0xfff4a /* RXD2.rxd2 */ +#define URT2_SFR_TXDx 0xfff48 /* TXD2.txd2 */ +#define URT2_SFR2_PERx 0xf00f0 /* PER0.per0 */ +#define URT2_SFR2_BIT_SAUxEN 3 /* SAU1EN :PER0.3 */ +#define URT2_SFR2_SPSx 0xf0166 /* SPS1.sps1 */ +#define URT2_SFR2_STx 0xf0164 /* ST1.st1 */ +#define URT2_SFR2_BIT_STxx0 0 /* ST10 :ST1.0 */ +#define URT2_SFR2_BIT_STxx1 1 /* ST11 :ST1.1 */ +#define URT2_SFR_MKxx 0xfffe5 /* MK0H.mk0h */ +#define URT2_SFR_IFxx 0xfffe1 /* IF0H.if0h */ +#define URT2_SFR_PR1xx 0xfffed /* PR10H.pr10h */ +#define URT2_SFR_PR0xx 0xfffe9 /* PR00H.pr00h */ +#define URT2_SFR_BIT_STMKx 0 /* STMK2 :MK0H.0 */ +#define URT2_SFR_BIT_STIFx 0 /* STIF2 :IF0H.0 */ +#define URT2_SFR_BIT_SRMKx 1 /* SRMK2 :MK0H.1 */ +#define URT2_SFR_BIT_SRIFx 1 /* SRIF2 :IF0H.1 */ +#define URT2_SFR_BIT_SREMKx 2 /* SREMK2 :MK0H.2 */ +#define URT2_SFR_BIT_SREIFx 2 /* SREIF2 :IF0H.2 */ +#define URT2_SFR_BIT_STPR1x 0 /* STPR12 :PR10H.0 */ +#define URT2_SFR_BIT_STPR0x 0 /* STPR02 :PR00H.0 */ +#define URT2_SFR_BIT_SRPR1x 1 /* SRPR12 :PR10H.1 */ +#define URT2_SFR_BIT_SRPR0x 1 /* SRPR02 :PR00H.1 */ +#define URT2_SFR_BIT_SREPR1x 2 /* SREPR12:PR10H.2 */ +#define URT2_SFR_BIT_SREPR0x 2 /* SREPR02:PR00H.2 */ +#define URT2_SFR2_SMRx0 0xf0150 /* SMR10.smr10 */ +#define URT2_SFR2_SCRx0 0xf0158 /* SCR10.scr10 */ +#define URT2_SFR_SDRx0 0xfff48 /* SDR10.sdr10 */ +#define URT2_SFR2_NFENx 0xf0070 /* NFEN0.nfen0 */ +#define URT2_SFR2_BIT_SNFENxx 4 /* SNFEN20:NFEN0.4 */ +#define URT2_SFR2_SIRx1 0xf014a /* SIR11.sir11 */ +#define URT2_SFR2_SMRx1 0xf0152 /* SMR11.smr11 */ +#define URT2_SFR2_SCRx1 0xf015a /* SCR11.scr11 */ +#define URT2_SFR_SDRx1 0xfff4a /* SDR11.sdr11 */ +#define URT2_SFR2_SOx 0xf0168 /* SO1.so1 */ +#define URT2_SFR2_BIT_SOxx 0 /* SO10 :SO1.0 */ +#define URT2_SFR2_SOLx 0xf0174 /* SOL1.sol1 */ +#define URT2_SFR2_BIT_SOLxx 0 /* SOL10 :SOL1.0 */ +#define URT2_SFR2_SOEx 0xf016a /* SOE1.soe1 */ +#define URT2_SFR2_BIT_SOExx 0 /* SOE10 :SOE1.0 */ +#define URT2_SFR2_SSx 0xf0162 /* SS1.ss1 */ +#define URT2_SFR2_BIT_SSxx0 0 /* SS10 :SS1.0 */ +#define URT2_SFR2_BIT_SSxx1 1 /* SS11 :SS1.1 */ +#endif /* ( UART2_CHANNEL == 2 ) */ + +/* + * this next line disables the entire HardwareUart.cpp, + * this is so I can support Attiny series and any other chip without a uart + */ + +#include "HardwareUart.h" + +/* + * Define constants and variables for buffering incoming serial data. We're + * using a ring buffer (I think), in which head is the index of the location + * to which to write the next incoming character and tail is the index of the + * location from which to read. + */ +// #define SERIAL_BUFFER_SIZE 256 + +void serialEventRun(void) +{ + +} + +fInterruptFunc_t uart_receive_callback_table[3] __attribute__((weak)); +fInterruptFunc_t uart_transmit_callback_table[3] __attribute__((weak)); + +// Constructors //////////////////////////////////////////////////////////////// + +/********************************************************************************************************************** + * Function Name: HardwareUart::HardwareUart + * Description : Constructor + * Arguments : rxen - UART channel + * Return Value : void + *********************************************************************************************************************/ +HardwareUart::HardwareUart(uint8_t rxen) +{ + _urt_channel = rxen; + _rx_buffer_head = 0; + _rx_buffer_tail = 0; + _tx_buffer_head = 0; + _tx_buffer_tail = 0; + _rx_buf_size = 0; + _tx_buf_size = 0; + _rx_buffer = 0; + _tx_buffer = 0; + transmitting = 0; + receive_buffer = 0; +} + +// Public Methods ////////////////////////////////////////////////////////////// + +/********************************************************************************************************************** + * Function Name: HardwareUart::begin + * Description : Initialize and configure the serial port. + * Arguments : baud - baud rate + * : { 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 57600, 115200 } + * Return Value : void + *********************************************************************************************************************/ +void HardwareUart::begin(unsigned long baud) +{ + begin(baud, SERIAL_8N1); +} + +/********************************************************************************************************************** + * Function Name: HardwareUart::begin + * Description : Initialize and configure the serial port. + * Arguments : baud - baud rate + * : { 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 57600, 115200 } + * : config - serial port setting + * : SERIAL_{ 8, 7 }{ N, E }{ 1, 2 } + * Return Value : void + *********************************************************************************************************************/ +void HardwareUart::begin(unsigned long baud, uint16_t config){ + begin(baud, config, SERIAL_BUFFER_SIZE, SERIAL_BUFFER_SIZE); +} + +/********************************************************************************************************************** + * Function Name: HardwareUart::begin + * Description : Initialize and configure the serial port. + * Arguments : baud - baud rate + * : { 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 57600, 115200 } + * : rx_buf - receive buffer size + * : tx_buf - transmit buffer size + * Return Value : void + *********************************************************************************************************************/ +void HardwareUart::begin(unsigned long baud, int rx_buf, int tx_buf){ + begin(baud, SERIAL_8N1, rx_buf, tx_buf); +} + +/********************************************************************************************************************** + * Function Name: HardwareUart::begin + * Description : Initialize and configure the serial port. + * Arguments : baud - baud rate + * : { 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 57600, 115200 } + * : config - serial port setting + * : SERIAL_{ 8, 7 }{ N, E }{ 1, 2 } + * : rx_buf - receive buffer size + * : tx_buf - transmit buffer size + * Return Value : void + *********************************************************************************************************************/ +void HardwareUart::begin(unsigned long baud, uint16_t config, int rx_buf, int tx_buf) +{ + /* Initialize Unit */ + /* begin executed. end call */ + if ((0 != _rx_buffer) || (0 != _tx_buffer)){ + return; + } + if ((1 == rx_buf) || (1 == tx_buf)){ + return; + } +#if defined(FEW_RAM_MODEL) && (FEW_RAM_MODEL == 1) + _rx_buffer = base_rx_buffer; + _tx_buffer = base_tx_buffer; +#else + _rx_buffer = (uint8_t *)malloc((size_t)(rx_buf * (int)sizeof(uint8_t))); + if (0 == _rx_buffer){ + _rx_buf_size = 0; + _tx_buf_size = 0; + return; + } + _tx_buffer = (uint8_t *)malloc((size_t)(tx_buf * (int)sizeof(uint8_t))); + if (0 == _tx_buffer){ + free((uint8_t *)_rx_buffer); + _rx_buffer = 0; + _rx_buf_size = 0; + _tx_buf_size = 0; + return; + } +#endif + + _rx_buf_size = rx_buf; + _tx_buf_size = tx_buf; + _rx_buffer_head = 0; + _rx_buffer_tail = 0; + _tx_buffer_head = 0; + _tx_buffer_tail = 0; + + switch (_urt_channel) + { + case 0: +#if (UART_CHANNEL==0) + R_Config_UART0_Create(); + Set_Baudrate(baud); + Set_SerialPort(SERIAL_TXD0,SERIAL_RXD0); + Set_Config(config); + R_Config_UART0_Start(); + R_Config_UART0_Receive((uint8_t * const)&receive_buffer,1); +#endif /* UART_CHANNEL==0 */ + break; + case 1: +#if (UART1_CHANNEL==1) + R_Config_UART1_Create(); + Set_Baudrate(baud); + Set_SerialPort(SERIAL_TXD1,SERIAL_RXD1); + Set_Config(config); + R_Config_UART1_Start(); + R_Config_UART1_Receive((uint8_t * const)&receive_buffer,1); +#endif /* UART1_CHANNEL==1 */ + break; + case 2: +#if (UART2_CHANNEL==2) + R_Config_UART2_Create(); + Set_Baudrate(baud); + Set_SerialPort(SERIAL_TXD2,SERIAL_RXD2); + Set_Config(config); + R_Config_UART2_Start(); + R_Config_UART2_Receive((uint8_t * const)&receive_buffer,1); +#endif /* UART2_CHANNEL==2 */ + break; + case 3: + break; + default : + /* Do nothing */ + break; + } +} + +/********************************************************************************************************************** + * Function Name: HardwareUart::end + * Description : Terminate the serial port processing. + * Arguments : - + * Return Value : void + *********************************************************************************************************************/ +void HardwareUart::end() +{ + switch (_urt_channel) + { + case 0: +#if (UART_CHANNEL == 0 ) + R_Config_UART0_Stop(); +#endif /* (UART_CHANNEL == 0 ) */ + break; + case 1: +#if (UART1_CHANNEL == 1 ) + R_Config_UART1_Stop(); +#endif /* (UART1_CHANNEL == 1 ) */ + break; + case 2: +#if (UART2_CHANNEL == 2 ) + R_Config_UART2_Stop(); +#endif /* (UART2_CHANNEL == 2 ) */ + break; + case 3: + break; + } +#if defined(FEW_RAM_MODEL) && (FEW_RAM_MODEL == 1) + _rx_buffer = 0; + _tx_buffer = 0; +#else + if(_rx_buffer!= 0) + { + free((uint8_t *)_rx_buffer); + _rx_buffer = 0; + } + if(_tx_buffer!= 0) + { + free((uint8_t *)_tx_buffer); + _tx_buffer = 0; + } +#endif + _rx_buffer_head = 0; + _rx_buffer_tail = 0; + _tx_buffer_head = 0; + _tx_buffer_tail = 0; + _rx_buf_size = 0; + _tx_buf_size = 0; +} + +/********************************************************************************************************************** + * Function Name: HardwareUart::available + * Description : Get the number of readable data bytes of received data. + * Arguments : - + * Return Value : size of readable data + *********************************************************************************************************************/ +int HardwareUart::available(void) +{ + int head = 0; + int tail = 0; + noInterrupts(); + head = _rx_buffer_head; + tail = _rx_buffer_tail; + interrupts(); + if (head >= tail) return head - tail; + return (_rx_buf_size - tail + head ); +} + +/********************************************************************************************************************** + * Function Name: HardwareUart::peek + * Description : Read received data by 1 byte and do not change the buffer position. + * Arguments : - + * Return Value : -1 - no read data + * : other - read data + *********************************************************************************************************************/ +int HardwareUart::peek(void) +{ + if (_rx_buffer_head == _rx_buffer_tail) { + return -1; + } else { + return _rx_buffer[_rx_buffer_tail]; + } +} + +/********************************************************************************************************************** + * Function Name: HardwareUart::read + * Description : Read received data by 1 byte and advance the buffer position by 1 byte. + * Arguments : - + * Return Value : -1 - no read data + * : other - read data + *********************************************************************************************************************/ +int HardwareUart::read(void) +{ + /* if the head isn't ahead of the tail, we don't have any characters */ + noInterrupts(); + if (_rx_buffer_head == _rx_buffer_tail) { + interrupts(); + return -1; + } + unsigned char c = _rx_buffer[_rx_buffer_tail]; + _rx_buffer_tail = (_rx_buffer_tail + 1) % _rx_buf_size; + interrupts(); + + return c; +} + +/********************************************************************************************************************** + * Function Name: HardwareUart::flush + * Description : Wait for all data transmission in the transmission buffer to be completed. + * Arguments : - + * Return Value : void + *********************************************************************************************************************/ +void HardwareUart::flush() +{ + /* buffer is none */ + if (0 == _tx_buf_size || 0 == _tx_buffer){ + return; + } + if (_urt_channel == 0) { + while (SSR00 & (_0040_SAU_UNDER_EXECUTE | _0020_SAU_VALID_STORED)) { /* check TSF00 and BFF00 */ + ; + } + } + else if (_urt_channel == 1) { + while (SSR02 & (_0040_SAU_UNDER_EXECUTE | _0020_SAU_VALID_STORED)) { /* check TSF02 and BFF02 */ + ; + } + } +#if ( UART2_CHANNEL == 2 ) + else if (_urt_channel == 2) { + while (SSR10 & (_0040_SAU_UNDER_EXECUTE | _0020_SAU_VALID_STORED)) { /* check TSF10 and BFF10 */ + + ; + } + } +#endif /* ( UART2_CHANNEL == 2 ) */ + + while(_tx_buf_size-1!=availableForWrite()) + { + NOP(); + } +} + +/********************************************************************************************************************** + * Function Name: HardwareUart::UART_Send + * Description : Transmit data to the target serial port (actual implementation of write operation). + * Arguments : c - transmission data + * Return Value : -1 - write failed with the transmission buffer overflow + * : other - written data size + *********************************************************************************************************************/ +size_t HardwareUart::UART_Send(uint8_t c) +{ + MD_STATUS err = MD_OK; + int i; + uint8_t isp; + size_t ret = 0; + + /* buffer is none */ + if (0 == _tx_buf_size){ + return ret; + } + + isp = (uint8_t)GET_PSW_ISP(); + + noInterrupts(); + if(_tx_buffer_tail == _tx_buffer_head){ + /* Unsent */ + //int head = (_tx_buffer_head + 1); + i = (_tx_buffer_head + 1) % _tx_buf_size; + _tx_buffer[_tx_buffer_head] = c; + _tx_buffer_head = i; + interrupts(); + + switch (_urt_channel) + { + case 0: + if((SSR00 & _0020_SAU_VALID_STORED) != 0)/*BFF00*/ + { + return 0; + } + err = R_Config_UART0_Send((uint8_t * const)&c,1); + break; + case 1: + if((SSR02 & _0020_SAU_VALID_STORED) != 0)/*BFF02*/ + { + return 0; + } + err = R_Config_UART1_Send((uint8_t * const)&c,1); + break; + case 2: +#if ( UART2_CHANNEL == 2 ) + if((SSR10 & _0020_SAU_VALID_STORED) != 0)/*BFF10*/ + { + return 0; + } + err = R_Config_UART2_Send((uint8_t * const)&c,1); +#endif /* ( UART2_CHANNEL == 2 ) */ + break; + case 3: + break; + } + } + else + { + /* only buffer copy during transmission process */ + i = (_tx_buffer_head + 1) % _tx_buf_size; + if(i == _tx_buffer_tail) + { + /* buffer over */ + if(ISP_LEVEL_3 == isp) + { + /* When called from main program(setup() or loop() */ + interrupts(); + while(i == _tx_buffer_tail) + { + ; + } + noInterrupts(); + } + else + { + /* When called from interuupt function (ex. callback routine for periodic processing */ + switch (_urt_channel) + { + case 0: + #if ( UART_CHANNEL == 0 ) + while((SSR00 & _0020_SAU_VALID_STORED) != 0)/*BFF00*/ + { + ; + } + STIF0 = 0; + #endif /* ( UART_CHANNEL == 0 ) */ + break; + case 1: + #if ( UART1_CHANNEL == 1 ) + while((SSR02 & _0020_SAU_VALID_STORED) != 0)/*BFF02*/ + { + ; + } + STIF1 = 0; + #endif /* ( UART1_CHANNEL == 1 ) */ + break; + case 2: + #if ( UART2_CHANNEL == 2 ) + while((SSR10 & _0020_SAU_VALID_STORED) != 0)/*BFF10*/ + { + ; + } + STIF2 = 0; + #endif /* ( UART2_CHANNEL == 2 ) */ + break; + case 3: + break; + } + Set_Char_Serial_from_buf(_urt_channel); + if(0 != uart_transmit_callback_table[_urt_channel]) + { + (*uart_transmit_callback_table[_urt_channel])(); + } + } + } + _tx_buffer[_tx_buffer_head] = c; + _tx_buffer_head = i; + interrupts(); + } + if(err == MD_OK){ + return 1; + } + return ret; +} + +/********************************************************************************************************************** + * Function Name: HardwareUart::write + * Description : Transmit data to the target serial port. + * Arguments : c - transmission data + * Return Value : -1 - write failed with the transmission buffer overflow + * : other - written data size + *********************************************************************************************************************/ + +size_t HardwareUart::write(uint8_t c) +{ + size_t err = 0; + err = UART_Send(c); + return err; +} + + +/********************************************************************************************************************** + * Function Name: HardwareUart::availableForWrite + * Description : Get the number of available transmit buffer space for write. + * Arguments : - + * Return Value : size of transmit buffer free space + *********************************************************************************************************************/ +int HardwareUart::availableForWrite(void) +{ + int head = 0; + int tail = 0; + noInterrupts(); + head = _tx_buffer_head; + tail = _tx_buffer_tail; + interrupts(); + if (head >= tail) return _tx_buf_size - 1 - head + tail; + return (tail - head - 1); +} + +/********************************************************************************************************************** + * Function Name: HardwareUart::availableForRead + * Description : Get the number of available receive buffer space for read. + * Arguments : - + * Return Value : size of receive buffer free space + *********************************************************************************************************************/ +int HardwareUart::availableForRead(void) +{ + int head = 0; + int tail = 0; + noInterrupts(); + head = _rx_buffer_head; + tail = _rx_buffer_tail; + interrupts(); + if (head >= tail) return _rx_buf_size - 1 - head + tail; + return (tail - head - 1); + +} + +HardwareUart::operator bool() { + return true; +} + +/* Load Send data from Send Buffer & Start New Send Function */ +/********************************************************************************************************************** + * Function Name: HardwareUart::load_char + * Description : Extract 1 byte from the transmit buffer and send it. + * : Called from the transmission complete interrupt handler. + * : Unavailable for the other purpose. + * Arguments : - + * Return Value : - + *********************************************************************************************************************/ +void HardwareUart::load_char(void){ + int i = (_tx_buffer_tail + 1) % _tx_buf_size; + _tx_buffer_tail = i; + if (i != _tx_buffer_head) { + uint8_t send_buffer = _tx_buffer[i]; + switch (_urt_channel) + { + case 0: +#if (UART_CHANNEL == 0) + R_Config_UART0_Send((uint8_t * const)&send_buffer,1); +#endif /* (UART_CHANNEL == 0) */ + break; + case 1: +#if (UART1_CHANNEL == 1) + R_Config_UART1_Send((uint8_t * const)&send_buffer,1); +#endif /* (UART1_CHANNEL == 1) */ + break; + case 2: +#if (UART2_CHANNEL == 2) + R_Config_UART2_Send((uint8_t * const)&send_buffer,1); +#endif /* (UART2_CHANNEL == 2) */ + break; + case 3: + break; + } + } +} + + +/* Store Received data to Receive Buffer & Start New Receive Function */ +/********************************************************************************************************************** + * Function Name: HardwareUart::store_char + * Description : Store 1 byte of the last received data in the receive buffer + * : and continue the receive process for the following bytes. + * : Called from the receive complete interrupt handler. + * : Unavailable for the other purpose. + * Arguments : - + * Return Value : - + *********************************************************************************************************************/ +void HardwareUart::store_char(void){ + store_char(receive_buffer); + receive_buffer = 0; + switch (_urt_channel) + { + case 0: + #if (UART_CHANNEL == 0) + R_Config_UART0_Receive((uint8_t * const)&receive_buffer,1); + #endif /* (UART_CHANNEL == 0) */ + break; + case 1: + #if (UART1_CHANNEL == 1) + R_Config_UART1_Receive((uint8_t * const)&receive_buffer,1); + #endif /* (UART1_CHANNEL == 1) */ + break; + case 2: + #if (UART2_CHANNEL == 2) + R_Config_UART2_Receive((uint8_t * const)&receive_buffer,1); + #endif /* (UART2_CHANNEL == 2) */ + break; + break; + } +} + +/********************************************************************************************************************** + * Function Name: HardwareUart::store_char + * Description : Store 1 byte of the last received data in the receive buffer + * : and continue the receive process for the following bytes. + * : Make sure to disable interrupts before calling this from outside of the interrupt handler. + * Arguments : c - byte to store + * Return Value : - + *********************************************************************************************************************/ +void HardwareUart::store_char(unsigned char c){ + int i = (_rx_buffer_head + 1) % _rx_buf_size; + if (i != _rx_buffer_tail) { + _rx_buffer[_rx_buffer_head] = c; + _rx_buffer_head = i; + } +} + +/* Add for RL78/G23 */ +/********************************************************************************************************************** + * Function Name: HardwareUart::Set_Baudrate + * Description : Set baud rate for the serial port. + * Arguments : baudrate - baud rate + * : { 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 57600, 115200 } + * Return Value : void + *********************************************************************************************************************/ +void HardwareUart::Set_Baudrate(unsigned long baudrate) +{ + uint32_t fclk_frequency; + uint32_t peri_clk ; + uint8_t sdr ; + uint16_t tmp_sdr ; + uint8_t prs = 0U; + fclk_frequency = R_BSP_GetFclkFreqHz(); + + peri_clk = (fclk_frequency) ; /* SPSmk0\[3:0] = 0x0 */ + + tmp_sdr = (uint16_t)(((peri_clk/baudrate) >> 1) -1) ; + while(0x007F> 1); + tmp_sdr = (uint16_t)(((peri_clk/baudrate) >> 1) -1) ; + } + + sdr = (uint8_t)(tmp_sdr & 0x007F) ; + + switch (_urt_channel) + { + case 0: +#if ( UART_CHANNEL == 0 ) + SPS0 &= (_00F0_SAU_CK00_CLEAR) ; + SPS0 |= prs ; + SDR00 = ((uint16_t)sdr) << 9 ; + SDR01 = ((uint16_t)sdr) << 9 ; +#endif /* ( UART_CHANNEL == 0 ) */ + break; + case 1: +#if ( UART1_CHANNEL == 1 ) + SPS0 &= (_000F_SAU_CK01_CLEAR) ; + SPS0 |= ((uint16_t)prs << 4); + SDR02 = ((uint16_t)sdr) << 9 ; + SDR03 = ((uint16_t)sdr) << 9 ; +#endif /* ( UART1_CHANNEL == 1 ) */ + break; + case 2: +#if ( UART2_CHANNEL == 2 ) + SPS1 &= (_00F0_SAU_CK00_CLEAR) ; + SPS1 |= prs ; + SDR10 = ((uint16_t)sdr) << 9 ; + SDR11 = ((uint16_t)sdr) << 9 ; +#endif /* ( UART2_CHANNEL == 2 ) */ + break; + case 3: + break; + default : + /* Do nothing */ + break; + } +} + +#ifdef __RL78__ +/********************************************************************************************************************** + * Function Name: HardwareUart::Set_Config + * Description : Set the serial data length, parity, and stop bit. + * Arguments : config - serial port setting + * : SERIAL_{ 8, 7 }{ N, E }{ 1, 2 } + * Return Value : void + *********************************************************************************************************************/ +void HardwareUart::Set_Config(uint16_t config ) +{ + uint16_t converted_config = 0; + + switch(config) + { + case SERIAL_7N1: + case SERIAL_8N1: + case SERIAL_7N2: + case SERIAL_8N2: + case SERIAL_7E1: + case SERIAL_8E1: + case SERIAL_7E2: + case SERIAL_8E2: + case SERIAL_7O1: + case SERIAL_8O1: + case SERIAL_7O2: + case SERIAL_8O2: + /* Do nothing */ + break; + default: + config = SERIAL_8N1; + break; + } + if(SERIAL_DATA_7 == (SERIAL_DATA_MASK & config)) + { + converted_config |= _0002_SAU_LENGTH_7; + } + else + { + /* All other settings are treated as SERIAL_DATA_8(default). */ + converted_config |= _0003_SAU_LENGTH_8; + } + + if(SERIAL_STOP_BIT_2 == (SERIAL_STOP_BIT_MASK & config)) + { + converted_config |= _0020_SAU_STOP_2; + } + else + { + /* All other settings are treated as SERIAL_STOP_BIT_1(default). */ + converted_config |= _0010_SAU_STOP_1; + } + + if(SERIAL_PARITY_EVEN == (SERIAL_PARITY_MASK & config)) + { + converted_config |= _0200_SAU_PARITY_EVEN; + } + else if(SERIAL_PARITY_ODD == (SERIAL_PARITY_MASK & config)) + { + converted_config |= _0300_SAU_PARITY_ODD; + } + else + { + /* All other settings are treated as SERIAL_PARITY_NONE(default). */ + converted_config |= _0000_SAU_PARITY_NONE; + } + + switch (_urt_channel) + { + /* Rewriting prohibited when SEmn = 1 / Set_Config is called between R_Config_UART0_Create () and R_Config_UART0_Start (), so SEmn = 0*/ + case 0: + { + /* SCR00 16bit*/ +#if ( UART_CHANNEL == 0 ) + unsigned short SCR00data=_8000_SAU_TRANSMISSION |_0000_SAU_INTSRE_MASK |_0004_SAU_SCRMN_INITIALVALUE |_0080_SAU_LSB | converted_config; + /* When sending, _0000_SAU_INTSRE_MASK :EOCmn = 0*/ + unsigned short SCR01data=_4000_SAU_RECEPTION |_0400_SAU_INTSRE_ENABLE |_0004_SAU_SCRMN_INITIALVALUE |_0080_SAU_LSB | converted_config; + /* _0400_SAU_INTSRE_ENABLE: EOCmn = 1 Allow the occurrence of the error interrupt INTSREx */ + + /* SLCmn1: 0 SLCmn0: 1 when receiving XXXXXXXXXX01XXXX*/ + SCR01data &= ~(_0020_SAU_STOP_2); + SCR01data |= _0010_SAU_STOP_1; + + SCR00 = SCR00data; + SCR01 = SCR01data; +#endif /* ( UART_CHANNEL == 0 ) */ + } + break; + + case 1: + { +#if ( UART1_CHANNEL == 1 ) + unsigned short SCR02data=_8000_SAU_TRANSMISSION| _0000_SAU_INTSRE_MASK |_0004_SAU_SCRMN_INITIALVALUE |_0080_SAU_LSB |converted_config; + unsigned short SCR03data=_4000_SAU_RECEPTION| _0400_SAU_INTSRE_ENABLE |_0004_SAU_SCRMN_INITIALVALUE |_0080_SAU_LSB |converted_config; + /* SLCmn1: 0 SLCmn0: 1 when receiving XXXXXXXXXX01XXXX*/ + SCR03data &= ~(_0020_SAU_STOP_2); + SCR03data |= _0010_SAU_STOP_1; + + SCR02 = SCR02data; + SCR03 = SCR03data; +#endif /* ( UART1_CHANNEL == 1 ) */ + } + break; + case 2: + { +#if ( UART2_CHANNEL == 2 ) + unsigned short SCR10data=_8000_SAU_TRANSMISSION| _0000_SAU_INTSRE_MASK |_0004_SAU_SCRMN_INITIALVALUE |_0080_SAU_LSB |converted_config; + unsigned short SCR11data=_4000_SAU_RECEPTION| _0400_SAU_INTSRE_ENABLE |_0004_SAU_SCRMN_INITIALVALUE |_0080_SAU_LSB |converted_config; + /* SLCmn1: 0 SLCmn0: 1 when receiving XXXXXXXXXX01XXXX*/ + SCR11data &= ~(_0020_SAU_STOP_2); + SCR11data |= _0010_SAU_STOP_1; + SCR10 = SCR10data; + SCR11 = SCR11data; +#endif /* ( UART2_CHANNEL == 2 ) */ + } + break; + case 3: + { + + } + break; + } +} +/********************************************************************************************************************** + End of function Set_Config + *********************************************************************************************************************/ +#endif /* __RL78__ */ + +/********************************************************************************************************************** + * Function Name: HardwareUart::Set_SerialPort + * Description : Set serial port pins for the target port. + * Arguments : txd_pin - transmit pin no. + * : rxd_pin - receive pin no. + * Return Value : void + *********************************************************************************************************************/ +void HardwareUart::Set_SerialPort(uint8_t txd_pin,uint8_t rxd_pin) +{ + //PinTableType* p; + //PinTableType pin_tbl; + //p = (PinTableType*)&pin_tbl; + + + const PinTableType ** pp; + PinTableType * p; + + /* Set RxD pin */ + //getPinTable(rxd_pin,p); + pp = &pinTablelist[rxd_pin]; + p = (PinTableType *)*pp; + /* Set PM Register for Input */ + *p->portModeRegisterAddr |= (unsigned long)(0x1 << p->bit); + +#if defined(G22_FPB) || defined(G23_FPB) + /* Set PMCA Register */ + if (0!=p->pmca){ + *p->portModeControlARegisterAddr &= (unsigned long)~(p->pmca); + } +#endif // defined(G22_FPB) || defined(G23_FPB) + + /* Set PMCT Register */ +#if defined(G22_FPB) || defined(G23_FPB) + if (0!=p->pmct){ + *p->portModeControlTRegisterAddr &= (unsigned long)~(p->pmct); + } +#endif // defined(G22_FPB) || defined(G23_FPB) + + /* Set PMCE Register for Output */ +#if defined(G23_FPB) + if (0!=p->pmce){ + *p->portModeControlERegisterAddr &= (unsigned long)~(p->pmce); + } +#endif // G23_FPB + /* Set CCDE Register for Digital InOut */ +#if defined(G23_FPB) + if (0!=p->ccde){ + CCDE &= (uint8_t)~(p->ccde); + } +#endif // G23_FPB +#if defined(G16_FPB) + if (0!=p->pmc){ + *p->portModeControlRegisterAddr &= (unsigned long)~(p->pmc); + } +#endif // defined(G16_FPB) + + /* Set TxD pin */ + //getPinTable(txd_pin,p); + pp = &pinTablelist[txd_pin]; + p = (PinTableType *)*pp; + /* Set PMCE Register t */ +#if defined(G23_FPB) + if (0!=p->pmce){ + *p->portModeControlERegisterAddr &= (unsigned long)~(p->pmce); + } +#endif // G23_FPB + + /* Set P Register for Set "H" Output Port*/ + *p->portRegisterAddr |= (unsigned long)(0x1 << p->bit); + + /* Set PM Register for Output */ + *p->portModeRegisterAddr &= (unsigned long)~(0x1 << p->bit); + + /* Set PMCA Register */ +#if defined(G22_FPB) || defined(G23_FPB) + if (0!=p->pmca){ + *p->portModeControlARegisterAddr &= (unsigned long)~(p->pmca); + } +#endif // defined(G22_FPB) || defined(G23_FPB) + + /* Set PMCT Register */ +#if defined(G22_FPB) || defined(G23_FPB) + if (0!=p->pmct){ + *p->portModeControlTRegisterAddr &= (unsigned long)~(p->pmct); + } +#endif // defined(G22_FPB) || defined(G23_FPB) + + /* Set PMCE Register t */ +#if defined(G23_FPB) + if (0!=p->pmce){ + *p->portModeControlERegisterAddr &= (unsigned long)~(p->pmce); + } +#endif // G23_FPB + /* Set CCDE Register for Digital InOut */ +#if defined(G23_FPB) + if (0!=p->ccde){ + CCDE &= (uint8_t)~(p->ccde); + } +#endif // G23_FPB + +#if defined(G16_FPB) + if (0!=p->pmc){ + *p->portModeControlRegisterAddr &= (unsigned long)~(p->pmc); + } +#endif // G16_FPB +} + +void HardwareUart::setReceiveCallback(void (*userFunc)(void)) +{ + uart_receive_callback_table[_urt_channel] = userFunc; +} +void HardwareUart::setTransmitCallback(void (*userFunc)(void)) +{ + uart_transmit_callback_table[_urt_channel] = userFunc; +} + +extern "C" { +/********************************************************************************************************************** + * Function Name: Set_Char_Serial_to_buf + * Description : Store the received data in the buffer. + * : Called from the receive interrupt handler. + * Arguments : chn - UART channel + * Return Value : void + *********************************************************************************************************************/ +void Set_Char_Serial_to_buf(uint8_t chn) +{ + switch (chn) + { + case 0: +#if (UART_CHANNEL == 0) + Serial.store_char(); +#endif /* (UART_CHANNEL == 0) */ + break; + case 1: +#if (UART1_CHANNEL == 1) + Serial1.store_char(); +#endif /* (UART1_CHANNEL == 1) */ + break; + case 2: +#if (UART2_CHANNEL == 2) + Serial2.store_char(); +#endif /* (UART2_CHANNEL == 2) */ + break; + case 3: + break; + } +} + +/********************************************************************************************************************** + * Function Name: Set_Char_Serial_from_buf + * Description : Load write data from the buffer. + * Arguments : chn - UART_CHANNEL + * Return Value : void - + *********************************************************************************************************************/ + +void Set_Char_Serial_from_buf(uint8_t chn) +{ + switch (chn) + { + case 0: +#if (UART_CHANNEL == 0) + Serial.load_char(); +#endif /* (UART_CHANNEL == 0) */ + break; + case 1: +#if (UART1_CHANNEL == 1) + Serial1.load_char(); +#endif /* (UART1_CHANNEL == 1) */ + break; + case 2: +#if (UART2_CHANNEL == 2) + Serial2.load_char(); +#endif /* (UART2_CHANNEL == 2) */ + break; + case 3: + break; + } +} + +} + +// Preinstantiate Objects ////////////////////////////////////////////////////// + +#if ( UART_CHANNEL == 0 ) + HardwareUart Serial(0); +#endif /* ( UART_CHANNEL == 0 ) */ +#if ( UART1_CHANNEL == 1 ) + HardwareUart Serial1(1); +#endif /* ( UART1_CHANNEL == 1 ) */ +#if ( UART2_CHANNEL == 2 ) + HardwareUart Serial2(2); +#endif /* ( UART2_CHANNEL == 2 ) */ + + diff --git a/cores/rl78g22/HardwareUart.h b/cores/rl78g22/HardwareUart.h index f75f9d3..9b3e681 100644 --- a/cores/rl78g22/HardwareUart.h +++ b/cores/rl78g22/HardwareUart.h @@ -24,7 +24,11 @@ #undef SERIAL_BUFFER_SIZE #endif +#if defined(FEW_RAM_MODEL) && (FEW_RAM_MODEL == 1) +#define SERIAL_BUFFER_SIZE 32 +#else #define SERIAL_BUFFER_SIZE 256 +#endif class HardwareUart : public arduino::HardwareSerial { @@ -65,6 +69,11 @@ class HardwareUart : public arduino::HardwareSerial unsigned char *_rx_buffer; unsigned char *_tx_buffer; +#if defined(FEW_RAM_MODEL) && (FEW_RAM_MODEL == 1) + unsigned char base_rx_buffer[SERIAL_BUFFER_SIZE]; + unsigned char base_tx_buffer[SERIAL_BUFFER_SIZE]; +#endif // + uint8_t receive_buffer; uint8_t _urt_channel; bool transmitting; diff --git a/cores/rl78g22/WInterrupts.c b/cores/rl78g22/WInterrupts.c index 12eae9e..22d4b3f 100644 --- a/cores/rl78g22/WInterrupts.c +++ b/cores/rl78g22/WInterrupts.c @@ -1,112 +1,112 @@ -/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Wiring project - http://wiring.uniandes.edu.co - - Copyright (c) 2004-05 Hernando Barragan - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - Modified 24 November 2006 by David A. Mellis - Modified 1 August 2010 by Mark Sproul -*/ -/* - * Mar 1st 2017 : Modified for RL78/G13 by Yuuki Okamiya. - */ - -#include -// #include -#include - -#include "utilities.h" -#include "wiring_private.h" -#include "api/Common.h" -#include "r_smc_entry.h" -#include "platform.h" - - - -/* 1108 Ueeda add */ - -typedef struct { - void (*begin)(); - void (*mode)(uint8_t interruptNum, PinStatus mode); - void (*start)(); - void (*stop)(uint8_t interruptNum); -} Interrupts_func; - -Interrupts_func Int_func = -{ - .begin = (void*)R_Config_INTC_Create, - .mode = (void*)R_Config_INTC_Create_Mode, - .start = (void*)R_Config_INTC_INTP_Start, - .stop = (void*)R_Config_INTC_INTP_Stop -}; - -static bool IsFirst = true; - -// void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) - -//void attachInterrupt(pin_size_t interruptNum, voidFuncPtr userFunc, int mode) - -void attachInterrupt(pin_size_t interruptNum, voidFuncPtr userFunc, PinStatus p_mode) -{ - uint8_t mode = (uint8_t)p_mode; - if (interruptNum < EXTERNAL_NUM_INTERRUPTS) { - g_afInterruptFuncTable[interruptNum] = userFunc; - if(IsFirst){ - Int_func.begin(); - IsFirst = false; - } - Int_func.mode(interruptNum, mode); - Int_func.start(); - } -} - -void detachInterrupt(uint8_t interruptNum) { - - if (interruptNum < EXTERNAL_NUM_INTERRUPTS) { - Int_func.stop(interruptNum); - g_afInterruptFuncTable[interruptNum] = NULL; - } -} - -// INTERRUPT HANDLERS *********************************************************/ -// NMI and IRQ interrupt handlers. Note that all of these are declared in -// interrupts_handlers.h but defined here for clarity. - -// ***************************************************************************/ -INTERRUPT void external_interrupt_0(void) -{ - if (g_afInterruptFuncTable[0] != NULL) { - (*g_afInterruptFuncTable[0])(); - } -} - -INTERRUPT void external_interrupt_1(void) -{ - if (g_afInterruptFuncTable[1] != NULL) { - (*g_afInterruptFuncTable[1])(); - } -} - -INTERRUPT void external_interrupt_2(void) -{ - if (g_afInterruptFuncTable[2] != NULL) { - (*g_afInterruptFuncTable[2])(); - } -} - +/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ + +/* + Part of the Wiring project - http://wiring.uniandes.edu.co + + Copyright (c) 2004-05 Hernando Barragan + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + Modified 24 November 2006 by David A. Mellis + Modified 1 August 2010 by Mark Sproul +*/ +/* + * Mar 1st 2017 : Modified for RL78/G13 by Yuuki Okamiya. + */ + +#include +// #include +#include + +#include "utilities.h" +#include "wiring_private.h" +#include "api/Common.h" +#include "r_smc_entry.h" +#include "platform.h" + + + +/* 1108 Ueeda add */ + +typedef struct { + void (*begin)(); + void (*mode)(uint8_t interruptNum, PinStatus mode); + void (*start)(); + void (*stop)(uint8_t interruptNum); +} Interrupts_func; + +Interrupts_func Int_func = +{ + .begin = (void*)R_Config_INTC_Create, + .mode = (void*)R_Config_INTC_Create_Mode, + .start = (void*)R_Config_INTC_INTP_Start, + .stop = (void*)R_Config_INTC_INTP_Stop +}; + +static bool IsFirst = true; + +// void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) + +//void attachInterrupt(pin_size_t interruptNum, voidFuncPtr userFunc, int mode) + +void attachInterrupt(pin_size_t interruptNum, voidFuncPtr userFunc, PinStatus p_mode) +{ + uint8_t mode = (uint8_t)p_mode; + if (interruptNum < EXTERNAL_NUM_INTERRUPTS) { + g_afInterruptFuncTable[interruptNum] = userFunc; + if(IsFirst){ + Int_func.begin(); + IsFirst = false; + } + Int_func.mode(interruptNum, mode); + Int_func.start(); + } +} + +void detachInterrupt(uint8_t interruptNum) { + + if (interruptNum < EXTERNAL_NUM_INTERRUPTS) { + Int_func.stop(interruptNum); + g_afInterruptFuncTable[interruptNum] = NULL; + } +} + +// INTERRUPT HANDLERS *********************************************************/ +// NMI and IRQ interrupt handlers. Note that all of these are declared in +// interrupts_handlers.h but defined here for clarity. + +// ***************************************************************************/ +INTERRUPT void external_interrupt_0(void) +{ + if (g_afInterruptFuncTable[0] != NULL) { + (*g_afInterruptFuncTable[0])(); + } +} + +INTERRUPT void external_interrupt_1(void) +{ + if (g_afInterruptFuncTable[1] != NULL) { + (*g_afInterruptFuncTable[1])(); + } +} + +INTERRUPT void external_interrupt_2(void) +{ + if (g_afInterruptFuncTable[2] != NULL) { + (*g_afInterruptFuncTable[2])(); + } +} + diff --git a/cores/rl78g22/WMath.cpp b/cores/rl78g22/WMath.cpp index 0a200ee..12c0149 100644 --- a/cores/rl78g22/WMath.cpp +++ b/cores/rl78g22/WMath.cpp @@ -1,74 +1,74 @@ -/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Wiring project - http://wiring.org.co - Copyright (c) 2004-06 Hernando Barragan - Modified 13 August 2006, David A. Mellis for Arduino - http://www.arduino.cc/ - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA -*/ -/* - * Modified 5 Mar 2017 by Yuuki Okamiya for RL78/G13 -*/ - -extern "C" { - #include "stdlib.h" -} - -void randomSeed(unsigned long seed) -{ - if (seed != 0) { -#ifndef __RL78__ - srandom(seed); -#else - srand((unsigned int)seed); -#endif - } -} - -long random(long howbig) -{ - unsigned long value = 0; - if (howbig == 0) { - return 0; - } -#ifndef __RL78__ - return random() % howbig; -#else - value = ((unsigned long)rand() << 16); - value |= ((unsigned long)rand() << 1); - value |= ((unsigned long)rand() & 0x01); - return (signed long)value % howbig; -#endif -} - -long random(long howsmall, long howbig) -{ - if (howsmall >= howbig) { - return howsmall; - } - long diff = howbig - howsmall; - return random(diff) + howsmall; -} -/* -long map(long x, long in_min, long in_max, long out_min, long out_max) -{ - return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; -} - -unsigned int makeWord(unsigned int w) { return w; } -unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; } -*/ +/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ + +/* + Part of the Wiring project - http://wiring.org.co + Copyright (c) 2004-06 Hernando Barragan + Modified 13 August 2006, David A. Mellis for Arduino - http://www.arduino.cc/ + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA +*/ +/* + * Modified 5 Mar 2017 by Yuuki Okamiya for RL78/G13 +*/ + +extern "C" { + #include "stdlib.h" +} + +void randomSeed(unsigned long seed) +{ + if (seed != 0) { +#ifndef __RL78__ + srandom(seed); +#else + srand((unsigned int)seed); +#endif + } +} + +long random(long howbig) +{ + unsigned long value = 0; + if (howbig == 0) { + return 0; + } +#ifndef __RL78__ + return random() % howbig; +#else + value = ((unsigned long)rand() << 16); + value |= ((unsigned long)rand() << 1); + value |= ((unsigned long)rand() & 0x01); + return (signed long)value % howbig; +#endif +} + +long random(long howsmall, long howbig) +{ + if (howsmall >= howbig) { + return howsmall; + } + long diff = howbig - howsmall; + return random(diff) + howsmall; +} +/* +long map(long x, long in_min, long in_max, long out_min, long out_max) +{ + return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; +} + +unsigned int makeWord(unsigned int w) { return w; } +unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; } +*/ diff --git a/cores/rl78g22/api/ArduinoAPI.h b/cores/rl78g22/api/ArduinoAPI.h new file mode 100644 index 0000000..edc0491 --- /dev/null +++ b/cores/rl78g22/api/ArduinoAPI.h @@ -0,0 +1,57 @@ +/* + Arduino API main include + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef ARDUINO_API_H +#define ARDUINO_API_H + +// version 1.4.0 +#define ARDUINO_API_VERSION 10400 + +#include "Binary.h" + +#ifdef __cplusplus +#include "Interrupts.h" +#include "IPAddress.h" +#include "Print.h" +#include "Printable.h" +#include "PluggableUSB.h" +#include "Server.h" +#include "String.h" +#include "Stream.h" +#include "Udp.h" +#include "USBAPI.h" +#include "WCharacter.h" +#endif + +/* Standard C library includes */ +#include +#include +#include +#include +#include + +// Misc Arduino core functions +#include "Common.h" + +#ifdef __cplusplus +// Compatibility layer for older code +#include "Compat.h" +#endif + +#endif diff --git a/cores/rl78g22/api/Binary.h b/cores/rl78g22/api/Binary.h new file mode 100644 index 0000000..947542e --- /dev/null +++ b/cores/rl78g22/api/Binary.h @@ -0,0 +1,552 @@ +/* + binary.h - Definitions for binary constants + Deprecated -- use 0b binary literals instead + Copyright (c) 2006 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef Binary_h +#define Binary_h + +/* If supported, 0b binary literals are preferable to these constants. + * In that case, warn the user about these being deprecated (if possible). */ +#if __cplusplus >= 201402L + /* C++14 introduces binary literals; C++11 introduces [[deprecated()]] */ + #define DEPRECATED(x) [[deprecated("use " #x " instead")]] +#elif __GNUC__ >= 6 + /* GCC 4.3 supports binary literals; GCC 6 supports __deprecated__ on enums*/ + #define DEPRECATED(x) __attribute__ ((__deprecated__ ("use " #x " instead"))) +#else + /* binary literals not supported, or "deprecated" warning not displayable */ + #define DEPRECATED(x) +#endif + +enum { + B0 DEPRECATED(0b0 ) = 0, + B00 DEPRECATED(0b00 ) = 0, + B000 DEPRECATED(0b000 ) = 0, + B0000 DEPRECATED(0b0000 ) = 0, + B00000 DEPRECATED(0b00000 ) = 0, + B000000 DEPRECATED(0b000000 ) = 0, + B0000000 DEPRECATED(0b0000000 ) = 0, + B00000000 DEPRECATED(0b00000000) = 0, + B1 DEPRECATED(0b1 ) = 1, + B01 DEPRECATED(0b01 ) = 1, + B001 DEPRECATED(0b001 ) = 1, + B0001 DEPRECATED(0b0001 ) = 1, + B00001 DEPRECATED(0b00001 ) = 1, + B000001 DEPRECATED(0b000001 ) = 1, + B0000001 DEPRECATED(0b0000001 ) = 1, + B00000001 DEPRECATED(0b00000001) = 1, + B10 DEPRECATED(0b10 ) = 2, + B010 DEPRECATED(0b010 ) = 2, + B0010 DEPRECATED(0b0010 ) = 2, + B00010 DEPRECATED(0b00010 ) = 2, + B000010 DEPRECATED(0b000010 ) = 2, + B0000010 DEPRECATED(0b0000010 ) = 2, + B00000010 DEPRECATED(0b00000010) = 2, + B11 DEPRECATED(0b11 ) = 3, + B011 DEPRECATED(0b011 ) = 3, + B0011 DEPRECATED(0b0011 ) = 3, + B00011 DEPRECATED(0b00011 ) = 3, + B000011 DEPRECATED(0b000011 ) = 3, + B0000011 DEPRECATED(0b0000011 ) = 3, + B00000011 DEPRECATED(0b00000011) = 3, + B100 DEPRECATED(0b100 ) = 4, + B0100 DEPRECATED(0b0100 ) = 4, + B00100 DEPRECATED(0b00100 ) = 4, + B000100 DEPRECATED(0b000100 ) = 4, + B0000100 DEPRECATED(0b0000100 ) = 4, + B00000100 DEPRECATED(0b00000100) = 4, + B101 DEPRECATED(0b101 ) = 5, + B0101 DEPRECATED(0b0101 ) = 5, + B00101 DEPRECATED(0b00101 ) = 5, + B000101 DEPRECATED(0b000101 ) = 5, + B0000101 DEPRECATED(0b0000101 ) = 5, + B00000101 DEPRECATED(0b00000101) = 5, + B110 DEPRECATED(0b110 ) = 6, + B0110 DEPRECATED(0b0110 ) = 6, + B00110 DEPRECATED(0b00110 ) = 6, + B000110 DEPRECATED(0b000110 ) = 6, + B0000110 DEPRECATED(0b0000110 ) = 6, + B00000110 DEPRECATED(0b00000110) = 6, + B111 DEPRECATED(0b111 ) = 7, + B0111 DEPRECATED(0b0111 ) = 7, + B00111 DEPRECATED(0b00111 ) = 7, + B000111 DEPRECATED(0b000111 ) = 7, + B0000111 DEPRECATED(0b0000111 ) = 7, + B00000111 DEPRECATED(0b00000111) = 7, + B1000 DEPRECATED(0b1000 ) = 8, + B01000 DEPRECATED(0b01000 ) = 8, + B001000 DEPRECATED(0b001000 ) = 8, + B0001000 DEPRECATED(0b0001000 ) = 8, + B00001000 DEPRECATED(0b00001000) = 8, + B1001 DEPRECATED(0b1001 ) = 9, + B01001 DEPRECATED(0b01001 ) = 9, + B001001 DEPRECATED(0b001001 ) = 9, + B0001001 DEPRECATED(0b0001001 ) = 9, + B00001001 DEPRECATED(0b00001001) = 9, + B1010 DEPRECATED(0b1010 ) = 10, + B01010 DEPRECATED(0b01010 ) = 10, + B001010 DEPRECATED(0b001010 ) = 10, + B0001010 DEPRECATED(0b0001010 ) = 10, + B00001010 DEPRECATED(0b00001010) = 10, + B1011 DEPRECATED(0b1011 ) = 11, + B01011 DEPRECATED(0b01011 ) = 11, + B001011 DEPRECATED(0b001011 ) = 11, + B0001011 DEPRECATED(0b0001011 ) = 11, + B00001011 DEPRECATED(0b00001011) = 11, + B1100 DEPRECATED(0b1100 ) = 12, + B01100 DEPRECATED(0b01100 ) = 12, + B001100 DEPRECATED(0b001100 ) = 12, + B0001100 DEPRECATED(0b0001100 ) = 12, + B00001100 DEPRECATED(0b00001100) = 12, + B1101 DEPRECATED(0b1101 ) = 13, + B01101 DEPRECATED(0b01101 ) = 13, + B001101 DEPRECATED(0b001101 ) = 13, + B0001101 DEPRECATED(0b0001101 ) = 13, + B00001101 DEPRECATED(0b00001101) = 13, + B1110 DEPRECATED(0b1110 ) = 14, + B01110 DEPRECATED(0b01110 ) = 14, + B001110 DEPRECATED(0b001110 ) = 14, + B0001110 DEPRECATED(0b0001110 ) = 14, + B00001110 DEPRECATED(0b00001110) = 14, + B1111 DEPRECATED(0b1111 ) = 15, + B01111 DEPRECATED(0b01111 ) = 15, + B001111 DEPRECATED(0b001111 ) = 15, + B0001111 DEPRECATED(0b0001111 ) = 15, + B00001111 DEPRECATED(0b00001111) = 15, + B10000 DEPRECATED(0b10000 ) = 16, + B010000 DEPRECATED(0b010000 ) = 16, + B0010000 DEPRECATED(0b0010000 ) = 16, + B00010000 DEPRECATED(0b00010000) = 16, + B10001 DEPRECATED(0b10001 ) = 17, + B010001 DEPRECATED(0b010001 ) = 17, + B0010001 DEPRECATED(0b0010001 ) = 17, + B00010001 DEPRECATED(0b00010001) = 17, + B10010 DEPRECATED(0b10010 ) = 18, + B010010 DEPRECATED(0b010010 ) = 18, + B0010010 DEPRECATED(0b0010010 ) = 18, + B00010010 DEPRECATED(0b00010010) = 18, + B10011 DEPRECATED(0b10011 ) = 19, + B010011 DEPRECATED(0b010011 ) = 19, + B0010011 DEPRECATED(0b0010011 ) = 19, + B00010011 DEPRECATED(0b00010011) = 19, + B10100 DEPRECATED(0b10100 ) = 20, + B010100 DEPRECATED(0b010100 ) = 20, + B0010100 DEPRECATED(0b0010100 ) = 20, + B00010100 DEPRECATED(0b00010100) = 20, + B10101 DEPRECATED(0b10101 ) = 21, + B010101 DEPRECATED(0b010101 ) = 21, + B0010101 DEPRECATED(0b0010101 ) = 21, + B00010101 DEPRECATED(0b00010101) = 21, + B10110 DEPRECATED(0b10110 ) = 22, + B010110 DEPRECATED(0b010110 ) = 22, + B0010110 DEPRECATED(0b0010110 ) = 22, + B00010110 DEPRECATED(0b00010110) = 22, + B10111 DEPRECATED(0b10111 ) = 23, + B010111 DEPRECATED(0b010111 ) = 23, + B0010111 DEPRECATED(0b0010111 ) = 23, + B00010111 DEPRECATED(0b00010111) = 23, + B11000 DEPRECATED(0b11000 ) = 24, + B011000 DEPRECATED(0b011000 ) = 24, + B0011000 DEPRECATED(0b0011000 ) = 24, + B00011000 DEPRECATED(0b00011000) = 24, + B11001 DEPRECATED(0b11001 ) = 25, + B011001 DEPRECATED(0b011001 ) = 25, + B0011001 DEPRECATED(0b0011001 ) = 25, + B00011001 DEPRECATED(0b00011001) = 25, + B11010 DEPRECATED(0b11010 ) = 26, + B011010 DEPRECATED(0b011010 ) = 26, + B0011010 DEPRECATED(0b0011010 ) = 26, + B00011010 DEPRECATED(0b00011010) = 26, + B11011 DEPRECATED(0b11011 ) = 27, + B011011 DEPRECATED(0b011011 ) = 27, + B0011011 DEPRECATED(0b0011011 ) = 27, + B00011011 DEPRECATED(0b00011011) = 27, + B11100 DEPRECATED(0b11100 ) = 28, + B011100 DEPRECATED(0b011100 ) = 28, + B0011100 DEPRECATED(0b0011100 ) = 28, + B00011100 DEPRECATED(0b00011100) = 28, + B11101 DEPRECATED(0b11101 ) = 29, + B011101 DEPRECATED(0b011101 ) = 29, + B0011101 DEPRECATED(0b0011101 ) = 29, + B00011101 DEPRECATED(0b00011101) = 29, + B11110 DEPRECATED(0b11110 ) = 30, + B011110 DEPRECATED(0b011110 ) = 30, + B0011110 DEPRECATED(0b0011110 ) = 30, + B00011110 DEPRECATED(0b00011110) = 30, + B11111 DEPRECATED(0b11111 ) = 31, + B011111 DEPRECATED(0b011111 ) = 31, + B0011111 DEPRECATED(0b0011111 ) = 31, + B00011111 DEPRECATED(0b00011111) = 31, + B100000 DEPRECATED(0b100000 ) = 32, + B0100000 DEPRECATED(0b0100000 ) = 32, + B00100000 DEPRECATED(0b00100000) = 32, + B100001 DEPRECATED(0b100001 ) = 33, + B0100001 DEPRECATED(0b0100001 ) = 33, + B00100001 DEPRECATED(0b00100001) = 33, + B100010 DEPRECATED(0b100010 ) = 34, + B0100010 DEPRECATED(0b0100010 ) = 34, + B00100010 DEPRECATED(0b00100010) = 34, + B100011 DEPRECATED(0b100011 ) = 35, + B0100011 DEPRECATED(0b0100011 ) = 35, + B00100011 DEPRECATED(0b00100011) = 35, + B100100 DEPRECATED(0b100100 ) = 36, + B0100100 DEPRECATED(0b0100100 ) = 36, + B00100100 DEPRECATED(0b00100100) = 36, + B100101 DEPRECATED(0b100101 ) = 37, + B0100101 DEPRECATED(0b0100101 ) = 37, + B00100101 DEPRECATED(0b00100101) = 37, + B100110 DEPRECATED(0b100110 ) = 38, + B0100110 DEPRECATED(0b0100110 ) = 38, + B00100110 DEPRECATED(0b00100110) = 38, + B100111 DEPRECATED(0b100111 ) = 39, + B0100111 DEPRECATED(0b0100111 ) = 39, + B00100111 DEPRECATED(0b00100111) = 39, + B101000 DEPRECATED(0b101000 ) = 40, + B0101000 DEPRECATED(0b0101000 ) = 40, + B00101000 DEPRECATED(0b00101000) = 40, + B101001 DEPRECATED(0b101001 ) = 41, + B0101001 DEPRECATED(0b0101001 ) = 41, + B00101001 DEPRECATED(0b00101001) = 41, + B101010 DEPRECATED(0b101010 ) = 42, + B0101010 DEPRECATED(0b0101010 ) = 42, + B00101010 DEPRECATED(0b00101010) = 42, + B101011 DEPRECATED(0b101011 ) = 43, + B0101011 DEPRECATED(0b0101011 ) = 43, + B00101011 DEPRECATED(0b00101011) = 43, + B101100 DEPRECATED(0b101100 ) = 44, + B0101100 DEPRECATED(0b0101100 ) = 44, + B00101100 DEPRECATED(0b00101100) = 44, + B101101 DEPRECATED(0b101101 ) = 45, + B0101101 DEPRECATED(0b0101101 ) = 45, + B00101101 DEPRECATED(0b00101101) = 45, + B101110 DEPRECATED(0b101110 ) = 46, + B0101110 DEPRECATED(0b0101110 ) = 46, + B00101110 DEPRECATED(0b00101110) = 46, + B101111 DEPRECATED(0b101111 ) = 47, + B0101111 DEPRECATED(0b0101111 ) = 47, + B00101111 DEPRECATED(0b00101111) = 47, + B110000 DEPRECATED(0b110000 ) = 48, + B0110000 DEPRECATED(0b0110000 ) = 48, + B00110000 DEPRECATED(0b00110000) = 48, + B110001 DEPRECATED(0b110001 ) = 49, + B0110001 DEPRECATED(0b0110001 ) = 49, + B00110001 DEPRECATED(0b00110001) = 49, + B110010 DEPRECATED(0b110010 ) = 50, + B0110010 DEPRECATED(0b0110010 ) = 50, + B00110010 DEPRECATED(0b00110010) = 50, + B110011 DEPRECATED(0b110011 ) = 51, + B0110011 DEPRECATED(0b0110011 ) = 51, + B00110011 DEPRECATED(0b00110011) = 51, + B110100 DEPRECATED(0b110100 ) = 52, + B0110100 DEPRECATED(0b0110100 ) = 52, + B00110100 DEPRECATED(0b00110100) = 52, + B110101 DEPRECATED(0b110101 ) = 53, + B0110101 DEPRECATED(0b0110101 ) = 53, + B00110101 DEPRECATED(0b00110101) = 53, + B110110 DEPRECATED(0b110110 ) = 54, + B0110110 DEPRECATED(0b0110110 ) = 54, + B00110110 DEPRECATED(0b00110110) = 54, + B110111 DEPRECATED(0b110111 ) = 55, + B0110111 DEPRECATED(0b0110111 ) = 55, + B00110111 DEPRECATED(0b00110111) = 55, + B111000 DEPRECATED(0b111000 ) = 56, + B0111000 DEPRECATED(0b0111000 ) = 56, + B00111000 DEPRECATED(0b00111000) = 56, + B111001 DEPRECATED(0b111001 ) = 57, + B0111001 DEPRECATED(0b0111001 ) = 57, + B00111001 DEPRECATED(0b00111001) = 57, + B111010 DEPRECATED(0b111010 ) = 58, + B0111010 DEPRECATED(0b0111010 ) = 58, + B00111010 DEPRECATED(0b00111010) = 58, + B111011 DEPRECATED(0b111011 ) = 59, + B0111011 DEPRECATED(0b0111011 ) = 59, + B00111011 DEPRECATED(0b00111011) = 59, + B111100 DEPRECATED(0b111100 ) = 60, + B0111100 DEPRECATED(0b0111100 ) = 60, + B00111100 DEPRECATED(0b00111100) = 60, + B111101 DEPRECATED(0b111101 ) = 61, + B0111101 DEPRECATED(0b0111101 ) = 61, + B00111101 DEPRECATED(0b00111101) = 61, + B111110 DEPRECATED(0b111110 ) = 62, + B0111110 DEPRECATED(0b0111110 ) = 62, + B00111110 DEPRECATED(0b00111110) = 62, + B111111 DEPRECATED(0b111111 ) = 63, + B0111111 DEPRECATED(0b0111111 ) = 63, + B00111111 DEPRECATED(0b00111111) = 63, + B1000000 DEPRECATED(0b1000000 ) = 64, + B01000000 DEPRECATED(0b01000000) = 64, + B1000001 DEPRECATED(0b1000001 ) = 65, + B01000001 DEPRECATED(0b01000001) = 65, + B1000010 DEPRECATED(0b1000010 ) = 66, + B01000010 DEPRECATED(0b01000010) = 66, + B1000011 DEPRECATED(0b1000011 ) = 67, + B01000011 DEPRECATED(0b01000011) = 67, + B1000100 DEPRECATED(0b1000100 ) = 68, + B01000100 DEPRECATED(0b01000100) = 68, + B1000101 DEPRECATED(0b1000101 ) = 69, + B01000101 DEPRECATED(0b01000101) = 69, + B1000110 DEPRECATED(0b1000110 ) = 70, + B01000110 DEPRECATED(0b01000110) = 70, + B1000111 DEPRECATED(0b1000111 ) = 71, + B01000111 DEPRECATED(0b01000111) = 71, + B1001000 DEPRECATED(0b1001000 ) = 72, + B01001000 DEPRECATED(0b01001000) = 72, + B1001001 DEPRECATED(0b1001001 ) = 73, + B01001001 DEPRECATED(0b01001001) = 73, + B1001010 DEPRECATED(0b1001010 ) = 74, + B01001010 DEPRECATED(0b01001010) = 74, + B1001011 DEPRECATED(0b1001011 ) = 75, + B01001011 DEPRECATED(0b01001011) = 75, + B1001100 DEPRECATED(0b1001100 ) = 76, + B01001100 DEPRECATED(0b01001100) = 76, + B1001101 DEPRECATED(0b1001101 ) = 77, + B01001101 DEPRECATED(0b01001101) = 77, + B1001110 DEPRECATED(0b1001110 ) = 78, + B01001110 DEPRECATED(0b01001110) = 78, + B1001111 DEPRECATED(0b1001111 ) = 79, + B01001111 DEPRECATED(0b01001111) = 79, + B1010000 DEPRECATED(0b1010000 ) = 80, + B01010000 DEPRECATED(0b01010000) = 80, + B1010001 DEPRECATED(0b1010001 ) = 81, + B01010001 DEPRECATED(0b01010001) = 81, + B1010010 DEPRECATED(0b1010010 ) = 82, + B01010010 DEPRECATED(0b01010010) = 82, + B1010011 DEPRECATED(0b1010011 ) = 83, + B01010011 DEPRECATED(0b01010011) = 83, + B1010100 DEPRECATED(0b1010100 ) = 84, + B01010100 DEPRECATED(0b01010100) = 84, + B1010101 DEPRECATED(0b1010101 ) = 85, + B01010101 DEPRECATED(0b01010101) = 85, + B1010110 DEPRECATED(0b1010110 ) = 86, + B01010110 DEPRECATED(0b01010110) = 86, + B1010111 DEPRECATED(0b1010111 ) = 87, + B01010111 DEPRECATED(0b01010111) = 87, + B1011000 DEPRECATED(0b1011000 ) = 88, + B01011000 DEPRECATED(0b01011000) = 88, + B1011001 DEPRECATED(0b1011001 ) = 89, + B01011001 DEPRECATED(0b01011001) = 89, + B1011010 DEPRECATED(0b1011010 ) = 90, + B01011010 DEPRECATED(0b01011010) = 90, + B1011011 DEPRECATED(0b1011011 ) = 91, + B01011011 DEPRECATED(0b01011011) = 91, + B1011100 DEPRECATED(0b1011100 ) = 92, + B01011100 DEPRECATED(0b01011100) = 92, + B1011101 DEPRECATED(0b1011101 ) = 93, + B01011101 DEPRECATED(0b01011101) = 93, + B1011110 DEPRECATED(0b1011110 ) = 94, + B01011110 DEPRECATED(0b01011110) = 94, + B1011111 DEPRECATED(0b1011111 ) = 95, + B01011111 DEPRECATED(0b01011111) = 95, + B1100000 DEPRECATED(0b1100000 ) = 96, + B01100000 DEPRECATED(0b01100000) = 96, + B1100001 DEPRECATED(0b1100001 ) = 97, + B01100001 DEPRECATED(0b01100001) = 97, + B1100010 DEPRECATED(0b1100010 ) = 98, + B01100010 DEPRECATED(0b01100010) = 98, + B1100011 DEPRECATED(0b1100011 ) = 99, + B01100011 DEPRECATED(0b01100011) = 99, + B1100100 DEPRECATED(0b1100100 ) = 100, + B01100100 DEPRECATED(0b01100100) = 100, + B1100101 DEPRECATED(0b1100101 ) = 101, + B01100101 DEPRECATED(0b01100101) = 101, + B1100110 DEPRECATED(0b1100110 ) = 102, + B01100110 DEPRECATED(0b01100110) = 102, + B1100111 DEPRECATED(0b1100111 ) = 103, + B01100111 DEPRECATED(0b01100111) = 103, + B1101000 DEPRECATED(0b1101000 ) = 104, + B01101000 DEPRECATED(0b01101000) = 104, + B1101001 DEPRECATED(0b1101001 ) = 105, + B01101001 DEPRECATED(0b01101001) = 105, + B1101010 DEPRECATED(0b1101010 ) = 106, + B01101010 DEPRECATED(0b01101010) = 106, + B1101011 DEPRECATED(0b1101011 ) = 107, + B01101011 DEPRECATED(0b01101011) = 107, + B1101100 DEPRECATED(0b1101100 ) = 108, + B01101100 DEPRECATED(0b01101100) = 108, + B1101101 DEPRECATED(0b1101101 ) = 109, + B01101101 DEPRECATED(0b01101101) = 109, + B1101110 DEPRECATED(0b1101110 ) = 110, + B01101110 DEPRECATED(0b01101110) = 110, + B1101111 DEPRECATED(0b1101111 ) = 111, + B01101111 DEPRECATED(0b01101111) = 111, + B1110000 DEPRECATED(0b1110000 ) = 112, + B01110000 DEPRECATED(0b01110000) = 112, + B1110001 DEPRECATED(0b1110001 ) = 113, + B01110001 DEPRECATED(0b01110001) = 113, + B1110010 DEPRECATED(0b1110010 ) = 114, + B01110010 DEPRECATED(0b01110010) = 114, + B1110011 DEPRECATED(0b1110011 ) = 115, + B01110011 DEPRECATED(0b01110011) = 115, + B1110100 DEPRECATED(0b1110100 ) = 116, + B01110100 DEPRECATED(0b01110100) = 116, + B1110101 DEPRECATED(0b1110101 ) = 117, + B01110101 DEPRECATED(0b01110101) = 117, + B1110110 DEPRECATED(0b1110110 ) = 118, + B01110110 DEPRECATED(0b01110110) = 118, + B1110111 DEPRECATED(0b1110111 ) = 119, + B01110111 DEPRECATED(0b01110111) = 119, + B1111000 DEPRECATED(0b1111000 ) = 120, + B01111000 DEPRECATED(0b01111000) = 120, + B1111001 DEPRECATED(0b1111001 ) = 121, + B01111001 DEPRECATED(0b01111001) = 121, + B1111010 DEPRECATED(0b1111010 ) = 122, + B01111010 DEPRECATED(0b01111010) = 122, + B1111011 DEPRECATED(0b1111011 ) = 123, + B01111011 DEPRECATED(0b01111011) = 123, + B1111100 DEPRECATED(0b1111100 ) = 124, + B01111100 DEPRECATED(0b01111100) = 124, + B1111101 DEPRECATED(0b1111101 ) = 125, + B01111101 DEPRECATED(0b01111101) = 125, + B1111110 DEPRECATED(0b1111110 ) = 126, + B01111110 DEPRECATED(0b01111110) = 126, + B1111111 DEPRECATED(0b1111111 ) = 127, + B01111111 DEPRECATED(0b01111111) = 127, + B10000000 DEPRECATED(0b10000000) = 128, + B10000001 DEPRECATED(0b10000001) = 129, + B10000010 DEPRECATED(0b10000010) = 130, + B10000011 DEPRECATED(0b10000011) = 131, + B10000100 DEPRECATED(0b10000100) = 132, + B10000101 DEPRECATED(0b10000101) = 133, + B10000110 DEPRECATED(0b10000110) = 134, + B10000111 DEPRECATED(0b10000111) = 135, + B10001000 DEPRECATED(0b10001000) = 136, + B10001001 DEPRECATED(0b10001001) = 137, + B10001010 DEPRECATED(0b10001010) = 138, + B10001011 DEPRECATED(0b10001011) = 139, + B10001100 DEPRECATED(0b10001100) = 140, + B10001101 DEPRECATED(0b10001101) = 141, + B10001110 DEPRECATED(0b10001110) = 142, + B10001111 DEPRECATED(0b10001111) = 143, + B10010000 DEPRECATED(0b10010000) = 144, + B10010001 DEPRECATED(0b10010001) = 145, + B10010010 DEPRECATED(0b10010010) = 146, + B10010011 DEPRECATED(0b10010011) = 147, + B10010100 DEPRECATED(0b10010100) = 148, + B10010101 DEPRECATED(0b10010101) = 149, + B10010110 DEPRECATED(0b10010110) = 150, + B10010111 DEPRECATED(0b10010111) = 151, + B10011000 DEPRECATED(0b10011000) = 152, + B10011001 DEPRECATED(0b10011001) = 153, + B10011010 DEPRECATED(0b10011010) = 154, + B10011011 DEPRECATED(0b10011011) = 155, + B10011100 DEPRECATED(0b10011100) = 156, + B10011101 DEPRECATED(0b10011101) = 157, + B10011110 DEPRECATED(0b10011110) = 158, + B10011111 DEPRECATED(0b10011111) = 159, + B10100000 DEPRECATED(0b10100000) = 160, + B10100001 DEPRECATED(0b10100001) = 161, + B10100010 DEPRECATED(0b10100010) = 162, + B10100011 DEPRECATED(0b10100011) = 163, + B10100100 DEPRECATED(0b10100100) = 164, + B10100101 DEPRECATED(0b10100101) = 165, + B10100110 DEPRECATED(0b10100110) = 166, + B10100111 DEPRECATED(0b10100111) = 167, + B10101000 DEPRECATED(0b10101000) = 168, + B10101001 DEPRECATED(0b10101001) = 169, + B10101010 DEPRECATED(0b10101010) = 170, + B10101011 DEPRECATED(0b10101011) = 171, + B10101100 DEPRECATED(0b10101100) = 172, + B10101101 DEPRECATED(0b10101101) = 173, + B10101110 DEPRECATED(0b10101110) = 174, + B10101111 DEPRECATED(0b10101111) = 175, + B10110000 DEPRECATED(0b10110000) = 176, + B10110001 DEPRECATED(0b10110001) = 177, + B10110010 DEPRECATED(0b10110010) = 178, + B10110011 DEPRECATED(0b10110011) = 179, + B10110100 DEPRECATED(0b10110100) = 180, + B10110101 DEPRECATED(0b10110101) = 181, + B10110110 DEPRECATED(0b10110110) = 182, + B10110111 DEPRECATED(0b10110111) = 183, + B10111000 DEPRECATED(0b10111000) = 184, + B10111001 DEPRECATED(0b10111001) = 185, + B10111010 DEPRECATED(0b10111010) = 186, + B10111011 DEPRECATED(0b10111011) = 187, + B10111100 DEPRECATED(0b10111100) = 188, + B10111101 DEPRECATED(0b10111101) = 189, + B10111110 DEPRECATED(0b10111110) = 190, + B10111111 DEPRECATED(0b10111111) = 191, + B11000000 DEPRECATED(0b11000000) = 192, + B11000001 DEPRECATED(0b11000001) = 193, + B11000010 DEPRECATED(0b11000010) = 194, + B11000011 DEPRECATED(0b11000011) = 195, + B11000100 DEPRECATED(0b11000100) = 196, + B11000101 DEPRECATED(0b11000101) = 197, + B11000110 DEPRECATED(0b11000110) = 198, + B11000111 DEPRECATED(0b11000111) = 199, + B11001000 DEPRECATED(0b11001000) = 200, + B11001001 DEPRECATED(0b11001001) = 201, + B11001010 DEPRECATED(0b11001010) = 202, + B11001011 DEPRECATED(0b11001011) = 203, + B11001100 DEPRECATED(0b11001100) = 204, + B11001101 DEPRECATED(0b11001101) = 205, + B11001110 DEPRECATED(0b11001110) = 206, + B11001111 DEPRECATED(0b11001111) = 207, + B11010000 DEPRECATED(0b11010000) = 208, + B11010001 DEPRECATED(0b11010001) = 209, + B11010010 DEPRECATED(0b11010010) = 210, + B11010011 DEPRECATED(0b11010011) = 211, + B11010100 DEPRECATED(0b11010100) = 212, + B11010101 DEPRECATED(0b11010101) = 213, + B11010110 DEPRECATED(0b11010110) = 214, + B11010111 DEPRECATED(0b11010111) = 215, + B11011000 DEPRECATED(0b11011000) = 216, + B11011001 DEPRECATED(0b11011001) = 217, + B11011010 DEPRECATED(0b11011010) = 218, + B11011011 DEPRECATED(0b11011011) = 219, + B11011100 DEPRECATED(0b11011100) = 220, + B11011101 DEPRECATED(0b11011101) = 221, + B11011110 DEPRECATED(0b11011110) = 222, + B11011111 DEPRECATED(0b11011111) = 223, + B11100000 DEPRECATED(0b11100000) = 224, + B11100001 DEPRECATED(0b11100001) = 225, + B11100010 DEPRECATED(0b11100010) = 226, + B11100011 DEPRECATED(0b11100011) = 227, + B11100100 DEPRECATED(0b11100100) = 228, + B11100101 DEPRECATED(0b11100101) = 229, + B11100110 DEPRECATED(0b11100110) = 230, + B11100111 DEPRECATED(0b11100111) = 231, + B11101000 DEPRECATED(0b11101000) = 232, + B11101001 DEPRECATED(0b11101001) = 233, + B11101010 DEPRECATED(0b11101010) = 234, + B11101011 DEPRECATED(0b11101011) = 235, + B11101100 DEPRECATED(0b11101100) = 236, + B11101101 DEPRECATED(0b11101101) = 237, + B11101110 DEPRECATED(0b11101110) = 238, + B11101111 DEPRECATED(0b11101111) = 239, + B11110000 DEPRECATED(0b11110000) = 240, + B11110001 DEPRECATED(0b11110001) = 241, + B11110010 DEPRECATED(0b11110010) = 242, + B11110011 DEPRECATED(0b11110011) = 243, + B11110100 DEPRECATED(0b11110100) = 244, + B11110101 DEPRECATED(0b11110101) = 245, + B11110110 DEPRECATED(0b11110110) = 246, + B11110111 DEPRECATED(0b11110111) = 247, + B11111000 DEPRECATED(0b11111000) = 248, + B11111001 DEPRECATED(0b11111001) = 249, + B11111010 DEPRECATED(0b11111010) = 250, + B11111011 DEPRECATED(0b11111011) = 251, + B11111100 DEPRECATED(0b11111100) = 252, + B11111101 DEPRECATED(0b11111101) = 253, + B11111110 DEPRECATED(0b11111110) = 254, + B11111111 DEPRECATED(0b11111111) = 255 +}; + +#undef DEPRECATED + +#endif diff --git a/cores/rl78g22/api/Client.h b/cores/rl78g22/api/Client.h new file mode 100644 index 0000000..5a1d99f --- /dev/null +++ b/cores/rl78g22/api/Client.h @@ -0,0 +1,46 @@ +/* + Client.h - Base class that provides Client + Copyright (c) 2011 Adrian McEwen. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include "Stream.h" +#include "IPAddress.h" + +namespace arduino { + +class Client : public Stream { + +public: + virtual int connect(IPAddress ip, uint16_t port) =0; + virtual int connect(const char *host, uint16_t port) =0; + virtual size_t write(uint8_t) =0; + virtual size_t write(const uint8_t *buf, size_t size) =0; + virtual int available() = 0; + virtual int read() = 0; + virtual int read(uint8_t *buf, size_t size) = 0; + virtual int peek() = 0; + virtual void flush() = 0; + virtual void stop() = 0; + virtual uint8_t connected() = 0; + virtual operator bool() = 0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +} \ No newline at end of file diff --git a/cores/rl78g22/api/Common.cpp b/cores/rl78g22/api/Common.cpp new file mode 100644 index 0000000..d1f822c --- /dev/null +++ b/cores/rl78g22/api/Common.cpp @@ -0,0 +1,10 @@ +#include "Common.h" + +/* C++ prototypes */ +long map(long x, long in_min, long in_max, long out_min, long out_max) +{ + return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; +} + +uint16_t makeWord(uint16_t w) { return w; } +uint16_t makeWord(uint8_t h, uint8_t l) { return (h << 8) | l; } \ No newline at end of file diff --git a/cores/rl78g22/api/Common.h b/cores/rl78g22/api/Common.h new file mode 100644 index 0000000..44fe95e --- /dev/null +++ b/cores/rl78g22/api/Common.h @@ -0,0 +1,171 @@ +#pragma once +#include +#include + +#ifdef __cplusplus +extern "C"{ +#endif + +void yield(void); + +typedef enum { + LOW = 0, + HIGH = 1, + CHANGE = 2, + FALLING = 3, + RISING = 4, +} PinStatus; + +typedef enum { + INPUT = 0x0, + OUTPUT = 0x1, + INPUT_PULLUP = 0x2, + INPUT_PULLDOWN = 0x3, + OUTPUT_OPENDRAIN = 0x4, +} PinMode; + +typedef enum { + LSBFIRST = 0, + MSBFIRST = 1, +} BitOrder; + +#define PI 3.1415926535897932384626433832795 +#define HALF_PI 1.5707963267948966192313216916398 +#define TWO_PI 6.283185307179586476925286766559 +#define DEG_TO_RAD 0.017453292519943295769236907684886 +#define RAD_TO_DEG 57.295779513082320876798154814105 +#define EULER 2.718281828459045235360287471352 + +#define SERIAL 0x0 +#define DISPLAY 0x1 + +#ifndef constrain +#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) +#endif + +#ifndef radians +#define radians(deg) ((deg)*DEG_TO_RAD) +#endif + +#ifndef degrees +#define degrees(rad) ((rad)*RAD_TO_DEG) +#endif + +#ifndef sq +#define sq(x) ((x)*(x)) +#endif + +typedef void (*voidFuncPtr)(void); +typedef void (*voidFuncPtrParam)(void*); + +// interrupts() / noInterrupts() must be defined by the core + +#define lowByte(w) ((uint8_t) ((w) & 0xff)) +#define highByte(w) ((uint8_t) ((w) >> 8)) + +#define bitRead(value, bit) (((value) >> (bit)) & 0x01) +#define bitSet(value, bit) ((value) |= (1UL << (bit))) +#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) +#define bitToggle(value, bit) ((value) ^= (1UL << (bit))) +#define bitWrite(value, bit, bitvalue) ((bitvalue) ? bitSet((value), (bit)) : bitClear((value), (bit))) + +#ifndef bit +#define bit(b) (1UL << (b)) +#endif + +/* TODO: request for removal */ +typedef bool boolean; +typedef uint8_t byte; +typedef uint16_t word; + +void init(void); +void initVariant(void); + +#ifndef HOST +int atexit(void (*func)()) __attribute__((weak)); +#endif +int main() __attribute__((weak)); + +#ifdef EXTENDED_PIN_MODE +// Platforms who want to declare more than 256 pins need to define EXTENDED_PIN_MODE globally +typedef uint32_t pin_size_t; +#else +typedef uint8_t pin_size_t; +#endif + +void pinMode(pin_size_t pinNumber, PinMode pinMode); +void digitalWrite(pin_size_t pinNumber, PinStatus status); +PinStatus digitalRead(pin_size_t pinNumber); +int analogRead(pin_size_t pinNumber); +void analogReference(uint8_t mode); +void analogWrite(pin_size_t pinNumber, int value); + +unsigned long millis(void); +unsigned long micros(void); +void delay(unsigned long); +void delayMicroseconds(unsigned int us); +unsigned long pulseIn(pin_size_t pin, uint8_t state, unsigned long timeout); +unsigned long pulseInLong(pin_size_t pin, uint8_t state, unsigned long timeout); + +void shiftOut(pin_size_t dataPin, pin_size_t clockPin, BitOrder bitOrder, uint8_t val); +uint8_t shiftIn(pin_size_t dataPin, pin_size_t clockPin, BitOrder bitOrder); + +void attachInterrupt(pin_size_t interruptNumber, voidFuncPtr callback, PinStatus mode); +void attachInterruptParam(pin_size_t interruptNumber, voidFuncPtrParam callback, PinStatus mode, void* param); +void detachInterrupt(pin_size_t interruptNumber); + +void setup(void); +void loop(void); + +#ifdef __cplusplus +} // extern "C" +#endif + +#ifdef __cplusplus + template + auto min(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (b < a) ? b : a; + } + + template + auto max(const T& a, const L& b) -> decltype((b < a) ? b : a) + { + return (a < b) ? b : a; + } +#else +#ifndef min +#define min(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a < _b ? _a : _b; }) +#endif +#ifndef max +#define max(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a > _b ? _a : _b; }) +#endif +#endif + +#ifdef __cplusplus + +/* C++ prototypes */ +uint16_t makeWord(uint16_t w); +uint16_t makeWord(byte h, byte l); + +#define word(...) makeWord(__VA_ARGS__) + +unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L); +unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L); + +void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0); +void noTone(uint8_t _pin); + +// WMath prototypes +long random(long); +long random(long, long); +void randomSeed(unsigned long); +long map(long, long, long, long, long); + +#endif // __cplusplus diff --git a/cores/rl78g22/api/Compat.h b/cores/rl78g22/api/Compat.h new file mode 100644 index 0000000..725ccd6 --- /dev/null +++ b/cores/rl78g22/api/Compat.h @@ -0,0 +1,16 @@ +#ifndef __COMPAT_H__ +#define __COMPAT_H__ + +namespace arduino { + +inline void pinMode(pin_size_t pinNumber, int mode) { + pinMode(pinNumber, (PinMode)mode); +}; + +inline void digitalWrite(pin_size_t pinNumber, int status) { + digitalWrite(pinNumber, (PinStatus)status); +}; + +} + +#endif \ No newline at end of file diff --git a/cores/rl78g22/api/HardwareI2C.h b/cores/rl78g22/api/HardwareI2C.h new file mode 100644 index 0000000..4a8e5f9 --- /dev/null +++ b/cores/rl78g22/api/HardwareI2C.h @@ -0,0 +1,47 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include "Stream.h" + +namespace arduino { + +class HardwareI2C : public Stream +{ + public: + virtual void begin() = 0; + virtual void begin(uint8_t address) = 0; + virtual void end() = 0; + + virtual void setClock(uint32_t freq) = 0; + + virtual void beginTransmission(uint8_t address) = 0; + virtual uint8_t endTransmission(bool stopBit) = 0; + virtual uint8_t endTransmission(void) = 0; + + virtual size_t requestFrom(uint8_t address, size_t len, bool stopBit) = 0; + virtual size_t requestFrom(uint8_t address, size_t len) = 0; + + virtual void onReceive(void(*)(int)) = 0; + virtual void onRequest(void(*)(void)) = 0; +}; + +} + diff --git a/cores/rl78g22/api/HardwareSPI.h b/cores/rl78g22/api/HardwareSPI.h new file mode 100644 index 0000000..8b8affd --- /dev/null +++ b/cores/rl78g22/api/HardwareSPI.h @@ -0,0 +1,130 @@ +/* + Copyright (c) 2018 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include "Common.h" +#include +#include "Stream.h" + +#define SPI_HAS_TRANSACTION + +namespace arduino { + +typedef enum { + SPI_MODE0 = 0, + SPI_MODE1 = 1, + SPI_MODE2 = 2, + SPI_MODE3 = 3, +} SPIMode; + + +class SPISettings { + public: + SPISettings(uint32_t clock, BitOrder bitOrder, SPIMode dataMode) { + if (__builtin_constant_p(clock)) { + init_AlwaysInline(clock, bitOrder, dataMode); + } else { + init_MightInline(clock, bitOrder, dataMode); + } + } + + SPISettings(uint32_t clock, BitOrder bitOrder, int dataMode) { + if (__builtin_constant_p(clock)) { + init_AlwaysInline(clock, bitOrder, (SPIMode)dataMode); + } else { + init_MightInline(clock, bitOrder, (SPIMode)dataMode); + } + } + + // Default speed set to 4MHz, SPI mode set to MODE 0 and Bit order set to MSB first. + SPISettings() { init_AlwaysInline(4000000, MSBFIRST, SPI_MODE0); } + + bool operator==(const SPISettings& rhs) const + { + if ((this->clockFreq == rhs.clockFreq) && + (this->bitOrder == rhs.bitOrder) && + (this->dataMode == rhs.dataMode)) { + return true; + } + return false; + } + + bool operator!=(const SPISettings& rhs) const + { + return !(*this == rhs); + } + + uint32_t getClockFreq() const { + return clockFreq; + } + SPIMode getDataMode() const { + return dataMode; + } + BitOrder getBitOrder() const { + return (bitOrder); + } + + private: + void init_MightInline(uint32_t clock, BitOrder bitOrder, SPIMode dataMode) { + init_AlwaysInline(clock, bitOrder, dataMode); + } + + // Core developer MUST use an helper function in beginTransaction() to use this data + void init_AlwaysInline(uint32_t clock, BitOrder bitOrder, SPIMode dataMode) __attribute__((__always_inline__)) { + this->clockFreq = clock; + this->dataMode = dataMode; + this->bitOrder = bitOrder; + } + + uint32_t clockFreq; + SPIMode dataMode; + BitOrder bitOrder; + + friend class HardwareSPI; +}; + +const SPISettings DEFAULT_SPI_SETTINGS = SPISettings(); + +class HardwareSPI +{ + public: + virtual ~HardwareSPI() { } + + virtual uint8_t transfer(uint8_t data) = 0; + virtual uint16_t transfer16(uint16_t data) = 0; + virtual void transfer(void *buf, size_t count) = 0; + + // Transaction Functions + virtual void usingInterrupt(int interruptNumber) = 0; + virtual void notUsingInterrupt(int interruptNumber) = 0; + virtual void beginTransaction(SPISettings settings) = 0; + virtual void endTransaction(void) = 0; + + // SPI Configuration methods + virtual void attachInterrupt() = 0; + virtual void detachInterrupt() = 0; + + virtual void begin() = 0; + virtual void end() = 0; +}; + +// Alias SPIClass to HardwareSPI since it's already the defacto standard for SPI class name +typedef HardwareSPI SPIClass; + +} diff --git a/cores/rl78g22/api/HardwareSerial.h b/cores/rl78g22/api/HardwareSerial.h new file mode 100644 index 0000000..e8f0657 --- /dev/null +++ b/cores/rl78g22/api/HardwareSerial.h @@ -0,0 +1,105 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include "Stream.h" + +namespace arduino { + +// XXX: Those constants should be defined as const int / enums? +// XXX: shall we use namespaces too? +#define SERIAL_PARITY_EVEN (0x1ul) +#define SERIAL_PARITY_ODD (0x2ul) +#define SERIAL_PARITY_NONE (0x3ul) +#define SERIAL_PARITY_MARK (0x4ul) +#define SERIAL_PARITY_SPACE (0x5ul) +#define SERIAL_PARITY_MASK (0xFul) + +#define SERIAL_STOP_BIT_1 (0x10ul) +#define SERIAL_STOP_BIT_1_5 (0x20ul) +#define SERIAL_STOP_BIT_2 (0x30ul) +#define SERIAL_STOP_BIT_MASK (0xF0ul) + +#define SERIAL_DATA_5 (0x100ul) +#define SERIAL_DATA_6 (0x200ul) +#define SERIAL_DATA_7 (0x300ul) +#define SERIAL_DATA_8 (0x400ul) +#define SERIAL_DATA_MASK (0xF00ul) + +#define SERIAL_5N1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_NONE | SERIAL_DATA_5) +#define SERIAL_6N1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_NONE | SERIAL_DATA_6) +#define SERIAL_7N1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_NONE | SERIAL_DATA_7) +#define SERIAL_8N1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_NONE | SERIAL_DATA_8) +#define SERIAL_5N2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_NONE | SERIAL_DATA_5) +#define SERIAL_6N2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_NONE | SERIAL_DATA_6) +#define SERIAL_7N2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_NONE | SERIAL_DATA_7) +#define SERIAL_8N2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_NONE | SERIAL_DATA_8) +#define SERIAL_5E1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_EVEN | SERIAL_DATA_5) +#define SERIAL_6E1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_EVEN | SERIAL_DATA_6) +#define SERIAL_7E1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_EVEN | SERIAL_DATA_7) +#define SERIAL_8E1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_EVEN | SERIAL_DATA_8) +#define SERIAL_5E2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_EVEN | SERIAL_DATA_5) +#define SERIAL_6E2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_EVEN | SERIAL_DATA_6) +#define SERIAL_7E2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_EVEN | SERIAL_DATA_7) +#define SERIAL_8E2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_EVEN | SERIAL_DATA_8) +#define SERIAL_5O1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_ODD | SERIAL_DATA_5) +#define SERIAL_6O1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_ODD | SERIAL_DATA_6) +#define SERIAL_7O1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_ODD | SERIAL_DATA_7) +#define SERIAL_8O1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_ODD | SERIAL_DATA_8) +#define SERIAL_5O2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_ODD | SERIAL_DATA_5) +#define SERIAL_6O2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_ODD | SERIAL_DATA_6) +#define SERIAL_7O2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_ODD | SERIAL_DATA_7) +#define SERIAL_8O2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_ODD | SERIAL_DATA_8) +#define SERIAL_5M1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_MARK | SERIAL_DATA_5) +#define SERIAL_6M1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_MARK | SERIAL_DATA_6) +#define SERIAL_7M1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_MARK | SERIAL_DATA_7) +#define SERIAL_8M1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_MARK | SERIAL_DATA_8) +#define SERIAL_5M2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_MARK | SERIAL_DATA_5) +#define SERIAL_6M2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_MARK | SERIAL_DATA_6) +#define SERIAL_7M2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_MARK | SERIAL_DATA_7) +#define SERIAL_8M2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_MARK | SERIAL_DATA_8) +#define SERIAL_5S1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_SPACE | SERIAL_DATA_5) +#define SERIAL_6S1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_SPACE | SERIAL_DATA_6) +#define SERIAL_7S1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_SPACE | SERIAL_DATA_7) +#define SERIAL_8S1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_SPACE | SERIAL_DATA_8) +#define SERIAL_5S2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_SPACE | SERIAL_DATA_5) +#define SERIAL_6S2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_SPACE | SERIAL_DATA_6) +#define SERIAL_7S2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_SPACE | SERIAL_DATA_7) +#define SERIAL_8S2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_SPACE | SERIAL_DATA_8) + +class HardwareSerial : public Stream +{ + public: + virtual void begin(unsigned long) = 0; + virtual void begin(unsigned long baudrate, uint16_t config) = 0; + virtual void end() = 0; + virtual int available(void) = 0; + virtual int peek(void) = 0; + virtual int read(void) = 0; + virtual void flush(void) = 0; + virtual size_t write(uint8_t) = 0; + using Print::write; // pull in write(str) and write(buf, size) from Print + virtual operator bool() = 0; +}; + +// XXX: Are we keeping the serialEvent API? +extern void serialEventRun(void) __attribute__((weak)); + +} \ No newline at end of file diff --git a/cores/rl78g22/api/IPAddress.cpp b/cores/rl78g22/api/IPAddress.cpp new file mode 100644 index 0000000..4b72931 --- /dev/null +++ b/cores/rl78g22/api/IPAddress.cpp @@ -0,0 +1,341 @@ +/* + IPAddress.cpp - Base class that provides IPAddress + Copyright (c) 2011 Adrian McEwen. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "IPAddress.h" +#include "Print.h" + +using namespace arduino; + +IPAddress::IPAddress() : IPAddress(IPv4) {} + +IPAddress::IPAddress(IPType ip_type) +{ + _type = ip_type; + memset(_address.bytes, 0, sizeof(_address.bytes)); +} + +IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet) +{ + _type = IPv4; + memset(_address.bytes, 0, sizeof(_address.bytes)); + _address.bytes[IPADDRESS_V4_BYTES_INDEX] = first_octet; + _address.bytes[IPADDRESS_V4_BYTES_INDEX + 1] = second_octet; + _address.bytes[IPADDRESS_V4_BYTES_INDEX + 2] = third_octet; + _address.bytes[IPADDRESS_V4_BYTES_INDEX + 3] = fourth_octet; +} + +IPAddress::IPAddress(uint8_t o1, uint8_t o2, uint8_t o3, uint8_t o4, uint8_t o5, uint8_t o6, uint8_t o7, uint8_t o8, uint8_t o9, uint8_t o10, uint8_t o11, uint8_t o12, uint8_t o13, uint8_t o14, uint8_t o15, uint8_t o16) { + _type = IPv6; + _address.bytes[0] = o1; + _address.bytes[1] = o2; + _address.bytes[2] = o3; + _address.bytes[3] = o4; + _address.bytes[4] = o5; + _address.bytes[5] = o6; + _address.bytes[6] = o7; + _address.bytes[7] = o8; + _address.bytes[8] = o9; + _address.bytes[9] = o10; + _address.bytes[10] = o11; + _address.bytes[11] = o12; + _address.bytes[12] = o13; + _address.bytes[13] = o14; + _address.bytes[14] = o15; + _address.bytes[15] = o16; +} + +IPAddress::IPAddress(uint32_t address) +{ + // IPv4 only + _type = IPv4; + memset(_address.bytes, 0, sizeof(_address.bytes)); + _address.dword[IPADDRESS_V4_DWORD_INDEX] = address; + + // NOTE on conversion/comparison and uint32_t: + // These conversions are host platform dependent. + // There is a defined integer representation of IPv4 addresses, + // based on network byte order (will be the value on big endian systems), + // e.g. http://2398766798 is the same as http://142.250.70.206, + // However on little endian systems the octets 0x83, 0xFA, 0x46, 0xCE, + // in that order, will form the integer (uint32_t) 3460758158 . +} + +IPAddress::IPAddress(const uint8_t *address) : IPAddress(IPv4, address) {} + +IPAddress::IPAddress(IPType ip_type, const uint8_t *address) +{ + _type = ip_type; + if (ip_type == IPv4) { + memset(_address.bytes, 0, sizeof(_address.bytes)); + memcpy(&_address.bytes[IPADDRESS_V4_BYTES_INDEX], address, sizeof(uint32_t)); + } else { + memcpy(_address.bytes, address, sizeof(_address.bytes)); + } +} + +IPAddress::IPAddress(const char *address) +{ + fromString(address); +} + +bool IPAddress::fromString(const char *address) { + if (!fromString4(address)) { + return fromString6(address); + } + return true; +} + +bool IPAddress::fromString4(const char *address) +{ + // TODO: add support for "a", "a.b", "a.b.c" formats + + int16_t acc = -1; // Accumulator + uint8_t dots = 0; + + memset(_address.bytes, 0, sizeof(_address.bytes)); + while (*address) + { + char c = *address++; + if (c >= '0' && c <= '9') + { + acc = (acc < 0) ? (c - '0') : acc * 10 + (c - '0'); + if (acc > 255) { + // Value out of [0..255] range + return false; + } + } + else if (c == '.') + { + if (dots == 3) { + // Too many dots (there must be 3 dots) + return false; + } + if (acc < 0) { + /* No value between dots, e.g. '1..' */ + return false; + } + _address.bytes[IPADDRESS_V4_BYTES_INDEX + dots++] = acc; + acc = -1; + } + else + { + // Invalid char + return false; + } + } + + if (dots != 3) { + // Too few dots (there must be 3 dots) + return false; + } + if (acc < 0) { + /* No value between dots, e.g. '1..' */ + return false; + } + _address.bytes[IPADDRESS_V4_BYTES_INDEX + 3] = acc; + _type = IPv4; + return true; +} + +bool IPAddress::fromString6(const char *address) { + uint32_t acc = 0; // Accumulator + int colons = 0, double_colons = -1; + + while (*address) + { + char c = tolower(*address++); + if (isalnum(c) && c <= 'f') { + if (c >= 'a') + c -= 'a' - '0' - 10; + acc = acc * 16 + (c - '0'); + if (acc > 0xffff) + // Value out of range + return false; + } + else if (c == ':') { + if (*address == ':') { + if (double_colons >= 0) { + // :: allowed once + return false; + } + if (*address != '\0' && *(address + 1) == ':') { + // ::: not allowed + return false; + } + // remember location + double_colons = colons + !!acc; + address++; + } else if (*address == '\0') { + // can't end with a single colon + return false; + } + if (colons == 7) + // too many separators + return false; + _address.bytes[colons * 2] = acc >> 8; + _address.bytes[colons * 2 + 1] = acc & 0xff; + colons++; + acc = 0; + } + else + // Invalid char + return false; + } + + if (double_colons == -1 && colons != 7) { + // Too few separators + return false; + } + if (double_colons > -1 && colons > 6) { + // Too many segments (double colon must be at least one zero field) + return false; + } + _address.bytes[colons * 2] = acc >> 8; + _address.bytes[colons * 2 + 1] = acc & 0xff; + colons++; + + if (double_colons != -1) { + for (int i = colons * 2 - double_colons * 2 - 1; i >= 0; i--) + _address.bytes[16 - colons * 2 + double_colons * 2 + i] = _address.bytes[double_colons * 2 + i]; + for (int i = double_colons * 2; i < 16 - colons * 2 + double_colons * 2; i++) + _address.bytes[i] = 0; + } + + _type = IPv6; + return true; +} + +IPAddress& IPAddress::operator=(const uint8_t *address) +{ + // IPv4 only conversion from byte pointer + _type = IPv4; + memset(_address.bytes, 0, sizeof(_address.bytes)); + memcpy(&_address.bytes[IPADDRESS_V4_BYTES_INDEX], address, sizeof(uint32_t)); + return *this; +} + +IPAddress& IPAddress::operator=(const char *address) +{ + fromString(address); + return *this; +} + +IPAddress& IPAddress::operator=(uint32_t address) +{ + // IPv4 conversion + // See note on conversion/comparison and uint32_t + _type = IPv4; + memset(_address.bytes, 0, sizeof(_address.bytes)); + _address.dword[IPADDRESS_V4_DWORD_INDEX] = address; + return *this; +} + +bool IPAddress::operator==(const IPAddress& addr) const { + return (addr._type == _type) + && (memcmp(addr._address.bytes, _address.bytes, sizeof(_address.bytes)) == 0); +} + +bool IPAddress::operator==(const uint8_t* addr) const +{ + // IPv4 only comparison to byte pointer + // Can't support IPv6 as we know our type, but not the length of the pointer + return _type == IPv4 && memcmp(addr, &_address.bytes[IPADDRESS_V4_BYTES_INDEX], sizeof(uint32_t)) == 0; +} + +uint8_t IPAddress::operator[](int index) const { + if (_type == IPv4) { + return _address.bytes[IPADDRESS_V4_BYTES_INDEX + index]; + } + return _address.bytes[index]; +} + +uint8_t& IPAddress::operator[](int index) { + if (_type == IPv4) { + return _address.bytes[IPADDRESS_V4_BYTES_INDEX + index]; + } + return _address.bytes[index]; +} + +size_t IPAddress::printTo(Print& p) const +{ + size_t n = 0; + + if (_type == IPv6) { + // IPv6 IETF canonical format: compress left-most longest run of two or more zero fields, lower case + int8_t longest_start = -1; + int8_t longest_length = 1; + int8_t current_start = -1; + int8_t current_length = 0; + for (int8_t f = 0; f < 8; f++) { + if (_address.bytes[f * 2] == 0 && _address.bytes[f * 2 + 1] == 0) { + if (current_start == -1) { + current_start = f; + current_length = 1; + } else { + current_length++; + } + if (current_length > longest_length) { + longest_start = current_start; + longest_length = current_length; + } + } else { + current_start = -1; + } + } + for (int f = 0; f < 8; f++) { + if (f < longest_start || f >= longest_start + longest_length) { + uint8_t c1 = _address.bytes[f * 2] >> 4; + uint8_t c2 = _address.bytes[f * 2] & 0xf; + uint8_t c3 = _address.bytes[f * 2 + 1] >> 4; + uint8_t c4 = _address.bytes[f * 2 + 1] & 0xf; + if (c1 > 0) { + n += p.print((char)(c1 < 10 ? '0' + c1 : 'a' + c1 - 10)); + } + if (c1 > 0 || c2 > 0) { + n += p.print((char)(c2 < 10 ? '0' + c2 : 'a' + c2 - 10)); + } + if (c1 > 0 || c2 > 0 || c3 > 0) { + n += p.print((char)(c3 < 10 ? '0' + c3 : 'a' + c3 - 10)); + } + n += p.print((char)(c4 < 10 ? '0' + c4 : 'a' + c4 - 10)); + if (f < 7) { + n += p.print(':'); + } + } else if (f == longest_start) { + if (longest_start == 0) { + n += p.print(':'); + } + n += p.print(':'); + } + } + return n; + } + + // IPv4 + for (int i =0; i < 3; i++) + { + n += p.print(_address.bytes[IPADDRESS_V4_BYTES_INDEX + i], DEC); + n += p.print('.'); + } + n += p.print(_address.bytes[IPADDRESS_V4_BYTES_INDEX + 3], DEC); + return n; +} + +const IPAddress arduino::IN6ADDR_ANY(IPv6); +const IPAddress arduino::INADDR_NONE(0,0,0,0); diff --git a/cores/rl78g22/api/IPAddress.h b/cores/rl78g22/api/IPAddress.h new file mode 100644 index 0000000..964faa6 --- /dev/null +++ b/cores/rl78g22/api/IPAddress.h @@ -0,0 +1,119 @@ +/* + IPAddress.h - Base class that provides IPAddress + Copyright (c) 2011 Adrian McEwen. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include "Printable.h" +#include "String.h" + +#define IPADDRESS_V4_BYTES_INDEX 12 +#define IPADDRESS_V4_DWORD_INDEX 3 + +// forward declarations of global name space friend classes +class EthernetClass; +class DhcpClass; +class DNSClient; + +namespace arduino { + +// A class to make it easier to handle and pass around IP addresses + +enum IPType { + IPv4, + IPv6 +}; + +class IPAddress : public Printable { +private: + union { + uint8_t bytes[16]; + uint32_t dword[4]; + } _address; + IPType _type; + + // Access the raw byte array containing the address. Because this returns a pointer + // to the internal structure rather than a copy of the address this function should only + // be used when you know that the usage of the returned uint8_t* will be transient and not + // stored. + uint8_t* raw_address() { return _type == IPv4 ? &_address.bytes[IPADDRESS_V4_BYTES_INDEX] : _address.bytes; } + +public: + // Constructors + + // Default IPv4 + IPAddress(); + IPAddress(IPType ip_type); + IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet); + IPAddress(uint8_t o1, uint8_t o2, uint8_t o3, uint8_t o4, uint8_t o5, uint8_t o6, uint8_t o7, uint8_t o8, uint8_t o9, uint8_t o10, uint8_t o11, uint8_t o12, uint8_t o13, uint8_t o14, uint8_t o15, uint8_t o16); + // IPv4; see implementation note + IPAddress(uint32_t address); + // Default IPv4 + IPAddress(const uint8_t *address); + IPAddress(IPType ip_type, const uint8_t *address); + // If IPv4 fails tries IPv6 see fromString function + IPAddress(const char *address); + + bool fromString(const char *address); + bool fromString(const String &address) { return fromString(address.c_str()); } + + // Overloaded cast operator to allow IPAddress objects to be used where a uint32_t is expected + // NOTE: IPv4 only; see implementation note + operator uint32_t() const { return _type == IPv4 ? _address.dword[IPADDRESS_V4_DWORD_INDEX] : 0; }; + + bool operator==(const IPAddress& addr) const; + bool operator!=(const IPAddress& addr) const { return !(*this == addr); }; + + // NOTE: IPv4 only; we don't know the length of the pointer + bool operator==(const uint8_t* addr) const; + + // Overloaded index operator to allow getting and setting individual octets of the address + uint8_t operator[](int index) const; + uint8_t& operator[](int index); + + // Overloaded copy operators to allow initialisation of IPAddress objects from other types + // NOTE: IPv4 only + IPAddress& operator=(const uint8_t *address); + // NOTE: IPv4 only; see implementation note + IPAddress& operator=(uint32_t address); + // If IPv4 fails tries IPv6 see fromString function + IPAddress& operator=(const char *address); + + virtual size_t printTo(Print& p) const; + + IPType type() { return _type; } + + friend class UDP; + friend class Client; + friend class Server; + + friend ::EthernetClass; + friend ::DhcpClass; + friend ::DNSClient; + +protected: + bool fromString4(const char *address); + bool fromString6(const char *address); +}; + +extern const IPAddress IN6ADDR_ANY; +extern const IPAddress INADDR_NONE; +} + +using arduino::IPAddress; \ No newline at end of file diff --git a/cores/rl78g22/api/Interrupts.h b/cores/rl78g22/api/Interrupts.h new file mode 100644 index 0000000..e306fc7 --- /dev/null +++ b/cores/rl78g22/api/Interrupts.h @@ -0,0 +1,44 @@ +#ifndef W_INTERRUPTS_CPP +#define W_INTERRUPTS_CPP +#ifdef __cplusplus + +#include +#include +#include +#include "Common.h" + +namespace arduino { + +template +using voidTemplateFuncPtrParam = void (*)(T param); + +template struct __container__ { + void* param; + voidTemplateFuncPtrParam function; +}; + +// C++ only overloaded version of attachInterrupt function +template void attachInterrupt(pin_size_t interruptNum, voidTemplateFuncPtrParam userFunc, PinStatus mode, T& param) { + + struct __container__ *cont = new __container__(); + cont->param = ¶m; + cont->function = userFunc; + + // TODO: check lambda scope + // TODO: add structure to delete(__container__) when detachInterrupt() is called + auto f = [](void* a) -> void + { + T param = *(T*)((struct __container__*)a)->param; + (((struct __container__*)a)->function)(param); + }; + + attachInterruptParam(interruptNum, f, mode, cont); +} + +template void attachInterrupt(pin_size_t interruptNum, voidTemplateFuncPtrParam userFunc, PinStatus mode, T* param) { + attachInterruptParam(interruptNum, (voidFuncPtrParam)userFunc, mode, (void*)param); +} + +} +#endif +#endif diff --git a/cores/rl78g22/api/PluggableUSB.cpp b/cores/rl78g22/api/PluggableUSB.cpp new file mode 100644 index 0000000..ca19d65 --- /dev/null +++ b/cores/rl78g22/api/PluggableUSB.cpp @@ -0,0 +1,101 @@ +/* + PluggableUSB.cpp + Copyright (c) 2015 Arduino LLC + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "USBAPI.h" +#include "PluggableUSB.h" + +using namespace arduino; + +int PluggableUSB_::getInterface(uint8_t* interfaceCount) +{ + int sent = 0; + PluggableUSBModule* node; + for (node = rootNode; node; node = node->next) { + int res = node->getInterface(interfaceCount); + if (res < 0) + return -1; + sent += res; + } + return sent; +} + +int PluggableUSB_::getDescriptor(USBSetup& setup) +{ + PluggableUSBModule* node; + for (node = rootNode; node; node = node->next) { + int ret = node->getDescriptor(setup); + // ret!=0 -> request has been processed + if (ret) + return ret; + } + return 0; +} + +void PluggableUSB_::getShortName(char *iSerialNum) +{ + PluggableUSBModule* node; + for (node = rootNode; node; node = node->next) { + iSerialNum += node->getShortName(iSerialNum); + } + *iSerialNum = 0; +} + +bool PluggableUSB_::setup(USBSetup& setup) +{ + PluggableUSBModule* node; + for (node = rootNode; node; node = node->next) { + if (node->setup(setup)) { + return true; + } + } + return false; +} + +bool PluggableUSB_::plug(PluggableUSBModule *node) +{ + if ((lastEp + node->numEndpoints) > totalEP) { + return false; + } + + if (!rootNode) { + rootNode = node; + } else { + PluggableUSBModule *current = rootNode; + while (current->next) { + current = current->next; + } + current->next = node; + } + + node->pluggedInterface = lastIf; + node->pluggedEndpoint = lastEp; + lastIf += node->numInterfaces; + for (uint8_t i = 0; i < node->numEndpoints; i++) { + *(unsigned int*)(epBuffer(lastEp)) = node->endpointType[i]; + lastEp++; + } + return true; + // restart USB layer??? +} + +PluggableUSB_& PluggableUSB() +{ + static PluggableUSB_ obj; + return obj; +} \ No newline at end of file diff --git a/cores/rl78g22/api/PluggableUSB.h b/cores/rl78g22/api/PluggableUSB.h new file mode 100644 index 0000000..9018f6c --- /dev/null +++ b/cores/rl78g22/api/PluggableUSB.h @@ -0,0 +1,78 @@ +/* + PluggableUSB.h + Copyright (c) 2015 Arduino LLC + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef PUSB_h +#define PUSB_h + +#include "USBAPI.h" +#include +#include + +namespace arduino { + +class PluggableUSBModule { +public: + PluggableUSBModule(uint8_t numEps, uint8_t numIfs, unsigned int *epType) : + numEndpoints(numEps), numInterfaces(numIfs), endpointType(epType) + { } + +protected: + virtual bool setup(USBSetup& setup) = 0; + virtual int getInterface(uint8_t* interfaceCount) = 0; + virtual int getDescriptor(USBSetup& setup) = 0; + virtual uint8_t getShortName(char *name) { name[0] = 'A'+pluggedInterface; return 1; } + + uint8_t pluggedInterface; + uint8_t pluggedEndpoint; + + const uint8_t numEndpoints; + const uint8_t numInterfaces; + const unsigned int *endpointType; + + PluggableUSBModule *next = NULL; + + friend class PluggableUSB_; +}; + +class PluggableUSB_ { +public: + PluggableUSB_(); + bool plug(PluggableUSBModule *node); + int getInterface(uint8_t* interfaceCount); + int getDescriptor(USBSetup& setup); + bool setup(USBSetup& setup); + void getShortName(char *iSerialNum); + +private: + uint8_t lastIf; + uint8_t lastEp; + PluggableUSBModule* rootNode; + uint8_t totalEP; +}; +} + +// core need to define +void* epBuffer(unsigned int n); // -> returns a pointer to the Nth element of the EP buffer structure + +// Replacement for global singleton. +// This function prevents static-initialization-order-fiasco +// https://isocpp.org/wiki/faq/ctors#static-init-order-on-first-use +arduino::PluggableUSB_& PluggableUSB(); + +#endif \ No newline at end of file diff --git a/cores/rl78g22/api/Print.cpp b/cores/rl78g22/api/Print.cpp new file mode 100644 index 0000000..8c3e193 --- /dev/null +++ b/cores/rl78g22/api/Print.cpp @@ -0,0 +1,381 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include +#include +#include +#include + +#include "Print.h" + +using namespace arduino; + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + if (write(*buffer++)) n++; + else break; + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ +#if defined(__AVR__) + PGM_P p = reinterpret_cast(ifsh); + size_t n = 0; + while (1) { + unsigned char c = pgm_read_byte(p++); + if (c == 0) break; + if (write(c)) n++; + else break; + } + return n; +#else + return print(reinterpret_cast(ifsh)); +#endif +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + return write("\r\n"); +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + char c = n % base; + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + +size_t Print::printFloat(double number, int digits) +{ + if (digits < 0) + digits = 2; + + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} diff --git a/cores/rl78g22/api/Print.h b/cores/rl78g22/api/Print.h new file mode 100644 index 0000000..5a19fe7 --- /dev/null +++ b/cores/rl78g22/api/Print.h @@ -0,0 +1,96 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include +#include // for size_t + +#include "String.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +namespace arduino { + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); + size_t printFloat(double, int); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + // default to zero, meaning "a single write may block" + // should be overridden by subclasses with buffering + virtual int availableForWrite() { return 0; } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + + virtual void flush() { /* Empty implementation for backward compatibility */ } +}; + +} +using arduino::Print; \ No newline at end of file diff --git a/cores/rl78g22/api/Printable.h b/cores/rl78g22/api/Printable.h new file mode 100644 index 0000000..972866e --- /dev/null +++ b/cores/rl78g22/api/Printable.h @@ -0,0 +1,39 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include + +namespace arduino { + +class Print; + +/** The Printable class provides a way for new classes to allow themselves to be printed. + By deriving from Printable and implementing the printTo method, it will then be possible + for users to print out instances of this class by passing them into the usual + Print::print and Print::println methods. +*/ + +class Printable +{ + public: + virtual size_t printTo(Print& p) const = 0; +}; + +} \ No newline at end of file diff --git a/cores/rl78g22/api/RingBuffer.h b/cores/rl78g22/api/RingBuffer.h new file mode 100644 index 0000000..833350d --- /dev/null +++ b/cores/rl78g22/api/RingBuffer.h @@ -0,0 +1,141 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifdef __cplusplus + +#ifndef _RING_BUFFER_ +#define _RING_BUFFER_ + +#include +#include + +namespace arduino { + +// Define constants and variables for buffering incoming serial data. We're +// using a ring buffer (I think), in which head is the index of the location +// to which to write the next incoming character and tail is the index of the +// location from which to read. +#define SERIAL_BUFFER_SIZE 64 + +template +class RingBufferN +{ + public: + uint8_t _aucBuffer[N] ; + volatile int _iHead ; + volatile int _iTail ; + volatile int _numElems; + + public: + RingBufferN( void ) ; + void store_char( uint8_t c ) ; + void clear(); + int read_char(); + int available(); + int availableForStore(); + int peek(); + bool isFull(); + + private: + int nextIndex(int index); + inline bool isEmpty() const { return (_numElems == 0); } +}; + +typedef RingBufferN RingBuffer; + + +template +RingBufferN::RingBufferN( void ) +{ + memset( _aucBuffer, 0, N ) ; + clear(); +} + +template +void RingBufferN::store_char( uint8_t c ) +{ + // if we should be storing the received character into the location + // just before the tail (meaning that the head would advance to the + // current location of the tail), we're about to overflow the buffer + // and so we don't write the character or advance the head. + if (!isFull()) + { + _aucBuffer[_iHead] = c ; + _iHead = nextIndex(_iHead); + _numElems++; + } +} + +template +void RingBufferN::clear() +{ + _iHead = 0; + _iTail = 0; + _numElems = 0; +} + +template +int RingBufferN::read_char() +{ + if (isEmpty()) + return -1; + + uint8_t value = _aucBuffer[_iTail]; + _iTail = nextIndex(_iTail); + _numElems--; + + return value; +} + +template +int RingBufferN::available() +{ + return _numElems; +} + +template +int RingBufferN::availableForStore() +{ + return (N - _numElems); +} + +template +int RingBufferN::peek() +{ + if (isEmpty()) + return -1; + + return _aucBuffer[_iTail]; +} + +template +int RingBufferN::nextIndex(int index) +{ + return (uint32_t)(index + 1) % N; +} + +template +bool RingBufferN::isFull() +{ + return (_numElems == N); +} + +} + +#endif /* _RING_BUFFER_ */ +#endif /* __cplusplus */ \ No newline at end of file diff --git a/cores/rl78g22/api/Server.h b/cores/rl78g22/api/Server.h new file mode 100644 index 0000000..83d0cd3 --- /dev/null +++ b/cores/rl78g22/api/Server.h @@ -0,0 +1,31 @@ +/* + Server.h - Base class that provides Server + Copyright (c) 2011 Adrian McEwen. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include "Print.h" + +namespace arduino { + +class Server : public Print { + public: + virtual void begin() = 0; +}; + +} \ No newline at end of file diff --git a/cores/rl78g22/api/Stream.cpp b/cores/rl78g22/api/Stream.cpp new file mode 100644 index 0000000..f6f9bda --- /dev/null +++ b/cores/rl78g22/api/Stream.cpp @@ -0,0 +1,321 @@ +/* + Stream.cpp - adds parsing methods to Stream class + Copyright (c) 2008 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Created July 2011 + parsing functions based on TextFinder library by Michael Margolis + + findMulti/findUntil routines written by Jim Leonard/Xuth + */ + +#include "Common.h" +#include "Stream.h" + +#define PARSE_TIMEOUT 1000 // default number of milli-seconds to wait + +using namespace arduino; + +// private method to read stream with timeout +int Stream::timedRead() +{ + int c; + _startMillis = millis(); + do { + c = read(); + if (c >= 0) return c; + } while(millis() - _startMillis < _timeout); + return -1; // -1 indicates timeout +} + +// private method to peek stream with timeout +int Stream::timedPeek() +{ + int c; + _startMillis = millis(); + do { + c = peek(); + if (c >= 0) return c; + } while(millis() - _startMillis < _timeout); + return -1; // -1 indicates timeout +} + +// returns peek of the next digit in the stream or -1 if timeout +// discards non-numeric characters +int Stream::peekNextDigit(LookaheadMode lookahead, bool detectDecimal) +{ + int c; + while (1) { + c = timedPeek(); + + if( c < 0 || + c == '-' || + (c >= '0' && c <= '9') || + (detectDecimal && c == '.')) return c; + + switch( lookahead ){ + case SKIP_NONE: return -1; // Fail code. + case SKIP_WHITESPACE: + switch( c ){ + case ' ': + case '\t': + case '\r': + case '\n': break; + default: return -1; // Fail code. + } + case SKIP_ALL: + break; + } + read(); // discard non-numeric + } +} + +// Public Methods +////////////////////////////////////////////////////////////// + +void Stream::setTimeout(unsigned long timeout) // sets the maximum number of milliseconds to wait +{ + _timeout = timeout; +} + + // find returns true if the target string is found +bool Stream::find(const char *target) +{ + return findUntil(target, strlen(target), NULL, 0); +} + +// reads data from the stream until the target string of given length is found +// returns true if target string is found, false if timed out +bool Stream::find(const char *target, size_t length) +{ + return findUntil(target, length, NULL, 0); +} + +// as find but search ends if the terminator string is found +bool Stream::findUntil(const char *target, const char *terminator) +{ + return findUntil(target, strlen(target), terminator, strlen(terminator)); +} + +// reads data from the stream until the target string of the given length is found +// search terminated if the terminator string is found +// returns true if target string is found, false if terminated or timed out +bool Stream::findUntil(const char *target, size_t targetLen, const char *terminator, size_t termLen) +{ + if (terminator == NULL) { + MultiTarget t[1] = {{target, targetLen, 0}}; + return findMulti(t, 1) == 0; + } else { + MultiTarget t[2] = {{target, targetLen, 0}, {terminator, termLen, 0}}; + return findMulti(t, 2) == 0; + } +} + +// returns the first valid (long) integer value from the current position. +// lookahead determines how parseInt looks ahead in the stream. +// See LookaheadMode enumeration at the top of the file. +// Lookahead is terminated by the first character that is not a valid part of an integer. +// Once parsing commences, 'ignore' will be skipped in the stream. +long Stream::parseInt(LookaheadMode lookahead, char ignore) +{ + bool isNegative = false; + long value = 0; + int c; + + c = peekNextDigit(lookahead, false); + // ignore non numeric leading characters + if(c < 0) + return 0; // zero returned if timeout + + do{ + if((char)c == ignore) + ; // ignore this character + else if(c == '-') + isNegative = true; + else if(c >= '0' && c <= '9') // is c a digit? + value = value * 10 + c - '0'; + read(); // consume the character we got with peek + c = timedPeek(); + } + while( (c >= '0' && c <= '9') || (char)c == ignore ); + + if(isNegative) + value = -value; + return value; +} + +// as parseInt but returns a floating point value +float Stream::parseFloat(LookaheadMode lookahead, char ignore) +{ + bool isNegative = false; + bool isFraction = false; + double value = 0.0; + int c; + double fraction = 1.0; + + c = peekNextDigit(lookahead, true); + // ignore non numeric leading characters + if(c < 0) + return 0; // zero returned if timeout + + do{ + if((char)c == ignore) + ; // ignore + else if(c == '-') + isNegative = true; + else if (c == '.') + isFraction = true; + else if(c >= '0' && c <= '9') { // is c a digit? + if(isFraction) { + fraction *= 0.1; + value = value + fraction * (c - '0'); + } else { + value = value * 10 + c - '0'; + } + } + read(); // consume the character we got with peek + c = timedPeek(); + } + while( (c >= '0' && c <= '9') || (c == '.' && !isFraction) || (char)c == ignore ); + + if(isNegative) + value = -value; + + return value; +} + +// read characters from stream into buffer +// terminates if length characters have been read, or timeout (see setTimeout) +// returns the number of characters placed in the buffer +// the buffer is NOT null terminated. +// +size_t Stream::readBytes(char *buffer, size_t length) +{ + size_t count = 0; + while (count < length) { + int c = timedRead(); + if (c < 0) break; + *buffer++ = (char)c; + count++; + } + return count; +} + + +// as readBytes with terminator character +// terminates if length characters have been read, timeout, or if the terminator character detected +// returns the number of characters placed in the buffer (0 means no valid data found) + +size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length) +{ + size_t index = 0; + while (index < length) { + int c = timedRead(); + if (c < 0 || (char)c == terminator) break; + *buffer++ = (char)c; + index++; + } + return index; // return number of characters, not including null terminator +} + +String Stream::readString() +{ + String ret; + int c = timedRead(); + while (c >= 0) + { + ret += (char)c; + c = timedRead(); + } + return ret; +} + +String Stream::readStringUntil(char terminator) +{ + String ret; + int c = timedRead(); + while (c >= 0 && (char)c != terminator) + { + ret += (char)c; + c = timedRead(); + } + return ret; +} + +int Stream::findMulti( struct Stream::MultiTarget *targets, int tCount) { + // any zero length target string automatically matches and would make + // a mess of the rest of the algorithm. + for (struct MultiTarget *t = targets; t < targets+tCount; ++t) { + if (t->len <= 0) + return t - targets; + } + + while (1) { + int c = timedRead(); + if (c < 0) + return -1; + + for (struct MultiTarget *t = targets; t < targets+tCount; ++t) { + // the simple case is if we match, deal with that first. + if ((char)c == t->str[t->index]) { + if (++t->index == t->len) + return t - targets; + else + continue; + } + + // if not we need to walk back and see if we could have matched further + // down the stream (ie '1112' doesn't match the first position in '11112' + // but it will match the second position so we can't just reset the current + // index to 0 when we find a mismatch. + if (t->index == 0) + continue; + + int origIndex = t->index; + do { + --t->index; + // first check if current char works against the new current index + if ((char)c != t->str[t->index]) + continue; + + // if it's the only char then we're good, nothing more to check + if (t->index == 0) { + t->index++; + break; + } + + // otherwise we need to check the rest of the found string + int diff = origIndex - t->index; + size_t i; + for (i = 0; i < t->index; ++i) { + if (t->str[i] != t->str[i + diff]) + break; + } + + // if we successfully got through the previous loop then our current + // index is good. + if (i == t->index) { + t->index++; + break; + } + + // otherwise we just try the next index + } while (t->index); + } + } + // unreachable + return -1; +} diff --git a/cores/rl78g22/api/Stream.h b/cores/rl78g22/api/Stream.h new file mode 100644 index 0000000..e81c71b --- /dev/null +++ b/cores/rl78g22/api/Stream.h @@ -0,0 +1,133 @@ +/* + Stream.h - base class for character-based streams. + Copyright (c) 2010 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + parsing functions based on TextFinder library by Michael Margolis +*/ + +#pragma once + +#include +#include "Print.h" + +// compatibility macros for testing +/* +#define getInt() parseInt() +#define getInt(ignore) parseInt(ignore) +#define getFloat() parseFloat() +#define getFloat(ignore) parseFloat(ignore) +#define getString( pre_string, post_string, buffer, length) +readBytesBetween( pre_string, terminator, buffer, length) +*/ + +namespace arduino { + +// This enumeration provides the lookahead options for parseInt(), parseFloat() +// The rules set out here are used until either the first valid character is found +// or a time out occurs due to lack of input. +enum LookaheadMode{ + SKIP_ALL, // All invalid characters are ignored. + SKIP_NONE, // Nothing is skipped, and the stream is not touched unless the first waiting character is valid. + SKIP_WHITESPACE // Only tabs, spaces, line feeds & carriage returns are skipped. +}; + +#define NO_IGNORE_CHAR '\x01' // a char not found in a valid ASCII numeric field + +class Stream : public Print +{ + protected: + unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read + unsigned long _startMillis; // used for timeout measurement + int timedRead(); // private method to read stream with timeout + int timedPeek(); // private method to peek stream with timeout + int peekNextDigit(LookaheadMode lookahead, bool detectDecimal); // returns the next numeric digit in the stream or -1 if timeout + + public: + virtual int available() = 0; + virtual int read() = 0; + virtual int peek() = 0; + + Stream() {_timeout=1000;} + +// parsing methods + + void setTimeout(unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second + unsigned long getTimeout(void) { return _timeout; } + + bool find(const char *target); // reads data from the stream until the target string is found + bool find(const uint8_t *target) { return find ((const char *)target); } + // returns true if target string is found, false if timed out (see setTimeout) + + bool find(const char *target, size_t length); // reads data from the stream until the target string of given length is found + bool find(const uint8_t *target, size_t length) { return find ((const char *)target, length); } + // returns true if target string is found, false if timed out + + bool find(char target) { return find (&target, 1); } + + bool findUntil(const char *target, const char *terminator); // as find but search ends if the terminator string is found + bool findUntil(const uint8_t *target, const char *terminator) { return findUntil((const char *)target, terminator); } + + bool findUntil(const char *target, size_t targetLen, const char *terminate, size_t termLen); // as above but search ends if the terminate string is found + bool findUntil(const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen) {return findUntil((const char *)target, targetLen, terminate, termLen); } + + long parseInt(LookaheadMode lookahead = SKIP_ALL, char ignore = NO_IGNORE_CHAR); + // returns the first valid (long) integer value from the current position. + // lookahead determines how parseInt looks ahead in the stream. + // See LookaheadMode enumeration at the top of the file. + // Lookahead is terminated by the first character that is not a valid part of an integer. + // Once parsing commences, 'ignore' will be skipped in the stream. + + float parseFloat(LookaheadMode lookahead = SKIP_ALL, char ignore = NO_IGNORE_CHAR); + // float version of parseInt + + size_t readBytes( char *buffer, size_t length); // read chars from stream into buffer + size_t readBytes( uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); } + // terminates if length characters have been read or timeout (see setTimeout) + // returns the number of characters placed in the buffer (0 means no valid data found) + + size_t readBytesUntil( char terminator, char *buffer, size_t length); // as readBytes with terminator character + size_t readBytesUntil( char terminator, uint8_t *buffer, size_t length) { return readBytesUntil(terminator, (char *)buffer, length); } + // terminates if length characters have been read, timeout, or if the terminator character detected + // returns the number of characters placed in the buffer (0 means no valid data found) + + // Arduino String functions to be added here + String readString(); + String readStringUntil(char terminator); + + protected: + long parseInt(char ignore) { return parseInt(SKIP_ALL, ignore); } + float parseFloat(char ignore) { return parseFloat(SKIP_ALL, ignore); } + // These overload exists for compatibility with any class that has derived + // Stream and used parseFloat/Int with a custom ignore character. To keep + // the public API simple, these overload remains protected. + + struct MultiTarget { + const char *str; // string you're searching for + size_t len; // length of string you're searching for + size_t index; // index used by the search routine. + }; + + // This allows you to search for an arbitrary number of strings. + // Returns index of the target that is found first or -1 if timeout occurs. + int findMulti(struct MultiTarget *targets, int tCount); +}; + +#undef NO_IGNORE_CHAR + +} + +using arduino::Stream; \ No newline at end of file diff --git a/cores/rl78g22/api/String.cpp b/cores/rl78g22/api/String.cpp new file mode 100644 index 0000000..0a5c11f --- /dev/null +++ b/cores/rl78g22/api/String.cpp @@ -0,0 +1,756 @@ +/* + String library for Wiring & Arduino + ...mostly rewritten by Paul Stoffregen... + Copyright (c) 2009-10 Hernando Barragan. All rights reserved. + Copyright 2011, Paul Stoffregen, paul@pjrc.com + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "String.h" +#include "Common.h" +#include "itoa.h" +#include "deprecated-avr-comp/avr/dtostrf.h" + +#include + +namespace arduino { + +/*********************************************/ +/* Static Member Initialisation */ +/*********************************************/ + +size_t const String::FLT_MAX_DECIMAL_PLACES; +size_t const String::DBL_MAX_DECIMAL_PLACES; + +/*********************************************/ +/* Constructors */ +/*********************************************/ + +String::String(const char *cstr) +{ + init(); + if (cstr) copy(cstr, strlen(cstr)); +} + +String::String(const char *cstr, unsigned int length) +{ + init(); + if (cstr) copy(cstr, length); +} + +String::String(const String &value) +{ + init(); + *this = value; +} + +String::String(const __FlashStringHelper *pstr) +{ + init(); + *this = pstr; +} + +#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) +String::String(String &&rval) + : buffer(rval.buffer) + , capacity(rval.capacity) + , len(rval.len) +{ + rval.buffer = NULL; + rval.capacity = 0; + rval.len = 0; +} +#endif + +String::String(char c) +{ + init(); + char buf[2]; + buf[0] = c; + buf[1] = 0; + *this = buf; +} + +String::String(unsigned char value, unsigned char base) +{ + init(); + char buf[1 + 8 * sizeof(unsigned char)]; + utoa(value, buf, base); + *this = buf; +} + +String::String(int value, unsigned char base) +{ + init(); + char buf[2 + 8 * sizeof(int)]; + itoa(value, buf, base); + *this = buf; +} + +String::String(unsigned int value, unsigned char base) +{ + init(); + char buf[1 + 8 * sizeof(unsigned int)]; + utoa(value, buf, base); + *this = buf; +} + +String::String(long value, unsigned char base) +{ + init(); + char buf[2 + 8 * sizeof(long)]; + ltoa(value, buf, base); + *this = buf; +} + +String::String(unsigned long value, unsigned char base) +{ + init(); + char buf[1 + 8 * sizeof(unsigned long)]; + ultoa(value, buf, base); + *this = buf; +} + +String::String(float value, unsigned char decimalPlaces) +{ + static size_t const FLOAT_BUF_SIZE = FLT_MAX_10_EXP + FLT_MAX_DECIMAL_PLACES + 1 /* '-' */ + 1 /* '.' */ + 1 /* '\0' */; + init(); + char buf[FLOAT_BUF_SIZE]; + decimalPlaces = min(decimalPlaces, FLT_MAX_DECIMAL_PLACES); + *this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf); +} + +String::String(double value, unsigned char decimalPlaces) +{ + static size_t const DOUBLE_BUF_SIZE = DBL_MAX_10_EXP + DBL_MAX_DECIMAL_PLACES + 1 /* '-' */ + 1 /* '.' */ + 1 /* '\0' */; + init(); + char buf[DOUBLE_BUF_SIZE]; + decimalPlaces = min(decimalPlaces, DBL_MAX_DECIMAL_PLACES); + *this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf); +} + +String::~String() +{ + if (buffer) free(buffer); +} + +/*********************************************/ +/* Memory Management */ +/*********************************************/ + +inline void String::init(void) +{ + buffer = NULL; + capacity = 0; + len = 0; +} + +void String::invalidate(void) +{ + if (buffer) free(buffer); + buffer = NULL; + capacity = len = 0; +} + +bool String::reserve(unsigned int size) +{ + if (buffer && capacity >= size) return 1; + if (changeBuffer(size)) { + if (len == 0) buffer[0] = 0; + return true; + } + return false; +} + +bool String::changeBuffer(unsigned int maxStrLen) +{ + char *newbuffer = (char *)realloc(buffer, maxStrLen + 1); + if (newbuffer) { + buffer = newbuffer; + capacity = maxStrLen; + return true; + } + return false; +} + +/*********************************************/ +/* Copy and Move */ +/*********************************************/ + +String & String::copy(const char *cstr, unsigned int length) +{ + if (!reserve(length)) { + invalidate(); + return *this; + } + len = length; + memcpy(buffer, cstr, length); + buffer[len] = '\0'; + return *this; +} + +String & String::copy(const __FlashStringHelper *pstr, unsigned int length) +{ + if (!reserve(length)) { + invalidate(); + return *this; + } + len = length; + strcpy_P(buffer, (PGM_P)pstr); + return *this; +} + +#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) +void String::move(String &rhs) +{ + if (this != &rhs) + { + free(buffer); + + buffer = rhs.buffer; + len = rhs.len; + capacity = rhs.capacity; + + rhs.buffer = NULL; + rhs.len = 0; + rhs.capacity = 0; + } +} +#endif + +String & String::operator = (const String &rhs) +{ + if (this == &rhs) return *this; + + if (rhs.buffer) copy(rhs.buffer, rhs.len); + else invalidate(); + + return *this; +} + +#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) +String & String::operator = (String &&rval) +{ + move(rval); + return *this; +} +#endif + +String & String::operator = (const char *cstr) +{ + if (cstr) copy(cstr, strlen(cstr)); + else invalidate(); + + return *this; +} + +String & String::operator = (const __FlashStringHelper *pstr) +{ + if (pstr) copy(pstr, strlen_P((PGM_P)pstr)); + else invalidate(); + + return *this; +} + +/*********************************************/ +/* concat */ +/*********************************************/ + +bool String::concat(const String &s) +{ + return concat(s.buffer, s.len); +} + +bool String::concat(const char *cstr, unsigned int length) +{ + unsigned int newlen = len + length; + if (!cstr) return false; + if (length == 0) return true; + if (!reserve(newlen)) return false; + memcpy(buffer + len, cstr, length); + len = newlen; + buffer[len] = '\0'; + return true; +} + +bool String::concat(const char *cstr) +{ + if (!cstr) return false; + return concat(cstr, strlen(cstr)); +} + +bool String::concat(char c) +{ + return concat(&c, 1); +} + +bool String::concat(unsigned char num) +{ + char buf[1 + 3 * sizeof(unsigned char)]; + itoa(num, buf, 10); + return concat(buf); +} + +bool String::concat(int num) +{ + char buf[2 + 3 * sizeof(int)]; + itoa(num, buf, 10); + return concat(buf); +} + +bool String::concat(unsigned int num) +{ + char buf[1 + 3 * sizeof(unsigned int)]; + utoa(num, buf, 10); + return concat(buf); +} + +bool String::concat(long num) +{ + char buf[2 + 3 * sizeof(long)]; + ltoa(num, buf, 10); + return concat(buf); +} + +bool String::concat(unsigned long num) +{ + char buf[1 + 3 * sizeof(unsigned long)]; + ultoa(num, buf, 10); + return concat(buf); +} + +bool String::concat(float num) +{ + char buf[20]; + char* string = dtostrf(num, 4, 2, buf); + return concat(string); +} + +bool String::concat(double num) +{ + char buf[20]; + char* string = dtostrf(num, 4, 2, buf); + return concat(string); +} + +bool String::concat(const __FlashStringHelper * str) +{ + if (!str) return false; + int length = strlen_P((const char *) str); + if (length == 0) return true; + unsigned int newlen = len + length; + if (!reserve(newlen)) return false; + strcpy_P(buffer + len, (const char *) str); + len = newlen; + return true; +} + +/*********************************************/ +/* Concatenate */ +/*********************************************/ + +StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(rhs.buffer, rhs.len)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr) +{ + StringSumHelper &a = const_cast(lhs); + if (!cstr || !a.concat(cstr)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, char c) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(c)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, int num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, long num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, float num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, double num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, const __FlashStringHelper *rhs) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(rhs)) a.invalidate(); + return a; +} + +/*********************************************/ +/* Comparison */ +/*********************************************/ + +int String::compareTo(const String &s) const +{ + if (!buffer || !s.buffer) { + if (s.buffer && s.len > 0) return 0 - *(unsigned char *)s.buffer; + if (buffer && len > 0) return *(unsigned char *)buffer; + return 0; + } + return strcmp(buffer, s.buffer); +} + +int String::compareTo(const char *cstr) const +{ + if (!buffer || !cstr) { + if (cstr && *cstr) return 0 - *(unsigned char *)cstr; + if (buffer && len > 0) return *(unsigned char *)buffer; + return 0; + } + return strcmp(buffer, cstr); +} + +bool String::equals(const String &s2) const +{ + return (len == s2.len && compareTo(s2) == 0); +} + +bool String::equals(const char *cstr) const +{ + if (len == 0) return (cstr == NULL || *cstr == 0); + if (cstr == NULL) return buffer[0] == 0; + return strcmp(buffer, cstr) == 0; +} + +bool String::equalsIgnoreCase( const String &s2 ) const +{ + if (this == &s2) return true; + if (len != s2.len) return false; + if (len == 0) return true; + const char *p1 = buffer; + const char *p2 = s2.buffer; + while (*p1) { + if (tolower(*p1++) != tolower(*p2++)) return false; + } + return true; +} + +bool String::startsWith( const String &s2 ) const +{ + if (len < s2.len) return false; + return startsWith(s2, 0); +} + +bool String::startsWith( const String &s2, unsigned int offset ) const +{ + if (offset > len - s2.len || !buffer || !s2.buffer) return false; + return strncmp( &buffer[offset], s2.buffer, s2.len ) == 0; +} + +bool String::endsWith( const String &s2 ) const +{ + if ( len < s2.len || !buffer || !s2.buffer) return false; + return strcmp(&buffer[len - s2.len], s2.buffer) == 0; +} + +/*********************************************/ +/* Character Access */ +/*********************************************/ + +char String::charAt(unsigned int loc) const +{ + return operator[](loc); +} + +void String::setCharAt(unsigned int loc, char c) +{ + if (loc < len) buffer[loc] = c; +} + +char & String::operator[](unsigned int index) +{ + static char dummy_writable_char; + if (index >= len || !buffer) { + dummy_writable_char = 0; + return dummy_writable_char; + } + return buffer[index]; +} + +char String::operator[]( unsigned int index ) const +{ + if (index >= len || !buffer) return 0; + return buffer[index]; +} + +void String::getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index) const +{ + if (!bufsize || !buf) return; + if (index >= len) { + buf[0] = 0; + return; + } + unsigned int n = bufsize - 1; + if (n > len - index) n = len - index; + strncpy((char *)buf, buffer + index, n); + buf[n] = 0; +} + +/*********************************************/ +/* Search */ +/*********************************************/ + +int String::indexOf(char c) const +{ + return indexOf(c, 0); +} + +int String::indexOf( char ch, unsigned int fromIndex ) const +{ + if (fromIndex >= len) return -1; + const char* temp = strchr(buffer + fromIndex, ch); + if (temp == NULL) return -1; + return temp - buffer; +} + +int String::indexOf(const String &s2) const +{ + return indexOf(s2, 0); +} + +int String::indexOf(const String &s2, unsigned int fromIndex) const +{ + if (fromIndex >= len) return -1; + const char *found = strstr(buffer + fromIndex, s2.buffer); + if (found == NULL) return -1; + return found - buffer; +} + +int String::lastIndexOf( char theChar ) const +{ + return lastIndexOf(theChar, len - 1); +} + +int String::lastIndexOf(char ch, unsigned int fromIndex) const +{ + if (fromIndex >= len) return -1; + char tempchar = buffer[fromIndex + 1]; + buffer[fromIndex + 1] = '\0'; + char* temp = strrchr( buffer, ch ); + buffer[fromIndex + 1] = tempchar; + if (temp == NULL) return -1; + return temp - buffer; +} + +int String::lastIndexOf(const String &s2) const +{ + return lastIndexOf(s2, len - s2.len); +} + +int String::lastIndexOf(const String &s2, unsigned int fromIndex) const +{ + if (s2.len == 0 || len == 0 || s2.len > len) return -1; + if (fromIndex >= len) fromIndex = len - 1; + int found = -1; + for (char *p = buffer; p <= buffer + fromIndex; p++) { + p = strstr(p, s2.buffer); + if (!p) break; + if ((unsigned int)(p - buffer) <= fromIndex) found = p - buffer; + } + return found; +} + +String String::substring(unsigned int left, unsigned int right) const +{ + if (left > right) { + unsigned int temp = right; + right = left; + left = temp; + } + String out; + if (left >= len) return out; + if (right > len) right = len; + out.copy(buffer + left, right - left); + return out; +} + +/*********************************************/ +/* Modification */ +/*********************************************/ + +void String::replace(char find, char replace) +{ + if (!buffer) return; + for (char *p = buffer; *p; p++) { + if (*p == find) *p = replace; + } +} + +void String::replace(const String& find, const String& replace) +{ + if (len == 0 || find.len == 0) return; + int diff = replace.len - find.len; + char *readFrom = buffer; + char *foundAt; + if (diff == 0) { + while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { + memcpy(foundAt, replace.buffer, replace.len); + readFrom = foundAt + replace.len; + } + } else if (diff < 0) { + unsigned int size = len; // compute size needed for result + while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { + readFrom = foundAt + find.len; + diff = 0 - diff; + size -= diff; + } + if (size == len) return; + int index = len - 1; + while (index >= 0 && (index = lastIndexOf(find, index)) >= 0) { + readFrom = buffer + index + find.len; + memmove(readFrom - diff, readFrom, len - (readFrom - buffer)); + len -= diff; + buffer[len] = 0; + memcpy(buffer + index, replace.buffer, replace.len); + index--; + } + } else { + unsigned int size = len; // compute size needed for result + while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { + readFrom = foundAt + find.len; + size += diff; + } + if (size == len) return; + if (size > capacity && !changeBuffer(size)) return; // XXX: tell user! + int index = len - 1; + while (index >= 0 && (index = lastIndexOf(find, index)) >= 0) { + readFrom = buffer + index + find.len; + memmove(readFrom + diff, readFrom, len - (readFrom - buffer)); + len += diff; + buffer[len] = 0; + memcpy(buffer + index, replace.buffer, replace.len); + index--; + } + } +} + +void String::remove(unsigned int index){ + // Pass the biggest integer as the count. The remove method + // below will take care of truncating it at the end of the + // string. + remove(index, (unsigned int)-1); +} + +void String::remove(unsigned int index, unsigned int count){ + if (index >= len) { return; } + if (count <= 0) { return; } + if (count > len - index) { count = len - index; } + char *writeTo = buffer + index; + len = len - count; + memmove(writeTo, buffer + index + count,len - index); + buffer[len] = 0; +} + +void String::toLowerCase(void) +{ + if (!buffer) return; + for (char *p = buffer; *p; p++) { + *p = tolower(*p); + } +} + +void String::toUpperCase(void) +{ + if (!buffer) return; + for (char *p = buffer; *p; p++) { + *p = toupper(*p); + } +} + +void String::trim(void) +{ + if (!buffer || len == 0) return; + char *begin = buffer; + while (isspace(*begin)) begin++; + char *end = buffer + len - 1; + while (isspace(*end) && end >= begin) end--; + len = end + 1 - begin; + if (begin > buffer) memmove(buffer, begin, len); + buffer[len] = 0; +} + +/*********************************************/ +/* Parsing / Conversion */ +/*********************************************/ + +long String::toInt(void) const +{ + if (buffer) return atol(buffer); + return 0; +} + +float String::toFloat(void) const +{ + return float(toDouble()); +} + +double String::toDouble(void) const +{ + if (buffer) return atof(buffer); + return 0; +} + +} // namespace arduino diff --git a/cores/rl78g22/api/String.h b/cores/rl78g22/api/String.h new file mode 100644 index 0000000..03ecf44 --- /dev/null +++ b/cores/rl78g22/api/String.h @@ -0,0 +1,260 @@ +/* + String library for Wiring & Arduino + ...mostly rewritten by Paul Stoffregen... + Copyright (c) 2009-10 Hernando Barragan. All right reserved. + Copyright 2011, Paul Stoffregen, paul@pjrc.com + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifdef __cplusplus + +#ifndef __ARDUINO_STRINGS__ +#define __ARDUINO_STRINGS__ + +#include +#include +#include +#if defined(__AVR__) +#include "avr/pgmspace.h" +#else +#include "deprecated-avr-comp/avr/pgmspace.h" +#endif + +namespace arduino { + +// When compiling programs with this class, the following gcc parameters +// dramatically increase performance and memory (RAM) efficiency, typically +// with little or no increase in code size. +// -felide-constructors +// -std=c++0x + +class __FlashStringHelper; +#define F(string_literal) (reinterpret_cast(PSTR(string_literal))) + +// An inherited class for holding the result of a concatenation. These +// result objects are assumed to be writable by subsequent concatenations. +class StringSumHelper; + +// The string class +class String +{ + friend class StringSumHelper; + // use a function pointer to allow for "if (s)" without the + // complications of an operator bool(). for more information, see: + // http://www.artima.com/cppsource/safebool.html + typedef void (String::*StringIfHelperType)() const; + void StringIfHelper() const {} + + static size_t const FLT_MAX_DECIMAL_PLACES = 10; + static size_t const DBL_MAX_DECIMAL_PLACES = FLT_MAX_DECIMAL_PLACES; + +public: + // constructors + // creates a copy of the initial value. + // if the initial value is null or invalid, or if memory allocation + // fails, the string will be marked as invalid (i.e. "if (s)" will + // be false). + String(const char *cstr = ""); + String(const char *cstr, unsigned int length); + String(const uint8_t *cstr, unsigned int length) : String((const char*)cstr, length) {} + String(const String &str); + String(const __FlashStringHelper *str); + #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) + String(String &&rval); + #endif + explicit String(char c); + explicit String(unsigned char, unsigned char base=10); + explicit String(int, unsigned char base=10); + explicit String(unsigned int, unsigned char base=10); + explicit String(long, unsigned char base=10); + explicit String(unsigned long, unsigned char base=10); + explicit String(float, unsigned char decimalPlaces=2); + explicit String(double, unsigned char decimalPlaces=2); + ~String(void); + + // memory management + // return true on success, false on failure (in which case, the string + // is left unchanged). reserve(0), if successful, will validate an + // invalid string (i.e., "if (s)" will be true afterwards) + bool reserve(unsigned int size); + inline unsigned int length(void) const {return len;} + + // creates a copy of the assigned value. if the value is null or + // invalid, or if the memory allocation fails, the string will be + // marked as invalid ("if (s)" will be false). + String & operator = (const String &rhs); + String & operator = (const char *cstr); + String & operator = (const __FlashStringHelper *str); + #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) + String & operator = (String &&rval); + #endif + + // concatenate (works w/ built-in types) + + // returns true on success, false on failure (in which case, the string + // is left unchanged). if the argument is null or invalid, the + // concatenation is considered unsuccessful. + bool concat(const String &str); + bool concat(const char *cstr); + bool concat(const char *cstr, unsigned int length); + bool concat(const uint8_t *cstr, unsigned int length) {return concat((const char*)cstr, length);} + bool concat(char c); + bool concat(unsigned char num); + bool concat(int num); + bool concat(unsigned int num); + bool concat(long num); + bool concat(unsigned long num); + bool concat(float num); + bool concat(double num); + bool concat(const __FlashStringHelper * str); + + // if there's not enough memory for the concatenated value, the string + // will be left unchanged (but this isn't signalled in any way) + String & operator += (const String &rhs) {concat(rhs); return (*this);} + String & operator += (const char *cstr) {concat(cstr); return (*this);} + String & operator += (char c) {concat(c); return (*this);} + String & operator += (unsigned char num) {concat(num); return (*this);} + String & operator += (int num) {concat(num); return (*this);} + String & operator += (unsigned int num) {concat(num); return (*this);} + String & operator += (long num) {concat(num); return (*this);} + String & operator += (unsigned long num) {concat(num); return (*this);} + String & operator += (float num) {concat(num); return (*this);} + String & operator += (double num) {concat(num); return (*this);} + String & operator += (const __FlashStringHelper *str){concat(str); return (*this);} + + friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs); + friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr); + friend StringSumHelper & operator + (const StringSumHelper &lhs, char c); + friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, int num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, long num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, float num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, double num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, const __FlashStringHelper *rhs); + + // comparison (only works w/ Strings and "strings") + operator StringIfHelperType() const { return buffer ? &String::StringIfHelper : 0; } + int compareTo(const String &s) const; + int compareTo(const char *cstr) const; + bool equals(const String &s) const; + bool equals(const char *cstr) const; + + friend bool operator == (const String &a, const String &b) { return a.equals(b); } + friend bool operator == (const String &a, const char *b) { return a.equals(b); } + friend bool operator == (const char *a, const String &b) { return b == a; } + friend bool operator < (const String &a, const String &b) { return a.compareTo(b) < 0; } + friend bool operator < (const String &a, const char *b) { return a.compareTo(b) < 0; } + friend bool operator < (const char *a, const String &b) { return b.compareTo(a) > 0; } + + friend bool operator != (const String &a, const String &b) { return !(a == b); } + friend bool operator != (const String &a, const char *b) { return !(a == b); } + friend bool operator != (const char *a, const String &b) { return !(a == b); } + friend bool operator > (const String &a, const String &b) { return b < a; } + friend bool operator > (const String &a, const char *b) { return b < a; } + friend bool operator > (const char *a, const String &b) { return b < a; } + friend bool operator <= (const String &a, const String &b) { return !(b < a); } + friend bool operator <= (const String &a, const char *b) { return !(b < a); } + friend bool operator <= (const char *a, const String &b) { return !(b < a); } + friend bool operator >= (const String &a, const String &b) { return !(a < b); } + friend bool operator >= (const String &a, const char *b) { return !(a < b); } + friend bool operator >= (const char *a, const String &b) { return !(a < b); } + + bool equalsIgnoreCase(const String &s) const; + bool startsWith( const String &prefix) const; + bool startsWith(const String &prefix, unsigned int offset) const; + bool endsWith(const String &suffix) const; + + // character access + char charAt(unsigned int index) const; + void setCharAt(unsigned int index, char c); + char operator [] (unsigned int index) const; + char& operator [] (unsigned int index); + void getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index=0) const; + void toCharArray(char *buf, unsigned int bufsize, unsigned int index=0) const + { getBytes((unsigned char *)buf, bufsize, index); } + const char* c_str() const { return buffer; } + char* begin() { return buffer; } + char* end() { return buffer + length(); } + const char* begin() const { return c_str(); } + const char* end() const { return c_str() + length(); } + + // search + int indexOf( char ch ) const; + int indexOf( char ch, unsigned int fromIndex ) const; + int indexOf( const String &str ) const; + int indexOf( const String &str, unsigned int fromIndex ) const; + int lastIndexOf( char ch ) const; + int lastIndexOf( char ch, unsigned int fromIndex ) const; + int lastIndexOf( const String &str ) const; + int lastIndexOf( const String &str, unsigned int fromIndex ) const; + String substring( unsigned int beginIndex ) const { return substring(beginIndex, len); }; + String substring( unsigned int beginIndex, unsigned int endIndex ) const; + + // modification + void replace(char find, char replace); + void replace(const String& find, const String& replace); + void remove(unsigned int index); + void remove(unsigned int index, unsigned int count); + void toLowerCase(void); + void toUpperCase(void); + void trim(void); + + // parsing/conversion + long toInt(void) const; + float toFloat(void) const; + double toDouble(void) const; + +protected: + char *buffer; // the actual char array + unsigned int capacity; // the array length minus one (for the '\0') + unsigned int len; // the String length (not counting the '\0') +protected: + void init(void); + void invalidate(void); + bool changeBuffer(unsigned int maxStrLen); + + // copy and move + String & copy(const char *cstr, unsigned int length); + String & copy(const __FlashStringHelper *pstr, unsigned int length); + #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) + void move(String &rhs); + #endif +}; + +class StringSumHelper : public String +{ +public: + StringSumHelper(const String &s) : String(s) {} + StringSumHelper(const char *p) : String(p) {} + StringSumHelper(char c) : String(c) {} + StringSumHelper(unsigned char num) : String(num) {} + StringSumHelper(int num) : String(num) {} + StringSumHelper(unsigned int num) : String(num) {} + StringSumHelper(long num) : String(num) {} + StringSumHelper(unsigned long num) : String(num) {} + StringSumHelper(float num) : String(num) {} + StringSumHelper(double num) : String(num) {} +}; + +} // namespace arduino + +using arduino::__FlashStringHelper; +using arduino::String; + +#endif // __cplusplus +#endif // __ARDUINO_STRINGS__ diff --git a/cores/rl78g22/api/USBAPI.h b/cores/rl78g22/api/USBAPI.h new file mode 100644 index 0000000..ba5e87c --- /dev/null +++ b/cores/rl78g22/api/USBAPI.h @@ -0,0 +1,64 @@ +/* + USBAPI.h + Copyright (c) 2005-2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef __USBAPI__ +#define __USBAPI__ + +#include + +namespace arduino { +//================================================================================ +//================================================================================ +// Low level API + +typedef struct __attribute__((packed)) +{ + union { + uint8_t bmRequestType; + struct { + uint8_t direction : 5; + uint8_t type : 2; + uint8_t transferDirection : 1; + }; + }; + uint8_t bRequest; + uint8_t wValueL; + uint8_t wValueH; + uint16_t wIndex; + uint16_t wLength; +} USBSetup; + +} + +//================================================================================ +// USB APIs (C scope) +//================================================================================ + +int USB_SendControl(uint8_t flags, const void* d, int len); +int USB_RecvControl(void* d, int len); +int USB_RecvControlLong(void* d, int len); + +uint8_t USB_Available(uint8_t ep); +uint8_t USB_SendSpace(uint8_t ep); +int USB_Send(uint8_t ep, const void* data, int len); // blocking +int USB_Recv(uint8_t ep, void* data, int len); // non-blocking +int USB_Recv(uint8_t ep); // non-blocking +void USB_Flush(uint8_t ep); + +#endif \ No newline at end of file diff --git a/cores/rl78g22/api/Udp.h b/cores/rl78g22/api/Udp.h new file mode 100644 index 0000000..20117a6 --- /dev/null +++ b/cores/rl78g22/api/Udp.h @@ -0,0 +1,92 @@ +/* + * Udp.cpp: Library to send/receive UDP packets. + * + * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) + * 1) UDP does not guarantee the order in which assembled UDP packets are received. This + * might not happen often in practice, but in larger network topologies, a UDP + * packet can be received out of sequence. + * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being + * aware of it. Again, this may not be a concern in practice on small local networks. + * For more information, see http://www.cafeaulait.org/course/week12/35.html + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + */ + +#pragma once + +#include "Stream.h" +#include "IPAddress.h" + +namespace arduino { + +class UDP : public Stream { + +public: + virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure + virtual void stop() =0; // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specified in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port) =0; + // Start building up a packet to send to the remote host specified in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port) =0; + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket() =0; + // Write a single byte into the packet + virtual size_t write(uint8_t) =0; + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size) =0; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket() =0; + // Number of bytes remaining in the current packet + virtual int available() =0; + // Read a single byte from the current packet + virtual int read() =0; + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len) =0; + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) =0; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek() =0; + virtual void flush() =0; // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() =0; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() =0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +} + +using arduino::UDP; \ No newline at end of file diff --git a/cores/rl78g22/api/WCharacter.h b/cores/rl78g22/api/WCharacter.h new file mode 100644 index 0000000..e3642cc --- /dev/null +++ b/cores/rl78g22/api/WCharacter.h @@ -0,0 +1,171 @@ +/* + WCharacter.h - Character utility functions for Wiring & Arduino + Copyright (c) 2010 Hernando Barragan. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef Character_h +#define Character_h + +#include + +namespace arduino { + +// WCharacter.h prototypes +inline bool isAlphaNumeric(int c) __attribute__((always_inline)); +inline bool isAlpha(int c) __attribute__((always_inline)); +inline bool isAscii(int c) __attribute__((always_inline)); +inline bool isWhitespace(int c) __attribute__((always_inline)); +inline bool isControl(int c) __attribute__((always_inline)); +inline bool isDigit(int c) __attribute__((always_inline)); +inline bool isGraph(int c) __attribute__((always_inline)); +inline bool isLowerCase(int c) __attribute__((always_inline)); +inline bool isPrintable(int c) __attribute__((always_inline)); +inline bool isPunct(int c) __attribute__((always_inline)); +inline bool isSpace(int c) __attribute__((always_inline)); +inline bool isUpperCase(int c) __attribute__((always_inline)); +inline bool isHexadecimalDigit(int c) __attribute__((always_inline)); +inline int toAscii(int c) __attribute__((always_inline)); +inline int toLowerCase(int c) __attribute__((always_inline)); +inline int toUpperCase(int c)__attribute__((always_inline)); + + +// Checks for an alphanumeric character. +// It is equivalent to (isalpha(c) || isdigit(c)). +inline bool isAlphaNumeric(int c) +{ + return ( isalnum(c) == 0 ? false : true); +} + + +// Checks for an alphabetic character. +// It is equivalent to (isupper(c) || islower(c)). +inline bool isAlpha(int c) +{ + return ( isalpha(c) == 0 ? false : true); +} + + +// Checks whether c is a 7-bit unsigned char value +// that fits into the ASCII character set. +inline bool isAscii(int c) +{ + return ((c & ~0x7f) != 0 ? false : true ); +} + + +// Checks for a blank character, that is, a space or a tab. +inline bool isWhitespace(int c) +{ + return ( isblank (c) == 0 ? false : true); +} + + +// Checks for a control character. +inline bool isControl(int c) +{ + return ( iscntrl (c) == 0 ? false : true); +} + + +// Checks for a digit (0 through 9). +inline bool isDigit(int c) +{ + return ( isdigit (c) == 0 ? false : true); +} + + +// Checks for any printable character except space. +inline bool isGraph(int c) +{ + return ( isgraph (c) == 0 ? false : true); +} + + +// Checks for a lower-case character. +inline bool isLowerCase(int c) +{ + return (islower (c) == 0 ? false : true); +} + + +// Checks for any printable character including space. +inline bool isPrintable(int c) +{ + return ( isprint (c) == 0 ? false : true); +} + + +// Checks for any printable character which is not a space +// or an alphanumeric character. +inline bool isPunct(int c) +{ + return ( ispunct (c) == 0 ? false : true); +} + + +// Checks for white-space characters. For the avr-libc library, +// these are: space, formfeed ('\f'), newline ('\n'), carriage +// return ('\r'), horizontal tab ('\t'), and vertical tab ('\v'). +inline bool isSpace(int c) +{ + return ( isspace (c) == 0 ? false : true); +} + + +// Checks for an uppercase letter. +inline bool isUpperCase(int c) +{ + return ( isupper (c) == 0 ? false : true); +} + + +// Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7 +// 8 9 a b c d e f A B C D E F. +inline bool isHexadecimalDigit(int c) +{ + return ( isxdigit (c) == 0 ? false : true); +} + + +// Converts c to a 7-bit unsigned char value that fits into the +// ASCII character set, by clearing the high-order bits. +inline int toAscii(int c) +{ + return (c & 0x7f); +} + + +// Warning: +// Many people will be unhappy if you use this function. +// This function will convert accented letters into random +// characters. + +// Converts the letter c to lower case, if possible. +inline int toLowerCase(int c) +{ + return tolower (c); +} + + +// Converts the letter c to upper case, if possible. +inline int toUpperCase(int c) +{ + return toupper (c); +} + +} +#endif \ No newline at end of file diff --git a/cores/rl78g22/api/deprecated-avr-comp/avr/dtostrf.c.impl b/cores/rl78g22/api/deprecated-avr-comp/avr/dtostrf.c.impl new file mode 100644 index 0000000..96987a8 --- /dev/null +++ b/cores/rl78g22/api/deprecated-avr-comp/avr/dtostrf.c.impl @@ -0,0 +1,37 @@ +/* + dtostrf - Emulation for dtostrf function from avr-libc + Copyright (c) 2016 Arduino LLC. All rights reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// This is a default implementation for dtostrf function. +// This file should be used if the standard lib doesn't provide an +// implementation of dtostrf. + +// Create a file called "dtostrf.c" with the following include: +// #include "api/deprecated-avr-comp/avr/dtostrf.c.impl" + +#include + +char *dtostrf (double val, signed char width, unsigned char prec, char *sout) { + asm(".global _printf_float"); + + char fmt[20]; + sprintf(fmt, "%%%d.%df", width, prec); + sprintf(sout, fmt, val); + return sout; +} + diff --git a/cores/rl78g22/api/deprecated-avr-comp/avr/dtostrf.h b/cores/rl78g22/api/deprecated-avr-comp/avr/dtostrf.h new file mode 100644 index 0000000..2d287ca --- /dev/null +++ b/cores/rl78g22/api/deprecated-avr-comp/avr/dtostrf.h @@ -0,0 +1,34 @@ +/* + dtostrf - Emulation for dtostrf function from avr-libc + Copyright (c) 2015 Arduino LLC. All rights reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#if !defined(ARDUINO_ARCH_AVR) + +#ifdef __cplusplus +extern "C" { +#endif + +char *dtostrf(double val, signed char width, unsigned char prec, char *sout); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cores/rl78g22/api/deprecated-avr-comp/avr/interrupt.h b/cores/rl78g22/api/deprecated-avr-comp/avr/interrupt.h new file mode 100644 index 0000000..a2873cf --- /dev/null +++ b/cores/rl78g22/api/deprecated-avr-comp/avr/interrupt.h @@ -0,0 +1,23 @@ +/* + Copyright (c) 2015 Arduino LCC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* + Empty file. + This file is here to allow compatibility with sketches (made for AVR) + that include +*/ diff --git a/cores/rl78g22/api/deprecated-avr-comp/avr/pgmspace.h b/cores/rl78g22/api/deprecated-avr-comp/avr/pgmspace.h new file mode 100644 index 0000000..95897d7 --- /dev/null +++ b/cores/rl78g22/api/deprecated-avr-comp/avr/pgmspace.h @@ -0,0 +1,122 @@ +/* + pgmspace.h - Definitions for compatibility with AVR pgmspace macros + + Copyright (c) 2015 Arduino LLC + + Based on work of Paul Stoffregen on Teensy 3 (http://pjrc.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE +*/ + +#ifndef __PGMSPACE_H_ +#define __PGMSPACE_H_ 1 + +#include + +#define PROGMEM +#define PGM_P const char * +#define PSTR(str) (str) + +#define _SFR_BYTE(n) (n) + +typedef void prog_void; +typedef char prog_char; +typedef unsigned char prog_uchar; +typedef int8_t prog_int8_t; +typedef uint8_t prog_uint8_t; +typedef int16_t prog_int16_t; +typedef uint16_t prog_uint16_t; +typedef int32_t prog_int32_t; +typedef uint32_t prog_uint32_t; +typedef int64_t prog_int64_t; +typedef uint64_t prog_uint64_t; + +typedef const void* int_farptr_t; +typedef const void* uint_farptr_t; + +#define memchr_P(s, c, n) memchr((s), (c), (n)) +#define memcmp_P(s1, s2, n) memcmp((s1), (s2), (n)) +#define memccpy_P(dest, src, c, n) memccpy((dest), (src), (c), (n)) +#define memcpy_P(dest, src, n) memcpy((dest), (src), (n)) +#define memmem_P(haystack, haystacklen, needle, needlelen) memmem((haystack), (haystacklen), (needle), (needlelen)) +#define memrchr_P(s, c, n) memrchr((s), (c), (n)) +#define strcat_P(dest, src) strcat((dest), (src)) +#define strchr_P(s, c) strchr((s), (c)) +#define strchrnul_P(s, c) strchrnul((s), (c)) +#define strcmp_P(a, b) strcmp((a), (b)) +#define strcpy_P(dest, src) strcpy((dest), (src)) +#define strcasecmp_P(s1, s2) strcasecmp((s1), (s2)) +#define strcasestr_P(haystack, needle) strcasestr((haystack), (needle)) +#define strcspn_P(s, accept) strcspn((s), (accept)) +#define strlcat_P(s1, s2, n) strlcat((s1), (s2), (n)) +#define strlcpy_P(s1, s2, n) strlcpy((s1), (s2), (n)) +#define strlen_P(a) strlen((a)) +#define strnlen_P(s, n) strnlen((s), (n)) +#define strncmp_P(s1, s2, n) strncmp((s1), (s2), (n)) +#define strncasecmp_P(s1, s2, n) strncasecmp((s1), (s2), (n)) +#define strncat_P(s1, s2, n) strncat((s1), (s2), (n)) +#define strncpy_P(s1, s2, n) strncpy((s1), (s2), (n)) +#define strpbrk_P(s, accept) strpbrk((s), (accept)) +#define strrchr_P(s, c) strrchr((s), (c)) +#define strsep_P(sp, delim) strsep((sp), (delim)) +#define strspn_P(s, accept) strspn((s), (accept)) +#define strstr_P(a, b) strstr((a), (b)) +#define strtok_P(s, delim) strtok((s), (delim)) +#define strtok_rP(s, delim, last) strtok((s), (delim), (last)) + +#define strlen_PF(a) strlen((a)) +#define strnlen_PF(src, len) strnlen((src), (len)) +#define memcpy_PF(dest, src, len) memcpy((dest), (src), (len)) +#define strcpy_PF(dest, src) strcpy((dest), (src)) +#define strncpy_PF(dest, src, len) strncpy((dest), (src), (len)) +#define strcat_PF(dest, src) strcat((dest), (src)) +#define strlcat_PF(dest, src, len) strlcat((dest), (src), (len)) +#define strncat_PF(dest, src, len) strncat((dest), (src), (len)) +#define strcmp_PF(s1, s2) strcmp((s1), (s2)) +#define strncmp_PF(s1, s2, n) strncmp((s1), (s2), (n)) +#define strcasecmp_PF(s1, s2) strcasecmp((s1), (s2)) +#define strncasecmp_PF(s1, s2, n) strncasecmp((s1), (s2), (n)) +#define strstr_PF(s1, s2) strstr((s1), (s2)) +#define strlcpy_PF(dest, src, n) strlcpy((dest), (src), (n)) +#define memcmp_PF(s1, s2, n) memcmp((s1), (s2), (n)) + +#define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__) +#define snprintf_P(s, f, ...) snprintf((s), (f), __VA_ARGS__) + +#define pgm_read_byte(addr) (*(const unsigned char *)(addr)) +#define pgm_read_word(addr) (*(const unsigned short *)(addr)) +#define pgm_read_dword(addr) (*(const unsigned long *)(addr)) +#define pgm_read_float(addr) (*(const float *)(addr)) +#define pgm_read_ptr(addr) (*(void *const *)(addr)) + +#define pgm_read_byte_near(addr) pgm_read_byte(addr) +#define pgm_read_word_near(addr) pgm_read_word(addr) +#define pgm_read_dword_near(addr) pgm_read_dword(addr) +#define pgm_read_float_near(addr) pgm_read_float(addr) +#define pgm_read_ptr_near(addr) pgm_read_ptr(addr) + +#define pgm_read_byte_far(addr) pgm_read_byte(addr) +#define pgm_read_word_far(addr) pgm_read_word(addr) +#define pgm_read_dword_far(addr) pgm_read_dword(addr) +#define pgm_read_float_far(addr) pgm_read_float(addr) +#define pgm_read_ptr_far(addr) pgm_read_ptr(addr) + +#define pgm_get_far_address(addr) (&(addr)) + +#endif diff --git a/cores/rl78g22/api/deprecated/Client.h b/cores/rl78g22/api/deprecated/Client.h new file mode 100644 index 0000000..84981c7 --- /dev/null +++ b/cores/rl78g22/api/deprecated/Client.h @@ -0,0 +1,25 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// including Client.h is deprecated, for all future projects use Arduino.h instead + +// This include is added for compatibility, it will be removed on the next +// major release of the API +#include "../Client.h" + + diff --git a/cores/rl78g22/api/deprecated/HardwareSerial.h b/cores/rl78g22/api/deprecated/HardwareSerial.h new file mode 100644 index 0000000..0ed7d7a --- /dev/null +++ b/cores/rl78g22/api/deprecated/HardwareSerial.h @@ -0,0 +1,25 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// including HardwareSerial.h is deprecated, for all future projects use Arduino.h instead + +// This include is added for compatibility, it will be removed on the next +// major release of the API +#include "../HardwareSerial.h" + + diff --git a/cores/rl78g22/api/deprecated/IPAddress.h b/cores/rl78g22/api/deprecated/IPAddress.h new file mode 100644 index 0000000..4c03574 --- /dev/null +++ b/cores/rl78g22/api/deprecated/IPAddress.h @@ -0,0 +1,25 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// including IPAddress.h is deprecated, for all future projects use Arduino.h instead + +// This include is added for compatibility, it will be removed on the next +// major release of the API +#include "../IPAddress.h" + + diff --git a/cores/rl78g22/api/deprecated/Print.h b/cores/rl78g22/api/deprecated/Print.h new file mode 100644 index 0000000..a0d1bd1 --- /dev/null +++ b/cores/rl78g22/api/deprecated/Print.h @@ -0,0 +1,24 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// including Print.h is deprecated, for all future projects use Arduino.h instead + +// This include is added for compatibility, it will be removed on the next +// major release of the API +#include "../Print.h" + diff --git a/cores/rl78g22/api/deprecated/Printable.h b/cores/rl78g22/api/deprecated/Printable.h new file mode 100644 index 0000000..b6888c1 --- /dev/null +++ b/cores/rl78g22/api/deprecated/Printable.h @@ -0,0 +1,24 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// including Printable.h is deprecated, for all future projects use Arduino.h instead + +// This include is added for compatibility, it will be removed on the next +// major release of the API +#include "../Printable.h" + diff --git a/cores/rl78g22/api/deprecated/Server.h b/cores/rl78g22/api/deprecated/Server.h new file mode 100644 index 0000000..65b544b --- /dev/null +++ b/cores/rl78g22/api/deprecated/Server.h @@ -0,0 +1,25 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// including Server.h is deprecated, for all future projects use Arduino.h instead + +// This include is added for compatibility, it will be removed on the next +// major release of the API +#include "../Server.h" + + diff --git a/cores/rl78g22/api/deprecated/Stream.h b/cores/rl78g22/api/deprecated/Stream.h new file mode 100644 index 0000000..4118ccb --- /dev/null +++ b/cores/rl78g22/api/deprecated/Stream.h @@ -0,0 +1,25 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// including Stream.h is deprecated, for all future projects use Arduino.h instead + +// This include is added for compatibility, it will be removed on the next +// major release of the API +#include "../Stream.h" + + diff --git a/cores/rl78g22/api/deprecated/Udp.h b/cores/rl78g22/api/deprecated/Udp.h new file mode 100644 index 0000000..f03a64b --- /dev/null +++ b/cores/rl78g22/api/deprecated/Udp.h @@ -0,0 +1,25 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// including Udp.h is deprecated, for all future projects use Arduino.h instead + +// This include is added for compatibility, it will be removed on the next +// major release of the API +#include "../Udp.h" + + diff --git a/cores/rl78g22/api/deprecated/WString.h b/cores/rl78g22/api/deprecated/WString.h new file mode 100644 index 0000000..1a3a79f --- /dev/null +++ b/cores/rl78g22/api/deprecated/WString.h @@ -0,0 +1,24 @@ +/* + Copyright 2016, Arduino LLC. All Right Reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// including WString.h is deprecated, for all future projects use Arduino.h instead + +// This include is added for compatibility, it will be removed on the next +// major release of the API +#include "../String.h" + diff --git a/cores/rl78g22/api/itoa.h b/cores/rl78g22/api/itoa.h new file mode 100644 index 0000000..55b2849 --- /dev/null +++ b/cores/rl78g22/api/itoa.h @@ -0,0 +1,37 @@ +/* + Copyright (c) 2016 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +// Standard C functions required in Arduino API +// If these functions are not provided by the standard library, the +// core should supply an implementation of them. + +#ifdef __cplusplus +extern "C" { +#endif + +extern char* itoa(int value, char *string, int radix); +extern char* ltoa(long value, char *string, int radix); +extern char* utoa(unsigned value, char *string, int radix); +extern char* ultoa(unsigned long value, char *string, int radix); + +#ifdef __cplusplus +} // extern "C" +#endif + diff --git a/cores/rl78g22/dtostrf.c b/cores/rl78g22/dtostrf.c new file mode 100644 index 0000000..892ffa6 --- /dev/null +++ b/cores/rl78g22/dtostrf.c @@ -0,0 +1,142 @@ +//#include "api/deprecated-avr-comp/avr/dtostrf.c.impl" + +#if 1 +#include +#include +#include + +static size_t printNumber(unsigned long n, uint8_t base, char *inputbuff) +{ + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) + { + base = 10; + } + + do + { + char c = (char)(n % base); + n /= base; + + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + strcpy(inputbuff,str); + + return strlen(str); +} + + +char *dtostrf (double val, signed char width, unsigned char prec, char *sout) +{ + char fmt[20]; + double number = val; + unsigned char digits = prec; + signed short n; + signed short width_local = width; + memset(fmt, 0, sizeof(fmt)); + + n = 0; + + if (isnan(number)) + { + strcpy(fmt, "nan"); + strcpy(sout, fmt); + return sout; + } + if (isinf(number)) + { + strcpy(fmt, "inf"); + strcpy(sout, fmt); + return sout; + } + if (number > 4294967040.0) + { + strcpy(fmt, "ovf"); + strcpy(sout, fmt); + return sout; + } + if (number <-4294967040.0) + { + strcpy(fmt, "ovf"); + strcpy(sout, fmt); + return sout; + } + + // Handle negative numbers + if (number < 0.0) + { + // n += print('-'); + fmt[n] = '-'; + n++; + number = -number; + } + + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + fmt[n] = '.'; + n++; +// n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + unsigned int toPrint = (unsigned int)remainder; +// n += print(toPrint); + n+= printNumber((unsigned long)toPrint, 10, &fmt[n]); + remainder -= toPrint; + } + + if(width_local < 0) + { + /* left */ + width_local = -width_local; + if(n <= width_local) + { + n = width_local; + } + strncpy((char *)sout, (const char *)fmt, (size_t)n); + *(sout+n) = '\0'; + } + else + { + /* right */ + signed short offset = 0; + memset((void *)sout, ' ', (size_t)width_local); + if(n <= width_local) + { + offset = width_local - n; + strncpy((char *)sout+offset, (const char *)fmt, (size_t)n); + *(sout+n+offset) = '\0'; + } + else + { + strncpy((char *)sout, (const char *)fmt, (size_t)n); + *(sout+n) = '\0'; + } + } + return sout; +} +#endif diff --git a/cores/rl78g22/itoa.c b/cores/rl78g22/itoa.c new file mode 100644 index 0000000..fb468dc --- /dev/null +++ b/cores/rl78g22/itoa.c @@ -0,0 +1,125 @@ +/* + Copyright (c) 2014 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +char* ltoa( long value, char *string, int radix ) +{ + char tmp[33]; + char *tp = tmp; + long i; + unsigned long v; + int sign; + char *sp; + + if ( string == NULL ) + { + return 0 ; + } + + if (radix > 36 || radix <= 1) + { + return 0 ; + } + + sign = (radix == 10 && value < 0); + if (sign) + { + v = -value; + } + else + { + v = (unsigned long)value; + } + + while (v || tp == tmp) + { + i = v % radix; + v = v / radix; + if (i < 10) + *tp++ = i+'0'; + else + *tp++ = i + 'a' - 10; + } + + sp = string; + + if (sign) + *sp++ = '-'; + while (tp > tmp) + *sp++ = *--tp; + *sp = 0; + + return string; +} + +char* ultoa( unsigned long value, char *string, int radix ) +{ + char tmp[33]; + char *tp = tmp; + long i; + unsigned long v = value; + char *sp; + + if ( string == NULL ) + { + return 0; + } + + if (radix > 36 || radix <= 1) + { + return 0; + } + + while (v || tp == tmp) + { + i = v % radix; + v = v / radix; + if (i < 10) + *tp++ = i+'0'; + else + *tp++ = i + 'a' - 10; + } + + sp = string; + + + while (tp > tmp) + *sp++ = *--tp; + *sp = 0; + + return string; +} + +char* itoa( int value, char *string, int radix ) +{ + return ltoa( value, string, radix ) ; +} + +char* utoa( unsigned int value, char *string, int radix ) +{ + return ultoa( value, string, radix ) ; +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/cores/rl78g22/main.cpp b/cores/rl78g22/main.cpp index d4cebfa..f87525a 100644 --- a/cores/rl78g22/main.cpp +++ b/cores/rl78g22/main.cpp @@ -1,140 +1,130 @@ -/* - main.cpp - Main loop for Arduino sketches - Copyright (c) 2005-2013 Arduino Team. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include -#include "utilities.h" -extern "C" { - #include "r_smc_entry.h" -} - -extern "C" { -// #include "Config_ITL013.h" -} - -/* This declaration is used to force the constant in - * r_cg_vect_table.c to be linked to the static library (*.a). */ -extern const unsigned char Option_Bytes[]; -void * p_force_link = (void * )Option_Bytes; - -int main(void) -{ -/******************************************************/ - interrupts(); /* Enable Interrupt */ - _readResetFlag(); /* Read causes of reset */ - -/* Start Interval Timer */ - R_Config_ITL000_Create(); /* Create 1ms Interval Timer */ - R_Config_ITL000_Start(); /* Start 1ms Interval Timer */ - R_ITL_Start_Interrupt(); /* Start ITL Interrupt */ - - R_Config_TAU0_6_Micros_Create(); - R_Config_TAU0_6_Micros_Start(); - - /* Start RTC Timer */ -// R_Config_RTC_Start(); /*//KAD Start RTC Timer */ - -/* Power Off unused Peripheral */ -/* SERIAL ARRAY UNIT (SAU) */ -#if !defined(UART_CHANNEL) & (UART1_CHANNEL == 0) & !defined(CSI_CHANNEL) - R_SAU0_Set_Reset(); - R_SAU0_Set_PowerOff(); -#endif -#if !defined(UART1_CHANNEL) || UART1_CHANNEL == 0 - R_Config_UART1_Stop(); -#endif -// 2023/03/02 temporary removal by KAD -// #if !defined(CSI_CHANNEL) -// R_Config_CSI20_Stop(); -// #endif -#if !defined(UART2_CHANNEL) || (UART2_CHANNEL == 0) - R_SAU1_Set_Reset(); - R_SAU1_Set_PowerOff(); -#endif - -/* IICA UNIT(IICA*) */ -#if !defined(IIC_CHANNEL0) | (IIC_CHANNEL0!=0) - R_IICA0_Set_Reset(); - R_IICA0_Set_PowerOff(); -#endif -#if (IIC_CHANNEL1!=1) -// 2023/02/28 comment out by KAD -// R_IICA1_Set_Reset(); -// R_IICA1_Set_PowerOff(); -#endif - -/* RTC */ -#if !defined(RTC_ON) | (RTC_ON!=0) - R_RTC_Set_PowerOff(); -#endif - -#if WDT_EN==1 - R_Config_WDT_Start(); -#endif - - setPowerManagementMode(PM_NORMAL_MODE); - - SOE0 &= 0xf3; - SO0 |= 0x08; -// 2022/11/18 added by KAD for safety reason for G22, These pins are not available -#if defined(G22_FPB) - /* P26,P25,P24,P23,P22 */ - PMCA2 &= 0x83; /* 0 : Use Digital IO */ - PMCT2 &= 0x83; /* 0 : Use Digital IO */ - PM2 &= 0x83; /* 0 : Use Output Mode */ - P2 &= 0x83; /* 0 : Use Output Low */ - - /* P30 */ - PMCT3 &= 0xFE; /* 0 : Use Digital IO */ - PM3 &= 0xFE; /* 0 : Use Output Mode */ - P3 &= 0xFE; /* 0 : Use Output Low */ - -#endif -/******************************************************/ - - setup(); - - for (;;) { - loop(); -// 2023/02/22 -// execCyclicHandler(); - - } - return 0; -} - -/** - * Finish Function - * - * RLduino78 Framework finish - * * - * @return None - * - * @attention No return - ***************************************************************************/ -#include - -void abort(void) -{ - for(;;); -} - -void exit(int) __attribute__ ((weak, alias ("abort"))); - -#include - +/* + main.cpp - Main loop for Arduino sketches + Copyright (c) 2005-2013 Arduino Team. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include +#include "utilities.h" +extern "C" { + #include "r_smc_entry.h" +} + +extern "C" { + +} + +/* This declaration is used to force the constant in + * r_cg_vect_table.c to be linked to the static library (*.a). */ +extern const unsigned char Option_Bytes[]; +void * p_force_link = (void * )Option_Bytes; + +int main(void) +{ +/******************************************************/ + interrupts(); /* Enable Interrupt */ + _readResetFlag(); /* Read causes of reset */ + +/* Start Interval Timer */ + R_Config_ITL000_Create(); /* Create 1ms Interval Timer */ + R_Config_ITL000_Start(); /* Start 1ms Interval Timer */ + R_ITL_Start_Interrupt(); /* Start ITL Interrupt */ + + R_Config_TAU0_6_Micros_Create(); + R_Config_TAU0_6_Micros_Start(); + + /* Start RTC Timer */ +// R_Config_RTC_Start(); /*//KAD Start RTC Timer */ + R_Config_ITL013_SetCompareMatch(0x20, 0x0); + R_Config_ITL013_Start(); + +/* Power Off unused Peripheral */ +/* SERIAL ARRAY UNIT (SAU) */ +#if !defined(UART_CHANNEL) & (UART1_CHANNEL == 0) & !defined(CSI_CHANNEL) + R_SAU0_Set_Reset(); + R_SAU0_Set_PowerOff(); +#endif +#if !defined(UART1_CHANNEL) || UART1_CHANNEL == 0 + R_Config_UART1_Stop(); +#endif + +#if !defined(UART2_CHANNEL) || (UART2_CHANNEL == 0) + R_SAU1_Set_Reset(); + R_SAU1_Set_PowerOff(); +#endif + +/* IICA UNIT(IICA*) */ +#if !defined(IIC_CHANNEL0) | (IIC_CHANNEL0!=0) + R_IICA0_Set_Reset(); + R_IICA0_Set_PowerOff(); +#endif +/* RTC */ +#if !defined(RTC_ON) | (RTC_ON!=0) + R_RTC_Set_PowerOff(); +#endif + +#if WDT_EN==1 + R_Config_WDT_Start(); +#endif + + setPowerManagementMode(PM_NORMAL_MODE); + + SOE0 &= 0xf3; + SO0 |= 0x08; +// added for safety reason for G22, These pins are not available +#if defined(G22_FPB) + /* P26,P25,P24,P23,P22 */ + PMCA2 &= 0x83; /* 0 : Use Digital IO */ + PMCT2 &= 0x83; /* 0 : Use Digital IO */ + PM2 &= 0x83; /* 0 : Use Output Mode */ + P2 &= 0x83; /* 0 : Use Output Low */ + + /* P30 */ + PMCT3 &= 0xFE; /* 0 : Use Digital IO */ + PM3 &= 0xFE; /* 0 : Use Output Mode */ + P3 &= 0xFE; /* 0 : Use Output Low */ + +#endif +/******************************************************/ + + setup(); + + for (;;) { + loop(); + } + return 0; +} + +/** + * Finish Function + * + * RLduino78 Framework finish + * * + * @return None + * + * @attention No return + ***************************************************************************/ +#include + +void abort(void) +{ + for(;;); +} + +void exit(int) __attribute__ ((weak, alias ("abort"))); + +#include + diff --git a/cores/rl78g22/smc_gen/Config_ADC/Config_ADC.c b/cores/rl78g22/smc_gen/Config_ADC/Config_ADC.c index e43c195..0f55fa3 100644 --- a/cores/rl78g22/smc_gen/Config_ADC/Config_ADC.c +++ b/cores/rl78g22/smc_gen/Config_ADC/Config_ADC.c @@ -1,377 +1,373 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_ADC.c -* Version : 1.0.2 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_ADC. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_ADC.h" -/* Start user code for include. Do not edit comment generated here */ -#include -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_ADC_Create -* Description : This function initializes the ADC module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ADC_Create(void) -{ - ADCEN = 1U; /* supply AD clock */ - ADMK = 1U; /* disable INTAD interrupt */ - ADIF = 0U; /* clear INTAD interrupt flag */ - /* Set INTAD priority */ - ADPR1 = 1U; - ADPR0 = 1U; - /* Set ANI2 pin */ - PMCA2 |= 0x04U; - PMCT2 &= 0xFBU; - PM2 |= 0x04U; - ADM0 = _00_AD_OPERMODE_SELECT | _08_AD_CONVERSION_CLOCK_32 | _00_AD_TIME_MODE_NORMAL_1; - ADM1 = _00_AD_TRIGGER_SOFTWARE | _00_AD_CONVMODE_CONSELECT; - ADM2 = _00_AD_NEGATIVE_VSS | _00_AD_AREA_MODE_1 | _00_AD_RESOLUTION_10BIT; - ADUL = _FF_AD_ADUL_VALUE; - ADLL = _00_AD_ADLL_VALUE; - ADS = _02_AD_INPUT_CHANNEL_2; - ADM2 &= _3F_AD_POSITIVE_CLEAR; /* clear ADREFP1 and ADREFP0 */ - ADM2 |= _00_AD_POSITIVE_VDD; /* set the reference voltage */ - - R_Config_ADC_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ADC_Start -* Description : This function starts the AD converter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ADC_Start(void) -{ - ADIF = 0U; /* clear INTAD interrupt flag */ - ADMK = 0U; /* enable INTAD interrupt */ - ADCS = 1U; /* enables conversion operation */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ADC_Stop -* Description : This function stops the AD converter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ADC_Stop(void) -{ - ADCS = 0U; /* stops conversion operation */ - ADMK = 1U; /* disables INTAD interrupt */ - ADIF = 0U; /* clear INTAD interrupt flag */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ADC_Set_OperationOn -* Description : This function enables AD voltage comparator operation. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ADC_Set_OperationOn(void) -{ - volatile uint16_t w_count; - - ADCE = 1U; /* enable AD comparator */ - - /* Reference voltage stability wait time (B) 1us */ - for (w_count = 0U; w_count < AD_WAITTIME_B; w_count++ ) - { - NOP(); - } -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ADC_Set_OperationOff -* Description : This function disables AD voltage comparator operation. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ADC_Set_OperationOff(void) -{ - ADCE = 0U; /* disable AD comparator */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ADC_Set_SnoozeOn -* Description : This function enables AD wakeup function. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ADC_Set_SnoozeOn(void) -{ - AWC = 1U; /* use wakeup function */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ADC_Set_SnoozeOff -* Description : This function disables AD wakeup function. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ADC_Set_SnoozeOff(void) -{ - AWC = 0U; /* stop wakeup function */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ADC_Get_Result_10bit -* Description : This function returns the high 10 bits conversion result in the buffer. -* Arguments : buffer - -* the address where to write the conversion result -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ADC_Get_Result_10bit(uint16_t * const buffer) -{ -// 2023/02/22 in case of G23 -// *buffer = (uint16_t)(ADCR0 >> 6U); - *buffer = (uint16_t)(ADCR >> 6U); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ADC_Set_ADChannel -* Description : This function selects analog input channel. -* Arguments : channel - -* analog input channel -* Return Value : status - -* MD_OK or MD_ARGERROR -***********************************************************************************************************************/ -MD_STATUS R_Config_ADC_Set_ADChannel(e_ad_channel_t channel) -{ - MD_STATUS status = MD_OK; - - if (((channel > ADCHANNEL7) && (channel < ADCHANNEL18)) || ((channel > ADCHANNEL19) && (channel != ADTSCAP) - && (channel < ADTEMPERSENSOR0)) || (channel > ADINTERREFVOLT)) - { - status = MD_ARGERROR; - } - else - { - ADS = (uint8_t)channel; - } - - return (status); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ADC_Set_TestChannel -* Description : This function sets test function. -* Arguments : channel - -* sets test channel -* Return Value : status - -* MD_OK or MD_ARGERROR -***********************************************************************************************************************/ -MD_STATUS R_Config_ADC_Set_TestChannel(e_test_channel_t channel) -{ - MD_STATUS status = MD_OK; - - if ((1U == channel) || (4U <= channel)) - { - status = MD_ARGERROR; - } - else - { - ADTES = (uint8_t)channel; - } - - return (status); -} - -/* Start user code for adding. Do not edit comment generated here */ -/*********************************************************************************************************************** -* Function Name: R_Config_ADC_Set_Reference -* Description : This function configures the reference voltage used for analog input. -* Arguments : mode - -* DEFAULT: use VDD as VREF(+) -* INTERNAL: use internal voltage as VREF(+) -* EXTERNAL: use AVREFP as VREF(+) -* Return Value : None -***********************************************************************************************************************/ - -MD_STATUS R_Config_ADC_Set_Reference(uint8_t mode) -{ - MD_STATUS status = MD_OK; - volatile uint16_t w_count; - - if (DEFAULT == mode) - { - ADM2 |= _00_AD_POSITIVE_VDD; /* use VDD as VREF(+) */ - } - else if (INTERNAL == mode) - { - ADM0 |= _04_AD_TIME_MODE_LOWVOLTAGE_1; - ADM2 |= _01_AD_RESOLUTION_8BIT; - ADM2 |= _C0_AD_POSITIVE_DISCHARGE; /* Discharge */ - - /* Reference voltage discharge time 1us */ - for (w_count = 0U; w_count < AD_WAITTIME_DISCHARGE; w_count++) - { - NOP(); - } - - ADM2 &= _3F_AD_POSITIVE_CLEAR; /* clear ADREFP1 and ADREFP0 */ - ADM2 |= _80_AD_POSITIVE_INTERVOLT; /* set the reference voltage */ - - /* Internal reference voltage is selected, Reference voltage stability wait time(A), 5us */ - for (w_count = 0U; w_count < AD_WAITTIME_A; w_count++) - { - NOP(); - } - - ADM2 |= _80_AD_POSITIVE_INTERVOLT; /* use internal voltage as VREF(+) */ - - } - else //EXTERNAL - { - ADM2 |= _40_AD_POSITIVE_AVREFP; /* use AVREFP as VREF(+) */ - } - return status; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ADC_Get_Result_8bit -* Description : This function returns the high 8 bits conversion result in the buffer. -* Arguments : buffer - -* the address where to write the conversion result -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ADC_Get_Result_8bit(uint8_t * const buffer) -{ -// 2022/11/01 KAD 2023/02/22 need confirmation -// *buffer = ADCR0H; - *buffer = ADCRH; -} - -void R_Config_ADC_Snooze_Start(void) -{ - ADIF = 0U; /* clear INTAD interrupt flag */ - ADMK = 0U; /* enable INTAD interrupt */ - ADCE = 1U; /* enable AD comparator */ -} - -void R_Config_ADC_Snooze_Stop(void) -{ - ADIF = 0U; /* clear INTAD interrupt flag */ - ADMK = 1U; /* disable INTAD interrupt */ -} - -void R_Config_ADC_Set_ModeTrigger(uint8_t mode) -{ - if (PM_SNOOZE_MODE == mode) - { - ADM1 = 0xE2; - } - else - { - ADM1 = 0x23; - } -} - -void R_Config_ADC_Set_ComparisonLimit(uint8_t upper, uint8_t lower) -{ - ADUL = upper; - ADLL = lower; -} - - -//���x�Z���T�o�͂̃��W�X�^�̐ݒ� -void R_Config_ADC_Set_TemperatureSensor(void) -{ - ADCEN = 1U; /* supply AD clock */ - ADMK = 1U; /* disable INTAD interrupt */ - ADIF = 0U; /* clear INTAD interrupt flag */ - /* Set INTAD priority */ - ADPR1 = 1U; - ADPR0 = 1U; - ADM0 = _00_AD_OPERMODE_SELECT | _08_AD_CONVERSION_CLOCK_32 | _02_AD_TIME_MODE_NORMAL_2; - ADM1 = _00_AD_TRIGGER_SOFTWARE | _20_AD_CONVMODE_ONESELECT; - ADM2 = _00_AD_NEGATIVE_VSS | _00_AD_AREA_MODE_1 | _00_AD_RESOLUTION_10BIT; - ADUL = _FF_AD_ADUL_VALUE; - ADLL = _00_AD_ADLL_VALUE; - - ADS = _80_AD_INPUT_TEMPERSENSOR_0; - - ADM2 &= _3F_AD_POSITIVE_CLEAR; /* clear ADREFP1 and ADREFP0 */ - ADM2 |= _00_AD_POSITIVE_VDD; /* set the reference voltage */ - - ADCE = 1U; - - /* Reference voltage stability wait time (B), 1us+2fAD */ - volatile uint16_t w_count; - for (w_count = 0U; w_count < AD_WAITTIME_B; w_count++) - { - NOP(); - } - -} - -void R_Config_ADC_Set_InternalReferenceVoltage(void) -{ - ADCEN = 1U; /* supply AD clock */ - ADMK = 1U; /* disable INTAD interrupt */ - ADIF = 0U; /* clear INTAD interrupt flag */ - /* Set INTAD priority */ - ADPR1 = 1U; - ADPR0 = 1U; - ADM0 = _00_AD_OPERMODE_SELECT | _10_AD_CONVERSION_CLOCK_16 | _02_AD_TIME_MODE_NORMAL_2; - ADM1 = _00_AD_TRIGGER_SOFTWARE | _20_AD_CONVMODE_ONESELECT; - ADM2 = _00_AD_NEGATIVE_VSS | _00_AD_AREA_MODE_1 | _00_AD_RESOLUTION_10BIT; - ADUL = _FF_AD_ADUL_VALUE; - ADLL = _00_AD_ADLL_VALUE; - - ADS = _81_AD_INPUT_INTERREFVOLT; - - ADM2 &= _3F_AD_POSITIVE_CLEAR; /* clear ADREFP1 and ADREFP0 */ - ADM2 |= _00_AD_POSITIVE_VDD; /* set the reference voltage */ - - ADCE = 1U; - - /* Reference voltage stability wait time (B), 1us+2fAD */ - volatile uint16_t w_count; - for (w_count = 0U; w_count < AD_WAITTIME_B; w_count++) - { - NOP(); - } -} -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_ADC.c +* Version : 1.0.2 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_ADC. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_ADC.h" +/* Start user code for include. Do not edit comment generated here */ +#include +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_ADC_Create +* Description : This function initializes the ADC module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ADC_Create(void) +{ + ADCEN = 1U; /* supply AD clock */ + ADMK = 1U; /* disable INTAD interrupt */ + ADIF = 0U; /* clear INTAD interrupt flag */ + /* Set INTAD priority */ + ADPR1 = 1U; + ADPR0 = 1U; + /* Set ANI2 pin */ + PMCA2 |= 0x04U; + PMCT2 &= 0xFBU; + PM2 |= 0x04U; + ADM0 = _00_AD_OPERMODE_SELECT | _08_AD_CONVERSION_CLOCK_32 | _00_AD_TIME_MODE_NORMAL_1; + ADM1 = _00_AD_TRIGGER_SOFTWARE | _00_AD_CONVMODE_CONSELECT; + ADM2 = _00_AD_NEGATIVE_VSS | _00_AD_AREA_MODE_1 | _00_AD_RESOLUTION_10BIT; + ADUL = _FF_AD_ADUL_VALUE; + ADLL = _00_AD_ADLL_VALUE; + ADS = _02_AD_INPUT_CHANNEL_2; + ADM2 &= _3F_AD_POSITIVE_CLEAR; /* clear ADREFP1 and ADREFP0 */ + ADM2 |= _00_AD_POSITIVE_VDD; /* set the reference voltage */ + + R_Config_ADC_Create_UserInit(); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ADC_Start +* Description : This function starts the AD converter. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ADC_Start(void) +{ + ADIF = 0U; /* clear INTAD interrupt flag */ + ADMK = 0U; /* enable INTAD interrupt */ + ADCS = 1U; /* enables conversion operation */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ADC_Stop +* Description : This function stops the AD converter. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ADC_Stop(void) +{ + ADCS = 0U; /* stops conversion operation */ + ADMK = 1U; /* disables INTAD interrupt */ + ADIF = 0U; /* clear INTAD interrupt flag */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ADC_Set_OperationOn +* Description : This function enables AD voltage comparator operation. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ADC_Set_OperationOn(void) +{ + volatile uint16_t w_count; + + ADCE = 1U; /* enable AD comparator */ + + /* Reference voltage stability wait time (B) 1us */ + for (w_count = 0U; w_count < AD_WAITTIME_B; w_count++ ) + { + NOP(); + } +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ADC_Set_OperationOff +* Description : This function disables AD voltage comparator operation. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ADC_Set_OperationOff(void) +{ + ADCE = 0U; /* disable AD comparator */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ADC_Set_SnoozeOn +* Description : This function enables AD wakeup function. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ADC_Set_SnoozeOn(void) +{ + AWC = 1U; /* use wakeup function */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ADC_Set_SnoozeOff +* Description : This function disables AD wakeup function. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ADC_Set_SnoozeOff(void) +{ + AWC = 0U; /* stop wakeup function */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ADC_Get_Result_10bit +* Description : This function returns the high 10 bits conversion result in the buffer. +* Arguments : buffer - +* the address where to write the conversion result +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ADC_Get_Result_10bit(uint16_t * const buffer) +{ + *buffer = (uint16_t)(ADCR >> 6U); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ADC_Set_ADChannel +* Description : This function selects analog input channel. +* Arguments : channel - +* analog input channel +* Return Value : status - +* MD_OK or MD_ARGERROR +***********************************************************************************************************************/ +MD_STATUS R_Config_ADC_Set_ADChannel(e_ad_channel_t channel) +{ + MD_STATUS status = MD_OK; + + if (((channel > ADCHANNEL7) && (channel < ADCHANNEL18)) || ((channel > ADCHANNEL19) && (channel != ADTSCAP) + && (channel < ADTEMPERSENSOR0)) || (channel > ADINTERREFVOLT)) + { + status = MD_ARGERROR; + } + else + { + ADS = (uint8_t)channel; + } + + return (status); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ADC_Set_TestChannel +* Description : This function sets test function. +* Arguments : channel - +* sets test channel +* Return Value : status - +* MD_OK or MD_ARGERROR +***********************************************************************************************************************/ +MD_STATUS R_Config_ADC_Set_TestChannel(e_test_channel_t channel) +{ + MD_STATUS status = MD_OK; + + if ((1U == channel) || (4U <= channel)) + { + status = MD_ARGERROR; + } + else + { + ADTES = (uint8_t)channel; + } + + return (status); +} + +/* Start user code for adding. Do not edit comment generated here */ +/*********************************************************************************************************************** +* Function Name: R_Config_ADC_Set_Reference +* Description : This function configures the reference voltage used for analog input. +* Arguments : mode - +* DEFAULT: use VDD as VREF(+) +* INTERNAL: use internal voltage as VREF(+) +* EXTERNAL: use AVREFP as VREF(+) +* Return Value : None +***********************************************************************************************************************/ + +MD_STATUS R_Config_ADC_Set_Reference(uint8_t mode) +{ + MD_STATUS status = MD_OK; + volatile uint16_t w_count; + + if (DEFAULT == mode) + { + ADM2 |= _00_AD_POSITIVE_VDD; /* use VDD as VREF(+) */ + } + else if (INTERNAL == mode) + { + ADM0 |= _04_AD_TIME_MODE_LOWVOLTAGE_1; + ADM2 |= _01_AD_RESOLUTION_8BIT; + ADM2 |= _C0_AD_POSITIVE_DISCHARGE; /* Discharge */ + + /* Reference voltage discharge time 1us */ + for (w_count = 0U; w_count < AD_WAITTIME_DISCHARGE; w_count++) + { + NOP(); + } + + ADM2 &= _3F_AD_POSITIVE_CLEAR; /* clear ADREFP1 and ADREFP0 */ + ADM2 |= _80_AD_POSITIVE_INTERVOLT; /* set the reference voltage */ + + /* Internal reference voltage is selected, Reference voltage stability wait time(A), 5us */ + for (w_count = 0U; w_count < AD_WAITTIME_A; w_count++) + { + NOP(); + } + + ADM2 |= _80_AD_POSITIVE_INTERVOLT; /* use internal voltage as VREF(+) */ + + } + else //EXTERNAL + { + ADM2 |= _40_AD_POSITIVE_AVREFP; /* use AVREFP as VREF(+) */ + } + return status; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ADC_Get_Result_8bit +* Description : This function returns the high 8 bits conversion result in the buffer. +* Arguments : buffer - +* the address where to write the conversion result +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ADC_Get_Result_8bit(uint8_t * const buffer) +{ + *buffer = ADCRH; +} + +void R_Config_ADC_Snooze_Start(void) +{ + ADIF = 0U; /* clear INTAD interrupt flag */ + ADMK = 0U; /* enable INTAD interrupt */ + ADCE = 1U; /* enable AD comparator */ +} + +void R_Config_ADC_Snooze_Stop(void) +{ + ADIF = 0U; /* clear INTAD interrupt flag */ + ADMK = 1U; /* disable INTAD interrupt */ +} + +void R_Config_ADC_Set_ModeTrigger(uint8_t mode) +{ + if (PM_SNOOZE_MODE == mode) + { + ADM1 = 0xE2; + } + else + { + ADM1 = 0x23; + } +} + +void R_Config_ADC_Set_ComparisonLimit(uint8_t upper, uint8_t lower) +{ + ADUL = upper; + ADLL = lower; +} + + +// 温度センサ出力のレジスタの設定 +void R_Config_ADC_Set_TemperatureSensor(void) +{ + ADCEN = 1U; /* supply AD clock */ + ADMK = 1U; /* disable INTAD interrupt */ + ADIF = 0U; /* clear INTAD interrupt flag */ + /* Set INTAD priority */ + ADPR1 = 1U; + ADPR0 = 1U; + ADM0 = _00_AD_OPERMODE_SELECT | _08_AD_CONVERSION_CLOCK_32 | _02_AD_TIME_MODE_NORMAL_2; + ADM1 = _00_AD_TRIGGER_SOFTWARE | _20_AD_CONVMODE_ONESELECT; + ADM2 = _00_AD_NEGATIVE_VSS | _00_AD_AREA_MODE_1 | _00_AD_RESOLUTION_10BIT; + ADUL = _FF_AD_ADUL_VALUE; + ADLL = _00_AD_ADLL_VALUE; + + ADS = _80_AD_INPUT_TEMPERSENSOR_0; + + ADM2 &= _3F_AD_POSITIVE_CLEAR; /* clear ADREFP1 and ADREFP0 */ + ADM2 |= _00_AD_POSITIVE_VDD; /* set the reference voltage */ + + ADCE = 1U; + + /* Reference voltage stability wait time (B), 1us+2fAD */ + volatile uint16_t w_count; + for (w_count = 0U; w_count < AD_WAITTIME_B; w_count++) + { + NOP(); + } + +} + +void R_Config_ADC_Set_InternalReferenceVoltage(void) +{ + ADCEN = 1U; /* supply AD clock */ + ADMK = 1U; /* disable INTAD interrupt */ + ADIF = 0U; /* clear INTAD interrupt flag */ + /* Set INTAD priority */ + ADPR1 = 1U; + ADPR0 = 1U; + ADM0 = _00_AD_OPERMODE_SELECT | _10_AD_CONVERSION_CLOCK_16 | _02_AD_TIME_MODE_NORMAL_2; + ADM1 = _00_AD_TRIGGER_SOFTWARE | _20_AD_CONVMODE_ONESELECT; + ADM2 = _00_AD_NEGATIVE_VSS | _00_AD_AREA_MODE_1 | _00_AD_RESOLUTION_10BIT; + ADUL = _FF_AD_ADUL_VALUE; + ADLL = _00_AD_ADLL_VALUE; + + ADS = _81_AD_INPUT_INTERREFVOLT; + + ADM2 &= _3F_AD_POSITIVE_CLEAR; /* clear ADREFP1 and ADREFP0 */ + ADM2 |= _00_AD_POSITIVE_VDD; /* set the reference voltage */ + + ADCE = 1U; + + /* Reference voltage stability wait time (B), 1us+2fAD */ + volatile uint16_t w_count; + for (w_count = 0U; w_count < AD_WAITTIME_B; w_count++) + { + NOP(); + } +} +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_ADC/Config_ADC.h b/cores/rl78g22/smc_gen/Config_ADC/Config_ADC.h index 6c2f047..f35e1e7 100644 --- a/cores/rl78g22/smc_gen/Config_ADC/Config_ADC.h +++ b/cores/rl78g22/smc_gen/Config_ADC/Config_ADC.h @@ -1,93 +1,93 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_ADC.h -* Version : 1.0.2 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_ADC. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_ADC_H -#define CFG_Config_ADC_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_ad.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -/* Upper bound (ADUL) value */ -#define _FF_AD_ADUL_VALUE (0xFFU) -/* Lower bound (ADLL) value */ -#define _00_AD_ADLL_VALUE (0x00U) -#define AD_WAITTIME_B (2U) - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ -typedef enum -{ - ADCHANNEL0, ADCHANNEL1, ADCHANNEL2, ADCHANNEL3, ADCHANNEL4, ADCHANNEL5, ADCHANNEL6, ADCHANNEL7, - ADCHANNEL18 = 18U, ADCHANNEL19, ADTSCAP = 30U, ADTEMPERSENSOR0 = 128U, ADINTERREFVOLT -} e_ad_channel_t; -typedef enum -{ - ADNORMALINPUT, - ADAVREFM = 2U, - ADAVREFP -} e_test_channel_t; - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_ADC_Create (void); -void R_Config_ADC_Start (void); -void R_Config_ADC_Stop (void); -void R_Config_ADC_Set_OperationOn (void); -void R_Config_ADC_Set_OperationOff (void); -void R_Config_ADC_Set_SnoozeOn (void); -void R_Config_ADC_Set_SnoozeOff (void); -void R_Config_ADC_Get_Result_10bit (uint16_t * const buffer); -MD_STATUS R_Config_ADC_Set_ADChannel (e_ad_channel_t channel); -MD_STATUS R_Config_ADC_Set_TestChannel (e_test_channel_t channel); -void R_Config_ADC_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* 1006 Nhu add */ -#define AD_WAITTIME_DISCHARGE (2U) -#define AD_WAITTIME_A (13U) - -void R_Config_ADC_Get_Result_8bit(uint8_t * const buffer); -MD_STATUS R_Config_ADC_Set_Reference(uint8_t mode); -void R_Config_ADC_Set_ModeTrigger(uint8_t mode); -void R_Config_ADC_Set_ComparisonLimit(uint8_t upper, uint8_t lower); -void R_Config_ADC_Snooze_Start(void); -void R_Config_ADC_Snooze_Stop(void); -void R_Config_ADC_Set_TemperatureSensor(void); -void R_Config_ADC_Set_InternalReferenceVoltage(void); - -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_ADC.h +* Version : 1.0.2 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_ADC. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef CFG_Config_ADC_H +#define CFG_Config_ADC_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_ad.h" + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ +/* Upper bound (ADUL) value */ +#define _FF_AD_ADUL_VALUE (0xFFU) +/* Lower bound (ADLL) value */ +#define _00_AD_ADLL_VALUE (0x00U) +#define AD_WAITTIME_B (2U) + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ +typedef enum +{ + ADCHANNEL0, ADCHANNEL1, ADCHANNEL2, ADCHANNEL3, ADCHANNEL4, ADCHANNEL5, ADCHANNEL6, ADCHANNEL7, + ADCHANNEL18 = 18U, ADCHANNEL19, ADTSCAP = 30U, ADTEMPERSENSOR0 = 128U, ADINTERREFVOLT +} e_ad_channel_t; +typedef enum +{ + ADNORMALINPUT, + ADAVREFM = 2U, + ADAVREFP +} e_test_channel_t; + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_Config_ADC_Create (void); +void R_Config_ADC_Start (void); +void R_Config_ADC_Stop (void); +void R_Config_ADC_Set_OperationOn (void); +void R_Config_ADC_Set_OperationOff (void); +void R_Config_ADC_Set_SnoozeOn (void); +void R_Config_ADC_Set_SnoozeOff (void); +void R_Config_ADC_Get_Result_10bit (uint16_t * const buffer); +MD_STATUS R_Config_ADC_Set_ADChannel (e_ad_channel_t channel); +MD_STATUS R_Config_ADC_Set_TestChannel (e_test_channel_t channel); +void R_Config_ADC_Create_UserInit (void); +/* Start user code for function. Do not edit comment generated here */ +/* 1006 Nhu add */ +#define AD_WAITTIME_DISCHARGE (2U) +#define AD_WAITTIME_A (13U) + +void R_Config_ADC_Get_Result_8bit(uint8_t * const buffer); +MD_STATUS R_Config_ADC_Set_Reference(uint8_t mode); +void R_Config_ADC_Set_ModeTrigger(uint8_t mode); +void R_Config_ADC_Set_ComparisonLimit(uint8_t upper, uint8_t lower); +void R_Config_ADC_Snooze_Start(void); +void R_Config_ADC_Snooze_Stop(void); +void R_Config_ADC_Set_TemperatureSensor(void); +void R_Config_ADC_Set_InternalReferenceVoltage(void); + +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/Config_ADC/Config_ADC_user.c b/cores/rl78g22/smc_gen/Config_ADC/Config_ADC_user.c index 8d58192..6eb7f73 100644 --- a/cores/rl78g22/smc_gen/Config_ADC/Config_ADC_user.c +++ b/cores/rl78g22/smc_gen/Config_ADC/Config_ADC_user.c @@ -1,76 +1,76 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_ADC_user.c -* Version : 1.0.2 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_ADC. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_ADC.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -uint8_t g_adc_int_flg=0; -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_ADC_Create_UserInit -* Description : This function adds user code after initializing the AD converter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ADC_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_ADC_interrupt -* Description : This function is INTAD interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_ADC_interrupt(void) -{ - /* Start user code for r_Config_ADC_interrupt. Do not edit comment generated here */ - g_adc_int_flg=1; - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_ADC_user.c +* Version : 1.0.2 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_ADC. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_ADC.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +uint8_t g_adc_int_flg=0; +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_ADC_Create_UserInit +* Description : This function adds user code after initializing the AD converter. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ADC_Create_UserInit(void) +{ + /* Start user code for user init. Do not edit comment generated here */ + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_ADC_interrupt +* Description : This function is INTAD interrupt service routine. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_ADC_interrupt(void) +{ + /* Start user code for r_Config_ADC_interrupt. Do not edit comment generated here */ + g_adc_int_flg=1; + /* End user code. Do not edit comment generated here */ +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_CSI20/Config_CSI20.c b/cores/rl78g22/smc_gen/Config_CSI20/Config_CSI20.c index f3097b3..e2912f3 100644 --- a/cores/rl78g22/smc_gen/Config_CSI20/Config_CSI20.c +++ b/cores/rl78g22/smc_gen/Config_CSI20/Config_CSI20.c @@ -1,289 +1,306 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2021, 2022 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_CSI20.c -* Component Version: 1.3.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_CSI20. -* Creation Date : -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_CSI20.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -volatile uint8_t * gp_csi20_tx_address; /* csi20 send buffer address */ -volatile uint16_t g_csi20_tx_count; /* csi20 send data count */ -volatile uint8_t * gp_csi20_rx_address; /* csi20 receive buffer address */ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_CSI20_Create -* Description : This function initializes the CSI20 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_CSI20_Create(void) -{ - SPS1 &= _00F0_SAU_CK00_CLEAR; - SPS1 |= _0000_SAU_CK00_FCLK_0; - /* Stop channel 0 */ - ST1 |= _0001_SAU_CH0_STOP_TRG_ON; - /* Mask channel 0 interrupt */ - CSIMK20 = 1U; /* disable INTCSI20 interrupt */ - CSIIF20 = 0U; /* clear INTCSI20 interrupt flag */ - /* Set INTCSI20 low priority */ - CSIPR120 = 1U; - CSIPR020 = 1U; - SIR10 = _0002_SAU_SIRMN_PECTMN | _0001_SAU_SIRMN_OVCTMN; /* clear error flag */ - SMR10 = _0020_SAU_SMRMN_INITIALVALUE | _0000_SAU_CLOCK_SELECT_CK00 | _0000_SAU_CLOCK_MODE_CKS | - _0000_SAU_TRIGGER_SOFTWARE | _0000_SAU_MODE_CSI | _0000_SAU_TRANSFER_END; - SCR10 = _0004_SAU_SCRMN_INITIALVALUE | _C000_SAU_RECEPTION_TRANSMISSION | _0000_SAU_TIMING_1 | _0080_SAU_LSB | - _0003_SAU_LENGTH_8; - SDR10 = _CE00_SAU1_CH0_BAUDRATE_DIVISOR; - SO1 |= _0100_SAU_CH0_CLOCK_OUTPUT_1; /* CSI20 clock initial level */ - SO1 &= (uint16_t)~_0001_SAU_CH0_DATA_OUTPUT_1; /* CSI20 SO initial level */ - SOE1 |= _0001_SAU_CH0_OUTPUT_ENABLE; /* enable CSI20 output */ - /* Set SI20 pin */ - PMCT1 &= 0xEFU; - PM1 |= 0x10U; - /* Set SO20 pin */ - PMCT1 &= 0xF7U; - P1 |= 0x08U; - PM1 &= 0xF7U; - /* Set SCK20 pin */ - PMCT1 &= 0xDFU; - P1 |= 0x20U; - PM1 &= 0xDFU; - - R_Config_CSI20_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_CSI20_Start -* Description : This function starts the CSI20 module operation. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_CSI20_Start(void) -{ - SO1 |= _0100_SAU_CH0_CLOCK_OUTPUT_1; /* CSI20 clock initial level */ - SO1 &= (uint16_t)~_0001_SAU_CH0_DATA_OUTPUT_1; /* CSI20 SO initial level */ - SOE1 |= _0001_SAU_CH0_OUTPUT_ENABLE; /* enable CSI20 output */ - SS1 |= _0001_SAU_CH0_START_TRG_ON; /* enable CSI20 */ - CSIIF20 = 0U; /* clear INTCSI20 interrupt flag */ - CSIMK20 = 0U; /* enable INTCSI20 interrupt */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_CSI20_Stop -* Description : This function stops the CSI20 module operation. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_CSI20_Stop(void) -{ - CSIMK20 = 1U; /* disable INTCSI20 interrupt */ - ST1 |= _0001_SAU_CH0_STOP_TRG_ON; /* disable CSI20 */ - SOE1 &= (uint16_t)~_0001_SAU_CH0_OUTPUT_ENABLE; /* disable CSI20 output */ - CSIIF20 = 0U; /* clear INTCSI20 interrupt flag */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_CSI20_Send_Receive -* Description : This function sends and receives CSI20 data. -* Arguments : tx_buf - -* transfer buffer pointer -* tx_num - -* buffer size -* rx_buf - -* receive buffer pointer -* Return Value : status - -* MD_OK or MD_ARGERROR -***********************************************************************************************************************/ -MD_STATUS R_Config_CSI20_Send_Receive(uint8_t * const tx_buf, uint16_t tx_num, uint8_t * const rx_buf) -{ - MD_STATUS status = MD_OK; - - if (tx_num < 1U) - { - status = MD_ARGERROR; - } - else - { - g_csi20_tx_count = tx_num; /* send data count */ - gp_csi20_tx_address = tx_buf; /* send buffer pointer */ - gp_csi20_rx_address = rx_buf; /* receive buffer pointer */ - CSIMK20 = 1U; /* disable INTCSI20 interrupt */ - - if (0U != gp_csi20_tx_address) - { - SIO20 = *gp_csi20_tx_address; /* started by writing data to SDR10[7:0] */ - gp_csi20_tx_address++; - } - else - { - SIO20 = 0xFFU; - } - - g_csi20_tx_count--; - CSIMK20 = 0U; /* enable INTCSI20 interrupt */ - } - - return (status); -} - -/* Start user code for adding. Do not edit comment generated here */ -/********************************************************************************************************************** - * Function Name: R_Config_CSI20_GetBitOrder - * Description : Get the order of the bits shifted out of and into the SPI bus. - * Arguments : - - * Return Value : Current bit order setting - * : LSBFIRST - * : MSBFIRST - *********************************************************************************************************************/ -uint8_t R_Config_CSI20_GetBitOrder(void) { - return (SCR03 & (uint16_t)_0080_SAU_LSB) == _0080_SAU_LSB - ? LSBFIRST : MSBFIRST; -} - -/********************************************************************************************************************** - * Function Name: R_Config_CSI20_SetBitOrder - * Description : Set the order of the bits shifted out of and into the SPI bus. - * Arguments : bitOrder - Bit order setting - * : LSBFIRST - * : MSBFIRST - * Return Value : - - *********************************************************************************************************************/ -void R_Config_CSI20_SetBitOrder(uint8_t bitOrder) { - ST0 |= _0008_SAU_CH3_STOP_TRG_ON; /* Stop channel 3 */ - SOE0 &= (uint16_t)~_0008_SAU_CH3_OUTPUT_ENABLE; /* disable CSI20 output */ - - SCR03 = (SCR03 & (uint16_t)~_0080_SAU_LSB) - | (bitOrder == LSBFIRST ? _0080_SAU_LSB : _0000_SAU_MSB); - - CSIIF11 = 0U; /* clear INTCSI20 interrupt flag */ - - SO0 |= _0800_SAU_CH3_CLOCK_OUTPUT_1; /* CSI20 clock initial level */ - SO0 &= (uint16_t)~_0008_SAU_CH3_DATA_OUTPUT_1; /* CSI20 SO initial level */ - SOE0 |= _0008_SAU_CH3_OUTPUT_ENABLE; /* enable CSI20 output */ - SS0 |= _0008_SAU_CH3_START_TRG_ON; /* enable CSI20 */ -} - -/********************************************************************************************************************** - * Function Name: R_Config_CSI20_SetDataMode - * Description : Set the SPI data mode (clock polarity and phase). - * Arguments : dataMode - SPI data mode - * : SPI_MODE0 - * : SPI_MODE1 - * : SPI_MODE2 - * : SPI_MODE3 - * Return Value : - - *********************************************************************************************************************/ -void R_Config_CSI20_SetDataMode(uint8_t dataMode) { - - ST0 |= _0008_SAU_CH3_STOP_TRG_ON; /* Stop channel 3 */ - SOE0 &= (uint16_t)~_0008_SAU_CH3_OUTPUT_ENABLE; /* disable CSI20 output */ - /* - * This mapping is obeying the base code. - * Fix the `SPI_MODEx` macros together. - */ - switch (dataMode) { - case SPI_MODE3: SCR03 = (SCR03 & (uint16_t)~SPI_MODE_MASK) | _0000_SAU_TIMING_1; break; - case SPI_MODE2: SCR03 = (SCR03 & (uint16_t)~SPI_MODE_MASK) | _2000_SAU_TIMING_3; break; - case SPI_MODE1: SCR03 = (SCR03 & (uint16_t)~SPI_MODE_MASK) | _1000_SAU_TIMING_2; break; - case SPI_MODE0: - default: SCR03 = (SCR03 & (uint16_t)~SPI_MODE_MASK) | _3000_SAU_TIMING_4; break; - } - - CSIIF11 = 0U; /* clear INTCSI20 interrupt flag */ - - SO0 |= _0800_SAU_CH3_CLOCK_OUTPUT_1; /* CSI20 clock initial level */ - SO0 &= (uint16_t)~_0008_SAU_CH3_DATA_OUTPUT_1; /* CSI20 SO initial level */ - SOE0 |= _0008_SAU_CH3_OUTPUT_ENABLE; /* enable CSI20 output */ - SS0 |= _0008_SAU_CH3_START_TRG_ON; /* enable CSI20 */ -} - -/********************************************************************************************************************** - * Function Name: R_Config_CSI20_SetClockDivider - * Description : Set the SPI clock divider relative to the system clock. - * Arguments : clockDiv - SPI clock divider - * : SPI_CLOCK_DIV2 - * : SPI_CLOCK_DIV4 - * : SPI_CLOCK_DIV8 - * : SPI_CLOCK_DIV16 - * : SPI_CLOCK_DIV32 - * : SPI_CLOCK_DIV64 - * : SPI_CLOCK_DIV128 - * : or an immediate { 2, 4, 6, 8, ..., 256 } - * Return Value : - - *********************************************************************************************************************/ -void R_Config_CSI20_SetClockDivider(uint16_t clockDiv) { - ST0 |= _0008_SAU_CH3_STOP_TRG_ON; /* Stop channel 3 */ - SOE0 &= (uint16_t)~_0008_SAU_CH3_OUTPUT_ENABLE; /* disable CSI20 output */ - - clockDiv = clockDiv < 2 ? 2U - : clockDiv > 256 ? 256U - : clockDiv + (clockDiv & 1U); - - SDR03 = ((clockDiv >> 1) - 1) << 9; - - CSIIF11 = 0U; /* clear INTCSI20 interrupt flag */ - - SO0 |= _0800_SAU_CH3_CLOCK_OUTPUT_1; /* CSI20 clock initial level */ - SO0 &= (uint16_t)~_0008_SAU_CH3_DATA_OUTPUT_1; /* CSI20 SO initial level */ - SOE0 |= _0008_SAU_CH3_OUTPUT_ENABLE; /* enable CSI20 output */ - SS0 |= _0008_SAU_CH3_START_TRG_ON; /* enable CSI20 */ -} - -/********************************************************************************************************************** - * Function Name: R_Config_CSI20_SetClock - * Description : Set the SPI maximum speed of communication. - * Arguments : clock - SPI clock speed - * Return Value : - - *********************************************************************************************************************/ -void R_Config_CSI20_SetClock(uint32_t clock) { - uint16_t clockDiv; - uint32_t spi_frequency = R_BSP_GetFclkFreqHz() >> ((SPS0 >> 4) & 0x0F); - - for (clockDiv = 2; clockDiv < 256; clockDiv += 2) { - if (clock >= spi_frequency / clockDiv) { - break; - } - } - - R_Config_CSI20_SetClockDivider(clockDiv); -} -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021, 2023 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_CSI20.c +* Component Version: 1.4.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_CSI20. +* Creation Date : +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_CSI20.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +volatile uint8_t * gp_csi20_tx_address; /* csi20 send buffer address */ +volatile uint16_t g_csi20_tx_count; /* csi20 send data count */ +volatile uint8_t * gp_csi20_rx_address; /* csi20 receive buffer address */ +/* Start user code for global. Do not edit comment generated here */ +volatile uint16_t g_csi20_status_flag; +uint32_t R_BSP_GetFclkFreqHz(void); +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_CSI20_Create +* Description : This function initializes the CSI20 module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_CSI20_Create(void) +{ + SPS1 &= _00F0_SAU_CK00_CLEAR; + SPS1 |= _0000_SAU_CK00_FCLK_0; + /* Stop channel 0 */ + ST1 |= _0001_SAU_CH0_STOP_TRG_ON; + /* Mask channel 0 interrupt */ + CSIMK20 = 1U; /* disable INTCSI20 interrupt */ + CSIIF20 = 0U; /* clear INTCSI20 interrupt flag */ + /* Set INTCSI20 low priority */ + CSIPR120 = 1U; + CSIPR020 = 1U; + SIR10 = _0002_SAU_SIRMN_PECTMN | _0001_SAU_SIRMN_OVCTMN; /* clear error flag */ + SMR10 = _0020_SAU_SMRMN_INITIALVALUE | _0000_SAU_CLOCK_SELECT_CK00 | _0000_SAU_CLOCK_MODE_CKS | + _0000_SAU_TRIGGER_SOFTWARE | _0000_SAU_MODE_CSI | _0000_SAU_TRANSFER_END; + SCR10 = _0004_SAU_SCRMN_INITIALVALUE | _C000_SAU_RECEPTION_TRANSMISSION | _3000_SAU_TIMING_4 | _0000_SAU_MSB | + _0003_SAU_LENGTH_8; + SDR10 = _0600_SAU1_CH0_BAUDRATE_DIVISOR; +// SO1 |= _0100_SAU_CH0_CLOCK_OUTPUT_1; /* CSI20 clock initial level */ + SO1 &= (uint16_t)~_0100_SAU_CH0_CLOCK_OUTPUT_1; /* CSI20 clock initial level */ + + SO1 &= (uint16_t)~_0001_SAU_CH0_DATA_OUTPUT_1; /* CSI20 SO initial level */ + SOE1 |= _0001_SAU_CH0_OUTPUT_ENABLE; /* enable CSI20 output */ + /* Set SI20 pin */ + PMCT1 &= 0xEFU; + PM1 |= 0x10U; + /* Set SO20 pin */ + PMCT1 &= 0xF7U; + P1 |= 0x08U; + PM1 &= 0xF7U; + /* Set SCK20 pin */ + PMCT1 &= 0xDFU; + P1 |= 0x20U; + PM1 &= 0xDFU; + + R_Config_CSI20_Create_UserInit(); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_CSI20_Start +* Description : This function starts the CSI20 module operation. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_CSI20_Start(void) +{ +// SO1 |= _0100_SAU_CH0_CLOCK_OUTPUT_1; /* CSI20 clock initial level */ +// SO1 &= (uint16_t)~_0001_SAU_CH0_DATA_OUTPUT_1; /* CSI20 SO initial level */ + SOE1 |= _0001_SAU_CH0_OUTPUT_ENABLE; /* enable CSI20 output */ + SS1 |= _0001_SAU_CH0_START_TRG_ON; /* enable CSI20 */ + CSIIF20 = 0U; /* clear INTCSI20 interrupt flag */ + CSIMK20 = 0U; /* enable INTCSI20 interrupt */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_CSI20_Stop +* Description : This function stops the CSI20 module operation. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_CSI20_Stop(void) +{ + CSIMK20 = 1U; /* disable INTCSI20 interrupt */ + ST1 |= _0001_SAU_CH0_STOP_TRG_ON; /* disable CSI20 */ + SOE1 &= (uint16_t)~_0001_SAU_CH0_OUTPUT_ENABLE; /* disable CSI20 output */ + CSIIF20 = 0U; /* clear INTCSI20 interrupt flag */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_CSI20_Send_Receive +* Description : This function sends and receives CSI20 data. +* Arguments : tx_buf - +* transfer buffer pointer +* tx_num - +* buffer size +* rx_buf - +* receive buffer pointer +* Return Value : status - +* MD_OK or MD_ARGERROR +***********************************************************************************************************************/ +MD_STATUS R_Config_CSI20_Send_Receive(uint8_t * const tx_buf, uint16_t tx_num, uint8_t * const rx_buf) +{ + MD_STATUS status = MD_OK; + + if (tx_num < 1U) + { + status = MD_ARGERROR; + } + else + { + g_csi20_tx_count = tx_num; /* send data count */ + gp_csi20_tx_address = tx_buf; /* send buffer pointer */ + gp_csi20_rx_address = rx_buf; /* receive buffer pointer */ + CSIMK20 = 1U; /* disable INTCSI20 interrupt */ + + if (0U != gp_csi20_tx_address) + { + SIO20 = *gp_csi20_tx_address; /* started by writing data to SDR10[7:0] */ + gp_csi20_tx_address++; + } + else + { + SIO20 = 0xFFU; + } + + g_csi20_tx_count--; + CSIMK20 = 0U; /* enable INTCSI20 interrupt */ + } + + return (status); +} + +/* Start user code for adding. Do not edit comment generated here */ +/********************************************************************************************************************** + * Function Name: R_Config_CSI20_GetBitOrder + * Description : Get the order of the bits shifted out of and into the SPI bus. + * Arguments : - + * Return Value : Current bit order setting + * : LSBFIRST + * : MSBFIRST + *********************************************************************************************************************/ +uint8_t R_Config_CSI20_GetBitOrder(void) { + return (SCR10 & (uint16_t)_0080_SAU_LSB) == _0080_SAU_LSB + ? LSBFIRST : MSBFIRST; +} + +/********************************************************************************************************************** + * Function Name: R_Config_CSI20_SetBitOrder + * Description : Set the order of the bits shifted out of and into the SPI bus. + * Arguments : bitOrder - Bit order setting + * : LSBFIRST + * : MSBFIRST + * Return Value : - + *********************************************************************************************************************/ +void R_Config_CSI20_SetBitOrder(uint8_t bitOrder) { + ST1 |= _0001_SAU_CH0_STOP_TRG_ON; /* Stop unit 1, channel 0 */ + SOE1 &= (uint16_t)~_0001_SAU_CH0_OUTPUT_ENABLE; /* disable CSI20 output */ + + SCR10 = (SCR10 & (uint16_t)~_0080_SAU_LSB) + | (bitOrder == LSBFIRST ? _0080_SAU_LSB : _0000_SAU_MSB); + + CSIIF20 = 0U; /* clear INTCSI20 interrupt flag */ + +// SO1 |= _0100_SAU_CH0_CLOCK_OUTPUT_1; /* CSI20 clock initial level */ +// SO1 &= (uint16_t)~_0001_SAU_CH0_DATA_OUTPUT_1; /* CSI20 SO initial level */ + SOE1 |= _0001_SAU_CH0_OUTPUT_ENABLE; /* enable CSI20 output */ + SS1 |= _0001_SAU_CH0_START_TRG_ON; /* enable CSI20 */ +} + +/********************************************************************************************************************** + * Function Name: R_Config_CSI20_SetDataMode + * Description : Set the SPI data mode (clock polarity and phase). + * Arguments : dataMode - SPI data mode + * : SPI_MODE0 + * : SPI_MODE1 + * : SPI_MODE2 + * : SPI_MODE3 + * Return Value : - + *********************************************************************************************************************/ +void R_Config_CSI20_SetDataMode(uint8_t dataMode) { + + ST1 |= _0001_SAU_CH0_STOP_TRG_ON; /* Stop unit 1, channel 0 */ + SOE1 &= (uint16_t)~_0001_SAU_CH0_OUTPUT_ENABLE; /* disable CSI11 output */ + /* + * This mapping is obeying the base code. + * Fix the `SPI_MODEx` macros together. + */ + switch (dataMode) { + case SPI_MODE3: + SCR10 = (SCR10 & (uint16_t)~SPI_MODE_MASK) | _0000_SAU_TIMING_1; + SO1 |= _0100_SAU_CH0_CLOCK_OUTPUT_1; /* CSI20 clock initial level */ + break; + case SPI_MODE2: + SCR10 = (SCR10 & (uint16_t)~SPI_MODE_MASK) | _2000_SAU_TIMING_3; + SO1 |= _0100_SAU_CH0_CLOCK_OUTPUT_1; /* CSI20 clock initial level */ + break; + case SPI_MODE1: + SCR10 = (SCR10 & (uint16_t)~SPI_MODE_MASK) | _1000_SAU_TIMING_2; + SO1 &= (uint16_t)~_0100_SAU_CH0_CLOCK_OUTPUT_1; /* CSI20 clock initial level */ + break; + case SPI_MODE0: + default: + SCR10 = (SCR10 & (uint16_t)~SPI_MODE_MASK) | _3000_SAU_TIMING_4; + SO1 &= (uint16_t)~_0100_SAU_CH0_CLOCK_OUTPUT_1; /* CSI20 clock initial level */ + break; + } + + CSIIF20 = 0U; /* clear INTCSI20 interrupt flag */ + +// SO1 |= _0100_SAU_CH0_CLOCK_OUTPUT_1; /* CSI20 clock initial level */ +// SO1 &= (uint16_t)~_0001_SAU_CH0_DATA_OUTPUT_1; /* CSI20 SO initial level */ + SOE1 |= _0001_SAU_CH0_OUTPUT_ENABLE; /* enable CSI20 output */ + SS1 |= _0001_SAU_CH0_START_TRG_ON; /* enable CSI20 */ +} + +/********************************************************************************************************************** + * Function Name: R_Config_CSI20_SetClockDivider + * Description : Set the SPI clock divider relative to the system clock. + * Arguments : clockDiv - SPI clock divider + * : SPI_CLOCK_DIV2 + * : SPI_CLOCK_DIV4 + * : SPI_CLOCK_DIV8 + * : SPI_CLOCK_DIV16 + * : SPI_CLOCK_DIV32 + * : SPI_CLOCK_DIV64 + * : SPI_CLOCK_DIV128 + * : or an immediate { 2, 4, 6, 8, ..., 256 } + * Return Value : - + *********************************************************************************************************************/ +void R_Config_CSI20_SetClockDivider(uint16_t clockDiv) { + ST1 |= _0001_SAU_CH0_STOP_TRG_ON; /* Stop unit 1, channel 0 */ + SOE1 &= (uint16_t)~_0001_SAU_CH0_OUTPUT_ENABLE; /* disable CSI11 output */ + +// clockDiv = clockDiv < 2 ? 2U + clockDiv = clockDiv < 4 ? 4U + : clockDiv > 256 ? 256U + : clockDiv + (clockDiv & 1U); + + SDR10 = ((clockDiv >> 1) - 1) << 9; + + CSIIF20 = 0U; /* clear INTCSI20 interrupt flag */ + +// SO1 |= _0100_SAU_CH0_CLOCK_OUTPUT_1; /* CSI20 clock initial level */ +// SO1 &= (uint16_t)~_0001_SAU_CH0_DATA_OUTPUT_1; /* CSI20 SO initial level */ + SOE1 |= _0001_SAU_CH0_OUTPUT_ENABLE; /* enable CSI20 output */ + SS1 |= _0001_SAU_CH0_START_TRG_ON; /* enable CSI20 */ +} + +/********************************************************************************************************************** + * Function Name: R_Config_CSI20_SetClock + * Description : Set the SPI maximum speed of communication. + * Arguments : clock - SPI clock speed + * Return Value : - + *********************************************************************************************************************/ +void R_Config_CSI20_SetClock(uint32_t clock) { + uint16_t clockDiv; + uint32_t spi_frequency = R_BSP_GetFclkFreqHz() >> ((SPS1 >> 4) & 0x0F); + + for (clockDiv = 2; clockDiv < 256; clockDiv += 2) { + if (clock >= spi_frequency / clockDiv) { + break; + } + } + + R_Config_CSI20_SetClockDivider(clockDiv); +} +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_CSI20/Config_CSI20.h b/cores/rl78g22/smc_gen/Config_CSI20/Config_CSI20.h index 2ff6d78..99eced3 100644 --- a/cores/rl78g22/smc_gen/Config_CSI20/Config_CSI20.h +++ b/cores/rl78g22/smc_gen/Config_CSI20/Config_CSI20.h @@ -1,67 +1,67 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2021, 2022 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_CSI20.h -* Component Version: 1.3.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_CSI20. -* Creation Date : -***********************************************************************************************************************/ - -#ifndef CFG_Config_CSI20_H -#define CFG_Config_CSI20_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_sau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _CE00_SAU1_CH0_BAUDRATE_DIVISOR (0xCE00U) /* transfer clock set by dividing the operating clock */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_CSI20_Create (void); -void R_Config_CSI20_Start (void); -void R_Config_CSI20_Stop (void); -MD_STATUS R_Config_CSI20_Send_Receive (uint8_t * const tx_buf, uint16_t tx_num, uint8_t * const rx_buf); -void R_Config_CSI20_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -void R_Config_CSI20_ClearStatus(void); -uint8_t R_Config_CSI20_GetBitOrder(void); -void R_Config_CSI20_SetBitOrder(uint8_t bitOrder); -void R_Config_CSI20_SetDataMode(uint8_t dataMode); -void R_Config_CSI20_SetClockDivider(uint16_t clockDiv); -void R_Config_CSI20_SetClock(uint32_t clock); -// -void r_Config_CSI20_interrupt(void); -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021, 2023 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_CSI20.h +* Component Version: 1.4.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_CSI20. +* Creation Date : +***********************************************************************************************************************/ + +#ifndef CFG_Config_CSI20_H +#define CFG_Config_CSI20_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_sau.h" + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ +#define _0600_SAU1_CH0_BAUDRATE_DIVISOR (0x0600U) /* transfer clock set by dividing the operating clock */ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_Config_CSI20_Create (void); +void R_Config_CSI20_Start (void); +void R_Config_CSI20_Stop (void); +MD_STATUS R_Config_CSI20_Send_Receive (uint8_t * const tx_buf, uint16_t tx_num, uint8_t * const rx_buf); +void R_Config_CSI20_Create_UserInit (void); +/* Start user code for function. Do not edit comment generated here */ +void R_Config_CSI20_ClearStatus(void); +uint8_t R_Config_CSI20_GetBitOrder(void); +void R_Config_CSI20_SetBitOrder(uint8_t bitOrder); +void R_Config_CSI20_SetDataMode(uint8_t dataMode); +void R_Config_CSI20_SetClockDivider(uint16_t clockDiv); +void R_Config_CSI20_SetClock(uint32_t clock); +// +// void r_Config_CSI20_interrupt(void); +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/Config_CSI20/Config_CSI20_user.c b/cores/rl78g22/smc_gen/Config_CSI20/Config_CSI20_user.c index e1b6d62..bb09148 100644 --- a/cores/rl78g22/smc_gen/Config_CSI20/Config_CSI20_user.c +++ b/cores/rl78g22/smc_gen/Config_CSI20/Config_CSI20_user.c @@ -1,175 +1,179 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2021, 2022 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_CSI20_user.c -* Component Version: 1.3.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_CSI20. -* Creation Date : -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_CSI20.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -extern volatile uint8_t * gp_csi20_tx_address; /* csi20 send buffer address */ -extern volatile uint16_t g_csi20_tx_count; /* csi20 send data count */ -extern volatile uint8_t * gp_csi20_rx_address; /* csi20 receive buffer address */ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_CSI20_Create_UserInit -* Description : This function adds user code after initializing the CSI20. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_CSI20_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_CSI20_callback_sendend -* Description : This function is a callback function when CSI20 finishes transmission. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_CSI20_callback_sendend(void) -{ - /* Start user code for r_Config_CSI20_callback_sendend. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_CSI20_callback_receiveend -* Description : This function is a callback function when CSI20 finishes reception. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_CSI20_callback_receiveend(void) -{ - /* Start user code for r_Config_CSI20_callback_receiveend. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_CSI20_callback_error -* Description : This function is a callback function when CSI20 reception error occurs. -* Arguments : err_type - -* error type value -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_CSI20_callback_error(uint8_t err_type) -{ - /* Start user code for r_Config_CSI20_callback_error. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_CSI20_interrupt -* Description : This function is INTCSI20 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_CSI20_interrupt(void) -{ - uint8_t err_type; - volatile uint8_t sio_dummy; - - err_type = (uint8_t)(SSR10 & _0001_SAU_OVERRUN_ERROR); - SIR10 = (uint16_t)err_type; - - if (1U == err_type) - { - r_Config_CSI20_callback_error(err_type); /* overrun error occurs */ - } - else - { - if (g_csi20_tx_count > 0U) - { - if (0U != gp_csi20_rx_address) - { - *gp_csi20_rx_address = SIO20; - gp_csi20_rx_address++; - } - else - { - sio_dummy = SIO20; - } - - if (0U != gp_csi20_tx_address) - { - SIO20 = *gp_csi20_tx_address; - gp_csi20_tx_address++; - } - else - { - SIO20 = 0xFFU; - } - - g_csi20_tx_count--; - } - else - { - if (0U == g_csi20_tx_count) - { - if (0U != gp_csi20_rx_address) - { - *gp_csi20_rx_address = SIO20; - } - else - { - sio_dummy = SIO20; - } - } - - r_Config_CSI20_callback_sendend(); /* complete send */ - r_Config_CSI20_callback_receiveend(); /* complete receive */ - } - } -} - -/* Start user code for adding. Do not edit comment generated here */ -/********************************************************************************************************************** - * Function Name: R_Config_CSI20_ClearStatus - * Description : Clear the CSI module's status. - * Arguments : - - * Return Value : - - *********************************************************************************************************************/ -void R_Config_CSI20_ClearStatus(void) { -// g_csi11_status_flag = _0000_SPI_STATUS_CLEAR; -} -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021, 2023 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_CSI20_user.c +* Component Version: 1.4.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_CSI20. +* Creation Date : +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_CSI20.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +extern volatile uint8_t * gp_csi20_tx_address; /* csi20 send buffer address */ +extern volatile uint16_t g_csi20_tx_count; /* csi20 send data count */ +extern volatile uint8_t * gp_csi20_rx_address; /* csi20 receive buffer address */ +/* Start user code for global. Do not edit comment generated here */ +extern volatile uint16_t g_csi20_status_flag; +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_CSI20_Create_UserInit +* Description : This function adds user code after initializing the CSI20. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_CSI20_Create_UserInit(void) +{ + /* Start user code for user init. Do not edit comment generated here */ + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_CSI20_callback_sendend +* Description : This function is a callback function when CSI20 finishes transmission. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_CSI20_callback_sendend(void) +{ + /* Start user code for r_Config_CSI20_callback_sendend. Do not edit comment generated here */ + g_csi20_status_flag |= _8000_SPI_STATUS_SENDEND; + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_CSI20_callback_receiveend +* Description : This function is a callback function when CSI20 finishes reception. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_CSI20_callback_receiveend(void) +{ + /* Start user code for r_Config_CSI20_callback_receiveend. Do not edit comment generated here */ + g_csi20_status_flag |= _4000_SPI_STATUS_RECEIVEEND; + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_CSI20_callback_error +* Description : This function is a callback function when CSI20 reception error occurs. +* Arguments : err_type - +* error type value +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_CSI20_callback_error(uint8_t err_type) +{ + /* Start user code for r_Config_CSI20_callback_error. Do not edit comment generated here */ + g_csi20_status_flag = (g_csi20_status_flag & ~_00FF_SPI_STATUS_ERROR_MASK) | err_type; + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_CSI20_interrupt +* Description : This function is INTCSI20 interrupt service routine. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_CSI20_interrupt(void) +{ + uint8_t err_type; + volatile uint8_t sio_dummy; + + err_type = (uint8_t)(SSR10 & _0001_SAU_OVERRUN_ERROR); + SIR10 = (uint16_t)err_type; + + if (1U == err_type) + { + r_Config_CSI20_callback_error(err_type); /* overrun error occurs */ + } + else + { + if (g_csi20_tx_count > 0U) + { + if (0U != gp_csi20_rx_address) + { + *gp_csi20_rx_address = SIO20; + gp_csi20_rx_address++; + } + else + { + sio_dummy = SIO20; + } + + if (0U != gp_csi20_tx_address) + { + SIO20 = *gp_csi20_tx_address; + gp_csi20_tx_address++; + } + else + { + SIO20 = 0xFFU; + } + + g_csi20_tx_count--; + } + else + { + if (0U == g_csi20_tx_count) + { + if (0U != gp_csi20_rx_address) + { + *gp_csi20_rx_address = SIO20; + } + else + { + sio_dummy = SIO20; + } + } + + r_Config_CSI20_callback_sendend(); /* complete send */ + r_Config_CSI20_callback_receiveend(); /* complete receive */ + } + } +} + +/* Start user code for adding. Do not edit comment generated here */ +/********************************************************************************************************************** + * Function Name: R_Config_CSI20_ClearStatus + * Description : Clear the CSI module's status. + * Arguments : - + * Return Value : - + *********************************************************************************************************************/ +void R_Config_CSI20_ClearStatus(void) { + g_csi20_status_flag = _0000_SPI_STATUS_CLEAR; +} +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_IICA0/Config_IICA0.c b/cores/rl78g22/smc_gen/Config_IICA0/Config_IICA0.c index c55f03b..6635b48 100644 --- a/cores/rl78g22/smc_gen/Config_IICA0/Config_IICA0.c +++ b/cores/rl78g22/smc_gen/Config_IICA0/Config_IICA0.c @@ -1,304 +1,304 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2021, 2022 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_IICA0.c -* Component Version: 1.4.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_IICA0. -* Creation Date : -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_IICA0.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -// wakeup time of I2C SCL and SDA. If pulled up to Vdd, it can be set 0. -#define I2C_WakeupTime 0.0 - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -volatile uint8_t g_iica0_master_status_flag; /* iica0 master flag */ -volatile uint8_t * gp_iica0_rx_address; /* iica0 receive buffer address */ -volatile uint16_t g_iica0_rx_len; /* iica0 receive data length */ -volatile uint16_t g_iica0_rx_cnt; /* iica0 receive data count */ -volatile uint8_t * gp_iica0_tx_address; /* iica0 send buffer address */ -volatile uint16_t g_iica0_tx_cnt; /* iica0 send data count */ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_IICA0_Create -* Description : This function initializes the IICA0 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_IICA0_Create(void) -{ - IICA0EN = 1U; /* enables input clock supply */ - IICE0 = 0U; - IICAMK0 = 1U; /* disable INTIICA0 interrupt */ - IICAIF0 = 0U; /* clear INTIICA0 interrupt flag */ - /* Set INTIICA0 low priority */ - IICAPR10 = 1U; - IICAPR00 = 1U; - /* Set SCLA0, SDAA0 pin */ - P6 &= 0xFCU; - PM6 |= 0x03U; - SMC0 = 0U; - IICWL0 = _4C_IICA0_IICWL_VALUE; - IICWH0 = _55_IICA0_IICWH_VALUE; - IICCTL01 |= _01_IICA_fCLK_HALF; - SVA0 = _10_IICA0_MASTERADDRESS; - STCEN0 = 1U; - IICRSV0 = 1U; - SPIE0 = 0U; - WTIM0 = 1U; - ACKE0 = 1U; - IICAMK0 = 0U; - IICE0 = 1U; - LREL0 = 1U; - /* Set SCLA0, SDAA0 pin */ - PM6 &= 0xFCU; - - R_Config_IICA0_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_IICA0_Stop -* Description : This function stops IICA0 module operation. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_IICA0_Stop(void) -{ - IICE0 = 0U; /* disable IICA0 operation */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_IICA0_StopCondition -* Description : This function stops the IICA0 condition. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_IICA0_StopCondition(void) -{ - SPT0 = 1U; /* set stop condition flag */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_IICA0_Master_Send -* Description : This function starts to send data as master mode. -* Arguments : adr - -* transfer address -* tx_buf - -* transfer buffer pointer -* tx_num - -* buffer size -* wait - -* wait for start condition -* Return Value : status - -* MD_OK, MD_ERROR1 or MD_ERROR2 -***********************************************************************************************************************/ -MD_STATUS R_Config_IICA0_Master_Send(uint8_t adr, uint8_t * const tx_buf, uint16_t tx_num, uint8_t wait) -{ - MD_STATUS status = MD_OK; - - IICAMK0 = 1U; /* disable INTIICA0 interrupt */ - - if ((1U == IICBSY0) && (0U == MSTS0)) - { - /* Check bus busy */ - IICAMK0 = 0U; /* enable INTIICA0 interrupt */ - status = MD_ERROR1; - } - else - { - STT0 = 1U; /* send IICA0 start condition */ - IICAMK0 = 0U; /* enable INTIICA0 interrupt */ - - /* Wait */ - while (0U == STD0) - { - if (0U == (wait--)) - { - status = MD_ERROR2; - break; - } - } - - /* Detect start condition */ - if (MD_OK == status) - { - g_iica0_tx_cnt = tx_num; - gp_iica0_tx_address = tx_buf; - g_iica0_master_status_flag = _00_IICA_MASTER_FLAG_CLEAR; - adr &= (uint8_t)~0x01U; /* set send mode */ - IICA0 = adr; /* send address */ - } - } - - return (status); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_IICA0_Master_Receive -* Description : This function starts to receive data as master mode. -* Arguments : adr - -* receive address -* rx_buf - -* receive buffer pointer -* rx_num - -* buffer size -* wait - -* wait for start condition -* Return Value : status - -* MD_OK, MD_ERROR1 or MD_ERROR2 -***********************************************************************************************************************/ -MD_STATUS R_Config_IICA0_Master_Receive(uint8_t adr, uint8_t * const rx_buf, uint16_t rx_num, uint8_t wait) -{ - MD_STATUS status = MD_OK; - - IICAMK0 = 1U; /* disable INTIICA0 interrupt */ - - if ((1U == IICBSY0) && (0U == MSTS0)) - { - /* Check bus busy */ - IICAMK0 = 0U; /* enable INTIICA0 interrupt */ - status = MD_ERROR1; - } - else - { - STT0 = 1U; /* send IICA0 start condition */ - IICAMK0 = 0U; /* enable INTIICA0 interrupt */ - - /* Wait */ - while (0U == STD0) - { - if (0U == (wait--)) - { - status = MD_ERROR2; - break; - } - } - - /* Detect start condition */ - if (MD_OK == status) - { - /* Set parameter */ - g_iica0_rx_len = rx_num; - g_iica0_rx_cnt = 0U; - gp_iica0_rx_address = rx_buf; - g_iica0_master_status_flag = _00_IICA_MASTER_FLAG_CLEAR; - adr |= 0x01U; /* set receive mode */ - IICA0 = adr; /* receive address */ - } - } - - return (status); -} - -/* Start user code for adding. Do not edit comment generated here */ -double coeffL, coeffH; -/********************************************************************************************************************** - * Function Name: R_Config_IICA0_Master_SetClock - * Description : This function sets I2C clock frequency - * Arguments : clock - clock frequency to set - * : The given frequency is normalized - * : cutting off to the either one of the frequencies below: - * : I2C_CLOCK_FAST_PLUS = 1,000,000 Hz (fast mode plus) - * : I2C_CLOCK_FAST = 400,000 Hz (fast mode ) - * : I2C_CLOCK_STANDARD = 100,000 Hz (standard mode ) - * : If the given frequency is lower than above all, - * : considers it as the lowest clock or standard mode 100,000 Hz. - * Return Value : None - *********************************************************************************************************************/ -void R_Config_IICA0_Master_SetClock(uint32_t clock) { - if (IICA0EN == 0U || IICE0 == 0U) { - return; - } - -// double coeffL, coeffH; -#if !defined(DISABLE_CLOCK_FAST_PLUS) - if ( clock >= I2C_CLOCK_FAST_PLUS ) { clock = I2C_CLOCK_FAST_PLUS; coeffL = 0.50; coeffH = 0.50; } - else -#endif /* !defined(DISABLE_CLOCK_FAST_PLUS) */ -// if ( clock >= I2C_CLOCK_FAST ) { clock = I2C_CLOCK_FAST ; coeffL = 0.52; coeffH = 0.48; } -// else { clock = I2C_CLOCK_STANDARD ; coeffL = 0.47; coeffH = 0.53; } - - if ( clock >= I2C_CLOCK_FAST ) - { -// clock = I2C_CLOCK_FAST ; - coeffL = 0.52; - coeffH = 0.48; - } - else - { -// clock = I2C_CLOCK_STANDARD ; - coeffL = 0.47; - coeffH = 0.53; - } - /* - * XXX: - * Register access code is copied from `R_Config_IICA0_Create()`. - * Do the same settings but clock `IICWL0` / `IICWH0`. - */ - - IICE0 = 0U; - IICAMK0 = 1U; /* disable INTIICA0 interrupt */ - IICAIF0 = 0U; /* clear INTIICA0 interrupt flag */ - /* Set INTIICA0 low priority */ - IICAPR10 = 1U; - IICAPR00 = 1U; - /* Set SCLA0, SDAA0 pin */ - P6 &= 0xFCU; - PM6 |= 0x03U; - SMC0 = 0U; - - IICWL0 = (uint8_t)(ceil((double)(configCPU_CLOCK_HZ / 2 * coeffL) / (double)clock)); -// IICWH0 = (uint8_t)(ceil((double)(configCPU_CLOCK_HZ / 2 * coeffH) / (double)clock)); - IICWH0 = (uint8_t) (ceil( (coeffH / (double)clock - I2C_WakeupTime ) * (double)configCPU_CLOCK_HZ / 2 )); - - IICCTL01 |= _01_IICA_fCLK_HALF; - SVA0 = _10_IICA0_MASTERADDRESS; - STCEN0 = 1U; - IICRSV0 = 1U; - SPIE0 = 0U; - WTIM0 = 1U; - ACKE0 = 1U; - IICAMK0 = 0U; - IICE0 = 1U; - LREL0 = 1U; - /* Set SCLA0, SDAA0 pin */ - PM6 &= 0xFCU; -} -/* End user code. Do not edit comment generated here */ - +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021, 2022 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_IICA0.c +* Component Version: 1.4.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_IICA0. +* Creation Date : +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_IICA0.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +// wakeup time of I2C SCL and SDA. If pulled up to Vdd, it can be set 0. +#define I2C_WakeupTime 0.0 + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +volatile uint8_t g_iica0_master_status_flag; /* iica0 master flag */ +volatile uint8_t * gp_iica0_rx_address; /* iica0 receive buffer address */ +volatile uint16_t g_iica0_rx_len; /* iica0 receive data length */ +volatile uint16_t g_iica0_rx_cnt; /* iica0 receive data count */ +volatile uint8_t * gp_iica0_tx_address; /* iica0 send buffer address */ +volatile uint16_t g_iica0_tx_cnt; /* iica0 send data count */ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_IICA0_Create +* Description : This function initializes the IICA0 module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_IICA0_Create(void) +{ + IICA0EN = 1U; /* enables input clock supply */ + IICE0 = 0U; + IICAMK0 = 1U; /* disable INTIICA0 interrupt */ + IICAIF0 = 0U; /* clear INTIICA0 interrupt flag */ + /* Set INTIICA0 low priority */ + IICAPR10 = 1U; + IICAPR00 = 1U; + /* Set SCLA0, SDAA0 pin */ + P6 &= 0xFCU; + PM6 |= 0x03U; + SMC0 = 0U; + IICWL0 = _4C_IICA0_IICWL_VALUE; + IICWH0 = _55_IICA0_IICWH_VALUE; + IICCTL01 |= _01_IICA_fCLK_HALF; + SVA0 = _10_IICA0_MASTERADDRESS; + STCEN0 = 1U; + IICRSV0 = 1U; + SPIE0 = 0U; + WTIM0 = 1U; + ACKE0 = 1U; + IICAMK0 = 0U; + IICE0 = 1U; + LREL0 = 1U; + /* Set SCLA0, SDAA0 pin */ + PM6 &= 0xFCU; + + R_Config_IICA0_Create_UserInit(); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_IICA0_Stop +* Description : This function stops IICA0 module operation. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_IICA0_Stop(void) +{ + IICE0 = 0U; /* disable IICA0 operation */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_IICA0_StopCondition +* Description : This function stops the IICA0 condition. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_IICA0_StopCondition(void) +{ + SPT0 = 1U; /* set stop condition flag */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_IICA0_Master_Send +* Description : This function starts to send data as master mode. +* Arguments : adr - +* transfer address +* tx_buf - +* transfer buffer pointer +* tx_num - +* buffer size +* wait - +* wait for start condition +* Return Value : status - +* MD_OK, MD_ERROR1 or MD_ERROR2 +***********************************************************************************************************************/ +MD_STATUS R_Config_IICA0_Master_Send(uint8_t adr, uint8_t * const tx_buf, uint16_t tx_num, uint8_t wait) +{ + MD_STATUS status = MD_OK; + + IICAMK0 = 1U; /* disable INTIICA0 interrupt */ + + if ((1U == IICBSY0) && (0U == MSTS0)) + { + /* Check bus busy */ + IICAMK0 = 0U; /* enable INTIICA0 interrupt */ + status = MD_ERROR1; + } + else + { + STT0 = 1U; /* send IICA0 start condition */ + IICAMK0 = 0U; /* enable INTIICA0 interrupt */ + + /* Wait */ + while (0U == STD0) + { + if (0U == (wait--)) + { + status = MD_ERROR2; + break; + } + } + + /* Detect start condition */ + if (MD_OK == status) + { + g_iica0_tx_cnt = tx_num; + gp_iica0_tx_address = tx_buf; + g_iica0_master_status_flag = _00_IICA_MASTER_FLAG_CLEAR; + adr &= (uint8_t)~0x01U; /* set send mode */ + IICA0 = adr; /* send address */ + } + } + + return (status); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_IICA0_Master_Receive +* Description : This function starts to receive data as master mode. +* Arguments : adr - +* receive address +* rx_buf - +* receive buffer pointer +* rx_num - +* buffer size +* wait - +* wait for start condition +* Return Value : status - +* MD_OK, MD_ERROR1 or MD_ERROR2 +***********************************************************************************************************************/ +MD_STATUS R_Config_IICA0_Master_Receive(uint8_t adr, uint8_t * const rx_buf, uint16_t rx_num, uint8_t wait) +{ + MD_STATUS status = MD_OK; + + IICAMK0 = 1U; /* disable INTIICA0 interrupt */ + + if ((1U == IICBSY0) && (0U == MSTS0)) + { + /* Check bus busy */ + IICAMK0 = 0U; /* enable INTIICA0 interrupt */ + status = MD_ERROR1; + } + else + { + STT0 = 1U; /* send IICA0 start condition */ + IICAMK0 = 0U; /* enable INTIICA0 interrupt */ + + /* Wait */ + while (0U == STD0) + { + if (0U == (wait--)) + { + status = MD_ERROR2; + break; + } + } + + /* Detect start condition */ + if (MD_OK == status) + { + /* Set parameter */ + g_iica0_rx_len = rx_num; + g_iica0_rx_cnt = 0U; + gp_iica0_rx_address = rx_buf; + g_iica0_master_status_flag = _00_IICA_MASTER_FLAG_CLEAR; + adr |= 0x01U; /* set receive mode */ + IICA0 = adr; /* receive address */ + } + } + + return (status); +} + +/* Start user code for adding. Do not edit comment generated here */ +double coeffL, coeffH; +/********************************************************************************************************************** + * Function Name: R_Config_IICA0_Master_SetClock + * Description : This function sets I2C clock frequency + * Arguments : clock - clock frequency to set + * : The given frequency is normalized + * : cutting off to the either one of the frequencies below: + * : I2C_CLOCK_FAST_PLUS = 1,000,000 Hz (fast mode plus) + * : I2C_CLOCK_FAST = 400,000 Hz (fast mode ) + * : I2C_CLOCK_STANDARD = 100,000 Hz (standard mode ) + * : If the given frequency is lower than above all, + * : considers it as the lowest clock or standard mode 100,000 Hz. + * Return Value : None + *********************************************************************************************************************/ +void R_Config_IICA0_Master_SetClock(uint32_t clock) { + if (IICA0EN == 0U || IICE0 == 0U) { + return; + } + +// double coeffL, coeffH; +#if !defined(DISABLE_CLOCK_FAST_PLUS) + if ( clock >= I2C_CLOCK_FAST_PLUS ) { clock = I2C_CLOCK_FAST_PLUS; coeffL = 0.50; coeffH = 0.50; } + else +#endif /* !defined(DISABLE_CLOCK_FAST_PLUS) */ +// if ( clock >= I2C_CLOCK_FAST ) { clock = I2C_CLOCK_FAST ; coeffL = 0.52; coeffH = 0.48; } +// else { clock = I2C_CLOCK_STANDARD ; coeffL = 0.47; coeffH = 0.53; } + + if ( clock >= I2C_CLOCK_FAST ) + { +// clock = I2C_CLOCK_FAST ; + coeffL = 0.52; + coeffH = 0.48; + } + else + { +// clock = I2C_CLOCK_STANDARD ; + coeffL = 0.47; + coeffH = 0.53; + } + /* + * XXX: + * Register access code is copied from `R_Config_IICA0_Create()`. + * Do the same settings but clock `IICWL0` / `IICWH0`. + */ + + IICE0 = 0U; + IICAMK0 = 1U; /* disable INTIICA0 interrupt */ + IICAIF0 = 0U; /* clear INTIICA0 interrupt flag */ + /* Set INTIICA0 low priority */ + IICAPR10 = 1U; + IICAPR00 = 1U; + /* Set SCLA0, SDAA0 pin */ + P6 &= 0xFCU; + PM6 |= 0x03U; + SMC0 = 0U; + + IICWL0 = (uint8_t)(ceil((double)(configCPU_CLOCK_HZ / 2 * coeffL) / (double)clock)); +// IICWH0 = (uint8_t)(ceil((double)(configCPU_CLOCK_HZ / 2 * coeffH) / (double)clock)); + IICWH0 = (uint8_t) (ceil( (coeffH / (double)clock - I2C_WakeupTime ) * (double)configCPU_CLOCK_HZ / 2 )); + + IICCTL01 |= _01_IICA_fCLK_HALF; + SVA0 = _10_IICA0_MASTERADDRESS; + STCEN0 = 1U; + IICRSV0 = 1U; + SPIE0 = 0U; + WTIM0 = 1U; + ACKE0 = 1U; + IICAMK0 = 0U; + IICE0 = 1U; + LREL0 = 1U; + /* Set SCLA0, SDAA0 pin */ + PM6 &= 0xFCU; +} +/* End user code. Do not edit comment generated here */ + diff --git a/cores/rl78g22/smc_gen/Config_IICA0/Config_IICA0.h b/cores/rl78g22/smc_gen/Config_IICA0/Config_IICA0.h index 02ac676..d6866e6 100644 --- a/cores/rl78g22/smc_gen/Config_IICA0/Config_IICA0.h +++ b/cores/rl78g22/smc_gen/Config_IICA0/Config_IICA0.h @@ -1,65 +1,65 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2021, 2022 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_IICA0.h -* Component Version: 1.4.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_IICA0. -* Creation Date : -***********************************************************************************************************************/ - -#ifndef CFG_Config_IICA0_H -#define CFG_Config_IICA0_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_iica.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -#define _10_IICA0_MASTERADDRESS (0x10U) /* IICA0 address */ -#define _4C_IICA0_IICWL_VALUE (0x4CU) -#define _55_IICA0_IICWH_VALUE (0x55U) - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_IICA0_Create (void); -void R_Config_IICA0_Stop (void); -void R_Config_IICA0_StopCondition (void); -MD_STATUS R_Config_IICA0_Master_Send (uint8_t adr, uint8_t * const tx_buf, uint16_t tx_num, uint8_t wait); -MD_STATUS R_Config_IICA0_Master_Receive (uint8_t adr, uint8_t * const rx_buf, uint16_t rx_num, uint8_t wait); -void R_Config_IICA0_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -void R_Config_IICA0_Master_SetClock(uint32_t clock); -/* End user code. Do not edit comment generated here */ -#endif - +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021, 2022 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_IICA0.h +* Component Version: 1.4.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_IICA0. +* Creation Date : +***********************************************************************************************************************/ + +#ifndef CFG_Config_IICA0_H +#define CFG_Config_IICA0_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_iica.h" + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ + +#define _10_IICA0_MASTERADDRESS (0x10U) /* IICA0 address */ +#define _4C_IICA0_IICWL_VALUE (0x4CU) +#define _55_IICA0_IICWH_VALUE (0x55U) + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_Config_IICA0_Create (void); +void R_Config_IICA0_Stop (void); +void R_Config_IICA0_StopCondition (void); +MD_STATUS R_Config_IICA0_Master_Send (uint8_t adr, uint8_t * const tx_buf, uint16_t tx_num, uint8_t wait); +MD_STATUS R_Config_IICA0_Master_Receive (uint8_t adr, uint8_t * const rx_buf, uint16_t rx_num, uint8_t wait); +void R_Config_IICA0_Create_UserInit (void); +/* Start user code for function. Do not edit comment generated here */ +void R_Config_IICA0_Master_SetClock(uint32_t clock); +/* End user code. Do not edit comment generated here */ +#endif + diff --git a/cores/rl78g22/smc_gen/Config_IICA0/Config_IICA0_user.c b/cores/rl78g22/smc_gen/Config_IICA0/Config_IICA0_user.c index 902a8c0..7a6fdb2 100644 --- a/cores/rl78g22/smc_gen/Config_IICA0/Config_IICA0_user.c +++ b/cores/rl78g22/smc_gen/Config_IICA0/Config_IICA0_user.c @@ -1,227 +1,227 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2021, 2022 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_IICA0_user.c -* Component Version: 1.4.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_IICA0. -* Creation Date : -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_IICA0.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -extern volatile uint8_t g_iica0_master_status_flag; /* iica0 master flag */ -extern volatile uint8_t * gp_iica0_rx_address; /* iica0 receive buffer address */ -extern volatile uint16_t g_iica0_rx_len; /* iica0 receive data length */ -extern volatile uint16_t g_iica0_rx_cnt; /* iica0 receive data count */ -extern volatile uint8_t * gp_iica0_tx_address; /* iica0 send buffer address */ -extern volatile uint16_t g_iica0_tx_cnt; /* iica0 send data count */ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_IICA0_Create_UserInit -* Description : This function adds user code after initializing the IICA0. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_IICA0_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_IICA0_callback_master_sendend -* Description : This function is a callback function when IICA0 finishes master transmission. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_IICA0_callback_master_sendend(void) -{ - SPT0 = 1U; -/* Start user code for r_Config_IICA0_callback_master_sendend. Do not edit comment generated here */ - g_iica0_master_status_flag |= _40_IICA_DATA_COMPLETE; -/* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_IICA0_callback_master_receiveend -* Description : This function is a callback function when IICA0 finishes master reception. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_IICA0_callback_master_receiveend(void) -{ - SPT0 = 1U; -/* Start user code for r_Config_IICA0_callback_master_receiveend. Do not edit comment generated here */ - g_iica0_master_status_flag |= _40_IICA_DATA_COMPLETE; -/* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_IICA0_callback_master_error -* Description : This function is a callback function when IICA0 master error occurs. -* Arguments : flag - -* status flag -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_IICA0_callback_master_error(MD_STATUS flag) -{ - /* Start user code for r_Config_IICA0_callback_master_error. Do not edit comment generated here */ - g_iica0_master_status_flag = (g_iica0_master_status_flag & 0xF0U) | (flag & 0x0FU); - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_IICA0_master_handler -* Description : This function is IICA0 master handler -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_IICA0_master_handler(void) -{ - /* Detection of stop condition handling */ - if ((0U == IICBSY0) && (0U != g_iica0_tx_cnt)) - { - r_Config_IICA0_callback_master_error(MD_SPT); - } - else - { - /* Control for sended address */ - if (0U == (g_iica0_master_status_flag & _80_IICA_ADDRESS_COMPLETE)) - { - if (1U == ACKD0) - { - g_iica0_master_status_flag |= _80_IICA_ADDRESS_COMPLETE; - - if (1U == TRC0) - { - WTIM0 = 1U; - - if (g_iica0_tx_cnt > 0U) - { - IICA0 = *gp_iica0_tx_address; - gp_iica0_tx_address++; - g_iica0_tx_cnt--; - } - else - { - r_Config_IICA0_callback_master_sendend(); - } - } - else - { - ACKE0 = 1U; - WTIM0 = 0U; - WREL0 = 1U; - } - } - else - { - r_Config_IICA0_callback_master_error(MD_NACK); - } - } - else - { - /* Master send control */ - if (1U == TRC0) - { - if ((0U == ACKD0) && (0U != g_iica0_tx_cnt)) - { - r_Config_IICA0_callback_master_error(MD_NACK); - } - else - { - if (g_iica0_tx_cnt > 0U) - { - IICA0 = *gp_iica0_tx_address; - gp_iica0_tx_address++; - g_iica0_tx_cnt--; - } - else - { - r_Config_IICA0_callback_master_sendend(); - } - } - } - /* Master receive control */ - else - { - if (g_iica0_rx_cnt < g_iica0_rx_len) - { - *gp_iica0_rx_address = IICA0; - gp_iica0_rx_address++; - g_iica0_rx_cnt++; - - if (g_iica0_rx_cnt == g_iica0_rx_len) - { - ACKE0 = 0U; - WTIM0 = 1U; - WREL0 = 1U; - } - else - { - WREL0 = 1U; - } - } - else - { - r_Config_IICA0_callback_master_receiveend(); - } - } - } - } -} - -/*********************************************************************************************************************** -* Function Name: r_Config_IICA0_interrupt -* Description : This function is INTIICA0 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_IICA0_interrupt(void) -{ - /* Start user code for r_Config_IICA0_interrupt. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ - if (0x80U == (IICS0 & _80_IICA_STATUS_MASTER)) - { - r_Config_IICA0_master_handler(); - } -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021, 2022 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_IICA0_user.c +* Component Version: 1.4.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_IICA0. +* Creation Date : +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_IICA0.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +extern volatile uint8_t g_iica0_master_status_flag; /* iica0 master flag */ +extern volatile uint8_t * gp_iica0_rx_address; /* iica0 receive buffer address */ +extern volatile uint16_t g_iica0_rx_len; /* iica0 receive data length */ +extern volatile uint16_t g_iica0_rx_cnt; /* iica0 receive data count */ +extern volatile uint8_t * gp_iica0_tx_address; /* iica0 send buffer address */ +extern volatile uint16_t g_iica0_tx_cnt; /* iica0 send data count */ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_IICA0_Create_UserInit +* Description : This function adds user code after initializing the IICA0. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_IICA0_Create_UserInit(void) +{ + /* Start user code for user init. Do not edit comment generated here */ + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_IICA0_callback_master_sendend +* Description : This function is a callback function when IICA0 finishes master transmission. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_IICA0_callback_master_sendend(void) +{ + SPT0 = 1U; +/* Start user code for r_Config_IICA0_callback_master_sendend. Do not edit comment generated here */ + g_iica0_master_status_flag |= _40_IICA_DATA_COMPLETE; +/* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_IICA0_callback_master_receiveend +* Description : This function is a callback function when IICA0 finishes master reception. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_IICA0_callback_master_receiveend(void) +{ + SPT0 = 1U; +/* Start user code for r_Config_IICA0_callback_master_receiveend. Do not edit comment generated here */ + g_iica0_master_status_flag |= _40_IICA_DATA_COMPLETE; +/* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_IICA0_callback_master_error +* Description : This function is a callback function when IICA0 master error occurs. +* Arguments : flag - +* status flag +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_IICA0_callback_master_error(MD_STATUS flag) +{ + /* Start user code for r_Config_IICA0_callback_master_error. Do not edit comment generated here */ + g_iica0_master_status_flag = (g_iica0_master_status_flag & 0xF0U) | (flag & 0x0FU); + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_IICA0_master_handler +* Description : This function is IICA0 master handler +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_IICA0_master_handler(void) +{ + /* Detection of stop condition handling */ + if ((0U == IICBSY0) && (0U != g_iica0_tx_cnt)) + { + r_Config_IICA0_callback_master_error(MD_SPT); + } + else + { + /* Control for sended address */ + if (0U == (g_iica0_master_status_flag & _80_IICA_ADDRESS_COMPLETE)) + { + if (1U == ACKD0) + { + g_iica0_master_status_flag |= _80_IICA_ADDRESS_COMPLETE; + + if (1U == TRC0) + { + WTIM0 = 1U; + + if (g_iica0_tx_cnt > 0U) + { + IICA0 = *gp_iica0_tx_address; + gp_iica0_tx_address++; + g_iica0_tx_cnt--; + } + else + { + r_Config_IICA0_callback_master_sendend(); + } + } + else + { + ACKE0 = 1U; + WTIM0 = 0U; + WREL0 = 1U; + } + } + else + { + r_Config_IICA0_callback_master_error(MD_NACK); + } + } + else + { + /* Master send control */ + if (1U == TRC0) + { + if ((0U == ACKD0) && (0U != g_iica0_tx_cnt)) + { + r_Config_IICA0_callback_master_error(MD_NACK); + } + else + { + if (g_iica0_tx_cnt > 0U) + { + IICA0 = *gp_iica0_tx_address; + gp_iica0_tx_address++; + g_iica0_tx_cnt--; + } + else + { + r_Config_IICA0_callback_master_sendend(); + } + } + } + /* Master receive control */ + else + { + if (g_iica0_rx_cnt < g_iica0_rx_len) + { + *gp_iica0_rx_address = IICA0; + gp_iica0_rx_address++; + g_iica0_rx_cnt++; + + if (g_iica0_rx_cnt == g_iica0_rx_len) + { + ACKE0 = 0U; + WTIM0 = 1U; + WREL0 = 1U; + } + else + { + WREL0 = 1U; + } + } + else + { + r_Config_IICA0_callback_master_receiveend(); + } + } + } + } +} + +/*********************************************************************************************************************** +* Function Name: r_Config_IICA0_interrupt +* Description : This function is INTIICA0 interrupt service routine. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_IICA0_interrupt(void) +{ + /* Start user code for r_Config_IICA0_interrupt. Do not edit comment generated here */ + /* End user code. Do not edit comment generated here */ + if (0x80U == (IICS0 & _80_IICA_STATUS_MASTER)) + { + r_Config_IICA0_master_handler(); + } +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_INTC/Config_INTC.c b/cores/rl78g22/smc_gen/Config_INTC/Config_INTC.c index c4cb0da..52ad7c2 100644 --- a/cores/rl78g22/smc_gen/Config_INTC/Config_INTC.c +++ b/cores/rl78g22/smc_gen/Config_INTC/Config_INTC.c @@ -1,796 +1,428 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_INTC.c -* Version : 1.0.0 -* Device(s) : R7F100GLGxFB -* Description : This file implements device driver for Config_INTC. -* Creation Date: 2021-11-04 -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_INTC.h" -/* Start user code for include. Do not edit comment generated here */ -#include "wiring_variant.h" -#include -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -typedef struct { - uint8_t intNum; - uint8_t pinNum; - int modeNum; -} Num; -Num value; - -/* End user code. Do not edit comment generated here */ -/*********************************************************************************************************************** -* Function Name: R_Config_INTC_Create -* Description : This function initializes the INTC module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_INTC_Create(void) -{ - PMK1 = 1U; /* disable INTP1 operation */ - PIF1 = 0U; /* clear INTP1 interrupt flag */ - PMK2 = 1U; /* disable INTP2 operation */ - PIF2 = 0U; /* clear INTP2 interrupt flag */ - PMK3 = 1U; /* disable INTP3 operation */ - PIF3 = 0U; /* clear INTP3 interrupt flag */ - PMK4 = 1U; /* disable INTP4 operation */ - PIF4 = 0U; /* clear INTP4 interrupt flag */ - PMK5 = 1U; /* disable INTP10 operation */ - PIF5 = 0U; /* clear INTP10 interrupt flag */ - PMK6 = 1U; /* disable INTP11 operation */ - PIF6 = 0U; /* clear INTP11 interrupt flag */ - /* Set INTP0 low priority */ - PPR10 = 1U; - PPR00 = 1U; - /* Set INTP1 low priority */ - PPR11 = 1U; - PPR01 = 1U; - /* Set INTP2 low priority */ - PPR12 = 1U; - PPR02 = 1U; - /* Set INTP3 low priority */ - PPR13 = 1U; - PPR03 = 1U; - /* Set INTP4 low priority */ - PPR14 = 1U; - PPR04 = 1U; - /* Set INTP5 low priority */ - PPR15 = 1U; - PPR05 = 1U; - /* Set INTP6 low priority */ - PPR16 = 1U; - PPR06 = 1U; - EGN0 = _10_INTP4_EDGE_FALLING_SEL | _08_INTP3_EDGE_FALLING_SEL | _04_INTP2_EDGE_FALLING_SEL | - _02_INTP1_EDGE_FALLING_SEL | _01_INTP0_EDGE_FALLING_SEL | _20_INTP5_EDGE_FALLING_SEL| _40_INTP6_EDGE_FALLING_SEL; - EGP0 = _00_INTP4_EDGE_RISING_UNSEL | _00_INTP3_EDGE_RISING_UNSEL | _00_INTP2_EDGE_RISING_UNSEL | - _00_INTP1_EDGE_RISING_UNSEL | _00_INTP0_EDGE_RISING_UNSEL | _00_INTP5_EDGE_RISING_UNSEL | _00_INTP6_EDGE_RISING_UNSEL ; -// EGN1 = _08_INTP11_EDGE_FALLING_SEL | _04_INTP10_EDGE_FALLING_SEL; -// EGP1 = _00_INTP11_EDGE_RISING_UNSEL | _00_INTP10_EDGE_RISING_UNSEL; - /* Set INTP1 pin */ - PMCT5 &= 0xFEU; -// PMCE5 &= 0xFEU; -// CCDE &= 0xF7U; - PM5 |= 0x01U; - /* Set INTP2 pin */ -// PMCE5 &= 0xFDU; -// CCDE &= 0xFBU; - PM5 |= 0x02U; - /* Set INTP3 pin */ - PMCT3 &= 0xFEU; - PM3 |= 0x01U; - /* Set INTP4 pin */ - PMCT3 &= 0xFDU; - PM3 |= 0x02U; - /* Set INTP5 pin */ -// PMCT1 &= 0xDEU; -// PM1 |= 0x20U; - PMCT1 &= 0xBEU; - PM1 |= 0x40U; - /* Set INTP6 pin */ - PMCT14 &= 0xC0U; - PM14 |= 0x01U; - - R_Config_INTC_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_INTC_INTP0_Start -* Description : This function clears INTP0 interrupt flag and enables interrupt. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_INTC_INTP0_Start(void) -{ - PIF0 = 0U; /* clear INTP0 interrupt flag */ - PMK0 = 0U; /* enable INTP0 interrupt */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_INTC_INTP0_Stop -* Description : This function disables INTP0 interrupt and clears interrupt flag. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_INTC_INTP0_Stop(void) -{ - PMK0 = 1U; /* disable INTP0 interrupt */ - PIF0 = 0U; /* clear INTP0 interrupt flag */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_INTC_INTP1_Start -* Description : This function clears INTP1 interrupt flag and enables interrupt. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_INTC_INTP1_Start(void) -{ - PIF1 = 0U; /* clear INTP1 interrupt flag */ - PMK1 = 0U; /* enable INTP1 interrupt */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_INTC_INTP1_Stop -* Description : This function disables INTP1 interrupt and clears interrupt flag. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_INTC_INTP1_Stop(void) -{ - PMK1 = 1U; /* disable INTP1 interrupt */ - PIF1 = 0U; /* clear INTP1 interrupt flag */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_INTC_INTP2_Start -* Description : This function clears INTP2 interrupt flag and enables interrupt. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_INTC_INTP2_Start(void) -{ - PIF2 = 0U; /* clear INTP2 interrupt flag */ - PMK2 = 0U; /* enable INTP2 interrupt */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_INTC_INTP2_Stop -* Description : This function disables INTP2 interrupt and clears interrupt flag. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_INTC_INTP2_Stop(void) -{ - PMK2 = 1U; /* disable INTP2 interrupt */ - PIF2 = 0U; /* clear INTP2 interrupt flag */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_INTC_INTP3_Start -* Description : This function clears INTP3 interrupt flag and enables interrupt. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_INTC_INTP3_Start(void) -{ - PIF3 = 0U; /* clear INTP3 interrupt flag */ - PMK3 = 0U; /* enable INTP3 interrupt */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_INTC_INTP3_Stop -* Description : This function disables INTP3 interrupt and clears interrupt flag. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_INTC_INTP3_Stop(void) -{ - PMK3 = 1U; /* disable INTP3 interrupt */ - PIF3 = 0U; /* clear INTP3 interrupt flag */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_INTC_INTP4_Start -* Description : This function clears INTP4 interrupt flag and enables interrupt. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_INTC_INTP4_Start(void) -{ - PIF4 = 0U; /* clear INTP4 interrupt flag */ - PMK4 = 0U; /* enable INTP4 interrupt */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_INTC_INTP4_Stop -* Description : This function disables INTP4 interrupt and clears interrupt flag. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_INTC_INTP4_Stop(void) -{ - PMK4 = 1U; /* disable INTP4 interrupt */ - PIF4 = 0U; /* clear INTP4 interrupt flag */ -} - -// 2022/11/16 added by KAD -/*********************************************************************************************************************** -* Function Name: R_Config_INTC_INTP5_Start -* Description : This function clears INTP4 interrupt flag and enables interrupt. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_INTC_INTP5_Start(void) -{ - PIF5 = 0U; /* clear INTP5 interrupt flag */ - PMK5 = 0U; /* enable INTP5 interrupt */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_INTC_INTP5_Stop -* Description : This function disables INTP3 interrupt and clears interrupt flag. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_INTC_INTP5_Stop(void) -{ - PMK5 = 1U; /* disable INTP5 interrupt */ - PIF5 = 0U; /* clear INTP5 interrupt flag */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_INTC_INTP6_Start -* Description : This function clears INTP4 interrupt flag and enables interrupt. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_INTC_INTP6_Start(void) -{ - PIF6 = 0U; /* clear INTP6 interrupt flag */ - PMK6 = 0U; /* enable INTP6 interrupt */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_INTC_INTP6_Stop -* Description : This function disables INTP6 interrupt and clears interrupt flag. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_INTC_INTP6_Stop(void) -{ - PMK6 = 1U; /* disable INTP6 interrupt */ - PIF6 = 0U; /* clear INTP6 interrupt flag */ -} - - - -/* Start user code for adding. Do not edit comment generated here */ -// mod 2022/10/17 fit to RL78/G23 by KAD -void R_Config_INTC_Create_Mode(uint8_t interruptNum, int mode) -{ - switch (interruptNum) { - case 0: - value.intNum = interruptNum; - value.pinNum = EXTERNAL_INTERRUPT_0; - value.modeNum = mode; - // 割り込みモードの設定 - // 1102 nhu del -// if (value.modeNum == FALLING) { -// EGP0_bit.no0 = 0U; -// EGN0_bit.no0 = 1U; -// } -// else if (value.modeNum == RISING) { -// EGP0_bit.no0 = 1U; -// EGN0_bit.no0 = 0U; -// } -// else if (value.modeNum == CHANGE){ -// EGP0_bit.no0 = 1U; -// EGN0_bit.no0 = 1U; -// } -// else{ -// EGP0_bit.no0 = 0U; -// EGN0_bit.no0 = 0U; -// } - if (value.modeNum == FALLING) { - EGP0_bit.no6 = 0U; - EGN0_bit.no6 = 1U; - } - else if (value.modeNum == RISING) { - EGP0_bit.no6 = 1U; - EGN0_bit.no6 = 0U; - } - else if (value.modeNum == CHANGE){ - EGP0_bit.no6 = 1U; - EGN0_bit.no6 = 1U; - } - else{ - EGP0_bit.no6 = 0U; - EGN0_bit.no6 = 0U; - } - break; - case 1: - value.intNum = interruptNum; - value.pinNum = EXTERNAL_INTERRUPT_1; - value.modeNum = mode; - // 割り込みモードの設定 - // 1202 nhu del -// if (value.modeNum == FALLING) { -// EGP0_bit.no1 = 0U; -// EGN0_bit.no1 = 1U; -// } -// else if (value.modeNum == RISING) { -// EGP0_bit.no1 = 1U; -// EGN0_bit.no1 = 0U; -// } -// else if (value.modeNum == CHANGE){ -// EGP0_bit.no1 = 1U; -// EGN0_bit.no1 = 1U; -// } -// else{ -// EGP0_bit.no1 = 0U; -// EGN0_bit.no1 = 0U; -// } - if (value.modeNum == FALLING) { - EGP0_bit.no4 = 0U; - EGN0_bit.no4 = 1U; - } - else if (value.modeNum == RISING) { - EGP0_bit.no4 = 1U; - EGN0_bit.no4 = 0U; - } - else if (value.modeNum == CHANGE){ - EGP0_bit.no4 = 1U; - EGN0_bit.no4 = 1U; - } - else{ - EGP0_bit.no4 = 0U; - EGN0_bit.no4 = 0U; - } - break; - case 2: - value.intNum = interruptNum; - value.pinNum = EXTERNAL_INTERRUPT_2; - value.modeNum = mode; - // 割り込みモードの設定 - // 1102 nhu del -// if (value.modeNum == FALLING) { -// EGP0_bit.no2 = 0U; -// EGN0_bit.no2 = 1U; -// } -// else if (value.modeNum == RISING) { -// EGP0_bit.no2 = 1U; -// EGN0_bit.no2 = 0U; -// } -// else if (value.modeNum == CHANGE){ -// EGP0_bit.no2 = 1U; -// EGN0_bit.no2 = 1U; -// } -// else{ -// EGP0_bit.no2 = 0U; -// EGN0_bit.no2 = 0U; -// } - if (value.modeNum == FALLING) { - EGP0_bit.no5 = 0U; - EGN0_bit.no5 = 1U; - } - else if (value.modeNum == RISING) { - EGP0_bit.no5 = 1U; - EGN0_bit.no5 = 0U; - } - else if (value.modeNum == CHANGE){ - EGP0_bit.no5 = 1U; - EGN0_bit.no5 = 1U; - } - else{ - EGP0_bit.no5 = 0U; - EGN0_bit.no5 = 0U; - } - break; - case 3: - value.intNum = interruptNum; - value.pinNum = EXTERNAL_INTERRUPT_3; - value.modeNum = mode; - // 割り込みモードの設定 - // 1102 nhu del -// if (value.modeNum == FALLING) { -// EGP0_bit.no3 = 0U; -// EGN0_bit.no3 = 1U; -// } -// else if (value.modeNum == RISING) { -// EGP0_bit.no3 = 1U; -// EGN0_bit.no3 = 0U; -// } -// else if (value.modeNum == CHANGE){ -// EGP0_bit.no3 = 1U; -// EGN0_bit.no3 = 1U; -// } -// else{ -// EGP0_bit.no3 = 0U; -// EGN0_bit.no3 = 0U; -// } - if (value.modeNum == FALLING) { - EGP0_bit.no0 = 0U; - EGN0_bit.no0 = 1U; - } - else if (value.modeNum == RISING) { - EGP0_bit.no0 = 1U; - EGN0_bit.no0 = 0U; - } - else if (value.modeNum == CHANGE){ - EGP0_bit.no0 = 1U; - EGN0_bit.no0 = 1U; - } - else{ - EGP0_bit.no0 = 0U; - EGN0_bit.no0 = 0U; - } - break; - // 1202 nhu del - /* - case 4: - value.intNum = interruptNum; - value.pinNum = EXTERNAL_INTERRUPT_4; - value.modeNum = mode; - // 割り込みモードの設定 - if (value.modeNum == FALLING) { - EGP0_bit.no4 = 0U; - EGN0_bit.no4 = 1U; - } - else if (value.modeNum == RISING) { - EGP0_bit.no4 = 1U; - EGN0_bit.no4 = 0U; - } - else if (value.modeNum == CHANGE){ - EGP0_bit.no4 = 1U; - EGN0_bit.no4 = 1U; - } - else{ - EGP0_bit.no4 = 0U; - EGN0_bit.no4 = 0U; - } - break; - case 5: - value.intNum = interruptNum; - value.pinNum = EXTERNAL_INTERRUPT_5; - value.modeNum = mode; - // 割り込みモードの設定 - if (value.modeNum == FALLING) { - EGP0_bit.no5 = 0U; - EGN0_bit.no5 = 1U; - } - else if (value.modeNum == RISING) { - EGP0_bit.no5 = 1U; - EGN0_bit.no5 = 0U; - } - else if (value.modeNum == CHANGE){ - EGP0_bit.no5 = 1U; - EGN0_bit.no5 = 1U; - } - else{ - EGP0_bit.no5 = 0U; - EGN0_bit.no5 = 0U; - } - break; - - case 6: - value.intNum = interruptNum; - value.pinNum = EXTERNAL_INTERRUPT_6; - value.modeNum = mode; - // 割り込みモードの設定 - if (value.modeNum == FALLING) { - EGP0_bit.no6 = 0U; - EGN0_bit.no6 = 1U; - } - else if (value.modeNum == RISING) { - EGP0_bit.no6 = 1U; - EGN0_bit.no6 = 0U; - } - else if (value.modeNum == CHANGE){ - EGP0_bit.no6 = 1U; - EGN0_bit.no6 = 1U; - } - else{ - EGP0_bit.no6 = 0U; - EGN0_bit.no6 = 0U; - } - break; - */ - } -} - -/* -void R_Config_INTC_Create_Mode(uint8_t interruptNum, int mode) -{ - switch (interruptNum) { - case 0: - value.intNum = interruptNum; - value.pinNum = EXTERNAL_INTERRUPT_0; - value.modeNum = mode; - // 割り込みモードの設定 - if (value.modeNum == FALLING) { - EGP1_bit.no3 = 0U; - EGN1_bit.no3 = 1U; - } - else if (value.modeNum == RISING) { - EGP1_bit.no3 = 1U; - EGN1_bit.no3 = 0U; - } - else if (value.modeNum == CHANGE){ - EGP1_bit.no3 = 1U; - EGN1_bit.no3 = 1U; - } - else{ - EGP1_bit.no3 = 0U; - EGN1_bit.no3 = 0U; - } - break; - case 1: - value.intNum = interruptNum; - value.pinNum = EXTERNAL_INTERRUPT_1; - value.modeNum = mode; - // 割り込みモードの設定 - if (value.modeNum == FALLING) { - EGP0_bit.no4 = 0U; - EGN0_bit.no4 = 1U; - } - else if (value.modeNum == RISING) { - EGP0_bit.no4 = 1U; - EGN0_bit.no4 = 0U; - } - else if (value.modeNum == CHANGE){ - EGP0_bit.no4 = 1U; - EGN0_bit.no4 = 1U; - } - else{ - EGP0_bit.no4 = 0U; - EGN0_bit.no4 = 0U; - } - break; - case 2: - value.intNum = interruptNum; - value.pinNum = EXTERNAL_INTERRUPT_2; - value.modeNum = mode; - // 割り込みモードの設定 - if (value.modeNum == FALLING) { - EGP1_bit.no2 = 0U; - EGN1_bit.no2 = 1U; - } - else if (value.modeNum == RISING) { - EGP1_bit.no2 = 1U; - EGN1_bit.no2 = 0U; - } - else if (value.modeNum == CHANGE){ - EGP1_bit.no2 = 1U; - EGN1_bit.no2 = 1U; - } - else{ - EGP1_bit.no2 = 0U; - EGN1_bit.no2 = 0U; - } - break; - case 3: - value.intNum = interruptNum; - value.pinNum = EXTERNAL_INTERRUPT_3; - value.modeNum = mode; - // 割り込みモードの設定 - if (value.modeNum == FALLING) { - EGP0_bit.no2 = 0U; - EGN0_bit.no2 = 1U; - } - else if (value.modeNum == RISING) { - EGP0_bit.no2 = 1U; - EGN0_bit.no2 = 0U; - } - else if (value.modeNum == CHANGE){ - EGP0_bit.no2 = 1U; - EGN0_bit.no2 = 1U; - } - else{ - EGP0_bit.no2 = 0U; - EGN0_bit.no2 = 0U; - } - break; - case 4: - value.intNum = interruptNum; - value.pinNum = EXTERNAL_INTERRUPT_4; - value.modeNum = mode; - // 割り込みモードの設定 - if (value.modeNum == FALLING) { - EGP0_bit.no1 = 0U; - EGN0_bit.no1 = 1U; - } - else if (value.modeNum == RISING) { - EGP0_bit.no1 = 1U; - EGN0_bit.no1 = 0U; - } - else if (value.modeNum == CHANGE){ - EGP0_bit.no1 = 1U; - EGN0_bit.no1 = 1U; - } - else{ - EGP0_bit.no1 = 0U; - EGN0_bit.no1 = 0U; - } - break; - case 5: - value.intNum = interruptNum; - value.pinNum = EXTERNAL_INTERRUPT_5; - value.modeNum = mode; - // 割り込みモードの設定 - if (value.modeNum == FALLING) { - EGP0_bit.no3 = 0U; - EGN0_bit.no3 = 1U; - } - else if (value.modeNum == RISING) { - EGP0_bit.no3 = 1U; - EGN0_bit.no3 = 0U; - } - else if (value.modeNum == CHANGE){ - EGP0_bit.no3 = 1U; - EGN0_bit.no3 = 1U; - } - else{ - EGP0_bit.no3 = 0U; - EGN0_bit.no3 = 0U; - } - break; - case 6: - value.intNum = interruptNum; - value.pinNum = EXTERNAL_INTERRUPT_6; - value.modeNum = mode; - // 割り込みモードの設定 - if (value.modeNum == FALLING) { - EGP0_bit.no0 = 0U; - EGN0_bit.no0 = 1U; - } - else if (value.modeNum == RISING) { - EGP0_bit.no0 = 1U; - EGN0_bit.no0 = 0U; - } - else if (value.modeNum == CHANGE){ - EGP0_bit.no0 = 1U; - EGN0_bit.no0 = 1U; - } - else{ - EGP0_bit.no0 = 0U; - EGN0_bit.no0 = 0U; - } - break; - } -} -*/ - -// mod 2022/10/17 fit to RL78/G23 by KAD -void R_Config_INTC_INTP_Start(void){ - if(value.pinNum == EXTERNAL_INTERRUPT_0){ - // 1102 nhu del -// R_Config_INTC_INTP0_Start(); - R_Config_INTC_INTP6_Start(); - } - else if (value.pinNum == EXTERNAL_INTERRUPT_1){ - // 1102 nhu del -// R_Config_INTC_INTP1_Start(); - R_Config_INTC_INTP4_Start(); - } - else if (value.pinNum == EXTERNAL_INTERRUPT_2){ - // 1102 nhu del -// R_Config_INTC_INTP2_Start(); - R_Config_INTC_INTP5_Start(); - } - else if (value.pinNum == EXTERNAL_INTERRUPT_3){ - // 1102 nhu del -// R_Config_INTC_INTP3_Start(); - R_Config_INTC_INTP0_Start(); - } - // 1102 nhu del - /* - else if (value.pinNum == EXTERNAL_INTERRUPT_4){ - R_Config_INTC_INTP4_Start(); - } - else if (value.pinNum == EXTERNAL_INTERRUPT_5){ - R_Config_INTC_INTP5_Start(); - } - else if (value.pinNum == EXTERNAL_INTERRUPT_6){ - R_Config_INTC_INTP6_Start(); - } - */ -} -/* -void R_Config_INTC_INTP_Start(void){ - if(value.pinNum == EXTERNAL_INTERRUPT_0){ - R_Config_INTC_INTP11_Start(); - } - else if (value.pinNum == EXTERNAL_INTERRUPT_1){ - R_Config_INTC_INTP4_Start(); - } - else if (value.pinNum == EXTERNAL_INTERRUPT_2){ - R_Config_INTC_INTP10_Start(); - } - else if (value.pinNum == EXTERNAL_INTERRUPT_3){ - R_Config_INTC_INTP2_Start(); - } - else if (value.pinNum == EXTERNAL_INTERRUPT_4){ - R_Config_INTC_INTP1_Start(); - } - else if (value.pinNum == EXTERNAL_INTERRUPT_5){ - R_Config_INTC_INTP3_Start(); - } - else if (value.pinNum == EXTERNAL_INTERRUPT_6){ - R_Config_INTC_INTP0_Start(); - } -} -*/ - -void R_Config_INTC_INTP_Stop(uint8_t interruptNum){ - switch (interruptNum) { - case 0: - // 1102 nhu del -// R_Config_INTC_INTP0_Stop(); - R_Config_INTC_INTP6_Stop(); - break; - case 1: - // 1102 nhu del -// R_Config_INTC_INTP1_Stop(); - R_Config_INTC_INTP4_Stop(); - break; - - case 2: - // 1102 nhu del -// R_Config_INTC_INTP2_Stop(); - R_Config_INTC_INTP5_Stop(); - break; - case 3: - // 1102 nhu del -// R_Config_INTC_INTP3_Stop(); - R_Config_INTC_INTP0_Stop(); - break; - // 1102 nhu del - /* - case 4: - R_Config_INTC_INTP4_Stop(); - break; - case 5: - R_Config_INTC_INTP5_Stop(); - break; - case 6: - R_Config_INTC_INTP6_Stop(); - break; - */ - } -} -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_INTC.c +* Version : 1.0.0 +* Device(s) : R7F100GLGxFB +* Description : This file implements device driver for Config_INTC. +* Creation Date: 2021-11-04 +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_INTC.h" +/* Start user code for include. Do not edit comment generated here */ +#include "wiring_variant.h" +#include +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +typedef struct { + uint8_t intNum; + uint8_t pinNum; + PinStatus modeNum; +} Num; +Num value; + +/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* Function Name: R_Config_INTC_Create +* Description : This function initializes the INTC module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_INTC_Create(void) +{ + PMK1 = 1U; /* disable INTP1 operation */ + PIF1 = 0U; /* clear INTP1 interrupt flag */ + PMK2 = 1U; /* disable INTP2 operation */ + PIF2 = 0U; /* clear INTP2 interrupt flag */ + PMK3 = 1U; /* disable INTP3 operation */ + PIF3 = 0U; /* clear INTP3 interrupt flag */ + PMK4 = 1U; /* disable INTP4 operation */ + PIF4 = 0U; /* clear INTP4 interrupt flag */ + PMK5 = 1U; /* disable INTP10 operation */ + PIF5 = 0U; /* clear INTP10 interrupt flag */ + PMK6 = 1U; /* disable INTP11 operation */ + PIF6 = 0U; /* clear INTP11 interrupt flag */ + /* Set INTP0 low priority */ + PPR10 = 1U; + PPR00 = 1U; + /* Set INTP1 low priority */ + PPR11 = 1U; + PPR01 = 1U; + /* Set INTP2 low priority */ + PPR12 = 1U; + PPR02 = 1U; + /* Set INTP3 low priority */ + PPR13 = 1U; + PPR03 = 1U; + /* Set INTP4 low priority */ + PPR14 = 1U; + PPR04 = 1U; + /* Set INTP5 low priority */ + PPR15 = 1U; + PPR05 = 1U; + /* Set INTP6 low priority */ + PPR16 = 1U; + PPR06 = 1U; +/* + EGN0 = _10_INTP4_EDGE_FALLING_SEL | _08_INTP3_EDGE_FALLING_SEL | _04_INTP2_EDGE_FALLING_SEL | + _02_INTP1_EDGE_FALLING_SEL | _01_INTP0_EDGE_FALLING_SEL | _20_INTP5_EDGE_FALLING_SEL| _40_INTP6_EDGE_FALLING_SEL; + EGP0 = _00_INTP4_EDGE_RISING_UNSEL | _00_INTP3_EDGE_RISING_UNSEL | _00_INTP2_EDGE_RISING_UNSEL | + _00_INTP1_EDGE_RISING_UNSEL | _00_INTP0_EDGE_RISING_UNSEL | _00_INTP5_EDGE_RISING_UNSEL | _00_INTP6_EDGE_RISING_UNSEL ; + EGN1 = _08_INTP11_EDGE_FALLING_SEL | _04_INTP10_EDGE_FALLING_SEL; + EGP1 = _00_INTP11_EDGE_RISING_UNSEL | _00_INTP10_EDGE_RISING_UNSEL; +*/ + /* Set INTP1 pin */ +// PMCT5 &= 0xFEU; +// PMCE5 &= 0xFEU; +// CCDE &= 0xF7U; +// PM5 |= 0x01U; + /* Set INTP2 pin */ +// PMCE5 &= 0xFDU; +// CCDE &= 0xFBU; +// PM5 |= 0x02U; + /* Set INTP3 pin */ +// PMCT3 &= 0xFEU; +// PM3 |= 0x01U; + /* Set INTP4 pin */ +// PMCT3 &= 0xFDU; +// PM3 |= 0x02U; + /* Set INTP5 pin */ +// PMCT1 &= 0xDEU; +// PM1 |= 0x20U; +// PMCT1 &= 0xBEU; +// PM1 |= 0x40U; + /* Set INTP6 pin */ +// PMCT14 &= 0xC0U; +// PM14 |= 0x01U; + + R_Config_INTC_Create_UserInit(); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_INTC_INTP0_Start +* Description : This function clears INTP0 interrupt flag and enables interrupt. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_INTC_INTP0_Start(void) +{ + PIF0 = 0U; /* clear INTP0 interrupt flag */ + PMK0 = 0U; /* enable INTP0 interrupt */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_INTC_INTP0_Stop +* Description : This function disables INTP0 interrupt and clears interrupt flag. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_INTC_INTP0_Stop(void) +{ + PMK0 = 1U; /* disable INTP0 interrupt */ + PIF0 = 0U; /* clear INTP0 interrupt flag */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_INTC_INTP1_Start +* Description : This function clears INTP1 interrupt flag and enables interrupt. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_INTC_INTP1_Start(void) +{ + PIF1 = 0U; /* clear INTP1 interrupt flag */ + PMK1 = 0U; /* enable INTP1 interrupt */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_INTC_INTP1_Stop +* Description : This function disables INTP1 interrupt and clears interrupt flag. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_INTC_INTP1_Stop(void) +{ + PMK1 = 1U; /* disable INTP1 interrupt */ + PIF1 = 0U; /* clear INTP1 interrupt flag */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_INTC_INTP2_Start +* Description : This function clears INTP2 interrupt flag and enables interrupt. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_INTC_INTP2_Start(void) +{ + PIF2 = 0U; /* clear INTP2 interrupt flag */ + PMK2 = 0U; /* enable INTP2 interrupt */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_INTC_INTP2_Stop +* Description : This function disables INTP2 interrupt and clears interrupt flag. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_INTC_INTP2_Stop(void) +{ + PMK2 = 1U; /* disable INTP2 interrupt */ + PIF2 = 0U; /* clear INTP2 interrupt flag */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_INTC_INTP3_Start +* Description : This function clears INTP3 interrupt flag and enables interrupt. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_INTC_INTP3_Start(void) +{ + PIF3 = 0U; /* clear INTP3 interrupt flag */ + PMK3 = 0U; /* enable INTP3 interrupt */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_INTC_INTP3_Stop +* Description : This function disables INTP3 interrupt and clears interrupt flag. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_INTC_INTP3_Stop(void) +{ + PMK3 = 1U; /* disable INTP3 interrupt */ + PIF3 = 0U; /* clear INTP3 interrupt flag */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_INTC_INTP4_Start +* Description : This function clears INTP4 interrupt flag and enables interrupt. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_INTC_INTP4_Start(void) +{ + PIF4 = 0U; /* clear INTP4 interrupt flag */ + PMK4 = 0U; /* enable INTP4 interrupt */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_INTC_INTP4_Stop +* Description : This function disables INTP4 interrupt and clears interrupt flag. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_INTC_INTP4_Stop(void) +{ + PMK4 = 1U; /* disable INTP4 interrupt */ + PIF4 = 0U; /* clear INTP4 interrupt flag */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_INTC_INTP5_Start +* Description : This function clears INTP4 interrupt flag and enables interrupt. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_INTC_INTP5_Start(void) +{ + PIF5 = 0U; /* clear INTP5 interrupt flag */ + PMK5 = 0U; /* enable INTP5 interrupt */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_INTC_INTP5_Stop +* Description : This function disables INTP3 interrupt and clears interrupt flag. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_INTC_INTP5_Stop(void) +{ + PMK5 = 1U; /* disable INTP5 interrupt */ + PIF5 = 0U; /* clear INTP5 interrupt flag */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_INTC_INTP6_Start +* Description : This function clears INTP4 interrupt flag and enables interrupt. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_INTC_INTP6_Start(void) +{ + PIF6 = 0U; /* clear INTP6 interrupt flag */ + PMK6 = 0U; /* enable INTP6 interrupt */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_INTC_INTP6_Stop +* Description : This function disables INTP6 interrupt and clears interrupt flag. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_INTC_INTP6_Stop(void) +{ + PMK6 = 1U; /* disable INTP6 interrupt */ + PIF6 = 0U; /* clear INTP6 interrupt flag */ +} + + + +/* Start user code for adding. Do not edit comment generated here */ + +void R_Config_INTC_Create_Mode(uint8_t interruptNum, int mode) +{ + switch (interruptNum) { + case 0: + value.intNum = interruptNum; + value.pinNum = EXTERNAL_INTERRUPT_0; + value.modeNum = mode; + if (value.modeNum == FALLING) { + EGP0_bit.no6 = 0U; + EGN0_bit.no6 = 1U; + } + else if (value.modeNum == RISING) { + EGP0_bit.no6 = 1U; + EGN0_bit.no6 = 0U; + } + else if (value.modeNum == CHANGE){ + EGP0_bit.no6 = 1U; + EGN0_bit.no6 = 1U; + } + else{ + EGP0_bit.no6 = 0U; + EGN0_bit.no6 = 0U; + } + break; + case 1: + value.intNum = interruptNum; + value.pinNum = EXTERNAL_INTERRUPT_1; + value.modeNum = mode; + if (value.modeNum == FALLING) { + EGP0_bit.no4 = 0U; + EGN0_bit.no4 = 1U; + } + else if (value.modeNum == RISING) { + EGP0_bit.no4 = 1U; + EGN0_bit.no4 = 0U; + } + else if (value.modeNum == CHANGE){ + EGP0_bit.no4 = 1U; + EGN0_bit.no4 = 1U; + } + else{ + EGP0_bit.no4 = 0U; + EGN0_bit.no4 = 0U; + } + break; + case 2: + value.intNum = interruptNum; + value.pinNum = EXTERNAL_INTERRUPT_2; + value.modeNum = mode; + if (value.modeNum == FALLING) { + EGP0_bit.no5 = 0U; + EGN0_bit.no5 = 1U; + } + else if (value.modeNum == RISING) { + EGP0_bit.no5 = 1U; + EGN0_bit.no5 = 0U; + } + else if (value.modeNum == CHANGE){ + EGP0_bit.no5 = 1U; + EGN0_bit.no5 = 1U; + } + else{ + EGP0_bit.no5 = 0U; + EGN0_bit.no5 = 0U; + } + break; + case 3: + value.intNum = interruptNum; + value.pinNum = EXTERNAL_INTERRUPT_3; + value.modeNum = mode; + if (value.modeNum == FALLING) { + EGP0_bit.no0 = 0U; + EGN0_bit.no0 = 1U; + } + else if (value.modeNum == RISING) { + EGP0_bit.no0 = 1U; + EGN0_bit.no0 = 0U; + } + else if (value.modeNum == CHANGE){ + EGP0_bit.no0 = 1U; + EGN0_bit.no0 = 1U; + } + else{ + EGP0_bit.no0 = 0U; + EGN0_bit.no0 = 0U; + } + break; + } +} + + +void R_Config_INTC_INTP_Start(void){ + if(value.pinNum == EXTERNAL_INTERRUPT_0){ + R_Config_INTC_INTP6_Start(); + } + else if (value.pinNum == EXTERNAL_INTERRUPT_1){ + R_Config_INTC_INTP4_Start(); + } + else if (value.pinNum == EXTERNAL_INTERRUPT_2){ + R_Config_INTC_INTP5_Start(); + } + else if (value.pinNum == EXTERNAL_INTERRUPT_3){ + R_Config_INTC_INTP0_Start(); + } +} + +void R_Config_INTC_INTP_Stop(uint8_t interruptNum){ + switch (interruptNum) { + case 0: + R_Config_INTC_INTP6_Stop(); + break; + case 1: + R_Config_INTC_INTP4_Stop(); + break; + + case 2: + R_Config_INTC_INTP5_Stop(); + break; + case 3: + R_Config_INTC_INTP0_Stop(); + break; + } +} +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_INTC/Config_INTC.h b/cores/rl78g22/smc_gen/Config_INTC/Config_INTC.h index 2940846..d3f9b3f 100644 --- a/cores/rl78g22/smc_gen/Config_INTC/Config_INTC.h +++ b/cores/rl78g22/smc_gen/Config_INTC/Config_INTC.h @@ -1,72 +1,72 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_INTC.h -* Version : 1.0.0 -* Device(s) : R7F100GLGxFB -* Description : This file implements device driver for Config_INTC. -* Creation Date: 2021-11-04 -***********************************************************************************************************************/ - -#ifndef CFG_Config_INTC_H -#define CFG_Config_INTC_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_intc.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_INTC_Create(void); -void R_Config_INTC_INTP1_Start(void); -void R_Config_INTC_INTP1_Stop(void); -void R_Config_INTC_INTP2_Start(void); -void R_Config_INTC_INTP2_Stop(void); -void R_Config_INTC_INTP3_Start(void); -void R_Config_INTC_INTP3_Stop(void); -void R_Config_INTC_INTP4_Start(void); -void R_Config_INTC_INTP4_Stop(void); -void R_Config_INTC_INTP5_Start(void); -void R_Config_INTC_INTP5_Stop(void); -void R_Config_INTC_INTP6_Start(void); -void R_Config_INTC_INTP6_Stop(void); -void R_Config_INTC_Create_UserInit(void); -/* Start user code for function. Do not edit comment generated here */ -/* 1104 Ueeda add */ -void R_Config_INTC_Create_Mode(uint8_t interruptNum, int mode); -void R_Config_INTC_INTP_Start(void); -void R_Config_INTC_INTP_Stop(uint8_t interruptNum); -/* 1104 Ueeda add */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_INTC.h +* Version : 1.0.0 +* Device(s) : R7F100GLGxFB +* Description : This file implements device driver for Config_INTC. +* Creation Date: 2021-11-04 +***********************************************************************************************************************/ + +#ifndef CFG_Config_INTC_H +#define CFG_Config_INTC_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_intc.h" + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_Config_INTC_Create(void); +void R_Config_INTC_INTP1_Start(void); +void R_Config_INTC_INTP1_Stop(void); +void R_Config_INTC_INTP2_Start(void); +void R_Config_INTC_INTP2_Stop(void); +void R_Config_INTC_INTP3_Start(void); +void R_Config_INTC_INTP3_Stop(void); +void R_Config_INTC_INTP4_Start(void); +void R_Config_INTC_INTP4_Stop(void); +void R_Config_INTC_INTP5_Start(void); +void R_Config_INTC_INTP5_Stop(void); +void R_Config_INTC_INTP6_Start(void); +void R_Config_INTC_INTP6_Stop(void); +void R_Config_INTC_Create_UserInit(void); +/* Start user code for function. Do not edit comment generated here */ +/* 1104 Ueeda add */ +void R_Config_INTC_Create_Mode(uint8_t interruptNum, int mode); +void R_Config_INTC_INTP_Start(void); +void R_Config_INTC_INTP_Stop(uint8_t interruptNum); +/* 1104 Ueeda add */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/Config_INTC/Config_INTC_user.c b/cores/rl78g22/smc_gen/Config_INTC/Config_INTC_user.c index 50fc8f3..c419f99 100644 --- a/cores/rl78g22/smc_gen/Config_INTC/Config_INTC_user.c +++ b/cores/rl78g22/smc_gen/Config_INTC/Config_INTC_user.c @@ -1,195 +1,170 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_INTC_user.c -* Version : 1.0.0 -* Device(s) : R7F100GLGxFB -* Description : This file implements device driver for Config_INTC. -* Creation Date: 2021-11-04 -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_INTC.h" -/* Start user code for include. Do not edit comment generated here */ -#include "wiring_private.h" -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -extern fInterruptFunc_t g_afInterruptFuncTable[EXTERNAL_NUM_INTERRUPTS] __attribute__((weak));; -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_INTC_Create_UserInit -* Description : This function adds user code after initializing the INTC module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_INTC_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_INTC_intp0_interrupt -* Description : This function is INTP0 interrupt service routine -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_INTC_intp0_interrupt(void) -{ - /* Start user code for r_Config_INTC_intp0_interrupt. Do not edit comment generated here */ - // 1105 nhu del -// if (g_afInterruptFuncTable[0] != NULL) { -// (*g_afInterruptFuncTable[0])(); -// } - if (g_afInterruptFuncTable[3] != NULL) { - (*g_afInterruptFuncTable[3])(); - } - /* End user code. Do not edit comment generated here */ -} - - -/*********************************************************************************************************************** -* Function Name: r_Config_INTC_intp1_interrupt -* Description : This function is INTP1 interrupt service routine -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_INTC_intp1_interrupt(void) -{ - /* Start user code for r_Config_INTC_intp1_interrupt. Do not edit comment generated here */ -/* 20221003 - if (g_afInterruptFuncTable[4] != NULL) { - (*g_afInterruptFuncTable[4])(); - } - */ - if (g_afInterruptFuncTable[1] != NULL) { - (*g_afInterruptFuncTable[1])(); - } - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_INTC_intp2_interrupt -* Description : This function is INTP2 interrupt service routine -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_INTC_intp2_interrupt(void) -{ - /* Start user code for r_Config_INTC_intp2_interrupt. Do not edit comment generated here */ -/* 20221003 - if (g_afInterruptFuncTable[3] != NULL) { - (*g_afInterruptFuncTable[3])(); - } - */ - if (g_afInterruptFuncTable[2] != NULL) { - (*g_afInterruptFuncTable[2])(); - } - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_INTC_intp3_interrupt -* Description : This function is INTP3 interrupt service routine -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_INTC_intp3_interrupt(void) -{ - /* Start user code for r_Config_INTC_intp3_interrupt. Do not edit comment generated here */ - if (g_afInterruptFuncTable[3] != NULL) { - (*g_afInterruptFuncTable[3])(); - } - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_INTC_intp4_interrupt -* Description : This function is INTP4 interrupt service routine -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_INTC_intp4_interrupt(void) -{ - /* Start user code for r_Config_INTC_intp4_interrupt. Do not edit comment generated here */ -// 1205 nhu del -// if (g_afInterruptFuncTable[4] != NULL) { -// (*g_afInterruptFuncTable[4])(); -// } - if (g_afInterruptFuncTable[1] != NULL) { - (*g_afInterruptFuncTable[1])(); - } - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_INTC_intp5_interrupt -* Description : This function is INTP10 interrupt service routine -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_INTC_intp5_interrupt(void) -{ - /* Start user code for r_Config_INTC_intp10_interrupt. Do not edit comment generated here */ -// 1205 nhu del -// if (g_afInterruptFuncTable[5] != NULL) { -// (*g_afInterruptFuncTable[5])(); -// } - if (g_afInterruptFuncTable[2] != NULL) { - (*g_afInterruptFuncTable[2])(); - } - /* End user code. Do not edit comment generated here */ -} -/*********************************************************************************************************************** -* Function Name: r_Config_INTC_intp6_interrupt -* Description : This function is INTP11 interrupt service routine -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_INTC_intp6_interrupt(void) -{ - /* Start user code for r_Config_INTC_intp11_interrupt. Do not edit comment generated here */ -// 1205 nhu del -// if (g_afInterruptFuncTable[6] != NULL) { -// (*g_afInterruptFuncTable[6])(); -// } - if (g_afInterruptFuncTable[0] != NULL) { - (*g_afInterruptFuncTable[0])(); - } - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_INTC_user.c +* Version : 1.0.0 +* Device(s) : R7F100GLGxFB +* Description : This file implements device driver for Config_INTC. +* Creation Date: 2021-11-04 +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_INTC.h" +/* Start user code for include. Do not edit comment generated here */ +#include "wiring_private.h" +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +extern fInterruptFunc_t g_afInterruptFuncTable[EXTERNAL_NUM_INTERRUPTS] __attribute__((weak));; +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_INTC_Create_UserInit +* Description : This function adds user code after initializing the INTC module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_INTC_Create_UserInit(void) +{ + /* Start user code for user init. Do not edit comment generated here */ + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_INTC_intp0_interrupt +* Description : This function is INTP0 interrupt service routine +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_INTC_intp0_interrupt(void) +{ + /* Start user code for r_Config_INTC_intp0_interrupt. Do not edit comment generated here */ + if (g_afInterruptFuncTable[3] != NULL) { + (*g_afInterruptFuncTable[3])(); + } + /* End user code. Do not edit comment generated here */ +} + + +/*********************************************************************************************************************** +* Function Name: r_Config_INTC_intp1_interrupt +* Description : This function is INTP1 interrupt service routine +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_INTC_intp1_interrupt(void) +{ + /* Start user code for r_Config_INTC_intp1_interrupt. Do not edit comment generated here */ + +// if (g_afInterruptFuncTable[4] != NULL) { +// (*g_afInterruptFuncTable[4])(); +// } + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_INTC_intp2_interrupt +* Description : This function is INTP2 interrupt service routine +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_INTC_intp2_interrupt(void) +{ + /* Start user code for r_Config_INTC_intp2_interrupt. Do not edit comment generated here */ +// if (g_afInterruptFuncTable[5] != NULL) { +// (*g_afInterruptFuncTable[5])(); +// } + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_INTC_intp3_interrupt +* Description : This function is INTP3 interrupt service routine +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_INTC_intp3_interrupt(void) +{ + /* Start user code for r_Config_INTC_intp3_interrupt. Do not edit comment generated here */ +// if (g_afInterruptFuncTable[6] != NULL) { +// (*g_afInterruptFuncTable[6])(); +// } + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_INTC_intp4_interrupt +* Description : This function is INTP4 interrupt service routine +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_INTC_intp4_interrupt(void) +{ + /* Start user code for r_Config_INTC_intp4_interrupt. Do not edit comment generated here */ + if (g_afInterruptFuncTable[1] != NULL) { + (*g_afInterruptFuncTable[1])(); + } + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_INTC_intp5_interrupt +* Description : This function is INTP10 interrupt service routine +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_INTC_intp5_interrupt(void) +{ + /* Start user code for r_Config_INTC_intp10_interrupt. Do not edit comment generated here */ + if (g_afInterruptFuncTable[2] != NULL) { + (*g_afInterruptFuncTable[2])(); + } + /* End user code. Do not edit comment generated here */ +} +/*********************************************************************************************************************** +* Function Name: r_Config_INTC_intp6_interrupt +* Description : This function is INTP11 interrupt service routine +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_INTC_intp6_interrupt(void) +{ + /* Start user code for r_Config_INTC_intp11_interrupt. Do not edit comment generated here */ + if (g_afInterruptFuncTable[0] != NULL) { + (*g_afInterruptFuncTable[0])(); + } + /* End user code. Do not edit comment generated here */ +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_ITL000/Config_ITL000.c b/cores/rl78g22/smc_gen/Config_ITL000/Config_ITL000.c index 314af20..d203f8c 100644 --- a/cores/rl78g22/smc_gen/Config_ITL000/Config_ITL000.c +++ b/cores/rl78g22/smc_gen/Config_ITL000/Config_ITL000.c @@ -1,141 +1,141 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_ITL000.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_ITL000. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_ITL000.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL000_Create -* Description : This function initializes the ITL000 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL000_Create(void) -{ - /* Stop 32-bit interval timer */ - ITLCTL0 = 0x00U; - /* Mask INTITL interrupt */ - ITLMKF0 |= _01_ITL_CHANNEL0_COUNT_MATCH_MASK; - ITLS0 &= (uint8_t)~_01_ITL_CHANNEL0_COUNT_MATCH_DETECTE; - ITLMK = 1U; /* disable INTITL interrupt */ - ITLIF = 0U; /* clear INTITL interrupt flag */ - /* Set INTITL low priority */ - ITLPR1 = 1U; - ITLPR0 = 1U; - /* 32-bit interval timer used as 8-bit timer */ - ITLCTL0 |= _00_ITL_MODE_8BIT; - ITLCSEL0 &= _F8_ITL_CLOCK_FITL0_CLEAR; - ITLCSEL0 |= _04_ITL_CLOCK_FITL0_FSXP; - ITLFDIV00 &= _F8_ITL_ITL000_FITL0_CLEAR; - ITLFDIV00 |= _00_ITL_ITL000_FITL0_1; - ITLCMP000 = _20_ITL_ITLCMP000_VALUE; - - R_Config_ITL000_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL000_Start -* Description : This function starts the ITL000 channel. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL000_Start(void) -{ - ITLS0 &= (uint8_t)~_01_ITL_CHANNEL0_COUNT_MATCH_DETECTE; - ITLMKF0 &= (uint8_t)~_01_ITL_CHANNEL0_COUNT_MATCH_MASK; - ITLEN00 = 1U; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL000_Stop -* Description : This function stops the ITL000 channel. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL000_Stop(void) -{ - ITLMKF0 |= _01_ITL_CHANNEL0_COUNT_MATCH_MASK; - ITLS0 &= (uint8_t)~_01_ITL_CHANNEL0_COUNT_MATCH_DETECTE; - ITLEN00 = 0U; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL000_Set_OperationMode -* Description : This function is used to stop counter and clear interrupt flag before changing operation mode. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL000_Set_OperationMode(void) -{ - ITLMKF0 |= _01_ITL_CHANNEL0_COUNT_MATCH_MASK; - ITLS0 &= (uint8_t)~_01_ITL_CHANNEL0_COUNT_MATCH_DETECTE; - /* Stop 32-bit interval timer */ - ITLCTL0 &= 0xF0U; -} - -/* Start user code for adding. Do not edit comment generated here */ -void R_Config_ITL000_SetCompareMatch_For_MainClock(void) -{ -// ITLEN00 = 0U; - - ITLCSEL0 &= _F8_ITL_CLOCK_FITL0_CLEAR; - ITLCSEL0 |= _01_ITL_CLOCK_FITL0_FIHP; - ITLFDIV00 &= _F8_ITL_ITL000_FITL0_CLEAR; - ITLFDIV00 |= _07_ITL_ITL000_FITL0_128; - ITLCMP000 = _F9_ITL_ITLCMP000_VALUE; - -} - -void R_Config_ITL000_SetCompareMatch(void) -{ - ITLEN00 = 0U; - ITLCSEL0 &= _F8_ITL_CLOCK_FITL0_CLEAR; - ITLCSEL0 |= _04_ITL_CLOCK_FITL0_FSXP; - ITLFDIV00 &= _F8_ITL_ITL000_FITL0_CLEAR; - ITLFDIV00 |= _00_ITL_ITL000_FITL0_1; - ITLCMP000 = _20_ITL_ITLCMP000_VALUE; - } - -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021, 2023 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_ITL000.c +* Component Version: 1.4.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_ITL000. +* Creation Date : +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_ITL000.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL000_Create +* Description : This function initializes the ITL000 module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL000_Create(void) +{ + /* Stop 32-bit interval timer */ + ITLCTL0 = 0x00U; + /* Mask INTITL interrupt */ + ITLMKF0 |= _01_ITL_CHANNEL0_COUNT_MATCH_MASK; + ITLS0 &= (uint8_t)~_01_ITL_CHANNEL0_COUNT_MATCH_DETECTE; + ITLMK = 1U; /* disable INTITL interrupt */ + ITLIF = 0U; /* clear INTITL interrupt flag */ + /* Set INTITL low priority */ + ITLPR1 = 1U; + ITLPR0 = 1U; + /* 32-bit interval timer used as 8-bit timer */ + ITLCTL0 |= _00_ITL_MODE_8BIT; + ITLCSEL0 &= _F8_ITL_CLOCK_FITL0_CLEAR; + ITLCSEL0 |= _04_ITL_CLOCK_FITL0_FSXP; + ITLFDIV00 &= _F8_ITL_ITL000_FITL0_CLEAR; + ITLFDIV00 |= _00_ITL_ITL000_FITL0_1; + ITLCMP000 = _20_ITL_ITLCMP000_VALUE; + + R_Config_ITL000_Create_UserInit(); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL000_Start +* Description : This function starts the ITL000 channel. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL000_Start(void) +{ + ITLS0 &= (uint8_t)~_01_ITL_CHANNEL0_COUNT_MATCH_DETECTE; + ITLMKF0 &= (uint8_t)~_01_ITL_CHANNEL0_COUNT_MATCH_MASK; + ITLEN00 = 1U; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL000_Stop +* Description : This function stops the ITL000 channel. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL000_Stop(void) +{ + ITLMKF0 |= _01_ITL_CHANNEL0_COUNT_MATCH_MASK; + ITLS0 &= (uint8_t)~_01_ITL_CHANNEL0_COUNT_MATCH_DETECTE; + ITLEN00 = 0U; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL000_Set_OperationMode +* Description : This function is used to stop counter and clear interrupt flag before changing operation mode. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL000_Set_OperationMode(void) +{ + ITLMKF0 |= _01_ITL_CHANNEL0_COUNT_MATCH_MASK; + ITLS0 &= (uint8_t)~_01_ITL_CHANNEL0_COUNT_MATCH_DETECTE; + /* Stop 32-bit interval timer */ + ITLCTL0 &= 0xF0U; +} + +/* Start user code for adding. Do not edit comment generated here */ +void R_Config_ITL000_SetCompareMatch_For_MainClock(void) +{ +// ITLEN00 = 0U; + + ITLCSEL0 &= _F8_ITL_CLOCK_FITL0_CLEAR; + ITLCSEL0 |= _01_ITL_CLOCK_FITL0_FIHP; + ITLFDIV00 &= _F8_ITL_ITL000_FITL0_CLEAR; + ITLFDIV00 |= _07_ITL_ITL000_FITL0_128; + ITLCMP000 = _F9_ITL_ITLCMP000_VALUE; + +} + +void R_Config_ITL000_SetCompareMatch(void) +{ +// ITLEN00 = 0U; + ITLCSEL0 &= _F8_ITL_CLOCK_FITL0_CLEAR; + ITLCSEL0 |= _04_ITL_CLOCK_FITL0_FSXP; + ITLFDIV00 &= _F8_ITL_ITL000_FITL0_CLEAR; + ITLFDIV00 |= _00_ITL_ITL000_FITL0_1; + ITLCMP000 = _20_ITL_ITLCMP000_VALUE; + } + +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_ITL000/Config_ITL000.h b/cores/rl78g22/smc_gen/Config_ITL000/Config_ITL000.h index c17e7d5..86236e5 100644 --- a/cores/rl78g22/smc_gen/Config_ITL000/Config_ITL000.h +++ b/cores/rl78g22/smc_gen/Config_ITL000/Config_ITL000.h @@ -1,63 +1,63 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_ITL000.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_ITL000. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_ITL000_H -#define CFG_Config_ITL000_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_itl.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _20_ITL_ITLCMP000_VALUE (0x20U) /* 8-bit compare data register */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_ITL000_Create (void); -void R_Config_ITL000_Start (void); -void R_Config_ITL000_Stop (void); -void R_Config_ITL000_Set_OperationMode (void); -void R_Config_ITL000_Callback_Shared_Interrupt (void); -void R_Config_ITL000_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -#define _F9_ITL_ITLCMP000_VALUE (0xF9) -void R_Config_ITL000_SetCompareMatch_For_MainClock(void); -void R_Config_ITL000_SetCompareMatch(void); -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021, 2023 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_ITL000.h +* Component Version: 1.4.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_ITL000. +* Creation Date : +***********************************************************************************************************************/ + +#ifndef CFG_Config_ITL000_H +#define CFG_Config_ITL000_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_itl.h" + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ +#define _20_ITL_ITLCMP000_VALUE (0x20U) /* 8-bit compare data register */ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_Config_ITL000_Create (void); +void R_Config_ITL000_Start (void); +void R_Config_ITL000_Stop (void); +void R_Config_ITL000_Set_OperationMode (void); +void R_Config_ITL000_Callback_Shared_Interrupt (void); +void R_Config_ITL000_Create_UserInit (void); +/* Start user code for function. Do not edit comment generated here */ +#define _F9_ITL_ITLCMP000_VALUE (0xF9) +void R_Config_ITL000_SetCompareMatch_For_MainClock(void); +void R_Config_ITL000_SetCompareMatch(void); +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/Config_ITL000/Config_ITL000_user.c b/cores/rl78g22/smc_gen/Config_ITL000/Config_ITL000_user.c index 24479a2..b5fcb70 100644 --- a/cores/rl78g22/smc_gen/Config_ITL000/Config_ITL000_user.c +++ b/cores/rl78g22/smc_gen/Config_ITL000/Config_ITL000_user.c @@ -1,91 +1,89 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_ITL000_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_ITL000. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_ITL000.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -extern volatile unsigned long g_u32timer_millis; -// 2022/11/04 -// extern volatile unsigned long g_u32delay_timer; -extern volatile int long g_u32delay_timer; -extern uint8_t g_delay_cnt_flg; -extern uint8_t g_timer_millis_overflow_cnt; -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL000_Create_UserInit -* Description : This function adds user code after initializing the ITL000 channel. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL000_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - g_u32timer_millis=0; - g_timer_millis_overflow_cnt=0; - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL000_Callback_Shared_Interrupt -* Description : This function handles the ITL000 shared interrupt. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL000_Callback_Shared_Interrupt(void) -{ - /* Start user code for R_Config_ITL000_Callback_Shared_Interrupt. Do not edit comment generated here */ - g_u32timer_millis++; - if (0 == g_u32timer_millis){ - g_timer_millis_overflow_cnt++; - } - - if (1U==g_delay_cnt_flg) - { - g_u32delay_timer++; - } - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021, 2023 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_ITL000_user.c +* Component Version: 1.4.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_ITL000. +* Creation Date : +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_ITL000.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +extern volatile unsigned long g_u32timer_millis; +extern volatile unsigned long g_u32delay_timer; +extern uint8_t g_delay_cnt_flg; +extern uint8_t g_timer_millis_overflow_cnt; +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL000_Create_UserInit +* Description : This function adds user code after initializing the ITL000 channel. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL000_Create_UserInit(void) +{ + /* Start user code for user init. Do not edit comment generated here */ + g_u32timer_millis=0; + g_timer_millis_overflow_cnt=0; + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL000_Callback_Shared_Interrupt +* Description : This function handles the ITL000 shared interrupt. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL000_Callback_Shared_Interrupt(void) +{ + /* Start user code for R_Config_ITL000_Callback_Shared_Interrupt. Do not edit comment generated here */ + g_u32timer_millis++; + if (0 == g_u32timer_millis){ + g_timer_millis_overflow_cnt++; + } + + if (1U==g_delay_cnt_flg) + { + g_u32delay_timer++; + } + /* End user code. Do not edit comment generated here */ +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_ITL001/Config_ITL001.c b/cores/rl78g22/smc_gen/Config_ITL001/Config_ITL001.c index 7c3c8d1..868a9ef 100644 --- a/cores/rl78g22/smc_gen/Config_ITL001/Config_ITL001.c +++ b/cores/rl78g22/smc_gen/Config_ITL001/Config_ITL001.c @@ -1,131 +1,131 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_ITL001.c -* Version : 1.0.0 -* Device(s) : R7F100GLGxFB -* Description : This file implements device driver for Config_ITL001. -* Creation Date: 2021-05-14 -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_ITL001.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL001_Create -* Description : This function initializes the ITL001 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL001_Create(void) -{ - /* Stop 32-bit interval timer */ - ITLCTL0 = 0x00U; - /* Mask INTITL interrupt */ - ITLMKF0 |= _02_ITL_CHANNEL1_COUNT_MATCH_MASK; - ITLS0 &= (uint16_t)~_02_ITL_CHANNEL1_COUNT_MATCH_DETECTE; - ITLMK = 1U; /* disable INTITL interrupt */ - ITLIF = 0U; /* clear INTITL interrupt flag */ - /* Set INTITL low priority */ - ITLPR1 = 1U; - ITLPR0 = 1U; - /* 32-bit interval timer used as 8-bit timer */ - ITLCTL0 |= _00_ITL_MODE_8BIT; - ITLCSEL0 &= _F8_ITL_CLOCK_FITL0_CLEAR; - ITLCSEL0 |= _01_ITL_CLOCK_FITL0_FIHP; - ITLFDIV00 &= _8F_ITL_ITL001_FITL0_CLEAR; - ITLFDIV00 |= _00_ITL_ITL001_FITL0_1; - ITLCMP001 = _1F_ITL_ITLCMP001_VALUE; - - R_Config_ITL001_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL001_Start -* Description : This function starts the ITL001 channel. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL001_Start(void) -{ - ITLS0 &= (uint16_t)~_02_ITL_CHANNEL1_COUNT_MATCH_DETECTE; - ITLMKF0 &= (uint16_t)~_02_ITL_CHANNEL1_COUNT_MATCH_MASK; - ITLEN01 = 1U; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL001_Stop -* Description : This function stops the ITL001 channel. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL001_Stop(void) -{ - ITLMKF0 |= _02_ITL_CHANNEL1_COUNT_MATCH_MASK; - ITLS0 &= (uint16_t)~_02_ITL_CHANNEL1_COUNT_MATCH_DETECTE; - ITLEN01 = 0U; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL001_Set_OperationMode -* Description : This function is used to stop counter and clear interrupt flag before changing operation mode. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL001_Set_OperationMode(void) -{ - ITLMKF0 |= _02_ITL_CHANNEL1_COUNT_MATCH_MASK; - ITLS0 &= (uint16_t)~_02_ITL_CHANNEL1_COUNT_MATCH_DETECTE; - /* Stop 32-bit interval timer */ - ITLCTL0 &= 0xF0U; -} - -/* Start user code for adding. Do not edit comment generated here */ -void R_Config_ITL001_SetCompareMatch(uint8_t count,uint8_t div) -{ - ITLEN01 = 0U; - - ITLCSEL0 &= _F8_ITL_CLOCK_FITL0_CLEAR; - ITLCSEL0 |= _01_ITL_CLOCK_FITL0_FIHP; - ITLFDIV00 &= _8F_ITL_ITL001_FITL0_CLEAR; - - ITLFDIV00 |= div; - ITLCMP001 = count; - -} -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_ITL001.c +* Version : 1.0.0 +* Device(s) : R7F100GLGxFB +* Description : This file implements device driver for Config_ITL001. +* Creation Date: 2021-05-14 +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_ITL001.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL001_Create +* Description : This function initializes the ITL001 module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL001_Create(void) +{ + /* Stop 32-bit interval timer */ + ITLCTL0 = 0x00U; + /* Mask INTITL interrupt */ + ITLMKF0 |= _02_ITL_CHANNEL1_COUNT_MATCH_MASK; + ITLS0 &= (uint16_t)~_02_ITL_CHANNEL1_COUNT_MATCH_DETECTE; + ITLMK = 1U; /* disable INTITL interrupt */ + ITLIF = 0U; /* clear INTITL interrupt flag */ + /* Set INTITL low priority */ + ITLPR1 = 1U; + ITLPR0 = 1U; + /* 32-bit interval timer used as 8-bit timer */ + ITLCTL0 |= _00_ITL_MODE_8BIT; + ITLCSEL0 &= _F8_ITL_CLOCK_FITL0_CLEAR; + ITLCSEL0 |= _01_ITL_CLOCK_FITL0_FIHP; + ITLFDIV00 &= _8F_ITL_ITL001_FITL0_CLEAR; + ITLFDIV00 |= _00_ITL_ITL001_FITL0_1; + ITLCMP001 = _1F_ITL_ITLCMP001_VALUE; + + R_Config_ITL001_Create_UserInit(); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL001_Start +* Description : This function starts the ITL001 channel. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL001_Start(void) +{ + ITLS0 &= (uint16_t)~_02_ITL_CHANNEL1_COUNT_MATCH_DETECTE; + ITLMKF0 &= (uint16_t)~_02_ITL_CHANNEL1_COUNT_MATCH_MASK; + ITLEN01 = 1U; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL001_Stop +* Description : This function stops the ITL001 channel. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL001_Stop(void) +{ + ITLMKF0 |= _02_ITL_CHANNEL1_COUNT_MATCH_MASK; + ITLS0 &= (uint16_t)~_02_ITL_CHANNEL1_COUNT_MATCH_DETECTE; + ITLEN01 = 0U; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL001_Set_OperationMode +* Description : This function is used to stop counter and clear interrupt flag before changing operation mode. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL001_Set_OperationMode(void) +{ + ITLMKF0 |= _02_ITL_CHANNEL1_COUNT_MATCH_MASK; + ITLS0 &= (uint16_t)~_02_ITL_CHANNEL1_COUNT_MATCH_DETECTE; + /* Stop 32-bit interval timer */ + ITLCTL0 &= 0xF0U; +} + +/* Start user code for adding. Do not edit comment generated here */ +void R_Config_ITL001_SetCompareMatch(uint8_t count,uint8_t div) +{ + ITLEN01 = 0U; + + ITLCSEL0 &= _F8_ITL_CLOCK_FITL0_CLEAR; + ITLCSEL0 |= _01_ITL_CLOCK_FITL0_FIHP; + ITLFDIV00 &= _8F_ITL_ITL001_FITL0_CLEAR; + + ITLFDIV00 |= div; + ITLCMP001 = count; + +} +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_ITL001/Config_ITL001.h b/cores/rl78g22/smc_gen/Config_ITL001/Config_ITL001.h index d15f493..4d27b4e 100644 --- a/cores/rl78g22/smc_gen/Config_ITL001/Config_ITL001.h +++ b/cores/rl78g22/smc_gen/Config_ITL001/Config_ITL001.h @@ -1,63 +1,63 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_ITL001.h -* Version : 1.0.0 -* Device(s) : R7F100GLGxFB -* Description : This file implements device driver for Config_ITL001. -* Creation Date: 2021-05-14 -***********************************************************************************************************************/ - -#ifndef Config_ITL001_H -#define Config_ITL001_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_itl.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _1F_ITL_ITLCMP001_VALUE (0x1FU) /* 8-bit compare data register */ -#define _FA_ITL_ITLCMP001_VALUE (0xFAU) /* 8-bit compare data register */ -#define _01_ITL_ITLCMP001_VALUE (0x01U) /* 8-bit compare data register */ -#define _20_ITL_ITLCMP001_VALUE (0x20U) /* 8-bit compare data register */ -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_ITL001_Create(void); -void R_Config_ITL001_Start(void); -void R_Config_ITL001_Stop(void); -void R_Config_ITL001_Set_OperationMode(void); -void R_Config_ITL001_Callback_Shared_Interrupt(void); -void R_Config_ITL001_Create_UserInit(void); -/* Start user code for function. Do not edit comment generated here */ -void R_Config_ITL001_SetCompareMatch(uint8_t count,uint8_t div); -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_ITL001.h +* Version : 1.0.0 +* Device(s) : R7F100GLGxFB +* Description : This file implements device driver for Config_ITL001. +* Creation Date: 2021-05-14 +***********************************************************************************************************************/ + +#ifndef Config_ITL001_H +#define Config_ITL001_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_itl.h" + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ +#define _1F_ITL_ITLCMP001_VALUE (0x1FU) /* 8-bit compare data register */ +#define _FA_ITL_ITLCMP001_VALUE (0xFAU) /* 8-bit compare data register */ +#define _01_ITL_ITLCMP001_VALUE (0x01U) /* 8-bit compare data register */ +#define _20_ITL_ITLCMP001_VALUE (0x20U) /* 8-bit compare data register */ +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_Config_ITL001_Create(void); +void R_Config_ITL001_Start(void); +void R_Config_ITL001_Stop(void); +void R_Config_ITL001_Set_OperationMode(void); +void R_Config_ITL001_Callback_Shared_Interrupt(void); +void R_Config_ITL001_Create_UserInit(void); +/* Start user code for function. Do not edit comment generated here */ +void R_Config_ITL001_SetCompareMatch(uint8_t count,uint8_t div); +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/Config_ITL001/Config_ITL001_user.c b/cores/rl78g22/smc_gen/Config_ITL001/Config_ITL001_user.c index 7a8f599..b03b7ec 100644 --- a/cores/rl78g22/smc_gen/Config_ITL001/Config_ITL001_user.c +++ b/cores/rl78g22/smc_gen/Config_ITL001/Config_ITL001_user.c @@ -1,105 +1,105 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_ITL001_user.c -* Version : 1.0.0 -* Device(s) : R7F100GLGxFB -* Description : This file implements device driver for Config_ITL001. -* Creation Date: 2021-05-14 -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_ITL001.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -extern volatile unsigned long g_u32timer_micros; -extern volatile unsigned long g_u32delay_micros_timer; -extern uint8_t g_delay_cnt_micros_flg; - -extern volatile unsigned long g_u32timer_millis; //!< �C���^�[�o���^�C�}�ϐ� -extern uint8_t g_timer_millis_overflow_cnt; - -extern volatile uint8_t g_u8delay_micros_timer_flg; -extern volatile uint16_t g_u16delay_micros_timer_set; //!< delay() �p�^�C�}�ϐ� -extern volatile uint16_t g_u16delay_micros_timer_total; //!< delay() �p�^�C�}�ϐ� - -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL001_Create_UserInit -* Description : This function adds user code after initializing the ITL001 channel. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL001_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ -// ITLFDIV00 |= _50_ITL_ITL001_FITL0_32; -// ITLCMP000 = _01_ITL_ITLCMP001_VALUE; - g_u32timer_micros=0; - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL001_Callback_Shared_Interrupt -* Description : This function handles the ITL001 shared interrupt. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL001_Callback_Shared_Interrupt(void) -{ - /* Start user code for R_Config_ITL001_Callback_Shared_Interrupt. Do not edit comment generated here */ - R_Config_ITL001_Stop(); - g_u32timer_micros++; - if(1U==g_delay_cnt_micros_flg) - { - g_u8delay_micros_timer_flg = 1; - } - - g_u16delay_micros_timer_total += g_u16delay_micros_timer_set; - if(g_u16delay_micros_timer_total >= 1000) - { - g_u16delay_micros_timer_total -= 1000; - g_u32timer_millis++; - if (0 == g_u32timer_millis) - { - g_timer_millis_overflow_cnt++; - } - } - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_ITL001_user.c +* Version : 1.0.0 +* Device(s) : R7F100GLGxFB +* Description : This file implements device driver for Config_ITL001. +* Creation Date: 2021-05-14 +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_ITL001.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +extern volatile unsigned long g_u32timer_micros; +extern volatile unsigned long g_u32delay_micros_timer; +extern uint8_t g_delay_cnt_micros_flg; + +extern volatile unsigned long g_u32timer_millis; //!< �C���^�[�o���^�C�}�ϐ� +extern uint8_t g_timer_millis_overflow_cnt; + +extern volatile uint8_t g_u8delay_micros_timer_flg; +extern volatile uint16_t g_u16delay_micros_timer_set; //!< delay() �p�^�C�}�ϐ� +extern volatile uint16_t g_u16delay_micros_timer_total; //!< delay() �p�^�C�}�ϐ� + +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL001_Create_UserInit +* Description : This function adds user code after initializing the ITL001 channel. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL001_Create_UserInit(void) +{ + /* Start user code for user init. Do not edit comment generated here */ +// ITLFDIV00 |= _50_ITL_ITL001_FITL0_32; +// ITLCMP000 = _01_ITL_ITLCMP001_VALUE; + g_u32timer_micros=0; + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL001_Callback_Shared_Interrupt +* Description : This function handles the ITL001 shared interrupt. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL001_Callback_Shared_Interrupt(void) +{ + /* Start user code for R_Config_ITL001_Callback_Shared_Interrupt. Do not edit comment generated here */ + R_Config_ITL001_Stop(); + g_u32timer_micros++; + if(1U==g_delay_cnt_micros_flg) + { + g_u8delay_micros_timer_flg = 1; + } + + g_u16delay_micros_timer_total += g_u16delay_micros_timer_set; + if(g_u16delay_micros_timer_total >= 1000) + { + g_u16delay_micros_timer_total -= 1000; + g_u32timer_millis++; + if (0 == g_u32timer_millis) + { + g_timer_millis_overflow_cnt++; + } + } + /* End user code. Do not edit comment generated here */ +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_ITL012/Config_ITL012.c b/cores/rl78g22/smc_gen/Config_ITL012/Config_ITL012.c index 25d75dd..4956da9 100644 --- a/cores/rl78g22/smc_gen/Config_ITL012/Config_ITL012.c +++ b/cores/rl78g22/smc_gen/Config_ITL012/Config_ITL012.c @@ -1,120 +1,120 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_ITL012.c -* Version : 1.0.0 -* Device(s) : R7F100GLGxFB -* Description : This file implements device driver for Config_ITL012. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_ITL012.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL012_Create -* Description : This function initializes the ITL012 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL012_Create(void) -{ - /* Stop 32-bit interval timer */ - ITLCTL0 = 0x00U; - /* Mask INTITL interrupt */ - ITLMKF0 |= _04_ITL_CHANNEL2_COUNT_MATCH_MASK; - ITLS0 &= (uint16_t)~_04_ITL_CHANNEL2_COUNT_MATCH_DETECTE; - ITLMK = 1U; /* disable INTITL interrupt */ - ITLIF = 0U; /* clear INTITL interrupt flag */ - /* Set INTITL low priority */ - ITLPR1 = 1U; - ITLPR0 = 1U; - /* 32-bit interval timer used as 8-bit timer */ - ITLCTL0 |= _00_ITL_MODE_8BIT; -// 2022/11/04 temporary removal -// ITLCSEL0 &= _F8_ITL_CLOCK_FITL0_CLEAR; -// ITLCSEL0 |= _01_ITL_CLOCK_FITL0_FIHP; - ITLFDIV01 &= _F8_ITL_ITL012_FITL0_CLEAR; - ITLFDIV01 |= _00_ITL_ITL012_FITL0_1; - ITLCMP012 = _1F_ITL_ITLCMP012_VALUE; - - R_Config_ITL012_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL012_Start -* Description : This function starts the ITL012 channel. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL012_Start(void) -{ - ITLS0 &= (uint16_t)~_04_ITL_CHANNEL2_COUNT_MATCH_DETECTE; - ITLMKF0 &= (uint16_t)~_04_ITL_CHANNEL2_COUNT_MATCH_MASK; - ITLEN02 = 1U; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL012_Stop -* Description : This function stops the ITL012 channel. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL012_Stop(void) -{ - ITLMKF0 |= _04_ITL_CHANNEL2_COUNT_MATCH_MASK; - ITLS0 &= (uint16_t)~_04_ITL_CHANNEL2_COUNT_MATCH_DETECTE; - ITLEN02 = 0U; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL012_Set_OperationMode -* Description : This function is used to stop counter and clear interrupt flag before changing operation mode. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL012_Set_OperationMode(void) -{ - ITLMKF0 |= _04_ITL_CHANNEL2_COUNT_MATCH_MASK; - ITLS0 &= (uint16_t)~_04_ITL_CHANNEL2_COUNT_MATCH_DETECTE; - /* Stop 32-bit interval timer */ - ITLCTL0 &= 0xF0U; -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_ITL012.c +* Version : 1.0.0 +* Device(s) : R7F100GLGxFB +* Description : This file implements device driver for Config_ITL012. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_ITL012.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL012_Create +* Description : This function initializes the ITL012 module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL012_Create(void) +{ + /* Stop 32-bit interval timer */ + ITLCTL0 = 0x00U; + /* Mask INTITL interrupt */ + ITLMKF0 |= _04_ITL_CHANNEL2_COUNT_MATCH_MASK; + ITLS0 &= (uint16_t)~_04_ITL_CHANNEL2_COUNT_MATCH_DETECTE; + ITLMK = 1U; /* disable INTITL interrupt */ + ITLIF = 0U; /* clear INTITL interrupt flag */ + /* Set INTITL low priority */ + ITLPR1 = 1U; + ITLPR0 = 1U; + /* 32-bit interval timer used as 8-bit timer */ + ITLCTL0 |= _00_ITL_MODE_8BIT; +// 2022/11/04 temporary removal +// ITLCSEL0 &= _F8_ITL_CLOCK_FITL0_CLEAR; +// ITLCSEL0 |= _01_ITL_CLOCK_FITL0_FIHP; + ITLFDIV01 &= _F8_ITL_ITL012_FITL0_CLEAR; + ITLFDIV01 |= _00_ITL_ITL012_FITL0_1; + ITLCMP012 = _1F_ITL_ITLCMP012_VALUE; + + R_Config_ITL012_Create_UserInit(); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL012_Start +* Description : This function starts the ITL012 channel. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL012_Start(void) +{ + ITLS0 &= (uint16_t)~_04_ITL_CHANNEL2_COUNT_MATCH_DETECTE; + ITLMKF0 &= (uint16_t)~_04_ITL_CHANNEL2_COUNT_MATCH_MASK; + ITLEN02 = 1U; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL012_Stop +* Description : This function stops the ITL012 channel. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL012_Stop(void) +{ + ITLMKF0 |= _04_ITL_CHANNEL2_COUNT_MATCH_MASK; + ITLS0 &= (uint16_t)~_04_ITL_CHANNEL2_COUNT_MATCH_DETECTE; + ITLEN02 = 0U; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL012_Set_OperationMode +* Description : This function is used to stop counter and clear interrupt flag before changing operation mode. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL012_Set_OperationMode(void) +{ + ITLMKF0 |= _04_ITL_CHANNEL2_COUNT_MATCH_MASK; + ITLS0 &= (uint16_t)~_04_ITL_CHANNEL2_COUNT_MATCH_DETECTE; + /* Stop 32-bit interval timer */ + ITLCTL0 &= 0xF0U; +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_ITL012/Config_ITL012.h b/cores/rl78g22/smc_gen/Config_ITL012/Config_ITL012.h index 1977b59..dee7fff 100644 --- a/cores/rl78g22/smc_gen/Config_ITL012/Config_ITL012.h +++ b/cores/rl78g22/smc_gen/Config_ITL012/Config_ITL012.h @@ -1,60 +1,60 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_ITL012.h -* Version : 1.0.0 -* Device(s) : R7F100GLGxFB -* Description : This file implements device driver for Config_ITL012. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef Config_ITL012_H -#define Config_ITL012_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_itl.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _1F_ITL_ITLCMP012_VALUE (0x1FU) /* 8-bit compare data register */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_ITL012_Create(void); -void R_Config_ITL012_Start(void); -void R_Config_ITL012_Stop(void); -void R_Config_ITL012_Set_OperationMode(void); -void R_Config_ITL012_Callback_Shared_Interrupt(void); -void R_Config_ITL012_Create_UserInit(void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_ITL012.h +* Version : 1.0.0 +* Device(s) : R7F100GLGxFB +* Description : This file implements device driver for Config_ITL012. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef Config_ITL012_H +#define Config_ITL012_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_itl.h" + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ +#define _1F_ITL_ITLCMP012_VALUE (0x1FU) /* 8-bit compare data register */ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_Config_ITL012_Create(void); +void R_Config_ITL012_Start(void); +void R_Config_ITL012_Stop(void); +void R_Config_ITL012_Set_OperationMode(void); +void R_Config_ITL012_Callback_Shared_Interrupt(void); +void R_Config_ITL012_Create_UserInit(void); +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/Config_ITL012/Config_ITL012_user.c b/cores/rl78g22/smc_gen/Config_ITL012/Config_ITL012_user.c index 70b050f..8476fed 100644 --- a/cores/rl78g22/smc_gen/Config_ITL012/Config_ITL012_user.c +++ b/cores/rl78g22/smc_gen/Config_ITL012/Config_ITL012_user.c @@ -1,83 +1,83 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_ITL012_user.c -* Version : 1.0.0 -* Device(s) : R7F100GLGxFB -* Description : This file implements device driver for Config_ITL012. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_ITL012.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -extern volatile unsigned long g_u32timer_micros; -extern volatile unsigned long g_u32delay_micros_timer; -extern uint8_t g_delay_cnt_micros_flg; -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL012_Create_UserInit -* Description : This function adds user code after initializing the ITL012 channel. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL012_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - g_u32timer_micros=0; - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL012_Callback_Shared_Interrupt -* Description : This function handles the ITL012 shared interrupt. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL012_Callback_Shared_Interrupt(void) -{ - /* Start user code for R_Config_ITL012_Callback_Shared_Interrupt. Do not edit comment generated here */ - g_u32timer_micros++; - if(1U==g_delay_cnt_micros_flg) - { - g_u32delay_micros_timer++; - } - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_ITL012_user.c +* Version : 1.0.0 +* Device(s) : R7F100GLGxFB +* Description : This file implements device driver for Config_ITL012. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_ITL012.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +extern volatile unsigned long g_u32timer_micros; +extern volatile unsigned long g_u32delay_micros_timer; +extern uint8_t g_delay_cnt_micros_flg; +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL012_Create_UserInit +* Description : This function adds user code after initializing the ITL012 channel. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL012_Create_UserInit(void) +{ + /* Start user code for user init. Do not edit comment generated here */ + g_u32timer_micros=0; + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL012_Callback_Shared_Interrupt +* Description : This function handles the ITL012 shared interrupt. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL012_Callback_Shared_Interrupt(void) +{ + /* Start user code for R_Config_ITL012_Callback_Shared_Interrupt. Do not edit comment generated here */ + g_u32timer_micros++; + if(1U==g_delay_cnt_micros_flg) + { + g_u32delay_micros_timer++; + } + /* End user code. Do not edit comment generated here */ +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_ITL013/Config_ITL013.c b/cores/rl78g22/smc_gen/Config_ITL013/Config_ITL013.c index 6f31221..f95bed7 100644 --- a/cores/rl78g22/smc_gen/Config_ITL013/Config_ITL013.c +++ b/cores/rl78g22/smc_gen/Config_ITL013/Config_ITL013.c @@ -1,130 +1,130 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_ITL013.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_ITL013. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_ITL013.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL013_Create -* Description : This function initializes the ITL013 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL013_Create(void) -{ - /* Stop 32-bit interval timer */ - ITLCTL0 = 0x00U; - /* Mask INTITL interrupt */ - ITLMKF0 |= _08_ITL_CHANNEL3_COUNT_MATCH_MASK; - ITLS0 &= (uint8_t)~_08_ITL_CHANNEL3_COUNT_MATCH_DETECTE; - ITLMK = 1U; /* disable INTITL interrupt */ - ITLIF = 0U; /* clear INTITL interrupt flag */ - /* Set INTITL low priority */ - ITLPR1 = 1U; - ITLPR0 = 1U; - /* 32-bit interval timer used as 8-bit timer */ - ITLCTL0 |= _00_ITL_MODE_8BIT; - ITLCSEL0 &= _F8_ITL_CLOCK_FITL0_CLEAR; - ITLCSEL0 |= _04_ITL_CLOCK_FITL0_FSXP; - ITLFDIV01 &= _8F_ITL_ITL013_FITL0_CLEAR; - ITLFDIV01 |= _00_ITL_ITL013_FITL0_1; - ITLCMP013 = _20_ITL_ITLCMP013_VALUE; - - R_Config_ITL013_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL013_Start -* Description : This function starts the ITL013 channel. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL013_Start(void) -{ - ITLS0 &= (uint8_t)~_08_ITL_CHANNEL3_COUNT_MATCH_DETECTE; - ITLMKF0 &= (uint8_t)~_08_ITL_CHANNEL3_COUNT_MATCH_MASK; - ITLEN03 = 1U; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL013_Stop -* Description : This function stops the ITL013 channel. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL013_Stop(void) -{ - ITLMKF0 |= _08_ITL_CHANNEL3_COUNT_MATCH_MASK; - ITLS0 &= (uint8_t)~_08_ITL_CHANNEL3_COUNT_MATCH_DETECTE; - ITLEN03 = 0U; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL013_Set_OperationMode -* Description : This function is used to stop counter and clear interrupt flag before changing operation mode. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL013_Set_OperationMode(void) -{ - ITLMKF0 |= _08_ITL_CHANNEL3_COUNT_MATCH_MASK; - ITLS0 &= (uint8_t)~_08_ITL_CHANNEL3_COUNT_MATCH_DETECTE; - /* Stop 32-bit interval timer */ - ITLCTL0 &= 0xF0U; -} - -/* Start user code for adding. Do not edit comment generated here */ -void R_Config_ITL013_SetCompareMatch(uint8_t count,uint8_t div) -{ - ITLEN03 = 0U; - - ITLCSEL0 &= _F8_ITL_CLOCK_FITL0_CLEAR; - ITLCSEL0 |= _04_ITL_CLOCK_FITL0_FSXP;; - ITLFDIV01 &= _8F_ITL_ITL013_FITL0_CLEAR; - ITLFDIV01 |= div; - ITLCMP013 = count; -} - -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021, 2023 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_ITL013.c +* Component Version: 1.4.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_ITL013. +* Creation Date : +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_ITL013.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL013_Create +* Description : This function initializes the ITL013 module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL013_Create(void) +{ + /* Stop 32-bit interval timer */ + ITLCTL0 = 0x00U; + /* Mask INTITL interrupt */ + ITLMKF0 |= _08_ITL_CHANNEL3_COUNT_MATCH_MASK; + ITLS0 &= (uint8_t)~_08_ITL_CHANNEL3_COUNT_MATCH_DETECTE; + ITLMK = 1U; /* disable INTITL interrupt */ + ITLIF = 0U; /* clear INTITL interrupt flag */ + /* Set INTITL low priority */ + ITLPR1 = 1U; + ITLPR0 = 1U; + /* 32-bit interval timer used as 8-bit timer */ + ITLCTL0 |= _00_ITL_MODE_8BIT; + ITLCSEL0 &= _F8_ITL_CLOCK_FITL0_CLEAR; + ITLCSEL0 |= _04_ITL_CLOCK_FITL0_FSXP; + ITLFDIV01 &= _8F_ITL_ITL013_FITL0_CLEAR; + ITLFDIV01 |= _00_ITL_ITL013_FITL0_1; + ITLCMP013 = _20_ITL_ITLCMP013_VALUE; + + R_Config_ITL013_Create_UserInit(); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL013_Start +* Description : This function starts the ITL013 channel. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL013_Start(void) +{ + ITLS0 &= (uint8_t)~_08_ITL_CHANNEL3_COUNT_MATCH_DETECTE; + ITLMKF0 &= (uint8_t)~_08_ITL_CHANNEL3_COUNT_MATCH_MASK; + ITLEN03 = 1U; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL013_Stop +* Description : This function stops the ITL013 channel. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL013_Stop(void) +{ + ITLMKF0 |= _08_ITL_CHANNEL3_COUNT_MATCH_MASK; + ITLS0 &= (uint8_t)~_08_ITL_CHANNEL3_COUNT_MATCH_DETECTE; + ITLEN03 = 0U; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL013_Set_OperationMode +* Description : This function is used to stop counter and clear interrupt flag before changing operation mode. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL013_Set_OperationMode(void) +{ + ITLMKF0 |= _08_ITL_CHANNEL3_COUNT_MATCH_MASK; + ITLS0 &= (uint8_t)~_08_ITL_CHANNEL3_COUNT_MATCH_DETECTE; + /* Stop 32-bit interval timer */ + ITLCTL0 &= 0xF0U; +} + +/* Start user code for adding. Do not edit comment generated here */ +void R_Config_ITL013_SetCompareMatch(uint8_t count,uint8_t div) +{ + ITLEN03 = 0U; + + ITLCSEL0 &= _F8_ITL_CLOCK_FITL0_CLEAR; + ITLCSEL0 |= _04_ITL_CLOCK_FITL0_FSXP;; + ITLFDIV01 &= _8F_ITL_ITL013_FITL0_CLEAR; + ITLFDIV01 |= div; + ITLCMP013 = count; +} + +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_ITL013/Config_ITL013.h b/cores/rl78g22/smc_gen/Config_ITL013/Config_ITL013.h index 91c932b..46724e4 100644 --- a/cores/rl78g22/smc_gen/Config_ITL013/Config_ITL013.h +++ b/cores/rl78g22/smc_gen/Config_ITL013/Config_ITL013.h @@ -1,61 +1,61 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_ITL013.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_ITL013. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_ITL013_H -#define CFG_Config_ITL013_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_itl.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _20_ITL_ITLCMP013_VALUE (0x20U) /* 8-bit compare data register */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_ITL013_Create (void); -void R_Config_ITL013_Start (void); -void R_Config_ITL013_Stop (void); -void R_Config_ITL013_Set_OperationMode (void); -void R_Config_ITL013_Callback_Shared_Interrupt (void); -void R_Config_ITL013_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -void R_Config_ITL013_SetCompareMatch(uint8_t count,uint8_t div); -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021, 2023 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_ITL013.h +* Component Version: 1.4.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_ITL013. +* Creation Date : +***********************************************************************************************************************/ + +#ifndef CFG_Config_ITL013_H +#define CFG_Config_ITL013_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_itl.h" + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ +#define _20_ITL_ITLCMP013_VALUE (0x20U) /* 8-bit compare data register */ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_Config_ITL013_Create (void); +void R_Config_ITL013_Start (void); +void R_Config_ITL013_Stop (void); +void R_Config_ITL013_Set_OperationMode (void); +void R_Config_ITL013_Callback_Shared_Interrupt (void); +void R_Config_ITL013_Create_UserInit (void); +/* Start user code for function. Do not edit comment generated here */ +void R_Config_ITL013_SetCompareMatch(uint8_t count,uint8_t div); +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/Config_ITL013/Config_ITL013_user.c b/cores/rl78g22/smc_gen/Config_ITL013/Config_ITL013_user.c index 3f2621f..4bdbd8f 100644 --- a/cores/rl78g22/smc_gen/Config_ITL013/Config_ITL013_user.c +++ b/cores/rl78g22/smc_gen/Config_ITL013/Config_ITL013_user.c @@ -1,74 +1,91 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_ITL013_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_ITL013. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_ITL013.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL013_Create_UserInit -* Description : This function adds user code after initializing the ITL013 channel. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL013_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_ITL013_Callback_Shared_Interrupt -* Description : This function handles the ITL013 shared interrupt. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_ITL013_Callback_Shared_Interrupt(void) -{ - /* Start user code for R_Config_ITL013_Callback_Shared_Interrupt. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021, 2023 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_ITL013_user.c +* Component Version: 1.4.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_ITL013. +* Creation Date : +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_ITL013.h" +/* Start user code for include. Do not edit comment generated here */ +#include "utilities.h" +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +extern volatile unsigned long g_u32timer_periodic; +void (*INT_TM_HOOK)() = NULL; +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL013_Create_UserInit +* Description : This function adds user code after initializing the ITL013 channel. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL013_Create_UserInit(void) +{ + /* Start user code for user init. Do not edit comment generated here */ + g_u32timer_periodic = 0; + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_ITL013_Callback_Shared_Interrupt +* Description : This function handles the ITL013 shared interrupt. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_ITL013_Callback_Shared_Interrupt(void) +{ + /* Start user code for R_Config_ITL013_Callback_Shared_Interrupt. Do not edit comment generated here */ + g_u32timer_periodic ++; + + if(g_fITInterruptFunc != NULL) + { + g_fITInterruptFunc(g_u32timer_periodic); + } + execCyclicHandler(); + + // for MsTImer2 + if(NULL != INT_TM_HOOK) + { + INT_TM_HOOK(); + } + /* End user code. Do not edit comment generated here */ +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_RTC/Config_RTC.c b/cores/rl78g22/smc_gen/Config_RTC/Config_RTC.c index 07db8b8..efe334c 100644 --- a/cores/rl78g22/smc_gen/Config_RTC/Config_RTC.c +++ b/cores/rl78g22/smc_gen/Config_RTC/Config_RTC.c @@ -1,467 +1,467 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_RTC.c -* Version : 1.0.0 -* Device(s) : R7F100GLGxFB -* Description : This file implements device driver for Config_RTC. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_RTC.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_RTC_Create -* Description : This function initializes the real-time clock module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_RTC_Create(void) -{ - /* Supplies input clock */ - RTCWEN = 1U; - /* Disable RTC clock operation */ - RTCE = 0U; - /* Disable INTRTC interrupt */ - RTCMK = 1U; - /* Clear INTRTC interrupt flag */ - RTCIF = 0U; - /* Set INTRTC Low priority */ - RTCPR1 = 1U; - RTCPR0 = 1U; - /* Set fRTCCK */ - RTCC0 = _00_RTC_CLK_32KHZ; - /* Set 12-/24-hour system and period of Constant-period interrupt (INTRTC) */ - RTCC0 |= (_00_RTC_RTC1HZ_DISABLE | _08_RTC_24HOUR_MODE | _02_RTC_INTRTC_CLOCK_1SEC); - /* Set real-time clock initial value */ - SEC = _00_RTC_COUNTER_SEC; - MIN = _00_RTC_COUNTER_MIN; - HOUR = _00_RTC_COUNTER_HOUR; - WEEK = _01_RTC_COUNTER_WEEK; - DAY = _01_RTC_COUNTER_DAY; - MONTH = _01_RTC_COUNTER_MONTH; - YEAR = _01_RTC_COUNTER_YEAR; - /* Set alarm detect function */ - WALE = 0U; - WALIE = 1U; - /* Alarm function setting */ - ALARMWM = _00_RTC_ALARM_MIN; - ALARMWH = _00_RTC_ALARM_HOUR; - ALARMWW = _01_RTC_ALARM_WEEK; - - R_Config_RTC_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_RTC_Start -* Description : This function enables the real-time clock. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_RTC_Start(void) -{ - /* Clear INTRTC interrupt flag */ - RTCIF = 0U; - /* Enable INTRTC interrupt */ - RTCMK = 0U; - /* Enable RTC clock operation */ - RTCE = 1U; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_RTC_Stop -* Description : This function disables the real-time clock. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_RTC_Stop(void) -{ - /* Disable RTC clock operation */ - RTCE = 0U; - /* Disable INTRTC interrupt */ - RTCMK = 1U; - /* Clear INTRTC interrupt flag */ - RTCIF = 0U; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_RTC_Set_HourSystem -* Description : This function chooses 12-hour system or 24-hour system. -* Arguments : hour_system - -* the selection of real-time clock hour system -* Return Value : status - -* MD_OK, MD_ARGERROR, MD_BUSY1 or MD_BUSY2 -***********************************************************************************************************************/ -MD_STATUS R_Config_RTC_Set_HourSystem(e_rtc_hour_system_t hour_system) -{ - MD_STATUS status = MD_OK; - volatile uint16_t w_count; - - switch (hour_system) - { - case HOUR12: - - if (_08_RTC_24HOUR_MODE == (RTCC0 & _08_RTC_RTCC0_AMPM)) - { - RTCC1 |= _01_RTC_COUNTER_PAUSE; - /* Change the waiting time according to the system */ - for (w_count = 0U; w_count < RTC_WAITTIME_2CYCLE; w_count++) - { - NOP(); - } - if (0U == RWST) - { - status = MD_BUSY1; - } - else - { - RTCC0 &= (uint8_t)~_08_RTC_24HOUR_MODE; - RTCC1 &= (uint8_t)~_01_RTC_COUNTER_PAUSE; - /* Change the waiting time according to the system */ - for (w_count = 0U; w_count < RTC_WAITTIME_2CYCLE; w_count++) - { - NOP(); - } - - if (1U == RWST) - { - status = MD_BUSY2; - } - } - } - - break; - - case HOUR24: - - if (_00_RTC_12HOUR_MODE == (RTCC0 & _08_RTC_RTCC0_AMPM)) - { - RTCC1 |= _01_RTC_COUNTER_PAUSE; - /* Change the waiting time according to the system */ - for (w_count = 0U; w_count < RTC_WAITTIME_2CYCLE; w_count++) - { - NOP(); - } - - if (0U == RWST) - { - status = MD_BUSY1; - } - else - { - RTCC0 |= _08_RTC_24HOUR_MODE; - RTCC1 &= (uint8_t)~_01_RTC_COUNTER_PAUSE; - /* Change the waiting time according to the system */ - for (w_count = 0U; w_count < RTC_WAITTIME_2CYCLE; w_count++) - { - NOP(); - } - - if (1U == RWST) - { - status = MD_BUSY2; - } - } - } - - break; - - default: - status = MD_ARGERROR; - break; - } - return (status); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_RTC_Get_CounterValue -* Description : This function reads the results of real-time clock and store them in the variables. -* Arguments : counter_read_val - -* the current real-time clock value (BCD code) -* Return Value : status - -* MD_OK, MD_BUSY1 or MD_BUSY2 -***********************************************************************************************************************/ -MD_STATUS R_Config_RTC_Get_CounterValue(st_rtc_counter_value_t * const counter_read_val) -{ - MD_STATUS status = MD_OK; - volatile uint16_t w_count; - /*Stops SEC to YEAR counters, read or write counter value*/ - RTCC1 |= _01_RTC_COUNTER_PAUSE; - /* Change the waiting time according to the system */ - for (w_count = 0U; w_count < RTC_WAITTIME_2CYCLE; w_count++) - { - NOP(); - } - /* Checks wait status of counter */ - if (0U == RWST) - { - status = MD_BUSY1; - } - else - { - counter_read_val->sec = SEC; - counter_read_val->min = MIN; - counter_read_val->hour = HOUR; - counter_read_val->week = WEEK; - counter_read_val->day = DAY; - counter_read_val->month = MONTH; - counter_read_val->year = YEAR; - /* Sets counter operation */ - RTCC1 &= (uint8_t)~_01_RTC_COUNTER_PAUSE; - /* Change the waiting time according to the system */ - for (w_count = 0U; w_count < RTC_WAITTIME_2CYCLE; w_count++) - { - NOP(); - } - - if (1U == RWST) - { - status = MD_BUSY2; - } - } - - return (status); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_RTC_Set_CounterValue -* Description : This function changes the real-time clock value. -* Arguments : counter_write_val - -* the expected real-time clock value (BCD code) -* Return Value : status - -* MD_OK, MD_BUSY1 or MD_BUSY2 -***********************************************************************************************************************/ -MD_STATUS R_Config_RTC_Set_CounterValue(st_rtc_counter_value_t counter_write_val) -{ - MD_STATUS status = MD_OK; - volatile uint16_t w_count; - /*Stops SEC to YEAR counters, read or write counter value*/ - RTCC1 |= _01_RTC_COUNTER_PAUSE; - /* Change the waiting time according to the system */ - for (w_count = 0U; w_count < RTC_WAITTIME_2CYCLE; w_count++) - { - NOP(); - } - - if (0U == RWST) - { - status = MD_BUSY1; - } - else - { - if ((1U == RTCE) && (0U == RTCMK)) - { - /* Disable INTRTC interrupt */ - RTCMK = 1U; - - SEC = counter_write_val.sec; - MIN = counter_write_val.min; - HOUR = counter_write_val.hour; - WEEK = counter_write_val.week; - DAY = counter_write_val.day; - MONTH = counter_write_val.month; - YEAR = counter_write_val.year; - /* Clear matching detection flag */ - WAFG = 0U; - /* Clear constant-period interrupt flag */ - RIFG = 0U; - /* Clear INTRTC interrupt flag */ - RTCIF = 0U; - /* Enable INTRTC interrupt */ - RTCMK = 0U; - } - else - { - SEC = counter_write_val.sec; - MIN = counter_write_val.min; - HOUR = counter_write_val.hour; - WEEK = counter_write_val.week; - DAY = counter_write_val.day; - MONTH = counter_write_val.month; - YEAR = counter_write_val.year; - } - /* Sets counter operation */ - RTCC1 &= (uint8_t)~_01_RTC_COUNTER_PAUSE; - /* Change the waiting time according to the system */ - for (w_count = 0U; w_count < RTC_WAITTIME_2CYCLE; w_count++) - { - NOP(); - } - - if (1U == RWST) - { - status = MD_BUSY2; - } - } - - return (status); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_RTC_Set_AlarmOn -* Description : This function starts the alarm operation. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_RTC_Set_AlarmOn(void) -{ - /* Disable INTRTC interrupt */ - RTCMK = 1U; - /* Enable RTC alarm operation */ - RTCC1 |= _80_RTC_ALARM_ENABLE; - RTCC1 &= (uint8_t)~_10_RTC_ALARM_MATCH; - /* Clear INTRTC interrupt flag */ - RTCIF = 0U; - /* Enable INTRTC interrupt */ - RTCMK = 0U; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_RTC_Set_AlarmOff -* Description : This function stops the alarm operation. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_RTC_Set_AlarmOff(void) -{ - /* Disable INTRTC interrupt */ - RTCMK = 1U; - /* Disable RTC alarm operation */ - RTCC1 &= (uint8_t)~_80_RTC_ALARM_ENABLE; - RTCC1 &= (uint8_t)~_10_RTC_ALARM_MATCH; - /* Clear INTRTC interrupt flag */ - RTCIF = 0U; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_RTC_Set_AlarmValue -* Description : This function sets alarm value. -* Arguments : alarm_val - -* the expected alarm value (BCD code) -* Return Value : None -***********************************************************************************************************************/ -void R_Config_RTC_Set_AlarmValue(st_rtc_alarm_value_t alarm_val) -{ - /* Disable INTRTC interrupt */ - RTCMK = 1U; - /* Disable RTC alarm operation */ - RTCC1 &= (uint8_t)~_80_RTC_ALARM_ENABLE; - RTCC1 |= _40_RTC_ALARM_INT_ENABLE; - ALARMWM = alarm_val.alarmwm; - ALARMWH = alarm_val.alarmwh; - ALARMWW = alarm_val.alarmww; - /* Enable RTC alarm operation */ - RTCC1 |= _80_RTC_ALARM_ENABLE; - RTCC1 &= (uint8_t)~_10_RTC_ALARM_MATCH; - /* Clear INTRTC interrupt flag */ - RTCIF = 0U; - /* Enable INTRTC interrupt */ - RTCMK = 0U; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_RTC_Get_AlarmValue -* Description : This function gets alarm value. -* Arguments : alarm_val - -* the address to save alarm value (BCD code) -* Return Value : None -***********************************************************************************************************************/ -void R_Config_RTC_Get_AlarmValue(st_rtc_alarm_value_t * const alarm_val) -{ - /* Disable INTRTC interrupt */ - RTCMK = 1U; - /* Disable RTC alarm operation */ - RTCC1 &= (uint8_t)~_80_RTC_ALARM_ENABLE; - alarm_val->alarmwm = ALARMWM; - alarm_val->alarmwh = ALARMWH; - alarm_val->alarmww = ALARMWW; - /* Enable RTC alarm operation */ - RTCC1 |= _80_RTC_ALARM_ENABLE; - RTCC1 &= (uint8_t)~_10_RTC_ALARM_MATCH; - /* Clear INTRTC interrupt flag */ - RTCIF = 0U; - /* Enable INTRTC interrupt */ - RTCMK = 0U; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_RTC_Set_ConstPeriodInterruptOn -* Description : This function enables constant-period interrupt. -* Arguments : period - -* the constant period of INTRTC -* Return Value : status - -* MD_OK or MD_ARGERROR -***********************************************************************************************************************/ -MD_STATUS R_Config_RTC_Set_ConstPeriodInterruptOn(e_rtc_int_period_t period) -{ - MD_STATUS status = MD_OK; - if ((period < HALFSEC) || (period > ONEMONTH)) - { - status = MD_ARGERROR; - } - else - { - /* Disable INTRTC */ - RTCMK = 1U; - RTCC0 = (RTCC0 & _F8_RTC_INTRTC_CLEAR) | period; - RTCC1 &= (uint8_t)~_08_RTC_INTC_GENERATE_FLAG; - /* Clear INTRTC interrupt flag */ - RTCIF = 0U; - /* Enable INTRTC interrupt */ - RTCMK = 0U; - } - return (status); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_RTC_Set_ConstPeriodInterruptOff -* Description : This function disables constant-period interrupt. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_RTC_Set_ConstPeriodInterruptOff(void) -{ - RTCC0 &= _F8_RTC_INTRTC_CLEAR; - RTCC1 &= (uint8_t)~_08_RTC_INTC_GENERATE_FLAG; - /* Clear INTRTC interrupt flag */ - RTCIF = 0U; -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_RTC.c +* Version : 1.0.0 +* Device(s) : R7F100GLGxFB +* Description : This file implements device driver for Config_RTC. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_RTC.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_RTC_Create +* Description : This function initializes the real-time clock module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_RTC_Create(void) +{ + /* Supplies input clock */ + RTCWEN = 1U; + /* Disable RTC clock operation */ + RTCE = 0U; + /* Disable INTRTC interrupt */ + RTCMK = 1U; + /* Clear INTRTC interrupt flag */ + RTCIF = 0U; + /* Set INTRTC Low priority */ + RTCPR1 = 1U; + RTCPR0 = 1U; + /* Set fRTCCK */ + RTCC0 = _00_RTC_CLK_32KHZ; + /* Set 12-/24-hour system and period of Constant-period interrupt (INTRTC) */ + RTCC0 |= (_00_RTC_RTC1HZ_DISABLE | _08_RTC_24HOUR_MODE | _02_RTC_INTRTC_CLOCK_1SEC); + /* Set real-time clock initial value */ + SEC = _00_RTC_COUNTER_SEC; + MIN = _00_RTC_COUNTER_MIN; + HOUR = _00_RTC_COUNTER_HOUR; + WEEK = _01_RTC_COUNTER_WEEK; + DAY = _01_RTC_COUNTER_DAY; + MONTH = _01_RTC_COUNTER_MONTH; + YEAR = _01_RTC_COUNTER_YEAR; + /* Set alarm detect function */ + WALE = 0U; + WALIE = 1U; + /* Alarm function setting */ + ALARMWM = _00_RTC_ALARM_MIN; + ALARMWH = _00_RTC_ALARM_HOUR; + ALARMWW = _01_RTC_ALARM_WEEK; + + R_Config_RTC_Create_UserInit(); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_RTC_Start +* Description : This function enables the real-time clock. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_RTC_Start(void) +{ + /* Clear INTRTC interrupt flag */ + RTCIF = 0U; + /* Enable INTRTC interrupt */ + RTCMK = 0U; + /* Enable RTC clock operation */ + RTCE = 1U; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_RTC_Stop +* Description : This function disables the real-time clock. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_RTC_Stop(void) +{ + /* Disable RTC clock operation */ + RTCE = 0U; + /* Disable INTRTC interrupt */ + RTCMK = 1U; + /* Clear INTRTC interrupt flag */ + RTCIF = 0U; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_RTC_Set_HourSystem +* Description : This function chooses 12-hour system or 24-hour system. +* Arguments : hour_system - +* the selection of real-time clock hour system +* Return Value : status - +* MD_OK, MD_ARGERROR, MD_BUSY1 or MD_BUSY2 +***********************************************************************************************************************/ +MD_STATUS R_Config_RTC_Set_HourSystem(e_rtc_hour_system_t hour_system) +{ + MD_STATUS status = MD_OK; + volatile uint16_t w_count; + + switch (hour_system) + { + case HOUR12: + + if (_08_RTC_24HOUR_MODE == (RTCC0 & _08_RTC_RTCC0_AMPM)) + { + RTCC1 |= _01_RTC_COUNTER_PAUSE; + /* Change the waiting time according to the system */ + for (w_count = 0U; w_count < RTC_WAITTIME_2CYCLE; w_count++) + { + NOP(); + } + if (0U == RWST) + { + status = MD_BUSY1; + } + else + { + RTCC0 &= (uint8_t)~_08_RTC_24HOUR_MODE; + RTCC1 &= (uint8_t)~_01_RTC_COUNTER_PAUSE; + /* Change the waiting time according to the system */ + for (w_count = 0U; w_count < RTC_WAITTIME_2CYCLE; w_count++) + { + NOP(); + } + + if (1U == RWST) + { + status = MD_BUSY2; + } + } + } + + break; + + case HOUR24: + + if (_00_RTC_12HOUR_MODE == (RTCC0 & _08_RTC_RTCC0_AMPM)) + { + RTCC1 |= _01_RTC_COUNTER_PAUSE; + /* Change the waiting time according to the system */ + for (w_count = 0U; w_count < RTC_WAITTIME_2CYCLE; w_count++) + { + NOP(); + } + + if (0U == RWST) + { + status = MD_BUSY1; + } + else + { + RTCC0 |= _08_RTC_24HOUR_MODE; + RTCC1 &= (uint8_t)~_01_RTC_COUNTER_PAUSE; + /* Change the waiting time according to the system */ + for (w_count = 0U; w_count < RTC_WAITTIME_2CYCLE; w_count++) + { + NOP(); + } + + if (1U == RWST) + { + status = MD_BUSY2; + } + } + } + + break; + + default: + status = MD_ARGERROR; + break; + } + return (status); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_RTC_Get_CounterValue +* Description : This function reads the results of real-time clock and store them in the variables. +* Arguments : counter_read_val - +* the current real-time clock value (BCD code) +* Return Value : status - +* MD_OK, MD_BUSY1 or MD_BUSY2 +***********************************************************************************************************************/ +MD_STATUS R_Config_RTC_Get_CounterValue(st_rtc_counter_value_t * const counter_read_val) +{ + MD_STATUS status = MD_OK; + volatile uint16_t w_count; + /*Stops SEC to YEAR counters, read or write counter value*/ + RTCC1 |= _01_RTC_COUNTER_PAUSE; + /* Change the waiting time according to the system */ + for (w_count = 0U; w_count < RTC_WAITTIME_2CYCLE; w_count++) + { + NOP(); + } + /* Checks wait status of counter */ + if (0U == RWST) + { + status = MD_BUSY1; + } + else + { + counter_read_val->sec = SEC; + counter_read_val->min = MIN; + counter_read_val->hour = HOUR; + counter_read_val->week = WEEK; + counter_read_val->day = DAY; + counter_read_val->month = MONTH; + counter_read_val->year = YEAR; + /* Sets counter operation */ + RTCC1 &= (uint8_t)~_01_RTC_COUNTER_PAUSE; + /* Change the waiting time according to the system */ + for (w_count = 0U; w_count < RTC_WAITTIME_2CYCLE; w_count++) + { + NOP(); + } + + if (1U == RWST) + { + status = MD_BUSY2; + } + } + + return (status); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_RTC_Set_CounterValue +* Description : This function changes the real-time clock value. +* Arguments : counter_write_val - +* the expected real-time clock value (BCD code) +* Return Value : status - +* MD_OK, MD_BUSY1 or MD_BUSY2 +***********************************************************************************************************************/ +MD_STATUS R_Config_RTC_Set_CounterValue(st_rtc_counter_value_t counter_write_val) +{ + MD_STATUS status = MD_OK; + volatile uint16_t w_count; + /*Stops SEC to YEAR counters, read or write counter value*/ + RTCC1 |= _01_RTC_COUNTER_PAUSE; + /* Change the waiting time according to the system */ + for (w_count = 0U; w_count < RTC_WAITTIME_2CYCLE; w_count++) + { + NOP(); + } + + if (0U == RWST) + { + status = MD_BUSY1; + } + else + { + if ((1U == RTCE) && (0U == RTCMK)) + { + /* Disable INTRTC interrupt */ + RTCMK = 1U; + + SEC = counter_write_val.sec; + MIN = counter_write_val.min; + HOUR = counter_write_val.hour; + WEEK = counter_write_val.week; + DAY = counter_write_val.day; + MONTH = counter_write_val.month; + YEAR = counter_write_val.year; + /* Clear matching detection flag */ + WAFG = 0U; + /* Clear constant-period interrupt flag */ + RIFG = 0U; + /* Clear INTRTC interrupt flag */ + RTCIF = 0U; + /* Enable INTRTC interrupt */ + RTCMK = 0U; + } + else + { + SEC = counter_write_val.sec; + MIN = counter_write_val.min; + HOUR = counter_write_val.hour; + WEEK = counter_write_val.week; + DAY = counter_write_val.day; + MONTH = counter_write_val.month; + YEAR = counter_write_val.year; + } + /* Sets counter operation */ + RTCC1 &= (uint8_t)~_01_RTC_COUNTER_PAUSE; + /* Change the waiting time according to the system */ + for (w_count = 0U; w_count < RTC_WAITTIME_2CYCLE; w_count++) + { + NOP(); + } + + if (1U == RWST) + { + status = MD_BUSY2; + } + } + + return (status); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_RTC_Set_AlarmOn +* Description : This function starts the alarm operation. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_RTC_Set_AlarmOn(void) +{ + /* Disable INTRTC interrupt */ + RTCMK = 1U; + /* Enable RTC alarm operation */ + RTCC1 |= _80_RTC_ALARM_ENABLE; + RTCC1 &= (uint8_t)~_10_RTC_ALARM_MATCH; + /* Clear INTRTC interrupt flag */ + RTCIF = 0U; + /* Enable INTRTC interrupt */ + RTCMK = 0U; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_RTC_Set_AlarmOff +* Description : This function stops the alarm operation. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_RTC_Set_AlarmOff(void) +{ + /* Disable INTRTC interrupt */ + RTCMK = 1U; + /* Disable RTC alarm operation */ + RTCC1 &= (uint8_t)~_80_RTC_ALARM_ENABLE; + RTCC1 &= (uint8_t)~_10_RTC_ALARM_MATCH; + /* Clear INTRTC interrupt flag */ + RTCIF = 0U; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_RTC_Set_AlarmValue +* Description : This function sets alarm value. +* Arguments : alarm_val - +* the expected alarm value (BCD code) +* Return Value : None +***********************************************************************************************************************/ +void R_Config_RTC_Set_AlarmValue(st_rtc_alarm_value_t alarm_val) +{ + /* Disable INTRTC interrupt */ + RTCMK = 1U; + /* Disable RTC alarm operation */ + RTCC1 &= (uint8_t)~_80_RTC_ALARM_ENABLE; + RTCC1 |= _40_RTC_ALARM_INT_ENABLE; + ALARMWM = alarm_val.alarmwm; + ALARMWH = alarm_val.alarmwh; + ALARMWW = alarm_val.alarmww; + /* Enable RTC alarm operation */ + RTCC1 |= _80_RTC_ALARM_ENABLE; + RTCC1 &= (uint8_t)~_10_RTC_ALARM_MATCH; + /* Clear INTRTC interrupt flag */ + RTCIF = 0U; + /* Enable INTRTC interrupt */ + RTCMK = 0U; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_RTC_Get_AlarmValue +* Description : This function gets alarm value. +* Arguments : alarm_val - +* the address to save alarm value (BCD code) +* Return Value : None +***********************************************************************************************************************/ +void R_Config_RTC_Get_AlarmValue(st_rtc_alarm_value_t * const alarm_val) +{ + /* Disable INTRTC interrupt */ + RTCMK = 1U; + /* Disable RTC alarm operation */ + RTCC1 &= (uint8_t)~_80_RTC_ALARM_ENABLE; + alarm_val->alarmwm = ALARMWM; + alarm_val->alarmwh = ALARMWH; + alarm_val->alarmww = ALARMWW; + /* Enable RTC alarm operation */ + RTCC1 |= _80_RTC_ALARM_ENABLE; + RTCC1 &= (uint8_t)~_10_RTC_ALARM_MATCH; + /* Clear INTRTC interrupt flag */ + RTCIF = 0U; + /* Enable INTRTC interrupt */ + RTCMK = 0U; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_RTC_Set_ConstPeriodInterruptOn +* Description : This function enables constant-period interrupt. +* Arguments : period - +* the constant period of INTRTC +* Return Value : status - +* MD_OK or MD_ARGERROR +***********************************************************************************************************************/ +MD_STATUS R_Config_RTC_Set_ConstPeriodInterruptOn(e_rtc_int_period_t period) +{ + MD_STATUS status = MD_OK; + if ((period < HALFSEC) || (period > ONEMONTH)) + { + status = MD_ARGERROR; + } + else + { + /* Disable INTRTC */ + RTCMK = 1U; + RTCC0 = (RTCC0 & _F8_RTC_INTRTC_CLEAR) | period; + RTCC1 &= (uint8_t)~_08_RTC_INTC_GENERATE_FLAG; + /* Clear INTRTC interrupt flag */ + RTCIF = 0U; + /* Enable INTRTC interrupt */ + RTCMK = 0U; + } + return (status); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_RTC_Set_ConstPeriodInterruptOff +* Description : This function disables constant-period interrupt. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_RTC_Set_ConstPeriodInterruptOff(void) +{ + RTCC0 &= _F8_RTC_INTRTC_CLEAR; + RTCC1 &= (uint8_t)~_08_RTC_INTC_GENERATE_FLAG; + /* Clear INTRTC interrupt flag */ + RTCIF = 0U; +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_RTC/Config_RTC.h b/cores/rl78g22/smc_gen/Config_RTC/Config_RTC.h index a7fc485..2a2c97b 100644 --- a/cores/rl78g22/smc_gen/Config_RTC/Config_RTC.h +++ b/cores/rl78g22/smc_gen/Config_RTC/Config_RTC.h @@ -1,109 +1,109 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_RTC.h -* Version : 1.0.0 -* Device(s) : R7F100GLGxFB -* Description : This file implements device driver for Config_RTC. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_RTC_H -#define CFG_Config_RTC_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_rtc.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _00_RTC_COUNTER_SEC (0x00U) -#define _00_RTC_COUNTER_MIN (0x00U) -#define _00_RTC_COUNTER_HOUR (0x00U) -#define _01_RTC_COUNTER_WEEK (0x01U) -#define _01_RTC_COUNTER_DAY (0x01U) -#define _01_RTC_COUNTER_MONTH (0x01U) -#define _01_RTC_COUNTER_YEAR (0x01U) -#define _00_RTC_ALARM_MIN (0x00U) -#define _00_RTC_ALARM_HOUR (0x00U) -#define _01_RTC_ALARM_WEEK (0x01U) -#define RTC_WAITTIME_2CYCLE (163U) - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ -typedef struct -{ - uint8_t sec; - uint8_t min; - uint8_t hour; - uint8_t day; - uint8_t week; - uint8_t month; - uint8_t year; -} st_rtc_counter_value_t; -typedef struct -{ - uint8_t alarmwm; - uint8_t alarmwh; - uint8_t alarmww; -} st_rtc_alarm_value_t; -typedef enum -{ - HOUR12, - HOUR24 -} e_rtc_hour_system_t; -typedef enum -{ - HALFSEC = 1U, - ONESEC, - ONEMIN, - ONEHOUR, - ONEDAY, - ONEMONTH -} e_rtc_int_period_t; - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_RTC_Create(void); -void R_Config_RTC_Start(void); -void R_Config_RTC_Stop(void); -MD_STATUS R_Config_RTC_Set_HourSystem(e_rtc_hour_system_t hour_system); -MD_STATUS R_Config_RTC_Get_CounterValue(st_rtc_counter_value_t * const counter_read_val); -MD_STATUS R_Config_RTC_Set_CounterValue(st_rtc_counter_value_t counter_write_val); -void R_Config_RTC_Set_AlarmOn(void); -void R_Config_RTC_Set_AlarmOff(void); -void R_Config_RTC_Set_AlarmValue(st_rtc_alarm_value_t alarm_val); -void R_Config_RTC_Get_AlarmValue(st_rtc_alarm_value_t * const alarm_val); -MD_STATUS R_Config_RTC_Set_ConstPeriodInterruptOn(e_rtc_int_period_t period); -void R_Config_RTC_Set_ConstPeriodInterruptOff(void); -void R_Config_RTC_Create_UserInit(void); -/* Start user code for function. Do not edit comment generated here */ -// void r_Config_RTC_interrupt(void); -typedef void(*voidFunc_t)(void); -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_RTC.h +* Version : 1.0.0 +* Device(s) : R7F100GLGxFB +* Description : This file implements device driver for Config_RTC. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef CFG_Config_RTC_H +#define CFG_Config_RTC_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_rtc.h" + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ +#define _00_RTC_COUNTER_SEC (0x00U) +#define _00_RTC_COUNTER_MIN (0x00U) +#define _00_RTC_COUNTER_HOUR (0x00U) +#define _01_RTC_COUNTER_WEEK (0x01U) +#define _01_RTC_COUNTER_DAY (0x01U) +#define _01_RTC_COUNTER_MONTH (0x01U) +#define _01_RTC_COUNTER_YEAR (0x01U) +#define _00_RTC_ALARM_MIN (0x00U) +#define _00_RTC_ALARM_HOUR (0x00U) +#define _01_RTC_ALARM_WEEK (0x01U) +#define RTC_WAITTIME_2CYCLE (163U) + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ +typedef struct +{ + uint8_t sec; + uint8_t min; + uint8_t hour; + uint8_t day; + uint8_t week; + uint8_t month; + uint8_t year; +} st_rtc_counter_value_t; +typedef struct +{ + uint8_t alarmwm; + uint8_t alarmwh; + uint8_t alarmww; +} st_rtc_alarm_value_t; +typedef enum +{ + HOUR12, + HOUR24 +} e_rtc_hour_system_t; +typedef enum +{ + HALFSEC = 1U, + ONESEC, + ONEMIN, + ONEHOUR, + ONEDAY, + ONEMONTH +} e_rtc_int_period_t; + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_Config_RTC_Create(void); +void R_Config_RTC_Start(void); +void R_Config_RTC_Stop(void); +MD_STATUS R_Config_RTC_Set_HourSystem(e_rtc_hour_system_t hour_system); +MD_STATUS R_Config_RTC_Get_CounterValue(st_rtc_counter_value_t * const counter_read_val); +MD_STATUS R_Config_RTC_Set_CounterValue(st_rtc_counter_value_t counter_write_val); +void R_Config_RTC_Set_AlarmOn(void); +void R_Config_RTC_Set_AlarmOff(void); +void R_Config_RTC_Set_AlarmValue(st_rtc_alarm_value_t alarm_val); +void R_Config_RTC_Get_AlarmValue(st_rtc_alarm_value_t * const alarm_val); +MD_STATUS R_Config_RTC_Set_ConstPeriodInterruptOn(e_rtc_int_period_t period); +void R_Config_RTC_Set_ConstPeriodInterruptOff(void); +void R_Config_RTC_Create_UserInit(void); +/* Start user code for function. Do not edit comment generated here */ +// void r_Config_RTC_interrupt(void); +typedef void(*voidFunc_t)(void); +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/Config_RTC/Config_RTC_user.c b/cores/rl78g22/smc_gen/Config_RTC/Config_RTC_user.c index da26690..44d866c 100644 --- a/cores/rl78g22/smc_gen/Config_RTC/Config_RTC_user.c +++ b/cores/rl78g22/smc_gen/Config_RTC/Config_RTC_user.c @@ -1,120 +1,120 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_RTC_user.c -* Version : 1.0.0 -* Device(s) : R7F100GLGxFB -* Description : This file implements device driver for Config_RTC. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_RTC.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -voidFunc_t alarmUserCallback; -voidFunc_t periodTimeUserCallback; -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_RTC_Create_UserInit -* Description : This function adds user code after initializing the real-time clock. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_RTC_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - alarmUserCallback = NULL; - periodTimeUserCallback = NULL; - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_RTC_callback_alarm -* Description : This function is alarm interrupt service handler. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_RTC_callback_alarm(void) -{ - /* Start user code for r_Config_RTC_callback_alarm. Do not edit comment generated here */ - if (NULL != alarmUserCallback) - { - alarmUserCallback(); - } - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_RTC_callback_constperiod -* Description : This function is real-time clock constant-period interrupt service handler. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_RTC_callback_constperiod(void) -{ - /* Start user code for r_Config_RTC_callback_constperiod. Do not edit comment generated here */ - if (NULL != periodTimeUserCallback) - { - periodTimeUserCallback(); - } - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_RTC_interrupt -* Description : This function is INTRTC interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_RTC_interrupt(void) -{ - if (1U == WAFG) - { - /* clear WAFG */ - RTCC1 &= (uint8_t)~_10_RTC_ALARM_MATCH; - r_Config_RTC_callback_alarm(); - } - if (1U == RIFG) - { - /* clear RIFG */ - RTCC1 &= (uint8_t)~_08_RTC_INTC_GENERATE_FLAG; - r_Config_RTC_callback_constperiod(); - } -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_RTC_user.c +* Version : 1.0.0 +* Device(s) : R7F100GLGxFB +* Description : This file implements device driver for Config_RTC. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_RTC.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +voidFunc_t alarmUserCallback; +voidFunc_t periodTimeUserCallback; +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_RTC_Create_UserInit +* Description : This function adds user code after initializing the real-time clock. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_RTC_Create_UserInit(void) +{ + /* Start user code for user init. Do not edit comment generated here */ + alarmUserCallback = NULL; + periodTimeUserCallback = NULL; + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_RTC_callback_alarm +* Description : This function is alarm interrupt service handler. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_RTC_callback_alarm(void) +{ + /* Start user code for r_Config_RTC_callback_alarm. Do not edit comment generated here */ + if (NULL != alarmUserCallback) + { + alarmUserCallback(); + } + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_RTC_callback_constperiod +* Description : This function is real-time clock constant-period interrupt service handler. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_RTC_callback_constperiod(void) +{ + /* Start user code for r_Config_RTC_callback_constperiod. Do not edit comment generated here */ + if (NULL != periodTimeUserCallback) + { + periodTimeUserCallback(); + } + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_RTC_interrupt +* Description : This function is INTRTC interrupt service routine. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_RTC_interrupt(void) +{ + if (1U == WAFG) + { + /* clear WAFG */ + RTCC1 &= (uint8_t)~_10_RTC_ALARM_MATCH; + r_Config_RTC_callback_alarm(); + } + if (1U == RIFG) + { + /* clear RIFG */ + RTCC1 &= (uint8_t)~_08_RTC_INTC_GENERATE_FLAG; + r_Config_RTC_callback_constperiod(); + } +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_01_PWM/Config_TAU0_01_PWM_user.c b/cores/rl78g22/smc_gen/Config_TAU0_01_PWM/Config_TAU0_01_PWM_user.c deleted file mode 100644 index 12cfa27..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_01_PWM/Config_TAU0_01_PWM_user.c +++ /dev/null @@ -1,86 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_01_PWM_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_0. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_01_PWM.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_0_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel0. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_01_PWM_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_0_channel0_interrupt -* Description : This function is INTTM00 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_01_PWM_channel0_interrupt(void) -{ - /* Start user code for r_Config_TAU0_0_channel0_interrupt. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_0_channel1_interrupt -* Description : This function is INTTM01 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_01_PWM_channel1_interrupt(void) -{ - /* Start user code for r_Config_TAU0_0_channel1_interrupt. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_0_Measure_Signal/Config_TAU0_0_Measure_Signal.c b/cores/rl78g22/smc_gen/Config_TAU0_0_Measure_Signal/Config_TAU0_0_Measure_Signal.c deleted file mode 100644 index 14014db..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_0_Measure_Signal/Config_TAU0_0_Measure_Signal.c +++ /dev/null @@ -1,280 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_0_Measure_Signal.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_0_Measure_Signal. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_0_Measure_Signal.h" -/* Start user code for include. Do not edit comment generated here */ -#include "Config_TAU0_1_Measure_Signal.h" -#include "Config_TAU0_2_Measure_Signal.h" -#include "Config_TAU0_3_Measure_Signal.h" - -#include "Config_TAU0_7_Measure_Signal.h" -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_0_Create -* Description : This function initializes the TAU0 channel 0 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_0_Measure_Signal_Create(void) -{ - TPS0 &= _FFF0_TAU_CKM0_CLEAR; - TPS0 |= _0006_TAU_CKM0_FCLK_6; - /* Stop channel 0 */ - TT0 |= _0001_TAU_CH0_STOP_TRG_ON; - /* Mask channel 0 interrupt */ - TMMK00 = 1U; /* disable INTTM00 interrupt */ - TMIF00 = 0U; /* clear INTTM00 interrupt flag */ - /* Set INTTM00 low priority */ - TMPR100 = 1U; - TMPR000 = 1U; - /* TAU00 used as interval timer */ - TMR00 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_TRIGGER_SOFTWARE | - _0000_TAU_MODE_INTERVAL_TIMER | _0000_TAU_START_INT_UNUSED; - TDR00 = _0000_TAU_TDR00_VALUE; - TO0 &= (uint16_t)~_0001_TAU_CH0_OUTPUT_VALUE_1; - TOE0 &= (uint16_t)~_0001_TAU_CH0_OUTPUT_ENABLE; - - R_Config_TAU0_0_Measure_Signal_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_0_Start -* Description : This function starts the TAU0 channel 0 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_0_Measure_Signal_Start(void) -{ - TMIF00 = 0U; /* clear INTTM00 interrupt flag */ - TMMK00 = 0U; /* enable INTTM00 interrupt */ - TS0 |= _0001_TAU_CH0_START_TRG_ON; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_0_Stop -* Description : This function stops the TAU0 channel 0 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_0_Measure_Signal_Stop(void) -{ - TT0 |= _0001_TAU_CH0_STOP_TRG_ON; - /* Mask channel 0 interrupt */ - TMMK00 = 1U; /* disable INTTM00 interrupt */ - TMIF00 = 0U; /* clear INTTM00 interrupt flag */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* 1124 nhu add */ -void R_Config_TAU0_0_1_Measure_Signal_Create(void) -{ - R_Config_TAU0_0_Measure_Signal_Create(); - R_Config_TAU0_1_Measure_Signal_Create(); -} - -void R_Config_TAU0_0_2_Measure_Signal_Create(void) -{ - R_Config_TAU0_0_Measure_Signal_Create(); - R_Config_TAU0_2_Measure_Signal_Create(); -} - -void R_Config_TAU0_0_3_Measure_Signal_Create(void) -{ - R_Config_TAU0_0_Measure_Signal_Create(); - R_Config_TAU0_3_Measure_Signal_Create(); -} -/* -void R_Config_TAU0_0_4_Measure_Signal_Create(void) -{ - R_Config_TAU0_0_Measure_Signal_Create(); - R_Config_TAU0_4_Measure_Signal_Create(); -} - -void R_Config_TAU0_0_5_Measure_Signal_Create(void) -{ - R_Config_TAU0_0_Measure_Signal_Create(); - R_Config_TAU0_5_Measure_Signal_Create(); -} - -void R_Config_TAU0_0_6_Measure_Signal_Create(void) -{ - R_Config_TAU0_0_Measure_Signal_Create(); - R_Config_TAU0_6_Measure_Signal_Create(); -} -*/ -void R_Config_TAU0_0_7_Measure_Signal_Create(void) -{ - R_Config_TAU0_0_Measure_Signal_Create(); - R_Config_TAU0_7_Measure_Signal_Create(); -} - -void R_Config_TAU0_0_1_Measure_Signal_Start(void) -{ - TMIF00 = 0U; /* clear INTTM00 interrupt flag */ - TMIF01 = 0U; /* clear INTTM01 interrupt flag */ - TMMK00 = 0U; /* enable INTTM00 interrupt */ - TMMK01 = 0U; /* enable INTTM01 interrupt */ - TS0 |= (_0001_TAU_CH0_START_TRG_ON | _0002_TAU_CH1_START_TRG_ON); -} - -void R_Config_TAU0_0_2_Measure_Signal_Start(void) -{ - TMIF00 = 0U; /* clear INTTM00 interrupt flag */ - TMIF02 = 0U; /* clear INTTM02 interrupt flag */ - TMMK00 = 0U; /* enable INTTM00 interrupt */ - TMMK02 = 0U; /* enable INTTM02 interrupt */ - TS0 |= (_0001_TAU_CH0_START_TRG_ON | _0004_TAU_CH2_START_TRG_ON); -} - -void R_Config_TAU0_0_3_Measure_Signal_Start(void) -{ - TMIF00 = 0U; /* clear INTTM00 interrupt flag */ - TMIF03 = 0U; /* clear INTTM03 interrupt flag */ - TMMK00 = 0U; /* enable INTTM00 interrupt */ - TMMK03 = 0U; /* enable INTTM03 interrupt */ - TS0 |= (_0001_TAU_CH0_START_TRG_ON | _0008_TAU_CH3_START_TRG_ON); -} - -void R_Config_TAU0_0_4_Measure_Signal_Start(void) -{ - TMIF00 = 0U; /* clear INTTM00 interrupt flag */ - TMIF04 = 0U; /* clear INTTM04 interrupt flag */ - TMMK00 = 0U; /* enable INTTM00 interrupt */ - TMMK04 = 0U; /* enable INTTM04 interrupt */ - TS0 |= (_0001_TAU_CH0_START_TRG_ON | _0010_TAU_CH4_START_TRG_ON); -} - -void R_Config_TAU0_0_5_Measure_Signal_Start(void) -{ - TMIF00 = 0U; /* clear INTTM00 interrupt flag */ - TMIF05 = 0U; /* clear INTTM05 interrupt flag */ - TMMK00 = 0U; /* enable INTTM00 interrupt */ - TMMK05 = 0U; /* enable INTTM05 interrupt */ - TS0 |= (_0001_TAU_CH0_START_TRG_ON | _0020_TAU_CH5_START_TRG_ON); -} - -void R_Config_TAU0_0_6_Measure_Signal_Start(void) -{ - TMIF00 = 0U; /* clear INTTM00 interrupt flag */ - TMIF06 = 0U; /* clear INTTM06 interrupt flag */ - TMMK00 = 0U; /* enable INTTM00 interrupt */ - TMMK06 = 0U; /* enable INTTM06 interrupt */ - TS0 |= (_0001_TAU_CH0_START_TRG_ON | _0040_TAU_CH6_START_TRG_ON); -} - -void R_Config_TAU0_0_7_Measure_Signal_Start(void) -{ - TMIF00 = 0U; /* clear INTTM00 interrupt flag */ - TMIF07 = 0U; /* clear INTTM07 interrupt flag */ - TMMK00 = 0U; /* enable INTTM00 interrupt */ - TMMK07 = 0U; /* enable INTTM07 interrupt */ - TS0 |= (_0001_TAU_CH0_START_TRG_ON | _0080_TAU_CH7_START_TRG_ON); -} - -void R_Config_TAU0_0_1_Measure_Signal_Stop(void) -{ - TMMK00 = 1U; /* disable INTTM00 interrupt */ - TMMK01 = 1U; /* disable INTTM01 interrupt */ - TMIF00 = 0U; /* clear INTTM00 interrupt flag */ - TMIF01 = 0U; /* clear INTTM01 interrupt flag */ - TT0 |= (_0001_TAU_CH0_STOP_TRG_ON | _0002_TAU_CH1_STOP_TRG_ON); -} - -void R_Config_TAU0_0_2_Measure_Signal_Stop(void) -{ - TMMK00 = 1U; /* disable INTTM00 interrupt */ - TMMK02 = 1U; /* disable INTTM02 interrupt */ - TMIF00 = 0U; /* clear INTTM00 interrupt flag */ - TMIF02 = 0U; /* clear INTTM02 interrupt flag */ - TT0 |= (_0001_TAU_CH0_STOP_TRG_ON | _0004_TAU_CH2_STOP_TRG_ON); -} - -void R_Config_TAU0_0_3_Measure_Signal_Stop(void) -{ - TMMK00 = 1U; /* disable INTTM00 interrupt */ - TMMK03 = 1U; /* disable INTTM03 interrupt */ - TMIF00 = 0U; /* clear INTTM00 interrupt flag */ - TMIF03 = 0U; /* clear INTTM03 interrupt flag */ - TT0 |= (_0001_TAU_CH0_STOP_TRG_ON | _0008_TAU_CH3_STOP_TRG_ON); -} - -void R_Config_TAU0_0_4_Measure_Signal_Stop(void) -{ - TMMK00 = 1U; /* disable INTTM00 interrupt */ - TMMK04 = 1U; /* disable INTTM04 interrupt */ - TMIF00 = 0U; /* clear INTTM00 interrupt flag */ - TMIF04 = 0U; /* clear INTTM04 interrupt flag */ - TT0 |= (_0001_TAU_CH0_STOP_TRG_ON | _0010_TAU_CH4_STOP_TRG_ON); -} - -void R_Config_TAU0_0_5_Measure_Signal_Stop(void) -{ - TMMK00 = 1U; /* disable INTTM00 interrupt */ - TMMK05 = 1U; /* disable INTTM05 interrupt */ - TMIF00 = 0U; /* clear INTTM00 interrupt flag */ - TMIF05 = 0U; /* clear INTTM05 interrupt flag */ - TT0 |= (_0001_TAU_CH0_STOP_TRG_ON | _0020_TAU_CH5_STOP_TRG_ON); -} - -void R_Config_TAU0_0_6_Measure_Signal_Stop(void) -{ - TMMK00 = 1U; /* disable INTTM00 interrupt */ - TMMK06 = 1U; /* disable INTTM06 interrupt */ - TMIF00 = 0U; /* clear INTTM00 interrupt flag */ - TMIF06 = 0U; /* clear INTTM06 interrupt flag */ - TT0 |= (_0001_TAU_CH0_STOP_TRG_ON | _0040_TAU_CH6_STOP_TRG_ON); -} - -void R_Config_TAU0_0_7_Measure_Signal_Stop(void) -{ - TMMK00 = 1U; /* disable INTTM00 interrupt */ - TMMK07 = 1U; /* disable INTTM07 interrupt */ - TMIF00 = 0U; /* clear INTTM00 interrupt flag */ - TMIF07 = 0U; /* clear INTTM07 interrupt flag */ - TT0 |= (_0001_TAU_CH0_STOP_TRG_ON | _0080_TAU_CH7_STOP_TRG_ON); -} -/* 1124 nhu add */ - -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_0_Measure_Signal/Config_TAU0_0_Measure_Signal.h b/cores/rl78g22/smc_gen/Config_TAU0_0_Measure_Signal/Config_TAU0_0_Measure_Signal.h deleted file mode 100644 index c1a318a..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_0_Measure_Signal/Config_TAU0_0_Measure_Signal.h +++ /dev/null @@ -1,85 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_0.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_0. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef Config_TAU0_0_MEASURE_SIGNAL_H -#define Config_TAU0_0_MEASURE_SIGNAL_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _0000_TAU_TDR00_VALUE (0x0000U) /* 16-bit timer data register 00 (TDR00) */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_0_Measure_Signal_Create (void); -void R_Config_TAU0_0_Measure_Signal_Start (void); -void R_Config_TAU0_0_Measure_Signal_Stop (void); -void R_Config_TAU0_0_Measure_Signal_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* 1124 nhu add */ -void R_Config_TAU0_0_1_Measure_Signal_Create(void); -void R_Config_TAU0_0_2_Measure_Signal_Create(void); -void R_Config_TAU0_0_3_Measure_Signal_Create(void); -// void R_Config_TAU0_0_4_Measure_Signal_Create(void); -// void R_Config_TAU0_0_5_Measure_Signal_Create(void); -// void R_Config_TAU0_0_6_Measure_Signal_Create(void); -void R_Config_TAU0_0_7_Measure_Signal_Create(void); -void R_Config_TAU0_0_1_Measure_Signal_Create(void); - -void R_Config_TAU0_0_1_Measure_Signal_Start(void); -void R_Config_TAU0_0_2_Measure_Signal_Start(void); -void R_Config_TAU0_0_3_Measure_Signal_Start(void); -// void R_Config_TAU0_0_4_Measure_Signal_Start(void); -// void R_Config_TAU0_0_5_Measure_Signal_Start(void); -// void R_Config_TAU0_0_6_Measure_Signal_Start(void); -void R_Config_TAU0_0_7_Measure_Signal_Start(void); - -void R_Config_TAU0_0_1_Measure_Signal_Stop(void); -void R_Config_TAU0_0_2_Measure_Signal_Stop(void); -void R_Config_TAU0_0_3_Measure_Signal_Stop(void); -// void R_Config_TAU0_0_4_Measure_Signal_Stop(void); -// void R_Config_TAU0_0_5_Measure_Signal_Stop(void); -// void R_Config_TAU0_0_6_Measure_Signal_Stop(void); -void R_Config_TAU0_0_7_Measure_Signal_Stop(void); - -/* 1124 nhu add */ -/* End user code. Do not edit comment generated here */ -#endif diff --git a/cores/rl78g22/smc_gen/Config_TAU0_0_Measure_Signal/Config_TAU0_0_Measure_Signal_user.c b/cores/rl78g22/smc_gen/Config_TAU0_0_Measure_Signal/Config_TAU0_0_Measure_Signal_user.c deleted file mode 100644 index bc63212..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_0_Measure_Signal/Config_TAU0_0_Measure_Signal_user.c +++ /dev/null @@ -1,85 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_0_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_0. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_0_Measure_Signal.h" -/* Start user code for include. Do not edit comment generated here */ -volatile uint8_t g_tau0_ch0_interrupt_flag = 0UL; -extern volatile uint8_t g_pulse_enable_interrupt_flag; -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_0_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel 0. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_0_Measure_Signal_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_0_interrupt -* Description : This function is INTTM00 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_0_Measure_Signal_interrupt(void) -{ - /* Start user code for r_Config_TAU0_0_interrupt. Do not edit comment generated here */ - - if(g_pulse_enable_interrupt_flag == 1UL) - { - g_tau0_ch0_interrupt_flag = 1UL; - } - else - { - ; - } - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_01_PWM/Config_TAU0_01_PWM.c b/cores/rl78g22/smc_gen/Config_TAU0_0_PWM/Config_TAU0_0_PWM.c similarity index 52% rename from cores/rl78g22/smc_gen/Config_TAU0_01_PWM/Config_TAU0_01_PWM.c rename to cores/rl78g22/smc_gen/Config_TAU0_0_PWM/Config_TAU0_0_PWM.c index 5dbf525..32ae0fb 100644 --- a/cores/rl78g22/smc_gen/Config_TAU0_01_PWM/Config_TAU0_01_PWM.c +++ b/cores/rl78g22/smc_gen/Config_TAU0_0_PWM/Config_TAU0_0_PWM.c @@ -1,126 +1,232 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_01_PWM.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_0. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_01_PWM.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_01_PWM_Create -* Description : This function initializes the TAU0 channel0 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_01_PWM_Create(void) -{ - TPS0 &= _FFF0_TAU_CKM0_CLEAR; - TPS0 |= _0000_TAU_CKM0_FCLK_0; - TT0 |= (_0002_TAU_CH1_STOP_TRG_ON | _0001_TAU_CH0_STOP_TRG_ON); - TMMK00 = 1U; /* disable INTTM00 interrupt */ - TMIF00 = 0U; /* clear INTTM00 interrupt flag */ - TMMK01 = 1U; /* disable INTTM01 interrupt */ - TMIF01 = 0U; /* clear INTTM01 interrupt flag */ - /* Set INTTM00 low priority */ -// TMPR100 = 1U; -// TMPR000 = 1U; - /* Set INTTM01 low priority */ -// TMPR101 = 1U; -// TMPR001 = 1U; - /* Channel 0 is used as master channel for PWM output function */ - TMR00 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_TRIGGER_SOFTWARE | - _0001_TAU_MODE_PWM_MASTER; - TDR00 = _F9FF_TAU_TDR00_VALUE; - TO0 &= (uint16_t)~_0001_TAU_CH0_OUTPUT_VALUE_1; - TOE0 &= (uint16_t)~_0001_TAU_CH0_OUTPUT_ENABLE; - /* Channel 1 is used as slave channel for PWM output function */ - TMR01 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_COMBINATION_SLAVE | - _0400_TAU_TRIGGER_MASTER_INT | _0009_TAU_MODE_PWM_SLAVE; - TDR01 = _7D00_TAU_TDR01_VALUE; - TOM0 |= _0002_TAU_CH1_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0002_TAU_CH1_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0002_TAU_CH1_OUTPUT_VALUE_1; - TOE0 |= _0002_TAU_CH1_OUTPUT_ENABLE; - /* Set TO01 pin */ - PMCT1 &= 0xBFU; - P1 &= 0xBFU; - PM1 &= 0xBFU; - - R_Config_TAU0_01_PWM_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_0_Start -* Description : This function starts the TAU0 channel0 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_01_PWM_Start(void) -{ -// TMIF00 = 0U; /* clear INTTM00 interrupt flag */ -// TMMK00 = 0U; /* enable INTTM00 interrupt */ -// TMIF01 = 0U; /* clear INTTM01 interrupt flag */ -// TMMK01 = 0U; /* enable INTTM01 interrupt */ - TOE0 |= _0002_TAU_CH1_OUTPUT_ENABLE; - TS0 |= (_0002_TAU_CH1_START_TRG_ON | _0001_TAU_CH0_START_TRG_ON); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_0_Stop -* Description : This function stops the TAU0 channel0 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_01_PWM_Stop(void) -{ - TT0 |= (_0002_TAU_CH1_STOP_TRG_ON | _0001_TAU_CH0_STOP_TRG_ON); - TOE0 &= (uint16_t)~_0002_TAU_CH1_OUTPUT_ENABLE; -// TMMK00 = 1U; /* disable INTTM00 interrupt */ -// TMIF00 = 0U; /* clear INTTM00 interrupt flag */ -// TMMK01 = 1U; /* disable INTTM01 interrupt */ -// TMIF01 = 0U; /* clear INTTM01 interrupt flag */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021, 2023 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_TAU0_0_PWM.c +* Component Version: 1.4.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_TAU0_0_PWM. +* Creation Date : +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_TAU0_0_PWM.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +volatile uint8_t g_tau_output_enable = 0; +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_0_Create +* Description : This function initializes the TAU0 channel0 module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_0_PWM_Create(void) +{ + TPS0 &= _FFF0_TAU_CKM0_CLEAR; + TPS0 |= _0000_TAU_CKM0_FCLK_0; + TT0 |= (_0080_TAU_CH7_STOP_TRG_ON | _0008_TAU_CH3_STOP_TRG_ON | _0004_TAU_CH2_STOP_TRG_ON | + _0002_TAU_CH1_STOP_TRG_ON | _0001_TAU_CH0_STOP_TRG_ON); + TMMK00 = 1U; /* disable INTTM00 interrupt */ + TMIF00 = 0U; /* clear INTTM00 interrupt flag */ + TMMK01 = 1U; /* disable INTTM01 interrupt */ + TMIF01 = 0U; /* clear INTTM01 interrupt flag */ + TMMK02 = 1U; /* disable INTTM02 interrupt */ + TMIF02 = 0U; /* clear INTTM02 interrupt flag */ + TMMK03 = 1U; /* disable INTTM03 interrupt */ + TMIF03 = 0U; /* clear INTTM03 interrupt flag */ + TMMK07 = 1U; /* disable INTTM07 interrupt */ + TMIF07 = 0U; /* clear INTTM07 interrupt flag */ + /* Set INTTM00 low priority */ + TMPR100 = 1U; + TMPR000 = 1U; + /* Channel 0 is used as master channel for PWM output function */ + TMR00 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_TRIGGER_SOFTWARE | + _0001_TAU_MODE_PWM_MASTER; + TDR00 = _7CFF_TAU_TDR00_VALUE; + TO0 &= (uint16_t)~_0001_TAU_CH0_OUTPUT_VALUE_1; + TOE0 &= (uint16_t)~_0001_TAU_CH0_OUTPUT_ENABLE; + /* Channel 1 is used as slave channel for PWM output function */ + TMR01 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_COMBINATION_SLAVE | + _0400_TAU_TRIGGER_MASTER_INT | _0009_TAU_MODE_PWM_SLAVE; + TDR01 = _7D00_TAU_TDR01_VALUE; + TOM0 |= _0002_TAU_CH1_SLAVE_OUTPUT; + TOL0 |= _0002_TAU_CH1_OUTPUT_LEVEL_L; + TO0 &= (uint16_t)~_0002_TAU_CH1_OUTPUT_VALUE_1; + /* Channel 2 is used as slave channel for PWM output function */ + TMR02 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_COMBINATION_SLAVE | + _0400_TAU_TRIGGER_MASTER_INT | _0009_TAU_MODE_PWM_SLAVE; + TDR02 = _7D00_TAU_TDR02_VALUE; + TOM0 |= _0004_TAU_CH2_SLAVE_OUTPUT; + TOL0 |= _0004_TAU_CH2_OUTPUT_LEVEL_L; + TO0 &= (uint16_t)~_0004_TAU_CH2_OUTPUT_VALUE_1; + /* Channel 3 is used as slave channel for PWM output function */ + TMR03 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_COMBINATION_SLAVE | + _0400_TAU_TRIGGER_MASTER_INT | _0009_TAU_MODE_PWM_SLAVE; + TDR03 = _7D00_TAU_TDR03_VALUE; + TOM0 |= _0008_TAU_CH3_SLAVE_OUTPUT; + TOL0 |= _0008_TAU_CH3_OUTPUT_LEVEL_L; + TO0 &= (uint16_t)~_0008_TAU_CH3_OUTPUT_VALUE_1; + /* Channel 7 is used as slave channel for PWM output function */ + TMR07 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_COMBINATION_SLAVE | + _0400_TAU_TRIGGER_MASTER_INT | _0009_TAU_MODE_PWM_SLAVE; + TDR07 = _7D00_TAU_TDR07_VALUE; + TOM0 |= _0080_TAU_CH7_SLAVE_OUTPUT; + TOL0 |= _0080_TAU_CH7_OUTPUT_LEVEL_L; + TO0 &= (uint16_t)~_0080_TAU_CH7_OUTPUT_VALUE_1; + + R_Config_TAU0_0_PWM_Create_UserInit(); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_0_Start +* Description : This function starts the TAU0 channel0 counter. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_0_PWM_Start(void) +{ + TMIF00 = 0U; /* clear INTTM00 interrupt flag */ + TMMK00 = 0U; /* enable INTTM00 interrupt */ + TS0 |= (_0080_TAU_CH7_START_TRG_ON | _0008_TAU_CH3_START_TRG_ON | _0004_TAU_CH2_START_TRG_ON | + _0002_TAU_CH1_START_TRG_ON | _0001_TAU_CH0_START_TRG_ON); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_0_Stop +* Description : This function stops the TAU0 channel0 counter. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_0_PWM_Stop(void) +{ + TT0 |= (_0080_TAU_CH7_STOP_TRG_ON | _0008_TAU_CH3_STOP_TRG_ON | _0004_TAU_CH2_STOP_TRG_ON | + _0002_TAU_CH1_STOP_TRG_ON | _0001_TAU_CH0_STOP_TRG_ON); + TOE0 &= (uint16_t) ~(_0080_TAU_CH7_OUTPUT_ENABLE | _0008_TAU_CH3_OUTPUT_ENABLE | _0004_TAU_CH2_OUTPUT_ENABLE | + _0002_TAU_CH1_OUTPUT_ENABLE); + TMMK00 = 1U; /* disable INTTM00 interrupt */ + TMIF00 = 0U; /* clear INTTM00 interrupt flag */ +} + +/* Start user code for adding. Do not edit comment generated here */ + +void R_Config_TAU0_1_PWM_Create(void) +{ + /* Set TO01 pin */ + PMCT1 &= 0xBFU; + P1 &= 0xBFU; + PM1 &= 0xBFU; +} + +void R_Config_TAU0_2_PWM_Create(void) +{ + /* Set TO02 pin */ + POM1 &= 0x7FU; + PMCT1 &= 0x7FU; + P1 &= 0x7FU; + PM1 &= 0x7FU; +} + +void R_Config_TAU0_3_PWM_Create(void) +{ + /* Set TO03 pin */ + PMCT3 &= 0xFDU; + P3 &= 0xFDU; + PM3 &= 0xFDU; +} + +void R_Config_TAU0_7_PWM_Create(void) +{ + /* Set TO07 pin */ + P4 &= 0xFDU; + PM4 &= 0xFDU; +} + +void R_Config_TAU0_01_PWM_Start(void) +{ + g_tau_output_enable |= _0002_TAU_CH1_OUTPUT_ENABLE; +} + +void R_Config_TAU0_02_PWM_Start(void) +{ + g_tau_output_enable |= _0004_TAU_CH2_OUTPUT_ENABLE; +} + +void R_Config_TAU0_03_PWM_Start(void) +{ + g_tau_output_enable |= _0008_TAU_CH3_OUTPUT_ENABLE; +} + +void R_Config_TAU0_07_PWM_Start(void) +{ + g_tau_output_enable |= _0080_TAU_CH7_OUTPUT_ENABLE; +} + +void R_Config_TAU0_01_PWM_Stop(void) +{ + g_tau_output_enable &= ~_0002_TAU_CH1_OUTPUT_ENABLE; + TOE0 &= ~_0002_TAU_CH1_OUTPUT_ENABLE; + TO0 &= (uint16_t)~_0002_TAU_CH1_OUTPUT_ENABLE; +} + +void R_Config_TAU0_02_PWM_Stop(void) +{ + g_tau_output_enable &= ~_0004_TAU_CH2_OUTPUT_ENABLE; + TOE0 &= ~_0004_TAU_CH2_OUTPUT_ENABLE; + TO0 &= (uint16_t)~_0004_TAU_CH2_OUTPUT_ENABLE; +} + +void R_Config_TAU0_03_PWM_Stop(void) +{ + g_tau_output_enable &= ~_0008_TAU_CH3_OUTPUT_ENABLE; + TOE0 &= ~_0008_TAU_CH3_OUTPUT_ENABLE; + TO0 &= (uint16_t)~_0008_TAU_CH3_OUTPUT_ENABLE; +} + +void R_Config_TAU0_07_PWM_Stop(void) +{ + g_tau_output_enable &= ~_0080_TAU_CH7_OUTPUT_ENABLE; + TOE0 &= ~_0080_TAU_CH7_OUTPUT_ENABLE; + TO0 &= (uint16_t)~_0080_TAU_CH7_OUTPUT_ENABLE; +} + +void R_Config_TAU0_0_PWM_Enable_IRQ(void) +{ + TMIF00 = 0U; /* clear INTTM00 interrupt flag */ + TMMK00 = 0U; /* enable INTTM00 interrupt */ +} + +/* End user code. Do not edit comment generated here */ + diff --git a/cores/rl78g22/smc_gen/Config_TAU0_01_PWM/Config_TAU0_01_PWM.h b/cores/rl78g22/smc_gen/Config_TAU0_0_PWM/Config_TAU0_0_PWM.h similarity index 68% rename from cores/rl78g22/smc_gen/Config_TAU0_01_PWM/Config_TAU0_01_PWM.h rename to cores/rl78g22/smc_gen/Config_TAU0_0_PWM/Config_TAU0_0_PWM.h index 8b12b74..6c3ac86 100644 --- a/cores/rl78g22/smc_gen/Config_TAU0_01_PWM/Config_TAU0_01_PWM.h +++ b/cores/rl78g22/smc_gen/Config_TAU0_0_PWM/Config_TAU0_0_PWM.h @@ -1,60 +1,79 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_0.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_0. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_TAU0_01_PWM_H -#define CFG_Config_TAU0_01_PWM_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _F9FF_TAU_TDR00_VALUE (0xF9FFU) /* 16-bit timer data register 00 (TDR00) */ -#define _7D00_TAU_TDR01_VALUE (0x7D00U) /* 16-bit timer data register 01 (TDR01) */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_01_PWM_Create (void); -void R_Config_TAU0_01_PWM_Start (void); -void R_Config_TAU0_01_PWM_Stop (void); -void R_Config_TAU0_01_PWM_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif - +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021, 2023 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_TAU0_0_PWM.h +* Component Version: 1.4.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_TAU0_0_PWM. +* Creation Date : +***********************************************************************************************************************/ + +#ifndef CFG_Config_TAU0_0_H +#define CFG_Config_TAU0_0_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_tau.h" + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ +#define _7CFF_TAU_TDR00_VALUE (0x7CFFU) /* 16-bit timer data register 00 (TDR00) */ +#define _7D00_TAU_TDR01_VALUE (0x7D00U) /* 16-bit timer data register 01 (TDR01) */ +#define _7D00_TAU_TDR02_VALUE (0x7D00U) /* 16-bit timer data register 02 (TDR02) */ +#define _7D00_TAU_TDR03_VALUE (0x7D00U) /* 16-bit timer data register 03 (TDR03) */ +#define _7D00_TAU_TDR07_VALUE (0x7D00U) /* 16-bit timer data register 07 (TDR07) */ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_Config_TAU0_0_PWM_Create (void); +void R_Config_TAU0_0_PWM_Start (void); +void R_Config_TAU0_0_PWM_Stop (void); +void R_Config_TAU0_0_PWM_Create_UserInit (void); +/* Start user code for function. Do not edit comment generated here */ +void R_Config_TAU0_1_PWM_Create(void); +void R_Config_TAU0_2_PWM_Create(void); +void R_Config_TAU0_3_PWM_Create(void); +void R_Config_TAU0_7_PWM_Create(void); + +void R_Config_TAU0_01_PWM_Start(void); +void R_Config_TAU0_02_PWM_Start(void); +void R_Config_TAU0_03_PWM_Start(void); +void R_Config_TAU0_07_PWM_Start(void); + +void R_Config_TAU0_01_PWM_Stop(void); +void R_Config_TAU0_02_PWM_Stop(void); +void R_Config_TAU0_03_PWM_Stop(void); +void R_Config_TAU0_07_PWM_Stop(void); + +void R_Config_TAU0_0_PWM_Enable_IRQ(void); +/* End user code. Do not edit comment generated here */ +#endif + diff --git a/cores/rl78g22/smc_gen/Config_TAU0_4_Servo/Config_TAU0_4_Servo_user.c b/cores/rl78g22/smc_gen/Config_TAU0_0_PWM/Config_TAU0_0_PWM_user.c similarity index 77% rename from cores/rl78g22/smc_gen/Config_TAU0_4_Servo/Config_TAU0_4_Servo_user.c rename to cores/rl78g22/smc_gen/Config_TAU0_0_PWM/Config_TAU0_0_PWM_user.c index 665a89e..45f1bfd 100644 --- a/cores/rl78g22/smc_gen/Config_TAU0_4_Servo/Config_TAU0_4_Servo_user.c +++ b/cores/rl78g22/smc_gen/Config_TAU0_0_PWM/Config_TAU0_0_PWM_user.c @@ -1,74 +1,79 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_4_Servo_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_4. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_4_Servo.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_4_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel4. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_4_Servo_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_4_interrupt -* Description : This function is INTTM04 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_4_Servo_interrupt(void) -{ - /* Start user code for r_Config_TAU0_4_interrupt. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021, 2023 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_TAU0_0_PWM_user.c +* Component Version: 1.4.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_TAU0_0_PWM. +* Creation Date : +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_TAU0_0_PWM.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +extern uint8_t g_analogWrite_enable_interrupt_flag; +extern volatile uint8_t g_tau_output_enable; +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_0_Create_UserInit +* Description : This function adds user code after initializing the TAU0 channel0. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_0_PWM_Create_UserInit(void) +{ + /* Start user code for user init. Do not edit comment generated here */ + /* End user code. Do not edit comment generated here */ +} + +/* Start user code for adding. Do not edit comment generated here */ +void r_Config_TAU0_0_PWM_interrupt(void) +{ + if(g_analogWrite_enable_interrupt_flag == 1UL) + { + TOE0 |= g_tau_output_enable; + g_tau_output_enable = 0; + g_analogWrite_enable_interrupt_flag = 0; + TMMK00 = 1U; /* disable INTTM00 interrupt */ + TMIF00 = 0U; /* clear INTTM00 interrupt flag */ + } + else + { + ; + } +} +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_1_Measure_Signal/Config_TAU0_1_Measure_Signal.c b/cores/rl78g22/smc_gen/Config_TAU0_1_Measure_Signal/Config_TAU0_1_Measure_Signal.c deleted file mode 100644 index 4ce45ff..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_1_Measure_Signal/Config_TAU0_1_Measure_Signal.c +++ /dev/null @@ -1,127 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_1_Measure_Signal.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_1. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_1_Measure_Signal.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* For TAU0_ch1 pulse measurement */ -extern volatile uint32_t g_tau0_ch1_width; -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_1_Measure_Signal_Create -* Description : This function initializes the TAU0 channel1 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_1_Measure_Signal_Create(void) -{ - TPS0 &= _FFF0_TAU_CKM0_CLEAR; - TPS0 |= _0006_TAU_CKM0_FCLK_6; - /* Stop channel 1 */ - TT0 |= _0002_TAU_CH1_STOP_TRG_ON; - /* Mask channel 1 interrupt */ - TMMK01 = 1U; /* disable INTTM01 interrupt */ - TMIF01 = 0U; /* clear INTTM01 interrupt flag */ - /* Set INTTM01 low priority */ - TMPR101 = 1U; - TMPR001 = 1U; - /* TAU01 is used to measure input pulse low-/high-width */ - TIS1 &= (uint8_t)~_02_TAU_CH1_INPUT_ELC; - NFEN1 |= _02_TAU_CH1_NOISE_ON; - TMR01 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_16BITS_MODE | - _0200_TAU_TRIGGER_TIMN_BOTH | _0080_TAU_TIMN_EDGE_BOTH_LOW | _000C_TAU_MODE_HIGHLOW_MEASURE; - TOM0 &= (uint16_t)~_0002_TAU_CH1_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0002_TAU_CH1_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0002_TAU_CH1_OUTPUT_VALUE_1; - TOE0 &= (uint16_t)~_0002_TAU_CH1_OUTPUT_ENABLE; - /* Set TI01 pin */ - PMCT1 &= 0xBFU; - PM1 |= 0x40U; - - R_Config_TAU0_1_Measure_Signal_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_1_Measure_Signal_Start -* Description : This function starts the TAU0 channel1 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_1_Measure_Signal_Start(void) -{ - TMIF01 = 0U; /* clear INTTM01 interrupt flag */ - TMMK01 = 0U; /* enable INTTM01 interrupt */ - TS0 |= _0002_TAU_CH1_START_TRG_ON; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_1_Measure_Signal_Stop -* Description : This function stops the TAU0 channel1 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_1_Measure_Signal_Stop(void) -{ - TT0 |= _0002_TAU_CH1_STOP_TRG_ON; - /* Mask channel 1 interrupt */ - TMMK01 = 1U; /* disable INTTM01 interrupt */ - TMIF01 = 0U; /* clear INTTM01 interrupt flag */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_1_Measure_Signal_Get_PulseWidth -* Description : This function measures TAU0 channel 1 input pulse width. -* Arguments : width - -* the address where to write the input pulse width -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_1_Measure_Signal_Get_PulseWidth(uint32_t * const width) -{ - /* For channel 1 pulse measurement */ - *width = g_tau0_ch1_width; -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - diff --git a/cores/rl78g22/smc_gen/Config_TAU0_1_Measure_Signal/Config_TAU0_1_Measure_Signal.h b/cores/rl78g22/smc_gen/Config_TAU0_1_Measure_Signal/Config_TAU0_1_Measure_Signal.h deleted file mode 100644 index eb9365d..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_1_Measure_Signal/Config_TAU0_1_Measure_Signal.h +++ /dev/null @@ -1,58 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_1_Measure_Signal.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_1. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_TAU0_1_Measure_Signal_H -#define CFG_Config_TAU0_1_Measure_Signal_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_1_Measure_Signal_Create (void); -void R_Config_TAU0_1_Measure_Signal_Start (void); -void R_Config_TAU0_1_Measure_Signal_Stop (void); -void R_Config_TAU0_1_Measure_Signal_Get_PulseWidth (uint32_t * const width); -void R_Config_TAU0_1_Measure_Signal_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif diff --git a/cores/rl78g22/smc_gen/Config_TAU0_1_Measure_Signal/Config_TAU0_1_Measure_Signal_user.c b/cores/rl78g22/smc_gen/Config_TAU0_1_Measure_Signal/Config_TAU0_1_Measure_Signal_user.c deleted file mode 100644 index 7d02a03..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_1_Measure_Signal/Config_TAU0_1_Measure_Signal_user.c +++ /dev/null @@ -1,110 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_1__Measure_Signaluser.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_1. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_1_Measure_Signal.h" -/* Start user code for include. Do not edit comment generated here */ -#define SERVO_CH_NUM (7) -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* For TAU0_ch1 pulse measurement */ -volatile uint32_t g_tau0_ch1_width = 0UL; -/* Start user code for global. Do not edit comment generated here */ -volatile uint8_t g_tau0_ch1_interrupt_flag = 0UL; -extern volatile uint8_t g_pulse_enable_interrupt_flag; - -volatile uint8_t g_servo_enable_interrupt_flag[SERVO_CH_NUM] = {0,0,0,0,0,0,0}; - -void R_Config_TAU0_1_Servo_Stop(void); -void R_Config_TAU0_2_Servo_Stop(void); -void R_Config_TAU0_3_Servo_Stop(void); -void R_Config_TAU0_4_Servo_Stop(void); -void R_Config_TAU0_5_Servo_Stop(void); -void R_Config_TAU0_6_Servo_Stop(void); -void R_Config_TAU0_7_Servo_Stop(void); -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_1_Measure_Signal_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel1. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_1_Measure_Signal_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_1_Measure_Signal_interrupt -* Description : This function is INTTM01 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_1_Measure_Signal_interrupt(void) -{ - if(g_pulse_enable_interrupt_flag == 1UL) - { - if (1U == (TSR01 & _0001_TAU_OVERFLOW_OCCURS)) /* overflow occurs */ - { - g_tau0_ch1_width = (uint32_t)(TDR01 + 1UL) + 0x10000UL; - } - else - { - g_tau0_ch1_width = (uint32_t)(TDR01 + 1UL); - } - /* Start user code for r_Config_TAU0_1_Mesure_Signal_interrupt. Do not edit comment generated here */ - g_tau0_ch1_interrupt_flag = 1UL; - } - else - { - ; - } - if (g_servo_enable_interrupt_flag[0] == 1UL) - { - R_Config_TAU0_1_Servo_Stop(); - g_servo_enable_interrupt_flag[0]= 0UL; - } - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_1_Servo/Config_TAU0_1_Servo.c b/cores/rl78g22/smc_gen/Config_TAU0_1_Servo/Config_TAU0_1_Servo.c deleted file mode 100644 index 1fbb8db..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_1_Servo/Config_TAU0_1_Servo.c +++ /dev/null @@ -1,113 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_1_Servo.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_1. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_1_Servo.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_1_Create -* Description : This function initializes the TAU0 channel1 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_1_Servo_Create(void) -{ - TPS0 &= _FFF0_TAU_CKM0_CLEAR; - TPS0 |= _0003_TAU_CKM0_FCLK_3; - /* Stop channel 1 */ - TT0 |= _0002_TAU_CH1_STOP_TRG_ON; - /* Mask channel 1 interrupt */ - TMMK01 = 1U; /* disable INTTM01 interrupt */ - TMIF01 = 0U; /* clear INTTM01 interrupt flag */ - /* Set INTTM01 low priority */ - TMPR101 = 1U; - TMPR001 = 1U; - /* TAU01 used as square output function */ - TMR01 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_16BITS_MODE | - _0000_TAU_TRIGGER_SOFTWARE | _0000_TAU_MODE_INTERVAL_TIMER | _0000_TAU_START_INT_UNUSED; - TDR01 = _257F_TAU_TDR01_VALUE; - TOM0 &= (uint16_t)~_0002_TAU_CH1_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0002_TAU_CH1_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0002_TAU_CH1_OUTPUT_VALUE_1; - TOE0 |= _0002_TAU_CH1_OUTPUT_ENABLE; - /* Set TO01 pin */ - PMCT1 &= 0xBFU; - P1 &= 0xBFU; - PM1 &= 0xBFU; - - R_Config_TAU0_1_Servo_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_1_Start -* Description : This function starts the TAU0 channel1 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_1_Servo_Start(void) -{ - TMIF01 = 0U; /* clear INTTM01 interrupt flag */ - TMMK01 = 0U; /* enable INTTM01 interrupt */ - TOE0 |= _0002_TAU_CH1_OUTPUT_ENABLE; - TS0 |= _0002_TAU_CH1_START_TRG_ON; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_1_Stop -* Description : This function stops the TAU0 channel1 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_1_Servo_Stop(void) -{ - TT0 |= _0002_TAU_CH1_STOP_TRG_ON; - TOE0 &= (uint16_t)~_0002_TAU_CH1_OUTPUT_ENABLE; - /* Mask channel 1 interrupt */ - TMMK01 = 1U; /* disable INTTM01 interrupt */ - TMIF01 = 0U; /* clear INTTM01 interrupt flag */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_1_Servo/Config_TAU0_1_Servo.h b/cores/rl78g22/smc_gen/Config_TAU0_1_Servo/Config_TAU0_1_Servo.h deleted file mode 100644 index 4cf230f..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_1_Servo/Config_TAU0_1_Servo.h +++ /dev/null @@ -1,58 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_1_Servo.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_1. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_TAU0_1_Servo_H -#define CFG_Config_TAU0_1_Servo_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _257F_TAU_TDR01_VALUE (0x257FU) /* 16-bit timer data register 01 (TDR01) */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_1_Servo_Create (void); -void R_Config_TAU0_1_Servo_Start (void); -void R_Config_TAU0_1_Servo_Stop (void); -void R_Config_TAU0_1_Servo_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif diff --git a/cores/rl78g22/smc_gen/Config_TAU0_1_Servo/Config_TAU0_1_Servo_user.c b/cores/rl78g22/smc_gen/Config_TAU0_1_Servo/Config_TAU0_1_Servo_user.c deleted file mode 100644 index 3c3f16d..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_1_Servo/Config_TAU0_1_Servo_user.c +++ /dev/null @@ -1,74 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_1_Servo_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_1. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_1_Servo.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_1_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel1. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_1_Servo_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_1_interrupt -* Description : This function is INTTM01 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_1_Servo_interrupt(void) -{ - /* Start user code for r_Config_TAU0_1_interrupt. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_1_Square_Wave/Config_TAU0_1_Square_Wave.c b/cores/rl78g22/smc_gen/Config_TAU0_1_Square_Wave/Config_TAU0_1_Square_Wave.c index 7322089..d5aa7e0 100644 --- a/cores/rl78g22/smc_gen/Config_TAU0_1_Square_Wave/Config_TAU0_1_Square_Wave.c +++ b/cores/rl78g22/smc_gen/Config_TAU0_1_Square_Wave/Config_TAU0_1_Square_Wave.c @@ -1,113 +1,113 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_1.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_1. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_1_Square_Wave.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_1_Create -* Description : This function initializes the TAU0 channel1 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_1_Square_Wave_Create(void) -{ - TPS0 &= _FFF0_TAU_CKM0_CLEAR; - TPS0 |= _0000_TAU_CKM0_FCLK_0; - /* Stop channel 1 */ - TT0 |= _0002_TAU_CH1_STOP_TRG_ON; - /* Mask channel 1 interrupt */ - TMMK01 = 1U; /* disable INTTM01 interrupt */ - TMIF01 = 0U; /* clear INTTM01 interrupt flag */ - /* Set INTTM01 low priority */ -// TMPR101 = 1U; -// TMPR001 = 1U; - /* TAU01 used as square output function */ - TMR01 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_16BITS_MODE | - _0000_TAU_TRIGGER_SOFTWARE | _0000_TAU_MODE_INTERVAL_TIMER | _0001_TAU_START_INT_USED; - TDR01 = _F9FF_TAU_TDR01_VALUE; - TOM0 &= (uint16_t)~_0002_TAU_CH1_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0002_TAU_CH1_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0002_TAU_CH1_OUTPUT_VALUE_1; - TOE0 |= _0002_TAU_CH1_OUTPUT_ENABLE; - /* Set TO01 pin */ - PMCT1 &= 0xBFU; - P1 &= 0xBFU; - PM1 &= 0xBFU; - - R_Config_TAU0_1_Square_Wave_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_1_Start -* Description : This function starts the TAU0 channel1 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_1_Square_Wave_Start(void) -{ -// TMIF01 = 0U; /* clear INTTM01 interrupt flag */ -// TMMK01 = 0U; /* enable INTTM01 interrupt */ - TOE0 |= _0002_TAU_CH1_OUTPUT_ENABLE; - TS0 |= _0002_TAU_CH1_START_TRG_ON; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_1_Stop -* Description : This function stops the TAU0 channel1 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_1_Square_Wave_Stop(void) -{ - TT0 |= _0002_TAU_CH1_STOP_TRG_ON; - TOE0 &= (uint16_t)~_0002_TAU_CH1_OUTPUT_ENABLE; - /* Mask channel 1 interrupt */ -// TMMK01 = 1U; /* disable INTTM01 interrupt */ -// TMIF01 = 0U; /* clear INTTM01 interrupt flag */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_TAU0_1.c +* Version : 1.1.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_TAU0_1. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_TAU0_1_Square_Wave.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_1_Create +* Description : This function initializes the TAU0 channel1 module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_1_Square_Wave_Create(void) +{ + TPS0 &= _FFF0_TAU_CKM0_CLEAR; + TPS0 |= _0000_TAU_CKM0_FCLK_0; + /* Stop channel 1 */ + TT0 |= _0002_TAU_CH1_STOP_TRG_ON; + /* Mask channel 1 interrupt */ + TMMK01 = 1U; /* disable INTTM01 interrupt */ + TMIF01 = 0U; /* clear INTTM01 interrupt flag */ + /* Set INTTM01 low priority */ +// TMPR101 = 1U; +// TMPR001 = 1U; + /* TAU01 used as square output function */ + TMR01 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_16BITS_MODE | + _0000_TAU_TRIGGER_SOFTWARE | _0000_TAU_MODE_INTERVAL_TIMER | _0001_TAU_START_INT_USED; + TDR01 = _F9FF_TAU_TDR01_VALUE; + TOM0 &= (uint16_t)~_0002_TAU_CH1_SLAVE_OUTPUT; + TOL0 &= (uint16_t)~_0002_TAU_CH1_OUTPUT_LEVEL_L; + TO0 &= (uint16_t)~_0002_TAU_CH1_OUTPUT_VALUE_1; + TOE0 |= _0002_TAU_CH1_OUTPUT_ENABLE; + /* Set TO01 pin */ + PMCT1 &= 0xBFU; + P1 &= 0xBFU; + PM1 &= 0xBFU; + + R_Config_TAU0_1_Square_Wave_Create_UserInit(); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_1_Start +* Description : This function starts the TAU0 channel1 counter. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_1_Square_Wave_Start(void) +{ +// TMIF01 = 0U; /* clear INTTM01 interrupt flag */ +// TMMK01 = 0U; /* enable INTTM01 interrupt */ + TOE0 |= _0002_TAU_CH1_OUTPUT_ENABLE; + TS0 |= _0002_TAU_CH1_START_TRG_ON; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_1_Stop +* Description : This function stops the TAU0 channel1 counter. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_1_Square_Wave_Stop(void) +{ + TT0 |= _0002_TAU_CH1_STOP_TRG_ON; + TOE0 &= (uint16_t)~_0002_TAU_CH1_OUTPUT_ENABLE; + /* Mask channel 1 interrupt */ +// TMMK01 = 1U; /* disable INTTM01 interrupt */ +// TMIF01 = 0U; /* clear INTTM01 interrupt flag */ +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_1_Square_Wave/Config_TAU0_1_Square_Wave.h b/cores/rl78g22/smc_gen/Config_TAU0_1_Square_Wave/Config_TAU0_1_Square_Wave.h index 97bb93e..3dd36e8 100644 --- a/cores/rl78g22/smc_gen/Config_TAU0_1_Square_Wave/Config_TAU0_1_Square_Wave.h +++ b/cores/rl78g22/smc_gen/Config_TAU0_1_Square_Wave/Config_TAU0_1_Square_Wave.h @@ -1,58 +1,58 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_1.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_1. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_TAU0_1_Square_Wave_H -#define CFG_Config_TAU0_1_Square_Wave_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _F9FF_TAU_TDR01_VALUE (0xF9FFU) /* 16-bit timer data register 01 (TDR01) */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_1_Square_Wave_Create (void); -void R_Config_TAU0_1_Square_Wave_Start (void); -void R_Config_TAU0_1_Square_Wave_Stop (void); -void R_Config_TAU0_1_Square_Wave_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_TAU0_1.h +* Version : 1.1.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_TAU0_1. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef CFG_Config_TAU0_1_Square_Wave_H +#define CFG_Config_TAU0_1_Square_Wave_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_tau.h" + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ +#define _F9FF_TAU_TDR01_VALUE (0xF9FFU) /* 16-bit timer data register 01 (TDR01) */ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_Config_TAU0_1_Square_Wave_Create (void); +void R_Config_TAU0_1_Square_Wave_Start (void); +void R_Config_TAU0_1_Square_Wave_Stop (void); +void R_Config_TAU0_1_Square_Wave_Create_UserInit (void); +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/Config_TAU0_1_Square_Wave/Config_TAU0_1_Square_Wave_user.c b/cores/rl78g22/smc_gen/Config_TAU0_1_Square_Wave/Config_TAU0_1_Square_Wave_user.c index 4908e8a..bf57b7a 100644 --- a/cores/rl78g22/smc_gen/Config_TAU0_1_Square_Wave/Config_TAU0_1_Square_Wave_user.c +++ b/cores/rl78g22/smc_gen/Config_TAU0_1_Square_Wave/Config_TAU0_1_Square_Wave_user.c @@ -1,74 +1,74 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_1_Square_Wave_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_1. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_1_Square_Wave.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_1_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel1. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_1_Square_Wave_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_1_interrupt -* Description : This function is INTTM01 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_1_Square_Wave_interrupt(void) -{ - /* Start user code for r_Config_TAU0_1_interrupt. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_TAU0_1_Square_Wave_user.c +* Version : 1.1.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_TAU0_1. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_TAU0_1_Square_Wave.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_1_Create_UserInit +* Description : This function adds user code after initializing the TAU0 channel1. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_1_Square_Wave_Create_UserInit(void) +{ + /* Start user code for user init. Do not edit comment generated here */ + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_TAU0_1_interrupt +* Description : This function is INTTM01 interrupt service routine. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_TAU0_1_Square_Wave_interrupt(void) +{ + /* Start user code for r_Config_TAU0_1_interrupt. Do not edit comment generated here */ + /* End user code. Do not edit comment generated here */ +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_23_PWM/Config_TAU0_23_PWM.c b/cores/rl78g22/smc_gen/Config_TAU0_23_PWM/Config_TAU0_23_PWM.c deleted file mode 100644 index b15bed4..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_23_PWM/Config_TAU0_23_PWM.c +++ /dev/null @@ -1,128 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_23_PWM.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_2. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_23_PWM.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_2_Create -* Description : This function initializes the TAU0 channel2 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_23_PWM_Create(void) -{ - TPS0 &= _FFF0_TAU_CKM0_CLEAR; - TPS0 |= _0000_TAU_CKM0_FCLK_0; - TT0 |= (_0008_TAU_CH3_STOP_TRG_ON | _0004_TAU_CH2_STOP_TRG_ON); - TMMK02 = 1U; /* disable INTTM02 interrupt */ - TMIF02 = 0U; /* clear INTTM02 interrupt flag */ - TMMK03 = 1U; /* disable INTTM03 interrupt */ - TMIF03 = 0U; /* clear INTTM03 interrupt flag */ - /* Set INTTM02 low priority */ -// TMPR102 = 1U; -// TMPR002 = 1U; - /* Set INTTM03 low priority */ -// TMPR103 = 1U; -// TMPR003 = 1U; - /* Channel 2 is used as master channel for PWM output function */ - TMR02 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0800_TAU_COMBINATION_MASTER | - _0000_TAU_TRIGGER_SOFTWARE | _0001_TAU_MODE_PWM_MASTER; - TDR02 = _F9FF_TAU_TDR02_VALUE; - TOM0 &= (uint16_t)~_0004_TAU_CH2_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0004_TAU_CH2_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0004_TAU_CH2_OUTPUT_VALUE_1; - TOE0 &= (uint16_t)~_0004_TAU_CH2_OUTPUT_ENABLE; - /* Channel 3 is used as slave channel for PWM output function */ - TMR03 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_COMBINATION_SLAVE | - _0400_TAU_TRIGGER_MASTER_INT | _0009_TAU_MODE_PWM_SLAVE; - TDR03 = _7D00_TAU_TDR03_VALUE; - TOM0 |= _0008_TAU_CH3_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0008_TAU_CH3_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0008_TAU_CH3_OUTPUT_VALUE_1; - TOE0 |= _0008_TAU_CH3_OUTPUT_ENABLE; - /* Set TO03 pin */ - PMCT3 &= 0xFDU; - P3 &= 0xFDU; - PM3 &= 0xFDU; - - R_Config_TAU0_23_PWM_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_2_Start -* Description : This function starts the TAU0 channel2 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_23_PWM_Start(void) -{ -// TMIF02 = 0U; /* clear INTTM02 interrupt flag */ -// TMMK02 = 0U; /* enable INTTM02 interrupt */ -// TMIF03 = 0U; /* clear INTTM03 interrupt flag */ -// TMMK03 = 0U; /* enable INTTM03 interrupt */ - TOE0 |= _0008_TAU_CH3_OUTPUT_ENABLE; - TS0 |= (_0008_TAU_CH3_START_TRG_ON | _0004_TAU_CH2_START_TRG_ON); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_2_Stop -* Description : This function stops the TAU0 channel2 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_23_PWM_Stop(void) -{ - TT0 |= (_0008_TAU_CH3_STOP_TRG_ON | _0004_TAU_CH2_STOP_TRG_ON); - TOE0 &= (uint16_t)~_0008_TAU_CH3_OUTPUT_ENABLE; -// TMMK02 = 1U; /* disable INTTM02 interrupt */ -// TMIF02 = 0U; /* clear INTTM02 interrupt flag */ -// TMMK03 = 1U; /* disable INTTM03 interrupt */ -// TMIF03 = 0U; /* clear INTTM03 interrupt flag */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - diff --git a/cores/rl78g22/smc_gen/Config_TAU0_23_PWM/Config_TAU0_23_PWM.h b/cores/rl78g22/smc_gen/Config_TAU0_23_PWM/Config_TAU0_23_PWM.h deleted file mode 100644 index 96ad389..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_23_PWM/Config_TAU0_23_PWM.h +++ /dev/null @@ -1,60 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_2.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_2. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_TAU0_23_PWM_H -#define CFG_Config_TAU0_23_PWM_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _F9FF_TAU_TDR02_VALUE (0xF9FFU) /* 16-bit timer data register 02 (TDR02) */ -#define _7D00_TAU_TDR03_VALUE (0x7D00U) /* 16-bit timer data register 03 (TDR03) */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_23_PWM_Create (void); -void R_Config_TAU0_23_PWM_Start (void); -void R_Config_TAU0_23_PWM_Stop (void); -void R_Config_TAU0_23_PWM_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif - diff --git a/cores/rl78g22/smc_gen/Config_TAU0_23_PWM/Config_TAU0_23_PWM_user.c b/cores/rl78g22/smc_gen/Config_TAU0_23_PWM/Config_TAU0_23_PWM_user.c deleted file mode 100644 index 1581402..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_23_PWM/Config_TAU0_23_PWM_user.c +++ /dev/null @@ -1,86 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_23_PWM_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_2. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_23_PWM.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_2_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel2. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_23_PWM_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_2_channel2_interrupt -* Description : This function is INTTM02 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_23_PWM_channel2_interrupt(void) -{ - /* Start user code for r_Config_TAU0_2_channel2_interrupt. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_2_channel3_interrupt -* Description : This function is INTTM03 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_23_PWM_channel3_interrupt(void) -{ - /* Start user code for r_Config_TAU0_2_channel3_interrupt. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_2_Measure_Signal/Config_TAU0_2_Measure_Signal.c b/cores/rl78g22/smc_gen/Config_TAU0_2_Measure_Signal/Config_TAU0_2_Measure_Signal.c deleted file mode 100644 index 060437c..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_2_Measure_Signal/Config_TAU0_2_Measure_Signal.c +++ /dev/null @@ -1,126 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_2_Measure_Signal.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_2. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_2_Measure_Signal.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* For TAU0_ch2 pulse measurement */ -extern volatile uint32_t g_tau0_ch2_width; -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_2_Measure_Signal_Create -* Description : This function initializes the TAU0 channel2 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_2_Measure_Signal_Create(void) -{ - TPS0 &= _FFF0_TAU_CKM0_CLEAR; - TPS0 |= _0006_TAU_CKM0_FCLK_6; - /* Stop channel 2 */ - TT0 |= _0004_TAU_CH2_STOP_TRG_ON; - /* Mask channel 2 interrupt */ - TMMK02 = 1U; /* disable INTTM02 interrupt */ - TMIF02 = 0U; /* clear INTTM02 interrupt flag */ - /* Set INTTM02 low priority */ - TMPR102 = 1U; - TMPR002 = 1U; - /* TAU02 is used to measure input pulse low-/high-width */ - NFEN1 &= (uint8_t)~_04_TAU_CH2_NOISE_ON; - TMR02 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_COMBINATION_SLAVE | - _0200_TAU_TRIGGER_TIMN_BOTH | _0080_TAU_TIMN_EDGE_BOTH_LOW | _000C_TAU_MODE_HIGHLOW_MEASURE; - TOM0 &= (uint16_t)~_0004_TAU_CH2_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0004_TAU_CH2_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0004_TAU_CH2_OUTPUT_VALUE_1; - TOE0 &= (uint16_t)~_0004_TAU_CH2_OUTPUT_ENABLE; - /* Set TI02 pin */ - PMCT1 &= 0x7FU; - PM1 |= 0x80U; - - R_Config_TAU0_2_Measure_Signal_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_2_Measure_Signal_Start -* Description : This function starts the TAU0 channel2 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_2_Measure_Signal_Start(void) -{ - TMIF02 = 0U; /* clear INTTM02 interrupt flag */ - TMMK02 = 0U; /* enable INTTM02 interrupt */ - TS0 |= _0004_TAU_CH2_START_TRG_ON; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_2_Measure_Signal_Stop -* Description : This function stops the TAU0 channel2 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_2_Measure_Signal_Stop(void) -{ - TT0 |= _0004_TAU_CH2_STOP_TRG_ON; - /* Mask channel 2 interrupt */ - TMMK02 = 1U; /* disable INTTM02 interrupt */ - TMIF02 = 0U; /* clear INTTM02 interrupt flag */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_2_Measure_Signal_Get_PulseWidth -* Description : This function measures TAU0 channel 2 input pulse width. -* Arguments : width - -* the address where to write the input pulse width -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_2_Measure_Signal_Get_PulseWidth(uint32_t * const width) -{ - /* For channel 2 pulse measurement */ - *width = g_tau0_ch2_width; -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - diff --git a/cores/rl78g22/smc_gen/Config_TAU0_2_Measure_Signal/Config_TAU0_2_Measure_Signal.h b/cores/rl78g22/smc_gen/Config_TAU0_2_Measure_Signal/Config_TAU0_2_Measure_Signal.h deleted file mode 100644 index 9b05572..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_2_Measure_Signal/Config_TAU0_2_Measure_Signal.h +++ /dev/null @@ -1,58 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_2_Measure_Signal.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_2. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_TAU0_2_Measure_Signal_H -#define CFG_Config_TAU0_2_Measure_Signal_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_2_Measure_Signal_Create (void); -void R_Config_TAU0_2_Measure_Signal_Start (void); -void R_Config_TAU0_2_Measure_Signal_Stop (void); -void R_Config_TAU0_2_Measure_Signal_Get_PulseWidth (uint32_t * const width); -void R_Config_TAU0_2_Measure_Signal_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif diff --git a/cores/rl78g22/smc_gen/Config_TAU0_2_Measure_Signal/Config_TAU0_2_Measure_Signal_user.c b/cores/rl78g22/smc_gen/Config_TAU0_2_Measure_Signal/Config_TAU0_2_Measure_Signal_user.c deleted file mode 100644 index ad7fcf0..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_2_Measure_Signal/Config_TAU0_2_Measure_Signal_user.c +++ /dev/null @@ -1,107 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_2_Measure_Signal_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_2. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_2_Measure_Signal.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* For TAU0_ch2 pulse measurement */ -volatile uint32_t g_tau0_ch2_width = 0UL; -/* Start user code for global. Do not edit comment generated here */ -volatile uint8_t g_tau0_ch2_interrupt_flag = 0UL; -extern volatile uint8_t g_pulse_enable_interrupt_flag; - -extern volatile uint8_t g_servo_enable_interrupt_flag[7]; -void R_Config_TAU0_1_Servo_Stop(void); -void R_Config_TAU0_2_Servo_Stop(void); -void R_Config_TAU0_3_Servo_Stop(void); -void R_Config_TAU0_4_Servo_Stop(void); -void R_Config_TAU0_5_Servo_Stop(void); -void R_Config_TAU0_6_Servo_Stop(void); -void R_Config_TAU0_7_Servo_Stop(void); -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_2_Measure_Signal_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel2. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_2_Measure_Signal_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_2_Measure_Signal_interrupt -* Description : This function is INTTM02 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_2_Measure_Signal_interrupt(void) -{ - if(g_pulse_enable_interrupt_flag == 1UL) - { - if (1U == (TSR02 & _0001_TAU_OVERFLOW_OCCURS)) /* overflow occurs */ - { - g_tau0_ch2_width = (uint32_t)(TDR02 + 1UL) + 0x10000UL; - } - else - { - g_tau0_ch2_width = (uint32_t)(TDR02 + 1UL); - } - /* Start user code for r_Config_TAU0_2_Mesure_Signal_interrupt. Do not edit comment generated here */ - g_tau0_ch2_interrupt_flag = 1UL; - } - else - { - ; - } - if (g_servo_enable_interrupt_flag[1] == 1UL) - { - R_Config_TAU0_2_Servo_Stop(); - g_servo_enable_interrupt_flag[1]= 0UL; - } /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_2_Servo/Config_TAU0_2_Servo.c b/cores/rl78g22/smc_gen/Config_TAU0_2_Servo/Config_TAU0_2_Servo.c deleted file mode 100644 index facd900..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_2_Servo/Config_TAU0_2_Servo.c +++ /dev/null @@ -1,114 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_2_Servo.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_2. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_2_Servo.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_2_Create -* Description : This function initializes the TAU0 channel2 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_2_Servo_Create(void) -{ - TPS0 &= _FFF0_TAU_CKM0_CLEAR; - TPS0 |= _0003_TAU_CKM0_FCLK_3; - /* Stop channel 2 */ - TT0 |= _0004_TAU_CH2_STOP_TRG_ON; - /* Mask channel 2 interrupt */ - TMMK02 = 1U; /* disable INTTM02 interrupt */ - TMIF02 = 0U; /* clear INTTM02 interrupt flag */ - /* Set INTTM02 low priority */ - TMPR102 = 1U; - TMPR002 = 1U; - /* TAU02 used as square output function */ - TMR02 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_COMBINATION_SLAVE | - _0000_TAU_TRIGGER_SOFTWARE | _0000_TAU_MODE_INTERVAL_TIMER | _0000_TAU_START_INT_UNUSED; - TDR02 = _257F_TAU_TDR02_VALUE; - TOM0 &= (uint16_t)~_0004_TAU_CH2_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0004_TAU_CH2_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0004_TAU_CH2_OUTPUT_VALUE_1; - TOE0 |= _0004_TAU_CH2_OUTPUT_ENABLE; - /* Set TO02 pin */ - POM1 &= 0xDFU; - PMCT1 &= 0xDFU; - P1 &= 0xDFU; - PM1 &= 0xDFU; - - R_Config_TAU0_2_Servo_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_2_Start -* Description : This function starts the TAU0 channel2 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_2_Servo_Start(void) -{ - TMIF02 = 0U; /* clear INTTM02 interrupt flag */ - TMMK02 = 0U; /* enable INTTM02 interrupt */ - TOE0 |= _0004_TAU_CH2_OUTPUT_ENABLE; - TS0 |= _0004_TAU_CH2_START_TRG_ON; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_2_Stop -* Description : This function stops the TAU0 channel2 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_2_Servo_Stop(void) -{ - TT0 |= _0004_TAU_CH2_STOP_TRG_ON; - TOE0 &= (uint16_t)~_0004_TAU_CH2_OUTPUT_ENABLE; - /* Mask channel 2 interrupt */ - TMMK02 = 1U; /* disable INTTM02 interrupt */ - TMIF02 = 0U; /* clear INTTM02 interrupt flag */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_2_Servo/Config_TAU0_2_Servo.h b/cores/rl78g22/smc_gen/Config_TAU0_2_Servo/Config_TAU0_2_Servo.h deleted file mode 100644 index fdf1996..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_2_Servo/Config_TAU0_2_Servo.h +++ /dev/null @@ -1,58 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_2.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_2. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_TAU0_2_H -#define CFG_Config_TAU0_2_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _257F_TAU_TDR02_VALUE (0x257FU) /* 16-bit timer data register 02 (TDR02) */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_2_Create (void); -void R_Config_TAU0_2_Start (void); -void R_Config_TAU0_2_Stop (void); -void R_Config_TAU0_2_Servo_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif diff --git a/cores/rl78g22/smc_gen/Config_TAU0_2_Servo/Config_TAU0_2_Servo_user.c b/cores/rl78g22/smc_gen/Config_TAU0_2_Servo/Config_TAU0_2_Servo_user.c deleted file mode 100644 index d1e0b58..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_2_Servo/Config_TAU0_2_Servo_user.c +++ /dev/null @@ -1,74 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_2_Servo_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_2. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_2_Servo.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_2_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel2. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_2_Servo_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_2_interrupt -* Description : This function is INTTM02 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_2_Servo_interrupt(void) -{ - /* Start user code for r_Config_TAU0_2_interrupt. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_2_Square_Wave/Config_TAU0_2_Square_Wave.c b/cores/rl78g22/smc_gen/Config_TAU0_2_Square_Wave/Config_TAU0_2_Square_Wave.c index 132b937..b66c11d 100644 --- a/cores/rl78g22/smc_gen/Config_TAU0_2_Square_Wave/Config_TAU0_2_Square_Wave.c +++ b/cores/rl78g22/smc_gen/Config_TAU0_2_Square_Wave/Config_TAU0_2_Square_Wave.c @@ -1,114 +1,114 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_2_Square_Wave.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_2. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_2_Square_Wave.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_2_Create -* Description : This function initializes the TAU0 channel2 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_2_Square_Wave_Create(void) -{ - TPS0 &= _FFF0_TAU_CKM0_CLEAR; - TPS0 |= _0000_TAU_CKM0_FCLK_0; - /* Stop channel 2 */ - TT0 |= _0004_TAU_CH2_STOP_TRG_ON; - /* Mask channel 2 interrupt */ - TMMK02 = 1U; /* disable INTTM02 interrupt */ - TMIF02 = 0U; /* clear INTTM02 interrupt flag */ - /* Set INTTM02 low priority */ -// TMPR102 = 1U; -// TMPR002 = 1U; - /* TAU02 used as square output function */ - TMR02 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_COMBINATION_SLAVE | - _0000_TAU_TRIGGER_SOFTWARE | _0000_TAU_MODE_INTERVAL_TIMER | _0001_TAU_START_INT_USED; - TDR02 = _F9FF_TAU_TDR02_VALUE; - TOM0 &= (uint16_t)~_0004_TAU_CH2_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0004_TAU_CH2_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0004_TAU_CH2_OUTPUT_VALUE_1; - TOE0 |= _0004_TAU_CH2_OUTPUT_ENABLE; - /* Set TO02 pin */ - POM1 &= 0x7FU; - PMCT1 &= 0x7FU; - P1 &= 0x7FU; - PM1 &= 0x7FU; - - R_Config_TAU0_2_Square_Wave_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_2_Start -* Description : This function starts the TAU0 channel2 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_2_Square_Wave_Start(void) -{ -// TMIF02 = 0U; /* clear INTTM02 interrupt flag */ -// TMMK02 = 0U; /* enable INTTM02 interrupt */ - TOE0 |= _0004_TAU_CH2_OUTPUT_ENABLE; - TS0 |= _0004_TAU_CH2_START_TRG_ON; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_2_Stop -* Description : This function stops the TAU0 channel2 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_2_Square_Wave_Stop(void) -{ - TT0 |= _0004_TAU_CH2_STOP_TRG_ON; - TOE0 &= (uint16_t)~_0004_TAU_CH2_OUTPUT_ENABLE; - /* Mask channel 2 interrupt */ -// TMMK02 = 1U; /* disable INTTM02 interrupt */ -// TMIF02 = 0U; /* clear INTTM02 interrupt flag */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_TAU0_2_Square_Wave.c +* Version : 1.1.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_TAU0_2. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_TAU0_2_Square_Wave.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_2_Create +* Description : This function initializes the TAU0 channel2 module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_2_Square_Wave_Create(void) +{ + TPS0 &= _FFF0_TAU_CKM0_CLEAR; + TPS0 |= _0000_TAU_CKM0_FCLK_0; + /* Stop channel 2 */ + TT0 |= _0004_TAU_CH2_STOP_TRG_ON; + /* Mask channel 2 interrupt */ + TMMK02 = 1U; /* disable INTTM02 interrupt */ + TMIF02 = 0U; /* clear INTTM02 interrupt flag */ + /* Set INTTM02 low priority */ +// TMPR102 = 1U; +// TMPR002 = 1U; + /* TAU02 used as square output function */ + TMR02 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_COMBINATION_SLAVE | + _0000_TAU_TRIGGER_SOFTWARE | _0000_TAU_MODE_INTERVAL_TIMER | _0001_TAU_START_INT_USED; + TDR02 = _F9FF_TAU_TDR02_VALUE; + TOM0 &= (uint16_t)~_0004_TAU_CH2_SLAVE_OUTPUT; + TOL0 &= (uint16_t)~_0004_TAU_CH2_OUTPUT_LEVEL_L; + TO0 &= (uint16_t)~_0004_TAU_CH2_OUTPUT_VALUE_1; + TOE0 |= _0004_TAU_CH2_OUTPUT_ENABLE; + /* Set TO02 pin */ + POM1 &= 0x7FU; + PMCT1 &= 0x7FU; + P1 &= 0x7FU; + PM1 &= 0x7FU; + + R_Config_TAU0_2_Square_Wave_Create_UserInit(); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_2_Start +* Description : This function starts the TAU0 channel2 counter. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_2_Square_Wave_Start(void) +{ +// TMIF02 = 0U; /* clear INTTM02 interrupt flag */ +// TMMK02 = 0U; /* enable INTTM02 interrupt */ + TOE0 |= _0004_TAU_CH2_OUTPUT_ENABLE; + TS0 |= _0004_TAU_CH2_START_TRG_ON; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_2_Stop +* Description : This function stops the TAU0 channel2 counter. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_2_Square_Wave_Stop(void) +{ + TT0 |= _0004_TAU_CH2_STOP_TRG_ON; + TOE0 &= (uint16_t)~_0004_TAU_CH2_OUTPUT_ENABLE; + /* Mask channel 2 interrupt */ +// TMMK02 = 1U; /* disable INTTM02 interrupt */ +// TMIF02 = 0U; /* clear INTTM02 interrupt flag */ +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_2_Square_Wave/Config_TAU0_2_Square_Wave.h b/cores/rl78g22/smc_gen/Config_TAU0_2_Square_Wave/Config_TAU0_2_Square_Wave.h index 90f0d6e..adb887f 100644 --- a/cores/rl78g22/smc_gen/Config_TAU0_2_Square_Wave/Config_TAU0_2_Square_Wave.h +++ b/cores/rl78g22/smc_gen/Config_TAU0_2_Square_Wave/Config_TAU0_2_Square_Wave.h @@ -1,58 +1,58 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_2.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_2. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_TAU0_2_Square_Wave_H -#define CFG_Config_TAU0_2_Square_Wave_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _F9FF_TAU_TDR02_VALUE (0xF9FFU) /* 16-bit timer data register 02 (TDR02) */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_2_Square_Wave_Create (void); -void R_Config_TAU0_2_Square_Wave_Start (void); -void R_Config_TAU0_2_Square_Wave_Stop (void); -void R_Config_TAU0_2_Square_Wave_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_TAU0_2.h +* Version : 1.1.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_TAU0_2. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef CFG_Config_TAU0_2_Square_Wave_H +#define CFG_Config_TAU0_2_Square_Wave_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_tau.h" + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ +#define _F9FF_TAU_TDR02_VALUE (0xF9FFU) /* 16-bit timer data register 02 (TDR02) */ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_Config_TAU0_2_Square_Wave_Create (void); +void R_Config_TAU0_2_Square_Wave_Start (void); +void R_Config_TAU0_2_Square_Wave_Stop (void); +void R_Config_TAU0_2_Square_Wave_Create_UserInit (void); +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/Config_TAU0_2_Square_Wave/Config_TAU0_2_Square_Wave_user.c b/cores/rl78g22/smc_gen/Config_TAU0_2_Square_Wave/Config_TAU0_2_Square_Wave_user.c index 23c6b4e..5d9f2e2 100644 --- a/cores/rl78g22/smc_gen/Config_TAU0_2_Square_Wave/Config_TAU0_2_Square_Wave_user.c +++ b/cores/rl78g22/smc_gen/Config_TAU0_2_Square_Wave/Config_TAU0_2_Square_Wave_user.c @@ -1,74 +1,74 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_2_Square_Wave_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_2. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_2_Square_Wave.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_2_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel2. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_2_Square_Wave_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_2_interrupt -* Description : This function is INTTM02 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_2_Square_Wave_interrupt(void) -{ - /* Start user code for r_Config_TAU0_2_interrupt. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_TAU0_2_Square_Wave_user.c +* Version : 1.1.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_TAU0_2. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_TAU0_2_Square_Wave.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_2_Create_UserInit +* Description : This function adds user code after initializing the TAU0 channel2. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_2_Square_Wave_Create_UserInit(void) +{ + /* Start user code for user init. Do not edit comment generated here */ + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_TAU0_2_interrupt +* Description : This function is INTTM02 interrupt service routine. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_TAU0_2_Square_Wave_interrupt(void) +{ + /* Start user code for r_Config_TAU0_2_interrupt. Do not edit comment generated here */ + /* End user code. Do not edit comment generated here */ +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_3_Measure_Signal/Config_TAU0_3_Measure_Signal.c b/cores/rl78g22/smc_gen/Config_TAU0_3_Measure_Signal/Config_TAU0_3_Measure_Signal.c deleted file mode 100644 index 9f2044c..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_3_Measure_Signal/Config_TAU0_3_Measure_Signal.c +++ /dev/null @@ -1,126 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_3_Measure_Signal.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_3. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_3_Measure_Signal.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* For TAU0_ch3 pulse measurement */ -extern volatile uint32_t g_tau0_ch3_width; -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_3_Measure_Signal_Create -* Description : This function initializes the TAU0 channel3 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_3_Measure_Signal_Create(void) -{ - TPS0 &= _FFF0_TAU_CKM0_CLEAR; - TPS0 |= _0006_TAU_CKM0_FCLK_6; - /* Stop channel 3 */ - TT0 |= _0008_TAU_CH3_STOP_TRG_ON; - /* Mask channel 3 interrupt */ - TMMK03 = 1U; /* disable INTTM03 interrupt */ - TMIF03 = 0U; /* clear INTTM03 interrupt flag */ - /* Set INTTM03 low priority */ - TMPR103 = 1U; - TMPR003 = 1U; - /* TAU03 is used to measure input pulse low-/high-width */ - NFEN1 &= (uint8_t)~_08_TAU_CH3_NOISE_ON; - TMR03 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_16BITS_MODE | - _0200_TAU_TRIGGER_TIMN_BOTH | _0080_TAU_TIMN_EDGE_BOTH_LOW | _000C_TAU_MODE_HIGHLOW_MEASURE; - TOM0 &= (uint16_t)~_0008_TAU_CH3_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0008_TAU_CH3_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0008_TAU_CH3_OUTPUT_VALUE_1; - TOE0 &= (uint16_t)~_0008_TAU_CH3_OUTPUT_ENABLE; - /* Set TI03 pin */ - PMCT3 &= 0xFDU; - PM3 |= 0x02U; - - R_Config_TAU0_3_Measure_Signal_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_3_Measure_Signal_Start -* Description : This function starts the TAU0 channel3 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_3_Measure_Signal_Start(void) -{ - TMIF03 = 0U; /* clear INTTM03 interrupt flag */ - TMMK03 = 0U; /* enable INTTM03 interrupt */ - TS0 |= _0008_TAU_CH3_START_TRG_ON; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_3_Measure_Signal_Stop -* Description : This function stops the TAU0 channel3 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_3_Measure_Signal_Stop(void) -{ - TT0 |= _0008_TAU_CH3_STOP_TRG_ON; - /* Mask channel 3 interrupt */ - TMMK03 = 1U; /* disable INTTM03 interrupt */ - TMIF03 = 0U; /* clear INTTM03 interrupt flag */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_3_Measure_Signal_Get_PulseWidth -* Description : This function measures TAU0 channel 3 input pulse width. -* Arguments : width - -* the address where to write the input pulse width -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_3_Measure_Signal_Get_PulseWidth(uint32_t * const width) -{ - /* For channel 3 pulse measurement */ - *width = g_tau0_ch3_width; -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - diff --git a/cores/rl78g22/smc_gen/Config_TAU0_3_Measure_Signal/Config_TAU0_3_Measure_Signal.h b/cores/rl78g22/smc_gen/Config_TAU0_3_Measure_Signal/Config_TAU0_3_Measure_Signal.h deleted file mode 100644 index 25a56f1..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_3_Measure_Signal/Config_TAU0_3_Measure_Signal.h +++ /dev/null @@ -1,58 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_3_Measure_Signal.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_3. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_TAU0_3_Measure_Signal_H -#define CFG_Config_TAU0_3_Measure_Signal_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_3_Measure_Signal_Create (void); -void R_Config_TAU0_3_Measure_Signal_Start (void); -void R_Config_TAU0_3_Measure_Signal_Stop (void); -void R_Config_TAU0_3_Measure_Signal_Get_PulseWidth (uint32_t * const width); -void R_Config_TAU0_3_Measure_Signal_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif diff --git a/cores/rl78g22/smc_gen/Config_TAU0_3_Measure_Signal/Config_TAU0_3_Measure_Signal_user.c b/cores/rl78g22/smc_gen/Config_TAU0_3_Measure_Signal/Config_TAU0_3_Measure_Signal_user.c deleted file mode 100644 index 1189b94..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_3_Measure_Signal/Config_TAU0_3_Measure_Signal_user.c +++ /dev/null @@ -1,107 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_3_Measure_Signal_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_3. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_3_Measure_Signal.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* For TAU0_ch3 pulse measurement */ -volatile uint32_t g_tau0_ch3_width = 0UL; -/* Start user code for global. Do not edit comment generated here */ -volatile uint8_t g_tau0_ch3_interrupt_flag = 0UL; -extern volatile uint8_t g_pulse_enable_interrupt_flag; - -extern volatile uint8_t g_servo_enable_interrupt_flag[7]; -void R_Config_TAU0_1_Servo_Stop(void); -void R_Config_TAU0_2_Servo_Stop(void); -void R_Config_TAU0_3_Servo_Stop(void); -void R_Config_TAU0_4_Servo_Stop(void); -void R_Config_TAU0_5_Servo_Stop(void); -void R_Config_TAU0_6_Servo_Stop(void); -void R_Config_TAU0_7_Servo_Stop(void); -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_3_Measure_Signal_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel3. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_3_Measure_Signal_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_3_Measure_Signal_interrupt -* Description : This function is INTTM03 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_3_Measure_Signal_interrupt(void) -{ - if(g_pulse_enable_interrupt_flag == 1UL) - { - if (1U == (TSR03 & _0001_TAU_OVERFLOW_OCCURS)) /* overflow occurs */ - { - g_tau0_ch3_width = (uint32_t)(TDR03 + 1UL) + 0x10000UL; - } - else - { - g_tau0_ch3_width = (uint32_t)(TDR03 + 1UL); - } - /* Start user code for r_Config_TAU0_3_Mesure_Signal_interrupt. Do not edit comment generated here */ - g_tau0_ch3_interrupt_flag = 1UL; - } - else - { - ; - } - if (g_servo_enable_interrupt_flag[2] == 1UL) - { - R_Config_TAU0_3_Servo_Stop(); - g_servo_enable_interrupt_flag[2]= 0UL; - } /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_3_Servo/Config_TAU0_3_Servo.c b/cores/rl78g22/smc_gen/Config_TAU0_3_Servo/Config_TAU0_3_Servo.c deleted file mode 100644 index fd98038..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_3_Servo/Config_TAU0_3_Servo.c +++ /dev/null @@ -1,114 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_3_Servo.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_3. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_3_Servo.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_3_Create -* Description : This function initializes the TAU0 channel3 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_3_Servo_Create(void) -{ - TPS0 &= _FFF0_TAU_CKM0_CLEAR; - TPS0 |= _0003_TAU_CKM0_FCLK_3; - /* Stop channel 3 */ - TT0 |= _0008_TAU_CH3_STOP_TRG_ON; - /* Mask channel 3 interrupt */ - TMMK03 = 1U; /* disable INTTM03 interrupt */ - TMIF03 = 0U; /* clear INTTM03 interrupt flag */ - /* Set INTTM03 low priority */ - TMPR103 = 1U; - TMPR003 = 1U; - /* TAU03 used as square output function */ - TMR03 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_16BITS_MODE | - _0000_TAU_TRIGGER_SOFTWARE | _0000_TAU_MODE_INTERVAL_TIMER | _0000_TAU_START_INT_UNUSED; - TDR03 = _257F_TAU_TDR03_VALUE; - TOM0 &= (uint16_t)~_0008_TAU_CH3_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0008_TAU_CH3_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0008_TAU_CH3_OUTPUT_VALUE_1; - TOE0 |= _0008_TAU_CH3_OUTPUT_ENABLE; - /* Set TO03 pin */ - POM1 &= 0xEFU; - PMCT1 &= 0xEFU; - P1 &= 0xEFU; - PM1 &= 0xEFU; - - R_Config_TAU0_3_Servo_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_3_Start -* Description : This function starts the TAU0 channel3 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_3_Servo_Start(void) -{ - TMIF03 = 0U; /* clear INTTM03 interrupt flag */ - TMMK03 = 0U; /* enable INTTM03 interrupt */ - TOE0 |= _0008_TAU_CH3_OUTPUT_ENABLE; - TS0 |= _0008_TAU_CH3_START_TRG_ON; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_3_Stop -* Description : This function stops the TAU0 channel3 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_3_Servo_Stop(void) -{ - TT0 |= _0008_TAU_CH3_STOP_TRG_ON; - TOE0 &= (uint16_t)~_0008_TAU_CH3_OUTPUT_ENABLE; - /* Mask channel 3 interrupt */ - TMMK03 = 1U; /* disable INTTM03 interrupt */ - TMIF03 = 0U; /* clear INTTM03 interrupt flag */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_3_Servo/Config_TAU0_3_Servo.h b/cores/rl78g22/smc_gen/Config_TAU0_3_Servo/Config_TAU0_3_Servo.h deleted file mode 100644 index 04b34fe..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_3_Servo/Config_TAU0_3_Servo.h +++ /dev/null @@ -1,58 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_3_Servo.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_3. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_TAU0_3_Servo_H -#define CFG_Config_TAU0_3_Servo_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _257F_TAU_TDR03_VALUE (0x257FU) /* 16-bit timer data register 03 (TDR03) */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_3_Servo_Create (void); -void R_Config_TAU0_3_Servo_Start (void); -void R_Config_TAU0_3_Servo_Stop (void); -void R_Config_TAU0_3_Servo_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif diff --git a/cores/rl78g22/smc_gen/Config_TAU0_3_Servo/Config_TAU0_3_Servo_user.c b/cores/rl78g22/smc_gen/Config_TAU0_3_Servo/Config_TAU0_3_Servo_user.c deleted file mode 100644 index 0c4d56a..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_3_Servo/Config_TAU0_3_Servo_user.c +++ /dev/null @@ -1,74 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_3_Servo_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_3. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_3_Servo.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_3_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel3. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_3_Servo_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_3_interrupt -* Description : This function is INTTM03 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_3_Servo_interrupt(void) -{ - /* Start user code for r_Config_TAU0_3_interrupt. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_3_Square_Wave/Config_TAU0_3_Square_Wave.c b/cores/rl78g22/smc_gen/Config_TAU0_3_Square_Wave/Config_TAU0_3_Square_Wave.c index 59f6004..6b80b1a 100644 --- a/cores/rl78g22/smc_gen/Config_TAU0_3_Square_Wave/Config_TAU0_3_Square_Wave.c +++ b/cores/rl78g22/smc_gen/Config_TAU0_3_Square_Wave/Config_TAU0_3_Square_Wave.c @@ -1,113 +1,113 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_3_Square_Wave.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_3. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_3_Square_Wave.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_3_Create -* Description : This function initializes the TAU0 channel3 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_3_Square_Wave_Create(void) -{ - TPS0 &= _FFF0_TAU_CKM0_CLEAR; - TPS0 |= _0000_TAU_CKM0_FCLK_0; - /* Stop channel 3 */ - TT0 |= _0008_TAU_CH3_STOP_TRG_ON; - /* Mask channel 3 interrupt */ - TMMK03 = 1U; /* disable INTTM03 interrupt */ - TMIF03 = 0U; /* clear INTTM03 interrupt flag */ - /* Set INTTM03 low priority */ -// TMPR103 = 1U; -// TMPR003 = 1U; - /* TAU03 used as square output function */ - TMR03 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_16BITS_MODE | - _0000_TAU_TRIGGER_SOFTWARE | _0000_TAU_MODE_INTERVAL_TIMER | _0001_TAU_START_INT_USED; - TDR03 = _F9FF_TAU_TDR03_VALUE; - TOM0 &= (uint16_t)~_0008_TAU_CH3_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0008_TAU_CH3_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0008_TAU_CH3_OUTPUT_VALUE_1; - TOE0 |= _0008_TAU_CH3_OUTPUT_ENABLE; - /* Set TO03 pin */ - PMCT3 &= 0xFDU; - P3 &= 0xFDU; - PM3 &= 0xFDU; - - R_Config_TAU0_3_Square_Wave_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_3_Start -* Description : This function starts the TAU0 channel3 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_3_Square_Wave_Start(void) -{ -// TMIF03 = 0U; /* clear INTTM03 interrupt flag */ -// TMMK03 = 0U; /* enable INTTM03 interrupt */ - TOE0 |= _0008_TAU_CH3_OUTPUT_ENABLE; - TS0 |= _0008_TAU_CH3_START_TRG_ON; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_3_Stop -* Description : This function stops the TAU0 channel3 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_3_Square_Wave_Stop(void) -{ - TT0 |= _0008_TAU_CH3_STOP_TRG_ON; - TOE0 &= (uint16_t)~_0008_TAU_CH3_OUTPUT_ENABLE; - /* Mask channel 3 interrupt */ -// TMMK03 = 1U; /* disable INTTM03 interrupt */ -// TMIF03 = 0U; /* clear INTTM03 interrupt flag */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_TAU0_3_Square_Wave.c +* Version : 1.1.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_TAU0_3. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_TAU0_3_Square_Wave.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_3_Create +* Description : This function initializes the TAU0 channel3 module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_3_Square_Wave_Create(void) +{ + TPS0 &= _FFF0_TAU_CKM0_CLEAR; + TPS0 |= _0000_TAU_CKM0_FCLK_0; + /* Stop channel 3 */ + TT0 |= _0008_TAU_CH3_STOP_TRG_ON; + /* Mask channel 3 interrupt */ + TMMK03 = 1U; /* disable INTTM03 interrupt */ + TMIF03 = 0U; /* clear INTTM03 interrupt flag */ + /* Set INTTM03 low priority */ +// TMPR103 = 1U; +// TMPR003 = 1U; + /* TAU03 used as square output function */ + TMR03 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_16BITS_MODE | + _0000_TAU_TRIGGER_SOFTWARE | _0000_TAU_MODE_INTERVAL_TIMER | _0001_TAU_START_INT_USED; + TDR03 = _F9FF_TAU_TDR03_VALUE; + TOM0 &= (uint16_t)~_0008_TAU_CH3_SLAVE_OUTPUT; + TOL0 &= (uint16_t)~_0008_TAU_CH3_OUTPUT_LEVEL_L; + TO0 &= (uint16_t)~_0008_TAU_CH3_OUTPUT_VALUE_1; + TOE0 |= _0008_TAU_CH3_OUTPUT_ENABLE; + /* Set TO03 pin */ + PMCT3 &= 0xFDU; + P3 &= 0xFDU; + PM3 &= 0xFDU; + + R_Config_TAU0_3_Square_Wave_Create_UserInit(); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_3_Start +* Description : This function starts the TAU0 channel3 counter. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_3_Square_Wave_Start(void) +{ +// TMIF03 = 0U; /* clear INTTM03 interrupt flag */ +// TMMK03 = 0U; /* enable INTTM03 interrupt */ + TOE0 |= _0008_TAU_CH3_OUTPUT_ENABLE; + TS0 |= _0008_TAU_CH3_START_TRG_ON; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_3_Stop +* Description : This function stops the TAU0 channel3 counter. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_3_Square_Wave_Stop(void) +{ + TT0 |= _0008_TAU_CH3_STOP_TRG_ON; + TOE0 &= (uint16_t)~_0008_TAU_CH3_OUTPUT_ENABLE; + /* Mask channel 3 interrupt */ +// TMMK03 = 1U; /* disable INTTM03 interrupt */ +// TMIF03 = 0U; /* clear INTTM03 interrupt flag */ +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_3_Square_Wave/Config_TAU0_3_Square_Wave.h b/cores/rl78g22/smc_gen/Config_TAU0_3_Square_Wave/Config_TAU0_3_Square_Wave.h index aa8eb59..428498d 100644 --- a/cores/rl78g22/smc_gen/Config_TAU0_3_Square_Wave/Config_TAU0_3_Square_Wave.h +++ b/cores/rl78g22/smc_gen/Config_TAU0_3_Square_Wave/Config_TAU0_3_Square_Wave.h @@ -1,58 +1,58 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_3_Square_Wave.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_3. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_TAU0_3_Square_Wave_H -#define CFG_Config_TAU0_3_Square_Wave_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _F9FF_TAU_TDR03_VALUE (0xF9FFU) /* 16-bit timer data register 03 (TDR03) */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_3_Square_Wave_Create (void); -void R_Config_TAU0_3_Square_Wave_Start (void); -void R_Config_TAU0_3_Square_Wave_Stop (void); -void R_Config_TAU0_3_Square_Wave_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_TAU0_3_Square_Wave.h +* Version : 1.1.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_TAU0_3. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef CFG_Config_TAU0_3_Square_Wave_H +#define CFG_Config_TAU0_3_Square_Wave_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_tau.h" + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ +#define _F9FF_TAU_TDR03_VALUE (0xF9FFU) /* 16-bit timer data register 03 (TDR03) */ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_Config_TAU0_3_Square_Wave_Create (void); +void R_Config_TAU0_3_Square_Wave_Start (void); +void R_Config_TAU0_3_Square_Wave_Stop (void); +void R_Config_TAU0_3_Square_Wave_Create_UserInit (void); +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/Config_TAU0_3_Square_Wave/Config_TAU0_3_Square_Wave_user.c b/cores/rl78g22/smc_gen/Config_TAU0_3_Square_Wave/Config_TAU0_3_Square_Wave_user.c index ff524f3..82bb7be 100644 --- a/cores/rl78g22/smc_gen/Config_TAU0_3_Square_Wave/Config_TAU0_3_Square_Wave_user.c +++ b/cores/rl78g22/smc_gen/Config_TAU0_3_Square_Wave/Config_TAU0_3_Square_Wave_user.c @@ -1,74 +1,74 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_3_Square_Wave_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_3. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_3_Square_Wave.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_3_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel3. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_3_Square_Wave_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_3_interrupt -* Description : This function is INTTM03 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_3_Square_Wave_interrupt(void) -{ - /* Start user code for r_Config_TAU0_3_interrupt. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_TAU0_3_Square_Wave_user.c +* Version : 1.1.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_TAU0_3. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_TAU0_3_Square_Wave.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_3_Create_UserInit +* Description : This function adds user code after initializing the TAU0 channel3. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_3_Square_Wave_Create_UserInit(void) +{ + /* Start user code for user init. Do not edit comment generated here */ + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_TAU0_3_interrupt +* Description : This function is INTTM03 interrupt service routine. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_TAU0_3_Square_Wave_interrupt(void) +{ + /* Start user code for r_Config_TAU0_3_interrupt. Do not edit comment generated here */ + /* End user code. Do not edit comment generated here */ +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_4_Servo/Config_TAU0_4_Servo.c b/cores/rl78g22/smc_gen/Config_TAU0_4_Servo/Config_TAU0_4_Servo.c deleted file mode 100644 index d57c693..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_4_Servo/Config_TAU0_4_Servo.c +++ /dev/null @@ -1,114 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_4_Servo.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_4. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_4_Servo.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_4_Create -* Description : This function initializes the TAU0 channel4 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_4_Servo_Create(void) -{ - TPS0 &= _FFF0_TAU_CKM0_CLEAR; - TPS0 |= _0003_TAU_CKM0_FCLK_3; - /* Stop channel 4 */ - TT0 |= _0010_TAU_CH4_STOP_TRG_ON; - /* Mask channel 4 interrupt */ - TMMK04 = 1U; /* disable INTTM04 interrupt */ - TMIF04 = 0U; /* clear INTTM04 interrupt flag */ - /* Set INTTM04 low priority */ - TMPR104 = 1U; - TMPR004 = 1U; - /* TAU04 used as square output function */ - TMR04 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_COMBINATION_SLAVE | - _0000_TAU_TRIGGER_SOFTWARE | _0000_TAU_MODE_INTERVAL_TIMER | _0000_TAU_START_INT_UNUSED; - TDR04 = _257F_TAU_TDR04_VALUE; - TOM0 &= (uint16_t)~_0010_TAU_CH4_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0010_TAU_CH4_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0010_TAU_CH4_OUTPUT_VALUE_1; - TOE0 |= _0010_TAU_CH4_OUTPUT_ENABLE; - /* Set TO04 pin */ - POM1 &= 0xF7U; - PMCT1 &= 0xF7U; - P1 &= 0xF7U; - PM1 &= 0xF7U; - - R_Config_TAU0_4_Servo_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_4_Start -* Description : This function starts the TAU0 channel4 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_4_Servo_Start(void) -{ - TMIF04 = 0U; /* clear INTTM04 interrupt flag */ - TMMK04 = 0U; /* enable INTTM04 interrupt */ - TOE0 |= _0010_TAU_CH4_OUTPUT_ENABLE; - TS0 |= _0010_TAU_CH4_START_TRG_ON; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_4_Stop -* Description : This function stops the TAU0 channel4 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_4_Servo_Stop(void) -{ - TT0 |= _0010_TAU_CH4_STOP_TRG_ON; - TOE0 &= (uint16_t)~_0010_TAU_CH4_OUTPUT_ENABLE; - /* Mask channel 4 interrupt */ - TMMK04 = 1U; /* disable INTTM04 interrupt */ - TMIF04 = 0U; /* clear INTTM04 interrupt flag */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_4_Servo/Config_TAU0_4_Servo.h b/cores/rl78g22/smc_gen/Config_TAU0_4_Servo/Config_TAU0_4_Servo.h deleted file mode 100644 index 51f8798..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_4_Servo/Config_TAU0_4_Servo.h +++ /dev/null @@ -1,58 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_4_Servo.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_4. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_TAU0_4_Servo_H -#define CFG_Config_TAU0_4_Servo_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _257F_TAU_TDR04_VALUE (0x257FU) /* 16-bit timer data register 04 (TDR04) */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_4_Servo_Create (void); -void R_Config_TAU0_4_Servo_Start (void); -void R_Config_TAU0_4_Servo_Stop (void); -void R_Config_TAU0_4_Servo_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif diff --git a/cores/rl78g22/smc_gen/Config_TAU0_5_Servo/Config_TAU0_5_Servo.c b/cores/rl78g22/smc_gen/Config_TAU0_5_Servo/Config_TAU0_5_Servo.c deleted file mode 100644 index a9c499e..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_5_Servo/Config_TAU0_5_Servo.c +++ /dev/null @@ -1,114 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_5_Servo.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_5. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_5_Servo.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_5_Create -* Description : This function initializes the TAU0 channel5 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_5_Servo_Create(void) -{ - TPS0 &= _FFF0_TAU_CKM0_CLEAR; - TPS0 |= _0003_TAU_CKM0_FCLK_3; - /* Stop channel 5 */ - TT0 |= _0020_TAU_CH5_STOP_TRG_ON; - /* Mask channel 5 interrupt */ - TMMK05 = 1U; /* disable INTTM05 interrupt */ - TMIF05 = 0U; /* clear INTTM05 interrupt flag */ - /* Set INTTM05 low priority */ - TMPR105 = 1U; - TMPR005 = 1U; - /* TAU05 used as square output function */ - TMR05 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_TRIGGER_SOFTWARE | - _0000_TAU_MODE_INTERVAL_TIMER | _0000_TAU_START_INT_UNUSED; - TDR05 = _257F_TAU_TDR05_VALUE; - TOM0 &= (uint16_t)~_0020_TAU_CH5_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0020_TAU_CH5_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0020_TAU_CH5_OUTPUT_VALUE_1; - TOE0 |= _0020_TAU_CH5_OUTPUT_ENABLE; - /* Set TO05 pin */ - POM1 &= 0xFBU; - PMCT1 &= 0xFBU; - P1 &= 0xFBU; - PM1 &= 0xFBU; - - R_Config_TAU0_5_Servo_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_5_Start -* Description : This function starts the TAU0 channel5 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_5_Servo_Start(void) -{ - TMIF05 = 0U; /* clear INTTM05 interrupt flag */ - TMMK05 = 0U; /* enable INTTM05 interrupt */ - TOE0 |= _0020_TAU_CH5_OUTPUT_ENABLE; - TS0 |= _0020_TAU_CH5_START_TRG_ON; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_5_Stop -* Description : This function stops the TAU0 channel5 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_5_Servo_Stop(void) -{ - TT0 |= _0020_TAU_CH5_STOP_TRG_ON; - TOE0 &= (uint16_t)~_0020_TAU_CH5_OUTPUT_ENABLE; - /* Mask channel 5 interrupt */ - TMMK05 = 1U; /* disable INTTM05 interrupt */ - TMIF05 = 0U; /* clear INTTM05 interrupt flag */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_5_Servo/Config_TAU0_5_Servo.h b/cores/rl78g22/smc_gen/Config_TAU0_5_Servo/Config_TAU0_5_Servo.h deleted file mode 100644 index b80b253..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_5_Servo/Config_TAU0_5_Servo.h +++ /dev/null @@ -1,58 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_5_Servo.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_5. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_TAU0_5_Servo_H -#define CFG_Config_TAU0_5_Servo_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _257F_TAU_TDR05_VALUE (0x257FU) /* 16-bit timer data register 05 (TDR05) */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_5_Servo_Create (void); -void R_Config_TAU0_5_Servo_Start (void); -void R_Config_TAU0_5_Servo_Stop (void); -void R_Config_TAU0_5_Servo_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif diff --git a/cores/rl78g22/smc_gen/Config_TAU0_5_Servo/Config_TAU0_5_Servo_user.c b/cores/rl78g22/smc_gen/Config_TAU0_5_Servo/Config_TAU0_5_Servo_user.c deleted file mode 100644 index 7de703e..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_5_Servo/Config_TAU0_5_Servo_user.c +++ /dev/null @@ -1,74 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_5_Servo_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_5. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_5_Servo.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_5_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel5. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_5_Servo_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_5_interrupt -* Description : This function is INTTM05 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_5_Servo_interrupt(void) -{ - /* Start user code for r_Config_TAU0_5_interrupt. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_67_PWM/Config_TAU0_67_PWM.c b/cores/rl78g22/smc_gen/Config_TAU0_67_PWM/Config_TAU0_67_PWM.c deleted file mode 100644 index 11b1eea..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_67_PWM/Config_TAU0_67_PWM.c +++ /dev/null @@ -1,127 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_67_PWM.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_6. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_67_PWM.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_6_Create -* Description : This function initializes the TAU0 channel6 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_67_PWM_Create(void) -{ - TPS0 &= _FFF0_TAU_CKM0_CLEAR; - TPS0 |= _0000_TAU_CKM0_FCLK_0; - TT0 |= (_0080_TAU_CH7_STOP_TRG_ON | _0040_TAU_CH6_STOP_TRG_ON); - TMMK06 = 1U; /* disable INTTM06 interrupt */ - TMIF06 = 0U; /* clear INTTM06 interrupt flag */ - TMMK07 = 1U; /* disable INTTM07 interrupt */ - TMIF07 = 0U; /* clear INTTM07 interrupt flag */ - /* Set INTTM06 low priority */ -// TMPR106 = 1U; -// TMPR006 = 1U; - /* Set INTTM07 low priority */ -// TMPR107 = 1U; -// TMPR007 = 1U; - /* Channel 6 is used as master channel for PWM output function */ - TMR06 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0800_TAU_COMBINATION_MASTER | - _0000_TAU_TRIGGER_SOFTWARE | _0001_TAU_MODE_PWM_MASTER; - TDR06 = _F9FF_TAU_TDR06_VALUE; - TOM0 &= (uint16_t)~_0040_TAU_CH6_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0040_TAU_CH6_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0040_TAU_CH6_OUTPUT_VALUE_1; - TOE0 &= (uint16_t)~_0040_TAU_CH6_OUTPUT_ENABLE; - /* Channel 7 is used as slave channel for PWM output function */ - TMR07 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_COMBINATION_SLAVE | - _0400_TAU_TRIGGER_MASTER_INT | _0009_TAU_MODE_PWM_SLAVE; - TDR07 = _7D00_TAU_TDR07_VALUE; - TOM0 |= _0080_TAU_CH7_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0080_TAU_CH7_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0080_TAU_CH7_OUTPUT_VALUE_1; - TOE0 |= _0080_TAU_CH7_OUTPUT_ENABLE; - /* Set TO07 pin */ - P4 &= 0xFDU; - PM4 &= 0xFDU; - - R_Config_TAU0_67_PWM_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_6_Start -* Description : This function starts the TAU0 channel6 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_67_PWM_Start(void) -{ -// TMIF06 = 0U; /* clear INTTM06 interrupt flag */ -// TMMK06 = 0U; /* enable INTTM06 interrupt */ -// TMIF07 = 0U; /* clear INTTM07 interrupt flag */ -// TMMK07 = 0U; /* enable INTTM07 interrupt */ - TOE0 |= _0080_TAU_CH7_OUTPUT_ENABLE; - TS0 |= (_0080_TAU_CH7_START_TRG_ON | _0040_TAU_CH6_START_TRG_ON); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_6_Stop -* Description : This function stops the TAU0 channel6 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_67_PWM_Stop(void) -{ - TT0 |= (_0080_TAU_CH7_STOP_TRG_ON | _0040_TAU_CH6_STOP_TRG_ON); - TOE0 &= (uint16_t)~_0080_TAU_CH7_OUTPUT_ENABLE; -// TMMK06 = 1U; /* disable INTTM06 interrupt */ -// TMIF06 = 0U; /* clear INTTM06 interrupt flag */ -// TMMK07 = 1U; /* disable INTTM07 interrupt */ -// TMIF07 = 0U; /* clear INTTM07 interrupt flag */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - diff --git a/cores/rl78g22/smc_gen/Config_TAU0_67_PWM/Config_TAU0_67_PWM.h b/cores/rl78g22/smc_gen/Config_TAU0_67_PWM/Config_TAU0_67_PWM.h deleted file mode 100644 index 76ac3f9..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_67_PWM/Config_TAU0_67_PWM.h +++ /dev/null @@ -1,60 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_6.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_6. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_TAU0_67_PWM_H -#define CFG_Config_TAU0_67_PWM_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _F9FF_TAU_TDR06_VALUE (0xF9FFU) /* 16-bit timer data register 06 (TDR06) */ -#define _7D00_TAU_TDR07_VALUE (0x7D00U) /* 16-bit timer data register 07 (TDR07) */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_67_PWM_Create (void); -void R_Config_TAU0_67_PWM_Start (void); -void R_Config_TAU0_67_PWM_Stop (void); -void R_Config_TAU0_67_PWM_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif - diff --git a/cores/rl78g22/smc_gen/Config_TAU0_67_PWM/Config_TAU0_67_PWM_user.c b/cores/rl78g22/smc_gen/Config_TAU0_67_PWM/Config_TAU0_67_PWM_user.c deleted file mode 100644 index a2e89e5..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_67_PWM/Config_TAU0_67_PWM_user.c +++ /dev/null @@ -1,86 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_67_PWM_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_6. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_67_PWM.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_6_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel6. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_67_PWM_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_6_channel6_interrupt -* Description : This function is INTTM06 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_67_PWM_channel6_interrupt(void) -{ - /* Start user code for r_Config_TAU0_6_channel6_interrupt. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_6_channel7_interrupt -* Description : This function is INTTM07 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_67_PWM_channel7_interrupt(void) -{ - /* Start user code for r_Config_TAU0_6_channel7_interrupt. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_6_Micros/Config_TAU0_6_Micros.c b/cores/rl78g22/smc_gen/Config_TAU0_6_Micros/Config_TAU0_6_Micros.c index 21da5ae..a0111b0 100644 --- a/cores/rl78g22/smc_gen/Config_TAU0_6_Micros/Config_TAU0_6_Micros.c +++ b/cores/rl78g22/smc_gen/Config_TAU0_6_Micros/Config_TAU0_6_Micros.c @@ -1,107 +1,107 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_6_Micros.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_6_Micros. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_6_Micros.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_6_Micros_Create -* Description : This function initializes the TAU0 channel 6 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_6_Micros_Create(void) -{ - TPS0 &= _FF0F_TAU_CKM1_CLEAR; - TPS0 |= _0050_TAU_CKM1_FCLK_5; - /* Stop channel 6 */ - TT0 |= _0040_TAU_CH6_STOP_TRG_ON; - /* Mask channel 6 interrupt */ - TMMK06 = 1U; /* disable INTTM06 interrupt */ - TMIF06 = 0U; /* clear INTTM06 interrupt flag */ - /* Set INTTM06 low priority */ - TMPR106 = 1U; - TMPR006 = 1U; - /* TAU06 used as interval timer */ - TMR06 = _8000_TAU_CLOCK_SELECT_CKM1 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_COMBINATION_SLAVE | - _0000_TAU_TRIGGER_SOFTWARE | _0000_TAU_MODE_INTERVAL_TIMER | _0000_TAU_START_INT_UNUSED; - TDR06 = _FFFE_TAU_TDR06_VALUE; - TOM0 &= (uint16_t)~_0040_TAU_CH6_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0040_TAU_CH6_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0040_TAU_CH6_OUTPUT_VALUE_1; - TOE0 &= (uint16_t)~_0040_TAU_CH6_OUTPUT_ENABLE; - - R_Config_TAU0_6_Micros_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_6_Micros_Start -* Description : This function starts the TAU0 channel 6 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_6_Micros_Start(void) -{ - TMIF06 = 0U; /* clear INTTM06 interrupt flag */ - TMMK06 = 0U; /* enable INTTM06 interrupt */ - TS0 |= _0040_TAU_CH6_START_TRG_ON; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_6_Micros_Stop -* Description : This function stops the TAU0 channel 6 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_6_Micros_Stop(void) -{ - TT0 |= _0040_TAU_CH6_STOP_TRG_ON; - /* Mask channel 6 interrupt */ - TMMK06 = 1U; /* disable INTTM06 interrupt */ - TMIF06 = 0U; /* clear INTTM06 interrupt flag */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_TAU0_6_Micros.c +* Version : 1.1.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_TAU0_6_Micros. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_TAU0_6_Micros.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_6_Micros_Create +* Description : This function initializes the TAU0 channel 6 module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_6_Micros_Create(void) +{ + TPS0 &= _FF0F_TAU_CKM1_CLEAR; + TPS0 |= _0050_TAU_CKM1_FCLK_5; + /* Stop channel 6 */ + TT0 |= _0040_TAU_CH6_STOP_TRG_ON; + /* Mask channel 6 interrupt */ + TMMK06 = 1U; /* disable INTTM06 interrupt */ + TMIF06 = 0U; /* clear INTTM06 interrupt flag */ + /* Set INTTM06 low priority */ + TMPR106 = 1U; + TMPR006 = 1U; + /* TAU06 used as interval timer */ + TMR06 = _8000_TAU_CLOCK_SELECT_CKM1 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_COMBINATION_SLAVE | + _0000_TAU_TRIGGER_SOFTWARE | _0000_TAU_MODE_INTERVAL_TIMER | _0000_TAU_START_INT_UNUSED; + TDR06 = _FFFE_TAU_TDR06_VALUE; + TOM0 &= (uint16_t)~_0040_TAU_CH6_SLAVE_OUTPUT; + TOL0 &= (uint16_t)~_0040_TAU_CH6_OUTPUT_LEVEL_L; + TO0 &= (uint16_t)~_0040_TAU_CH6_OUTPUT_VALUE_1; + TOE0 &= (uint16_t)~_0040_TAU_CH6_OUTPUT_ENABLE; + + R_Config_TAU0_6_Micros_Create_UserInit(); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_6_Micros_Start +* Description : This function starts the TAU0 channel 6 counter. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_6_Micros_Start(void) +{ + TMIF06 = 0U; /* clear INTTM06 interrupt flag */ + TMMK06 = 0U; /* enable INTTM06 interrupt */ + TS0 |= _0040_TAU_CH6_START_TRG_ON; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_6_Micros_Stop +* Description : This function stops the TAU0 channel 6 counter. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_6_Micros_Stop(void) +{ + TT0 |= _0040_TAU_CH6_STOP_TRG_ON; + /* Mask channel 6 interrupt */ + TMMK06 = 1U; /* disable INTTM06 interrupt */ + TMIF06 = 0U; /* clear INTTM06 interrupt flag */ +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_6_Micros/Config_TAU0_6_Micros.h b/cores/rl78g22/smc_gen/Config_TAU0_6_Micros/Config_TAU0_6_Micros.h index 330da70..a2277c7 100644 --- a/cores/rl78g22/smc_gen/Config_TAU0_6_Micros/Config_TAU0_6_Micros.h +++ b/cores/rl78g22/smc_gen/Config_TAU0_6_Micros/Config_TAU0_6_Micros.h @@ -1,58 +1,58 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_6_Micros.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_6_Micros. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_TAU0_6_Micros_H -#define CFG_Config_TAU0_6_Micros_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _FFFE_TAU_TDR06_VALUE (0xFFFEU) /* 16-bit timer data register 06 (TDR06) */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_6_Micros_Create (void); -void R_Config_TAU0_6_Micros_Start (void); -void R_Config_TAU0_6_Micros_Stop (void); -void R_Config_TAU0_6_Micros_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_TAU0_6_Micros.h +* Version : 1.1.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_TAU0_6_Micros. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef CFG_Config_TAU0_6_Micros_H +#define CFG_Config_TAU0_6_Micros_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_tau.h" + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ +#define _FFFE_TAU_TDR06_VALUE (0xFFFEU) /* 16-bit timer data register 06 (TDR06) */ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_Config_TAU0_6_Micros_Create (void); +void R_Config_TAU0_6_Micros_Start (void); +void R_Config_TAU0_6_Micros_Stop (void); +void R_Config_TAU0_6_Micros_Create_UserInit (void); +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/Config_TAU0_6_Micros/Config_TAU0_6_Micros_user.c b/cores/rl78g22/smc_gen/Config_TAU0_6_Micros/Config_TAU0_6_Micros_user.c index 78aa062..29256b2 100644 --- a/cores/rl78g22/smc_gen/Config_TAU0_6_Micros/Config_TAU0_6_Micros_user.c +++ b/cores/rl78g22/smc_gen/Config_TAU0_6_Micros/Config_TAU0_6_Micros_user.c @@ -1,76 +1,76 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_6_Micros_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_6_Micros. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_6_Micros.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -extern volatile unsigned long g_timer06_overflow_count; -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_6_Micros_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel 6. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_6_Micros_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_6_Micros_interrupt -* Description : This function is INTTM06 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_6_Micros_interrupt(void) -{ - /* Start user code for r_Config_TAU0_6_Micros_interrupt. Do not edit comment generated here */ - g_timer06_overflow_count++; - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_TAU0_6_Micros_user.c +* Version : 1.1.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_TAU0_6_Micros. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_TAU0_6_Micros.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +extern volatile unsigned long g_micros_timer_ovfl_count; +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_6_Micros_Create_UserInit +* Description : This function adds user code after initializing the TAU0 channel 6. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_6_Micros_Create_UserInit(void) +{ + /* Start user code for user init. Do not edit comment generated here */ + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_TAU0_6_Micros_interrupt +* Description : This function is INTTM06 interrupt service routine. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_TAU0_6_Micros_interrupt(void) +{ + /* Start user code for r_Config_TAU0_6_Micros_interrupt. Do not edit comment generated here */ + g_micros_timer_ovfl_count++; + /* End user code. Do not edit comment generated here */ +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_6_Servo/Config_TAU0_6_Servo.c b/cores/rl78g22/smc_gen/Config_TAU0_6_Servo/Config_TAU0_6_Servo.c deleted file mode 100644 index 78ee9ba..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_6_Servo/Config_TAU0_6_Servo.c +++ /dev/null @@ -1,114 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_6_Servo.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_6. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_6_Servo.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_6_Create -* Description : This function initializes the TAU0 channel6 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_6_Servo_Create(void) -{ - TPS0 &= _FFF0_TAU_CKM0_CLEAR; - TPS0 |= _0003_TAU_CKM0_FCLK_3; - /* Stop channel 6 */ - TT0 |= _0040_TAU_CH6_STOP_TRG_ON; - /* Mask channel 6 interrupt */ - TMMK06 = 1U; /* disable INTTM06 interrupt */ - TMIF06 = 0U; /* clear INTTM06 interrupt flag */ - /* Set INTTM06 low priority */ - TMPR106 = 1U; - TMPR006 = 1U; - /* TAU06 used as square output function */ - TMR06 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_COMBINATION_SLAVE | - _0000_TAU_TRIGGER_SOFTWARE | _0000_TAU_MODE_INTERVAL_TIMER | _0000_TAU_START_INT_UNUSED; - TDR06 = _257F_TAU_TDR06_VALUE; - TOM0 &= (uint16_t)~_0040_TAU_CH6_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0040_TAU_CH6_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0040_TAU_CH6_OUTPUT_VALUE_1; - TOE0 |= _0040_TAU_CH6_OUTPUT_ENABLE; - /* Set TO06 pin */ - POM1 &= 0xFDU; - PMCT1 &= 0xFDU; - P1 &= 0xFDU; - PM1 &= 0xFDU; - - R_Config_TAU0_6_Servo_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_6_Start -* Description : This function starts the TAU0 channel6 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_6_Servo_Start(void) -{ - TMIF06 = 0U; /* clear INTTM06 interrupt flag */ - TMMK06 = 0U; /* enable INTTM06 interrupt */ - TOE0 |= _0040_TAU_CH6_OUTPUT_ENABLE; - TS0 |= _0040_TAU_CH6_START_TRG_ON; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_6_Stop -* Description : This function stops the TAU0 channel6 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_6_Servo_Stop(void) -{ - TT0 |= _0040_TAU_CH6_STOP_TRG_ON; - TOE0 &= (uint16_t)~_0040_TAU_CH6_OUTPUT_ENABLE; - /* Mask channel 6 interrupt */ - TMMK06 = 1U; /* disable INTTM06 interrupt */ - TMIF06 = 0U; /* clear INTTM06 interrupt flag */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_6_Servo/Config_TAU0_6_Servo.h b/cores/rl78g22/smc_gen/Config_TAU0_6_Servo/Config_TAU0_6_Servo.h deleted file mode 100644 index a924130..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_6_Servo/Config_TAU0_6_Servo.h +++ /dev/null @@ -1,58 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_6_Servo.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_6. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_TAU0_6_Servo_H -#define CFG_Config_TAU0_6_Servo_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _257F_TAU_TDR06_VALUE (0x257FU) /* 16-bit timer data register 06 (TDR06) */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_6_Servo_Create (void); -void R_Config_TAU0_6_Servo_Start (void); -void R_Config_TAU0_6_Servo_Stop (void); -void R_Config_TAU0_6_Servo_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif diff --git a/cores/rl78g22/smc_gen/Config_TAU0_6_Servo/Config_TAU0_6_Servo_user.c b/cores/rl78g22/smc_gen/Config_TAU0_6_Servo/Config_TAU0_6_Servo_user.c deleted file mode 100644 index 28cee78..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_6_Servo/Config_TAU0_6_Servo_user.c +++ /dev/null @@ -1,74 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_6_Servo_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_6. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_6_Servo.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_6_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel6. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_6_Servo_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_6_interrupt -* Description : This function is INTTM06 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_6_Servo_interrupt(void) -{ - /* Start user code for r_Config_TAU0_6_interrupt. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_7_MSTimer2/Config_TAU0_7_MSTimer2.c b/cores/rl78g22/smc_gen/Config_TAU0_7_MSTimer2/Config_TAU0_7_MSTimer2.c deleted file mode 100644 index 3e08ebc..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_7_MSTimer2/Config_TAU0_7_MSTimer2.c +++ /dev/null @@ -1,114 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_7_MSTimer2.c -* Version : 1.1.0 -* Device(s) : R7F100GLGxFB -* Description : This file implements device driver for Config_TAU0_7. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_7_MSTimer2.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_7_Create -* Description : This function initializes the TAU0 channel 7 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_7_MSTimer2_Create(void) -{ - TPS0 &= _FFF0_TAU_CKM0_CLEAR; - TPS0 |= _0000_TAU_CKM0_FCLK_0; - /* Stop channel 7 */ - TT0 |= _0080_TAU_CH7_STOP_TRG_ON; - /* Mask channel 7 interrupt */ - TMMK07 = 1U; /* disable INTTM07 interrupt */ - TMIF07 = 0U; /* clear INTTM07 interrupt flag */ - /* Set INTTM07 low priority */ - TMPR107 = 1U; - TMPR007 = 1U; - /* TAU07 used as interval timer */ - TMR07 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_TRIGGER_SOFTWARE | - _0000_TAU_MODE_INTERVAL_TIMER | _0000_TAU_START_INT_UNUSED; - -// TDR07 = _0C7F_TAU_TDR07_VALUE; -// TDR07 = 0x13F; - TDR07 = 31; // 1us - TOM0 &= (uint16_t)~_0080_TAU_CH7_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0080_TAU_CH7_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0080_TAU_CH7_OUTPUT_VALUE_1; - TOE0 &= (uint16_t)~_0080_TAU_CH7_OUTPUT_ENABLE; - - R_Config_TAU0_7_MSTimer2_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_7_Start -* Description : This function starts the TAU0 channel 7 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_7_MSTimer2_Start(void) -{ - TMIF07 = 0U; /* clear INTTM07 interrupt flag */ - TMMK07 = 0U; /* enable INTTM07 interrupt */ - TS0 |= _0080_TAU_CH7_START_TRG_ON; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_7_Stop -* Description : This function stops the TAU0 channel 7 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_7_MSTimer2_Stop(void) -{ - TT0 |= _0080_TAU_CH7_STOP_TRG_ON; - /* Mask channel 7 interrupt */ - TMMK07 = 1U; /* disable INTTM07 interrupt */ - TMIF07 = 0U; /* clear INTTM07 interrupt flag */ -} - -/* Start user code for adding. Do not edit comment generated here */ -void R_Config_TAU0_7_MSTimer2_SetPeriod(uint16_t preiod_us) -{ - TDR07 = 32 * preiod_us -1; -} -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_7_MSTimer2/Config_TAU0_7_MSTimer2.h b/cores/rl78g22/smc_gen/Config_TAU0_7_MSTimer2/Config_TAU0_7_MSTimer2.h deleted file mode 100644 index b84b5d1..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_7_MSTimer2/Config_TAU0_7_MSTimer2.h +++ /dev/null @@ -1,59 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_7_MSTimer2.h -* Version : 1.1.0 -* Device(s) : R7F100GLGxFB -* Description : This file implements device driver for Config_TAU0_7. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef Config_TAU0_7_MSTIMER2_H -#define Config_TAU0_7_MSTIMER2_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _0C7F_TAU_TDR07_VALUE (0x0C7FU) /* 16-bit timer data register 07 (TDR07) */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_7_MSTimer2_Create(void); -void R_Config_TAU0_7_MSTimer2_Start(void); -void R_Config_TAU0_7_MSTimer2_Stop(void); -void R_Config_TAU0_7_MSTimer2_Create_UserInit(void); -/* Start user code for function. Do not edit comment generated here */ -void R_Config_TAU0_7_MSTimer2_SetPeriod(uint16_t preiod_us); -/* End user code. Do not edit comment generated here */ -#endif diff --git a/cores/rl78g22/smc_gen/Config_TAU0_7_MSTimer2/Config_TAU0_7_MSTimer2_user.c b/cores/rl78g22/smc_gen/Config_TAU0_7_MSTimer2/Config_TAU0_7_MSTimer2_user.c deleted file mode 100644 index 02df11f..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_7_MSTimer2/Config_TAU0_7_MSTimer2_user.c +++ /dev/null @@ -1,85 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_7_MSTimer2_user.c -* Version : 1.1.0 -* Device(s) : R7F100GLGxFB -* Description : This file implements device driver for Config_TAU0_7. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_7_MSTimer2.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" -#include "utilities.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -extern volatile unsigned long g_u32microtimer_periodic; - -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_7_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel 7. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_7_MSTimer2_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - g_u32microtimer_periodic = 0; - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_7_interrupt -* Description : This function is INTTM07 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_7_MSTimer2_interrupt(void) -{ - /* Start user code for r_Config_TAU0_7_interrupt. Do not edit comment generated here */ - g_u32microtimer_periodic ++; - if (g_u32microtimer_periodic > 0) { - if (g_fMicroInterruptFunc) { - g_fMicroInterruptFunc(); - } - g_u32microtimer_periodic = 0; - } - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_7_Measure_Signal/Config_TAU0_7_Measure_Signal.c b/cores/rl78g22/smc_gen/Config_TAU0_7_Measure_Signal/Config_TAU0_7_Measure_Signal.c deleted file mode 100644 index df7538c..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_7_Measure_Signal/Config_TAU0_7_Measure_Signal.c +++ /dev/null @@ -1,127 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_7_Measure_Signal.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_7. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_7_Measure_Signal.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* For TAU0_ch7 pulse measurement */ -extern volatile uint32_t g_tau0_ch7_width; -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_7_Measure_Signal_Create -* Description : This function initializes the TAU0 channel7 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_7_Measure_Signal_Create(void) -{ - TPS0 &= _FFF0_TAU_CKM0_CLEAR; - TPS0 |= _0006_TAU_CKM0_FCLK_6; - /* Stop channel 7 */ - TT0 |= _0080_TAU_CH7_STOP_TRG_ON; - /* Mask channel 7 interrupt */ - TMMK07 = 1U; /* disable INTTM07 interrupt */ - TMIF07 = 0U; /* clear INTTM07 interrupt flag */ - /* Set INTTM07 low priority */ - TMPR107 = 1U; - TMPR007 = 1U; - /* TAU07 is used to measure input pulse low-/high-width */ - ISC &= _FD_TAU_CH7_INPUT_CLEAR; - ISC |= _00_TAU_CH7_INPUT_TI07; - NFEN1 &= (uint8_t)~_80_TAU_CH7_NOISE_ON; - TMR07 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0200_TAU_TRIGGER_TIMN_BOTH | - _0080_TAU_TIMN_EDGE_BOTH_LOW | _000C_TAU_MODE_HIGHLOW_MEASURE; - TOM0 &= (uint16_t)~_0080_TAU_CH7_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0080_TAU_CH7_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0080_TAU_CH7_OUTPUT_VALUE_1; - TOE0 &= (uint16_t)~_0080_TAU_CH7_OUTPUT_ENABLE; - /* Set TI07 pin */ - PM4 |= 0x02U; - - R_Config_TAU0_7_Measure_Signal_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_7_Measure_Signal_Start -* Description : This function starts the TAU0 channel7 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_7_Measure_Signal_Start(void) -{ - TMIF07 = 0U; /* clear INTTM07 interrupt flag */ - TMMK07 = 0U; /* enable INTTM07 interrupt */ - TS0 |= _0080_TAU_CH7_START_TRG_ON; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_7_Measure_Signal_Stop -* Description : This function stops the TAU0 channel7 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_7_Measure_Signal_Stop(void) -{ - TT0 |= _0080_TAU_CH7_STOP_TRG_ON; - /* Mask channel 7 interrupt */ - TMMK07 = 1U; /* disable INTTM07 interrupt */ - TMIF07 = 0U; /* clear INTTM07 interrupt flag */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_7_Measure_Signal_Get_PulseWidth -* Description : This function measures TAU0 channel 7 input pulse width. -* Arguments : width - -* the address where to write the input pulse width -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_7_Measure_Signal_Get_PulseWidth(uint32_t * const width) -{ - /* For channel 7 pulse measurement */ - *width = g_tau0_ch7_width; -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - diff --git a/cores/rl78g22/smc_gen/Config_TAU0_7_Measure_Signal/Config_TAU0_7_Measure_Signal.h b/cores/rl78g22/smc_gen/Config_TAU0_7_Measure_Signal/Config_TAU0_7_Measure_Signal.h deleted file mode 100644 index 598cebe..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_7_Measure_Signal/Config_TAU0_7_Measure_Signal.h +++ /dev/null @@ -1,58 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_7_Measure_Signal.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_7. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_TAU0_7_Measure_Signal_H -#define CFG_Config_TAU0_7_Measure_Signal_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_7_Measure_Signal_Create (void); -void R_Config_TAU0_7_Measure_Signal_Start (void); -void R_Config_TAU0_7_Measure_Signal_Stop (void); -void R_Config_TAU0_7_Measure_Signal_Get_PulseWidth (uint32_t * const width); -void R_Config_TAU0_7_Measure_Signal_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif diff --git a/cores/rl78g22/smc_gen/Config_TAU0_7_Measure_Signal/Config_TAU0_7_user.c b/cores/rl78g22/smc_gen/Config_TAU0_7_Measure_Signal/Config_TAU0_7_user.c deleted file mode 100644 index 1314bc9..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_7_Measure_Signal/Config_TAU0_7_user.c +++ /dev/null @@ -1,108 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_7_Measure_Signal_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_7. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_7_Measure_Signal.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* For TAU0_ch7 pulse measurement */ -volatile uint32_t g_tau0_ch7_width = 0UL; -/* Start user code for global. Do not edit comment generated here */ -volatile uint8_t g_tau0_ch7_interrupt_flag = 0UL; -extern volatile uint8_t g_pulse_enable_interrupt_flag; - -extern volatile uint8_t g_servo_enable_interrupt_flag[7]; -void R_Config_TAU0_1_Servo_Stop(void); -void R_Config_TAU0_2_Servo_Stop(void); -void R_Config_TAU0_3_Servo_Stop(void); -void R_Config_TAU0_4_Servo_Stop(void); -void R_Config_TAU0_5_Servo_Stop(void); -void R_Config_TAU0_6_Servo_Stop(void); -void R_Config_TAU0_7_Servo_Stop(void); -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_7_Measure_Signal_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel7. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_7_Measure_Signal_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_7_Measure_Signal_interrupt -* Description : This function is INTTM07 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_7_Measure_Signal_interrupt(void) -{ - if (g_pulse_enable_interrupt_flag == 1UL) - { - if (1U == (TSR07 & _0001_TAU_OVERFLOW_OCCURS)) /* overflow occurs */ - { - g_tau0_ch7_width = (uint32_t)(TDR07 + 1UL) + 0x10000UL; - } - else - { - g_tau0_ch7_width = (uint32_t)(TDR07 + 1UL); - } - /* Start user code for r_Config_TAU0_7_Mesure_Signal_interrupt. Do not edit comment generated here */ - g_tau0_ch7_interrupt_flag = 1UL; - } - else - { - ; - } - if (g_servo_enable_interrupt_flag[6] == 1UL) - { - R_Config_TAU0_7_Servo_Stop(); - g_servo_enable_interrupt_flag[6]= 0UL; - } - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_7_Servo/Config_TAU0_7_Servo.c b/cores/rl78g22/smc_gen/Config_TAU0_7_Servo/Config_TAU0_7_Servo.c deleted file mode 100644 index 65ae3e2..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_7_Servo/Config_TAU0_7_Servo.c +++ /dev/null @@ -1,114 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_7_Servo.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_7. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_7_Servo.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_7_Create -* Description : This function initializes the TAU0 channel7 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_7_Servo_Create(void) -{ - TPS0 &= _FFF0_TAU_CKM0_CLEAR; - TPS0 |= _0003_TAU_CKM0_FCLK_3; - /* Stop channel 7 */ - TT0 |= _0080_TAU_CH7_STOP_TRG_ON; - /* Mask channel 7 interrupt */ - TMMK07 = 1U; /* disable INTTM07 interrupt */ - TMIF07 = 0U; /* clear INTTM07 interrupt flag */ - /* Set INTTM07 low priority */ - TMPR107 = 1U; - TMPR007 = 1U; - /* TAU07 used as square output function */ - TMR07 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_TRIGGER_SOFTWARE | - _0000_TAU_MODE_INTERVAL_TIMER | _0000_TAU_START_INT_UNUSED; - TDR07 = _257F_TAU_TDR07_VALUE; - TOM0 &= (uint16_t)~_0080_TAU_CH7_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0080_TAU_CH7_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0080_TAU_CH7_OUTPUT_VALUE_1; - TOE0 |= _0080_TAU_CH7_OUTPUT_ENABLE; - /* Set TO07 pin */ - POM1 &= 0xFEU; - PMCT1 &= 0xFEU; - P1 &= 0xFEU; - PM1 &= 0xFEU; - - R_Config_TAU0_7_Servo_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_7_Start -* Description : This function starts the TAU0 channel7 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_7_Servo_Start(void) -{ - TMIF07 = 0U; /* clear INTTM07 interrupt flag */ - TMMK07 = 0U; /* enable INTTM07 interrupt */ - TOE0 |= _0080_TAU_CH7_OUTPUT_ENABLE; - TS0 |= _0080_TAU_CH7_START_TRG_ON; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_7_Stop -* Description : This function stops the TAU0 channel7 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_7_Servo_Stop(void) -{ - TT0 |= _0080_TAU_CH7_STOP_TRG_ON; - TOE0 &= (uint16_t)~_0080_TAU_CH7_OUTPUT_ENABLE; - /* Mask channel 7 interrupt */ - TMMK07 = 1U; /* disable INTTM07 interrupt */ - TMIF07 = 0U; /* clear INTTM07 interrupt flag */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_7_Servo/Config_TAU0_7_Servo.h b/cores/rl78g22/smc_gen/Config_TAU0_7_Servo/Config_TAU0_7_Servo.h deleted file mode 100644 index 1419f95..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_7_Servo/Config_TAU0_7_Servo.h +++ /dev/null @@ -1,58 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_7_Servo.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_7. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_TAU0_7_Servo_H -#define CFG_Config_TAU0_7_Servo_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _257F_TAU_TDR07_VALUE (0x257FU) /* 16-bit timer data register 07 (TDR07) */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_7_Servo_Create (void); -void R_Config_TAU0_7_Servo_Start (void); -void R_Config_TAU0_7_Servo_Stop (void); -void R_Config_TAU0_7_Servo_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif diff --git a/cores/rl78g22/smc_gen/Config_TAU0_7_Servo/Config_TAU0_7_Servo_user.c b/cores/rl78g22/smc_gen/Config_TAU0_7_Servo/Config_TAU0_7_Servo_user.c deleted file mode 100644 index f9517b4..0000000 --- a/cores/rl78g22/smc_gen/Config_TAU0_7_Servo/Config_TAU0_7_Servo_user.c +++ /dev/null @@ -1,74 +0,0 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_7_Servo_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_7. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_7_Servo.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_7_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel7. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_7_Servo_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_7_interrupt -* Description : This function is INTTM07 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_7_Servo_interrupt(void) -{ - /* Start user code for r_Config_TAU0_7_interrupt. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_7_Square_Wave/Config_TAU0_7_Square_Wave.c b/cores/rl78g22/smc_gen/Config_TAU0_7_Square_Wave/Config_TAU0_7_Square_Wave.c index fdd3888..21dc5ee 100644 --- a/cores/rl78g22/smc_gen/Config_TAU0_7_Square_Wave/Config_TAU0_7_Square_Wave.c +++ b/cores/rl78g22/smc_gen/Config_TAU0_7_Square_Wave/Config_TAU0_7_Square_Wave.c @@ -1,112 +1,112 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_7_Square_Wave.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_7. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_7_Square_Wave.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_7_Create -* Description : This function initializes the TAU0 channel7 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_7_Square_Wave_Create(void) -{ - TPS0 &= _FFF0_TAU_CKM0_CLEAR; - TPS0 |= _0000_TAU_CKM0_FCLK_0; - /* Stop channel 7 */ - TT0 |= _0080_TAU_CH7_STOP_TRG_ON; - /* Mask channel 7 interrupt */ - TMMK07 = 1U; /* disable INTTM07 interrupt */ - TMIF07 = 0U; /* clear INTTM07 interrupt flag */ - /* Set INTTM07 low priority */ -// TMPR107 = 1U; -// TMPR007 = 1U; - /* TAU07 used as square output function */ - TMR07 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_TRIGGER_SOFTWARE | - _0000_TAU_MODE_INTERVAL_TIMER | _0001_TAU_START_INT_USED; - TDR07 = _F9FF_TAU_TDR07_VALUE; - TOM0 &= (uint16_t)~_0080_TAU_CH7_SLAVE_OUTPUT; - TOL0 &= (uint16_t)~_0080_TAU_CH7_OUTPUT_LEVEL_L; - TO0 &= (uint16_t)~_0080_TAU_CH7_OUTPUT_VALUE_1; - TOE0 |= _0080_TAU_CH7_OUTPUT_ENABLE; - /* Set TO07 pin */ - P4 &= 0xFDU; - PM4 &= 0xFDU; - - R_Config_TAU0_7_Square_Wave_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_7_Start -* Description : This function starts the TAU0 channel7 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_7_Square_Wave_Start(void) -{ -// TMIF07 = 0U; /* clear INTTM07 interrupt flag */ -// TMMK07 = 0U; /* enable INTTM07 interrupt */ - TOE0 |= _0080_TAU_CH7_OUTPUT_ENABLE; - TS0 |= _0080_TAU_CH7_START_TRG_ON; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_7_Stop -* Description : This function stops the TAU0 channel7 counter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_7_Square_Wave_Stop(void) -{ - TT0 |= _0080_TAU_CH7_STOP_TRG_ON; - TOE0 &= (uint16_t)~_0080_TAU_CH7_OUTPUT_ENABLE; - /* Mask channel 7 interrupt */ -// TMMK07 = 1U; /* disable INTTM07 interrupt */ -// TMIF07 = 0U; /* clear INTTM07 interrupt flag */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_TAU0_7_Square_Wave.c +* Version : 1.1.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_TAU0_7. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_TAU0_7_Square_Wave.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_7_Create +* Description : This function initializes the TAU0 channel7 module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_7_Square_Wave_Create(void) +{ + TPS0 &= _FFF0_TAU_CKM0_CLEAR; + TPS0 |= _0000_TAU_CKM0_FCLK_0; + /* Stop channel 7 */ + TT0 |= _0080_TAU_CH7_STOP_TRG_ON; + /* Mask channel 7 interrupt */ + TMMK07 = 1U; /* disable INTTM07 interrupt */ + TMIF07 = 0U; /* clear INTTM07 interrupt flag */ + /* Set INTTM07 low priority */ +// TMPR107 = 1U; +// TMPR007 = 1U; + /* TAU07 used as square output function */ + TMR07 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_TRIGGER_SOFTWARE | + _0000_TAU_MODE_INTERVAL_TIMER | _0001_TAU_START_INT_USED; + TDR07 = _F9FF_TAU_TDR07_VALUE; + TOM0 &= (uint16_t)~_0080_TAU_CH7_SLAVE_OUTPUT; + TOL0 &= (uint16_t)~_0080_TAU_CH7_OUTPUT_LEVEL_L; + TO0 &= (uint16_t)~_0080_TAU_CH7_OUTPUT_VALUE_1; + TOE0 |= _0080_TAU_CH7_OUTPUT_ENABLE; + /* Set TO07 pin */ + P4 &= 0xFDU; + PM4 &= 0xFDU; + + R_Config_TAU0_7_Square_Wave_Create_UserInit(); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_7_Start +* Description : This function starts the TAU0 channel7 counter. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_7_Square_Wave_Start(void) +{ +// TMIF07 = 0U; /* clear INTTM07 interrupt flag */ +// TMMK07 = 0U; /* enable INTTM07 interrupt */ + TOE0 |= _0080_TAU_CH7_OUTPUT_ENABLE; + TS0 |= _0080_TAU_CH7_START_TRG_ON; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_7_Stop +* Description : This function stops the TAU0 channel7 counter. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_7_Square_Wave_Stop(void) +{ + TT0 |= _0080_TAU_CH7_STOP_TRG_ON; + TOE0 &= (uint16_t)~_0080_TAU_CH7_OUTPUT_ENABLE; + /* Mask channel 7 interrupt */ +// TMMK07 = 1U; /* disable INTTM07 interrupt */ +// TMIF07 = 0U; /* clear INTTM07 interrupt flag */ +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_TAU0_7_Square_Wave/Config_TAU0_7_Square_Wave.h b/cores/rl78g22/smc_gen/Config_TAU0_7_Square_Wave/Config_TAU0_7_Square_Wave.h index 6dc451c..486ec68 100644 --- a/cores/rl78g22/smc_gen/Config_TAU0_7_Square_Wave/Config_TAU0_7_Square_Wave.h +++ b/cores/rl78g22/smc_gen/Config_TAU0_7_Square_Wave/Config_TAU0_7_Square_Wave.h @@ -1,58 +1,58 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_7_Square_Wave.h -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_7. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_TAU0_7_Square_Wave_H -#define CFG_Config_TAU0_7_Square_Wave_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_tau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _F9FF_TAU_TDR07_VALUE (0xF9FFU) /* 16-bit timer data register 07 (TDR07) */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_TAU0_7_Square_Wave_Create (void); -void R_Config_TAU0_7_Square_Wave_Start (void); -void R_Config_TAU0_7_Square_Wave_Stop (void); -void R_Config_TAU0_7_Square_Wave_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_TAU0_7_Square_Wave.h +* Version : 1.1.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_TAU0_7. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef CFG_Config_TAU0_7_Square_Wave_H +#define CFG_Config_TAU0_7_Square_Wave_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_tau.h" + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ +#define _F9FF_TAU_TDR07_VALUE (0xF9FFU) /* 16-bit timer data register 07 (TDR07) */ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_Config_TAU0_7_Square_Wave_Create (void); +void R_Config_TAU0_7_Square_Wave_Start (void); +void R_Config_TAU0_7_Square_Wave_Stop (void); +void R_Config_TAU0_7_Square_Wave_Create_UserInit (void); +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/Config_TAU0_7_Square_Wave/Config_TAU0_7_Square_Wave_user.c b/cores/rl78g22/smc_gen/Config_TAU0_7_Square_Wave/Config_TAU0_7_Square_Wave_user.c index 93700b3..2594c09 100644 --- a/cores/rl78g22/smc_gen/Config_TAU0_7_Square_Wave/Config_TAU0_7_Square_Wave_user.c +++ b/cores/rl78g22/smc_gen/Config_TAU0_7_Square_Wave/Config_TAU0_7_Square_Wave_user.c @@ -1,74 +1,74 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_TAU0_7_Square_Wave_user.c -* Version : 1.1.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_TAU0_7. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_TAU0_7_Square_Wave.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_TAU0_7_Create_UserInit -* Description : This function adds user code after initializing the TAU0 channel7. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_TAU0_7_Square_Wave_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_TAU0_7_interrupt -* Description : This function is INTTM07 interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_TAU0_7_Square_Wave_interrupt(void) -{ - /* Start user code for r_Config_TAU0_7_interrupt. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_TAU0_7_Square_Wave_user.c +* Version : 1.1.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_TAU0_7. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_TAU0_7_Square_Wave.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_TAU0_7_Create_UserInit +* Description : This function adds user code after initializing the TAU0 channel7. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_TAU0_7_Square_Wave_Create_UserInit(void) +{ + /* Start user code for user init. Do not edit comment generated here */ + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_TAU0_7_interrupt +* Description : This function is INTTM07 interrupt service routine. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_TAU0_7_Square_Wave_interrupt(void) +{ + /* Start user code for r_Config_TAU0_7_interrupt. Do not edit comment generated here */ + /* End user code. Do not edit comment generated here */ +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_UART0/Config_UART0.c b/cores/rl78g22/smc_gen/Config_UART0/Config_UART0.c index 767851d..91b8468 100644 --- a/cores/rl78g22/smc_gen/Config_UART0/Config_UART0.c +++ b/cores/rl78g22/smc_gen/Config_UART0/Config_UART0.c @@ -1,228 +1,228 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_UART0.c -* Version : 1.2.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_UART0. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_UART0.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -volatile uint8_t * gp_uart0_tx_address; /* uart0 transmit buffer address */ -volatile uint16_t g_uart0_tx_count; /* uart0 transmit data number */ -volatile uint8_t * gp_uart0_rx_address; /* uart0 receive buffer address */ -volatile uint16_t g_uart0_rx_count; /* uart0 receive data number */ -uint16_t g_uart0_rx_length; /* uart0 receive data length */ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_UART0_Create -* Description : This function initializes the UART0 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_UART0_Create(void) -{ - SPS0 &= _00F0_SAU_CK00_CLEAR; - SPS0 |= _0004_SAU_CK00_FCLK_4; - ST0 |= (_0002_SAU_CH1_STOP_TRG_ON | _0001_SAU_CH0_STOP_TRG_ON); - STMK0 = 1U; /* disable INTST0 interrupt */ - STIF0 = 0U; /* clear INTST0 interrupt flag */ - SRMK0 = 1U; /* disable INTSR0 interrupt */ - SRIF0 = 0U; /* clear INTSR0 interrupt flag */ - SREMK0 = 1U; /* disable INTSRE0 interrupt */ - SREIF0 = 0U; /* clear INTSRE0 interrupt flag */ - /* Set INTST0 low priority */ - STPR10 = 1U; - STPR00 = 1U; - /* Set INTSR0 low priority */ - SRPR10 = 1U; - SRPR00 = 1U; - /* Set INTSRE0 low priority */ - SREPR10 = 1U; - SREPR00 = 1U; - SMR00 = _0020_SAU_SMRMN_INITIALVALUE | _0000_SAU_CLOCK_SELECT_CK00 | _0000_SAU_TRIGGER_SOFTWARE | - _0002_SAU_MODE_UART | _0000_SAU_TRANSFER_END; - SCR00 = _0004_SAU_SCRMN_INITIALVALUE | _8000_SAU_TRANSMISSION | _0000_SAU_INTSRE_MASK | _0000_SAU_PARITY_NONE | - _0080_SAU_LSB | _0010_SAU_STOP_1 | _0003_SAU_LENGTH_8; - SDR00 = _1000_SAU0_CH0_TRANSMIT_DIVISOR; - NFEN0 |= _01_SAU_RXD0_FILTER_ON; - SIR01 = _0004_SAU_SIRMN_FECTMN | _0002_SAU_SIRMN_PECTMN | _0001_SAU_SIRMN_OVCTMN; /* clear error flag */ - SMR01 = _0020_SAU_SMRMN_INITIALVALUE | _0000_SAU_CLOCK_SELECT_CK00 | _0100_SAU_TRIGGER_RXD | _0000_SAU_EDGE_FALL | - _0002_SAU_MODE_UART | _0000_SAU_TRANSFER_END; - SCR01 = _0004_SAU_SCRMN_INITIALVALUE | _4000_SAU_RECEPTION | _0400_SAU_INTSRE_ENABLE | _0000_SAU_PARITY_NONE | - _0080_SAU_LSB | _0010_SAU_STOP_1 | _0003_SAU_LENGTH_8; - SDR01 = _1000_SAU0_CH1_RECEIVE_DIVISOR; - SO0 |= _0001_SAU_CH0_DATA_OUTPUT_1; - SOL0 |= _0000_SAU_CHANNEL0_NORMAL; /* output level normal */ - SOE0 |= _0001_SAU_CH0_OUTPUT_ENABLE; /* enable UART0 output */ - /* Set TxD0 pin */ - // 2022/11/17 removed by KAD pin settings are done by Set_SerialPort -// PMCT1 &= 0xFBU; -// PFOE1 |= 0x01U; -// P1 |= 0x04U; -// PM1 &= 0xFBU; - /* Set RxD0 pin */ -// PMCT1 &= 0xFDU; -// PM1 |= 0x02U; - - R_Config_UART0_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_UART0_Start -* Description : This function starts UART0 module operation. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_UART0_Start(void) -{ - SO0 |= _0001_SAU_CH0_DATA_OUTPUT_1; /* output level normal */ - SOE0 |= _0001_SAU_CH0_OUTPUT_ENABLE; /* enable UART0 output */ - SS0 |= (_0002_SAU_CH1_START_TRG_ON | _0001_SAU_CH0_START_TRG_ON); /* enable UART0 receive and transmit */ - STIF0 = 0U; /* clear INTST0 interrupt flag */ - SRIF0 = 0U; /* clear INTSR0 interrupt flag */ - SREIF0 = 0U; /* clear INTSRE0 interrupt flag */ - STMK0 = 0U; /* enable INTST0 interrupt */ - SRMK0 = 0U; /* enable INTSR0 interrupt */ - SREMK0 = 0U; /* enable INTSRE0 interrupt */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_UART0_Stop -* Description : This function stops UART0 module operation. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_UART0_Stop(void) -{ - STMK0 = 1U; /* disable INTST0 interrupt */ - SRMK0 = 1U; /* disable INTSR0 interrupt */ - SREMK0 = 1U; /* disable INTSRE0 interrupt */ - ST0 |= (_0002_SAU_CH1_STOP_TRG_ON | _0001_SAU_CH0_STOP_TRG_ON); - SOE0 &= (uint16_t)~_0001_SAU_CH0_OUTPUT_ENABLE; /* disable UART0 output */ - STIF0 = 0U; /* clear INTST0 interrupt flag */ - SRIF0 = 0U; /* clear INTSR0 interrupt flag */ - SREIF0 = 0U; /* clear INTSRE0 interrupt flag */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_UART0_Send -* Description : This function sends UART0 data. -* Arguments : tx_buf - -* transfer buffer pointer -* tx_num - -* buffer size -* Return Value : status - -* MD_OK or MD_ARGERROR -***********************************************************************************************************************/ -MD_STATUS R_Config_UART0_Send(uint8_t * const tx_buf, uint16_t tx_num) -{ - MD_STATUS status = MD_OK; - - if (tx_num < 1U) - { - status = MD_ARGERROR; - } - else - { - gp_uart0_tx_address = tx_buf; - g_uart0_tx_count = tx_num; - STMK0 = 1U; /* disable INTST0 interrupt */ - TXD0 = *gp_uart0_tx_address; - gp_uart0_tx_address++; - g_uart0_tx_count--; - STMK0 = 0U; /* enable INTST0 interrupt */ - } - - return (status); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_UART0_Receive -* Description : This function receives UART0 data. -* Arguments : rx_buf - -* receive buffer pointer -* rx_num - -* buffer size -* Return Value : status - -* MD_OK or MD_ARGERROR -***********************************************************************************************************************/ -MD_STATUS R_Config_UART0_Receive(uint8_t * const rx_buf, uint16_t rx_num) -{ - MD_STATUS status = MD_OK; - - if (rx_num < 1U) - { - status = MD_ARGERROR; - } - else - { - g_uart0_rx_count = 0U; - g_uart0_rx_length = rx_num; - gp_uart0_rx_address = rx_buf; - } - - return (status); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_UART0_Loopback_Enable -* Description : This function enables the UART0 loopback function. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_UART0_Loopback_Enable(void) -{ - ULBS0 = 1U; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_UART0_Loopback_Disable -* Description : This function disables the UART0 loopback function. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_UART0_Loopback_Disable(void) -{ - ULBS0 = 0U; -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_UART0.c +* Version : 1.2.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_UART0. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_UART0.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +volatile uint8_t * gp_uart0_tx_address; /* uart0 transmit buffer address */ +volatile uint16_t g_uart0_tx_count; /* uart0 transmit data number */ +volatile uint8_t * gp_uart0_rx_address; /* uart0 receive buffer address */ +volatile uint16_t g_uart0_rx_count; /* uart0 receive data number */ +uint16_t g_uart0_rx_length; /* uart0 receive data length */ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_UART0_Create +* Description : This function initializes the UART0 module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_UART0_Create(void) +{ + SPS0 &= _00F0_SAU_CK00_CLEAR; + SPS0 |= _0004_SAU_CK00_FCLK_4; + ST0 |= (_0002_SAU_CH1_STOP_TRG_ON | _0001_SAU_CH0_STOP_TRG_ON); + STMK0 = 1U; /* disable INTST0 interrupt */ + STIF0 = 0U; /* clear INTST0 interrupt flag */ + SRMK0 = 1U; /* disable INTSR0 interrupt */ + SRIF0 = 0U; /* clear INTSR0 interrupt flag */ + SREMK0 = 1U; /* disable INTSRE0 interrupt */ + SREIF0 = 0U; /* clear INTSRE0 interrupt flag */ + /* Set INTST0 low priority */ + STPR10 = 1U; + STPR00 = 1U; + /* Set INTSR0 low priority */ + SRPR10 = 1U; + SRPR00 = 1U; + /* Set INTSRE0 low priority */ + SREPR10 = 1U; + SREPR00 = 1U; + SMR00 = _0020_SAU_SMRMN_INITIALVALUE | _0000_SAU_CLOCK_SELECT_CK00 | _0000_SAU_TRIGGER_SOFTWARE | + _0002_SAU_MODE_UART | _0000_SAU_TRANSFER_END; + SCR00 = _0004_SAU_SCRMN_INITIALVALUE | _8000_SAU_TRANSMISSION | _0000_SAU_INTSRE_MASK | _0000_SAU_PARITY_NONE | + _0080_SAU_LSB | _0010_SAU_STOP_1 | _0003_SAU_LENGTH_8; + SDR00 = _1000_SAU0_CH0_TRANSMIT_DIVISOR; + NFEN0 |= _01_SAU_RXD0_FILTER_ON; + SIR01 = _0004_SAU_SIRMN_FECTMN | _0002_SAU_SIRMN_PECTMN | _0001_SAU_SIRMN_OVCTMN; /* clear error flag */ + SMR01 = _0020_SAU_SMRMN_INITIALVALUE | _0000_SAU_CLOCK_SELECT_CK00 | _0100_SAU_TRIGGER_RXD | _0000_SAU_EDGE_FALL | + _0002_SAU_MODE_UART | _0000_SAU_TRANSFER_END; + SCR01 = _0004_SAU_SCRMN_INITIALVALUE | _4000_SAU_RECEPTION | _0400_SAU_INTSRE_ENABLE | _0000_SAU_PARITY_NONE | + _0080_SAU_LSB | _0010_SAU_STOP_1 | _0003_SAU_LENGTH_8; + SDR01 = _1000_SAU0_CH1_RECEIVE_DIVISOR; + SO0 |= _0001_SAU_CH0_DATA_OUTPUT_1; + SOL0 |= _0000_SAU_CHANNEL0_NORMAL; /* output level normal */ + SOE0 |= _0001_SAU_CH0_OUTPUT_ENABLE; /* enable UART0 output */ + /* Set TxD0 pin */ + // 2022/11/17 removed by KAD pin settings are done by Set_SerialPort +// PMCT1 &= 0xFBU; +// PFOE1 |= 0x01U; +// P1 |= 0x04U; +// PM1 &= 0xFBU; + /* Set RxD0 pin */ +// PMCT1 &= 0xFDU; +// PM1 |= 0x02U; + + R_Config_UART0_Create_UserInit(); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_UART0_Start +* Description : This function starts UART0 module operation. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_UART0_Start(void) +{ + SO0 |= _0001_SAU_CH0_DATA_OUTPUT_1; /* output level normal */ + SOE0 |= _0001_SAU_CH0_OUTPUT_ENABLE; /* enable UART0 output */ + SS0 |= (_0002_SAU_CH1_START_TRG_ON | _0001_SAU_CH0_START_TRG_ON); /* enable UART0 receive and transmit */ + STIF0 = 0U; /* clear INTST0 interrupt flag */ + SRIF0 = 0U; /* clear INTSR0 interrupt flag */ + SREIF0 = 0U; /* clear INTSRE0 interrupt flag */ + STMK0 = 0U; /* enable INTST0 interrupt */ + SRMK0 = 0U; /* enable INTSR0 interrupt */ + SREMK0 = 0U; /* enable INTSRE0 interrupt */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_UART0_Stop +* Description : This function stops UART0 module operation. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_UART0_Stop(void) +{ + STMK0 = 1U; /* disable INTST0 interrupt */ + SRMK0 = 1U; /* disable INTSR0 interrupt */ + SREMK0 = 1U; /* disable INTSRE0 interrupt */ + ST0 |= (_0002_SAU_CH1_STOP_TRG_ON | _0001_SAU_CH0_STOP_TRG_ON); + SOE0 &= (uint16_t)~_0001_SAU_CH0_OUTPUT_ENABLE; /* disable UART0 output */ + STIF0 = 0U; /* clear INTST0 interrupt flag */ + SRIF0 = 0U; /* clear INTSR0 interrupt flag */ + SREIF0 = 0U; /* clear INTSRE0 interrupt flag */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_UART0_Send +* Description : This function sends UART0 data. +* Arguments : tx_buf - +* transfer buffer pointer +* tx_num - +* buffer size +* Return Value : status - +* MD_OK or MD_ARGERROR +***********************************************************************************************************************/ +MD_STATUS R_Config_UART0_Send(uint8_t * const tx_buf, uint16_t tx_num) +{ + MD_STATUS status = MD_OK; + + if (tx_num < 1U) + { + status = MD_ARGERROR; + } + else + { + gp_uart0_tx_address = tx_buf; + g_uart0_tx_count = tx_num; + STMK0 = 1U; /* disable INTST0 interrupt */ + TXD0 = *gp_uart0_tx_address; + gp_uart0_tx_address++; + g_uart0_tx_count--; + STMK0 = 0U; /* enable INTST0 interrupt */ + } + + return (status); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_UART0_Receive +* Description : This function receives UART0 data. +* Arguments : rx_buf - +* receive buffer pointer +* rx_num - +* buffer size +* Return Value : status - +* MD_OK or MD_ARGERROR +***********************************************************************************************************************/ +MD_STATUS R_Config_UART0_Receive(uint8_t * const rx_buf, uint16_t rx_num) +{ + MD_STATUS status = MD_OK; + + if (rx_num < 1U) + { + status = MD_ARGERROR; + } + else + { + g_uart0_rx_count = 0U; + g_uart0_rx_length = rx_num; + gp_uart0_rx_address = rx_buf; + } + + return (status); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_UART0_Loopback_Enable +* Description : This function enables the UART0 loopback function. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_UART0_Loopback_Enable(void) +{ + ULBS0 = 1U; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_UART0_Loopback_Disable +* Description : This function disables the UART0 loopback function. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_UART0_Loopback_Disable(void) +{ + ULBS0 = 0U; +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_UART0/Config_UART0.h b/cores/rl78g22/smc_gen/Config_UART0/Config_UART0.h index 93b8bd0..eb8b6c9 100644 --- a/cores/rl78g22/smc_gen/Config_UART0/Config_UART0.h +++ b/cores/rl78g22/smc_gen/Config_UART0/Config_UART0.h @@ -1,63 +1,63 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_UART0.h -* Version : 1.2.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_UART0. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_UART0_H -#define CFG_Config_UART0_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_sau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _1000_SAU0_CH0_TRANSMIT_DIVISOR (0x1000U) -#define _1000_SAU0_CH1_RECEIVE_DIVISOR (0x1000U) - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_UART0_Create (void); -void R_Config_UART0_Start (void); -void R_Config_UART0_Stop (void); -MD_STATUS R_Config_UART0_Send (uint8_t * const tx_buf, uint16_t tx_num); -MD_STATUS R_Config_UART0_Receive (uint8_t * const rx_buf, uint16_t rx_num); -void R_Config_UART0_Loopback_Enable (void); -void R_Config_UART0_Loopback_Disable (void); -void R_Config_UART0_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_UART0.h +* Version : 1.2.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_UART0. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef CFG_Config_UART0_H +#define CFG_Config_UART0_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_sau.h" + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ +#define _1000_SAU0_CH0_TRANSMIT_DIVISOR (0x1000U) +#define _1000_SAU0_CH1_RECEIVE_DIVISOR (0x1000U) + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_Config_UART0_Create (void); +void R_Config_UART0_Start (void); +void R_Config_UART0_Stop (void); +MD_STATUS R_Config_UART0_Send (uint8_t * const tx_buf, uint16_t tx_num); +MD_STATUS R_Config_UART0_Receive (uint8_t * const rx_buf, uint16_t rx_num); +void R_Config_UART0_Loopback_Enable (void); +void R_Config_UART0_Loopback_Disable (void); +void R_Config_UART0_Create_UserInit (void); +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/Config_UART0/Config_UART0_user.c b/cores/rl78g22/smc_gen/Config_UART0/Config_UART0_user.c index cdac39c..1025c6c 100644 --- a/cores/rl78g22/smc_gen/Config_UART0/Config_UART0_user.c +++ b/cores/rl78g22/smc_gen/Config_UART0/Config_UART0_user.c @@ -1,197 +1,198 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_UART0_user.c -* Version : 1.2.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_UART0. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_UART0.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -extern volatile uint8_t * gp_uart0_tx_address; /* uart0 transmit buffer address */ -extern volatile uint16_t g_uart0_tx_count; /* uart0 transmit data number */ -extern volatile uint8_t * gp_uart0_rx_address; /* uart0 receive buffer address */ -extern volatile uint16_t g_uart0_rx_count; /* uart0 receive data number */ -extern uint16_t g_uart0_rx_length; /* uart0 receive data length */ -/* Start user code for global. Do not edit comment generated here */ -void Set_Char_Serial_to_buf(uint8_t chn); -void Set_Char_Serial_from_buf(uint8_t chn); -extern fInterruptFunc_t uart_receive_callback_table[3] __attribute__((weak)); -extern fInterruptFunc_t uart_transmit_callback_table[3] __attribute__((weak)); -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_UART0_Create_UserInit -* Description : This function adds user code after initializing UART0. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_UART0_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART0_callback_sendend -* Description : This function is a callback function when UART0 finishes transmission. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_UART0_callback_sendend(void) -{ - /* Start user code for r_Config_UART0_callback_sendend. Do not edit comment generated here */ - - Set_Char_Serial_from_buf(0); - if(0 != uart_transmit_callback_table[0]) - { - (*uart_transmit_callback_table[0])(); - } - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART0_callback_receiveend -* Description : This function is a callback function when UART0 finishes reception. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_UART0_callback_receiveend(void) -{ - /* Start user code for r_Config_UART0_callback_receiveend. Do not edit comment generated here */ Set_Char_Serial_to_buf(0); -// (*uart_receive_callback_table[0])(); - if(0 != uart_receive_callback_table[0]) - { - (*uart_receive_callback_table[0])(); - } - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART0_callback_error -* Description : This function is a callback function when UART0 reception error occurs. -* Arguments : err_type - -* error type info -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_UART0_callback_error(uint8_t err_type) -{ - /* Start user code for r_Config_UART0_callback_error. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART0_callback_softwareoverrun -* Description : This function is a callback when UART0 receives an overflow data. -* Arguments : rx_data - -* receive data -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_UART0_callback_softwareoverrun(uint16_t rx_data) -{ - /* Start user code for r_Config_UART0_callback_softwareoverrun. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART0_interrupt_send -* Description : This function is UART0 send interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_UART0_interrupt_send(void) -{ - if (g_uart0_tx_count > 0U) - { - TXD0 = *gp_uart0_tx_address; - gp_uart0_tx_address++; - g_uart0_tx_count--; - } - else - { - r_Config_UART0_callback_sendend(); - } -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART0_interrupt_receive -* Description : This function is UART0 receive interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_UART0_interrupt_receive(void) -{ - uint8_t rx_data; - - rx_data = RXD0; - - if (g_uart0_rx_length > g_uart0_rx_count) - { - *gp_uart0_rx_address = rx_data; - gp_uart0_rx_address++; - g_uart0_rx_count++; - - if (g_uart0_rx_length == g_uart0_rx_count) - { - r_Config_UART0_callback_receiveend(); - } - } - else - { - r_Config_UART0_callback_softwareoverrun(rx_data); - } -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART0_interrupt_error -* Description : This function is UART0 error interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_UART0_interrupt_error(void) -{ - uint8_t err_type; - - *gp_uart0_rx_address = RXD0; - err_type = (uint8_t)(SSR01 & 0x0007U); - SIR01 = (uint16_t)err_type; - r_Config_UART0_callback_error(err_type); -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_UART0_user.c +* Version : 1.2.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_UART0. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_UART0.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +extern volatile uint8_t * gp_uart0_tx_address; /* uart0 transmit buffer address */ +extern volatile uint16_t g_uart0_tx_count; /* uart0 transmit data number */ +extern volatile uint8_t * gp_uart0_rx_address; /* uart0 receive buffer address */ +extern volatile uint16_t g_uart0_rx_count; /* uart0 receive data number */ +extern uint16_t g_uart0_rx_length; /* uart0 receive data length */ +/* Start user code for global. Do not edit comment generated here */ +void Set_Char_Serial_to_buf(uint8_t chn); +void Set_Char_Serial_from_buf(uint8_t chn); +extern fInterruptFunc_t uart_receive_callback_table[3] __attribute__((weak)); +extern fInterruptFunc_t uart_transmit_callback_table[3] __attribute__((weak)); +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_UART0_Create_UserInit +* Description : This function adds user code after initializing UART0. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_UART0_Create_UserInit(void) +{ + /* Start user code for user init. Do not edit comment generated here */ + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART0_callback_sendend +* Description : This function is a callback function when UART0 finishes transmission. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_UART0_callback_sendend(void) +{ + /* Start user code for r_Config_UART0_callback_sendend. Do not edit comment generated here */ + Set_Char_Serial_from_buf(0); + if(0 != uart_transmit_callback_table[0]) + { + (*uart_transmit_callback_table[0])(); + } + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART0_callback_receiveend +* Description : This function is a callback function when UART0 finishes reception. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_UART0_callback_receiveend(void) +{ + /* Start user code for r_Config_UART0_callback_receiveend. Do not edit comment generated here */ + Set_Char_Serial_to_buf(0); + if(0 != uart_receive_callback_table[0]) + { + (*uart_receive_callback_table[0])(); + } + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART0_callback_error +* Description : This function is a callback function when UART0 reception error occurs. +* Arguments : err_type - +* error type info +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_UART0_callback_error(uint8_t err_type) +{ + /* Start user code for r_Config_UART0_callback_error. Do not edit comment generated here */ + (void)err_type; //Warning measures + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART0_callback_softwareoverrun +* Description : This function is a callback when UART0 receives an overflow data. +* Arguments : rx_data - +* receive data +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_UART0_callback_softwareoverrun(uint16_t rx_data) +{ + /* Start user code for r_Config_UART0_callback_softwareoverrun. Do not edit comment generated here */ + (void)rx_data; //Warning measures + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART0_interrupt_send +* Description : This function is UART0 send interrupt service routine. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_UART0_interrupt_send(void) +{ + if (g_uart0_tx_count > 0U) + { + TXD0 = *gp_uart0_tx_address; + gp_uart0_tx_address++; + g_uart0_tx_count--; + } + else + { + r_Config_UART0_callback_sendend(); + } +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART0_interrupt_receive +* Description : This function is UART0 receive interrupt service routine. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_UART0_interrupt_receive(void) +{ + uint8_t rx_data; + + rx_data = RXD0; + + if (g_uart0_rx_length > g_uart0_rx_count) + { + *gp_uart0_rx_address = rx_data; + gp_uart0_rx_address++; + g_uart0_rx_count++; + + if (g_uart0_rx_length == g_uart0_rx_count) + { + r_Config_UART0_callback_receiveend(); + } + } + else + { + r_Config_UART0_callback_softwareoverrun(rx_data); + } +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART0_interrupt_error +* Description : This function is UART0 error interrupt service routine. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_UART0_interrupt_error(void) +{ + uint8_t err_type; + + *gp_uart0_rx_address = RXD0; + err_type = (uint8_t)(SSR01 & 0x0007U); + SIR01 = (uint16_t)err_type; + r_Config_UART0_callback_error(err_type); +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_UART1/Config_UART1.c b/cores/rl78g22/smc_gen/Config_UART1/Config_UART1.c index 1443e0f..9903484 100644 --- a/cores/rl78g22/smc_gen/Config_UART1/Config_UART1.c +++ b/cores/rl78g22/smc_gen/Config_UART1/Config_UART1.c @@ -1,227 +1,227 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_UART1.c -* Version : 1.2.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_UART1. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_UART1.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -volatile uint8_t * gp_uart1_tx_address; /* uart1 transmit buffer address */ -volatile uint16_t g_uart1_tx_count; /* uart1 transmit data number */ -volatile uint8_t * gp_uart1_rx_address; /* uart1 receive buffer address */ -volatile uint16_t g_uart1_rx_count; /* uart1 receive data number */ -uint16_t g_uart1_rx_length; /* uart1 receive data length */ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_UART1_Create -* Description : This function initializes the UART1 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_UART1_Create(void) -{ - SPS0 &= _000F_SAU_CK01_CLEAR; - SPS0 |= _0040_SAU_CK01_FCLK_4; - ST0 |= (_0008_SAU_CH3_STOP_TRG_ON | _0004_SAU_CH2_STOP_TRG_ON); - STMK1 = 1U; /* disable INTST1 interrupt */ - STIF1 = 0U; /* clear INTST1 interrupt flag */ - SRMK1 = 1U; /* disable INTSR1 interrupt */ - SRIF1 = 0U; /* clear INTSR1 interrupt flag */ - SREMK1 = 1U; /* disable INTSRE1 interrupt */ - SREIF1 = 0U; /* clear INTSRE1 interrupt flag */ - /* Set INTST1 low priority */ - STPR11 = 1U; - STPR01 = 1U; - /* Set INTSR1 low priority */ - SRPR11 = 1U; - SRPR01 = 1U; - /* Set INTSRE1 low priority */ - SREPR11 = 1U; - SREPR01 = 1U; - SMR02 = _0020_SAU_SMRMN_INITIALVALUE | _8000_SAU_CLOCK_SELECT_CK01 | _0000_SAU_TRIGGER_SOFTWARE | - _0002_SAU_MODE_UART | _0000_SAU_TRANSFER_END; - SCR02 = _0004_SAU_SCRMN_INITIALVALUE | _8000_SAU_TRANSMISSION | _0000_SAU_INTSRE_MASK | _0000_SAU_PARITY_NONE | - _0080_SAU_LSB | _0010_SAU_STOP_1 | _0003_SAU_LENGTH_8; - SDR02 = _1000_SAU0_CH2_TRANSMIT_DIVISOR; - NFEN0 |= _04_SAU_RXD1_FILTER_ON; - SIR03 = _0004_SAU_SIRMN_FECTMN | _0002_SAU_SIRMN_PECTMN | _0001_SAU_SIRMN_OVCTMN; /* clear error flag */ - SMR03 = _0020_SAU_SMRMN_INITIALVALUE | _8000_SAU_CLOCK_SELECT_CK01 | _0100_SAU_TRIGGER_RXD | _0000_SAU_EDGE_FALL | - _0002_SAU_MODE_UART | _0000_SAU_TRANSFER_END; - SCR03 = _0004_SAU_SCRMN_INITIALVALUE | _4000_SAU_RECEPTION | _0400_SAU_INTSRE_ENABLE | _0000_SAU_PARITY_NONE | - _0080_SAU_LSB | _0010_SAU_STOP_1 | _0003_SAU_LENGTH_8; - SDR03 = _1000_SAU0_CH3_RECEIVE_DIVISOR; - SO0 |= _0004_SAU_CH2_DATA_OUTPUT_1; - SOL0 |= _0000_SAU_CHANNEL2_NORMAL; /* output level normal */ - SOE0 |= _0004_SAU_CH2_OUTPUT_ENABLE; /* enable UART1 output */ - /* Set TxD1 pin */ -// 2022/11/17 removed by KAD pin settings are done by Set_SerialPort -// PMCT0 &= 0xFEU; -// P0 |= 0x01U; -// PM0 &= 0xFEU; - /* Set RxD1 pin */ -// PMCT0 &= 0xFDU; -// PM0 |= 0x02U; - - R_Config_UART1_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_UART1_Start -* Description : This function starts UART1 module operation. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_UART1_Start(void) -{ - SO0 |= _0004_SAU_CH2_DATA_OUTPUT_1; /* output level normal */ - SOE0 |= _0004_SAU_CH2_OUTPUT_ENABLE; /* enable UART1 output */ - SS0 |= (_0008_SAU_CH3_START_TRG_ON | _0004_SAU_CH2_START_TRG_ON); /* enable UART1 receive and transmit */ - STIF1 = 0U; /* clear INTST1 interrupt flag */ - SRIF1 = 0U; /* clear INTSR1 interrupt flag */ - SREIF1 = 0U; /* clear INTSRE1 interrupt flag */ - STMK1 = 0U; /* enable INTST1 interrupt */ - SRMK1 = 0U; /* enable INTSR1 interrupt */ - SREMK1 = 0U; /* enable INTSRE1 interrupt */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_UART1_Stop -* Description : This function stops UART1 module operation. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_UART1_Stop(void) -{ - STMK1 = 1U; /* disable INTST1 interrupt */ - SRMK1 = 1U; /* disable INTSR1 interrupt */ - SREMK1 = 1U; /* disable INTSRE1 interrupt */ - ST0 |= (_0008_SAU_CH3_STOP_TRG_ON | _0004_SAU_CH2_STOP_TRG_ON); - SOE0 &= (uint16_t)~_0004_SAU_CH2_OUTPUT_ENABLE; /* disable UART1 output */ - STIF1 = 0U; /* clear INTST1 interrupt flag */ - SRIF1 = 0U; /* clear INTSR1 interrupt flag */ - SREIF1 = 0U; /* clear INTSRE1 interrupt flag */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_UART1_Send -* Description : This function sends UART1 data. -* Arguments : tx_buf - -* transfer buffer pointer -* tx_num - -* buffer size -* Return Value : status - -* MD_OK or MD_ARGERROR -***********************************************************************************************************************/ -MD_STATUS R_Config_UART1_Send(uint8_t * const tx_buf, uint16_t tx_num) -{ - MD_STATUS status = MD_OK; - - if (tx_num < 1U) - { - status = MD_ARGERROR; - } - else - { - gp_uart1_tx_address = tx_buf; - g_uart1_tx_count = tx_num; - STMK1 = 1U; /* disable INTST1 interrupt */ - TXD1 = *gp_uart1_tx_address; - gp_uart1_tx_address++; - g_uart1_tx_count--; - STMK1 = 0U; /* enable INTST1 interrupt */ - } - - return (status); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_UART1_Receive -* Description : This function receives UART1 data. -* Arguments : rx_buf - -* receive buffer pointer -* rx_num - -* buffer size -* Return Value : status - -* MD_OK or MD_ARGERROR -***********************************************************************************************************************/ -MD_STATUS R_Config_UART1_Receive(uint8_t * const rx_buf, uint16_t rx_num) -{ - MD_STATUS status = MD_OK; - - if (rx_num < 1U) - { - status = MD_ARGERROR; - } - else - { - g_uart1_rx_count = 0U; - g_uart1_rx_length = rx_num; - gp_uart1_rx_address = rx_buf; - } - - return (status); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_UART1_Loopback_Enable -* Description : This function enables the UART1 loopback function. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_UART1_Loopback_Enable(void) -{ - ULBS1 = 1U; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_UART1_Loopback_Disable -* Description : This function disables the UART1 loopback function. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_UART1_Loopback_Disable(void) -{ - ULBS1 = 0U; -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_UART1.c +* Version : 1.2.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_UART1. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_UART1.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +volatile uint8_t * gp_uart1_tx_address; /* uart1 transmit buffer address */ +volatile uint16_t g_uart1_tx_count; /* uart1 transmit data number */ +volatile uint8_t * gp_uart1_rx_address; /* uart1 receive buffer address */ +volatile uint16_t g_uart1_rx_count; /* uart1 receive data number */ +uint16_t g_uart1_rx_length; /* uart1 receive data length */ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_UART1_Create +* Description : This function initializes the UART1 module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_UART1_Create(void) +{ + SPS0 &= _000F_SAU_CK01_CLEAR; + SPS0 |= _0040_SAU_CK01_FCLK_4; + ST0 |= (_0008_SAU_CH3_STOP_TRG_ON | _0004_SAU_CH2_STOP_TRG_ON); + STMK1 = 1U; /* disable INTST1 interrupt */ + STIF1 = 0U; /* clear INTST1 interrupt flag */ + SRMK1 = 1U; /* disable INTSR1 interrupt */ + SRIF1 = 0U; /* clear INTSR1 interrupt flag */ + SREMK1 = 1U; /* disable INTSRE1 interrupt */ + SREIF1 = 0U; /* clear INTSRE1 interrupt flag */ + /* Set INTST1 low priority */ + STPR11 = 1U; + STPR01 = 1U; + /* Set INTSR1 low priority */ + SRPR11 = 1U; + SRPR01 = 1U; + /* Set INTSRE1 low priority */ + SREPR11 = 1U; + SREPR01 = 1U; + SMR02 = _0020_SAU_SMRMN_INITIALVALUE | _8000_SAU_CLOCK_SELECT_CK01 | _0000_SAU_TRIGGER_SOFTWARE | + _0002_SAU_MODE_UART | _0000_SAU_TRANSFER_END; + SCR02 = _0004_SAU_SCRMN_INITIALVALUE | _8000_SAU_TRANSMISSION | _0000_SAU_INTSRE_MASK | _0000_SAU_PARITY_NONE | + _0080_SAU_LSB | _0010_SAU_STOP_1 | _0003_SAU_LENGTH_8; + SDR02 = _1000_SAU0_CH2_TRANSMIT_DIVISOR; + NFEN0 |= _04_SAU_RXD1_FILTER_ON; + SIR03 = _0004_SAU_SIRMN_FECTMN | _0002_SAU_SIRMN_PECTMN | _0001_SAU_SIRMN_OVCTMN; /* clear error flag */ + SMR03 = _0020_SAU_SMRMN_INITIALVALUE | _8000_SAU_CLOCK_SELECT_CK01 | _0100_SAU_TRIGGER_RXD | _0000_SAU_EDGE_FALL | + _0002_SAU_MODE_UART | _0000_SAU_TRANSFER_END; + SCR03 = _0004_SAU_SCRMN_INITIALVALUE | _4000_SAU_RECEPTION | _0400_SAU_INTSRE_ENABLE | _0000_SAU_PARITY_NONE | + _0080_SAU_LSB | _0010_SAU_STOP_1 | _0003_SAU_LENGTH_8; + SDR03 = _1000_SAU0_CH3_RECEIVE_DIVISOR; + SO0 |= _0004_SAU_CH2_DATA_OUTPUT_1; + SOL0 |= _0000_SAU_CHANNEL2_NORMAL; /* output level normal */ + SOE0 |= _0004_SAU_CH2_OUTPUT_ENABLE; /* enable UART1 output */ + /* Set TxD1 pin */ +// 2022/11/17 removed by KAD pin settings are done by Set_SerialPort +// PMCT0 &= 0xFEU; +// P0 |= 0x01U; +// PM0 &= 0xFEU; + /* Set RxD1 pin */ +// PMCT0 &= 0xFDU; +// PM0 |= 0x02U; + + R_Config_UART1_Create_UserInit(); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_UART1_Start +* Description : This function starts UART1 module operation. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_UART1_Start(void) +{ + SO0 |= _0004_SAU_CH2_DATA_OUTPUT_1; /* output level normal */ + SOE0 |= _0004_SAU_CH2_OUTPUT_ENABLE; /* enable UART1 output */ + SS0 |= (_0008_SAU_CH3_START_TRG_ON | _0004_SAU_CH2_START_TRG_ON); /* enable UART1 receive and transmit */ + STIF1 = 0U; /* clear INTST1 interrupt flag */ + SRIF1 = 0U; /* clear INTSR1 interrupt flag */ + SREIF1 = 0U; /* clear INTSRE1 interrupt flag */ + STMK1 = 0U; /* enable INTST1 interrupt */ + SRMK1 = 0U; /* enable INTSR1 interrupt */ + SREMK1 = 0U; /* enable INTSRE1 interrupt */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_UART1_Stop +* Description : This function stops UART1 module operation. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_UART1_Stop(void) +{ + STMK1 = 1U; /* disable INTST1 interrupt */ + SRMK1 = 1U; /* disable INTSR1 interrupt */ + SREMK1 = 1U; /* disable INTSRE1 interrupt */ + ST0 |= (_0008_SAU_CH3_STOP_TRG_ON | _0004_SAU_CH2_STOP_TRG_ON); + SOE0 &= (uint16_t)~_0004_SAU_CH2_OUTPUT_ENABLE; /* disable UART1 output */ + STIF1 = 0U; /* clear INTST1 interrupt flag */ + SRIF1 = 0U; /* clear INTSR1 interrupt flag */ + SREIF1 = 0U; /* clear INTSRE1 interrupt flag */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_UART1_Send +* Description : This function sends UART1 data. +* Arguments : tx_buf - +* transfer buffer pointer +* tx_num - +* buffer size +* Return Value : status - +* MD_OK or MD_ARGERROR +***********************************************************************************************************************/ +MD_STATUS R_Config_UART1_Send(uint8_t * const tx_buf, uint16_t tx_num) +{ + MD_STATUS status = MD_OK; + + if (tx_num < 1U) + { + status = MD_ARGERROR; + } + else + { + gp_uart1_tx_address = tx_buf; + g_uart1_tx_count = tx_num; + STMK1 = 1U; /* disable INTST1 interrupt */ + TXD1 = *gp_uart1_tx_address; + gp_uart1_tx_address++; + g_uart1_tx_count--; + STMK1 = 0U; /* enable INTST1 interrupt */ + } + + return (status); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_UART1_Receive +* Description : This function receives UART1 data. +* Arguments : rx_buf - +* receive buffer pointer +* rx_num - +* buffer size +* Return Value : status - +* MD_OK or MD_ARGERROR +***********************************************************************************************************************/ +MD_STATUS R_Config_UART1_Receive(uint8_t * const rx_buf, uint16_t rx_num) +{ + MD_STATUS status = MD_OK; + + if (rx_num < 1U) + { + status = MD_ARGERROR; + } + else + { + g_uart1_rx_count = 0U; + g_uart1_rx_length = rx_num; + gp_uart1_rx_address = rx_buf; + } + + return (status); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_UART1_Loopback_Enable +* Description : This function enables the UART1 loopback function. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_UART1_Loopback_Enable(void) +{ + ULBS1 = 1U; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_UART1_Loopback_Disable +* Description : This function disables the UART1 loopback function. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_UART1_Loopback_Disable(void) +{ + ULBS1 = 0U; +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_UART1/Config_UART1.h b/cores/rl78g22/smc_gen/Config_UART1/Config_UART1.h index f88648d..769d197 100644 --- a/cores/rl78g22/smc_gen/Config_UART1/Config_UART1.h +++ b/cores/rl78g22/smc_gen/Config_UART1/Config_UART1.h @@ -1,63 +1,63 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_UART1.h -* Version : 1.2.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_UART1. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_UART1_H -#define CFG_Config_UART1_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_sau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _1000_SAU0_CH2_TRANSMIT_DIVISOR (0x1000U) -#define _1000_SAU0_CH3_RECEIVE_DIVISOR (0x1000U) - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_UART1_Create (void); -void R_Config_UART1_Start (void); -void R_Config_UART1_Stop (void); -MD_STATUS R_Config_UART1_Send (uint8_t * const tx_buf, uint16_t tx_num); -MD_STATUS R_Config_UART1_Receive (uint8_t * const rx_buf, uint16_t rx_num); -void R_Config_UART1_Loopback_Enable (void); -void R_Config_UART1_Loopback_Disable (void); -void R_Config_UART1_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_UART1.h +* Version : 1.2.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_UART1. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef CFG_Config_UART1_H +#define CFG_Config_UART1_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_sau.h" + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ +#define _1000_SAU0_CH2_TRANSMIT_DIVISOR (0x1000U) +#define _1000_SAU0_CH3_RECEIVE_DIVISOR (0x1000U) + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_Config_UART1_Create (void); +void R_Config_UART1_Start (void); +void R_Config_UART1_Stop (void); +MD_STATUS R_Config_UART1_Send (uint8_t * const tx_buf, uint16_t tx_num); +MD_STATUS R_Config_UART1_Receive (uint8_t * const rx_buf, uint16_t rx_num); +void R_Config_UART1_Loopback_Enable (void); +void R_Config_UART1_Loopback_Disable (void); +void R_Config_UART1_Create_UserInit (void); +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/Config_UART1/Config_UART1_user.c b/cores/rl78g22/smc_gen/Config_UART1/Config_UART1_user.c index e6c501a..34e7420 100644 --- a/cores/rl78g22/smc_gen/Config_UART1/Config_UART1_user.c +++ b/cores/rl78g22/smc_gen/Config_UART1/Config_UART1_user.c @@ -1,196 +1,198 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_UART1_user.c -* Version : 1.2.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_UART1. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_UART1.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -extern volatile uint8_t * gp_uart1_tx_address; /* uart1 transmit buffer address */ -extern volatile uint16_t g_uart1_tx_count; /* uart1 transmit data number */ -extern volatile uint8_t * gp_uart1_rx_address; /* uart1 receive buffer address */ -extern volatile uint16_t g_uart1_rx_count; /* uart1 receive data number */ -extern uint16_t g_uart1_rx_length; /* uart1 receive data length */ -/* Start user code for global. Do not edit comment generated here */ -void Set_Char_Serial_to_buf(uint8_t chn); -void Set_Char_Serial_from_buf(uint8_t chn); -extern fInterruptFunc_t uart_receive_callback_table[3] __attribute__((weak)); -extern fInterruptFunc_t uart_transmit_callback_table[3] __attribute__((weak)); -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_UART1_Create_UserInit -* Description : This function adds user code after initializing UART1. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_UART1_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART1_callback_sendend -* Description : This function is a callback function when UART1 finishes transmission. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_UART1_callback_sendend(void) -{ - /* Start user code for r_Config_UART1_callback_sendend. Do not edit comment generated here */ - Set_Char_Serial_from_buf(1); - if(0 != uart_transmit_callback_table[1]) - { - (*uart_transmit_callback_table[1])(); - } - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART1_callback_receiveend -* Description : This function is a callback function when UART1 finishes reception. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_UART1_callback_receiveend(void) -{ - /* Start user code for r_Config_UART1_callback_receiveend. Do not edit comment generated here */ - Set_Char_Serial_to_buf(1); - if(0 != uart_receive_callback_table[1]) - { - (*uart_receive_callback_table[1])(); - } - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART1_callback_error -* Description : This function is a callback function when UART1 reception error occurs. -* Arguments : err_type - -* error type info -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_UART1_callback_error(uint8_t err_type) -{ - /* Start user code for r_Config_UART1_callback_error. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART1_callback_softwareoverrun -* Description : This function is a callback when UART1 receives an overflow data. -* Arguments : rx_data - -* receive data -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_UART1_callback_softwareoverrun(uint16_t rx_data) -{ - /* Start user code for r_Config_UART1_callback_softwareoverrun. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART1_interrupt_send -* Description : This function is UART1 send interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_UART1_interrupt_send(void) -{ - if (g_uart1_tx_count > 0U) - { - TXD1 = *gp_uart1_tx_address; - gp_uart1_tx_address++; - g_uart1_tx_count--; - } - else - { - r_Config_UART1_callback_sendend(); - } -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART1_interrupt_receive -* Description : This function is UART1 receive interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_UART1_interrupt_receive(void) -{ - uint8_t rx_data; - - rx_data = RXD1; - - if (g_uart1_rx_length > g_uart1_rx_count) - { - *gp_uart1_rx_address = rx_data; - gp_uart1_rx_address++; - g_uart1_rx_count++; - - if (g_uart1_rx_length == g_uart1_rx_count) - { - r_Config_UART1_callback_receiveend(); - } - } - else - { - r_Config_UART1_callback_softwareoverrun(rx_data); - } -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART1_interrupt_error -* Description : This function is UART1 error interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_UART1_interrupt_error(void) -{ - uint8_t err_type; - - *gp_uart1_rx_address = RXD1; - err_type = (uint8_t)(SSR03 & 0x0007U); - SIR03 = (uint16_t)err_type; - r_Config_UART1_callback_error(err_type); -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_UART1_user.c +* Version : 1.2.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_UART1. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_UART1.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +extern volatile uint8_t * gp_uart1_tx_address; /* uart1 transmit buffer address */ +extern volatile uint16_t g_uart1_tx_count; /* uart1 transmit data number */ +extern volatile uint8_t * gp_uart1_rx_address; /* uart1 receive buffer address */ +extern volatile uint16_t g_uart1_rx_count; /* uart1 receive data number */ +extern uint16_t g_uart1_rx_length; /* uart1 receive data length */ +/* Start user code for global. Do not edit comment generated here */ +void Set_Char_Serial_to_buf(uint8_t chn); +void Set_Char_Serial_from_buf(uint8_t chn); +extern fInterruptFunc_t uart_receive_callback_table[3] __attribute__((weak)); +extern fInterruptFunc_t uart_transmit_callback_table[3] __attribute__((weak)); +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_UART1_Create_UserInit +* Description : This function adds user code after initializing UART1. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_UART1_Create_UserInit(void) +{ + /* Start user code for user init. Do not edit comment generated here */ + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART1_callback_sendend +* Description : This function is a callback function when UART1 finishes transmission. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_UART1_callback_sendend(void) +{ + /* Start user code for r_Config_UART1_callback_sendend. Do not edit comment generated here */ + Set_Char_Serial_from_buf(1); + if(0 != uart_transmit_callback_table[1]) + { + (*uart_transmit_callback_table[1])(); + } + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART1_callback_receiveend +* Description : This function is a callback function when UART1 finishes reception. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_UART1_callback_receiveend(void) +{ + /* Start user code for r_Config_UART1_callback_receiveend. Do not edit comment generated here */ + Set_Char_Serial_to_buf(1); + if(0 != uart_receive_callback_table[1]) + { + (*uart_receive_callback_table[1])(); + } + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART1_callback_error +* Description : This function is a callback function when UART1 reception error occurs. +* Arguments : err_type - +* error type info +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_UART1_callback_error(uint8_t err_type) +{ + /* Start user code for r_Config_UART1_callback_error. Do not edit comment generated here */ + (void)err_type; //Warning measures + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART1_callback_softwareoverrun +* Description : This function is a callback when UART1 receives an overflow data. +* Arguments : rx_data - +* receive data +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_UART1_callback_softwareoverrun(uint16_t rx_data) +{ + /* Start user code for r_Config_UART1_callback_softwareoverrun. Do not edit comment generated here */ + (void)rx_data; //Warning measures + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART1_interrupt_send +* Description : This function is UART1 send interrupt service routine. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_UART1_interrupt_send(void) +{ + if (g_uart1_tx_count > 0U) + { + TXD1 = *gp_uart1_tx_address; + gp_uart1_tx_address++; + g_uart1_tx_count--; + } + else + { + r_Config_UART1_callback_sendend(); + } +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART1_interrupt_receive +* Description : This function is UART1 receive interrupt service routine. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_UART1_interrupt_receive(void) +{ + uint8_t rx_data; + + rx_data = RXD1; + + if (g_uart1_rx_length > g_uart1_rx_count) + { + *gp_uart1_rx_address = rx_data; + gp_uart1_rx_address++; + g_uart1_rx_count++; + + if (g_uart1_rx_length == g_uart1_rx_count) + { + r_Config_UART1_callback_receiveend(); + } + } + else + { + r_Config_UART1_callback_softwareoverrun(rx_data); + } +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART1_interrupt_error +* Description : This function is UART1 error interrupt service routine. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_UART1_interrupt_error(void) +{ + uint8_t err_type; + + *gp_uart1_rx_address = RXD1; + err_type = (uint8_t)(SSR03 & 0x0007U); + SIR03 = (uint16_t)err_type; + r_Config_UART1_callback_error(err_type); +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_UART2/Config_UART2.c b/cores/rl78g22/smc_gen/Config_UART2/Config_UART2.c index 968e5aa..6165eb3 100644 --- a/cores/rl78g22/smc_gen/Config_UART2/Config_UART2.c +++ b/cores/rl78g22/smc_gen/Config_UART2/Config_UART2.c @@ -1,226 +1,226 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_UART2.c -* Version : 1.2.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_UART2. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_UART2.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -volatile uint8_t * gp_uart2_tx_address; /* uart2 transmit buffer address */ -volatile uint16_t g_uart2_tx_count; /* uart2 transmit data number */ -volatile uint8_t * gp_uart2_rx_address; /* uart2 receive buffer address */ -volatile uint16_t g_uart2_rx_count; /* uart2 receive data number */ -uint16_t g_uart2_rx_length; /* uart2 receive data length */ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_UART2_Create -* Description : This function initializes the UART2 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_UART2_Create(void) -{ - SPS1 &= _00F0_SAU_CK00_CLEAR; - SPS1 |= _0004_SAU_CK00_FCLK_4; - ST1 |= (_0002_SAU_CH1_STOP_TRG_ON | _0001_SAU_CH0_STOP_TRG_ON); - STMK2 = 1U; /* disable INTST2 interrupt */ - STIF2 = 0U; /* clear INTST2 interrupt flag */ - SRMK2 = 1U; /* disable INTSR2 interrupt */ - SRIF2 = 0U; /* clear INTSR2 interrupt flag */ - SREMK2 = 1U; /* disable INTSRE2 interrupt */ - SREIF2 = 0U; /* clear INTSRE2 interrupt flag */ - /* Set INTST2 low priority */ - STPR12 = 1U; - STPR02 = 1U; - /* Set INTSR2 low priority */ - SRPR12 = 1U; - SRPR02 = 1U; - /* Set INTSRE2 low priority */ - SREPR12 = 1U; - SREPR02 = 1U; - SMR10 = _0020_SAU_SMRMN_INITIALVALUE | _0000_SAU_CLOCK_SELECT_CK00 | _0000_SAU_TRIGGER_SOFTWARE | - _0002_SAU_MODE_UART | _0000_SAU_TRANSFER_END; - SCR10 = _0004_SAU_SCRMN_INITIALVALUE | _8000_SAU_TRANSMISSION | _0000_SAU_INTSRE_MASK | _0000_SAU_PARITY_NONE | - _0080_SAU_LSB | _0010_SAU_STOP_1 | _0003_SAU_LENGTH_8; - SDR10 = _1000_SAU1_CH0_TRANSMIT_DIVISOR; - NFEN0 |= _10_SAU_RXD2_FILTER_ON; - SIR11 = _0004_SAU_SIRMN_FECTMN | _0002_SAU_SIRMN_PECTMN | _0001_SAU_SIRMN_OVCTMN; /* clear error flag */ - SMR11 = _0020_SAU_SMRMN_INITIALVALUE | _0000_SAU_CLOCK_SELECT_CK00 | _0100_SAU_TRIGGER_RXD | _0000_SAU_EDGE_FALL | - _0002_SAU_MODE_UART | _0000_SAU_TRANSFER_END; - SCR11 = _0004_SAU_SCRMN_INITIALVALUE | _4000_SAU_RECEPTION | _0400_SAU_INTSRE_ENABLE | _0000_SAU_PARITY_NONE | - _0080_SAU_LSB | _0010_SAU_STOP_1 | _0003_SAU_LENGTH_8; - SDR11 = _1000_SAU1_CH1_RECEIVE_DIVISOR; - SO1 |= _0001_SAU_CH0_DATA_OUTPUT_1; - SOL1 |= _0000_SAU_CHANNEL0_NORMAL; /* output level normal */ - SOE1 |= _0001_SAU_CH0_OUTPUT_ENABLE; /* enable UART2 output */ - /* Set TxD2 pin */ - PMCT1 &= 0xF7U; - P1 |= 0x08U; - PM1 &= 0xF7U; - /* Set RxD2 pin */ - PMCT1 &= 0xEFU; - PM1 |= 0x10U; - - R_Config_UART2_Create_UserInit(); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_UART2_Start -* Description : This function starts UART2 module operation. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_UART2_Start(void) -{ - SO1 |= _0001_SAU_CH0_DATA_OUTPUT_1; /* output level normal */ - SOE1 |= _0001_SAU_CH0_OUTPUT_ENABLE; /* enable UART2 output */ - SS1 |= (_0002_SAU_CH1_START_TRG_ON | _0001_SAU_CH0_START_TRG_ON); /* enable UART2 receive and transmit */ - STIF2 = 0U; /* clear INTST2 interrupt flag */ - SRIF2 = 0U; /* clear INTSR2 interrupt flag */ - SREIF2 = 0U; /* clear INTSRE2 interrupt flag */ - STMK2 = 0U; /* enable INTST2 interrupt */ - SRMK2 = 0U; /* enable INTSR2 interrupt */ - SREMK2 = 0U; /* enable INTSRE2 interrupt */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_UART2_Stop -* Description : This function stops UART2 module operation. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_UART2_Stop(void) -{ - STMK2 = 1U; /* disable INTST2 interrupt */ - SRMK2 = 1U; /* disable INTSR2 interrupt */ - SREMK2 = 1U; /* disable INTSRE2 interrupt */ - ST1 |= (_0002_SAU_CH1_STOP_TRG_ON | _0001_SAU_CH0_STOP_TRG_ON); - SOE1 &= (uint16_t)~_0001_SAU_CH0_OUTPUT_ENABLE; /* disable UART2 output */ - STIF2 = 0U; /* clear INTST2 interrupt flag */ - SRIF2 = 0U; /* clear INTSR2 interrupt flag */ - SREIF2 = 0U; /* clear INTSRE2 interrupt flag */ -} - -/*********************************************************************************************************************** -* Function Name: R_Config_UART2_Send -* Description : This function sends UART2 data. -* Arguments : tx_buf - -* transfer buffer pointer -* tx_num - -* buffer size -* Return Value : status - -* MD_OK or MD_ARGERROR -***********************************************************************************************************************/ -MD_STATUS R_Config_UART2_Send(uint8_t * const tx_buf, uint16_t tx_num) -{ - MD_STATUS status = MD_OK; - - if (tx_num < 1U) - { - status = MD_ARGERROR; - } - else - { - gp_uart2_tx_address = tx_buf; - g_uart2_tx_count = tx_num; - STMK2 = 1U; /* disable INTST2 interrupt */ - TXD2 = *gp_uart2_tx_address; - gp_uart2_tx_address++; - g_uart2_tx_count--; - STMK2 = 0U; /* enable INTST2 interrupt */ - } - - return (status); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_UART2_Receive -* Description : This function receives UART2 data. -* Arguments : rx_buf - -* receive buffer pointer -* rx_num - -* buffer size -* Return Value : status - -* MD_OK or MD_ARGERROR -***********************************************************************************************************************/ -MD_STATUS R_Config_UART2_Receive(uint8_t * const rx_buf, uint16_t rx_num) -{ - MD_STATUS status = MD_OK; - - if (rx_num < 1U) - { - status = MD_ARGERROR; - } - else - { - g_uart2_rx_count = 0U; - g_uart2_rx_length = rx_num; - gp_uart2_rx_address = rx_buf; - } - - return (status); -} - -/*********************************************************************************************************************** -* Function Name: R_Config_UART2_Loopback_Enable -* Description : This function enables the UART2 loopback function. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_UART2_Loopback_Enable(void) -{ - ULBS2 = 1U; -} - -/*********************************************************************************************************************** -* Function Name: R_Config_UART2_Loopback_Disable -* Description : This function disables the UART2 loopback function. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_UART2_Loopback_Disable(void) -{ - ULBS2 = 0U; -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_UART2.c +* Version : 1.2.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_UART2. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_UART2.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +volatile uint8_t * gp_uart2_tx_address; /* uart2 transmit buffer address */ +volatile uint16_t g_uart2_tx_count; /* uart2 transmit data number */ +volatile uint8_t * gp_uart2_rx_address; /* uart2 receive buffer address */ +volatile uint16_t g_uart2_rx_count; /* uart2 receive data number */ +uint16_t g_uart2_rx_length; /* uart2 receive data length */ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_UART2_Create +* Description : This function initializes the UART2 module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_UART2_Create(void) +{ + SPS1 &= _00F0_SAU_CK00_CLEAR; + SPS1 |= _0004_SAU_CK00_FCLK_4; + ST1 |= (_0002_SAU_CH1_STOP_TRG_ON | _0001_SAU_CH0_STOP_TRG_ON); + STMK2 = 1U; /* disable INTST2 interrupt */ + STIF2 = 0U; /* clear INTST2 interrupt flag */ + SRMK2 = 1U; /* disable INTSR2 interrupt */ + SRIF2 = 0U; /* clear INTSR2 interrupt flag */ + SREMK2 = 1U; /* disable INTSRE2 interrupt */ + SREIF2 = 0U; /* clear INTSRE2 interrupt flag */ + /* Set INTST2 low priority */ + STPR12 = 1U; + STPR02 = 1U; + /* Set INTSR2 low priority */ + SRPR12 = 1U; + SRPR02 = 1U; + /* Set INTSRE2 low priority */ + SREPR12 = 1U; + SREPR02 = 1U; + SMR10 = _0020_SAU_SMRMN_INITIALVALUE | _0000_SAU_CLOCK_SELECT_CK00 | _0000_SAU_TRIGGER_SOFTWARE | + _0002_SAU_MODE_UART | _0000_SAU_TRANSFER_END; + SCR10 = _0004_SAU_SCRMN_INITIALVALUE | _8000_SAU_TRANSMISSION | _0000_SAU_INTSRE_MASK | _0000_SAU_PARITY_NONE | + _0080_SAU_LSB | _0010_SAU_STOP_1 | _0003_SAU_LENGTH_8; + SDR10 = _1000_SAU1_CH0_TRANSMIT_DIVISOR; + NFEN0 |= _10_SAU_RXD2_FILTER_ON; + SIR11 = _0004_SAU_SIRMN_FECTMN | _0002_SAU_SIRMN_PECTMN | _0001_SAU_SIRMN_OVCTMN; /* clear error flag */ + SMR11 = _0020_SAU_SMRMN_INITIALVALUE | _0000_SAU_CLOCK_SELECT_CK00 | _0100_SAU_TRIGGER_RXD | _0000_SAU_EDGE_FALL | + _0002_SAU_MODE_UART | _0000_SAU_TRANSFER_END; + SCR11 = _0004_SAU_SCRMN_INITIALVALUE | _4000_SAU_RECEPTION | _0400_SAU_INTSRE_ENABLE | _0000_SAU_PARITY_NONE | + _0080_SAU_LSB | _0010_SAU_STOP_1 | _0003_SAU_LENGTH_8; + SDR11 = _1000_SAU1_CH1_RECEIVE_DIVISOR; + SO1 |= _0001_SAU_CH0_DATA_OUTPUT_1; + SOL1 |= _0000_SAU_CHANNEL0_NORMAL; /* output level normal */ + SOE1 |= _0001_SAU_CH0_OUTPUT_ENABLE; /* enable UART2 output */ + /* Set TxD2 pin */ + PMCT1 &= 0xF7U; + P1 |= 0x08U; + PM1 &= 0xF7U; + /* Set RxD2 pin */ + PMCT1 &= 0xEFU; + PM1 |= 0x10U; + + R_Config_UART2_Create_UserInit(); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_UART2_Start +* Description : This function starts UART2 module operation. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_UART2_Start(void) +{ + SO1 |= _0001_SAU_CH0_DATA_OUTPUT_1; /* output level normal */ + SOE1 |= _0001_SAU_CH0_OUTPUT_ENABLE; /* enable UART2 output */ + SS1 |= (_0002_SAU_CH1_START_TRG_ON | _0001_SAU_CH0_START_TRG_ON); /* enable UART2 receive and transmit */ + STIF2 = 0U; /* clear INTST2 interrupt flag */ + SRIF2 = 0U; /* clear INTSR2 interrupt flag */ + SREIF2 = 0U; /* clear INTSRE2 interrupt flag */ + STMK2 = 0U; /* enable INTST2 interrupt */ + SRMK2 = 0U; /* enable INTSR2 interrupt */ + SREMK2 = 0U; /* enable INTSRE2 interrupt */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_UART2_Stop +* Description : This function stops UART2 module operation. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_UART2_Stop(void) +{ + STMK2 = 1U; /* disable INTST2 interrupt */ + SRMK2 = 1U; /* disable INTSR2 interrupt */ + SREMK2 = 1U; /* disable INTSRE2 interrupt */ + ST1 |= (_0002_SAU_CH1_STOP_TRG_ON | _0001_SAU_CH0_STOP_TRG_ON); + SOE1 &= (uint16_t)~_0001_SAU_CH0_OUTPUT_ENABLE; /* disable UART2 output */ + STIF2 = 0U; /* clear INTST2 interrupt flag */ + SRIF2 = 0U; /* clear INTSR2 interrupt flag */ + SREIF2 = 0U; /* clear INTSRE2 interrupt flag */ +} + +/*********************************************************************************************************************** +* Function Name: R_Config_UART2_Send +* Description : This function sends UART2 data. +* Arguments : tx_buf - +* transfer buffer pointer +* tx_num - +* buffer size +* Return Value : status - +* MD_OK or MD_ARGERROR +***********************************************************************************************************************/ +MD_STATUS R_Config_UART2_Send(uint8_t * const tx_buf, uint16_t tx_num) +{ + MD_STATUS status = MD_OK; + + if (tx_num < 1U) + { + status = MD_ARGERROR; + } + else + { + gp_uart2_tx_address = tx_buf; + g_uart2_tx_count = tx_num; + STMK2 = 1U; /* disable INTST2 interrupt */ + TXD2 = *gp_uart2_tx_address; + gp_uart2_tx_address++; + g_uart2_tx_count--; + STMK2 = 0U; /* enable INTST2 interrupt */ + } + + return (status); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_UART2_Receive +* Description : This function receives UART2 data. +* Arguments : rx_buf - +* receive buffer pointer +* rx_num - +* buffer size +* Return Value : status - +* MD_OK or MD_ARGERROR +***********************************************************************************************************************/ +MD_STATUS R_Config_UART2_Receive(uint8_t * const rx_buf, uint16_t rx_num) +{ + MD_STATUS status = MD_OK; + + if (rx_num < 1U) + { + status = MD_ARGERROR; + } + else + { + g_uart2_rx_count = 0U; + g_uart2_rx_length = rx_num; + gp_uart2_rx_address = rx_buf; + } + + return (status); +} + +/*********************************************************************************************************************** +* Function Name: R_Config_UART2_Loopback_Enable +* Description : This function enables the UART2 loopback function. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_UART2_Loopback_Enable(void) +{ + ULBS2 = 1U; +} + +/*********************************************************************************************************************** +* Function Name: R_Config_UART2_Loopback_Disable +* Description : This function disables the UART2 loopback function. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_UART2_Loopback_Disable(void) +{ + ULBS2 = 0U; +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/Config_UART2/Config_UART2.h b/cores/rl78g22/smc_gen/Config_UART2/Config_UART2.h index a2bd968..0bf6a59 100644 --- a/cores/rl78g22/smc_gen/Config_UART2/Config_UART2.h +++ b/cores/rl78g22/smc_gen/Config_UART2/Config_UART2.h @@ -1,63 +1,63 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_UART2.h -* Version : 1.2.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_UART2. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef CFG_Config_UART2_H -#define CFG_Config_UART2_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_sau.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#define _1000_SAU1_CH0_TRANSMIT_DIVISOR (0x1000U) -#define _1000_SAU1_CH1_RECEIVE_DIVISOR (0x1000U) - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Config_UART2_Create (void); -void R_Config_UART2_Start (void); -void R_Config_UART2_Stop (void); -MD_STATUS R_Config_UART2_Send (uint8_t * const tx_buf, uint16_t tx_num); -MD_STATUS R_Config_UART2_Receive (uint8_t * const rx_buf, uint16_t rx_num); -void R_Config_UART2_Loopback_Enable (void); -void R_Config_UART2_Loopback_Disable (void); -void R_Config_UART2_Create_UserInit (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_UART2.h +* Version : 1.2.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_UART2. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef CFG_Config_UART2_H +#define CFG_Config_UART2_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_sau.h" + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ +#define _1000_SAU1_CH0_TRANSMIT_DIVISOR (0x1000U) +#define _1000_SAU1_CH1_RECEIVE_DIVISOR (0x1000U) + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_Config_UART2_Create (void); +void R_Config_UART2_Start (void); +void R_Config_UART2_Stop (void); +MD_STATUS R_Config_UART2_Send (uint8_t * const tx_buf, uint16_t tx_num); +MD_STATUS R_Config_UART2_Receive (uint8_t * const rx_buf, uint16_t rx_num); +void R_Config_UART2_Loopback_Enable (void); +void R_Config_UART2_Loopback_Disable (void); +void R_Config_UART2_Create_UserInit (void); +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/Config_UART2/Config_UART2_user.c b/cores/rl78g22/smc_gen/Config_UART2/Config_UART2_user.c index ecff62d..9031d56 100644 --- a/cores/rl78g22/smc_gen/Config_UART2/Config_UART2_user.c +++ b/cores/rl78g22/smc_gen/Config_UART2/Config_UART2_user.c @@ -1,196 +1,198 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : Config_UART2_user.c -* Version : 1.2.0 -* Device(s) : R7F102GGExFB -* Description : This file implements device driver for Config_UART2. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_UART2.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -extern volatile uint8_t * gp_uart2_tx_address; /* uart2 transmit buffer address */ -extern volatile uint16_t g_uart2_tx_count; /* uart2 transmit data number */ -extern volatile uint8_t * gp_uart2_rx_address; /* uart2 receive buffer address */ -extern volatile uint16_t g_uart2_rx_count; /* uart2 receive data number */ -extern uint16_t g_uart2_rx_length; /* uart2 receive data length */ -/* Start user code for global. Do not edit comment generated here */ -void Set_Char_Serial_to_buf(uint8_t chn); -void Set_Char_Serial_from_buf(uint8_t chn); -extern fInterruptFunc_t uart_receive_callback_table[3] __attribute__((weak)); -extern fInterruptFunc_t uart_transmit_callback_table[3] __attribute__((weak)); -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Config_UART2_Create_UserInit -* Description : This function adds user code after initializing UART2. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Config_UART2_Create_UserInit(void) -{ - /* Start user code for user init. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART2_callback_sendend -* Description : This function is a callback function when UART2 finishes transmission. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_UART2_callback_sendend(void) -{ - /* Start user code for r_Config_UART2_callback_sendend. Do not edit comment generated here */ - Set_Char_Serial_from_buf(2); - if(0 != uart_transmit_callback_table[2]) - { - (*uart_transmit_callback_table[2])(); - } - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART2_callback_receiveend -* Description : This function is a callback function when UART2 finishes reception. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_UART2_callback_receiveend(void) -{ - /* Start user code for r_Config_UART2_callback_receiveend. Do not edit comment generated here */ - Set_Char_Serial_to_buf(2); - if(0 != uart_receive_callback_table[2]) - { - (*uart_receive_callback_table[2])(); - } - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART2_callback_error -* Description : This function is a callback function when UART2 reception error occurs. -* Arguments : err_type - -* error type info -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_UART2_callback_error(uint8_t err_type) -{ - /* Start user code for r_Config_UART2_callback_error. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART2_callback_softwareoverrun -* Description : This function is a callback when UART2 receives an overflow data. -* Arguments : rx_data - -* receive data -* Return Value : None -***********************************************************************************************************************/ -static void r_Config_UART2_callback_softwareoverrun(uint16_t rx_data) -{ - /* Start user code for r_Config_UART2_callback_softwareoverrun. Do not edit comment generated here */ - /* End user code. Do not edit comment generated here */ -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART2_interrupt_send -* Description : This function is UART2 send interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_UART2_interrupt_send(void) -{ - if (g_uart2_tx_count > 0U) - { - TXD2 = *gp_uart2_tx_address; - gp_uart2_tx_address++; - g_uart2_tx_count--; - } - else - { - r_Config_UART2_callback_sendend(); - } -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART2_interrupt_receive -* Description : This function is UART2 receive interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_UART2_interrupt_receive(void) -{ - uint8_t rx_data; - - rx_data = RXD2; - - if (g_uart2_rx_length > g_uart2_rx_count) - { - *gp_uart2_rx_address = rx_data; - gp_uart2_rx_address++; - g_uart2_rx_count++; - - if (g_uart2_rx_length == g_uart2_rx_count) - { - r_Config_UART2_callback_receiveend(); - } - } - else - { - r_Config_UART2_callback_softwareoverrun(rx_data); - } -} - -/*********************************************************************************************************************** -* Function Name: r_Config_UART2_interrupt_error -* Description : This function is UART2 error interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_Config_UART2_interrupt_error(void) -{ - uint8_t err_type; - - *gp_uart2_rx_address = RXD2; - err_type = (uint8_t)(SSR11 & 0x0007U); - SIR11 = (uint16_t)err_type; - r_Config_UART2_callback_error(err_type); -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : Config_UART2_user.c +* Version : 1.2.0 +* Device(s) : R7F102GGExFB +* Description : This file implements device driver for Config_UART2. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_UART2.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +extern volatile uint8_t * gp_uart2_tx_address; /* uart2 transmit buffer address */ +extern volatile uint16_t g_uart2_tx_count; /* uart2 transmit data number */ +extern volatile uint8_t * gp_uart2_rx_address; /* uart2 receive buffer address */ +extern volatile uint16_t g_uart2_rx_count; /* uart2 receive data number */ +extern uint16_t g_uart2_rx_length; /* uart2 receive data length */ +/* Start user code for global. Do not edit comment generated here */ +void Set_Char_Serial_to_buf(uint8_t chn); +void Set_Char_Serial_from_buf(uint8_t chn); +extern fInterruptFunc_t uart_receive_callback_table[3] __attribute__((weak)); +extern fInterruptFunc_t uart_transmit_callback_table[3] __attribute__((weak)); +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Config_UART2_Create_UserInit +* Description : This function adds user code after initializing UART2. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Config_UART2_Create_UserInit(void) +{ + /* Start user code for user init. Do not edit comment generated here */ + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART2_callback_sendend +* Description : This function is a callback function when UART2 finishes transmission. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_UART2_callback_sendend(void) +{ + /* Start user code for r_Config_UART2_callback_sendend. Do not edit comment generated here */ + Set_Char_Serial_from_buf(2); + if(0 != uart_transmit_callback_table[2]) + { + (*uart_transmit_callback_table[2])(); + } + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART2_callback_receiveend +* Description : This function is a callback function when UART2 finishes reception. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_UART2_callback_receiveend(void) +{ + /* Start user code for r_Config_UART2_callback_receiveend. Do not edit comment generated here */ + Set_Char_Serial_to_buf(2); + if(0 != uart_receive_callback_table[2]) + { + (*uart_receive_callback_table[2])(); + } + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART2_callback_error +* Description : This function is a callback function when UART2 reception error occurs. +* Arguments : err_type - +* error type info +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_UART2_callback_error(uint8_t err_type) +{ + /* Start user code for r_Config_UART2_callback_error. Do not edit comment generated here */ + (void)err_type; //Warning measures + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART2_callback_softwareoverrun +* Description : This function is a callback when UART2 receives an overflow data. +* Arguments : rx_data - +* receive data +* Return Value : None +***********************************************************************************************************************/ +static void r_Config_UART2_callback_softwareoverrun(uint16_t rx_data) +{ + /* Start user code for r_Config_UART2_callback_softwareoverrun. Do not edit comment generated here */ + (void)rx_data; //Warning measures + /* End user code. Do not edit comment generated here */ +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART2_interrupt_send +* Description : This function is UART2 send interrupt service routine. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_UART2_interrupt_send(void) +{ + if (g_uart2_tx_count > 0U) + { + TXD2 = *gp_uart2_tx_address; + gp_uart2_tx_address++; + g_uart2_tx_count--; + } + else + { + r_Config_UART2_callback_sendend(); + } +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART2_interrupt_receive +* Description : This function is UART2 receive interrupt service routine. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_UART2_interrupt_receive(void) +{ + uint8_t rx_data; + + rx_data = RXD2; + + if (g_uart2_rx_length > g_uart2_rx_count) + { + *gp_uart2_rx_address = rx_data; + gp_uart2_rx_address++; + g_uart2_rx_count++; + + if (g_uart2_rx_length == g_uart2_rx_count) + { + r_Config_UART2_callback_receiveend(); + } + } + else + { + r_Config_UART2_callback_softwareoverrun(rx_data); + } +} + +/*********************************************************************************************************************** +* Function Name: r_Config_UART2_interrupt_error +* Description : This function is UART2 error interrupt service routine. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_Config_UART2_interrupt_error(void) +{ + uint8_t err_type; + + *gp_uart2_rx_address = RXD2; + err_type = (uint8_t)(SSR11 & 0x0007U); + SIR11 = (uint16_t)err_type; + r_Config_UART2_callback_error(err_type); +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/general/r_cg_ad.h b/cores/rl78g22/smc_gen/general/r_cg_ad.h index 9dd7559..ea1de2b 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_ad.h +++ b/cores/rl78g22/smc_gen/general/r_cg_ad.h @@ -1,164 +1,164 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_ad.h -* Version : 1.0.0 -* Device(s) : R7F102GGExFB -* Description : General header file for ADC peripheral. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef ADC_H -#define ADC_H - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ -/* - Peripheral Enable Register 0 (PER0) -*/ -/* Control of A/D converter input clock (ADCEN) */ -#define _00_AD_CLOCK_STOP (0x00U) /* stop supply of input clock */ -#define _20_AD_CLOCK_SUPPLY (0x20U) /* supply input clock */ - -/* - Peripheral Reset Control Register 0 (PRR0) -*/ -/* Reset control for A/D converters (ADCRES) */ -#define _00_AD_RESET_RELEASE (0x00U) /* released from the reset state */ -#define _20_AD_RESET_SET (0x20U) /* reset state */ - -/* - A/D Converter Mode Register 0 (ADM0) -*/ -/* A/D conversion operation control (ADCS) */ -#define _00_AD_CONVERSION_DISABLE (0x00U) /* disable A/D conversion operation control */ -#define _80_AD_CONVERSION_ENABLE (0x80U) /* enable A/D conversion operation control */ -/* Specification of the A/D conversion channel selection mode (ADMD) */ -#define _00_AD_OPERMODE_SELECT (0x00U) /* select operation mode */ -#define _40_AD_OPERMODE_SCAN (0x40U) /* scan operation mode */ -/* A/D conversion clock selection (FR2 - FR0) */ -#define _00_AD_CONVERSION_CLOCK_64 (0x00U) /* fCLK/64 */ -#define _08_AD_CONVERSION_CLOCK_32 (0x08U) /* fCLK/32 */ -#define _10_AD_CONVERSION_CLOCK_16 (0x10U) /* fCLK/16 */ -#define _18_AD_CONVERSION_CLOCK_8 (0x18U) /* fCLK/8 */ -#define _20_AD_CONVERSION_CLOCK_6 (0x20U) /* fCLK/6 */ -#define _28_AD_CONVERSION_CLOCK_5 (0x28U) /* fCLK/5 */ -#define _30_AD_CONVERSION_CLOCK_4 (0x30U) /* fCLK/4 */ -#define _38_AD_CONVERSION_CLOCK_2 (0x38U) /* fCLK/2 */ -/* Specification A/D conversion time mode (LV1, LV0) */ -#define _00_AD_TIME_MODE_NORMAL_1 (0x00U) /* normal 1 mode */ -#define _02_AD_TIME_MODE_NORMAL_2 (0x02U) /* normal 2 mode */ -#define _04_AD_TIME_MODE_LOWVOLTAGE_1 (0x04U) /* low-voltage 1 mode */ -#define _06_AD_TIME_MODE_LOWVOLTAGE_2 (0x06U) /* low-voltage 2 mode */ -/* A/D voltage comparator operation control (ADCE) */ -#define _00_AD_COMPARATOR_DISABLE (0x00U) /* disable comparator operation control */ -#define _01_AD_COMPARATOR_ENABLE (0x01U) /* enable comparator operation control */ - - -/* - Analog Input Channel Specification Register(ADS) -*/ -/* Specification of analog input channel(ADISS, ADS4 - ADS0) */ -/* Select mode */ -#define _00_AD_INPUT_CHANNEL_0 (0x00U) /* ANI0 */ -#define _01_AD_INPUT_CHANNEL_1 (0x01U) /* ANI1 */ -#define _02_AD_INPUT_CHANNEL_2 (0x02U) /* ANI2 */ -#define _03_AD_INPUT_CHANNEL_3 (0x03U) /* ANI3 */ -#define _04_AD_INPUT_CHANNEL_4 (0x04U) /* ANI4 */ -#define _05_AD_INPUT_CHANNEL_5 (0x05U) /* ANI5 */ -#define _06_AD_INPUT_CHANNEL_6 (0x06U) /* ANI6 */ -#define _07_AD_INPUT_CHANNEL_7 (0x07U) /* ANI7 */ -#define _10_AD_INPUT_CHANNEL_16 (0x10U) /* ANI16 */ -#define _11_AD_INPUT_CHANNEL_17 (0x11U) /* ANI17 */ -#define _12_AD_INPUT_CHANNEL_18 (0x12U) /* ANI18 */ -#define _13_AD_INPUT_CHANNEL_19 (0x13U) /* ANI19 */ -#define _1E_AD_INPUT_CTSUTSCAP (0x1EU) /* TSCAP voltage of the CTSU */ -#define _80_AD_INPUT_TEMPERSENSOR_0 (0x80U) /* temperature sensor output voltage */ -#define _81_AD_INPUT_INTERREFVOLT (0x81U) /* internal reference voltage */ -/* Scan mode */ -#define _00_AD_INPUT_CHANNEL_0_3 (0x00U) /* ANI0 - ANI3 */ -#define _01_AD_INPUT_CHANNEL_1_4 (0x01U) /* ANI1 - ANI4 */ -#define _02_AD_INPUT_CHANNEL_2_5 (0x02U) /* ANI2 - ANI5 */ -#define _03_AD_INPUT_CHANNEL_3_6 (0x03U) /* ANI3 - ANI6 */ -#define _04_AD_INPUT_CHANNEL_4_7 (0x04U) /* ANI4 - ANI7 */ - -/* - A/D Converter Mode Register 1 (ADM1) -*/ -/* Selection of the A/D conversion trigger mode (ADTMD1, ADTMD0) */ -#define _00_AD_TRIGGER_SOFTWARE (0x00U) /* software trigger mode */ -#define _80_AD_TRIGGER_HARDWARE_NOWAIT (0x80U) /* hardware trigger no-wait mode */ -#define _C0_AD_TRIGGER_HARDWARE_WAIT (0xC0U) /* hardware trigger wait mode */ -/* Specification of the A/D conversion mode (ADSCM)*/ -#define _00_AD_CONVMODE_CONSELECT (0x00U) /* sequential conversion mode */ -#define _20_AD_CONVMODE_ONESELECT (0x20U) /* one-shot conversion mode */ -/* Selection of the hardware trigger signal (ADTRS1, ADTRS0) */ -#define _00_AD_TRIGGER_INTTM01 (0x00U) /* end of timer channel 01 count or capture interrupt - signal (INTTM01) */ -#define _01_AD_TRIGGER_ELC (0x01U) /* event input from the ELC */ -#define _02_AD_TRIGGER_INTRTC (0x02U) /* realtime clock interrupt signal (INTRTC) */ -#define _03_AD_TRIGGER_ELCITL0 (0x03U) /* 32-bit interval timer interrupt signal (ELCITL0) */ - -/* - A/D Converter Mode Register 2 (ADM2) -*/ -/* Selection of the positive reference voltage source of the A/D converter (ADREFP1, ADREFP0) */ -#define _00_AD_POSITIVE_VDD (0x00U) /* use VDD as VREF(+) */ -#define _40_AD_POSITIVE_AVREFP (0x40U) /* use AVREFP as VREF(+) */ -#define _80_AD_POSITIVE_INTERVOLT (0x80U) /* use internal voltage as VREF(+) */ -#define _C0_AD_POSITIVE_DISCHARGE (0xC0U) /* discharge */ -#define _3F_AD_POSITIVE_CLEAR (0x3FU) /* clear ADREFP1 and ADREFP0 */ -/* Selection of the negative reference voltage of the A/D converter (ADREFM) */ -#define _00_AD_NEGATIVE_VSS (0x00U) /* use VSS as VREF(-) */ -#define _20_AD_NEGATIVE_AVREFM (0x20U) /* use AVREFM as VREF(-) */ -/* Checking the upper limit and lower limit conversion result values (ADRCK) */ -#define _00_AD_AREA_MODE_1 (0x00U) /* generates INTAD when ADLL <= ADCRH <= ADUL */ -#define _08_AD_AREA_MODE_2_3 (0x08U) /* generates INTAD when ADUL < ADCRH or ADLL > ADCRH */ -/* Specification of the SNOOZE mode (AWC) */ -#define _00_AD_WAKEUP_OFF (0x00U) /* do not use the SNOOZE mode function */ -#define _04_AD_WAKEUP_ON (0x04U) /* use the SNOOZE mode function */ -/* Selection of the A/D conversion resolution (ADTYP) */ -#define _00_AD_RESOLUTION_10BIT (0x00U) /* 10 bits */ -#define _01_AD_RESOLUTION_8BIT (0x01U) /* 8 bits */ - - -/* - A/D Test Register (ADTES) -*/ -/* A/D conversion target (ADTES1, ADTES0)*/ -#define _00_AD_NORMAL_INPUT (0x00U) /* normal mode */ -#define _02_AD_TEST_AVREFM (0x02U) /* use AVREFM as test signal */ -#define _03_AD_TEST_AVREFP (0x03U) /* use AVREFP as test signal */ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_ad.h +* Version : 1.0.0 +* Device(s) : R7F102GGExFB +* Description : General header file for ADC peripheral. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef ADC_H +#define ADC_H + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ +/* + Peripheral Enable Register 0 (PER0) +*/ +/* Control of A/D converter input clock (ADCEN) */ +#define _00_AD_CLOCK_STOP (0x00U) /* stop supply of input clock */ +#define _20_AD_CLOCK_SUPPLY (0x20U) /* supply input clock */ + +/* + Peripheral Reset Control Register 0 (PRR0) +*/ +/* Reset control for A/D converters (ADCRES) */ +#define _00_AD_RESET_RELEASE (0x00U) /* released from the reset state */ +#define _20_AD_RESET_SET (0x20U) /* reset state */ + +/* + A/D Converter Mode Register 0 (ADM0) +*/ +/* A/D conversion operation control (ADCS) */ +#define _00_AD_CONVERSION_DISABLE (0x00U) /* disable A/D conversion operation control */ +#define _80_AD_CONVERSION_ENABLE (0x80U) /* enable A/D conversion operation control */ +/* Specification of the A/D conversion channel selection mode (ADMD) */ +#define _00_AD_OPERMODE_SELECT (0x00U) /* select operation mode */ +#define _40_AD_OPERMODE_SCAN (0x40U) /* scan operation mode */ +/* A/D conversion clock selection (FR2 - FR0) */ +#define _00_AD_CONVERSION_CLOCK_64 (0x00U) /* fCLK/64 */ +#define _08_AD_CONVERSION_CLOCK_32 (0x08U) /* fCLK/32 */ +#define _10_AD_CONVERSION_CLOCK_16 (0x10U) /* fCLK/16 */ +#define _18_AD_CONVERSION_CLOCK_8 (0x18U) /* fCLK/8 */ +#define _20_AD_CONVERSION_CLOCK_6 (0x20U) /* fCLK/6 */ +#define _28_AD_CONVERSION_CLOCK_5 (0x28U) /* fCLK/5 */ +#define _30_AD_CONVERSION_CLOCK_4 (0x30U) /* fCLK/4 */ +#define _38_AD_CONVERSION_CLOCK_2 (0x38U) /* fCLK/2 */ +/* Specification A/D conversion time mode (LV1, LV0) */ +#define _00_AD_TIME_MODE_NORMAL_1 (0x00U) /* normal 1 mode */ +#define _02_AD_TIME_MODE_NORMAL_2 (0x02U) /* normal 2 mode */ +#define _04_AD_TIME_MODE_LOWVOLTAGE_1 (0x04U) /* low-voltage 1 mode */ +#define _06_AD_TIME_MODE_LOWVOLTAGE_2 (0x06U) /* low-voltage 2 mode */ +/* A/D voltage comparator operation control (ADCE) */ +#define _00_AD_COMPARATOR_DISABLE (0x00U) /* disable comparator operation control */ +#define _01_AD_COMPARATOR_ENABLE (0x01U) /* enable comparator operation control */ + + +/* + Analog Input Channel Specification Register(ADS) +*/ +/* Specification of analog input channel(ADISS, ADS4 - ADS0) */ +/* Select mode */ +#define _00_AD_INPUT_CHANNEL_0 (0x00U) /* ANI0 */ +#define _01_AD_INPUT_CHANNEL_1 (0x01U) /* ANI1 */ +#define _02_AD_INPUT_CHANNEL_2 (0x02U) /* ANI2 */ +#define _03_AD_INPUT_CHANNEL_3 (0x03U) /* ANI3 */ +#define _04_AD_INPUT_CHANNEL_4 (0x04U) /* ANI4 */ +#define _05_AD_INPUT_CHANNEL_5 (0x05U) /* ANI5 */ +#define _06_AD_INPUT_CHANNEL_6 (0x06U) /* ANI6 */ +#define _07_AD_INPUT_CHANNEL_7 (0x07U) /* ANI7 */ +#define _10_AD_INPUT_CHANNEL_16 (0x10U) /* ANI16 */ +#define _11_AD_INPUT_CHANNEL_17 (0x11U) /* ANI17 */ +#define _12_AD_INPUT_CHANNEL_18 (0x12U) /* ANI18 */ +#define _13_AD_INPUT_CHANNEL_19 (0x13U) /* ANI19 */ +#define _1E_AD_INPUT_CTSUTSCAP (0x1EU) /* TSCAP voltage of the CTSU */ +#define _80_AD_INPUT_TEMPERSENSOR_0 (0x80U) /* temperature sensor output voltage */ +#define _81_AD_INPUT_INTERREFVOLT (0x81U) /* internal reference voltage */ +/* Scan mode */ +#define _00_AD_INPUT_CHANNEL_0_3 (0x00U) /* ANI0 - ANI3 */ +#define _01_AD_INPUT_CHANNEL_1_4 (0x01U) /* ANI1 - ANI4 */ +#define _02_AD_INPUT_CHANNEL_2_5 (0x02U) /* ANI2 - ANI5 */ +#define _03_AD_INPUT_CHANNEL_3_6 (0x03U) /* ANI3 - ANI6 */ +#define _04_AD_INPUT_CHANNEL_4_7 (0x04U) /* ANI4 - ANI7 */ + +/* + A/D Converter Mode Register 1 (ADM1) +*/ +/* Selection of the A/D conversion trigger mode (ADTMD1, ADTMD0) */ +#define _00_AD_TRIGGER_SOFTWARE (0x00U) /* software trigger mode */ +#define _80_AD_TRIGGER_HARDWARE_NOWAIT (0x80U) /* hardware trigger no-wait mode */ +#define _C0_AD_TRIGGER_HARDWARE_WAIT (0xC0U) /* hardware trigger wait mode */ +/* Specification of the A/D conversion mode (ADSCM)*/ +#define _00_AD_CONVMODE_CONSELECT (0x00U) /* sequential conversion mode */ +#define _20_AD_CONVMODE_ONESELECT (0x20U) /* one-shot conversion mode */ +/* Selection of the hardware trigger signal (ADTRS1, ADTRS0) */ +#define _00_AD_TRIGGER_INTTM01 (0x00U) /* end of timer channel 01 count or capture interrupt + signal (INTTM01) */ +#define _01_AD_TRIGGER_ELC (0x01U) /* event input from the ELC */ +#define _02_AD_TRIGGER_INTRTC (0x02U) /* realtime clock interrupt signal (INTRTC) */ +#define _03_AD_TRIGGER_ELCITL0 (0x03U) /* 32-bit interval timer interrupt signal (ELCITL0) */ + +/* + A/D Converter Mode Register 2 (ADM2) +*/ +/* Selection of the positive reference voltage source of the A/D converter (ADREFP1, ADREFP0) */ +#define _00_AD_POSITIVE_VDD (0x00U) /* use VDD as VREF(+) */ +#define _40_AD_POSITIVE_AVREFP (0x40U) /* use AVREFP as VREF(+) */ +#define _80_AD_POSITIVE_INTERVOLT (0x80U) /* use internal voltage as VREF(+) */ +#define _C0_AD_POSITIVE_DISCHARGE (0xC0U) /* discharge */ +#define _3F_AD_POSITIVE_CLEAR (0x3FU) /* clear ADREFP1 and ADREFP0 */ +/* Selection of the negative reference voltage of the A/D converter (ADREFM) */ +#define _00_AD_NEGATIVE_VSS (0x00U) /* use VSS as VREF(-) */ +#define _20_AD_NEGATIVE_AVREFM (0x20U) /* use AVREFM as VREF(-) */ +/* Checking the upper limit and lower limit conversion result values (ADRCK) */ +#define _00_AD_AREA_MODE_1 (0x00U) /* generates INTAD when ADLL <= ADCRH <= ADUL */ +#define _08_AD_AREA_MODE_2_3 (0x08U) /* generates INTAD when ADUL < ADCRH or ADLL > ADCRH */ +/* Specification of the SNOOZE mode (AWC) */ +#define _00_AD_WAKEUP_OFF (0x00U) /* do not use the SNOOZE mode function */ +#define _04_AD_WAKEUP_ON (0x04U) /* use the SNOOZE mode function */ +/* Selection of the A/D conversion resolution (ADTYP) */ +#define _00_AD_RESOLUTION_10BIT (0x00U) /* 10 bits */ +#define _01_AD_RESOLUTION_8BIT (0x01U) /* 8 bits */ + + +/* + A/D Test Register (ADTES) +*/ +/* A/D conversion target (ADTES1, ADTES0)*/ +#define _00_AD_NORMAL_INPUT (0x00U) /* normal mode */ +#define _02_AD_TEST_AVREFM (0x02U) /* use AVREFM as test signal */ +#define _03_AD_TEST_AVREFP (0x03U) /* use AVREFP as test signal */ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/general/r_cg_ad_common.c b/cores/rl78g22/smc_gen/general/r_cg_ad_common.c index f9242c9..ee54322 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_ad_common.c +++ b/cores/rl78g22/smc_gen/general/r_cg_ad_common.c @@ -1,94 +1,94 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_ad_common.c -* Version : 1.0.0 -* Device(s) : R7F102GGExFB -* Description : None -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "r_cg_ad_common.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_ADC_Set_PowerOn -* Description : This function starts the clock supply for AD converter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_ADC_Set_PowerOn(void) -{ - ADCEN = 1U; /* start AD clock */ -} - -/*********************************************************************************************************************** -* Function Name: R_ADC_Set_PowerOff -* Description : This function stops the clock supply for AD converter. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_ADC_Set_PowerOff(void) -{ - ADCEN = 0U; /* stop AD clock */ -} - -/*********************************************************************************************************************** -* Function Name: R_ADC_Set_Reset -* Description : This function sets AD converter module in reset state. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_ADC_Set_Reset(void) -{ - ADCRES = 1U; /* reset AD converter */ -} - -/*********************************************************************************************************************** -* Function Name: R_ADC_Release_Reset -* Description : This function releases AD converter module from reset state. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_ADC_Release_Reset(void) -{ - ADCRES = 0U; /* release AD converter */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_ad_common.c +* Version : 1.0.0 +* Device(s) : R7F102GGExFB +* Description : None +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "r_cg_ad_common.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_ADC_Set_PowerOn +* Description : This function starts the clock supply for AD converter. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_ADC_Set_PowerOn(void) +{ + ADCEN = 1U; /* start AD clock */ +} + +/*********************************************************************************************************************** +* Function Name: R_ADC_Set_PowerOff +* Description : This function stops the clock supply for AD converter. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_ADC_Set_PowerOff(void) +{ + ADCEN = 0U; /* stop AD clock */ +} + +/*********************************************************************************************************************** +* Function Name: R_ADC_Set_Reset +* Description : This function sets AD converter module in reset state. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_ADC_Set_Reset(void) +{ + ADCRES = 1U; /* reset AD converter */ +} + +/*********************************************************************************************************************** +* Function Name: R_ADC_Release_Reset +* Description : This function releases AD converter module from reset state. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_ADC_Release_Reset(void) +{ + ADCRES = 0U; /* release AD converter */ +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/general/r_cg_ad_common.h b/cores/rl78g22/smc_gen/general/r_cg_ad_common.h index d6624d7..2175187 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_ad_common.h +++ b/cores/rl78g22/smc_gen/general/r_cg_ad_common.h @@ -1,52 +1,52 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_ad_common.h -* Version : 1.0.0 -* Device(s) : R7F102GGExFB -* Description : Common header file for ADC peripheral. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef ADC_COMMON_H -#define ADC_COMMON_H - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_ADC_Set_PowerOn (void); -void R_ADC_Set_PowerOff (void); -void R_ADC_Set_Reset (void); -void R_ADC_Release_Reset (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_ad_common.h +* Version : 1.0.0 +* Device(s) : R7F102GGExFB +* Description : Common header file for ADC peripheral. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef ADC_COMMON_H +#define ADC_COMMON_H + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_ADC_Set_PowerOn (void); +void R_ADC_Set_PowerOff (void); +void R_ADC_Set_Reset (void); +void R_ADC_Release_Reset (void); +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/general/r_cg_iica.h b/cores/rl78g22/smc_gen/general/r_cg_iica.h index a85639c..a5977cd 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_iica.h +++ b/cores/rl78g22/smc_gen/general/r_cg_iica.h @@ -1,175 +1,175 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_iica.h -* Version : 1.0.1 -* Device(s) : R7F100GLGxFB -* Description : General header file for IICA peripheral. -* Creation Date: 2021-05-14 -***********************************************************************************************************************/ - -#ifndef IICA_H -#define IICA_H - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ -/* - Peripheral Enable Register 0 (PER0) -*/ -/* Control of IICA1 input clock (IICA1EN) */ -#define _00_IICA1_CLOCK_STOP (0x00U) /* stops supply of input clock */ -#define _40_IICA1_CLOCK_SUPPLY (0x40U) /* supplies input clock */ -/* Control of IICA0 input clock (IICA0EN) */ -#define _00_IICA0_CLOCK_STOP (0x00U) /* stops supply of input clock */ -#define _10_IICA0_CLOCK_SUPPLY (0x10U) /* supplies input clock */ - -/* - Peripheral Reset Control Register 0 (PPR0) -*/ -/* Peripheral reset control of IICA1 (IICA1RES) */ -#define _00_IICA1_RESET_RELEASE (0x00U) /* released from the reset state */ -#define _40_IICA1_RESET_SET (0x40U) /* reset */ -/* Peripheral reset control of IICA0 (IICA0RES) */ -#define _00_IICA0_RESET_RELEASE (0x00U) /* released from the reset state */ -#define _10_IICA0_RESET_SET (0x10U) /* reset */ - -/* - IICA Control Register (IICCTLn0) -*/ -/* IIC operation enable (IICEn) */ -#define _00_IICA_OPERATION_DISABLE (0x00U) /* stop operation */ -#define _80_IICA_OPERATION_ENABLE (0x80U) /* enable operation */ -/* Exit from communications (LRELn) */ -#define _00_IICA_COMMUNICATION_NORMAL (0x00U) /* normal operation */ -#define _40_IICA_COMMUNICATION_EXIT (0x40U) /* exit from current communication */ -/* Wait cancellation (WRELn) */ -#define _00_IICA_WAIT_NOTCANCEL (0x00U) /* do not cancel wait */ -#define _20_IICA_WAIT_CANCEL (0x20U) /* cancel wait */ -/* Generation of interrupt when stop condition (SPIEn) */ -#define _00_IICA_STOPINT_DISABLE (0x00U) /* disable */ -#define _10_IICA_STOPINT_ENABLE (0x10U) /* enable */ -/* Wait and interrupt generation (WTIMn) */ -#define _00_IICA_WAITINT_CLK8FALLING (0x00U) /* generated at the eighth clock's falling edge */ -#define _08_IICA_WAITINT_CLK9FALLING (0x08U) /* generated at the ninth clock's falling edge */ -/* Acknowledgement control (ACKEn) */ -#define _00_IICA_ACK_DISABLE (0x00U) /* disable acknowledgement */ -#define _04_IICA_ACK_ENABLE (0x04U) /* enable acknowledgement */ -/* Start condition trigger (STTn) */ -#define _00_IICA_START_NOTGENERATE (0x00U) /* do not generate start condition */ -#define _02_IICA_START_GENERATE (0x02U) /* generate start condition */ -/* Stop condition trigger (SPTn) */ -#define _00_IICA_STOP_NOTGENERATE (0x00U) /* do not generate stop condition */ -#define _01_IICA_STOP_GENERATE (0x01U) /* generate stop condition */ - -/* - IICA Status Register (IICSn) -*/ -/* Master device status (MSTSn) */ -#define _00_IICA_STATUS_NOTMASTER (0x00U) /* slave device status or communication standby status */ -#define _80_IICA_STATUS_MASTER (0x80U) /* master device communication status */ -/* Detection of arbitration loss (ALDn) */ -#define _00_IICA_ARBITRATION_NO (0x00U) /* arbitration win or no arbitration */ -#define _40_IICA_ARBITRATION_LOSS (0x40U) /* arbitration loss */ -/* Detection of extension code reception (EXCn) */ -#define _00_IICA_EXTCODE_NOT (0x00U) /* extension code not received */ -#define _20_IICA_EXTCODE_RECEIVED (0x20U) /* extension code received */ -/* Detection of matching addresses (COIn) */ -#define _00_IICA_ADDRESS_NOTMATCH (0x00U) /* addresses do not match */ -#define _10_IICA_ADDRESS_MATCH (0x10U) /* addresses match */ -/* Detection of transmit/receive status (TRCn) */ -#define _00_IICA_STATUS_RECEIVE (0x00U) /* receive status */ -#define _08_IICA_STATUS_TRANSMIT (0x08U) /* transmit status */ -/* Detection of acknowledge signal (ACKDn) */ -#define _00_IICA_ACK_NOTDETECTED (0x00U) /* ACK signal was not detected */ -#define _04_IICA_ACK_DETECTED (0x04U) /* ACK signal was detected */ -/* Detection of start condition (STDn) */ -#define _00_IICA_START_NOTDETECTED (0x00U) /* start condition not detected */ -#define _02_IICA_START_DETECTED (0x02U) /* start condition detected */ -/* Detection of stop condition (SPDn) */ -#define _00_IICA_STOP_NOTDETECTED (0x00U) /* stop condition not detected */ -#define _01_IICA_STOP_DETECTED (0x01U) /* stop condition detected */ - -/* - IICA Flag Register (IICFn) -*/ -/* STT clear flag (STCFn) */ -#define _00_IICA_STARTFLAG_GENERATE (0x00U) /* generate start condition */ -#define _80_IICA_STARTFLAG_UNSUCCESSFUL (0x80U) /* start condition generation unsuccessful */ -/* IIC bus status flag (IICBSYn) */ -#define _00_IICA_BUS_RELEASE (0x00U) /* bus release status */ -#define _40_IICA_BUS_COMMUNICATION (0x40U) /* bus communication status */ -/* Initial start enable trigger (STCENn) */ -#define _00_IICA_START_WITHSTOP (0x00U) /* generate start condition upon detecting a stop condition */ -#define _02_IICA_START_WITHOUTSTOP (0x02U) /* generate start condition no detection a stop condition */ -/* Communication reservation function disable bit (IICRSVn) */ -#define _00_IICA_RESERVATION_ENABLE (0x00U) /* enable communication reservation */ -#define _01_IICA_RESERVATION_DISABLE (0x01U) /* disable communication reservation */ - -/* - IICA Control Register 1 (IICCTLn1) -*/ -/* Control of address match wakeup (WUPn) */ -#define _00_IICA_WAKEUP_STOP (0x00U) /* stop address match wakeup function in STOP mode */ -#define _80_IICA_WAKEUP_ENABLE (0x80U) /* enable address match wakeup function in STOP mode */ -/* Detection of SCL0 pin level (CLDn) */ -#define _00_IICA_SCL_LOW (0x00U) /* detect clock line at low level */ -#define _20_IICA_SCL_HIGH (0x20U) /* detect clock line at high level */ -/* Detection of SDA0 pin level (DADn) */ -#define _00_IICA_SDA_LOW (0x00U) /* detect data line at low level */ -#define _10_IICA_SDA_HIGH (0x10U) /* detect data line at high level */ -/* Operation mode switching (SMCn) */ -#define _00_IICA_MODE_STANDARD (0x00U) /* operates in standard mode */ -#define _08_IICA_MODE_HIGHSPEED (0x08U) /* operates in high-speed mode */ -/* Digital filter operation control (DFCn) */ -#define _00_IICA_FILTER_OFF (0x00U) /* digital filter off */ -#define _04_IICA_FILTER_ON (0x04U) /* digital filter on */ -/* Operation of clock dividing frequency permission (PRSn) */ -#define _00_IICA_fCLK (0x00U) /* clock of dividing frequency operation (fCLK) */ -#define _01_IICA_fCLK_HALF (0x01U) /* 2 clock of dividing frequency operation (fCLK/2) */ -/* IICA used flag */ -#define _80_IICA_ADDRESS_COMPLETE (0x80U) -#define _00_IICA_MASTER_FLAG_CLEAR (0x00U) - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -/* Start user code for function. Do not edit comment generated here */ - -#define _40_IICA_DATA_COMPLETE (0x40U) - -#define I2C_CLOCK_DEFAULT ( 100000UL) -#define I2C_CLOCK_STANDARD ( 100000UL) -#define I2C_CLOCK_FAST ( 400000UL) -#define I2C_CLOCK_FAST_PLUS (1000000UL) -// 20220928 temporary removal -// #warning FIXME: Disable I2C fast mode plus clock 1MHz: The setting is a bit differ from actual 1MHz frequency. -#define DISABLE_CLOCK_FAST_PLUS - -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_iica.h +* Version : 1.0.1 +* Device(s) : R7F100GLGxFB +* Description : General header file for IICA peripheral. +* Creation Date: 2021-05-14 +***********************************************************************************************************************/ + +#ifndef IICA_H +#define IICA_H + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ +/* + Peripheral Enable Register 0 (PER0) +*/ +/* Control of IICA1 input clock (IICA1EN) */ +#define _00_IICA1_CLOCK_STOP (0x00U) /* stops supply of input clock */ +#define _40_IICA1_CLOCK_SUPPLY (0x40U) /* supplies input clock */ +/* Control of IICA0 input clock (IICA0EN) */ +#define _00_IICA0_CLOCK_STOP (0x00U) /* stops supply of input clock */ +#define _10_IICA0_CLOCK_SUPPLY (0x10U) /* supplies input clock */ + +/* + Peripheral Reset Control Register 0 (PPR0) +*/ +/* Peripheral reset control of IICA1 (IICA1RES) */ +#define _00_IICA1_RESET_RELEASE (0x00U) /* released from the reset state */ +#define _40_IICA1_RESET_SET (0x40U) /* reset */ +/* Peripheral reset control of IICA0 (IICA0RES) */ +#define _00_IICA0_RESET_RELEASE (0x00U) /* released from the reset state */ +#define _10_IICA0_RESET_SET (0x10U) /* reset */ + +/* + IICA Control Register (IICCTLn0) +*/ +/* IIC operation enable (IICEn) */ +#define _00_IICA_OPERATION_DISABLE (0x00U) /* stop operation */ +#define _80_IICA_OPERATION_ENABLE (0x80U) /* enable operation */ +/* Exit from communications (LRELn) */ +#define _00_IICA_COMMUNICATION_NORMAL (0x00U) /* normal operation */ +#define _40_IICA_COMMUNICATION_EXIT (0x40U) /* exit from current communication */ +/* Wait cancellation (WRELn) */ +#define _00_IICA_WAIT_NOTCANCEL (0x00U) /* do not cancel wait */ +#define _20_IICA_WAIT_CANCEL (0x20U) /* cancel wait */ +/* Generation of interrupt when stop condition (SPIEn) */ +#define _00_IICA_STOPINT_DISABLE (0x00U) /* disable */ +#define _10_IICA_STOPINT_ENABLE (0x10U) /* enable */ +/* Wait and interrupt generation (WTIMn) */ +#define _00_IICA_WAITINT_CLK8FALLING (0x00U) /* generated at the eighth clock's falling edge */ +#define _08_IICA_WAITINT_CLK9FALLING (0x08U) /* generated at the ninth clock's falling edge */ +/* Acknowledgement control (ACKEn) */ +#define _00_IICA_ACK_DISABLE (0x00U) /* disable acknowledgement */ +#define _04_IICA_ACK_ENABLE (0x04U) /* enable acknowledgement */ +/* Start condition trigger (STTn) */ +#define _00_IICA_START_NOTGENERATE (0x00U) /* do not generate start condition */ +#define _02_IICA_START_GENERATE (0x02U) /* generate start condition */ +/* Stop condition trigger (SPTn) */ +#define _00_IICA_STOP_NOTGENERATE (0x00U) /* do not generate stop condition */ +#define _01_IICA_STOP_GENERATE (0x01U) /* generate stop condition */ + +/* + IICA Status Register (IICSn) +*/ +/* Master device status (MSTSn) */ +#define _00_IICA_STATUS_NOTMASTER (0x00U) /* slave device status or communication standby status */ +#define _80_IICA_STATUS_MASTER (0x80U) /* master device communication status */ +/* Detection of arbitration loss (ALDn) */ +#define _00_IICA_ARBITRATION_NO (0x00U) /* arbitration win or no arbitration */ +#define _40_IICA_ARBITRATION_LOSS (0x40U) /* arbitration loss */ +/* Detection of extension code reception (EXCn) */ +#define _00_IICA_EXTCODE_NOT (0x00U) /* extension code not received */ +#define _20_IICA_EXTCODE_RECEIVED (0x20U) /* extension code received */ +/* Detection of matching addresses (COIn) */ +#define _00_IICA_ADDRESS_NOTMATCH (0x00U) /* addresses do not match */ +#define _10_IICA_ADDRESS_MATCH (0x10U) /* addresses match */ +/* Detection of transmit/receive status (TRCn) */ +#define _00_IICA_STATUS_RECEIVE (0x00U) /* receive status */ +#define _08_IICA_STATUS_TRANSMIT (0x08U) /* transmit status */ +/* Detection of acknowledge signal (ACKDn) */ +#define _00_IICA_ACK_NOTDETECTED (0x00U) /* ACK signal was not detected */ +#define _04_IICA_ACK_DETECTED (0x04U) /* ACK signal was detected */ +/* Detection of start condition (STDn) */ +#define _00_IICA_START_NOTDETECTED (0x00U) /* start condition not detected */ +#define _02_IICA_START_DETECTED (0x02U) /* start condition detected */ +/* Detection of stop condition (SPDn) */ +#define _00_IICA_STOP_NOTDETECTED (0x00U) /* stop condition not detected */ +#define _01_IICA_STOP_DETECTED (0x01U) /* stop condition detected */ + +/* + IICA Flag Register (IICFn) +*/ +/* STT clear flag (STCFn) */ +#define _00_IICA_STARTFLAG_GENERATE (0x00U) /* generate start condition */ +#define _80_IICA_STARTFLAG_UNSUCCESSFUL (0x80U) /* start condition generation unsuccessful */ +/* IIC bus status flag (IICBSYn) */ +#define _00_IICA_BUS_RELEASE (0x00U) /* bus release status */ +#define _40_IICA_BUS_COMMUNICATION (0x40U) /* bus communication status */ +/* Initial start enable trigger (STCENn) */ +#define _00_IICA_START_WITHSTOP (0x00U) /* generate start condition upon detecting a stop condition */ +#define _02_IICA_START_WITHOUTSTOP (0x02U) /* generate start condition no detection a stop condition */ +/* Communication reservation function disable bit (IICRSVn) */ +#define _00_IICA_RESERVATION_ENABLE (0x00U) /* enable communication reservation */ +#define _01_IICA_RESERVATION_DISABLE (0x01U) /* disable communication reservation */ + +/* + IICA Control Register 1 (IICCTLn1) +*/ +/* Control of address match wakeup (WUPn) */ +#define _00_IICA_WAKEUP_STOP (0x00U) /* stop address match wakeup function in STOP mode */ +#define _80_IICA_WAKEUP_ENABLE (0x80U) /* enable address match wakeup function in STOP mode */ +/* Detection of SCL0 pin level (CLDn) */ +#define _00_IICA_SCL_LOW (0x00U) /* detect clock line at low level */ +#define _20_IICA_SCL_HIGH (0x20U) /* detect clock line at high level */ +/* Detection of SDA0 pin level (DADn) */ +#define _00_IICA_SDA_LOW (0x00U) /* detect data line at low level */ +#define _10_IICA_SDA_HIGH (0x10U) /* detect data line at high level */ +/* Operation mode switching (SMCn) */ +#define _00_IICA_MODE_STANDARD (0x00U) /* operates in standard mode */ +#define _08_IICA_MODE_HIGHSPEED (0x08U) /* operates in high-speed mode */ +/* Digital filter operation control (DFCn) */ +#define _00_IICA_FILTER_OFF (0x00U) /* digital filter off */ +#define _04_IICA_FILTER_ON (0x04U) /* digital filter on */ +/* Operation of clock dividing frequency permission (PRSn) */ +#define _00_IICA_fCLK (0x00U) /* clock of dividing frequency operation (fCLK) */ +#define _01_IICA_fCLK_HALF (0x01U) /* 2 clock of dividing frequency operation (fCLK/2) */ +/* IICA used flag */ +#define _80_IICA_ADDRESS_COMPLETE (0x80U) +#define _00_IICA_MASTER_FLAG_CLEAR (0x00U) + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +/* Start user code for function. Do not edit comment generated here */ + +#define _40_IICA_DATA_COMPLETE (0x40U) + +#define I2C_CLOCK_DEFAULT ( 100000UL) +#define I2C_CLOCK_STANDARD ( 100000UL) +#define I2C_CLOCK_FAST ( 400000UL) +#define I2C_CLOCK_FAST_PLUS (1000000UL) +// 20220928 temporary removal +// #warning FIXME: Disable I2C fast mode plus clock 1MHz: The setting is a bit differ from actual 1MHz frequency. +#define DISABLE_CLOCK_FAST_PLUS + +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/general/r_cg_iica_common.c b/cores/rl78g22/smc_gen/general/r_cg_iica_common.c index c60cd64..023f5c1 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_iica_common.c +++ b/cores/rl78g22/smc_gen/general/r_cg_iica_common.c @@ -1,94 +1,94 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_iica_common.c -* Version : 1.0.1 -* Device(s) : R7F100GLGxFB -* Description : None -* Creation Date: 2021-05-14 -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "r_cg_iica_common.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_IICA0_Set_PowerOn -* Description : This function starts the clock supply for IICA0. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_IICA0_Set_PowerOn(void) -{ - IICA0EN = 1U; /* start IICA0 clock */ -} - -/*********************************************************************************************************************** -* Function Name: R_IICA0_Set_PowerOff -* Description : This function stops the clock supply for IICA0. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_IICA0_Set_PowerOff(void) -{ - IICA0EN = 0U; /* stop IICA0 clock */ -} - -/*********************************************************************************************************************** -* Function Name: R_IICA0_Set_Reset -* Description : This function sets IICA0 module in reset state. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_IICA0_Set_Reset(void) -{ - IICA0RES = 1U; /* reset IICA0 module */ -} - -/*********************************************************************************************************************** -* Function Name: R_IICA0_Release_Reset -* Description : This function releases IICA0 module from reset state. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_IICA0_Release_Reset(void) -{ - IICA0RES = 0U; /* release IICA0 module */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_iica_common.c +* Version : 1.0.1 +* Device(s) : R7F100GLGxFB +* Description : None +* Creation Date: 2021-05-14 +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "r_cg_iica_common.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_IICA0_Set_PowerOn +* Description : This function starts the clock supply for IICA0. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_IICA0_Set_PowerOn(void) +{ + IICA0EN = 1U; /* start IICA0 clock */ +} + +/*********************************************************************************************************************** +* Function Name: R_IICA0_Set_PowerOff +* Description : This function stops the clock supply for IICA0. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_IICA0_Set_PowerOff(void) +{ + IICA0EN = 0U; /* stop IICA0 clock */ +} + +/*********************************************************************************************************************** +* Function Name: R_IICA0_Set_Reset +* Description : This function sets IICA0 module in reset state. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_IICA0_Set_Reset(void) +{ + IICA0RES = 1U; /* reset IICA0 module */ +} + +/*********************************************************************************************************************** +* Function Name: R_IICA0_Release_Reset +* Description : This function releases IICA0 module from reset state. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_IICA0_Release_Reset(void) +{ + IICA0RES = 0U; /* release IICA0 module */ +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/general/r_cg_iica_common.h b/cores/rl78g22/smc_gen/general/r_cg_iica_common.h index 062b780..ecd467d 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_iica_common.h +++ b/cores/rl78g22/smc_gen/general/r_cg_iica_common.h @@ -1,54 +1,54 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_iica_common.h -* Version : 1.0.1 -* Device(s) : R7F100GLGxFB -* Description : General header file for IICA common peripheral. -* Creation Date: 2021-05-14 -***********************************************************************************************************************/ - -#ifndef IICA_COMMON_H -#define IICA_COMMON_H - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_IICA0_Set_PowerOn(void); -void R_IICA0_Set_PowerOff(void); - -void R_IICA0_Set_Reset(void); -void R_IICA0_Release_Reset(void); - -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_iica_common.h +* Version : 1.0.1 +* Device(s) : R7F100GLGxFB +* Description : General header file for IICA common peripheral. +* Creation Date: 2021-05-14 +***********************************************************************************************************************/ + +#ifndef IICA_COMMON_H +#define IICA_COMMON_H + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_IICA0_Set_PowerOn(void); +void R_IICA0_Set_PowerOff(void); + +void R_IICA0_Set_Reset(void); +void R_IICA0_Release_Reset(void); + +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/general/r_cg_intc.h b/cores/rl78g22/smc_gen/general/r_cg_intc.h index 5dbd7d6..b023497 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_intc.h +++ b/cores/rl78g22/smc_gen/general/r_cg_intc.h @@ -1,115 +1,115 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_intc.h -* Version : 1.0.2 -* Device(s) : R7F100GLGxFB -* Description : General header file for INTC peripheral. -* Creation Date: 2021-11-04 -***********************************************************************************************************************/ - -#ifndef INTC_H -#define INTC_H - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ -/* - External Interrupt Rising Edge Enable Register 0 (EGP0) -*/ -/* INTPn pin valid edge selection (EGPn) */ -#define _80_INTP7_EDGE_RISING_SEL (0x80U) /* rising edge selected for INTP7 pin */ -#define _00_INTP7_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP7 pin */ -#define _40_INTP6_EDGE_RISING_SEL (0x40U) /* rising edge selected for INTP6 pin */ -#define _00_INTP6_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP6 pin */ -#define _20_INTP5_EDGE_RISING_SEL (0x20U) /* rising edge selected for INTP5 pin */ -#define _00_INTP5_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP5 pin */ -#define _10_INTP4_EDGE_RISING_SEL (0x10U) /* rising edge selected for INTP4 pin */ -#define _00_INTP4_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP4 pin */ -#define _08_INTP3_EDGE_RISING_SEL (0x08U) /* rising edge selected for INTP3 pin */ -#define _00_INTP3_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP3 pin */ -#define _04_INTP2_EDGE_RISING_SEL (0x04U) /* rising edge selected for INTP2 pin */ -#define _00_INTP2_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP2 pin */ -#define _02_INTP1_EDGE_RISING_SEL (0x02U) /* rising edge selected for INTP1 pin */ -#define _00_INTP1_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP1 pin*/ -#define _01_INTP0_EDGE_RISING_SEL (0x01U) /* rising edge selected for INTP0 pin */ -#define _00_INTP0_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP0 pin */ - -/* - External Interrupt Falling Edge Enable Register 0 (EGN0) -*/ -/* INTPn pin valid edge selection (EGNn) */ -#define _80_INTP7_EDGE_FALLING_SEL (0x80U) /* falling edge selected for INTP7 pin */ -#define _00_INTP7_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP7 pin */ -#define _40_INTP6_EDGE_FALLING_SEL (0x40U) /* falling edge selected for INTP6 pin */ -#define _00_INTP6_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP6 pin */ -#define _20_INTP5_EDGE_FALLING_SEL (0x20U) /* falling edge selected for INTP5 pin */ -#define _00_INTP5_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP5 pin */ -#define _10_INTP4_EDGE_FALLING_SEL (0x10U) /* falling edge selected for INTP4 pin */ -#define _00_INTP4_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP4 pin */ -#define _08_INTP3_EDGE_FALLING_SEL (0x08U) /* falling edge selected for INTP3 pin */ -#define _00_INTP3_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP3 pin */ -#define _04_INTP2_EDGE_FALLING_SEL (0x04U) /* falling edge selected for INTP2 pin */ -#define _00_INTP2_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP2 pin */ -#define _02_INTP1_EDGE_FALLING_SEL (0x02U) /* falling edge selected for INTP1 pin */ -#define _00_INTP1_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP1 pin */ -#define _01_INTP0_EDGE_FALLING_SEL (0x01U) /* falling edge selected for INTP0 pin */ -#define _00_INTP0_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP0 pin */ - -/* - External Interrupt Rising Edge Enable Register 1 (EGP1) -*/ -/* INTPn pin valid edge selection (EGPn) */ -#define _08_INTP11_EDGE_RISING_SEL (0x08U) /* rising edge selected for INTP11 pin */ -#define _00_INTP11_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP11 pin*/ -#define _04_INTP10_EDGE_RISING_SEL (0x04U) /* rising edge selected for INTP10 pin */ -#define _00_INTP10_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP10 pin */ -#define _02_INTP9_EDGE_RISING_SEL (0x02U) /* rising edge selected for INTP9 pin */ -#define _00_INTP9_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP9 pin*/ -#define _01_INTP8_EDGE_RISING_SEL (0x01U) /* rising edge selected for INTP8 pin */ -#define _00_INTP8_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP8 pin */ - -/* - External Interrupt Falling Edge Enable Register 1 (EGN1) -*/ -/* INTPn pin valid edge selection (EGNn) */ -#define _08_INTP11_EDGE_FALLING_SEL (0x08U) /* falling edge selected for INTP11 pin */ -#define _00_INTP11_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP11 pin */ -#define _04_INTP10_EDGE_FALLING_SEL (0x04U) /* falling edge selected for INTP10 pin */ -#define _00_INTP10_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP10 pin */ -#define _02_INTP9_EDGE_FALLING_SEL (0x02U) /* falling edge selected for INTP9 pin */ -#define _00_INTP9_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP9 pin */ -#define _01_INTP8_EDGE_FALLING_SEL (0x01U) /* falling edge selected for INTP8 pin */ -#define _00_INTP8_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP8 pin */ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_intc.h +* Version : 1.0.2 +* Device(s) : R7F100GLGxFB +* Description : General header file for INTC peripheral. +* Creation Date: 2021-11-04 +***********************************************************************************************************************/ + +#ifndef INTC_H +#define INTC_H + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ +/* + External Interrupt Rising Edge Enable Register 0 (EGP0) +*/ +/* INTPn pin valid edge selection (EGPn) */ +#define _80_INTP7_EDGE_RISING_SEL (0x80U) /* rising edge selected for INTP7 pin */ +#define _00_INTP7_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP7 pin */ +#define _40_INTP6_EDGE_RISING_SEL (0x40U) /* rising edge selected for INTP6 pin */ +#define _00_INTP6_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP6 pin */ +#define _20_INTP5_EDGE_RISING_SEL (0x20U) /* rising edge selected for INTP5 pin */ +#define _00_INTP5_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP5 pin */ +#define _10_INTP4_EDGE_RISING_SEL (0x10U) /* rising edge selected for INTP4 pin */ +#define _00_INTP4_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP4 pin */ +#define _08_INTP3_EDGE_RISING_SEL (0x08U) /* rising edge selected for INTP3 pin */ +#define _00_INTP3_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP3 pin */ +#define _04_INTP2_EDGE_RISING_SEL (0x04U) /* rising edge selected for INTP2 pin */ +#define _00_INTP2_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP2 pin */ +#define _02_INTP1_EDGE_RISING_SEL (0x02U) /* rising edge selected for INTP1 pin */ +#define _00_INTP1_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP1 pin*/ +#define _01_INTP0_EDGE_RISING_SEL (0x01U) /* rising edge selected for INTP0 pin */ +#define _00_INTP0_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP0 pin */ + +/* + External Interrupt Falling Edge Enable Register 0 (EGN0) +*/ +/* INTPn pin valid edge selection (EGNn) */ +#define _80_INTP7_EDGE_FALLING_SEL (0x80U) /* falling edge selected for INTP7 pin */ +#define _00_INTP7_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP7 pin */ +#define _40_INTP6_EDGE_FALLING_SEL (0x40U) /* falling edge selected for INTP6 pin */ +#define _00_INTP6_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP6 pin */ +#define _20_INTP5_EDGE_FALLING_SEL (0x20U) /* falling edge selected for INTP5 pin */ +#define _00_INTP5_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP5 pin */ +#define _10_INTP4_EDGE_FALLING_SEL (0x10U) /* falling edge selected for INTP4 pin */ +#define _00_INTP4_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP4 pin */ +#define _08_INTP3_EDGE_FALLING_SEL (0x08U) /* falling edge selected for INTP3 pin */ +#define _00_INTP3_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP3 pin */ +#define _04_INTP2_EDGE_FALLING_SEL (0x04U) /* falling edge selected for INTP2 pin */ +#define _00_INTP2_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP2 pin */ +#define _02_INTP1_EDGE_FALLING_SEL (0x02U) /* falling edge selected for INTP1 pin */ +#define _00_INTP1_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP1 pin */ +#define _01_INTP0_EDGE_FALLING_SEL (0x01U) /* falling edge selected for INTP0 pin */ +#define _00_INTP0_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP0 pin */ + +/* + External Interrupt Rising Edge Enable Register 1 (EGP1) +*/ +/* INTPn pin valid edge selection (EGPn) */ +#define _08_INTP11_EDGE_RISING_SEL (0x08U) /* rising edge selected for INTP11 pin */ +#define _00_INTP11_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP11 pin*/ +#define _04_INTP10_EDGE_RISING_SEL (0x04U) /* rising edge selected for INTP10 pin */ +#define _00_INTP10_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP10 pin */ +#define _02_INTP9_EDGE_RISING_SEL (0x02U) /* rising edge selected for INTP9 pin */ +#define _00_INTP9_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP9 pin*/ +#define _01_INTP8_EDGE_RISING_SEL (0x01U) /* rising edge selected for INTP8 pin */ +#define _00_INTP8_EDGE_RISING_UNSEL (0x00U) /* rising edge not selected for INTP8 pin */ + +/* + External Interrupt Falling Edge Enable Register 1 (EGN1) +*/ +/* INTPn pin valid edge selection (EGNn) */ +#define _08_INTP11_EDGE_FALLING_SEL (0x08U) /* falling edge selected for INTP11 pin */ +#define _00_INTP11_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP11 pin */ +#define _04_INTP10_EDGE_FALLING_SEL (0x04U) /* falling edge selected for INTP10 pin */ +#define _00_INTP10_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP10 pin */ +#define _02_INTP9_EDGE_FALLING_SEL (0x02U) /* falling edge selected for INTP9 pin */ +#define _00_INTP9_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP9 pin */ +#define _01_INTP8_EDGE_FALLING_SEL (0x01U) /* falling edge selected for INTP8 pin */ +#define _00_INTP8_EDGE_FALLING_UNSEL (0x00U) /* falling edge not selected for INTP8 pin */ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/general/r_cg_interrupt_handlers.h b/cores/rl78g22/smc_gen/general/r_cg_interrupt_handlers.h index 52e8790..72e92d4 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_interrupt_handlers.h +++ b/cores/rl78g22/smc_gen/general/r_cg_interrupt_handlers.h @@ -1,316 +1,300 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_interrupt_handlers.h -* Version : 1.0.0 -* Device(s) : R7F102GGExFB -* Description : None -* Creation Date: -***********************************************************************************************************************/ - -#ifndef INTERRUPT_HANDLER_H -#define INTERRUPT_HANDLER_H -/* - * INT_WDTI (0x4) - */ -void INT_WDTI(void) __attribute__ ((interrupt)); - -/* - * INT_LVI (0x6) - */ -void INT_LVI(void) __attribute__ ((interrupt)); - -/* - * INT_P0 (0x8) - */ -void INT_P0(void) __attribute__ ((interrupt)); -void r_Config_INTC_intp0_interrupt(void) __attribute__ ((interrupt)); -/* 1112 Ueeda add */ -/* - * INT_P1 (0xA) - */ -void r_Config_INTC_intp1_interrupt(void) __attribute__ ((interrupt)); - -/* - * INT_P2 (0xC) - */ -void r_Config_INTC_intp2_interrupt(void) __attribute__ ((interrupt)); - -/* - * INT_P3 (0xE) - */ -void r_Config_INTC_intp3_interrupt(void) __attribute__ ((interrupt)); - -/* - * INT_P4 (0x10) - */ -void r_Config_INTC_intp4_interrupt(void) __attribute__ ((interrupt)); -/* 1112 Ueeda add */ - -/* - * INT_P5 (0x12) - */ -//void INT_P5(void) __attribute__ ((interrupt)); -void r_Config_INTC_intp5_interrupt(void) __attribute__ ((interrupt)); - -/* - * INT_CSI20/INT_IIC20/INT_ST2 (0x14) - */ -void r_Config_UART2_interrupt_send(void) __attribute__ ((interrupt)); -// 2022/11/07 added by KAD -void INT_ST2(void) __attribute__ ((interrupt)); -/* - * INT_CSI21/INT_IIC21/INT_SR2 (0x16) - */ -void r_Config_UART2_interrupt_receive(void) __attribute__ ((interrupt)); -// 2022/11/07 added by KAD -void INT_SR2(void) __attribute__ ((interrupt)); - -/* - * INT_SRE2 (0x18) - */ -// 2022/11/07 comment removed by KAD -void INT_SRE2(void) __attribute__ ((interrupt)); -void r_Config_UART2_interrupt_error(void) __attribute__ ((interrupt)); - -/* - * INT_SMSE (0x1C) - */ -void INT_SMSE(void) __attribute__ ((interrupt)); - -/* - * INT_CSI00/INT_IIC00/INT_ST0 (0x1E) - */ -void r_Config_UART0_interrupt_send(void) __attribute__ ((interrupt)); -// 2022/11/07 added by KAD -void INT_ST0(void) __attribute__ ((interrupt)); - -/* - * INT_TM00 (0x20) - */ -//void r_Config_TAU0_0_channel0_interrupt(void) __attribute__ ((interrupt)); -void r_Config_TAU0_0_Measure_Signal_interrupt(void) __attribute__ ((interrupt)); - -/* - * INT_SRE0/INT_TM01H (0x22) - */ -void r_Config_UART0_interrupt_error(void) __attribute__ ((interrupt)); -//void INT_SRE0(void) __attribute__ ((interrupt)); -// 2022/11/07 added by KAD -void INT_TM01H(void) __attribute__ ((interrupt)); -/* - * INT_ST1 (0x24) - */ -void r_Config_UART1_interrupt_send(void) __attribute__ ((interrupt)); -void INT_ST1(void) __attribute__ ((interrupt)); - -/* - * INT_CSI11/INT_IIC11/INT_SR1 (0x26) - */ -// void r_Config_CSI11_interrupt(void) __attribute__ ((interrupt)); -void r_Config_CSI11_UART1_interrupt_switching(void) __attribute__ ((interrupt)); -// 2022/11/07 added by KAD -void r_Config_UART1_interrupt_receive(void); -void INT_SR1(void) __attribute__ ((interrupt)); -/* - * INT_SRE1/INT_TM03H (0x28) - */ -// 2022/11/07 added by KAD -void INT_TM03H(void) __attribute__ ((interrupt)); -void r_Config_UART1_interrupt_error(void) __attribute__ ((interrupt)); -void INT_SRE1(void) __attribute__ ((interrupt)); - -/* - * INT_IICA0 (0x2A) - */ -// void INT_IICA0(void) __attribute__ ((interrupt)); -// 2022/11/07 added by KAD -void r_Config_IICA0_interrupt(void) __attribute__ ((interrupt)); -/* - * INT_CSI01/INT_IIC01/INT_SR0 (0x2C) - */ -void INT_SR0(void) __attribute__ ((interrupt)); -//void INT_CSI01(void) __attribute__ ((interrupt)); -//void INT_IIC01(void) __attribute__ ((interrupt)); -void r_Config_UART0_interrupt_receive(void) __attribute__ ((interrupt)); - -/* - * INT_TM01 (0x2E) - */ -// void r_Config_TAU0_0_channel1_interrupt(void) __attribute__ ((interrupt)); -/* 1118 nhu add */ -void r_Config_TAU0_01_PWM_channel1_interrupt(void) __attribute__ ((interrupt)); -void r_Config_TAU0_1_Measure_Signal_interrupt(void) __attribute__ ((interrupt)); -void r_Config_TAU0_1_Square_Wave_interrupt(void) __attribute__ ((interrupt)); -void INT_TM01(void) __attribute__ ((interrupt)); -/* 1118 nhu add */ - -/* - * INT_TM02 (0x30) - */ -//void r_Config_TAU0_2_channel2_interrupt(void) __attribute__ ((interrupt)); -/* 1118 nhu add */ -void r_Config_TAU0_23_PWM_channel2_interrupt(void) __attribute__ ((interrupt)); -void r_Config_TAU0_2_Measure_Signal_interrupt(void) __attribute__ ((interrupt)); -void r_Config_TAU0_2_Square_Wave_interrupt(void) __attribute__ ((interrupt)); -void INT_TM02(void) __attribute__ ((interrupt)); -/* 1118 nhu add */ - -/* - * INT_TM03 (0x32) - */ -//void r_Config_TAU0_2_channel3_interrupt(void) __attribute__ ((interrupt)); -/* 1118 nhu add */ -void r_Config_TAU0_23_PWM_channel3_interrupt(void) __attribute__ ((interrupt)); -void r_Config_TAU0_3_Measure_Signal_interrupt(void) __attribute__ ((interrupt)); -void r_Config_TAU0_3_Square_Wave_interrupt(void) __attribute__ ((interrupt)); -void INT_TM03(void) __attribute__ ((interrupt)); -/* 1118 nhu add */ - -/* - * INT_AD (0x34) - */ -void r_Config_ADC_interrupt(void) __attribute__ ((interrupt)); - -/* - * INT_RTC (0x36) - */ -// 2022/11/07 modified by KAD -// void INT_RTC(void) __attribute__ ((interrupt)); -void r_Config_RTC_interrupt(void) __attribute__ ((interrupt)); - -/* - * INT_ITL (0x38) - */ -void r_itl_interrupt(void) __attribute__ ((interrupt)); - -/* - * INT_KR (0x3A) - */ -void INT_KR(void) __attribute__ ((interrupt)); - -/* - * INT_TM04 (0x42) - */ -//void r_Config_TAU0_4_channel4_interrupt(void) __attribute__ ((interrupt)); -/* 1118 nhu add */ -void r_Config_TAU0_45_PWM_channel4_interrupt(void) __attribute__ ((interrupt)); - -void r_Config_TAU0_4_Square_Wave_interrupt(void) __attribute__ ((interrupt)); -void INT_TM04(void) __attribute__ ((interrupt)); -/* 1118 nhu add */ - -/* - * INT_TM05 (0x44) - */ -//void r_Config_TAU0_4_channel5_interrupt(void) __attribute__ ((interrupt)); -/* 1118 nhu add */ -void r_Config_TAU0_45_PWM_channel5_interrupt(void) __attribute__ ((interrupt)); - -void r_Config_TAU0_5_Square_Wave_interrupt(void) __attribute__ ((interrupt)); -void INT_TM05(void) __attribute__ ((interrupt)); -/* 1118 nhu add */ - -/* - * INT_TM06 (0x46) - */ -//void r_Config_TAU0_6_channel6_interrupt(void) __attribute__ ((interrupt)); -/* 1118 nhu add */ -void r_Config_TAU0_67_PWM_channel6_interrupt(void) __attribute__ ((interrupt)); - -void r_Config_TAU0_6_Square_Wave_interrupt(void) __attribute__ ((interrupt)); -void r_Config_TAU0_6_Micros_interrupt(void) __attribute__ ((interrupt)); -void INT_TM06(void) __attribute__ ((interrupt)); -/* 1118 nhu add */ - -/* - * INT_TM07 (0x48) - */ -//void r_Config_TAU0_6_channel7_interrupt(void) __attribute__ ((interrupt)); -/* 1118 nhu add */ -void r_Config_TAU0_67_PWM_channel7_interrupt(void) __attribute__ ((interrupt)); -void r_Config_TAU0_7_Measure_Signal_interrupt(void) __attribute__ ((interrupt)); -void r_Config_TAU0_7_Square_Wave_interrupt(void) __attribute__ ((interrupt)); -void INT_TM07(void) __attribute__ ((interrupt)); -/* 1118 nhu add */ -// 20221006 KAD -void r_Config_TAU0_7_MSTimer2_interrupt(void) __attribute__ ((interrupt)); - -/* - * INT_P6 (0x4A) - */ -//void INT_P6(void) __attribute__ ((interrupt)); -void r_Config_INTC_intp6_interrupt(void) __attribute__ ((interrupt)); - -/* - * INT_P8 (0x4E) - */ -void INT_P8(void) __attribute__ ((interrupt)); - -/* - * INT_P9 (0x50) - */ -void INT_P9(void) __attribute__ ((interrupt)); - -/* - * INT_FL (0x52) - */ -void INT_FL(void) __attribute__ ((interrupt)); - -/* - * INT_URE0 (0x58) - */ -void INT_URE0(void) __attribute__ ((interrupt)); - -/* - * INT_CTSUWR (0x60) - */ -void INT_CTSUWR(void) __attribute__ ((interrupt)); - -/* - * INT_CTSURD (0x64) - */ -void INT_CTSURD(void) __attribute__ ((interrupt)); - -/* - * INT_CTSUFN (0x66) - */ -void INT_CTSUFN(void) __attribute__ ((interrupt)); - -/* - * INT_UT0 (0x6A) - */ -void INT_UT0(void) __attribute__ ((interrupt)); - -/* - * INT_UR0 (0x6C) - */ -void INT_UR0(void) __attribute__ ((interrupt)); - -/* - * INT_BRK_I (0x7E) - */ -void INT_BRK_I(void) __attribute__ ((interrupt)); - -//Hardware Vectors -//PowerON_Reset (0x0) -void PowerON_Reset(void) __attribute__ ((interrupt)); - -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_interrupt_handlers.h +* Version : 1.0.0 +* Device(s) : R7F102GGExFB +* Description : None +* Creation Date: +***********************************************************************************************************************/ + +#ifndef INTERRUPT_HANDLER_H +#define INTERRUPT_HANDLER_H +/* + * INT_WDTI (0x4) + */ +void INT_WDTI(void) __attribute__ ((interrupt)); + +/* + * INT_LVI (0x6) + */ +void INT_LVI(void) __attribute__ ((interrupt)); + +/* + * INT_P0 (0x8) + */ +void INT_P0(void) __attribute__ ((interrupt)); +void r_Config_INTC_intp0_interrupt(void) __attribute__ ((interrupt)); + +/* + * INT_P1 (0xA) + */ +void r_Config_INTC_intp1_interrupt(void) __attribute__ ((interrupt)); + +/* + * INT_P2 (0xC) + */ +void r_Config_INTC_intp2_interrupt(void) __attribute__ ((interrupt)); + +/* + * INT_P3 (0xE) + */ +void r_Config_INTC_intp3_interrupt(void) __attribute__ ((interrupt)); + +/* + * INT_P4 (0x10) + */ +void r_Config_INTC_intp4_interrupt(void) __attribute__ ((interrupt)); +/* 1112 Ueeda add */ + +/* + * INT_P5 (0x12) + */ +//void INT_P5(void) __attribute__ ((interrupt)); +void r_Config_INTC_intp5_interrupt(void) __attribute__ ((interrupt)); + +/* + * INT_CSI20/INT_IIC20/INT_ST2 (0x14) + */ +// void r_Config_UART2_interrupt_send(void) __attribute__ ((interrupt)); +void r_Config_CSI20_UART2_interrupt_send(void) __attribute__ ((interrupt)); +void INT_ST2(void) __attribute__ ((interrupt)); + +/* + * INT_CSI21/INT_IIC21/INT_SR2 (0x16) + */ +void r_Config_UART2_interrupt_receive(void) __attribute__ ((interrupt)); +// 2022/11/07 added by KAD +void INT_SR2(void) __attribute__ ((interrupt)); + +/* + * INT_SRE2 (0x18) + */ +// 2022/11/07 comment removed by KAD +void INT_SRE2(void) __attribute__ ((interrupt)); +void r_Config_UART2_interrupt_error(void) __attribute__ ((interrupt)); + +/* + * INT_SMSE (0x1C) + */ +void INT_SMSE(void) __attribute__ ((interrupt)); + +/* + * INT_CSI00/INT_IIC00/INT_ST0 (0x1E) + */ +void r_Config_UART0_interrupt_send(void) __attribute__ ((interrupt)); +// 2022/11/07 added by KAD +void INT_ST0(void) __attribute__ ((interrupt)); + +/* + * INT_TM00 (0x20) + */ +//void r_Config_TAU0_0_channel0_interrupt(void) __attribute__ ((interrupt)); +void r_Config_TAU0_0_PWM_interrupt(void) __attribute__ ((interrupt)); + +/* + * INT_SRE0/INT_TM01H (0x22) + */ +void r_Config_UART0_interrupt_error(void) __attribute__ ((interrupt)); +//void INT_SRE0(void) __attribute__ ((interrupt)); +// 2022/11/07 added by KAD +void INT_TM01H(void) __attribute__ ((interrupt)); +/* + * INT_ST1 (0x24) + */ +void r_Config_UART1_interrupt_send(void) __attribute__ ((interrupt)); +void INT_ST1(void) __attribute__ ((interrupt)); + +/* + * INT_CSI11/INT_IIC11/INT_SR1 (0x26) + */ +// void r_Config_CSI11_interrupt(void) __attribute__ ((interrupt)); +void r_Config_CSI11_UART1_interrupt_switching(void) __attribute__ ((interrupt)); +// 2022/11/07 added by KAD +void r_Config_UART1_interrupt_receive(void); +void INT_SR1(void) __attribute__ ((interrupt)); +/* + * INT_SRE1/INT_TM03H (0x28) + */ +// 2022/11/07 added by KAD +void INT_TM03H(void) __attribute__ ((interrupt)); +void r_Config_UART1_interrupt_error(void) __attribute__ ((interrupt)); +void INT_SRE1(void) __attribute__ ((interrupt)); + +/* + * INT_IICA0 (0x2A) + */ +// void INT_IICA0(void) __attribute__ ((interrupt)); +// 2022/11/07 added by KAD +void r_Config_IICA0_interrupt(void) __attribute__ ((interrupt)); +/* + * INT_CSI01/INT_IIC01/INT_SR0 (0x2C) + */ +void INT_SR0(void) __attribute__ ((interrupt)); +//void INT_CSI01(void) __attribute__ ((interrupt)); +//void INT_IIC01(void) __attribute__ ((interrupt)); +void r_Config_UART0_interrupt_receive(void) __attribute__ ((interrupt)); + +/* + * INT_TM01 (0x2E) + */ +// void r_Config_TAU0_0_channel1_interrupt(void) __attribute__ ((interrupt)); +/* 1118 nhu add */ +void r_Config_TAU0_1_Square_Wave_interrupt(void) __attribute__ ((interrupt)); +void INT_TM01(void) __attribute__ ((interrupt)); +/* 1118 nhu add */ + +/* + * INT_TM02 (0x30) + */ +//void r_Config_TAU0_2_channel2_interrupt(void) __attribute__ ((interrupt)); +/* 1118 nhu add */ +void r_Config_TAU0_2_Square_Wave_interrupt(void) __attribute__ ((interrupt)); +void INT_TM02(void) __attribute__ ((interrupt)); +/* 1118 nhu add */ + +/* + * INT_TM03 (0x32) + */ +//void r_Config_TAU0_2_channel3_interrupt(void) __attribute__ ((interrupt)); +/* 1118 nhu add */ +void r_Config_TAU0_3_Square_Wave_interrupt(void) __attribute__ ((interrupt)); +void INT_TM03(void) __attribute__ ((interrupt)); +/* 1118 nhu add */ + +/* + * INT_AD (0x34) + */ +void r_Config_ADC_interrupt(void) __attribute__ ((interrupt)); + +/* + * INT_RTC (0x36) + */ +// 2022/11/07 modified by KAD +// void INT_RTC(void) __attribute__ ((interrupt)); +void r_Config_RTC_interrupt(void) __attribute__ ((interrupt)); + +/* + * INT_ITL (0x38) + */ +void r_itl_interrupt(void) __attribute__ ((interrupt)); + +/* + * INT_KR (0x3A) + */ +void INT_KR(void) __attribute__ ((interrupt)); + +/* + * INT_TM04 (0x42) + */ +//void r_Config_TAU0_4_channel4_interrupt(void) __attribute__ ((interrupt)); +/* 1118 nhu add */ +void r_Config_TAU0_4_Square_Wave_interrupt(void) __attribute__ ((interrupt)); +void INT_TM04(void) __attribute__ ((interrupt)); +/* 1118 nhu add */ + +/* + * INT_TM05 (0x44) + */ +//void r_Config_TAU0_4_channel5_interrupt(void) __attribute__ ((interrupt)); +/* 1118 nhu add */ +void r_Config_TAU0_5_Square_Wave_interrupt(void) __attribute__ ((interrupt)); +void INT_TM05(void) __attribute__ ((interrupt)); +/* 1118 nhu add */ + +/* + * INT_TM06 (0x46) + */ +//void r_Config_TAU0_6_channel6_interrupt(void) __attribute__ ((interrupt)); +/* 1118 nhu add */ +void r_Config_TAU0_6_Square_Wave_interrupt(void) __attribute__ ((interrupt)); +void r_Config_TAU0_6_Micros_interrupt(void) __attribute__ ((interrupt)); +void INT_TM06(void) __attribute__ ((interrupt)); +/* 1118 nhu add */ + +/* + * INT_TM07 (0x48) + */ +//void r_Config_TAU0_6_channel7_interrupt(void) __attribute__ ((interrupt)); +/* 1118 nhu add */ +void r_Config_TAU0_7_Square_Wave_interrupt(void) __attribute__ ((interrupt)); +void INT_TM07(void) __attribute__ ((interrupt)); + +/* + * INT_P6 (0x4A) + */ +//void INT_P6(void) __attribute__ ((interrupt)); +void r_Config_INTC_intp6_interrupt(void) __attribute__ ((interrupt)); + +/* + * INT_P8 (0x4E) + */ +void INT_P8(void) __attribute__ ((interrupt)); + +/* + * INT_P9 (0x50) + */ +void INT_P9(void) __attribute__ ((interrupt)); + +/* + * INT_FL (0x52) + */ +void INT_FL(void) __attribute__ ((interrupt)); + +/* + * INT_URE0 (0x58) + */ +void INT_URE0(void) __attribute__ ((interrupt)); + +/* + * INT_CTSUWR (0x60) + */ +void INT_CTSUWR(void) __attribute__ ((interrupt)); + +/* + * INT_CTSURD (0x64) + */ +void INT_CTSURD(void) __attribute__ ((interrupt)); + +/* + * INT_CTSUFN (0x66) + */ +void INT_CTSUFN(void) __attribute__ ((interrupt)); + +/* + * INT_UT0 (0x6A) + */ +void INT_UT0(void) __attribute__ ((interrupt)); + +/* + * INT_UR0 (0x6C) + */ +void INT_UR0(void) __attribute__ ((interrupt)); + +/* + * INT_BRK_I (0x7E) + */ +void INT_BRK_I(void) __attribute__ ((interrupt)); + +//Hardware Vectors +//PowerON_Reset (0x0) +void PowerON_Reset(void) __attribute__ ((interrupt)); + +#endif diff --git a/cores/rl78g22/smc_gen/general/r_cg_inthandler.c b/cores/rl78g22/smc_gen/general/r_cg_inthandler.c index 6ed25f9..f9a2453 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_inthandler.c +++ b/cores/rl78g22/smc_gen/general/r_cg_inthandler.c @@ -1,252 +1,252 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_inthandler.c -* Version : 1.0.0 -* Device(s) : R7F102GGExFB -* Description : None -* Creation Date: -***********************************************************************************************************************/ - -#include "r_cg_macrodriver.h" -/* - * INT_WDTI (0x4) - */ -void INT_WDTI (void) { } - -/* - * INT_LVI (0x6) - */ -void INT_LVI (void) { } - -/* - * INT_P0 (0x8) - */ -void INT_P0 (void) { } - -/* - * INT_P1 (0xA) - */ -void INT_P1 (void) { } - -/* - * INT_P2 (0xC) - */ -void INT_P2 (void) { } - -/* - * INT_P3 (0xE) - */ -void INT_P3 (void) { } - -/* - * INT_P4 (0x10) - */ -void INT_P4 (void) { } - -/* - * INT_P5 (0x12) - */ -void INT_P5 (void) { } - -/* - * INT_CSI20/INT_IIC20/INT_ST2 (0x14) - */ -void INT_ST2 (void) { } -//void INT_CSI20 (void) { } -//void INT_IIC20 (void) { } - -/* - * INT_CSI21/INT_IIC21/INT_SR2 (0x16) - */ -void INT_SR2 (void) { } -//void INT_CSI21 (void) { } -//void INT_IIC21 (void) { } - -/* - * INT_SRE2 (0x18) -void INT_TM11H (void) { } -//void INT_SRE2 (void) { } - */ -void INT_SRE2 (void) { } - -/* - * INT_SMSE (0x1C) - */ -void INT_SMSE (void) { } - -/* - * INT_CSI00/INT_IIC00/INT_ST0 (0x1E) - */ -void INT_ST0 (void) { } -//void INT_CSI00 (void) { } -//void INT_IIC00 (void) { } - -/* - * INT_TM00 (0x20) - */ -void INT_TM00 (void) { } - -/* - * INT_TM01H (0x22) - */ -void INT_TM01H (void) { } - -/* - * INT_ST1 (0x24) - */ -void INT_ST1 (void) { } - -/* - * INT_CSI11/INT_IIC11/INT_SR1 (0x26) - */ -void INT_SR1 (void) { } -//void INT_CSI11 (void) { } -//void INT_IIC11 (void) { } - -/* - * INT_SRE1/INT_TM03H (0x28) - */ -void INT_TM03H (void) { } -//void INT_SRE1 (void) { } -void INT_SRE1 (void) { } - -/* - * INT_IICA0 (0x2A) - */ -void INT_IICA0 (void) { } - -/* - * INT_CSI01/INT_IIC01/INT_SR0 (0x2C) - */ -void INT_SR0 (void) { } -//void INT_CSI01 (void) { } -//void INT_IIC01 (void) { } -void r_Config_UART0_interrupt_receive(void) __attribute__ ((interrupt)); - -/* - * INT_TM01 (0x2E) - */ -void INT_TM01 (void) { } - -/* - * INT_TM02 (0x30) - */ -void INT_TM02 (void) { } - -/* - * INT_TM03 (0x32) - */ -void INT_TM03 (void) { } - -/* - * INT_AD (0x34) - */ -void INT_AD (void) { } - -/* - * INT_RTC (0x36) - */ -void INT_RTC (void) { } - -/* - * INT_ITL (0x38) - */ -void INT_ITL (void) { } - -/* - * INT_KR (0x3A) - */ -void INT_KR (void) { } - -/* - * INT_TM04 (0x42) - */ -void INT_TM04 (void) { } - -/* - * INT_TM05 (0x44) - */ -void INT_TM05 (void) { } - -/* - * INT_TM06 (0x46) - */ -void INT_TM06 (void) { } - -/* - * INT_TM07 (0x48) - */ -void INT_TM07 (void) { } - -/* - * INT_P6 (0x4A) - */ -void INT_P6 (void) { } - -/* - * INT_P8 (0x4E) - */ -void INT_P8 (void) { } - -/* - * INT_P9 (0x50) - */ -void INT_P9 (void) { } - -/* - * INT_FL (0x52) - */ -void INT_FL (void) { } - -/* - * INT_URE0 (0x58) - */ -void INT_URE0 (void) { } - -/* - * INT_CTSUWR (0x60) - */ -void INT_CTSUWR (void) { } - -/* - * INT_CTSURD (0x64) - */ -void INT_CTSURD (void) { } - -/* - * INT_CTSUFN (0x66) - */ -void INT_CTSUFN (void) { } - -/* - * INT_UT0 (0x6A) - */ -void INT_UT0 (void) { } - -/* - * INT_UR0 (0x6C) - */ -void INT_UR0 (void) { } - -/* - * INT_BRK_I (0x7E) - */ -void INT_BRK_I (void) { } +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_inthandler.c +* Version : 1.0.0 +* Device(s) : R7F102GGExFB +* Description : None +* Creation Date: +***********************************************************************************************************************/ + +#include "r_cg_macrodriver.h" +/* + * INT_WDTI (0x4) + */ +void INT_WDTI (void) { } + +/* + * INT_LVI (0x6) + */ +void INT_LVI (void) { } + +/* + * INT_P0 (0x8) + */ +void INT_P0 (void) { } + +/* + * INT_P1 (0xA) + */ +void INT_P1 (void) { } + +/* + * INT_P2 (0xC) + */ +void INT_P2 (void) { } + +/* + * INT_P3 (0xE) + */ +void INT_P3 (void) { } + +/* + * INT_P4 (0x10) + */ +void INT_P4 (void) { } + +/* + * INT_P5 (0x12) + */ +void INT_P5 (void) { } + +/* + * INT_CSI20/INT_IIC20/INT_ST2 (0x14) + */ +void INT_ST2 (void) { } +//void INT_CSI20 (void) { } +//void INT_IIC20 (void) { } + +/* + * INT_CSI21/INT_IIC21/INT_SR2 (0x16) + */ +void INT_SR2 (void) { } +//void INT_CSI21 (void) { } +//void INT_IIC21 (void) { } + +/* + * INT_SRE2 (0x18) +void INT_TM11H (void) { } +//void INT_SRE2 (void) { } + */ +void INT_SRE2 (void) { } + +/* + * INT_SMSE (0x1C) + */ +void INT_SMSE (void) { } + +/* + * INT_CSI00/INT_IIC00/INT_ST0 (0x1E) + */ +void INT_ST0 (void) { } +//void INT_CSI00 (void) { } +//void INT_IIC00 (void) { } + +/* + * INT_TM00 (0x20) + */ +void INT_TM00 (void) { } + +/* + * INT_TM01H (0x22) + */ +void INT_TM01H (void) { } + +/* + * INT_ST1 (0x24) + */ +void INT_ST1 (void) { } + +/* + * INT_CSI11/INT_IIC11/INT_SR1 (0x26) + */ +void INT_SR1 (void) { } +//void INT_CSI11 (void) { } +//void INT_IIC11 (void) { } + +/* + * INT_SRE1/INT_TM03H (0x28) + */ +void INT_TM03H (void) { } +//void INT_SRE1 (void) { } +void INT_SRE1 (void) { } + +/* + * INT_IICA0 (0x2A) + */ +void INT_IICA0 (void) { } + +/* + * INT_CSI01/INT_IIC01/INT_SR0 (0x2C) + */ +void INT_SR0 (void) { } +//void INT_CSI01 (void) { } +//void INT_IIC01 (void) { } +void r_Config_UART0_interrupt_receive(void) __attribute__ ((interrupt)); + +/* + * INT_TM01 (0x2E) + */ +void INT_TM01 (void) { } + +/* + * INT_TM02 (0x30) + */ +void INT_TM02 (void) { } + +/* + * INT_TM03 (0x32) + */ +void INT_TM03 (void) { } + +/* + * INT_AD (0x34) + */ +void INT_AD (void) { } + +/* + * INT_RTC (0x36) + */ +void INT_RTC (void) { } + +/* + * INT_ITL (0x38) + */ +void INT_ITL (void) { } + +/* + * INT_KR (0x3A) + */ +void INT_KR (void) { } + +/* + * INT_TM04 (0x42) + */ +void INT_TM04 (void) { } + +/* + * INT_TM05 (0x44) + */ +void INT_TM05 (void) { } + +/* + * INT_TM06 (0x46) + */ +void INT_TM06 (void) { } + +/* + * INT_TM07 (0x48) + */ +void INT_TM07 (void) { } + +/* + * INT_P6 (0x4A) + */ +void INT_P6 (void) { } + +/* + * INT_P8 (0x4E) + */ +void INT_P8 (void) { } + +/* + * INT_P9 (0x50) + */ +void INT_P9 (void) { } + +/* + * INT_FL (0x52) + */ +void INT_FL (void) { } + +/* + * INT_URE0 (0x58) + */ +void INT_URE0 (void) { } + +/* + * INT_CTSUWR (0x60) + */ +void INT_CTSUWR (void) { } + +/* + * INT_CTSURD (0x64) + */ +void INT_CTSURD (void) { } + +/* + * INT_CTSUFN (0x66) + */ +void INT_CTSUFN (void) { } + +/* + * INT_UT0 (0x6A) + */ +void INT_UT0 (void) { } + +/* + * INT_UR0 (0x6C) + */ +void INT_UR0 (void) { } + +/* + * INT_BRK_I (0x7E) + */ +void INT_BRK_I (void) { } diff --git a/cores/rl78g22/smc_gen/general/r_cg_itl.h b/cores/rl78g22/smc_gen/general/r_cg_itl.h index b9627d0..5b196a0 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_itl.h +++ b/cores/rl78g22/smc_gen/general/r_cg_itl.h @@ -1,212 +1,212 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_itl.h -* Version : 1.0.0 -* Device(s) : R7F102GGExFB -* Description : General header file for ITL peripheral. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef ITL_H -#define ITL_H - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ -/* - Peripheral Enable Register 1 (PER1) -*/ -/* Control of clock supply to 32-bit interval timer (TML32EN) */ -#define _00_ITL_CLOCK_STOP (0x00U) /* stops clock supply */ -#define _10_ITL_CLOCK_SUPPLY (0x10U) /* supplies clock */ - -/* - Peripheral Reset Control Register 1 (PRR1) -*/ -/* Peripheral reset control of 32-bit interval timer (TML32RES) */ -#define _00_ITL_RESET_RELEASE (0x00U) /* released from the reset state */ -#define _10_ITL_RESET_SET (0x10U) /* reset */ - -/* - Interval Timer Control Register (ITLCTL0) -*/ -/* Selection of 8-bit, 16-bit or 32-bit interval timer mode (ITLMD01,ITLMD00) */ -#define _00_ITL_MODE_8BIT (0x00U) /* 8-bit interval timer */ -#define _40_ITL_MODE_16BIT (0x40U) /* 16-bit interval timer */ -#define _80_ITL_MODE_32BIT (0x80U) /* 32-bit interval timer */ -/* Count enable for ITL013 (ITLEN03) */ -#define _00_ITL_ITL013_COUNT_STOP (0x00U) /* counting stops */ -#define _08_ITL_ITL013_COUNT_START (0x08U) /* counting begins */ -/* Count enable for ITL012 / ITL012 + ITL013 (ITLEN02) */ -#define _00_ITL_ITL012_COUNT_STOP (0x00U) /* counting stops */ -#define _04_ITL_ITL012_COUNT_START (0x04U) /* counting begins */ -/* Count enable for ITL001 (ITLEN01) */ -#define _00_ITL_ITL001_COUNT_STOP (0x00U) /* counting stops */ -#define _02_ITL_ITL001_COUNT_START (0x02U) /* counting begins */ -/* Count enable for ITL000/ITL000+ITL001/ITL000+ITL001+ITL012+ITL013 (ITLEN00) */ -#define _00_ITL_ITL000_COUNT_STOP (0x00U) /* counting stops */ -#define _01_ITL_ITL000_COUNT_START (0x01U) /* counting begins */ - -/* - Interval Timer Clock Select Register 0 (ITLCSEL0) -*/ -/* Selection of interval timer count source for capturing (fITL1) (CSEL012,CSEL011,CSEL010) */ -#define _00_ITL_CLOCK_FITL1_STOP (0x00U) /* counting stops */ -#define _10_ITL_CLOCK_FITL1_FIHP (0x10U) /* fIHP */ -#define _20_ITL_CLOCK_FITL1_FIMP (0x20U) /* fIMP */ -#define _30_ITL_CLOCK_FITL1_FMXP (0x30U) /* fMXP */ -#define _40_ITL_CLOCK_FITL1_FSXP (0x40U) /* fSXP */ -#define _50_ITL_CLOCK_FITL1_ELC (0x50U) /* event input from the ELC */ -#define _8F_ITL_CLOCK_FITL1_CLEAR (0x8FU) /* clear clock selection of fITL1 */ -/* Selection interval timer count source (fITL0) (ISEL002,ISEL001,ISEL000) */ -#define _00_ITL_CLOCK_FITL0_STOP (0x00U) /* counting stops */ -#define _01_ITL_CLOCK_FITL0_FIHP (0x01U) /* fIHP */ -#define _02_ITL_CLOCK_FITL0_FIMP (0x02U) /* fIMP */ -#define _03_ITL_CLOCK_FITL0_FMXP (0x03U) /* fMXP */ -#define _04_ITL_CLOCK_FITL0_FSXP (0x04U) /* fSXP */ -#define _05_ITL_CLOCK_FITL0_ELC (0x05U) /* event input from the ELC */ -#define _F8_ITL_CLOCK_FITL0_CLEAR (0xF8U) /* clear clock selection of fITL0 */ - -/* - Interval Timer Frequency Division Register 0 (ITLFDIV00) - */ -/* Selection of frequency division ratio for ITL001 (FDIV012,FDIV011,FDIV010) */ -#define _00_ITL_ITL001_FITL0_1 (0x00U) /* fITL0 */ -#define _10_ITL_ITL001_FITL0_2 (0x10U) /* fITL0/2 */ -#define _20_ITL_ITL001_FITL0_4 (0x20U) /* fITL0/4 */ -#define _30_ITL_ITL001_FITL0_8 (0x30U) /* fITL0/8 */ -#define _40_ITL_ITL001_FITL0_16 (0x40U) /* fITL0/16 */ -#define _50_ITL_ITL001_FITL0_32 (0x50U) /* fITL0/32 */ -#define _60_ITL_ITL001_FITL0_64 (0x60U) /* fITL0/64 */ -#define _70_ITL_ITL001_FITL0_128 (0x70U) /* fITL0/128 */ -#define _8F_ITL_ITL001_FITL0_CLEAR (0x8FU) /* clear fITL0 division selection of ITL001 */ -/* Selection of frequency division ratio for ITL000 (FDIV002,FDIV001,FDIV000) */ -#define _00_ITL_ITL000_FITL0_1 (0x00U) /* fITL0 */ -#define _01_ITL_ITL000_FITL0_2 (0x01U) /* fITL0/2 */ -#define _02_ITL_ITL000_FITL0_4 (0x02U) /* fITL0/4 */ -#define _03_ITL_ITL000_FITL0_8 (0x03U) /* fITL0/8 */ -#define _04_ITL_ITL000_FITL0_16 (0x04U) /* fITL0/16 */ -#define _05_ITL_ITL000_FITL0_32 (0x05U) /* fITL0/32 */ -#define _06_ITL_ITL000_FITL0_64 (0x06U) /* fITL0/64 */ -#define _07_ITL_ITL000_FITL0_128 (0x07U) /* fITL0/128 */ -#define _F8_ITL_ITL000_FITL0_CLEAR (0xF8U) /* clear fITL0 division selection of ITL000 */ - -/* - Interval Timer Frequency Division Register 1 (ITLFDIV01) - */ -/* Selection of frequency division ratio for ITL013 (FDIV032,FDIV031,FDIV030) */ -#define _00_ITL_ITL013_FITL0_1 (0x00U) /* fITL0 */ -#define _10_ITL_ITL013_FITL0_2 (0x10U) /* fITL0/2 */ -#define _20_ITL_ITL013_FITL0_4 (0x20U) /* fITL0/4 */ -#define _30_ITL_ITL013_FITL0_8 (0x30U) /* fITL0/8 */ -#define _40_ITL_ITL013_FITL0_16 (0x40U) /* fITL0/16 */ -#define _50_ITL_ITL013_FITL0_32 (0x50U) /* fITL0/32 */ -#define _60_ITL_ITL013_FITL0_64 (0x60U) /* fITL0/64 */ -#define _70_ITL_ITL013_FITL0_128 (0x70U) /* fITL0/128 */ -#define _8F_ITL_ITL013_FITL0_CLEAR (0x8FU) /* clear fITL0 division selection of ITL013 */ -/* Selection of frequency division ratio for ITL012 (FDIV022,FDIV021,FDIV020) */ -#define _00_ITL_ITL012_FITL0_1 (0x00U) /* fITL0 */ -#define _01_ITL_ITL012_FITL0_2 (0x01U) /* fITL0/2 */ -#define _02_ITL_ITL012_FITL0_4 (0x02U) /* fITL0/4 */ -#define _03_ITL_ITL012_FITL0_8 (0x03U) /* fITL0/8 */ -#define _04_ITL_ITL012_FITL0_16 (0x04U) /* fITL0/16 */ -#define _05_ITL_ITL012_FITL0_32 (0x05U) /* fITL0/32 */ -#define _06_ITL_ITL012_FITL0_64 (0x06U) /* fITL0/64 */ -#define _07_ITL_ITL012_FITL0_128 (0x07U) /* fITL0/128 */ -#define _F8_ITL_ITL012_FITL0_CLEAR (0xF8U) /* clear fITL0 division selection of ITL012 */ - -/* - Interval Timer Capture Control Register 0 (ITLCC0) -*/ -/* Capture enable (CAPEN0) */ -#define _00_ITL_CAPTURE_DISABLE (0x00U) /* capture is disabled */ -#define _80_ITL_CAPTURE_ENABLE (0x80U) /* capture is enabled */ -/* Capture completion flag clear (CAPF0CR) */ -#define _00_ITL_CAPTURE_COMPLETE_FLAG_RETAIN (0x00U) /* held capture completion flag CAPF0 */ -#define _40_ITL_CAPTURE_COMPLETE_FLAG_CLEAR (0x40U) /* clear capture completion flag CAPF0 */ -/* Capture completion flag (CAPF0) */ -#define _00_ITL_CAPTURE_NOT_COMPLETE (0x00U) /* capture not complete */ -#define _20_ITL_CAPTURE_COMPLETE (0x20U) /* capture complete */ -/* Software capture trigger (CAPR0) */ -#define _00_ITL_CAPTURE_SOFTWARE_NOT_TRIGGER (0x00U) /* software trigger is not generated */ -#define _10_ITL_CAPTURE_SOFTWARE_TRIGGER (0x10U) /* software trigger is generated */ -/* Selection of capture counter clearing after capturing (CAPC0CR) */ -#define _00_ITL_CAPTURE_COUNTER_RETAIN (0x00U) /* held the capture counter value */ -#define _08_ITL_CAPTURE_COUNTER_CLEAR (0x08U) /* clear the capture counter value */ -/* Selection of capture trigger (CTRS01,CTRS00) */ -#define _00_ITL_CAPTURE_TRIGGER_SOFTWARE (0x00U) /* software trigger */ -#define _01_ITL_CAPTURE_TRIGGER_INTERNAL (0x01U) /* interrupt on compare match with ITLCMP01 */ -#define _02_ITL_CAPTURE_TRIGGER_FSXP (0x02U) /* fSXP */ -#define _03_ITL_CAPTURE_TRIGGER_ELC (0x03U) /* event input from ELC (rising edge) */ -#define _FC_ITL_CAPTURE_TRIGGER_CLEAR (0xFCU) /* clear capture trigger selection */ - -/* - Interval Timer Status Register (ITLS0) -*/ -/* Capture detection flag (ITF0C) */ -#define _00_ITL_CAPTURE_COMPLETE_NOT_DETECTE (0x00U) /* completion of capturing not be detected */ -#define _10_ITL_CAPTURE_COMPLETE_DETECTE (0x10U) /* completion of capturing be detected */ -/* Compare match detection flag for channel 3 (ITF03) */ -#define _00_ITL_CHANNEL3_COUNT_MATCH_NOT_DETECTE (0x00U) /* channel 3 compare match signal not detected */ -#define _08_ITL_CHANNEL3_COUNT_MATCH_DETECTE (0x08U) /* channel 3 compare match signal detected */ -/* Compare match detection flag for channel 2 (ITF02) */ -#define _00_ITL_CHANNEL2_COUNT_MATCH_NOT_DETECTE (0x00U) /* channel 2 compare match signal not detected */ -#define _04_ITL_CHANNEL2_COUNT_MATCH_DETECTE (0x04U) /* channel 2 compare match signal detected */ -/* Compare match detection flag for channel 1 (ITF01) */ -#define _00_ITL_CHANNEL1_COUNT_MATCH_NOT_DETECTE (0x00U) /* channel 1 compare match signal not detected */ -#define _02_ITL_CHANNEL1_COUNT_MATCH_DETECTE (0x02U) /* channel 1 compare match signal detected */ -/* Compare match detection flag for channel 0 (ITF00) */ -#define _00_ITL_CHANNEL0_COUNT_MATCH_NOT_DETECTE (0x00U) /* channel 0 compare match signal not detected */ -#define _01_ITL_CHANNEL0_COUNT_MATCH_DETECTE (0x01U) /* channel 0 compare match signal detected */ - -/* - Interval Timer Match Detection Mask Register (ITLMKF0) -*/ -/* Mask for capture detection status flag (MKF0C) */ -#define _00_ITL_CAPTURE_COMPLETE_NOT_MASK (0x00U) /* not mask ITF0C */ -#define _10_ITL_CAPTURE_COMPLETE_MASK (0x10U) /* mask ITF0C */ -/* Mask for compare match status flag for channel 3 (MKF03) */ -#define _00_ITL_CHANNEL3_COUNT_MATCH_NOT_MASK (0x00U) /* not mask ITF03 */ -#define _08_ITL_CHANNEL3_COUNT_MATCH_MASK (0x08U) /* mask ITF03 */ -/* Mask for compare match status flag for channel 2 (MKF02) */ -#define _00_ITL_CHANNEL2_COUNT_MATCH_NOT_MASK (0x00U) /* not mask ITF02 */ -#define _04_ITL_CHANNEL2_COUNT_MATCH_MASK (0x04U) /* mask ITF02 */ -/* Mask for compare match status flag for channel 1 (MKF01) */ -#define _00_ITL_CHANNEL1_COUNT_MATCH_NOT_MASK (0x00U) /* not mask ITF01 */ -#define _02_ITL_CHANNEL1_COUNT_MATCH_MASK (0x02U) /* mask ITF01 */ -/* Mask for compare match status flag for channel 0 (MKF00) */ -#define _00_ITL_CHANNEL0_COUNT_MATCH_NOT_MASK (0x00U) /* not mask ITF00 */ -#define _01_ITL_CHANNEL0_COUNT_MATCH_MASK (0x01U) /* mask ITF00 */ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_itl.h +* Version : 1.0.0 +* Device(s) : R7F102GGExFB +* Description : General header file for ITL peripheral. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef ITL_H +#define ITL_H + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ +/* + Peripheral Enable Register 1 (PER1) +*/ +/* Control of clock supply to 32-bit interval timer (TML32EN) */ +#define _00_ITL_CLOCK_STOP (0x00U) /* stops clock supply */ +#define _10_ITL_CLOCK_SUPPLY (0x10U) /* supplies clock */ + +/* + Peripheral Reset Control Register 1 (PRR1) +*/ +/* Peripheral reset control of 32-bit interval timer (TML32RES) */ +#define _00_ITL_RESET_RELEASE (0x00U) /* released from the reset state */ +#define _10_ITL_RESET_SET (0x10U) /* reset */ + +/* + Interval Timer Control Register (ITLCTL0) +*/ +/* Selection of 8-bit, 16-bit or 32-bit interval timer mode (ITLMD01,ITLMD00) */ +#define _00_ITL_MODE_8BIT (0x00U) /* 8-bit interval timer */ +#define _40_ITL_MODE_16BIT (0x40U) /* 16-bit interval timer */ +#define _80_ITL_MODE_32BIT (0x80U) /* 32-bit interval timer */ +/* Count enable for ITL013 (ITLEN03) */ +#define _00_ITL_ITL013_COUNT_STOP (0x00U) /* counting stops */ +#define _08_ITL_ITL013_COUNT_START (0x08U) /* counting begins */ +/* Count enable for ITL012 / ITL012 + ITL013 (ITLEN02) */ +#define _00_ITL_ITL012_COUNT_STOP (0x00U) /* counting stops */ +#define _04_ITL_ITL012_COUNT_START (0x04U) /* counting begins */ +/* Count enable for ITL001 (ITLEN01) */ +#define _00_ITL_ITL001_COUNT_STOP (0x00U) /* counting stops */ +#define _02_ITL_ITL001_COUNT_START (0x02U) /* counting begins */ +/* Count enable for ITL000/ITL000+ITL001/ITL000+ITL001+ITL012+ITL013 (ITLEN00) */ +#define _00_ITL_ITL000_COUNT_STOP (0x00U) /* counting stops */ +#define _01_ITL_ITL000_COUNT_START (0x01U) /* counting begins */ + +/* + Interval Timer Clock Select Register 0 (ITLCSEL0) +*/ +/* Selection of interval timer count source for capturing (fITL1) (CSEL012,CSEL011,CSEL010) */ +#define _00_ITL_CLOCK_FITL1_STOP (0x00U) /* counting stops */ +#define _10_ITL_CLOCK_FITL1_FIHP (0x10U) /* fIHP */ +#define _20_ITL_CLOCK_FITL1_FIMP (0x20U) /* fIMP */ +#define _30_ITL_CLOCK_FITL1_FMXP (0x30U) /* fMXP */ +#define _40_ITL_CLOCK_FITL1_FSXP (0x40U) /* fSXP */ +#define _50_ITL_CLOCK_FITL1_ELC (0x50U) /* event input from the ELC */ +#define _8F_ITL_CLOCK_FITL1_CLEAR (0x8FU) /* clear clock selection of fITL1 */ +/* Selection interval timer count source (fITL0) (ISEL002,ISEL001,ISEL000) */ +#define _00_ITL_CLOCK_FITL0_STOP (0x00U) /* counting stops */ +#define _01_ITL_CLOCK_FITL0_FIHP (0x01U) /* fIHP */ +#define _02_ITL_CLOCK_FITL0_FIMP (0x02U) /* fIMP */ +#define _03_ITL_CLOCK_FITL0_FMXP (0x03U) /* fMXP */ +#define _04_ITL_CLOCK_FITL0_FSXP (0x04U) /* fSXP */ +#define _05_ITL_CLOCK_FITL0_ELC (0x05U) /* event input from the ELC */ +#define _F8_ITL_CLOCK_FITL0_CLEAR (0xF8U) /* clear clock selection of fITL0 */ + +/* + Interval Timer Frequency Division Register 0 (ITLFDIV00) + */ +/* Selection of frequency division ratio for ITL001 (FDIV012,FDIV011,FDIV010) */ +#define _00_ITL_ITL001_FITL0_1 (0x00U) /* fITL0 */ +#define _10_ITL_ITL001_FITL0_2 (0x10U) /* fITL0/2 */ +#define _20_ITL_ITL001_FITL0_4 (0x20U) /* fITL0/4 */ +#define _30_ITL_ITL001_FITL0_8 (0x30U) /* fITL0/8 */ +#define _40_ITL_ITL001_FITL0_16 (0x40U) /* fITL0/16 */ +#define _50_ITL_ITL001_FITL0_32 (0x50U) /* fITL0/32 */ +#define _60_ITL_ITL001_FITL0_64 (0x60U) /* fITL0/64 */ +#define _70_ITL_ITL001_FITL0_128 (0x70U) /* fITL0/128 */ +#define _8F_ITL_ITL001_FITL0_CLEAR (0x8FU) /* clear fITL0 division selection of ITL001 */ +/* Selection of frequency division ratio for ITL000 (FDIV002,FDIV001,FDIV000) */ +#define _00_ITL_ITL000_FITL0_1 (0x00U) /* fITL0 */ +#define _01_ITL_ITL000_FITL0_2 (0x01U) /* fITL0/2 */ +#define _02_ITL_ITL000_FITL0_4 (0x02U) /* fITL0/4 */ +#define _03_ITL_ITL000_FITL0_8 (0x03U) /* fITL0/8 */ +#define _04_ITL_ITL000_FITL0_16 (0x04U) /* fITL0/16 */ +#define _05_ITL_ITL000_FITL0_32 (0x05U) /* fITL0/32 */ +#define _06_ITL_ITL000_FITL0_64 (0x06U) /* fITL0/64 */ +#define _07_ITL_ITL000_FITL0_128 (0x07U) /* fITL0/128 */ +#define _F8_ITL_ITL000_FITL0_CLEAR (0xF8U) /* clear fITL0 division selection of ITL000 */ + +/* + Interval Timer Frequency Division Register 1 (ITLFDIV01) + */ +/* Selection of frequency division ratio for ITL013 (FDIV032,FDIV031,FDIV030) */ +#define _00_ITL_ITL013_FITL0_1 (0x00U) /* fITL0 */ +#define _10_ITL_ITL013_FITL0_2 (0x10U) /* fITL0/2 */ +#define _20_ITL_ITL013_FITL0_4 (0x20U) /* fITL0/4 */ +#define _30_ITL_ITL013_FITL0_8 (0x30U) /* fITL0/8 */ +#define _40_ITL_ITL013_FITL0_16 (0x40U) /* fITL0/16 */ +#define _50_ITL_ITL013_FITL0_32 (0x50U) /* fITL0/32 */ +#define _60_ITL_ITL013_FITL0_64 (0x60U) /* fITL0/64 */ +#define _70_ITL_ITL013_FITL0_128 (0x70U) /* fITL0/128 */ +#define _8F_ITL_ITL013_FITL0_CLEAR (0x8FU) /* clear fITL0 division selection of ITL013 */ +/* Selection of frequency division ratio for ITL012 (FDIV022,FDIV021,FDIV020) */ +#define _00_ITL_ITL012_FITL0_1 (0x00U) /* fITL0 */ +#define _01_ITL_ITL012_FITL0_2 (0x01U) /* fITL0/2 */ +#define _02_ITL_ITL012_FITL0_4 (0x02U) /* fITL0/4 */ +#define _03_ITL_ITL012_FITL0_8 (0x03U) /* fITL0/8 */ +#define _04_ITL_ITL012_FITL0_16 (0x04U) /* fITL0/16 */ +#define _05_ITL_ITL012_FITL0_32 (0x05U) /* fITL0/32 */ +#define _06_ITL_ITL012_FITL0_64 (0x06U) /* fITL0/64 */ +#define _07_ITL_ITL012_FITL0_128 (0x07U) /* fITL0/128 */ +#define _F8_ITL_ITL012_FITL0_CLEAR (0xF8U) /* clear fITL0 division selection of ITL012 */ + +/* + Interval Timer Capture Control Register 0 (ITLCC0) +*/ +/* Capture enable (CAPEN0) */ +#define _00_ITL_CAPTURE_DISABLE (0x00U) /* capture is disabled */ +#define _80_ITL_CAPTURE_ENABLE (0x80U) /* capture is enabled */ +/* Capture completion flag clear (CAPF0CR) */ +#define _00_ITL_CAPTURE_COMPLETE_FLAG_RETAIN (0x00U) /* held capture completion flag CAPF0 */ +#define _40_ITL_CAPTURE_COMPLETE_FLAG_CLEAR (0x40U) /* clear capture completion flag CAPF0 */ +/* Capture completion flag (CAPF0) */ +#define _00_ITL_CAPTURE_NOT_COMPLETE (0x00U) /* capture not complete */ +#define _20_ITL_CAPTURE_COMPLETE (0x20U) /* capture complete */ +/* Software capture trigger (CAPR0) */ +#define _00_ITL_CAPTURE_SOFTWARE_NOT_TRIGGER (0x00U) /* software trigger is not generated */ +#define _10_ITL_CAPTURE_SOFTWARE_TRIGGER (0x10U) /* software trigger is generated */ +/* Selection of capture counter clearing after capturing (CAPC0CR) */ +#define _00_ITL_CAPTURE_COUNTER_RETAIN (0x00U) /* held the capture counter value */ +#define _08_ITL_CAPTURE_COUNTER_CLEAR (0x08U) /* clear the capture counter value */ +/* Selection of capture trigger (CTRS01,CTRS00) */ +#define _00_ITL_CAPTURE_TRIGGER_SOFTWARE (0x00U) /* software trigger */ +#define _01_ITL_CAPTURE_TRIGGER_INTERNAL (0x01U) /* interrupt on compare match with ITLCMP01 */ +#define _02_ITL_CAPTURE_TRIGGER_FSXP (0x02U) /* fSXP */ +#define _03_ITL_CAPTURE_TRIGGER_ELC (0x03U) /* event input from ELC (rising edge) */ +#define _FC_ITL_CAPTURE_TRIGGER_CLEAR (0xFCU) /* clear capture trigger selection */ + +/* + Interval Timer Status Register (ITLS0) +*/ +/* Capture detection flag (ITF0C) */ +#define _00_ITL_CAPTURE_COMPLETE_NOT_DETECTE (0x00U) /* completion of capturing not be detected */ +#define _10_ITL_CAPTURE_COMPLETE_DETECTE (0x10U) /* completion of capturing be detected */ +/* Compare match detection flag for channel 3 (ITF03) */ +#define _00_ITL_CHANNEL3_COUNT_MATCH_NOT_DETECTE (0x00U) /* channel 3 compare match signal not detected */ +#define _08_ITL_CHANNEL3_COUNT_MATCH_DETECTE (0x08U) /* channel 3 compare match signal detected */ +/* Compare match detection flag for channel 2 (ITF02) */ +#define _00_ITL_CHANNEL2_COUNT_MATCH_NOT_DETECTE (0x00U) /* channel 2 compare match signal not detected */ +#define _04_ITL_CHANNEL2_COUNT_MATCH_DETECTE (0x04U) /* channel 2 compare match signal detected */ +/* Compare match detection flag for channel 1 (ITF01) */ +#define _00_ITL_CHANNEL1_COUNT_MATCH_NOT_DETECTE (0x00U) /* channel 1 compare match signal not detected */ +#define _02_ITL_CHANNEL1_COUNT_MATCH_DETECTE (0x02U) /* channel 1 compare match signal detected */ +/* Compare match detection flag for channel 0 (ITF00) */ +#define _00_ITL_CHANNEL0_COUNT_MATCH_NOT_DETECTE (0x00U) /* channel 0 compare match signal not detected */ +#define _01_ITL_CHANNEL0_COUNT_MATCH_DETECTE (0x01U) /* channel 0 compare match signal detected */ + +/* + Interval Timer Match Detection Mask Register (ITLMKF0) +*/ +/* Mask for capture detection status flag (MKF0C) */ +#define _00_ITL_CAPTURE_COMPLETE_NOT_MASK (0x00U) /* not mask ITF0C */ +#define _10_ITL_CAPTURE_COMPLETE_MASK (0x10U) /* mask ITF0C */ +/* Mask for compare match status flag for channel 3 (MKF03) */ +#define _00_ITL_CHANNEL3_COUNT_MATCH_NOT_MASK (0x00U) /* not mask ITF03 */ +#define _08_ITL_CHANNEL3_COUNT_MATCH_MASK (0x08U) /* mask ITF03 */ +/* Mask for compare match status flag for channel 2 (MKF02) */ +#define _00_ITL_CHANNEL2_COUNT_MATCH_NOT_MASK (0x00U) /* not mask ITF02 */ +#define _04_ITL_CHANNEL2_COUNT_MATCH_MASK (0x04U) /* mask ITF02 */ +/* Mask for compare match status flag for channel 1 (MKF01) */ +#define _00_ITL_CHANNEL1_COUNT_MATCH_NOT_MASK (0x00U) /* not mask ITF01 */ +#define _02_ITL_CHANNEL1_COUNT_MATCH_MASK (0x02U) /* mask ITF01 */ +/* Mask for compare match status flag for channel 0 (MKF00) */ +#define _00_ITL_CHANNEL0_COUNT_MATCH_NOT_MASK (0x00U) /* not mask ITF00 */ +#define _01_ITL_CHANNEL0_COUNT_MATCH_MASK (0x01U) /* mask ITF00 */ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/general/r_cg_itl_common.c b/cores/rl78g22/smc_gen/general/r_cg_itl_common.c index 1d6cd21..9b45fca 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_itl_common.c +++ b/cores/rl78g22/smc_gen/general/r_cg_itl_common.c @@ -1,136 +1,136 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_itl_common.c -* Version : 1.0.0 -* Device(s) : R7F102GGExFB -* Description : None -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_ITL000.h" -#include "Config_ITL012.h" -#include "r_cg_itl_common.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_ITL_Create -* Description : This function initializes the 32-bits IT. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_ITL_Create(void) -{ - TML32EN = 1U; /* start 32-bits IT clock */ - /* Set 32-bits IT settings */ - R_Config_ITL000_Create(); - R_Config_ITL012_Create(); -} - -/*********************************************************************************************************************** -* Function Name: R_ITL_Start_Interrupt -* Description : This function starts INTITL interrupt. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_ITL_Start_Interrupt(void) -{ - /* Clear INTITL interrupt request and enable operation */ - ITLIF = 0U; /* clear INTITL interrupt flag */ - ITLMK = 0U; /* enable INTITL interrupt */ -} - -/*********************************************************************************************************************** -* Function Name: R_ITL_Stop_Interrupt -* Description : This function stops INTITL interrupt. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_ITL_Stop_Interrupt(void) -{ - /* Disable INTITL interrupt operation and clear request */ - ITLMK = 1U; /* disable INTITL interrupt */ - ITLIF = 0U; /* clear INTITL interrupt flag */ -} - -/*********************************************************************************************************************** -* Function Name: R_ITL_Set_PowerOn -* Description : This function starts the clock supply for 32-bits IT. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_ITL_Set_PowerOn(void) -{ - TML32EN = 1U; /* start 32-bits IT clock */ -} - -/*********************************************************************************************************************** -* Function Name: R_ITL_Set_PowerOff -* Description : This function stops the clock supply for 32-bits IT. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_ITL_Set_PowerOff(void) -{ - TML32EN = 0U; /* stop 32-bits IT clock */ -} - -/*********************************************************************************************************************** -* Function Name: R_ITL_Set_Reset -* Description : This function sets 32-bits IT module in reset state. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_ITL_Set_Reset(void) -{ - TML32RES = 1U; /* reset 32-bit IT */ -} - -/*********************************************************************************************************************** -* Function Name: R_ITL_Release_Reset -* Description : This function releases 32-bits IT module from reset state. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_ITL_Release_Reset(void) -{ - TML32RES = 0U; /* release 32-bits IT */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_itl_common.c +* Version : 1.0.0 +* Device(s) : R7F102GGExFB +* Description : None +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_ITL000.h" +#include "Config_ITL012.h" +#include "r_cg_itl_common.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_ITL_Create +* Description : This function initializes the 32-bits IT. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_ITL_Create(void) +{ + TML32EN = 1U; /* start 32-bits IT clock */ + /* Set 32-bits IT settings */ + R_Config_ITL000_Create(); + R_Config_ITL012_Create(); +} + +/*********************************************************************************************************************** +* Function Name: R_ITL_Start_Interrupt +* Description : This function starts INTITL interrupt. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_ITL_Start_Interrupt(void) +{ + /* Clear INTITL interrupt request and enable operation */ + ITLIF = 0U; /* clear INTITL interrupt flag */ + ITLMK = 0U; /* enable INTITL interrupt */ +} + +/*********************************************************************************************************************** +* Function Name: R_ITL_Stop_Interrupt +* Description : This function stops INTITL interrupt. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_ITL_Stop_Interrupt(void) +{ + /* Disable INTITL interrupt operation and clear request */ + ITLMK = 1U; /* disable INTITL interrupt */ + ITLIF = 0U; /* clear INTITL interrupt flag */ +} + +/*********************************************************************************************************************** +* Function Name: R_ITL_Set_PowerOn +* Description : This function starts the clock supply for 32-bits IT. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_ITL_Set_PowerOn(void) +{ + TML32EN = 1U; /* start 32-bits IT clock */ +} + +/*********************************************************************************************************************** +* Function Name: R_ITL_Set_PowerOff +* Description : This function stops the clock supply for 32-bits IT. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_ITL_Set_PowerOff(void) +{ + TML32EN = 0U; /* stop 32-bits IT clock */ +} + +/*********************************************************************************************************************** +* Function Name: R_ITL_Set_Reset +* Description : This function sets 32-bits IT module in reset state. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_ITL_Set_Reset(void) +{ + TML32RES = 1U; /* reset 32-bit IT */ +} + +/*********************************************************************************************************************** +* Function Name: R_ITL_Release_Reset +* Description : This function releases 32-bits IT module from reset state. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_ITL_Release_Reset(void) +{ + TML32RES = 0U; /* release 32-bits IT */ +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/general/r_cg_itl_common.h b/cores/rl78g22/smc_gen/general/r_cg_itl_common.h index 225b965..0f3a9c9 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_itl_common.h +++ b/cores/rl78g22/smc_gen/general/r_cg_itl_common.h @@ -1,55 +1,55 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_itl_common.h -* Version : 1.0.0 -* Device(s) : R7F102GGExFB -* Description : Common header file for ITL peripheral. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef ITL_COMMON_H -#define ITL_COMMON_H - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_ITL_Create (void); -void R_ITL_Start_Interrupt (void); -void R_ITL_Stop_Interrupt (void); -void R_ITL_Set_PowerOn (void); -void R_ITL_Set_PowerOff (void); -void R_ITL_Set_Reset (void); -void R_ITL_Release_Reset (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_itl_common.h +* Version : 1.0.0 +* Device(s) : R7F102GGExFB +* Description : Common header file for ITL peripheral. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef ITL_COMMON_H +#define ITL_COMMON_H + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_ITL_Create (void); +void R_ITL_Start_Interrupt (void); +void R_ITL_Stop_Interrupt (void); +void R_ITL_Set_PowerOn (void); +void R_ITL_Set_PowerOff (void); +void R_ITL_Set_Reset (void); +void R_ITL_Release_Reset (void); +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/general/r_cg_itl_common_user.c b/cores/rl78g22/smc_gen/general/r_cg_itl_common_user.c index 7567a5e..850687a 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_itl_common_user.c +++ b/cores/rl78g22/smc_gen/general/r_cg_itl_common_user.c @@ -1,83 +1,83 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_itl_common_user.c -* Version : 1.0.0 -* Device(s) : R7F102GGExFB -* Description : None -* Creation Date: 2022/11/07 -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_ITL000.h" -#include "Config_ITL001.h" -#include "Config_ITL012.h" -#include "Config_ITL013.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: r_itl_interrupt -* Description : This function is INTITL interrupt service routine. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void r_itl_interrupt(void) -{ - if (_01_ITL_CHANNEL0_COUNT_MATCH_DETECTE == (ITLS0 & _01_ITL_CHANNEL0_COUNT_MATCH_DETECTE)) - { - ITLS0 &= (uint8_t)~_01_ITL_CHANNEL0_COUNT_MATCH_DETECTE; - R_Config_ITL000_Callback_Shared_Interrupt(); - } - if (_02_ITL_CHANNEL1_COUNT_MATCH_DETECTE == (ITLS0 & _02_ITL_CHANNEL1_COUNT_MATCH_DETECTE)) - { - ITLS0 &= (uint16_t)~_02_ITL_CHANNEL1_COUNT_MATCH_DETECTE; - R_Config_ITL001_Callback_Shared_Interrupt(); - } - if (_04_ITL_CHANNEL2_COUNT_MATCH_DETECTE == (ITLS0 & _04_ITL_CHANNEL2_COUNT_MATCH_DETECTE)) - { - ITLS0 &= (uint16_t)~_04_ITL_CHANNEL2_COUNT_MATCH_DETECTE; - R_Config_ITL012_Callback_Shared_Interrupt(); - } - if (_08_ITL_CHANNEL3_COUNT_MATCH_DETECTE == (ITLS0 & _08_ITL_CHANNEL3_COUNT_MATCH_DETECTE)) - { - ITLS0 &= (uint8_t)~_08_ITL_CHANNEL3_COUNT_MATCH_DETECTE; - R_Config_ITL013_Callback_Shared_Interrupt(); - } -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_itl_common_user.c +* Version : 1.0.0 +* Device(s) : R7F102GGExFB +* Description : None +* Creation Date: 2022/11/07 +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_ITL000.h" +#include "Config_ITL001.h" +#include "Config_ITL012.h" +#include "Config_ITL013.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: r_itl_interrupt +* Description : This function is INTITL interrupt service routine. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void r_itl_interrupt(void) +{ + if (_01_ITL_CHANNEL0_COUNT_MATCH_DETECTE == (ITLS0 & _01_ITL_CHANNEL0_COUNT_MATCH_DETECTE)) + { + ITLS0 &= (uint8_t)~_01_ITL_CHANNEL0_COUNT_MATCH_DETECTE; + R_Config_ITL000_Callback_Shared_Interrupt(); + } + if (_02_ITL_CHANNEL1_COUNT_MATCH_DETECTE == (ITLS0 & _02_ITL_CHANNEL1_COUNT_MATCH_DETECTE)) + { + ITLS0 &= (uint16_t)~_02_ITL_CHANNEL1_COUNT_MATCH_DETECTE; + R_Config_ITL001_Callback_Shared_Interrupt(); + } + if (_04_ITL_CHANNEL2_COUNT_MATCH_DETECTE == (ITLS0 & _04_ITL_CHANNEL2_COUNT_MATCH_DETECTE)) + { + ITLS0 &= (uint16_t)~_04_ITL_CHANNEL2_COUNT_MATCH_DETECTE; + R_Config_ITL012_Callback_Shared_Interrupt(); + } + if (_08_ITL_CHANNEL3_COUNT_MATCH_DETECTE == (ITLS0 & _08_ITL_CHANNEL3_COUNT_MATCH_DETECTE)) + { + ITLS0 &= (uint8_t)~_08_ITL_CHANNEL3_COUNT_MATCH_DETECTE; + R_Config_ITL013_Callback_Shared_Interrupt(); + } +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/general/r_cg_macrodriver.h b/cores/rl78g22/smc_gen/general/r_cg_macrodriver.h index 10423d3..d645a60 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_macrodriver.h +++ b/cores/rl78g22/smc_gen/general/r_cg_macrodriver.h @@ -1,78 +1,78 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_macrodriver.h -* Version : 1.0.0 -* Device(s) : R7F102GGExFB -* Description : Macro header file for code generation. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef MODULEID_H -#define MODULEID_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "platform.h" -#include "r_cg_interrupt_handlers.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -#ifndef __TYPEDEF__ -#endif -/* Status list definition */ -#define MD_STATUSBASE (0x00U) -#define MD_OK (MD_STATUSBASE + 0x00U) /* register setting OK */ -#define MD_SPT (MD_STATUSBASE + 0x01U) /* IIC stop */ -#define MD_NACK (MD_STATUSBASE + 0x02U) /* IIC no ACK */ -#define MD_BUSY1 (MD_STATUSBASE + 0x03U) /* busy 1 */ -#define MD_BUSY2 (MD_STATUSBASE + 0x04U) /* busy 2 */ -#define MD_OVERRUN (MD_STATUSBASE + 0x05U) /* IIC OVERRUN occur */ -/* Error list definition */ -#define MD_ERRORBASE (0x80U) -#define MD_ERROR (MD_ERRORBASE + 0x00U) /* error */ -#define MD_ARGERROR (MD_ERRORBASE + 0x01U) /* error argument input error */ -#define MD_ERROR1 (MD_ERRORBASE + 0x02U) /* error 1 */ -#define MD_ERROR2 (MD_ERRORBASE + 0x03U) /* error 2 */ -#define MD_ERROR3 (MD_ERRORBASE + 0x04U) /* error 3 */ -#define MD_ERROR4 (MD_ERRORBASE + 0x05U) /* error 4 */ -#define MD_ERROR5 (MD_ERRORBASE + 0x06U) /* error 5 */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ -#ifndef __TYPEDEF__ -typedef unsigned short MD_STATUS; -#define __TYPEDEF__ -#endif - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_Systeminit(void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_macrodriver.h +* Version : 1.0.0 +* Device(s) : R7F102GGExFB +* Description : Macro header file for code generation. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef MODULEID_H +#define MODULEID_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "platform.h" +#include "r_cg_interrupt_handlers.h" + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ +#ifndef __TYPEDEF__ +#endif +/* Status list definition */ +#define MD_STATUSBASE (0x00U) +#define MD_OK (MD_STATUSBASE + 0x00U) /* register setting OK */ +#define MD_SPT (MD_STATUSBASE + 0x01U) /* IIC stop */ +#define MD_NACK (MD_STATUSBASE + 0x02U) /* IIC no ACK */ +#define MD_BUSY1 (MD_STATUSBASE + 0x03U) /* busy 1 */ +#define MD_BUSY2 (MD_STATUSBASE + 0x04U) /* busy 2 */ +#define MD_OVERRUN (MD_STATUSBASE + 0x05U) /* IIC OVERRUN occur */ +/* Error list definition */ +#define MD_ERRORBASE (0x80U) +#define MD_ERROR (MD_ERRORBASE + 0x00U) /* error */ +#define MD_ARGERROR (MD_ERRORBASE + 0x01U) /* error argument input error */ +#define MD_ERROR1 (MD_ERRORBASE + 0x02U) /* error 1 */ +#define MD_ERROR2 (MD_ERRORBASE + 0x03U) /* error 2 */ +#define MD_ERROR3 (MD_ERRORBASE + 0x04U) /* error 3 */ +#define MD_ERROR4 (MD_ERRORBASE + 0x05U) /* error 4 */ +#define MD_ERROR5 (MD_ERRORBASE + 0x06U) /* error 5 */ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ +#ifndef __TYPEDEF__ +typedef unsigned short MD_STATUS; +#define __TYPEDEF__ +#endif + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_Systeminit(void); +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/general/r_cg_rtc.h b/cores/rl78g22/smc_gen/general/r_cg_rtc.h index bcd8006..d662130 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_rtc.h +++ b/cores/rl78g22/smc_gen/general/r_cg_rtc.h @@ -1,114 +1,114 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_rtc.h -* Version : 1.0.3 -* Device(s) : R7F100GLGxFB -* Description : General header file for RTC peripheral. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef RTC_H -#define RTC_H - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ -/* - Peripheral Enable Register 0 (PER0) -*/ -/* Control of real-time clock (RTC) input clock (RTCWEN) */ -#define _00_RTC_CLOCK_STOP (0x00U) /* stops supply of input clock */ -#define _80_RTC_CLOCK_SUPPLY (0x80U) /* supplies input clock */ - -/* - Subsystem Clock Supply Mode Control Register (OSMC) -*/ -/* Selection of operation clock (fRTCCK) for real-time clock (WUTMMCK0) */ -#define _00_RTC_CLK_FSXR (0x00U) /* subsystem clock (fSXR) or fRTC128HZ */ -#define _10_RTC_CLK_FIL (0x10U) /* low-speed on-chip oscillator clock (fIL) */ - -/* - Real-Time Clock Control Register 0 (RTCC0) -*/ -/* Real-time clock operation control (RTCE) */ -#define _00_RTC_COUNTER_STOP (0x00U) /* stops counter operation */ -#define _80_RTC_COUNTER_START (0x80U) /* starts counter operation */ -/* RTC1HZ pin output control (RCLOE1) */ -#define _00_RTC_RTC1HZ_DISABLE (0x00U) /* disables output of the RTC1HZ pin (1 Hz) */ -#define _20_RTC_RTC1HZ_ENABLE (0x20U) /* enables output of the RTC1HZ pin (1 Hz) */ -/* Operation clock (fRTCCLK) selection (RTC128EN) */ -#define _00_RTC_CLK_32KHZ (0x00U) /* 32.768kHz */ -#define _10_RTC_CLK_128HZ (0x10U) /* 128Hz */ -/* Selection of 12-/24-hour system (AMPM) */ -#define _08_RTC_HOURSYSTEM_CLEAR (0x08U) /* clear the AMPM bit */ -#define _08_RTC_RTCC0_AMPM (0x08U) /* AMPM bit status detect */ -#define _00_RTC_12HOUR_MODE (0x00U) /* 12-hour system */ -#define _08_RTC_24HOUR_MODE (0x08U) /* 24-hour system */ -/* Constant-period interrupt (INTRTC) selection (CT2 - CT0) */ -#define _F8_RTC_INTRTC_CLEAR (0xF8U) /* clear constant-period interrupt function */ -#define _00_RTC_INTRTC_NOT_GENERATE (0x00U) /* does not use constant-period - interrupt function */ -#define _01_RTC_INTRTC_CLOCK_05SEC (0x01U) /* once per 0.5 second */ -#define _02_RTC_INTRTC_CLOCK_1SEC (0x02U) /* once per 1 second */ -#define _03_RTC_INTRTC_CLOCK_1MINU (0x03U) /* once per 1 minute */ -#define _04_RTC_INTRTC_CLOCK_1HOUR (0x04U) /* once per 1 hour */ -#define _05_RTC_INTRTC_CLOCK_1DAY (0x05U) /* once per 1 day */ -#define _06_RTC_INTRTC_CLOCK_1MONTH (0x06U) /* once per 1 month */ - -/* - Real-Time Clock Control Register 1 (RTCC1) -*/ -/* Alarm operation control (WALE) */ -#define _00_RTC_ALARM_DISABLE (0x00U) /* alarm match operation is invalid */ -#define _80_RTC_ALARM_ENABLE (0x80U) /* alarm match operation is valid */ -/* Control of alarm interrupt (INTRTC) function operation (WALIE) */ -#define _00_RTC_ALARM_INT_DISABLE (0x00U) /* does not generate interrupt on - matching of alarm */ -#define _40_RTC_ALARM_INT_ENABLE (0x40U) /* generates interrupt on matching of alarm */ -/* Alarm detection status flag (WAFG) */ -#define _00_RTC_ALARM_MISMATCH (0x00U) /* alarm mismatch */ -#define _10_RTC_ALARM_MATCH (0x10U) /* detection of matching of alarm */ -/* Constant-period interrupt status flag (RIFG) */ -#define _00_RTC_INTC_NOTGENERATE_FLAG (0x00U) /* constant-period interrupt - is not generated */ -#define _08_RTC_INTC_GENERATE_FLAG (0x08U) /* constant-period interrupt is generated */ -/* Wait status flag of real-time clock (RWST) */ -#define _00_RTC_COUNTER_OPERATING (0x00U) /* counter is operating */ -#define _02_RTC_COUNTER_STOP (0x02U) /* mode to read or write counter value */ -/* Wait control of real-time clock (RWAIT) */ -#define _00_RTC_COUNTER_SET (0x00U) /* sets counter operation */ -#define _01_RTC_COUNTER_PAUSE (0x01U) /* stops SEC to YEAR counters. - Mode to read or write counter value */ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_rtc.h +* Version : 1.0.3 +* Device(s) : R7F100GLGxFB +* Description : General header file for RTC peripheral. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef RTC_H +#define RTC_H + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ +/* + Peripheral Enable Register 0 (PER0) +*/ +/* Control of real-time clock (RTC) input clock (RTCWEN) */ +#define _00_RTC_CLOCK_STOP (0x00U) /* stops supply of input clock */ +#define _80_RTC_CLOCK_SUPPLY (0x80U) /* supplies input clock */ + +/* + Subsystem Clock Supply Mode Control Register (OSMC) +*/ +/* Selection of operation clock (fRTCCK) for real-time clock (WUTMMCK0) */ +#define _00_RTC_CLK_FSXR (0x00U) /* subsystem clock (fSXR) or fRTC128HZ */ +#define _10_RTC_CLK_FIL (0x10U) /* low-speed on-chip oscillator clock (fIL) */ + +/* + Real-Time Clock Control Register 0 (RTCC0) +*/ +/* Real-time clock operation control (RTCE) */ +#define _00_RTC_COUNTER_STOP (0x00U) /* stops counter operation */ +#define _80_RTC_COUNTER_START (0x80U) /* starts counter operation */ +/* RTC1HZ pin output control (RCLOE1) */ +#define _00_RTC_RTC1HZ_DISABLE (0x00U) /* disables output of the RTC1HZ pin (1 Hz) */ +#define _20_RTC_RTC1HZ_ENABLE (0x20U) /* enables output of the RTC1HZ pin (1 Hz) */ +/* Operation clock (fRTCCLK) selection (RTC128EN) */ +#define _00_RTC_CLK_32KHZ (0x00U) /* 32.768kHz */ +#define _10_RTC_CLK_128HZ (0x10U) /* 128Hz */ +/* Selection of 12-/24-hour system (AMPM) */ +#define _08_RTC_HOURSYSTEM_CLEAR (0x08U) /* clear the AMPM bit */ +#define _08_RTC_RTCC0_AMPM (0x08U) /* AMPM bit status detect */ +#define _00_RTC_12HOUR_MODE (0x00U) /* 12-hour system */ +#define _08_RTC_24HOUR_MODE (0x08U) /* 24-hour system */ +/* Constant-period interrupt (INTRTC) selection (CT2 - CT0) */ +#define _F8_RTC_INTRTC_CLEAR (0xF8U) /* clear constant-period interrupt function */ +#define _00_RTC_INTRTC_NOT_GENERATE (0x00U) /* does not use constant-period + interrupt function */ +#define _01_RTC_INTRTC_CLOCK_05SEC (0x01U) /* once per 0.5 second */ +#define _02_RTC_INTRTC_CLOCK_1SEC (0x02U) /* once per 1 second */ +#define _03_RTC_INTRTC_CLOCK_1MINU (0x03U) /* once per 1 minute */ +#define _04_RTC_INTRTC_CLOCK_1HOUR (0x04U) /* once per 1 hour */ +#define _05_RTC_INTRTC_CLOCK_1DAY (0x05U) /* once per 1 day */ +#define _06_RTC_INTRTC_CLOCK_1MONTH (0x06U) /* once per 1 month */ + +/* + Real-Time Clock Control Register 1 (RTCC1) +*/ +/* Alarm operation control (WALE) */ +#define _00_RTC_ALARM_DISABLE (0x00U) /* alarm match operation is invalid */ +#define _80_RTC_ALARM_ENABLE (0x80U) /* alarm match operation is valid */ +/* Control of alarm interrupt (INTRTC) function operation (WALIE) */ +#define _00_RTC_ALARM_INT_DISABLE (0x00U) /* does not generate interrupt on + matching of alarm */ +#define _40_RTC_ALARM_INT_ENABLE (0x40U) /* generates interrupt on matching of alarm */ +/* Alarm detection status flag (WAFG) */ +#define _00_RTC_ALARM_MISMATCH (0x00U) /* alarm mismatch */ +#define _10_RTC_ALARM_MATCH (0x10U) /* detection of matching of alarm */ +/* Constant-period interrupt status flag (RIFG) */ +#define _00_RTC_INTC_NOTGENERATE_FLAG (0x00U) /* constant-period interrupt + is not generated */ +#define _08_RTC_INTC_GENERATE_FLAG (0x08U) /* constant-period interrupt is generated */ +/* Wait status flag of real-time clock (RWST) */ +#define _00_RTC_COUNTER_OPERATING (0x00U) /* counter is operating */ +#define _02_RTC_COUNTER_STOP (0x02U) /* mode to read or write counter value */ +/* Wait control of real-time clock (RWAIT) */ +#define _00_RTC_COUNTER_SET (0x00U) /* sets counter operation */ +#define _01_RTC_COUNTER_PAUSE (0x01U) /* stops SEC to YEAR counters. + Mode to read or write counter value */ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/general/r_cg_rtc_common.c b/cores/rl78g22/smc_gen/general/r_cg_rtc_common.c index ac0d78b..a03ee3a 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_rtc_common.c +++ b/cores/rl78g22/smc_gen/general/r_cg_rtc_common.c @@ -1,77 +1,77 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_rtc_common.c -* Version : 1.0.3 -* Device(s) : R7F100GLGxFB -* Description : None -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "r_cg_rtc_common.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ - -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_RTC_Set_PowerOn -* Description : This function starts the clock supply for RTC. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_RTC_Set_PowerOn(void) -{ - RTCWEN = 1U; /* supplies input clock */ -} - -/*********************************************************************************************************************** -* Function Name: R_RTC_Set_PowerOff -* Description : This function stops the clock supply for RTC. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_RTC_Set_PowerOff(void) -{ - RTCWEN = 0U; /* stops supply of input clock */ -} - -/* Start user code for adding. Do not edit comment generated here */ -bool R_RTC_IsPowerOn(void) -{ - return (RTCWEN == 1); -} -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_rtc_common.c +* Version : 1.0.3 +* Device(s) : R7F100GLGxFB +* Description : None +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "r_cg_rtc_common.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ + +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_RTC_Set_PowerOn +* Description : This function starts the clock supply for RTC. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_RTC_Set_PowerOn(void) +{ + RTCWEN = 1U; /* supplies input clock */ +} + +/*********************************************************************************************************************** +* Function Name: R_RTC_Set_PowerOff +* Description : This function stops the clock supply for RTC. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_RTC_Set_PowerOff(void) +{ + RTCWEN = 0U; /* stops supply of input clock */ +} + +/* Start user code for adding. Do not edit comment generated here */ +bool R_RTC_IsPowerOn(void) +{ + return (RTCWEN == 1); +} +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/general/r_cg_rtc_common.h b/cores/rl78g22/smc_gen/general/r_cg_rtc_common.h index b1cb017..6612677 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_rtc_common.h +++ b/cores/rl78g22/smc_gen/general/r_cg_rtc_common.h @@ -1,51 +1,51 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_rtc_common.h -* Version : 1.0.3 -* Device(s) : R7F100GLGxFB -* Description : Common header file for RTC peripheral. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef RTC_COMMON_H -#define RTC_COMMON_H - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_RTC_Set_PowerOn(void); -void R_RTC_Set_PowerOff(void); -/* Start user code for function. Do not edit comment generated here */ -bool R_RTC_IsPowerOn(void); -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_rtc_common.h +* Version : 1.0.3 +* Device(s) : R7F100GLGxFB +* Description : Common header file for RTC peripheral. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef RTC_COMMON_H +#define RTC_COMMON_H + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_RTC_Set_PowerOn(void); +void R_RTC_Set_PowerOff(void); +/* Start user code for function. Do not edit comment generated here */ +bool R_RTC_IsPowerOn(void); +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/general/r_cg_sau.h b/cores/rl78g22/smc_gen/general/r_cg_sau.h index 5a32fd7..a73b519 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_sau.h +++ b/cores/rl78g22/smc_gen/general/r_cg_sau.h @@ -1,357 +1,354 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_sau.h -* Version : 1.0.0 -* Device(s) : R7F102GGExFB -* Description : General header file for SAU peripheral. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef SAU_H -#define SAU_H - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ -/* - Peripheral Enable Register 0 (PER0) -*/ -/* Control of SAU1 input clock (SAU1EN) */ -#define _00_SAU1_CLOCK_STOP (0x00U) /* stops supply of input clock */ -#define _08_SAU1_CLOCK_SUPPLY (0x08U) /* supplies input clock */ -/* Control of SAU0 input clock (SAU0EN) */ -#define _00_SAU0_CLOCK_STOP (0x00U) /* stops supply of input clock */ -#define _04_SAU0_CLOCK_SUPPLY (0x04U) /* supplies input clock */ - -/* - Peripheral Reset Control Register 0 (PPR0) -*/ -/* Peripheral reset control of SAU1 (SAU1RES) */ -#define _00_SAU1_RESET_RELEASE (0x00U) /* released from the reset state */ -#define _08_SAU1_RESET_SET (0x08U) /* reset */ -/* Peripheral reset control of SAU0 (SAU0RES) */ -#define _00_SAU0_RESET_RELEASE (0x00U) /* released from the reset state */ -#define _04_SAU0_RESET_SET (0x04U) /* reset */ - -/* - Serial Clock Select Register m (SPSm) -*/ -/* Section of operation clock (CKm1) (PRSm13 - PRSm10) */ -#define _0000_SAU_CK01_FCLK_0 (0x0000U) /* ck01 - fCLK */ -#define _0010_SAU_CK01_FCLK_1 (0x0010U) /* ck01 - fCLK/2^1 */ -#define _0020_SAU_CK01_FCLK_2 (0x0020U) /* ck01 - fCLK/2^2 */ -#define _0030_SAU_CK01_FCLK_3 (0x0030U) /* ck01 - fCLK/2^3 */ -#define _0040_SAU_CK01_FCLK_4 (0x0040U) /* ck01 - fCLK/2^4 */ -#define _0050_SAU_CK01_FCLK_5 (0x0050U) /* ck01 - fCLK/2^5 */ -#define _0060_SAU_CK01_FCLK_6 (0x0060U) /* ck01 - fCLK/2^6 */ -#define _0070_SAU_CK01_FCLK_7 (0x0070U) /* ck01 - fCLK/2^7 */ -#define _0080_SAU_CK01_FCLK_8 (0x0080U) /* ck01 - fCLK/2^8 */ -#define _0090_SAU_CK01_FCLK_9 (0x0090U) /* ck01 - fCLK/2^9 */ -#define _00A0_SAU_CK01_FCLK_10 (0x00A0U) /* ck01 - fCLK/2^10 */ -#define _00B0_SAU_CK01_FCLK_11 (0x00B0U) /* ck01 - fCLK/2^11 */ -#define _00C0_SAU_CK01_FCLK_12 (0x00C0U) /* ck01 - fCLK/2^12 */ -#define _00D0_SAU_CK01_FCLK_13 (0x00D0U) /* ck01 - fCLK/2^13 */ -#define _00E0_SAU_CK01_FCLK_14 (0x00E0U) /* ck01 - fCLK/2^14 */ -#define _00F0_SAU_CK01_FCLK_15 (0x00F0U) /* ck01 - fCLK/2^15 */ -#define _000F_SAU_CK01_CLEAR (0x000FU) /* clear bit4 - bit7 */ -/* Section of operation clock (CKm0) (PRSm03 - PRSm00) */ -#define _0000_SAU_CK00_FCLK_0 (0x0000U) /* ck00 - fCLK */ -#define _0001_SAU_CK00_FCLK_1 (0x0001U) /* ck00 - fCLK/2^1 */ -#define _0002_SAU_CK00_FCLK_2 (0x0002U) /* ck00 - fCLK/2^2 */ -#define _0003_SAU_CK00_FCLK_3 (0x0003U) /* ck00 - fCLK/2^3 */ -#define _0004_SAU_CK00_FCLK_4 (0x0004U) /* ck00 - fCLK/2^4 */ -#define _0005_SAU_CK00_FCLK_5 (0x0005U) /* ck00 - fCLK/2^5 */ -#define _0006_SAU_CK00_FCLK_6 (0x0006U) /* ck00 - fCLK/2^6 */ -#define _0007_SAU_CK00_FCLK_7 (0x0007U) /* ck00 - fCLK/2^7 */ -#define _0008_SAU_CK00_FCLK_8 (0x0008U) /* ck00 - fCLK/2^8 */ -#define _0009_SAU_CK00_FCLK_9 (0x0009U) /* ck00 - fCLK/2^9 */ -#define _000A_SAU_CK00_FCLK_10 (0x000AU) /* ck00 - fCLK/2^10 */ -#define _000B_SAU_CK00_FCLK_11 (0x000BU) /* ck00 - fCLK/2^11 */ -#define _000C_SAU_CK00_FCLK_12 (0x000CU) /* ck00 - fCLK/2^12 */ -#define _000D_SAU_CK00_FCLK_13 (0x000DU) /* ck00 - fCLK/2^13 */ -#define _000E_SAU_CK00_FCLK_14 (0x000EU) /* ck00 - fCLK/2^14 */ -#define _000F_SAU_CK00_FCLK_15 (0x000FU) /* ck00 - fCLK/2^15 */ -#define _00F0_SAU_CK00_CLEAR (0x00F0U) /* clear bit0 - bit3 */ - -/* - Serial Mode Register mn (SMRmn) -*/ -#define _0020_SAU_SMRMN_INITIALVALUE (0x0020U) -/* Selection of macro clock (MCK) of channel n (CKSmn) */ -#define _0000_SAU_CLOCK_SELECT_CK00 (0x0000U) /* operation clock CK0 set by PRS register */ -#define _8000_SAU_CLOCK_SELECT_CK01 (0x8000U) /* operation clock CK1 set by PRS register */ -/* Selection of transfer clock (TCLK) of channel n (CCSmn) */ -#define _0000_SAU_CLOCK_MODE_CKS (0x0000U) /* divided operation clock MCK specified by CKSmn bit */ -#define _4000_SAU_CLOCK_MODE_TI0N (0x4000U) /* clock input from SCK pin (slave transfer in CSI mode) */ -/* Selection of start trigger source (STSmn) */ -#define _0000_SAU_TRIGGER_SOFTWARE (0x0000U) /* only software trigger is valid */ -#define _0100_SAU_TRIGGER_RXD (0x0100U) /* valid edge of RXD pin */ -/* Controls inversion of level of receive data of channel n in UART mode (SISmn0) */ -#define _0000_SAU_EDGE_FALL (0x0000U) /* falling edge is detected as the start bit */ -#define _0040_SAU_EDGE_RISING (0x0040U) /* rising edge is detected as the start bit */ -/* Setting of operation mode of channel n (MDmn2, MDmn1) */ -#define _0000_SAU_MODE_CSI (0x0000U) /* CSI mode */ -#define _0002_SAU_MODE_UART (0x0002U) /* UART mode */ -#define _0004_SAU_MODE_IIC (0x0004U) /* simplified IIC mode */ -/* Selection of interrupt source of channel n (MDmn0) */ -#define _0000_SAU_TRANSFER_END (0x0000U) /* transfer end interrupt */ -#define _0001_SAU_BUFFER_EMPTY (0x0001U) /* buffer empty interrupt */ - -/* - Serial Communication Operation Setting Register mn (SCRmn) -*/ -#define _0004_SAU_SCRMN_INITIALVALUE (0x0004U) -/* Setting of operation mode of channel n (TXEmn, RXEmn) */ -#define _0000_SAU_NOT_COMMUNICATION (0x0000U) /* does not start communication */ -#define _4000_SAU_RECEPTION (0x4000U) /* reception only */ -#define _8000_SAU_TRANSMISSION (0x8000U) /* transmission only */ -#define _C000_SAU_RECEPTION_TRANSMISSION (0xC000U) /* reception and transmission */ -/* Selection of data and clock phase in CSI mode (DAPmn, CKPmn) */ -#define _0000_SAU_TIMING_1 (0x0000U) /* type 1 */ -#define _1000_SAU_TIMING_2 (0x1000U) /* type 2 */ -#define _2000_SAU_TIMING_3 (0x2000U) /* type 3 */ -#define _3000_SAU_TIMING_4 (0x3000U) /* type 4 */ -/* Selection of masking of error interrupt signal (EOCmn) */ -#define _0000_SAU_INTSRE_MASK (0x0000U) /* masks error interrupt INTSREx */ -#define _0400_SAU_INTSRE_ENABLE (0x0400U) /* enables generation of error interrupt INTSREx */ -/* Setting of parity bit in UART mode (PTCmn1 - PTCmn0) */ -#define _0000_SAU_PARITY_NONE (0x0000U) /* none parity */ -#define _0100_SAU_PARITY_ZERO (0x0100U) /* zero parity */ -#define _0200_SAU_PARITY_EVEN (0x0200U) /* even parity */ -#define _0300_SAU_PARITY_ODD (0x0300U) /* odd parity */ -/* Selection of data transfer sequence in CSI and UART modes (DIRmn) */ -#define _0000_SAU_MSB (0x0000U) /* msb */ -#define _0080_SAU_LSB (0x0080U) /* lsb */ -/* Setting of stop bit in UART mode (SLCmn1, SLCmn0) */ -#define _0000_SAU_STOP_NONE (0x0000U) /* none stop bit */ -#define _0010_SAU_STOP_1 (0x0010U) /* 1 stop bit */ -#define _0020_SAU_STOP_2 (0x0020U) /* 2 stop bits */ -/* Setting of data length in CSI and UART modes (DLSmn1 - DLSmn0) */ -#define _0001_SAU_LENGTH_9 (0x0001U) /* 9-bit data length */ -#define _0002_SAU_LENGTH_7 (0x0002U) /* 7-bit data length */ -#define _0003_SAU_LENGTH_8 (0x0003U) /* 8-bit data length */ - -/* - Format Of Serial Flag Clear Trigger Register mn (SIRmn) -*/ -/* Clear trigger of framing error of channel n (FECTmn) */ -#define _0004_SAU_SIRMN_FECTMN (0x0004U) /* clears the FEFmn bit of the SSRmn register to 0 */ -/* Clear trigger of parity error flag of channel n (PECTmn) */ -#define _0002_SAU_SIRMN_PECTMN (0x0002U) /* clears the PEFmn bit of the SSRmn register to 0 */ -/* Clear trigger of overrun error flag of channel n (OVCTmn) */ -#define _0001_SAU_SIRMN_OVCTMN (0x0001U) /* clears the OVFmn bit of the SSRmn register to 0 */ - -/* - Format Of Serial Status Register mn (SSRmn) -*/ -/* Communication status indication flag of channel n (TSFmn) */ -#define _0040_SAU_UNDER_EXECUTE (0x0040U) /* communication is under execution */ -/* Buffer register status indication flag of channel n (BFFmn) */ -#define _0020_SAU_VALID_STORED (0x0020U) /* valid data is stored in the SDRmn register */ -/* Framing error detection flag of channel n (FEFmn) */ -#define _0004_SAU_FRAM_ERROR (0x0004U) /* a framing error occurs during UART reception */ -/* Parity error detection flag of channel n (PEFmn) */ -#define _0002_SAU_PARITY_ERROR (0x0002U) /* a parity error occurs or ACK is not detected */ -/* Overrun error detection flag of channel n (OVFmn) */ -#define _0001_SAU_OVERRUN_ERROR (0x0001U) /* an overrun error occurs */ - -/* - Serial Channel Start Register m (SSm) -*/ -/* Operation start trigger of channel 3 (SSm3) */ -#define _0000_SAU_CH3_START_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0008_SAU_CH3_START_TRG_ON (0x0008U) /* sets SEm3 to 1 and enters the communication wait status */ -/* Operation start trigger of channel 2 (SSm2) */ -#define _0000_SAU_CH2_START_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0004_SAU_CH2_START_TRG_ON (0x0004U) /* sets SEm2 to 1 and enters the communication wait status */ -/* Operation start trigger of channel 1 (SSm1) */ -#define _0000_SAU_CH1_START_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0002_SAU_CH1_START_TRG_ON (0x0002U) /* sets SEm1 to 1 and enters the communication wait status */ -/* Operation start trigger of channel 0 (SSm0) */ -#define _0000_SAU_CH0_START_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0001_SAU_CH0_START_TRG_ON (0x0001U) /* sets SEm0 to 1 and enters the communication wait status */ - -/* - Serial Channel Stop Register m (STm) -*/ -/* Operation stop trigger of channel 3 (STm3) */ -#define _0000_SAU_CH3_STOP_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0008_SAU_CH3_STOP_TRG_ON (0x0008U) /* operation is stopped (stop trigger is generated) */ -/* Operation stop trigger of channel 2 (STm2) */ -#define _0000_SAU_CH2_STOP_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0004_SAU_CH2_STOP_TRG_ON (0x0004U) /* operation is stopped (stop trigger is generated) */ -/* Operation stop trigger of channel 1 (STm1) */ -#define _0000_SAU_CH1_STOP_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0002_SAU_CH1_STOP_TRG_ON (0x0002U) /* operation is stopped (stop trigger is generated) */ -/* Operation stop trigger of channel 0 (STm0) */ -#define _0000_SAU_CH0_STOP_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0001_SAU_CH0_STOP_TRG_ON (0x0001U) /* operation is stopped (stop trigger is generated) */ - -/* - Serial Output Enable Register m (SOEm) -*/ -/* Serial output enable/disable of channel 3 (SOEm3) */ -#define _0000_SAU_CH3_OUTPUT_DISABLE (0x0000U) /* stops output by serial communication operation */ -#define _0008_SAU_CH3_OUTPUT_ENABLE (0x0008U) /* enables output by serial communication operation */ -/* Serial output enable/disable of channel 2 (SOEm2) */ -#define _0000_SAU_CH2_OUTPUT_DISABLE (0x0000U) /* stops output by serial communication operation */ -#define _0004_SAU_CH2_OUTPUT_ENABLE (0x0004U) /* enables output by serial communication operation */ -/* Serial output enable/disable of channel 1 (SOEm1) */ -#define _0000_SAU_CH1_OUTPUT_DISABLE (0x0000U) /* stops output by serial communication operation */ -#define _0002_SAU_CH1_OUTPUT_ENABLE (0x0002U) /* enables output by serial communication operation */ -/* Serial output enable/disable of channel 0 (SOEm0) */ -#define _0000_SAU_CH0_OUTPUT_DISABLE (0x0000U) /* stops output by serial communication operation */ -#define _0001_SAU_CH0_OUTPUT_ENABLE (0x0001U) /* enables output by serial communication operation */ - -/* - Serial Output Register m (SOm) -*/ -/* Serial clock output of channel 3 (CKOm3) */ -#define _0000_SAU_CH3_CLOCK_OUTPUT_0 (0x0000U) /* serial clock output value is "0" */ -#define _0800_SAU_CH3_CLOCK_OUTPUT_1 (0x0800U) /* serial clock output value is "1" */ -/* Serial clock output of channel 1 (CKOm1) */ -#define _0000_SAU_CH1_CLOCK_OUTPUT_0 (0x0000U) /* serial clock output value is "0" */ -#define _0200_SAU_CH1_CLOCK_OUTPUT_1 (0x0200U) /* serial clock output value is "1" */ -/* Serial clock output of channel 0 (CKOm0) */ -#define _0000_SAU_CH0_CLOCK_OUTPUT_0 (0x0000U) /* serial clock output value is "0" */ -#define _0100_SAU_CH0_CLOCK_OUTPUT_1 (0x0100U) /* serial clock output value is "1" */ -/* Serial data output of channel 3 (SOm3) */ -#define _0000_SAU_CH3_DATA_OUTPUT_0 (0x0000U) /* serial data output value is "0" */ -#define _0008_SAU_CH3_DATA_OUTPUT_1 (0x0008U) /* serial data output value is "1" */ -/* Serial data output of channel 2 (SOm2) */ -#define _0000_SAU_CH2_DATA_OUTPUT_0 (0x0000U) /* serial data output value is "0" */ -#define _0004_SAU_CH2_DATA_OUTPUT_1 (0x0004U) /* serial data output value is "1" */ -/* Serial data output of channel 1 (SOm1) */ -#define _0000_SAU_CH1_DATA_OUTPUT_0 (0x0000U) /* serial data output value is "0" */ -#define _0002_SAU_CH1_DATA_OUTPUT_1 (0x0002U) /* serial data output value is "1" */ -/* Serial data output of channel 0 (SOm0) */ -#define _0000_SAU_CH0_DATA_OUTPUT_0 (0x0000U) /* serial data output value is "0" */ -#define _0001_SAU_CH0_DATA_OUTPUT_1 (0x0001U) /* serial data output value is "1" */ - -/* - Serial Output Level Register m (SOLm) -*/ -/* Selects inversion of the level of the transmit data of channel n in UART mode (SOLm2) */ -#define _0000_SAU_CHANNEL2_NORMAL (0x0000U) /* normal bit level */ -#define _0004_SAU_CHANNEL2_INVERTED (0x0004U) /* inverted bit level */ -/* Selects inversion of the level of the transmit data of channel n in UART mode (SOLm0) */ -#define _0000_SAU_CHANNEL0_NORMAL (0x0000U) /* normal bit level */ -#define _0001_SAU_CHANNEL0_INVERTED (0x0001U) /* inverted bit level */ - -/* - Serial Standby Control Register 0 (SSC0) -*/ -/* Selection of enable or disable the generation of communication error interrupts in the SNOOZE mode (SSEC0) */ -#define _0000_SAU_CH0_SNOOZE_INT_ENABLE (0x0000U) /* enable the generation of error interrupts (INTSRE0) */ -#define _0002_SAU_CH0_SNOOZE_INT_DISABLE (0x0002U) /* disable the generation of error interrupts (INTSRE0) */ -/* Setting of the SNOOZE mode (SWC0) */ -#define _0000_SAU_CH0_SNOOZE_OFF (0x0000U) /* do not use the SNOOZE mode function */ -#define _0001_SAU_CH0_SNOOZE_ON (0x0001U) /* use the SNOOZE mode function */ - -/* - Input Switch Control Register (ISC) -*/ -/* Switch of the serial clock input source of CSI01 (ISC7 - ISC6) */ -#define _00_CSI01_INPUT_SCK01_PIN (0x00U) /* input signal of the SCK01 pin (normal operation) */ -#define _80_CSI01_INPUT_TO01_PIN (0x80U) /* TO01 output signal */ -#define _3F_CSI01_INPUT_CLEAR (0x3FU) /* clear ISC7-ISC6 bit */ -/* Switch of the serial clock input source of CSI00 (ISC4 - ISC3) */ -#define _00_CSI00_INPUT_SCK00_PIN (0x00U) /* input signal of the SCK00 pin (normal operation) */ -#define _10_CSI00_INPUT_TO01_PIN (0x10U) /* TO01 output signal */ -#define _E7_CSI00_INPUT_CLEAR (0xE7U) /* clear ISC4-ISC3 bit */ -/* Switching channel 7 input of timer array unit (ISC1) */ -#define _00_TAU07_INPUT_TI07_PIN (0x00U) /* uses the input signal of the TI07 pin as a timer input - (normal operation) */ -#define _02_TAU07_INPUT_RXD2_PIN (0x02U) /* input signal of the RxD2 pin is used as timer input */ -/* Switching external interrupt (INTP0) input (ISC0) */ -#define _00_INTP0_INPUT_INTP0_PIN (0x00U) /* uses the input signal of the INTP0 pin as an external interrupt - (normal operation) */ -#define _01_INTP0_INPUT_RXD2_PIN (0x01U) /* uses the input signal of the RxD2 pin as an external interrupt - (wake-up signal detection) */ - -/* - Noise Filter Enable Register 0 (NFEN0) -*/ -/* Use of noise filter */ -#define _00_SAU_RXD2_FILTER_OFF (0x00U) /* noise filter off */ -#define _10_SAU_RXD2_FILTER_ON (0x10U) /* noise filter on */ -#define _00_SAU_RXD1_FILTER_OFF (0x00U) /* noise filter off */ -#define _04_SAU_RXD1_FILTER_ON (0x04U) /* noise filter on */ -#define _00_SAU_RXD0_FILTER_OFF (0x00U) /* noise filter off */ -#define _01_SAU_RXD0_FILTER_ON (0x01U) /* noise filter on */ - -/* - UART Loopback Function Selection Register (ULBS) -*/ -/* UART2 loopback function setting (ULBS2) */ -#define _00_UART2_LOOPBACK_DISABLE (0x00U) /* disable Uart2 loopback function */ -#define _04_UART2_LOOPBACK_ENABLE (0x04U) /* enable Uart2 loopback function */ -/* UART1 loopback function setting (ULBS1) */ -#define _00_UART1_LOOPBACK_DISABLE (0x00U) /* disable Uart1 loopback function */ -#define _02_UART1_LOOPBACK_ENABLE (0x02U) /* enable Uart1 loopback function */ -/* UART0 loopback function setting (ULBS0) */ -#define _00_UART0_LOOPBACK_DISABLE (0x00U) /* disable Uart0 loopback function */ -#define _01_UART0_LOOPBACK_ENABLE (0x01U) /* enable Uart0 loopback function */ - -/* SAU Used Flag */ -#define _00_SAU_IIC_MASTER_FLAG_CLEAR (0x00U) -#define _01_SAU_IIC_SEND_FLAG (0x01U) -#define _02_SAU_IIC_RECEIVE_FLAG (0x02U) -#define _04_SAU_IIC_SENDED_ADDRESS_FLAG (0x04U) - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -/* Start user code for function. Do not edit comment generated here */ -// 20220928 temporary removal -// #warning FIXME: Instead of missing `r_cg_serial_csi.h`, define macros for `SPI` here. - -#define _0000_SPI_STATUS_CLEAR (0x0000U) -#define _8000_SPI_STATUS_SENDEND (0x8000U) -#define _4000_SPI_STATUS_RECEIVEEND (0x4000U) -#define _00FF_SPI_STATUS_ERROR_MASK (0x00FFU) -#define _0080_SPI_STATUS_ERROR_TIMEOUT (0x0080U) -#define _0001_SPI_STATUS_ERROR_OVERRUN (_0001_SAU_OVERRUN_ERROR) - -#define SPI_CLOCK_DIV2 ( 2U) -#define SPI_CLOCK_DIV4 ( 4U) -#define SPI_CLOCK_DIV8 ( 8U) -#define SPI_CLOCK_DIV16 ( 16U) -#define SPI_CLOCK_DIV32 ( 32U) -#define SPI_CLOCK_DIV64 ( 64U) -#define SPI_CLOCK_DIV128 (128U) - -#define SPI_MODE0 ((uint8_t)(_3000_SAU_TIMING_4 >> 8)) -#define SPI_MODE1 ((uint8_t)(_1000_SAU_TIMING_2 >> 8)) -#define SPI_MODE2 ((uint8_t)(_2000_SAU_TIMING_3 >> 8)) -#define SPI_MODE3 ((uint8_t)(_0000_SAU_TIMING_1 >> 8)) - -#define SPI_MODE_MASK ((uint16_t)_3000_SAU_TIMING_4) -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021, 2023 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_sau.h +* Version : 1.0.3 +* Device(s) : R7F102GGExFB +* Description : General header file for SAU peripheral. +* Creation Date : +***********************************************************************************************************************/ + +#ifndef SAU_H +#define SAU_H + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ +/* + Peripheral Enable Register 0 (PER0) +*/ +/* Control of SAU1 input clock (SAU1EN) */ +#define _00_SAU1_CLOCK_STOP (0x00U) /* stops supply of input clock */ +#define _08_SAU1_CLOCK_SUPPLY (0x08U) /* supplies input clock */ +/* Control of SAU0 input clock (SAU0EN) */ +#define _00_SAU0_CLOCK_STOP (0x00U) /* stops supply of input clock */ +#define _04_SAU0_CLOCK_SUPPLY (0x04U) /* supplies input clock */ + +/* + Peripheral Reset Control Register 0 (PPR0) +*/ +/* Peripheral reset control of SAU1 (SAU1RES) */ +#define _00_SAU1_RESET_RELEASE (0x00U) /* released from the reset state */ +#define _08_SAU1_RESET_SET (0x08U) /* reset */ +/* Peripheral reset control of SAU0 (SAU0RES) */ +#define _00_SAU0_RESET_RELEASE (0x00U) /* released from the reset state */ +#define _04_SAU0_RESET_SET (0x04U) /* reset */ + +/* + Serial Clock Select Register m (SPSm) +*/ +/* Section of operation clock (CKm1) (PRSm13 - PRSm10) */ +#define _0000_SAU_CK01_FCLK_0 (0x0000U) /* ck01 - fCLK */ +#define _0010_SAU_CK01_FCLK_1 (0x0010U) /* ck01 - fCLK/2^1 */ +#define _0020_SAU_CK01_FCLK_2 (0x0020U) /* ck01 - fCLK/2^2 */ +#define _0030_SAU_CK01_FCLK_3 (0x0030U) /* ck01 - fCLK/2^3 */ +#define _0040_SAU_CK01_FCLK_4 (0x0040U) /* ck01 - fCLK/2^4 */ +#define _0050_SAU_CK01_FCLK_5 (0x0050U) /* ck01 - fCLK/2^5 */ +#define _0060_SAU_CK01_FCLK_6 (0x0060U) /* ck01 - fCLK/2^6 */ +#define _0070_SAU_CK01_FCLK_7 (0x0070U) /* ck01 - fCLK/2^7 */ +#define _0080_SAU_CK01_FCLK_8 (0x0080U) /* ck01 - fCLK/2^8 */ +#define _0090_SAU_CK01_FCLK_9 (0x0090U) /* ck01 - fCLK/2^9 */ +#define _00A0_SAU_CK01_FCLK_10 (0x00A0U) /* ck01 - fCLK/2^10 */ +#define _00B0_SAU_CK01_FCLK_11 (0x00B0U) /* ck01 - fCLK/2^11 */ +#define _00C0_SAU_CK01_FCLK_12 (0x00C0U) /* ck01 - fCLK/2^12 */ +#define _00D0_SAU_CK01_FCLK_13 (0x00D0U) /* ck01 - fCLK/2^13 */ +#define _00E0_SAU_CK01_FCLK_14 (0x00E0U) /* ck01 - fCLK/2^14 */ +#define _00F0_SAU_CK01_FCLK_15 (0x00F0U) /* ck01 - fCLK/2^15 */ +#define _000F_SAU_CK01_CLEAR (0x000FU) /* clear bit4 - bit7 */ +/* Section of operation clock (CKm0) (PRSm03 - PRSm00) */ +#define _0000_SAU_CK00_FCLK_0 (0x0000U) /* ck00 - fCLK */ +#define _0001_SAU_CK00_FCLK_1 (0x0001U) /* ck00 - fCLK/2^1 */ +#define _0002_SAU_CK00_FCLK_2 (0x0002U) /* ck00 - fCLK/2^2 */ +#define _0003_SAU_CK00_FCLK_3 (0x0003U) /* ck00 - fCLK/2^3 */ +#define _0004_SAU_CK00_FCLK_4 (0x0004U) /* ck00 - fCLK/2^4 */ +#define _0005_SAU_CK00_FCLK_5 (0x0005U) /* ck00 - fCLK/2^5 */ +#define _0006_SAU_CK00_FCLK_6 (0x0006U) /* ck00 - fCLK/2^6 */ +#define _0007_SAU_CK00_FCLK_7 (0x0007U) /* ck00 - fCLK/2^7 */ +#define _0008_SAU_CK00_FCLK_8 (0x0008U) /* ck00 - fCLK/2^8 */ +#define _0009_SAU_CK00_FCLK_9 (0x0009U) /* ck00 - fCLK/2^9 */ +#define _000A_SAU_CK00_FCLK_10 (0x000AU) /* ck00 - fCLK/2^10 */ +#define _000B_SAU_CK00_FCLK_11 (0x000BU) /* ck00 - fCLK/2^11 */ +#define _000C_SAU_CK00_FCLK_12 (0x000CU) /* ck00 - fCLK/2^12 */ +#define _000D_SAU_CK00_FCLK_13 (0x000DU) /* ck00 - fCLK/2^13 */ +#define _000E_SAU_CK00_FCLK_14 (0x000EU) /* ck00 - fCLK/2^14 */ +#define _000F_SAU_CK00_FCLK_15 (0x000FU) /* ck00 - fCLK/2^15 */ +#define _00F0_SAU_CK00_CLEAR (0x00F0U) /* clear bit0 - bit3 */ + +/* + Serial Mode Register mn (SMRmn) +*/ +#define _0020_SAU_SMRMN_INITIALVALUE (0x0020U) +/* Selection of macro clock (MCK) of channel n (CKSmn) */ +#define _0000_SAU_CLOCK_SELECT_CK00 (0x0000U) /* operation clock CK0 set by PRS register */ +#define _8000_SAU_CLOCK_SELECT_CK01 (0x8000U) /* operation clock CK1 set by PRS register */ +/* Selection of transfer clock (TCLK) of channel n (CCSmn) */ +#define _0000_SAU_CLOCK_MODE_CKS (0x0000U) /* divided operation clock MCK specified by CKSmn bit */ +#define _4000_SAU_CLOCK_MODE_TI0N (0x4000U) /* clock input from SCK pin (slave transfer in CSI mode) */ +/* Selection of start trigger source (STSmn) */ +#define _0000_SAU_TRIGGER_SOFTWARE (0x0000U) /* only software trigger is valid */ +#define _0100_SAU_TRIGGER_RXD (0x0100U) /* valid edge of RXD pin */ +/* Controls inversion of level of receive data of channel n in UART mode (SISmn0) */ +#define _0000_SAU_EDGE_FALL (0x0000U) /* falling edge is detected as the start bit */ +#define _0040_SAU_EDGE_RISING (0x0040U) /* rising edge is detected as the start bit */ +/* Setting of operation mode of channel n (MDmn2, MDmn1) */ +#define _0000_SAU_MODE_CSI (0x0000U) /* CSI mode */ +#define _0002_SAU_MODE_UART (0x0002U) /* UART mode */ +#define _0004_SAU_MODE_IIC (0x0004U) /* simplified IIC mode */ +/* Selection of interrupt source of channel n (MDmn0) */ +#define _0000_SAU_TRANSFER_END (0x0000U) /* transfer end interrupt */ +#define _0001_SAU_BUFFER_EMPTY (0x0001U) /* buffer empty interrupt */ + +/* + Serial Communication Operation Setting Register mn (SCRmn) +*/ +#define _0004_SAU_SCRMN_INITIALVALUE (0x0004U) +/* Setting of operation mode of channel n (TXEmn, RXEmn) */ +#define _0000_SAU_NOT_COMMUNICATION (0x0000U) /* does not start communication */ +#define _4000_SAU_RECEPTION (0x4000U) /* reception only */ +#define _8000_SAU_TRANSMISSION (0x8000U) /* transmission only */ +#define _C000_SAU_RECEPTION_TRANSMISSION (0xC000U) /* reception and transmission */ +/* Selection of data and clock phase in CSI mode (DAPmn, CKPmn) */ +#define _0000_SAU_TIMING_1 (0x0000U) /* type 1 */ +#define _1000_SAU_TIMING_2 (0x1000U) /* type 2 */ +#define _2000_SAU_TIMING_3 (0x2000U) /* type 3 */ +#define _3000_SAU_TIMING_4 (0x3000U) /* type 4 */ +/* Selection of masking of error interrupt signal (EOCmn) */ +#define _0000_SAU_INTSRE_MASK (0x0000U) /* masks error interrupt INTSREx */ +#define _0400_SAU_INTSRE_ENABLE (0x0400U) /* enables generation of error interrupt INTSREx */ +/* Setting of parity bit in UART mode (PTCmn1 - PTCmn0) */ +#define _0000_SAU_PARITY_NONE (0x0000U) /* none parity */ +#define _0100_SAU_PARITY_ZERO (0x0100U) /* zero parity */ +#define _0200_SAU_PARITY_EVEN (0x0200U) /* even parity */ +#define _0300_SAU_PARITY_ODD (0x0300U) /* odd parity */ +/* Selection of data transfer sequence in CSI and UART modes (DIRmn) */ +#define _0000_SAU_MSB (0x0000U) /* msb */ +#define _0080_SAU_LSB (0x0080U) /* lsb */ +/* Setting of stop bit in UART mode (SLCmn1, SLCmn0) */ +#define _0000_SAU_STOP_NONE (0x0000U) /* none stop bit */ +#define _0010_SAU_STOP_1 (0x0010U) /* 1 stop bit */ +#define _0020_SAU_STOP_2 (0x0020U) /* 2 stop bits */ +/* Setting of data length in CSI and UART modes (DLSmn1 - DLSmn0) */ +#define _0001_SAU_LENGTH_9 (0x0001U) /* 9-bit data length */ +#define _0002_SAU_LENGTH_7 (0x0002U) /* 7-bit data length */ +#define _0003_SAU_LENGTH_8 (0x0003U) /* 8-bit data length */ + +/* + Format Of Serial Flag Clear Trigger Register mn (SIRmn) +*/ +/* Clear trigger of framing error of channel n (FECTmn) */ +#define _0004_SAU_SIRMN_FECTMN (0x0004U) /* clears the FEFmn bit of the SSRmn register to 0 */ +/* Clear trigger of parity error flag of channel n (PECTmn) */ +#define _0002_SAU_SIRMN_PECTMN (0x0002U) /* clears the PEFmn bit of the SSRmn register to 0 */ +/* Clear trigger of overrun error flag of channel n (OVCTmn) */ +#define _0001_SAU_SIRMN_OVCTMN (0x0001U) /* clears the OVFmn bit of the SSRmn register to 0 */ + +/* + Format Of Serial Status Register mn (SSRmn) +*/ +/* Communication status indication flag of channel n (TSFmn) */ +#define _0040_SAU_UNDER_EXECUTE (0x0040U) /* communication is under execution */ +/* Buffer register status indication flag of channel n (BFFmn) */ +#define _0020_SAU_VALID_STORED (0x0020U) /* valid data is stored in the SDRmn register */ +/* Framing error detection flag of channel n (FEFmn) */ +#define _0004_SAU_FRAM_ERROR (0x0004U) /* a framing error occurs during UART reception */ +/* Parity error detection flag of channel n (PEFmn) */ +#define _0002_SAU_PARITY_ERROR (0x0002U) /* a parity error occurs or ACK is not detected */ +/* Overrun error detection flag of channel n (OVFmn) */ +#define _0001_SAU_OVERRUN_ERROR (0x0001U) /* an overrun error occurs */ + +/* + Serial Channel Start Register m (SSm) +*/ +/* Operation start trigger of channel 3 (SSm3) */ +#define _0000_SAU_CH3_START_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0008_SAU_CH3_START_TRG_ON (0x0008U) /* sets SEm3 to 1 and enters the communication wait status */ +/* Operation start trigger of channel 2 (SSm2) */ +#define _0000_SAU_CH2_START_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0004_SAU_CH2_START_TRG_ON (0x0004U) /* sets SEm2 to 1 and enters the communication wait status */ +/* Operation start trigger of channel 1 (SSm1) */ +#define _0000_SAU_CH1_START_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0002_SAU_CH1_START_TRG_ON (0x0002U) /* sets SEm1 to 1 and enters the communication wait status */ +/* Operation start trigger of channel 0 (SSm0) */ +#define _0000_SAU_CH0_START_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0001_SAU_CH0_START_TRG_ON (0x0001U) /* sets SEm0 to 1 and enters the communication wait status */ + +/* + Serial Channel Stop Register m (STm) +*/ +/* Operation stop trigger of channel 3 (STm3) */ +#define _0000_SAU_CH3_STOP_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0008_SAU_CH3_STOP_TRG_ON (0x0008U) /* operation is stopped (stop trigger is generated) */ +/* Operation stop trigger of channel 2 (STm2) */ +#define _0000_SAU_CH2_STOP_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0004_SAU_CH2_STOP_TRG_ON (0x0004U) /* operation is stopped (stop trigger is generated) */ +/* Operation stop trigger of channel 1 (STm1) */ +#define _0000_SAU_CH1_STOP_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0002_SAU_CH1_STOP_TRG_ON (0x0002U) /* operation is stopped (stop trigger is generated) */ +/* Operation stop trigger of channel 0 (STm0) */ +#define _0000_SAU_CH0_STOP_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0001_SAU_CH0_STOP_TRG_ON (0x0001U) /* operation is stopped (stop trigger is generated) */ + +/* + Serial Output Enable Register m (SOEm) +*/ +/* Serial output enable/disable of channel 3 (SOEm3) */ +#define _0000_SAU_CH3_OUTPUT_DISABLE (0x0000U) /* stops output by serial communication operation */ +#define _0008_SAU_CH3_OUTPUT_ENABLE (0x0008U) /* enables output by serial communication operation */ +/* Serial output enable/disable of channel 2 (SOEm2) */ +#define _0000_SAU_CH2_OUTPUT_DISABLE (0x0000U) /* stops output by serial communication operation */ +#define _0004_SAU_CH2_OUTPUT_ENABLE (0x0004U) /* enables output by serial communication operation */ +/* Serial output enable/disable of channel 1 (SOEm1) */ +#define _0000_SAU_CH1_OUTPUT_DISABLE (0x0000U) /* stops output by serial communication operation */ +#define _0002_SAU_CH1_OUTPUT_ENABLE (0x0002U) /* enables output by serial communication operation */ +/* Serial output enable/disable of channel 0 (SOEm0) */ +#define _0000_SAU_CH0_OUTPUT_DISABLE (0x0000U) /* stops output by serial communication operation */ +#define _0001_SAU_CH0_OUTPUT_ENABLE (0x0001U) /* enables output by serial communication operation */ + +/* + Serial Output Register m (SOm) +*/ +/* Serial clock output of channel 3 (CKOm3) */ +#define _0000_SAU_CH3_CLOCK_OUTPUT_0 (0x0000U) /* serial clock output value is "0" */ +#define _0800_SAU_CH3_CLOCK_OUTPUT_1 (0x0800U) /* serial clock output value is "1" */ +/* Serial clock output of channel 1 (CKOm1) */ +#define _0000_SAU_CH1_CLOCK_OUTPUT_0 (0x0000U) /* serial clock output value is "0" */ +#define _0200_SAU_CH1_CLOCK_OUTPUT_1 (0x0200U) /* serial clock output value is "1" */ +/* Serial clock output of channel 0 (CKOm0) */ +#define _0000_SAU_CH0_CLOCK_OUTPUT_0 (0x0000U) /* serial clock output value is "0" */ +#define _0100_SAU_CH0_CLOCK_OUTPUT_1 (0x0100U) /* serial clock output value is "1" */ +/* Serial data output of channel 3 (SOm3) */ +#define _0000_SAU_CH3_DATA_OUTPUT_0 (0x0000U) /* serial data output value is "0" */ +#define _0008_SAU_CH3_DATA_OUTPUT_1 (0x0008U) /* serial data output value is "1" */ +/* Serial data output of channel 2 (SOm2) */ +#define _0000_SAU_CH2_DATA_OUTPUT_0 (0x0000U) /* serial data output value is "0" */ +#define _0004_SAU_CH2_DATA_OUTPUT_1 (0x0004U) /* serial data output value is "1" */ +/* Serial data output of channel 1 (SOm1) */ +#define _0000_SAU_CH1_DATA_OUTPUT_0 (0x0000U) /* serial data output value is "0" */ +#define _0002_SAU_CH1_DATA_OUTPUT_1 (0x0002U) /* serial data output value is "1" */ +/* Serial data output of channel 0 (SOm0) */ +#define _0000_SAU_CH0_DATA_OUTPUT_0 (0x0000U) /* serial data output value is "0" */ +#define _0001_SAU_CH0_DATA_OUTPUT_1 (0x0001U) /* serial data output value is "1" */ + +/* + Serial Output Level Register m (SOLm) +*/ +/* Selects inversion of the level of the transmit data of channel n in UART mode (SOLm2) */ +#define _0000_SAU_CHANNEL2_NORMAL (0x0000U) /* normal bit level */ +#define _0004_SAU_CHANNEL2_INVERTED (0x0004U) /* inverted bit level */ +/* Selects inversion of the level of the transmit data of channel n in UART mode (SOLm0) */ +#define _0000_SAU_CHANNEL0_NORMAL (0x0000U) /* normal bit level */ +#define _0001_SAU_CHANNEL0_INVERTED (0x0001U) /* inverted bit level */ + +/* + Serial Standby Control Register 0 (SSC0) +*/ +/* Selection of enable or disable the generation of communication error interrupts in the SNOOZE mode (SSEC0) */ +#define _0000_SAU_CH0_SNOOZE_INT_ENABLE (0x0000U) /* enable the generation of error interrupts (INTSRE0) */ +#define _0002_SAU_CH0_SNOOZE_INT_DISABLE (0x0002U) /* disable the generation of error interrupts (INTSRE0) */ +/* Setting of the SNOOZE mode (SWC0) */ +#define _0000_SAU_CH0_SNOOZE_OFF (0x0000U) /* do not use the SNOOZE mode function */ +#define _0001_SAU_CH0_SNOOZE_ON (0x0001U) /* use the SNOOZE mode function */ + +/* + Input Switch Control Register (ISC) +*/ +/* Switch of the serial clock input source of CSI01 (ISC7 - ISC6) */ +#define _00_CSI01_INPUT_SCK01_PIN (0x00U) /* input signal of the SCK01 pin (normal operation) */ +#define _80_CSI01_INPUT_TO01_PIN (0x80U) /* TO01 output signal */ +#define _3F_CSI01_INPUT_CLEAR (0x3FU) /* clear ISC7-ISC6 bit */ +/* Switch of the serial clock input source of CSI00 (ISC4 - ISC3) */ +#define _00_CSI00_INPUT_SCK00_PIN (0x00U) /* input signal of the SCK00 pin (normal operation) */ +#define _10_CSI00_INPUT_TO01_PIN (0x10U) /* TO01 output signal */ +#define _E7_CSI00_INPUT_CLEAR (0xE7U) /* clear ISC4-ISC3 bit */ +/* Switching channel 7 input of timer array unit (ISC1) */ +#define _00_TAU07_INPUT_TI07_PIN (0x00U) /* uses the input signal of the TI07 pin as a timer input + (normal operation) */ +#define _02_TAU07_INPUT_RXD2_PIN (0x02U) /* input signal of the RxD2 pin is used as timer input */ +/* Switching external interrupt (INTP0) input (ISC0) */ +#define _00_INTP0_INPUT_INTP0_PIN (0x00U) /* uses the input signal of the INTP0 pin as an external interrupt + (normal operation) */ +#define _01_INTP0_INPUT_RXD2_PIN (0x01U) /* uses the input signal of the RxD2 pin as an external interrupt + (wake-up signal detection) */ + +/* + Noise Filter Enable Register 0 (NFEN0) +*/ +/* Use of noise filter */ +#define _00_SAU_RXD2_FILTER_OFF (0x00U) /* noise filter off */ +#define _10_SAU_RXD2_FILTER_ON (0x10U) /* noise filter on */ +#define _00_SAU_RXD1_FILTER_OFF (0x00U) /* noise filter off */ +#define _04_SAU_RXD1_FILTER_ON (0x04U) /* noise filter on */ +#define _00_SAU_RXD0_FILTER_OFF (0x00U) /* noise filter off */ +#define _01_SAU_RXD0_FILTER_ON (0x01U) /* noise filter on */ + +/* + UART Loopback Function Selection Register (ULBS) +*/ +/* UART2 loopback function setting (ULBS2) */ +#define _00_UART2_LOOPBACK_DISABLE (0x00U) /* disable Uart2 loopback function */ +#define _04_UART2_LOOPBACK_ENABLE (0x04U) /* enable Uart2 loopback function */ +/* UART1 loopback function setting (ULBS1) */ +#define _00_UART1_LOOPBACK_DISABLE (0x00U) /* disable Uart1 loopback function */ +#define _02_UART1_LOOPBACK_ENABLE (0x02U) /* enable Uart1 loopback function */ +/* UART0 loopback function setting (ULBS0) */ +#define _00_UART0_LOOPBACK_DISABLE (0x00U) /* disable Uart0 loopback function */ +#define _01_UART0_LOOPBACK_ENABLE (0x01U) /* enable Uart0 loopback function */ + +/* SAU Used Flag */ +#define _00_SAU_IIC_MASTER_FLAG_CLEAR (0x00U) +#define _01_SAU_IIC_SEND_FLAG (0x01U) +#define _02_SAU_IIC_RECEIVE_FLAG (0x02U) +#define _04_SAU_IIC_SENDED_ADDRESS_FLAG (0x04U) + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +/* Start user code for function. Do not edit comment generated here */ +#define _0000_SPI_STATUS_CLEAR (0x0000U) +#define _8000_SPI_STATUS_SENDEND (0x8000U) +#define _4000_SPI_STATUS_RECEIVEEND (0x4000U) +#define _00FF_SPI_STATUS_ERROR_MASK (0x00FFU) +#define _0080_SPI_STATUS_ERROR_TIMEOUT (0x0080U) +#define _0001_SPI_STATUS_ERROR_OVERRUN (_0001_SAU_OVERRUN_ERROR) + +#define SPI_CLOCK_DIV2 ( 2U) +#define SPI_CLOCK_DIV4 ( 4U) +#define SPI_CLOCK_DIV8 ( 8U) +#define SPI_CLOCK_DIV16 ( 16U) +#define SPI_CLOCK_DIV32 ( 32U) +#define SPI_CLOCK_DIV64 ( 64U) +#define SPI_CLOCK_DIV128 (128U) + +#define SPI_MODE0 ((uint8_t)(_3000_SAU_TIMING_4 >> 8)) +#define SPI_MODE1 ((uint8_t)(_1000_SAU_TIMING_2 >> 8)) +#define SPI_MODE2 ((uint8_t)(_2000_SAU_TIMING_3 >> 8)) +#define SPI_MODE3 ((uint8_t)(_0000_SAU_TIMING_1 >> 8)) + +#define SPI_MODE_MASK ((uint16_t)_3000_SAU_TIMING_4) +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/general/r_cg_sau_common.c b/cores/rl78g22/smc_gen/general/r_cg_sau_common.c index 95b6f4f..f7d69bf 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_sau_common.c +++ b/cores/rl78g22/smc_gen/general/r_cg_sau_common.c @@ -1,212 +1,236 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_sau_common.c -* Version : 1.0.0 -* Device(s) : R7F102GGExFB -* Description : None -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_UART0.h" -#include "Config_UART1.h" -#include "Config_UART2.h" -// #include "Config_CSI11.h" -// #include "Config_CSI20.h" -#include "r_cg_sau_common.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_SAU0_Create -* Description : This function enables SAU0 input clock supply and initializes SAU0 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_SAU0_Create(void) -{ - SAU0EN = 1U; /* supplies input clock */ - R_Config_UART0_Create(); - R_Config_UART1_Create(); -// R_Config_CSI20_Create(); -} - -/*********************************************************************************************************************** -* Function Name: R_SAU1_Create -* Description : This function enables SAU1 input clock supply and initializes SAU1 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_SAU1_Create(void) -{ - SAU1EN = 1U; /* supplies input clock */ - R_Config_UART2_Create(); -} - -/*********************************************************************************************************************** -* Function Name: R_SAU0_Set_PowerOn -* Description : This function starts the clock supply for SAU0. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_SAU0_Set_PowerOn(void) -{ - SAU0EN = 1U; /* supplies input clock */ -} - -/*********************************************************************************************************************** -* Function Name: R_SAU0_Set_PowerOff -* Description : This function stops the clock supply for SAU0. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_SAU0_Set_PowerOff(void) -{ - SAU0EN = 0U; /* stops input clock supply */ -} - -/*********************************************************************************************************************** -* Function Name: R_SAU1_Set_PowerOn -* Description : This function starts the clock supply for SAU1. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_SAU1_Set_PowerOn(void) -{ - SAU1EN = 1U; /* supplies input clock */ -} - -/*********************************************************************************************************************** -* Function Name: R_SAU1_Set_PowerOff -* Description : This function stops the clock supply for SAU1. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_SAU1_Set_PowerOff(void) -{ - SAU1EN = 0U; /* stops input clock supply */ -} - -/*********************************************************************************************************************** -* Function Name: R_SAU0_Set_Reset -* Description : This function sets SAU0 module in reset state. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_SAU0_Set_Reset(void) -{ - SAU0RES = 1U; /* reset serial array unit */ -} - -/*********************************************************************************************************************** -* Function Name: R_SAU0_Release_Reset -* Description : This function releases SAU0 module from reset state. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_SAU0_Release_Reset(void) -{ - SAU0RES = 0U; /* reset release of serial array unit */ -} - -/*********************************************************************************************************************** -* Function Name: R_SAU1_Set_Reset -* Description : This function sets SAU1 module in reset state. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_SAU1_Set_Reset(void) -{ - SAU1RES = 1U; /* reset serial array unit */ -} - -/*********************************************************************************************************************** -* Function Name: R_SAU1_Release_Reset -* Description : This function releases SAU1 module from reset state. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_SAU1_Release_Reset(void) -{ - SAU1RES = 0U; /* reset release of serial array unit */ -} - -/*********************************************************************************************************************** -* Function Name: R_SAU0_Set_SnoozeOn -* Description : This function enables SAU0 wakeup function. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_SAU0_Set_SnoozeOn(void) -{ - SSC0 |= _0001_SAU_CH0_SNOOZE_ON; -} - -/*********************************************************************************************************************** -* Function Name: R_SAU0_Set_SnoozeOff -* Description : This function disables SAU0 wakeup function. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_SAU0_Set_SnoozeOff(void) -{ - SSC0 &= (uint16_t)~_0001_SAU_CH0_SNOOZE_ON; -} - -/* Start user code for adding. Do not edit comment generated here */ - -void r_Config_CSI11_UART1_interrupt_switching(void) { -#if defined(UART1_CHANNEL) && ( UART1_CHANNEL == 1 ) - // Check bit [2:1] of register SMR03 == 01 , which is set in R_Config_UART1_Create(). - if ( (SMR03 & _0002_SAU_MODE_UART) == _0002_SAU_MODE_UART) { - r_Config_UART1_interrupt_receive(); - return; - } -#endif - -#if defined(CSI_CHANNEL3) - // Check bit [2:1] of register SMR03 == 00 , which is set in R_Config_CSI11_Create(). - if ( (SMR03 & _0000_SAU_MODE_CSI) == _0000_SAU_MODE_CSI) { - // Call the interrupt handler for CSI11 (Master) - // If it is possible to distinguish between CSI11 (master) and CSI111 (slave), do so here. - r_Config_CSI20_interrupt(); - return; - } -#endif - -} -/* End user code. Do not edit comment generated here */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_sau_common.c +* Version : 1.0.0 +* Device(s) : R7F102GGExFB +* Description : None +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_UART0.h" +#include "Config_UART1.h" +#include "Config_UART2.h" +// #include "Config_CSI11.h" +#include "Config_CSI20.h" +#include "r_cg_sau_common.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +extern void r_Config_CSI20_interrupt(); +extern void r_Config_UART2_interrupt_send(); +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_SAU0_Create +* Description : This function enables SAU0 input clock supply and initializes SAU0 module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_SAU0_Create(void) +{ + SAU0EN = 1U; /* supplies input clock */ + R_Config_UART0_Create(); + R_Config_UART1_Create(); + R_Config_CSI20_Create(); +} + +/*********************************************************************************************************************** +* Function Name: R_SAU1_Create +* Description : This function enables SAU1 input clock supply and initializes SAU1 module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_SAU1_Create(void) +{ + SAU1EN = 1U; /* supplies input clock */ + R_Config_UART2_Create(); +} + +/*********************************************************************************************************************** +* Function Name: R_SAU0_Set_PowerOn +* Description : This function starts the clock supply for SAU0. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_SAU0_Set_PowerOn(void) +{ + SAU0EN = 1U; /* supplies input clock */ +} + +/*********************************************************************************************************************** +* Function Name: R_SAU0_Set_PowerOff +* Description : This function stops the clock supply for SAU0. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_SAU0_Set_PowerOff(void) +{ + SAU0EN = 0U; /* stops input clock supply */ +} + +/*********************************************************************************************************************** +* Function Name: R_SAU1_Set_PowerOn +* Description : This function starts the clock supply for SAU1. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_SAU1_Set_PowerOn(void) +{ + SAU1EN = 1U; /* supplies input clock */ +} + +/*********************************************************************************************************************** +* Function Name: R_SAU1_Set_PowerOff +* Description : This function stops the clock supply for SAU1. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_SAU1_Set_PowerOff(void) +{ + SAU1EN = 0U; /* stops input clock supply */ +} + +/*********************************************************************************************************************** +* Function Name: R_SAU0_Set_Reset +* Description : This function sets SAU0 module in reset state. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_SAU0_Set_Reset(void) +{ + SAU0RES = 1U; /* reset serial array unit */ +} + +/*********************************************************************************************************************** +* Function Name: R_SAU0_Release_Reset +* Description : This function releases SAU0 module from reset state. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_SAU0_Release_Reset(void) +{ + SAU0RES = 0U; /* reset release of serial array unit */ +} + +/*********************************************************************************************************************** +* Function Name: R_SAU1_Set_Reset +* Description : This function sets SAU1 module in reset state. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_SAU1_Set_Reset(void) +{ + SAU1RES = 1U; /* reset serial array unit */ +} + +/*********************************************************************************************************************** +* Function Name: R_SAU1_Release_Reset +* Description : This function releases SAU1 module from reset state. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_SAU1_Release_Reset(void) +{ + SAU1RES = 0U; /* reset release of serial array unit */ +} + +/*********************************************************************************************************************** +* Function Name: R_SAU0_Set_SnoozeOn +* Description : This function enables SAU0 wakeup function. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_SAU0_Set_SnoozeOn(void) +{ + SSC0 |= _0001_SAU_CH0_SNOOZE_ON; +} + +/*********************************************************************************************************************** +* Function Name: R_SAU0_Set_SnoozeOff +* Description : This function disables SAU0 wakeup function. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_SAU0_Set_SnoozeOff(void) +{ + SSC0 &= (uint16_t)~_0001_SAU_CH0_SNOOZE_ON; +} + +/* Start user code for adding. Do not edit comment generated here */ + +void r_Config_CSI11_UART1_interrupt_switching(void) { +#if defined(UART1_CHANNEL) && ( UART1_CHANNEL == 1 ) + // Check bit [2:1] of register SMR03 == 01 , which is set in R_Config_UART1_Create(). + if ( (SMR03 & _0002_SAU_MODE_UART) == _0002_SAU_MODE_UART) { + r_Config_UART1_interrupt_receive(); + return; + } +#endif + +#if defined(CSI_CHANNEL3) + // Check bit [2:1] of register SMR03 == 00 , which is set in R_Config_CSI11_Create(). + if ( (SMR03 & _0000_SAU_MODE_CSI) == _0000_SAU_MODE_CSI) { + // Call the interrupt handler for CSI11 (Master) + // If it is possible to distinguish between CSI11 (master) and CSI111 (slave), do so here. + r_Config_CSI20_interrupt(); + return; + } +#endif + +} + +void r_Config_CSI20_UART2_interrupt_send(void) { +#if (UART2_CHANNEL==2) + // Check bit [2:1] of register SMR03 == 01 , which is set in R_Config_UART1_Create(). + if ( (SMR10 & _0002_SAU_MODE_UART) == _0002_SAU_MODE_UART) { + r_Config_UART2_interrupt_send(); + return; + } +#endif + +#if defined(CSI_CHANNEL4) + // Check bit [2:1] of register SMR03 == 00 , which is set in R_Config_CSI11_Create(). + if ( (SMR10 & _0000_SAU_MODE_CSI) == _0000_SAU_MODE_CSI) { + // Call the interrupt handler for CSI11 (Master) + // If it is possible to distinguish between CSI11 (master) and CSI111 (slave), do so here. + r_Config_CSI20_interrupt(); + return; + } +#endif + +} + +/* End user code. Do not edit comment generated here */ diff --git a/cores/rl78g22/smc_gen/general/r_cg_sau_common.h b/cores/rl78g22/smc_gen/general/r_cg_sau_common.h index 07ae1b5..b657caa 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_sau_common.h +++ b/cores/rl78g22/smc_gen/general/r_cg_sau_common.h @@ -1,60 +1,60 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_sau_common.h -* Version : 1.0.0 -* Device(s) : R7F102GGExFB -* Description : Common header file for SAU peripheral. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef SAU_COMMON_H -#define SAU_COMMON_H - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_SAU0_Create (void); -void R_SAU1_Create (void); -void R_SAU0_Set_PowerOn (void); -void R_SAU0_Set_PowerOff (void); -void R_SAU1_Set_PowerOn (void); -void R_SAU1_Set_PowerOff (void); -void R_SAU0_Set_Reset (void); -void R_SAU0_Release_Reset (void); -void R_SAU1_Set_Reset (void); -void R_SAU1_Release_Reset (void); -void R_SAU0_Set_SnoozeOn (void); -void R_SAU0_Set_SnoozeOff (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_sau_common.h +* Version : 1.0.0 +* Device(s) : R7F102GGExFB +* Description : Common header file for SAU peripheral. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef SAU_COMMON_H +#define SAU_COMMON_H + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_SAU0_Create (void); +void R_SAU1_Create (void); +void R_SAU0_Set_PowerOn (void); +void R_SAU0_Set_PowerOff (void); +void R_SAU1_Set_PowerOn (void); +void R_SAU1_Set_PowerOff (void); +void R_SAU0_Set_Reset (void); +void R_SAU0_Release_Reset (void); +void R_SAU1_Set_Reset (void); +void R_SAU1_Release_Reset (void); +void R_SAU0_Set_SnoozeOn (void); +void R_SAU0_Set_SnoozeOff (void); +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/general/r_cg_systeminit.c b/cores/rl78g22/smc_gen/general/r_cg_systeminit.c index 485ba37..fe39e30 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_systeminit.c +++ b/cores/rl78g22/smc_gen/general/r_cg_systeminit.c @@ -1,81 +1,79 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_systeminit.c -* Version : 1.0.0 -* Device(s) : R7F102GGExFB -* Description : This file implements system initializing function. -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_ADC.h" -#include "Config_IICA0.h" -#include "Config_RTC.h" -#include "r_cg_sau_common.h" -#include "r_cg_tau_common.h" -#include "r_cg_itl_common.h" -/* Start user code for include. Do not edit comment generated here */ -/* 1112 Ueeda add */ -#include "Config_INTC.h" -/* 1112 Ueeda add */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_Systeminit -* Description : This function initializes every macro -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_Systeminit(void) -{ - PRR0 = 0x7FU; /* reset IICA, ADC, TAU and SAU module */ - PRR1 = 0xF3U; /* reset DAC, SMS, COMP, ITL, REMC, CTSU module */ - PRR0 = 0x00U; /* release IICA, ADC, TAU and SAU module */ - PRR1 = 0x00U; /* release DAC, SMS, COMP, ITL, REMC, CTSU module */ - /* Set peripheral settings */ -// R_SAU0_Create(); -// R_ITL_Create(); -// R_TAU0_Create(); - SAU0EN = 1U; /* supplies input clock */ /* R_SAU0_Create(); */ - SAU1EN = 1U; /* supplies input clock */ /* R_SAU1_Create(); */ - TAU0EN = 1U; /* start TAU0 clock */ /* R_TAU0_Create(); */ - TML32EN = 1U; /* start 32-bits IT clock */ /* R_ITL_Create(); */ - R_Config_ADC_Create(); - - /* The RTC initializes when using the function. */ - R_Config_RTC_Create(); -} +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_systeminit.c +* Version : 1.0.0 +* Device(s) : R7F102GGExFB +* Description : This file implements system initializing function. +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_ADC.h" +#include "Config_IICA0.h" +#include "Config_RTC.h" +#include "r_cg_sau_common.h" +#include "r_cg_tau_common.h" +#include "r_cg_itl_common.h" +/* Start user code for include. Do not edit comment generated here */ +#include "Config_INTC.h" +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_Systeminit +* Description : This function initializes every macro +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_Systeminit(void) +{ + PRR0 = 0x7FU; /* reset IICA, ADC, TAU and SAU module */ + PRR1 = 0xF3U; /* reset DAC, SMS, COMP, ITL, REMC, CTSU module */ + PRR0 = 0x00U; /* release IICA, ADC, TAU and SAU module */ + PRR1 = 0x00U; /* release DAC, SMS, COMP, ITL, REMC, CTSU module */ + /* Set peripheral settings */ +// R_SAU0_Create(); +// R_ITL_Create(); +// R_TAU0_Create(); + SAU0EN = 1U; /* supplies input clock */ /* R_SAU0_Create(); */ + SAU1EN = 1U; /* supplies input clock */ /* R_SAU1_Create(); */ + TAU0EN = 1U; /* start TAU0 clock */ /* R_TAU0_Create(); */ + TML32EN = 1U; /* start 32-bits IT clock */ /* R_ITL_Create(); */ + R_Config_ADC_Create(); + + /* The RTC initializes when using the function. */ + R_Config_RTC_Create(); +} diff --git a/cores/rl78g22/smc_gen/general/r_cg_tau.h b/cores/rl78g22/smc_gen/general/r_cg_tau.h index 3b26b3e..7a9dc29 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_tau.h +++ b/cores/rl78g22/smc_gen/general/r_cg_tau.h @@ -1,430 +1,430 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_tau.h -* Version : 1.0.0 -* Device(s) : R7F102GGExFB -* Description : General header file for TAU peripheral. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef TAU_H -#define TAU_H - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ -/* - Peripheral Enable Register 0 (PER0) -*/ -/* Control of timer array unit 0 input clock (TAU0EN) */ -#define _00_TAU0_CLOCK_STOP (0x00U) /* stops supply of input clock */ -#define _01_TAU0_CLOCK_SUPPLY (0x01U) /* supplies input clock */ - -/* - Peripheral Reset Control Register 0 (PRR0) -*/ -/* Reset control of timer array unit 0 (TAU0RES) */ -#define _00_TAU0_RESET_RELEASE (0x00U) /* unreset */ -#define _01_TAU0_RESET_SET (0x01U) /* reset */ - -/* - Timer Clock Select Register m (TPSm) -*/ -/* Operating mode and clear mode selection (PRSm31 - PRSm30) */ -#define _0000_TAU_CKM3_FCLK_8 (0x0000U) /* ckm3 - fCLK/2^8 */ -#define _1000_TAU_CKM3_FCLK_10 (0x1000U) /* ckm3 - fCLK/2^10 */ -#define _2000_TAU_CKM3_FCLK_12 (0x2000U) /* ckm3 - fCLK/2^12 */ -#define _3000_TAU_CKM3_FCLK_14 (0x3000U) /* ckm3 - fCLK/2^14 */ -#define _CFFF_TAU_CKM3_CLEAR (0xCFFFU) /* ckm3 - clear */ -/* Operating mode and clear mode selection (PRSm21 - PRSm20) */ -#define _0000_TAU_CKM2_FCLK_1 (0x0000U) /* ckm2 - fCLK/2^1 */ -#define _0100_TAU_CKM2_FCLK_2 (0x0100U) /* ckm2 - fCLK/2^2 */ -#define _0200_TAU_CKM2_FCLK_4 (0x0200U) /* ckm2 - fCLK/2^4 */ -#define _0300_TAU_CKM2_FCLK_6 (0x0300U) /* ckm2 - fCLK/2^6 */ -#define _FCFF_TAU_CKM2_CLEAR (0xFCFFU) /* ckm2 - clear */ -/* Operating mode and clear mode selection (PRSm13 - PRSm10) */ -#define _0000_TAU_CKM1_FCLK_0 (0x0000U) /* ckm1 - fCLK */ -#define _0010_TAU_CKM1_FCLK_1 (0x0010U) /* ckm1 - fCLK/2^1 */ -#define _0020_TAU_CKM1_FCLK_2 (0x0020U) /* ckm1 - fCLK/2^2 */ -#define _0030_TAU_CKM1_FCLK_3 (0x0030U) /* ckm1 - fCLK/2^3 */ -#define _0040_TAU_CKM1_FCLK_4 (0x0040U) /* ckm1 - fCLK/2^4 */ -#define _0050_TAU_CKM1_FCLK_5 (0x0050U) /* ckm1 - fCLK/2^5 */ -#define _0060_TAU_CKM1_FCLK_6 (0x0060U) /* ckm1 - fCLK/2^6 */ -#define _0070_TAU_CKM1_FCLK_7 (0x0070U) /* ckm1 - fCLK/2^7 */ -#define _0080_TAU_CKM1_FCLK_8 (0x0080U) /* ckm1 - fCLK/2^8 */ -#define _0090_TAU_CKM1_FCLK_9 (0x0090U) /* ckm1 - fCLK/2^9 */ -#define _00A0_TAU_CKM1_FCLK_10 (0x00A0U) /* ckm1 - fCLK/2^10 */ -#define _00B0_TAU_CKM1_FCLK_11 (0x00B0U) /* ckm1 - fCLK/2^11 */ -#define _00C0_TAU_CKM1_FCLK_12 (0x00C0U) /* ckm1 - fCLK/2^12 */ -#define _00D0_TAU_CKM1_FCLK_13 (0x00D0U) /* ckm1 - fCLK/2^13 */ -#define _00E0_TAU_CKM1_FCLK_14 (0x00E0U) /* ckm1 - fCLK/2^14 */ -#define _00F0_TAU_CKM1_FCLK_15 (0x00F0U) /* ckm1 - fCLK/2^15 */ -#define _FF0F_TAU_CKM1_CLEAR (0xFF0FU) /* ckm1 - clear */ -/* Operating mode and clear mode selection (PRSm03 - PRSm00) */ -#define _0000_TAU_CKM0_FCLK_0 (0x0000U) /* ckm0 - fCLK */ -#define _0001_TAU_CKM0_FCLK_1 (0x0001U) /* ckm0 - fCLK/2^1 */ -#define _0002_TAU_CKM0_FCLK_2 (0x0002U) /* ckm0 - fCLK/2^2 */ -#define _0003_TAU_CKM0_FCLK_3 (0x0003U) /* ckm0 - fCLK/2^3 */ -#define _0004_TAU_CKM0_FCLK_4 (0x0004U) /* ckm0 - fCLK/2^4 */ -#define _0005_TAU_CKM0_FCLK_5 (0x0005U) /* ckm0 - fCLK/2^5 */ -#define _0006_TAU_CKM0_FCLK_6 (0x0006U) /* ckm0 - fCLK/2^6 */ -#define _0007_TAU_CKM0_FCLK_7 (0x0007U) /* ckm0 - fCLK/2^7 */ -#define _0008_TAU_CKM0_FCLK_8 (0x0008U) /* ckm0 - fCLK/2^8 */ -#define _0009_TAU_CKM0_FCLK_9 (0x0009U) /* ckm0 - fCLK/2^9 */ -#define _000A_TAU_CKM0_FCLK_10 (0x000AU) /* ckm0 - fCLK/2^10 */ -#define _000B_TAU_CKM0_FCLK_11 (0x000BU) /* ckm0 - fCLK/2^11 */ -#define _000C_TAU_CKM0_FCLK_12 (0x000CU) /* ckm0 - fCLK/2^12 */ -#define _000D_TAU_CKM0_FCLK_13 (0x000DU) /* ckm0 - fCLK/2^13 */ -#define _000E_TAU_CKM0_FCLK_14 (0x000EU) /* ckm0 - fCLK/2^14 */ -#define _000F_TAU_CKM0_FCLK_15 (0x000FU) /* ckm0 - fCLK/2^15 */ -#define _FFF0_TAU_CKM0_CLEAR (0xFFF0U) /* ckm0 - clear */ - -/* - Timer Mode Register mn (TMRmn) -*/ -/* Selection of macro clock (MCK) of channel n (CKSmn1 - CKSmn0) */ -#define _0000_TAU_CLOCK_SELECT_CKM0 (0x0000U) /* operation clock CK0 set by PRS register */ -#define _8000_TAU_CLOCK_SELECT_CKM1 (0x8000U) /* operation clock CK1 set by PRS register */ -#define _4000_TAU_CLOCK_SELECT_CKM2 (0x4000U) /* operation clock CK2 set by PRS register */ -#define _C000_TAU_CLOCK_SELECT_CKM3 (0xC000U) /* operation clock CK3 set by PRS register */ -/* Selection of count clock (CCK) of channel n (CCSmn) */ -#define _0000_TAU_CLOCK_MODE_CKS (0x0000U) /* macro clock MCK specified by CKSmn bit */ -#define _1000_TAU_CLOCK_MODE_TIMN (0x1000U) /* valid edge of input signal input from TImn pin */ -/* Selection of slave/master of channel n (MASTERmn) */ -#define _0000_TAU_COMBINATION_SLAVE (0x0000U) /* operates as slave channel */ -#define _0800_TAU_COMBINATION_MASTER (0x0800U) /* channel 2, 4, 6 operates as master channel */ -/* Operation explanation of channel 1 or 3 (SPLIT) */ -#define _0000_TAU_16BITS_MODE (0x0000U) /* operates as 16 bits timer */ -#define _0800_TAU_8BITS_MODE (0x0800U) /* operates as 8 bits timer */ -/* Setting of start trigger or capture trigger of channel n (STSmn2 - STSmn0) */ -#define _0000_TAU_TRIGGER_SOFTWARE (0x0000U) /* only software trigger start is valid */ -#define _0100_TAU_TRIGGER_TIMN_VALID (0x0100U) /* TImn input edge is used as a start/capture trigger */ -#define _0200_TAU_TRIGGER_TIMN_BOTH (0x0200U) /* TImn input edges are used as a start/capture trigger */ -#define _0400_TAU_TRIGGER_MASTER_INT (0x0400U) /* interrupt signal of the master channel is used */ -#define _0600_TAU_TRIGGER_MASTER_INT_TI03 (0x0600U) /* interrupt signal of the master is used as start trigger, - a valid edge of the TI03 pin is used as the end trigger */ -/* Selection of TImn pin input valid edge (CISmn1 - CISmn0) */ -#define _0000_TAU_TIMN_EDGE_FALLING (0x0000U) /* falling edge */ -#define _0040_TAU_TIMN_EDGE_RISING (0x0040U) /* rising edge */ -#define _0080_TAU_TIMN_EDGE_BOTH_LOW (0x0080U) /* both edges (when low-level width is measured) */ -#define _00C0_TAU_TIMN_EDGE_BOTH_HIGH (0x00C0U) /* both edges (when high-level width is measured) */ -/* Operation mode of channel n (MDmn3 - MDmn0) */ -#define _0000_TAU_MODE_INTERVAL_TIMER (0x0000U) /* interval timer mode */ -#define _0004_TAU_MODE_CAPTURE (0x0004U) /* capture mode */ -#define _0006_TAU_MODE_EVENT_COUNT (0x0006U) /* event counter mode */ -#define _0008_TAU_MODE_ONE_COUNT (0x0008U) /* one count mode */ -#define _000C_TAU_MODE_HIGHLOW_MEASURE (0x000CU) /* high-/low-level width measurement mode */ -#define _0001_TAU_MODE_PWM_MASTER (0x0001U) /* PWM Function (Master Channel) mode */ -#define _0009_TAU_MODE_PWM_SLAVE (0x0009U) /* PWM Function (Slave Channel) mode */ -#define _0008_TAU_MODE_ONESHOT (0x0008U) /* one-shot pulse output mode */ -/* Setting of starting counting and interrupt (MDmn0) */ -#define _0000_TAU_START_INT_UNUSED (0x0000U) /* interrupt is not generated when counting is started */ -#define _0001_TAU_START_INT_USED (0x0001U) /* interrupt is generated when counting is started */ - -/* - Timer Status Register mn (TSRmn) -*/ -/* Counter overflow status of channel n (OVF) */ -#define _0000_TAU_OVERFLOW_NOT_OCCURS (0x0000U) /* overflow does not occur */ -#define _0001_TAU_OVERFLOW_OCCURS (0x0001U) /* overflow occurs */ - -/* - Timer Channel Enable Status Register m (TEm) -*/ -/* Indication of operation enable/stop status of channel 3 higher 8 bits (TEHm3) */ -#define _0000_TAU_CH3_H8_OPERATION_STOP (0x0000U) /* operation is stopped */ -#define _0800_TAU_CH3_H8_OPERATION_ENABLE (0x0800U) /* operation is enabled */ -/* Indication of operation enable/stop status of channel 1 higher 8 bits (TEHm1) */ -#define _0000_TAU_CH1_H8_OPERATION_STOP (0x0000U) /* operation is stopped */ -#define _0200_TAU_CH1_H8_OPERATION_ENABLE (0x0200U) /* operation is enabled */ -/* Indication of operation enable/stop status of channel 7 (TEm7) */ -#define _0000_TAU_CH7_OPERATION_STOP (0x0000U) /* operation is stopped */ -#define _0080_TAU_CH7_OPERATION_ENABLE (0x0080U) /* operation is enabled */ -/* Indication of operation enable/stop status of channel 6 (TEm6) */ -#define _0000_TAU_CH6_OPERATION_STOP (0x0000U) /* operation is stopped */ -#define _0040_TAU_CH6_OPERATION_ENABLE (0x0040U) /* operation is enabled */ -/* Indication of operation enable/stop status of channel 5 (TEm5) */ -#define _0000_TAU_CH5_OPERATION_STOP (0x0000U) /* operation is stopped */ -#define _0020_TAU_CH5_OPERATION_ENABLE (0x0020U) /* operation is enabled */ -/* Indication of operation enable/stop status of channel 4 (TEm4) */ -#define _0000_TAU_CH4_OPERATION_STOP (0x0000U) /* operation is stopped */ -#define _0010_TAU_CH4_OPERATION_ENABLE (0x0010U) /* operation is enabled */ -/* Indication of operation enable/stop status of channel 3 (TEm3) */ -#define _0000_TAU_CH3_OPERATION_STOP (0x0000U) /* operation is stopped */ -#define _0008_TAU_CH3_OPERATION_ENABLE (0x0008U) /* operation is enabled */ -/* Indication of operation enable/stop status of channel 2 (TEm2) */ -#define _0000_TAU_CH2_OPERATION_STOP (0x0000U) /* operation is stopped */ -#define _0004_TAU_CH2_OPERATION_ENABLE (0x0004U) /* operation is enabled */ -/* Indication of operation enable/stop status of channel 1 (TEm1) */ -#define _0000_TAU_CH1_OPERATION_STOP (0x0000U) /* operation is stopped */ -#define _0002_TAU_CH1_OPERATION_ENABLE (0x0002U) /* operation is enabled */ -/* Indication of operation enable/stop status of channel 0 (TEm0) */ -#define _0000_TAU_CH0_OPERATION_STOP (0x0000U) /* operation is stopped */ -#define _0001_TAU_CH0_OPERATION_ENABLE (0x0001U) /* operation is enabled */ - -/* - Timer Channel Start Register m (TSm) -*/ -/* Operation enable (start) trigger of channel 3 higher 8 bits (TSHm3) */ -#define _0000_TAU_CH3_H8_START_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0800_TAU_CH3_H8_START_TRG_ON (0x0800U) /* operation is enabled (start trigger is generated) */ -/* Operation enable (start) trigger of channel 1 higher 8 bits (TSHm1) */ -#define _0000_TAU_CH1_H8_START_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0200_TAU_CH1_H8_START_TRG_ON (0x0200U) /* operation is enabled (start trigger is generated) */ -/* Operation enable (start) trigger of channel 7 (TSm7) */ -#define _0000_TAU_CH7_START_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0080_TAU_CH7_START_TRG_ON (0x0080U) /* operation is enabled (start trigger is generated) */ -/* Operation enable (start) trigger of channel 6 (TSm6) */ -#define _0000_TAU_CH6_START_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0040_TAU_CH6_START_TRG_ON (0x0040U) /* operation is enabled (start trigger is generated) */ -/* Operation enable (start) trigger of channel 5 (TSm5) */ -#define _0000_TAU_CH5_START_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0020_TAU_CH5_START_TRG_ON (0x0020U) /* operation is enabled (start trigger is generated) */ -/* Operation enable (start) trigger of channel 4 (TSm4) */ -#define _0000_TAU_CH4_START_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0010_TAU_CH4_START_TRG_ON (0x0010U) /* operation is enabled (start trigger is generated) */ -/* Operation enable (start) trigger of channel 3 (TSm3) */ -#define _0000_TAU_CH3_START_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0008_TAU_CH3_START_TRG_ON (0x0008U) /* operation is enabled (start trigger is generated) */ -/* Operation enable (start) trigger of channel 2 (TSm2) */ -#define _0000_TAU_CH2_START_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0004_TAU_CH2_START_TRG_ON (0x0004U) /* operation is enabled (start trigger is generated) */ -/* Operation enable (start) trigger of channel 1 (TSm1) */ -#define _0000_TAU_CH1_START_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0002_TAU_CH1_START_TRG_ON (0x0002U) /* operation is enabled (start trigger is generated) */ -/* Operation enable (start) trigger of channel 0 (TSm0) */ -#define _0000_TAU_CH0_START_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0001_TAU_CH0_START_TRG_ON (0x0001U) /* operation is enabled (start trigger is generated) */ - -/* - Timer Channel Stop Register m (TTm) -*/ -/* Operation stop trigger of channel 3 higher 8 bits (TTHm3) */ -#define _0000_TAU_CH3_H8_STOP_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0800_TAU_CH3_H8_STOP_TRG_ON (0x0800U) /* operation is stopped (stop trigger is generated) */ -/* Operation stop trigger of channel 1 higher 8 bits (TTHm1) */ -#define _0000_TAU_CH1_H8_STOP_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0200_TAU_CH1_H8_STOP_TRG_ON (0x0200U) /* operation is stopped (stop trigger is generated) */ -/* Operation stop trigger of channel 7 (TTm7) */ -#define _0000_TAU_CH7_STOP_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0080_TAU_CH7_STOP_TRG_ON (0x0080U) /* operation is stopped (stop trigger is generated) */ -/* Operation stop trigger of channel 6 (TTm6) */ -#define _0000_TAU_CH6_STOP_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0040_TAU_CH6_STOP_TRG_ON (0x0040U) /* operation is stopped (stop trigger is generated) */ -/* Operation stop trigger of channel 5 (TTm5) */ -#define _0000_TAU_CH5_STOP_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0020_TAU_CH5_STOP_TRG_ON (0x0020U) /* operation is stopped (stop trigger is generated) */ -/* Operation stop trigger of channel 4 (TTm4) */ -#define _0000_TAU_CH4_STOP_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0010_TAU_CH4_STOP_TRG_ON (0x0010U) /* operation is stopped (stop trigger is generated) */ -/* Operation stop trigger of channel 3 (TTm3) */ -#define _0000_TAU_CH3_STOP_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0008_TAU_CH3_STOP_TRG_ON (0x0008U) /* operation is stopped (stop trigger is generated) */ -/* Operation stop trigger of channel 2 (TTm2) */ -#define _0000_TAU_CH2_STOP_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0004_TAU_CH2_STOP_TRG_ON (0x0004U) /* operation is stopped (stop trigger is generated) */ -/* Operation stop trigger of channel 1 (TTm1) */ -#define _0000_TAU_CH1_STOP_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0002_TAU_CH1_STOP_TRG_ON (0x0002U) /* operation is stopped (stop trigger is generated) */ -/* Operation stop trigger of channel 0 (TTm0) */ -#define _0000_TAU_CH0_STOP_TRG_OFF (0x0000U) /* no trigger operation */ -#define _0001_TAU_CH0_STOP_TRG_ON (0x0001U) /* operation is stopped (stop trigger is generated) */ - -/* - Timer Input Select Register m (TIS0) -*/ -/* Selection of timer input used with channel 5 of unit 0 (TIS02 - TIS00) */ -#define _00_TAU_CH5_INPUT_TI05 (0x00U) /* input signal of timer input pin (TI05) */ -#define _01_TAU_CH5_INPUT_ELC (0x01U) /* input signal of ELC */ -#define _03_TAU_CH5_INPUT_FIMP (0x03U) /* internal Medium speed oscillation colock (fIMP) */ -#define _04_TAU_CH5_INPUT_FIL (0x04U) /* internal low speed oscillation colock (fIL) */ -#define _05_TAU_CH5_INPUT_FSUB (0x05U) /* sub colock (fSUB) */ -#define _F8_TAU_CH5_INPUT_CLEAR (0xF8U) /* bits of TIS02 - TIS00 clear */ - -/* - Timer Input Select Register m (TIS1) -*/ -/* Selection of timer input used with channel 1 of unit 0 (TIS11) */ -#define _01_TAU_CH1_INPUT_TI01 (0x01U) /* input signal of timer input pin (TI01) */ -#define _02_TAU_CH1_INPUT_ELC (0x02U) /* input signal of ELC */ -/* Selection of timer input used with channel 0 of unit 0 (TIS10) */ -#define _02_TAU_CH0_INPUT_TI00 (0x02U) /* input signal of timer input pin (TI00) */ -#define _01_TAU_CH0_INPUT_ELC (0x01U) /* input signal of ELC */ - -/* - Timer Output Enable Register m (TOEm) -*/ -/* Timer output enable/disable of channel 7 (TOEm7) */ -#define _0080_TAU_CH7_OUTPUT_ENABLE (0x0080U) /* the TOm7 operation enabled by count operation */ -#define _0000_TAU_CH7_OUTPUT_DISABLE (0x0000U) /* the TOm7 operation stopped by count operation */ -/* Timer output enable/disable of channel 6 (TOEm6) */ -#define _0040_TAU_CH6_OUTPUT_ENABLE (0x0040U) /* the TOm6 operation enabled by count operation */ -#define _0000_TAU_CH6_OUTPUT_DISABLE (0x0000U) /* the TOm6 operation stopped by count operation */ -/* Timer output enable/disable of channel 5 (TOEm5) */ -#define _0020_TAU_CH5_OUTPUT_ENABLE (0x0020U) /* the TOm5 operation enabled by count operation */ -#define _0000_TAU_CH5_OUTPUT_DISABLE (0x0000U) /* the TOm5 operation stopped by count operation */ -/* Timer output enable/disable of channel 4 (TOEm4) */ -#define _0010_TAU_CH4_OUTPUT_ENABLE (0x0010U) /* the TOm4 operation enabled by count operation */ -#define _0000_TAU_CH4_OUTPUT_DISABLE (0x0000U) /* the TOm4 operation stopped by count operation */ -/* Timer output enable/disable of channel 3 (TOEm3) */ -#define _0008_TAU_CH3_OUTPUT_ENABLE (0x0008U) /* the TOm3 operation enabled by count operation */ -#define _0000_TAU_CH3_OUTPUT_DISABLE (0x0000U) /* the TOm3 operation stopped by count operation */ -/* Timer output enable/disable of channel 2 (TOEm2) */ -#define _0004_TAU_CH2_OUTPUT_ENABLE (0x0004U) /* the TOm2 operation enabled by count operation */ -#define _0000_TAU_CH2_OUTPUT_DISABLE (0x0000U) /* the TOm2 operation stopped by count operation */ -/* Timer output enable/disable of channel 1 (TOEm1) */ -#define _0002_TAU_CH1_OUTPUT_ENABLE (0x0002U) /* the TOm1 operation enabled by count operation */ -#define _0000_TAU_CH1_OUTPUT_DISABLE (0x0000U) /* the TOm1 operation stopped by count operation */ -/* Timer output enable/disable of channel 0 (TOEm0) */ -#define _0001_TAU_CH0_OUTPUT_ENABLE (0x0001U) /* the TOm0 operation enabled by count operation */ -#define _0000_TAU_CH0_OUTPUT_DISABLE (0x0000U) /* the TOm0 operation stopped by count operation */ - -/* - Timer Output Register m (TOm) -*/ -/* Timer output of channel 7 (TOm7) */ -#define _0000_TAU_CH7_OUTPUT_VALUE_0 (0x0000U) /* timer output value is "0" */ -#define _0080_TAU_CH7_OUTPUT_VALUE_1 (0x0080U) /* timer output value is "1" */ -/* Timer output of channel 6 (TOm6) */ -#define _0000_TAU_CH6_OUTPUT_VALUE_0 (0x0000U) /* timer output value is "0" */ -#define _0040_TAU_CH6_OUTPUT_VALUE_1 (0x0040U) /* timer output value is "1" */ -/* Timer output of channel 5 (TOm5) */ -#define _0000_TAU_CH5_OUTPUT_VALUE_0 (0x0000U) /* timer output value is "0" */ -#define _0020_TAU_CH5_OUTPUT_VALUE_1 (0x0020U) /* timer output value is "1" */ -/* Timer output of channel 4 (TOm4) */ -#define _0000_TAU_CH4_OUTPUT_VALUE_0 (0x0000U) /* timer output value is "0" */ -#define _0010_TAU_CH4_OUTPUT_VALUE_1 (0x0010U) /* timer output value is "1" */ -/* Timer output of channel 3 (TOm3) */ -#define _0000_TAU_CH3_OUTPUT_VALUE_0 (0x0000U) /* timer output value is "0" */ -#define _0008_TAU_CH3_OUTPUT_VALUE_1 (0x0008U) /* timer output value is "1" */ -/* Timer output of channel 2 (TOm2) */ -#define _0000_TAU_CH2_OUTPUT_VALUE_0 (0x0000U) /* timer output value is "0" */ -#define _0004_TAU_CH2_OUTPUT_VALUE_1 (0x0004U) /* timer output value is "1" */ -/* Timer output of channel 1 (TOm1) */ -#define _0000_TAU_CH1_OUTPUT_VALUE_0 (0x0000U) /* timer output value is "0" */ -#define _0002_TAU_CH1_OUTPUT_VALUE_1 (0x0002U) /* timer output value is "1" */ -/* Timer output of channel 0 (TOm0) */ -#define _0000_TAU_CH0_OUTPUT_VALUE_0 (0x0000U) /* timer output value is "0" */ -#define _0001_TAU_CH0_OUTPUT_VALUE_1 (0x0001U) /* timer output value is "1" */ - -/* - Timer Output Level Register 0 (TOLm) -*/ -/* Control of timer output level of channel 7 (TOLm7) */ -#define _0000_TAU_CH7_OUTPUT_LEVEL_H (0x0000U) /* positive logic output (active-high) */ -#define _0080_TAU_CH7_OUTPUT_LEVEL_L (0x0080U) /* inverted output (active-low) */ -/* Control of timer output level of channel 6 (TOLm6) */ -#define _0000_TAU_CH6_OUTPUT_LEVEL_H (0x0000U) /* positive logic output (active-high) */ -#define _0040_TAU_CH6_OUTPUT_LEVEL_L (0x0040U) /* inverted output (active-low) */ -/* Control of timer output level of channel 5 (TOLm5) */ -#define _0000_TAU_CH5_OUTPUT_LEVEL_H (0x0000U) /* positive logic output (active-high) */ -#define _0020_TAU_CH5_OUTPUT_LEVEL_L (0x0020U) /* inverted output (active-low) */ -/* Control of timer output level of channel 4 (TOLm4) */ -#define _0000_TAU_CH4_OUTPUT_LEVEL_H (0x0000U) /* positive logic output (active-high) */ -#define _0010_TAU_CH4_OUTPUT_LEVEL_L (0x0010U) /* inverted output (active-low) */ -/* Control of timer output level of channel 3 (TOLm3) */ -#define _0000_TAU_CH3_OUTPUT_LEVEL_H (0x0000U) /* positive logic output (active-high) */ -#define _0008_TAU_CH3_OUTPUT_LEVEL_L (0x0008U) /* inverted output (active-low) */ -/* Control of timer output level of channel 2 (TOLm2) */ -#define _0000_TAU_CH2_OUTPUT_LEVEL_H (0x0000U) /* positive logic output (active-high) */ -#define _0004_TAU_CH2_OUTPUT_LEVEL_L (0x0004U) /* inverted output (active-low) */ -/* Control of timer output level of channel 1 (TOLm1) */ -#define _0000_TAU_CH1_OUTPUT_LEVEL_H (0x0000U) /* positive logic output (active-high) */ -#define _0002_TAU_CH1_OUTPUT_LEVEL_L (0x0002U) /* inverted output (active-low) */ - -/* - Timer Output Mode Register m (TOMm) -*/ -/* Control of timer output mode of channel 7 (TOMm7) */ -#define _0000_TAU_CH7_MASTER_OUTPUT (0x0000U) /* master channel output mode */ -#define _0080_TAU_CH7_SLAVE_OUTPUT (0x0080U) /* slave channel output mode */ -/* Control of timer output mode of channel 6 (TOMm6) */ -#define _0000_TAU_CH6_MASTER_OUTPUT (0x0000U) /* master channel output mode */ -#define _0040_TAU_CH6_SLAVE_OUTPUT (0x0040U) /* slave channel output mode */ -/* Control of timer output mode of channel 5 (TOMm5) */ -#define _0000_TAU_CH5_MASTER_OUTPUT (0x0000U) /* master channel output mode */ -#define _0020_TAU_CH5_SLAVE_OUTPUT (0x0020U) /* slave channel output mode */ -/* Control of timer output mode of channel 4 (TOMm4) */ -#define _0000_TAU_CH4_MASTER_OUTPUT (0x0000U) /* master channel output mode */ -#define _0010_TAU_CH4_SLAVE_OUTPUT (0x0010U) /* slave channel output mode */ -/* Control of timer output mode of channel 3 (TOMm3) */ -#define _0000_TAU_CH3_MASTER_OUTPUT (0x0000U) /* master channel output mode */ -#define _0008_TAU_CH3_SLAVE_OUTPUT (0x0008U) /* slave channel output mode */ -/* Control of timer output mode of channel 2 (TOMm2) */ -#define _0000_TAU_CH2_MASTER_OUTPUT (0x0000U) /* master channel output mode */ -#define _0004_TAU_CH2_SLAVE_OUTPUT (0x0004U) /* slave channel output mode */ -/* Control of timer output mode of channel 1 (TOMm1) */ -#define _0000_TAU_CH1_MASTER_OUTPUT (0x0000U) /* master channel output mode */ -#define _0002_TAU_CH1_SLAVE_OUTPUT (0x0002U) /* slave channel output mode */ - -/* - Input Switch Control Register (ISC) -*/ -/* Switching channel 7 input of timer array unit (ISC1) */ -#define _00_TAU_CH7_INPUT_TI07 (0x00U) /* input signal of TI07 pin is used as timer input */ -#define _02_TAU_CH7_INPUT_RXD2 (0x02U) /* input signal of RxD2 pin is used as timer input */ -#define _FD_TAU_CH7_INPUT_CLEAR (0xFDU) /* channel 7 input clear */ -/* External interrupt (INTP0) input switching (ISC0) */ -#define _00_EXTERNAL_INPUT_INTP0 (0x00U) /* input signal of INTP0 is used as external interrupt input */ -#define _01_EXTERNAL_INPUT_RXD2 (0x01U) /* input signal of RxD2 pin is used as external interrupt input */ - -/* - Noise Filter Enable Register 1 (NFEN1) -*/ -/* Enable/disable using noise filter of TI07 pin input signal (TNFEN07) */ -#define _00_TAU_CH7_NOISE_OFF (0x00U) /* noise filter OFF */ -#define _80_TAU_CH7_NOISE_ON (0x80U) /* noise filter ON */ -/* Enable/disable using noise filter of TI06 pin input signal (TNFEN06) */ -#define _00_TAU_CH6_NOISE_OFF (0x00U) /* noise filter OFF */ -#define _40_TAU_CH6_NOISE_ON (0x40U) /* noise filter ON */ -/* Enable/disable using noise filter of TI05 pin input signal (TNFEN05) */ -#define _00_TAU_CH5_NOISE_OFF (0x00U) /* noise filter OFF */ -#define _20_TAU_CH5_NOISE_ON (0x20U) /* noise filter ON */ -/* Enable/disable using noise filter of TI04 pin input signal (TNFEN04) */ -#define _00_TAU_CH4_NOISE_OFF (0x00U) /* noise filter OFF */ -#define _10_TAU_CH4_NOISE_ON (0x10U) /* noise filter ON */ -/* Enable/disable using noise filter of TI03 pin input signal (TNFEN03) */ -#define _00_TAU_CH3_NOISE_OFF (0x00U) /* noise filter OFF */ -#define _08_TAU_CH3_NOISE_ON (0x08U) /* noise filter ON */ -/* Enable/disable using noise filter of TI02 pin input signal (TNFEN02) */ -#define _00_TAU_CH2_NOISE_OFF (0x00U) /* noise filter OFF */ -#define _04_TAU_CH2_NOISE_ON (0x04U) /* noise filter ON */ -/* Enable/disable using noise filter of TI01 pin input signal (TNFEN01) */ -#define _00_TAU_CH1_NOISE_OFF (0x00U) /* noise filter OFF */ -#define _02_TAU_CH1_NOISE_ON (0x02U) /* noise filter ON */ -/* Enable/disable using noise filter of TI00 pin input signal (TNFEN00) */ -#define _00_TAU_CH0_NOISE_OFF (0x00U) /* noise filter OFF */ -#define _01_TAU_CH0_NOISE_ON (0x01U) /* noise filter ON */ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_tau.h +* Version : 1.0.0 +* Device(s) : R7F102GGExFB +* Description : General header file for TAU peripheral. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef TAU_H +#define TAU_H + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ +/* + Peripheral Enable Register 0 (PER0) +*/ +/* Control of timer array unit 0 input clock (TAU0EN) */ +#define _00_TAU0_CLOCK_STOP (0x00U) /* stops supply of input clock */ +#define _01_TAU0_CLOCK_SUPPLY (0x01U) /* supplies input clock */ + +/* + Peripheral Reset Control Register 0 (PRR0) +*/ +/* Reset control of timer array unit 0 (TAU0RES) */ +#define _00_TAU0_RESET_RELEASE (0x00U) /* unreset */ +#define _01_TAU0_RESET_SET (0x01U) /* reset */ + +/* + Timer Clock Select Register m (TPSm) +*/ +/* Operating mode and clear mode selection (PRSm31 - PRSm30) */ +#define _0000_TAU_CKM3_FCLK_8 (0x0000U) /* ckm3 - fCLK/2^8 */ +#define _1000_TAU_CKM3_FCLK_10 (0x1000U) /* ckm3 - fCLK/2^10 */ +#define _2000_TAU_CKM3_FCLK_12 (0x2000U) /* ckm3 - fCLK/2^12 */ +#define _3000_TAU_CKM3_FCLK_14 (0x3000U) /* ckm3 - fCLK/2^14 */ +#define _CFFF_TAU_CKM3_CLEAR (0xCFFFU) /* ckm3 - clear */ +/* Operating mode and clear mode selection (PRSm21 - PRSm20) */ +#define _0000_TAU_CKM2_FCLK_1 (0x0000U) /* ckm2 - fCLK/2^1 */ +#define _0100_TAU_CKM2_FCLK_2 (0x0100U) /* ckm2 - fCLK/2^2 */ +#define _0200_TAU_CKM2_FCLK_4 (0x0200U) /* ckm2 - fCLK/2^4 */ +#define _0300_TAU_CKM2_FCLK_6 (0x0300U) /* ckm2 - fCLK/2^6 */ +#define _FCFF_TAU_CKM2_CLEAR (0xFCFFU) /* ckm2 - clear */ +/* Operating mode and clear mode selection (PRSm13 - PRSm10) */ +#define _0000_TAU_CKM1_FCLK_0 (0x0000U) /* ckm1 - fCLK */ +#define _0010_TAU_CKM1_FCLK_1 (0x0010U) /* ckm1 - fCLK/2^1 */ +#define _0020_TAU_CKM1_FCLK_2 (0x0020U) /* ckm1 - fCLK/2^2 */ +#define _0030_TAU_CKM1_FCLK_3 (0x0030U) /* ckm1 - fCLK/2^3 */ +#define _0040_TAU_CKM1_FCLK_4 (0x0040U) /* ckm1 - fCLK/2^4 */ +#define _0050_TAU_CKM1_FCLK_5 (0x0050U) /* ckm1 - fCLK/2^5 */ +#define _0060_TAU_CKM1_FCLK_6 (0x0060U) /* ckm1 - fCLK/2^6 */ +#define _0070_TAU_CKM1_FCLK_7 (0x0070U) /* ckm1 - fCLK/2^7 */ +#define _0080_TAU_CKM1_FCLK_8 (0x0080U) /* ckm1 - fCLK/2^8 */ +#define _0090_TAU_CKM1_FCLK_9 (0x0090U) /* ckm1 - fCLK/2^9 */ +#define _00A0_TAU_CKM1_FCLK_10 (0x00A0U) /* ckm1 - fCLK/2^10 */ +#define _00B0_TAU_CKM1_FCLK_11 (0x00B0U) /* ckm1 - fCLK/2^11 */ +#define _00C0_TAU_CKM1_FCLK_12 (0x00C0U) /* ckm1 - fCLK/2^12 */ +#define _00D0_TAU_CKM1_FCLK_13 (0x00D0U) /* ckm1 - fCLK/2^13 */ +#define _00E0_TAU_CKM1_FCLK_14 (0x00E0U) /* ckm1 - fCLK/2^14 */ +#define _00F0_TAU_CKM1_FCLK_15 (0x00F0U) /* ckm1 - fCLK/2^15 */ +#define _FF0F_TAU_CKM1_CLEAR (0xFF0FU) /* ckm1 - clear */ +/* Operating mode and clear mode selection (PRSm03 - PRSm00) */ +#define _0000_TAU_CKM0_FCLK_0 (0x0000U) /* ckm0 - fCLK */ +#define _0001_TAU_CKM0_FCLK_1 (0x0001U) /* ckm0 - fCLK/2^1 */ +#define _0002_TAU_CKM0_FCLK_2 (0x0002U) /* ckm0 - fCLK/2^2 */ +#define _0003_TAU_CKM0_FCLK_3 (0x0003U) /* ckm0 - fCLK/2^3 */ +#define _0004_TAU_CKM0_FCLK_4 (0x0004U) /* ckm0 - fCLK/2^4 */ +#define _0005_TAU_CKM0_FCLK_5 (0x0005U) /* ckm0 - fCLK/2^5 */ +#define _0006_TAU_CKM0_FCLK_6 (0x0006U) /* ckm0 - fCLK/2^6 */ +#define _0007_TAU_CKM0_FCLK_7 (0x0007U) /* ckm0 - fCLK/2^7 */ +#define _0008_TAU_CKM0_FCLK_8 (0x0008U) /* ckm0 - fCLK/2^8 */ +#define _0009_TAU_CKM0_FCLK_9 (0x0009U) /* ckm0 - fCLK/2^9 */ +#define _000A_TAU_CKM0_FCLK_10 (0x000AU) /* ckm0 - fCLK/2^10 */ +#define _000B_TAU_CKM0_FCLK_11 (0x000BU) /* ckm0 - fCLK/2^11 */ +#define _000C_TAU_CKM0_FCLK_12 (0x000CU) /* ckm0 - fCLK/2^12 */ +#define _000D_TAU_CKM0_FCLK_13 (0x000DU) /* ckm0 - fCLK/2^13 */ +#define _000E_TAU_CKM0_FCLK_14 (0x000EU) /* ckm0 - fCLK/2^14 */ +#define _000F_TAU_CKM0_FCLK_15 (0x000FU) /* ckm0 - fCLK/2^15 */ +#define _FFF0_TAU_CKM0_CLEAR (0xFFF0U) /* ckm0 - clear */ + +/* + Timer Mode Register mn (TMRmn) +*/ +/* Selection of macro clock (MCK) of channel n (CKSmn1 - CKSmn0) */ +#define _0000_TAU_CLOCK_SELECT_CKM0 (0x0000U) /* operation clock CK0 set by PRS register */ +#define _8000_TAU_CLOCK_SELECT_CKM1 (0x8000U) /* operation clock CK1 set by PRS register */ +#define _4000_TAU_CLOCK_SELECT_CKM2 (0x4000U) /* operation clock CK2 set by PRS register */ +#define _C000_TAU_CLOCK_SELECT_CKM3 (0xC000U) /* operation clock CK3 set by PRS register */ +/* Selection of count clock (CCK) of channel n (CCSmn) */ +#define _0000_TAU_CLOCK_MODE_CKS (0x0000U) /* macro clock MCK specified by CKSmn bit */ +#define _1000_TAU_CLOCK_MODE_TIMN (0x1000U) /* valid edge of input signal input from TImn pin */ +/* Selection of slave/master of channel n (MASTERmn) */ +#define _0000_TAU_COMBINATION_SLAVE (0x0000U) /* operates as slave channel */ +#define _0800_TAU_COMBINATION_MASTER (0x0800U) /* channel 2, 4, 6 operates as master channel */ +/* Operation explanation of channel 1 or 3 (SPLIT) */ +#define _0000_TAU_16BITS_MODE (0x0000U) /* operates as 16 bits timer */ +#define _0800_TAU_8BITS_MODE (0x0800U) /* operates as 8 bits timer */ +/* Setting of start trigger or capture trigger of channel n (STSmn2 - STSmn0) */ +#define _0000_TAU_TRIGGER_SOFTWARE (0x0000U) /* only software trigger start is valid */ +#define _0100_TAU_TRIGGER_TIMN_VALID (0x0100U) /* TImn input edge is used as a start/capture trigger */ +#define _0200_TAU_TRIGGER_TIMN_BOTH (0x0200U) /* TImn input edges are used as a start/capture trigger */ +#define _0400_TAU_TRIGGER_MASTER_INT (0x0400U) /* interrupt signal of the master channel is used */ +#define _0600_TAU_TRIGGER_MASTER_INT_TI03 (0x0600U) /* interrupt signal of the master is used as start trigger, + a valid edge of the TI03 pin is used as the end trigger */ +/* Selection of TImn pin input valid edge (CISmn1 - CISmn0) */ +#define _0000_TAU_TIMN_EDGE_FALLING (0x0000U) /* falling edge */ +#define _0040_TAU_TIMN_EDGE_RISING (0x0040U) /* rising edge */ +#define _0080_TAU_TIMN_EDGE_BOTH_LOW (0x0080U) /* both edges (when low-level width is measured) */ +#define _00C0_TAU_TIMN_EDGE_BOTH_HIGH (0x00C0U) /* both edges (when high-level width is measured) */ +/* Operation mode of channel n (MDmn3 - MDmn0) */ +#define _0000_TAU_MODE_INTERVAL_TIMER (0x0000U) /* interval timer mode */ +#define _0004_TAU_MODE_CAPTURE (0x0004U) /* capture mode */ +#define _0006_TAU_MODE_EVENT_COUNT (0x0006U) /* event counter mode */ +#define _0008_TAU_MODE_ONE_COUNT (0x0008U) /* one count mode */ +#define _000C_TAU_MODE_HIGHLOW_MEASURE (0x000CU) /* high-/low-level width measurement mode */ +#define _0001_TAU_MODE_PWM_MASTER (0x0001U) /* PWM Function (Master Channel) mode */ +#define _0009_TAU_MODE_PWM_SLAVE (0x0009U) /* PWM Function (Slave Channel) mode */ +#define _0008_TAU_MODE_ONESHOT (0x0008U) /* one-shot pulse output mode */ +/* Setting of starting counting and interrupt (MDmn0) */ +#define _0000_TAU_START_INT_UNUSED (0x0000U) /* interrupt is not generated when counting is started */ +#define _0001_TAU_START_INT_USED (0x0001U) /* interrupt is generated when counting is started */ + +/* + Timer Status Register mn (TSRmn) +*/ +/* Counter overflow status of channel n (OVF) */ +#define _0000_TAU_OVERFLOW_NOT_OCCURS (0x0000U) /* overflow does not occur */ +#define _0001_TAU_OVERFLOW_OCCURS (0x0001U) /* overflow occurs */ + +/* + Timer Channel Enable Status Register m (TEm) +*/ +/* Indication of operation enable/stop status of channel 3 higher 8 bits (TEHm3) */ +#define _0000_TAU_CH3_H8_OPERATION_STOP (0x0000U) /* operation is stopped */ +#define _0800_TAU_CH3_H8_OPERATION_ENABLE (0x0800U) /* operation is enabled */ +/* Indication of operation enable/stop status of channel 1 higher 8 bits (TEHm1) */ +#define _0000_TAU_CH1_H8_OPERATION_STOP (0x0000U) /* operation is stopped */ +#define _0200_TAU_CH1_H8_OPERATION_ENABLE (0x0200U) /* operation is enabled */ +/* Indication of operation enable/stop status of channel 7 (TEm7) */ +#define _0000_TAU_CH7_OPERATION_STOP (0x0000U) /* operation is stopped */ +#define _0080_TAU_CH7_OPERATION_ENABLE (0x0080U) /* operation is enabled */ +/* Indication of operation enable/stop status of channel 6 (TEm6) */ +#define _0000_TAU_CH6_OPERATION_STOP (0x0000U) /* operation is stopped */ +#define _0040_TAU_CH6_OPERATION_ENABLE (0x0040U) /* operation is enabled */ +/* Indication of operation enable/stop status of channel 5 (TEm5) */ +#define _0000_TAU_CH5_OPERATION_STOP (0x0000U) /* operation is stopped */ +#define _0020_TAU_CH5_OPERATION_ENABLE (0x0020U) /* operation is enabled */ +/* Indication of operation enable/stop status of channel 4 (TEm4) */ +#define _0000_TAU_CH4_OPERATION_STOP (0x0000U) /* operation is stopped */ +#define _0010_TAU_CH4_OPERATION_ENABLE (0x0010U) /* operation is enabled */ +/* Indication of operation enable/stop status of channel 3 (TEm3) */ +#define _0000_TAU_CH3_OPERATION_STOP (0x0000U) /* operation is stopped */ +#define _0008_TAU_CH3_OPERATION_ENABLE (0x0008U) /* operation is enabled */ +/* Indication of operation enable/stop status of channel 2 (TEm2) */ +#define _0000_TAU_CH2_OPERATION_STOP (0x0000U) /* operation is stopped */ +#define _0004_TAU_CH2_OPERATION_ENABLE (0x0004U) /* operation is enabled */ +/* Indication of operation enable/stop status of channel 1 (TEm1) */ +#define _0000_TAU_CH1_OPERATION_STOP (0x0000U) /* operation is stopped */ +#define _0002_TAU_CH1_OPERATION_ENABLE (0x0002U) /* operation is enabled */ +/* Indication of operation enable/stop status of channel 0 (TEm0) */ +#define _0000_TAU_CH0_OPERATION_STOP (0x0000U) /* operation is stopped */ +#define _0001_TAU_CH0_OPERATION_ENABLE (0x0001U) /* operation is enabled */ + +/* + Timer Channel Start Register m (TSm) +*/ +/* Operation enable (start) trigger of channel 3 higher 8 bits (TSHm3) */ +#define _0000_TAU_CH3_H8_START_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0800_TAU_CH3_H8_START_TRG_ON (0x0800U) /* operation is enabled (start trigger is generated) */ +/* Operation enable (start) trigger of channel 1 higher 8 bits (TSHm1) */ +#define _0000_TAU_CH1_H8_START_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0200_TAU_CH1_H8_START_TRG_ON (0x0200U) /* operation is enabled (start trigger is generated) */ +/* Operation enable (start) trigger of channel 7 (TSm7) */ +#define _0000_TAU_CH7_START_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0080_TAU_CH7_START_TRG_ON (0x0080U) /* operation is enabled (start trigger is generated) */ +/* Operation enable (start) trigger of channel 6 (TSm6) */ +#define _0000_TAU_CH6_START_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0040_TAU_CH6_START_TRG_ON (0x0040U) /* operation is enabled (start trigger is generated) */ +/* Operation enable (start) trigger of channel 5 (TSm5) */ +#define _0000_TAU_CH5_START_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0020_TAU_CH5_START_TRG_ON (0x0020U) /* operation is enabled (start trigger is generated) */ +/* Operation enable (start) trigger of channel 4 (TSm4) */ +#define _0000_TAU_CH4_START_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0010_TAU_CH4_START_TRG_ON (0x0010U) /* operation is enabled (start trigger is generated) */ +/* Operation enable (start) trigger of channel 3 (TSm3) */ +#define _0000_TAU_CH3_START_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0008_TAU_CH3_START_TRG_ON (0x0008U) /* operation is enabled (start trigger is generated) */ +/* Operation enable (start) trigger of channel 2 (TSm2) */ +#define _0000_TAU_CH2_START_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0004_TAU_CH2_START_TRG_ON (0x0004U) /* operation is enabled (start trigger is generated) */ +/* Operation enable (start) trigger of channel 1 (TSm1) */ +#define _0000_TAU_CH1_START_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0002_TAU_CH1_START_TRG_ON (0x0002U) /* operation is enabled (start trigger is generated) */ +/* Operation enable (start) trigger of channel 0 (TSm0) */ +#define _0000_TAU_CH0_START_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0001_TAU_CH0_START_TRG_ON (0x0001U) /* operation is enabled (start trigger is generated) */ + +/* + Timer Channel Stop Register m (TTm) +*/ +/* Operation stop trigger of channel 3 higher 8 bits (TTHm3) */ +#define _0000_TAU_CH3_H8_STOP_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0800_TAU_CH3_H8_STOP_TRG_ON (0x0800U) /* operation is stopped (stop trigger is generated) */ +/* Operation stop trigger of channel 1 higher 8 bits (TTHm1) */ +#define _0000_TAU_CH1_H8_STOP_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0200_TAU_CH1_H8_STOP_TRG_ON (0x0200U) /* operation is stopped (stop trigger is generated) */ +/* Operation stop trigger of channel 7 (TTm7) */ +#define _0000_TAU_CH7_STOP_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0080_TAU_CH7_STOP_TRG_ON (0x0080U) /* operation is stopped (stop trigger is generated) */ +/* Operation stop trigger of channel 6 (TTm6) */ +#define _0000_TAU_CH6_STOP_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0040_TAU_CH6_STOP_TRG_ON (0x0040U) /* operation is stopped (stop trigger is generated) */ +/* Operation stop trigger of channel 5 (TTm5) */ +#define _0000_TAU_CH5_STOP_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0020_TAU_CH5_STOP_TRG_ON (0x0020U) /* operation is stopped (stop trigger is generated) */ +/* Operation stop trigger of channel 4 (TTm4) */ +#define _0000_TAU_CH4_STOP_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0010_TAU_CH4_STOP_TRG_ON (0x0010U) /* operation is stopped (stop trigger is generated) */ +/* Operation stop trigger of channel 3 (TTm3) */ +#define _0000_TAU_CH3_STOP_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0008_TAU_CH3_STOP_TRG_ON (0x0008U) /* operation is stopped (stop trigger is generated) */ +/* Operation stop trigger of channel 2 (TTm2) */ +#define _0000_TAU_CH2_STOP_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0004_TAU_CH2_STOP_TRG_ON (0x0004U) /* operation is stopped (stop trigger is generated) */ +/* Operation stop trigger of channel 1 (TTm1) */ +#define _0000_TAU_CH1_STOP_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0002_TAU_CH1_STOP_TRG_ON (0x0002U) /* operation is stopped (stop trigger is generated) */ +/* Operation stop trigger of channel 0 (TTm0) */ +#define _0000_TAU_CH0_STOP_TRG_OFF (0x0000U) /* no trigger operation */ +#define _0001_TAU_CH0_STOP_TRG_ON (0x0001U) /* operation is stopped (stop trigger is generated) */ + +/* + Timer Input Select Register m (TIS0) +*/ +/* Selection of timer input used with channel 5 of unit 0 (TIS02 - TIS00) */ +#define _00_TAU_CH5_INPUT_TI05 (0x00U) /* input signal of timer input pin (TI05) */ +#define _01_TAU_CH5_INPUT_ELC (0x01U) /* input signal of ELC */ +#define _03_TAU_CH5_INPUT_FIMP (0x03U) /* internal Medium speed oscillation colock (fIMP) */ +#define _04_TAU_CH5_INPUT_FIL (0x04U) /* internal low speed oscillation colock (fIL) */ +#define _05_TAU_CH5_INPUT_FSUB (0x05U) /* sub colock (fSUB) */ +#define _F8_TAU_CH5_INPUT_CLEAR (0xF8U) /* bits of TIS02 - TIS00 clear */ + +/* + Timer Input Select Register m (TIS1) +*/ +/* Selection of timer input used with channel 1 of unit 0 (TIS11) */ +#define _01_TAU_CH1_INPUT_TI01 (0x01U) /* input signal of timer input pin (TI01) */ +#define _02_TAU_CH1_INPUT_ELC (0x02U) /* input signal of ELC */ +/* Selection of timer input used with channel 0 of unit 0 (TIS10) */ +#define _02_TAU_CH0_INPUT_TI00 (0x02U) /* input signal of timer input pin (TI00) */ +#define _01_TAU_CH0_INPUT_ELC (0x01U) /* input signal of ELC */ + +/* + Timer Output Enable Register m (TOEm) +*/ +/* Timer output enable/disable of channel 7 (TOEm7) */ +#define _0080_TAU_CH7_OUTPUT_ENABLE (0x0080U) /* the TOm7 operation enabled by count operation */ +#define _0000_TAU_CH7_OUTPUT_DISABLE (0x0000U) /* the TOm7 operation stopped by count operation */ +/* Timer output enable/disable of channel 6 (TOEm6) */ +#define _0040_TAU_CH6_OUTPUT_ENABLE (0x0040U) /* the TOm6 operation enabled by count operation */ +#define _0000_TAU_CH6_OUTPUT_DISABLE (0x0000U) /* the TOm6 operation stopped by count operation */ +/* Timer output enable/disable of channel 5 (TOEm5) */ +#define _0020_TAU_CH5_OUTPUT_ENABLE (0x0020U) /* the TOm5 operation enabled by count operation */ +#define _0000_TAU_CH5_OUTPUT_DISABLE (0x0000U) /* the TOm5 operation stopped by count operation */ +/* Timer output enable/disable of channel 4 (TOEm4) */ +#define _0010_TAU_CH4_OUTPUT_ENABLE (0x0010U) /* the TOm4 operation enabled by count operation */ +#define _0000_TAU_CH4_OUTPUT_DISABLE (0x0000U) /* the TOm4 operation stopped by count operation */ +/* Timer output enable/disable of channel 3 (TOEm3) */ +#define _0008_TAU_CH3_OUTPUT_ENABLE (0x0008U) /* the TOm3 operation enabled by count operation */ +#define _0000_TAU_CH3_OUTPUT_DISABLE (0x0000U) /* the TOm3 operation stopped by count operation */ +/* Timer output enable/disable of channel 2 (TOEm2) */ +#define _0004_TAU_CH2_OUTPUT_ENABLE (0x0004U) /* the TOm2 operation enabled by count operation */ +#define _0000_TAU_CH2_OUTPUT_DISABLE (0x0000U) /* the TOm2 operation stopped by count operation */ +/* Timer output enable/disable of channel 1 (TOEm1) */ +#define _0002_TAU_CH1_OUTPUT_ENABLE (0x0002U) /* the TOm1 operation enabled by count operation */ +#define _0000_TAU_CH1_OUTPUT_DISABLE (0x0000U) /* the TOm1 operation stopped by count operation */ +/* Timer output enable/disable of channel 0 (TOEm0) */ +#define _0001_TAU_CH0_OUTPUT_ENABLE (0x0001U) /* the TOm0 operation enabled by count operation */ +#define _0000_TAU_CH0_OUTPUT_DISABLE (0x0000U) /* the TOm0 operation stopped by count operation */ + +/* + Timer Output Register m (TOm) +*/ +/* Timer output of channel 7 (TOm7) */ +#define _0000_TAU_CH7_OUTPUT_VALUE_0 (0x0000U) /* timer output value is "0" */ +#define _0080_TAU_CH7_OUTPUT_VALUE_1 (0x0080U) /* timer output value is "1" */ +/* Timer output of channel 6 (TOm6) */ +#define _0000_TAU_CH6_OUTPUT_VALUE_0 (0x0000U) /* timer output value is "0" */ +#define _0040_TAU_CH6_OUTPUT_VALUE_1 (0x0040U) /* timer output value is "1" */ +/* Timer output of channel 5 (TOm5) */ +#define _0000_TAU_CH5_OUTPUT_VALUE_0 (0x0000U) /* timer output value is "0" */ +#define _0020_TAU_CH5_OUTPUT_VALUE_1 (0x0020U) /* timer output value is "1" */ +/* Timer output of channel 4 (TOm4) */ +#define _0000_TAU_CH4_OUTPUT_VALUE_0 (0x0000U) /* timer output value is "0" */ +#define _0010_TAU_CH4_OUTPUT_VALUE_1 (0x0010U) /* timer output value is "1" */ +/* Timer output of channel 3 (TOm3) */ +#define _0000_TAU_CH3_OUTPUT_VALUE_0 (0x0000U) /* timer output value is "0" */ +#define _0008_TAU_CH3_OUTPUT_VALUE_1 (0x0008U) /* timer output value is "1" */ +/* Timer output of channel 2 (TOm2) */ +#define _0000_TAU_CH2_OUTPUT_VALUE_0 (0x0000U) /* timer output value is "0" */ +#define _0004_TAU_CH2_OUTPUT_VALUE_1 (0x0004U) /* timer output value is "1" */ +/* Timer output of channel 1 (TOm1) */ +#define _0000_TAU_CH1_OUTPUT_VALUE_0 (0x0000U) /* timer output value is "0" */ +#define _0002_TAU_CH1_OUTPUT_VALUE_1 (0x0002U) /* timer output value is "1" */ +/* Timer output of channel 0 (TOm0) */ +#define _0000_TAU_CH0_OUTPUT_VALUE_0 (0x0000U) /* timer output value is "0" */ +#define _0001_TAU_CH0_OUTPUT_VALUE_1 (0x0001U) /* timer output value is "1" */ + +/* + Timer Output Level Register 0 (TOLm) +*/ +/* Control of timer output level of channel 7 (TOLm7) */ +#define _0000_TAU_CH7_OUTPUT_LEVEL_H (0x0000U) /* positive logic output (active-high) */ +#define _0080_TAU_CH7_OUTPUT_LEVEL_L (0x0080U) /* inverted output (active-low) */ +/* Control of timer output level of channel 6 (TOLm6) */ +#define _0000_TAU_CH6_OUTPUT_LEVEL_H (0x0000U) /* positive logic output (active-high) */ +#define _0040_TAU_CH6_OUTPUT_LEVEL_L (0x0040U) /* inverted output (active-low) */ +/* Control of timer output level of channel 5 (TOLm5) */ +#define _0000_TAU_CH5_OUTPUT_LEVEL_H (0x0000U) /* positive logic output (active-high) */ +#define _0020_TAU_CH5_OUTPUT_LEVEL_L (0x0020U) /* inverted output (active-low) */ +/* Control of timer output level of channel 4 (TOLm4) */ +#define _0000_TAU_CH4_OUTPUT_LEVEL_H (0x0000U) /* positive logic output (active-high) */ +#define _0010_TAU_CH4_OUTPUT_LEVEL_L (0x0010U) /* inverted output (active-low) */ +/* Control of timer output level of channel 3 (TOLm3) */ +#define _0000_TAU_CH3_OUTPUT_LEVEL_H (0x0000U) /* positive logic output (active-high) */ +#define _0008_TAU_CH3_OUTPUT_LEVEL_L (0x0008U) /* inverted output (active-low) */ +/* Control of timer output level of channel 2 (TOLm2) */ +#define _0000_TAU_CH2_OUTPUT_LEVEL_H (0x0000U) /* positive logic output (active-high) */ +#define _0004_TAU_CH2_OUTPUT_LEVEL_L (0x0004U) /* inverted output (active-low) */ +/* Control of timer output level of channel 1 (TOLm1) */ +#define _0000_TAU_CH1_OUTPUT_LEVEL_H (0x0000U) /* positive logic output (active-high) */ +#define _0002_TAU_CH1_OUTPUT_LEVEL_L (0x0002U) /* inverted output (active-low) */ + +/* + Timer Output Mode Register m (TOMm) +*/ +/* Control of timer output mode of channel 7 (TOMm7) */ +#define _0000_TAU_CH7_MASTER_OUTPUT (0x0000U) /* master channel output mode */ +#define _0080_TAU_CH7_SLAVE_OUTPUT (0x0080U) /* slave channel output mode */ +/* Control of timer output mode of channel 6 (TOMm6) */ +#define _0000_TAU_CH6_MASTER_OUTPUT (0x0000U) /* master channel output mode */ +#define _0040_TAU_CH6_SLAVE_OUTPUT (0x0040U) /* slave channel output mode */ +/* Control of timer output mode of channel 5 (TOMm5) */ +#define _0000_TAU_CH5_MASTER_OUTPUT (0x0000U) /* master channel output mode */ +#define _0020_TAU_CH5_SLAVE_OUTPUT (0x0020U) /* slave channel output mode */ +/* Control of timer output mode of channel 4 (TOMm4) */ +#define _0000_TAU_CH4_MASTER_OUTPUT (0x0000U) /* master channel output mode */ +#define _0010_TAU_CH4_SLAVE_OUTPUT (0x0010U) /* slave channel output mode */ +/* Control of timer output mode of channel 3 (TOMm3) */ +#define _0000_TAU_CH3_MASTER_OUTPUT (0x0000U) /* master channel output mode */ +#define _0008_TAU_CH3_SLAVE_OUTPUT (0x0008U) /* slave channel output mode */ +/* Control of timer output mode of channel 2 (TOMm2) */ +#define _0000_TAU_CH2_MASTER_OUTPUT (0x0000U) /* master channel output mode */ +#define _0004_TAU_CH2_SLAVE_OUTPUT (0x0004U) /* slave channel output mode */ +/* Control of timer output mode of channel 1 (TOMm1) */ +#define _0000_TAU_CH1_MASTER_OUTPUT (0x0000U) /* master channel output mode */ +#define _0002_TAU_CH1_SLAVE_OUTPUT (0x0002U) /* slave channel output mode */ + +/* + Input Switch Control Register (ISC) +*/ +/* Switching channel 7 input of timer array unit (ISC1) */ +#define _00_TAU_CH7_INPUT_TI07 (0x00U) /* input signal of TI07 pin is used as timer input */ +#define _02_TAU_CH7_INPUT_RXD2 (0x02U) /* input signal of RxD2 pin is used as timer input */ +#define _FD_TAU_CH7_INPUT_CLEAR (0xFDU) /* channel 7 input clear */ +/* External interrupt (INTP0) input switching (ISC0) */ +#define _00_EXTERNAL_INPUT_INTP0 (0x00U) /* input signal of INTP0 is used as external interrupt input */ +#define _01_EXTERNAL_INPUT_RXD2 (0x01U) /* input signal of RxD2 pin is used as external interrupt input */ + +/* + Noise Filter Enable Register 1 (NFEN1) +*/ +/* Enable/disable using noise filter of TI07 pin input signal (TNFEN07) */ +#define _00_TAU_CH7_NOISE_OFF (0x00U) /* noise filter OFF */ +#define _80_TAU_CH7_NOISE_ON (0x80U) /* noise filter ON */ +/* Enable/disable using noise filter of TI06 pin input signal (TNFEN06) */ +#define _00_TAU_CH6_NOISE_OFF (0x00U) /* noise filter OFF */ +#define _40_TAU_CH6_NOISE_ON (0x40U) /* noise filter ON */ +/* Enable/disable using noise filter of TI05 pin input signal (TNFEN05) */ +#define _00_TAU_CH5_NOISE_OFF (0x00U) /* noise filter OFF */ +#define _20_TAU_CH5_NOISE_ON (0x20U) /* noise filter ON */ +/* Enable/disable using noise filter of TI04 pin input signal (TNFEN04) */ +#define _00_TAU_CH4_NOISE_OFF (0x00U) /* noise filter OFF */ +#define _10_TAU_CH4_NOISE_ON (0x10U) /* noise filter ON */ +/* Enable/disable using noise filter of TI03 pin input signal (TNFEN03) */ +#define _00_TAU_CH3_NOISE_OFF (0x00U) /* noise filter OFF */ +#define _08_TAU_CH3_NOISE_ON (0x08U) /* noise filter ON */ +/* Enable/disable using noise filter of TI02 pin input signal (TNFEN02) */ +#define _00_TAU_CH2_NOISE_OFF (0x00U) /* noise filter OFF */ +#define _04_TAU_CH2_NOISE_ON (0x04U) /* noise filter ON */ +/* Enable/disable using noise filter of TI01 pin input signal (TNFEN01) */ +#define _00_TAU_CH1_NOISE_OFF (0x00U) /* noise filter OFF */ +#define _02_TAU_CH1_NOISE_ON (0x02U) /* noise filter ON */ +/* Enable/disable using noise filter of TI00 pin input signal (TNFEN00) */ +#define _00_TAU_CH0_NOISE_OFF (0x00U) /* noise filter OFF */ +#define _01_TAU_CH0_NOISE_ON (0x01U) /* noise filter ON */ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/general/r_cg_tau_common.c b/cores/rl78g22/smc_gen/general/r_cg_tau_common.c index 1944480..559f07b 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_tau_common.c +++ b/cores/rl78g22/smc_gen/general/r_cg_tau_common.c @@ -1,115 +1,106 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_tau_common.c -* Version : 1.0.0 -* Device(s) : R7F102GGExFB -* Description : None -* Creation Date: -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Pragma directive -***********************************************************************************************************************/ -/* Start user code for pragma. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -//#include "Config_TAU0_0.h" -//#include "Config_TAU0_2.h" -//#include "Config_TAU0_6.h" -//#include "Config_TAU0_4.h" -#include "r_cg_tau_common.h" -/* Start user code for include. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Global variables and functions -***********************************************************************************************************************/ -/* Start user code for global. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -* Function Name: R_TAU0_Create -* Description : This function enables TAU0 input clock supply and initializes TAU0 module. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_TAU0_Create(void) -{ - TAU0EN = 1U; /* start TAU0 clock */ - /* Set TAU0 settings */ -// R_Config_TAU0_0_Create(); -// R_Config_TAU0_2_Create(); -// R_Config_TAU0_6_Create(); -// R_Config_TAU0_4_Create(); -} - -/*********************************************************************************************************************** -* Function Name: R_TAU0_Set_PowerOn -* Description : This function starts the clock supply for TAU0. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_TAU0_Set_PowerOn(void) -{ - TAU0EN = 1U; /* start TAU0 clock */ -} - -/*********************************************************************************************************************** -* Function Name: R_TAU0_Set_PowerOff -* Description : This function stops the clock supply for TAU0. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_TAU0_Set_PowerOff(void) -{ - TAU0EN = 0U; /* stop TAU0 clock */ -} - -/*********************************************************************************************************************** -* Function Name: R_TAU0_Set_Reset -* Description : This function sets TAU0 module in reset state. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_TAU0_Set_Reset(void) -{ - TAU0RES = 1U; /* reset TAU0 */ -} - -/*********************************************************************************************************************** -* Function Name: R_TAU0_Release_Reset -* Description : This function releases TAU0 module from reset state. -* Arguments : None -* Return Value : None -***********************************************************************************************************************/ -void R_TAU0_Release_Reset(void) -{ - TAU0RES = 0U; /* release TAU0 */ -} - -/* Start user code for adding. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_tau_common.c +* Version : 1.0.0 +* Device(s) : R7F102GGExFB +* Description : None +* Creation Date: +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Pragma directive +***********************************************************************************************************************/ +/* Start user code for pragma. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "r_cg_tau_common.h" +/* Start user code for include. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Global variables and functions +***********************************************************************************************************************/ +/* Start user code for global. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +* Function Name: R_TAU0_Create +* Description : This function enables TAU0 input clock supply and initializes TAU0 module. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_TAU0_Create(void) +{ + TAU0EN = 1U; /* start TAU0 clock */ +} + +/*********************************************************************************************************************** +* Function Name: R_TAU0_Set_PowerOn +* Description : This function starts the clock supply for TAU0. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_TAU0_Set_PowerOn(void) +{ + TAU0EN = 1U; /* start TAU0 clock */ +} + +/*********************************************************************************************************************** +* Function Name: R_TAU0_Set_PowerOff +* Description : This function stops the clock supply for TAU0. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_TAU0_Set_PowerOff(void) +{ + TAU0EN = 0U; /* stop TAU0 clock */ +} + +/*********************************************************************************************************************** +* Function Name: R_TAU0_Set_Reset +* Description : This function sets TAU0 module in reset state. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_TAU0_Set_Reset(void) +{ + TAU0RES = 1U; /* reset TAU0 */ +} + +/*********************************************************************************************************************** +* Function Name: R_TAU0_Release_Reset +* Description : This function releases TAU0 module from reset state. +* Arguments : None +* Return Value : None +***********************************************************************************************************************/ +void R_TAU0_Release_Reset(void) +{ + TAU0RES = 0U; /* release TAU0 */ +} + +/* Start user code for adding. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + diff --git a/cores/rl78g22/smc_gen/general/r_cg_tau_common.h b/cores/rl78g22/smc_gen/general/r_cg_tau_common.h index 4fb43d6..626ddb1 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_tau_common.h +++ b/cores/rl78g22/smc_gen/general/r_cg_tau_common.h @@ -1,54 +1,54 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_tau_common.h -* Version : 1.0.0 -* Device(s) : R7F102GGExFB -* Description : Common header file for TAU peripheral. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef TAU_COMMON_H -#define TAU_COMMON_H - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -void R_TAU0_Create (void); -void R_TAU0_Set_PowerOn (void); -void R_TAU0_Set_PowerOff (void); -void R_TAU0_Set_Reset (void); -void R_TAU0_Release_Reset (void); -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif - +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_tau_common.h +* Version : 1.0.0 +* Device(s) : R7F102GGExFB +* Description : Common header file for TAU peripheral. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef TAU_COMMON_H +#define TAU_COMMON_H + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +void R_TAU0_Create (void); +void R_TAU0_Set_PowerOn (void); +void R_TAU0_Set_PowerOff (void); +void R_TAU0_Set_Reset (void); +void R_TAU0_Release_Reset (void); +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif + diff --git a/cores/rl78g22/smc_gen/general/r_cg_userdefine.h b/cores/rl78g22/smc_gen/general/r_cg_userdefine.h index 0a3aab9..62326eb 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_userdefine.h +++ b/cores/rl78g22/smc_gen/general/r_cg_userdefine.h @@ -1,61 +1,61 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_userdefine.h -* Version : 1.0.0 -* Device(s) : R7F102GGExFB -* Description : User header file for code generation. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef USER_DEF_H -#define USER_DEF_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -/* Start user code for include. Do not edit comment generated here */ -#include "Arduino.h" -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ -/* Start user code for register. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -/* Start user code for macro define. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ -/* Start user code for type define. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_userdefine.h +* Version : 1.0.0 +* Device(s) : R7F102GGExFB +* Description : User header file for code generation. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef USER_DEF_H +#define USER_DEF_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +/* Start user code for include. Do not edit comment generated here */ +#include "Arduino.h" +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ +/* Start user code for register. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ +/* Start user code for macro define. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ +/* Start user code for type define. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif diff --git a/cores/rl78g22/smc_gen/general/r_cg_vect_table.c b/cores/rl78g22/smc_gen/general/r_cg_vect_table.c index be234df..31068aa 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_vect_table.c +++ b/cores/rl78g22/smc_gen/general/r_cg_vect_table.c @@ -1,465 +1,431 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_vect_table.c -* Version : 1.0.0 -* Device(s) : R7F102GGExFB -* Description : None -* Creation Date: 2022/11/04 -***********************************************************************************************************************/ - -#include "r_cg_macrodriver.h" -#include "r_cg_userdefine.h" - -extern void PowerON_Reset (void); - -const unsigned char Option_Bytes[] __attribute__ ((section (".option_bytes"))) = { - 0xEFU, 0xFFU, 0xE8U, 0x04U -}; - -const unsigned char Security_Id[] __attribute__ ((section (".security_id"))) = { - 0x00U,0x00U,0x00U,0x00U,0x00U,0x00U,0x00U,0x00U,0x00U,0x00U -}; - -#define VEC __attribute__ ((section (".vec"))) -const void __near *HardwareVectors[] VEC = { - // Address 0x0 - PowerON_Reset, - // Secure for Debugging - (void*)0xFFFF -}; - -#define VECT_SECT __attribute__ ((section (".vects"))) -const void __near *Vectors[] VECT_SECT = { -/* - * INT_WDTI (0x4) - */ -INT_WDTI, - -/* - * INT_LVI (0x6) - */ - INT_LVI, - -/* - * INT_P0 (0x8) - */ -// INT_P0, - r_Config_INTC_intp0_interrupt, - /* 1112 Ueeda add */ -/* - * INT_P1 (0xA) - */ -// INT_P1, - r_Config_INTC_intp1_interrupt, - -/* - * INT_P2 (0xC) - */ -// INT_P2, - r_Config_INTC_intp2_interrupt, - -/* - * INT_P3 (0xE) - */ -// INT_P3, - r_Config_INTC_intp3_interrupt, - -/* - * INT_P4 (0x10) - */ -// INT_P4, - r_Config_INTC_intp4_interrupt, - /* 1112 Ueeda add */ - -/* - * INT_P5 (0x12) - */ -// INT_P5, - r_Config_INTC_intp5_interrupt, - -/* - * INT_CSI20/INT_IIC20/INT_ST2 (0x14) - */ -// INT_ST2, -#if defined(CSI_CHANNEL4) -// 2022/11/08 added by KAD (dummy data) - INT_ST2, -#else - #if (UART2_CHANNEL==2) - r_Config_UART2_interrupt_send, - #else - INT_ST2, - #endif -#endif - -/* - * INT_CSI21/INT_IIC21/INT_SR2 (0x16) - */ -// INT_SR2, -#if defined(CSI_CHANNEL5) -// 2022/11/08 added by KAD (dummy data) - INT_SR2, -#else - #if (UART2_CHANNEL==2) - r_Config_UART2_interrupt_receive, - #else - INT_SR2, - #endif -#endif -/* - * INT_SRE2/INT_TM11H (0x18) - */ -#if (UART2_CHANNEL==2) - r_Config_UART2_interrupt_error, -#else - INT_SRE2, -#endif - -/* - * Padding (0x1A) - */ - (void*)0xFFFF, - -/* - * INT_SMSE (0x1C) - */ - INT_SMSE, - -/* - * INT_CSI00/INT_IIC00/INT_ST0 (0x1E) - */ -// INT_ST0, -#if defined(UART_CHANNEL) & (UART_CHANNEL==0) - r_Config_UART0_interrupt_send, -#else - INT_ST0, -#endif - -/* - * INT_TM00 (0x20) - */ -// r_Config_TAU0_0_channel0_interrupt, - r_Config_TAU0_0_Measure_Signal_interrupt, - -/* - * INT_SRE0/INT_TM01H (0x22) - */ -// INT_TM01H, -#if defined(UART_CHANNEL) & (UART_CHANNEL==0) - r_Config_UART0_interrupt_error, -#else - INT_TM01H, -#endif - -/* - * INT_ST1 (0x24) - */ -// INT_ST1, -#if ( UART1_CHANNEL == 1 ) - r_Config_UART1_interrupt_send, -#else - INT_ST1, -#endif - -/* - * INT_CSI11/INT_IIC11/INT_SR1 (0x26) - */ -// r_Config_CSI11_interrupt, -#if defined(CSI_CHANNEL3) | (defined(UART1_CHANNEL) & UART1_CHANNEL == 1 ) - r_Config_CSI11_UART1_interrupt_switching, - #else - INT_SR1, -#endif - -/* - * INT_SRE1/INT_TM03H (0x28) - */ -// INT_TM03H, -#if ( UART1_CHANNEL == 1 ) - r_Config_UART1_interrupt_error, -#else - INT_TM03H, -#endif - -/* - * INT_IICA0 (0x2A) - */ - r_Config_IICA0_interrupt, - -/* - * INT_CSI01/INT_IIC01/INT_SR0 (0x2C) - */ -// INT_SR0, -#if defined(CSI_CHANNEL1) - INT_CSI01, -#else - #if defined(UART_CHANNEL) & (UART_CHANNEL==0) - r_Config_UART0_interrupt_receive, - #else - INT_SR0, - #endif -#endif - -/* - * INT_TM01 (0x2E) - */ -// r_Config_TAU0_0_channel1_interrupt, - r_Config_TAU0_1_Measure_Signal_interrupt, -/* 1118 nhu add */ - -/* - * INT_TM02 (0x30) - */ -// r_Config_TAU0_2_channel2_interrupt, -/* 1118 nhu add */ - r_Config_TAU0_2_Measure_Signal_interrupt, -/* 1118 nhu add */ - -/* - * INT_TM03 (0x32) - */ -// r_Config_TAU0_2_channel3_interrupt, -/* 1118 nhu add */ - r_Config_TAU0_3_Measure_Signal_interrupt, -/* 1118 nhu add */ - -/* - * INT_AD (0x34) - */ - r_Config_ADC_interrupt, - -/* - * INT_RTC (0x36) - */ -// INT_RTC, - r_Config_RTC_interrupt, - -/* - * INT_ITL (0x38) - */ - r_itl_interrupt, - -/* - * INT_KR (0x3A) - */ - INT_KR, - -/* - * Padding (0x3C) - */ - (void*)0xFFFF, - - -/* - * Padding (0x3E) - */ - (void*)0xFFFF, - - -/* - * Padding (0x40) - */ - (void*)0xFFFF, - - -/* - * INT_TM04 (0x42) - */ -// r_Config_TAU0_4_channel4_interrupt, -/* 1118 nhu add */ -// r_Config_TAU0_4_Measure_Signal_interrupt, - (void*)0xFFFF, -/* 1118 nhu add */ - -/* - * INT_TM05 (0x44) - */ - // r_Config_TAU0_4_channel5_interrupt, -/* 1118 nhu add */ -// r_Config_TAU0_5_Measure_Signal_interrupt, - (void*)0xFFFF, -/* 1118 nhu add */ - -/* - * INT_TM06 (0x46) - */ -// r_Config_TAU0_6_channel6_interrupt, -/* 1118 nhu add */ -// r_Config_TAU0_6_Measure_Signal_interrupt, - r_Config_TAU0_6_Micros_interrupt, -/* 1118 nhu add */ - -/* - * INT_TM07 (0x48) - */ -// r_Config_TAU0_6_channel7_interrupt, -/* 1118 nhu add */ - r_Config_TAU0_7_Measure_Signal_interrupt, -/* 1118 nhu add */ -// 20221006 KAD -// r_Config_TAU0_7_MSTimer2_interrupt, - - -/* - * INT_P6 (0x4A) - */ -// INT_P6, - r_Config_INTC_intp6_interrupt, - -/* - * Padding (0x4C) - */ - (void*)0xFFFF, - - -/* - * INT_P8 (0x4E) - */ - INT_P8, - -/* - * INT_P9 (0x50) - */ - INT_P9, - -/* - * INT_FL (0x52) - */ - INT_FL, - -/* - * Padding (0x54) - */ - (void*)0xFFFF, - - -/* - * Padding (0x56) - */ - (void*)0xFFFF, - - -/* - * INT_URE0 (0x58) - */ - INT_URE0, - -/* - * Padding (0x5A) - */ - (void*)0xFFFF, - - -/* - * Padding (0x5C) - */ - (void*)0xFFFF, - - -/* - * Padding (0x5E) - */ - (void*)0xFFFF, - - -/* - * INT_CTSUWR (0x60) - */ - INT_CTSUWR, - -/* - * Padding (0x62) - */ - (void*)0xFFFF, - - -/* - * INT_CTSURD (0x64) - */ - INT_CTSURD, - -/* - * INT_CTSUFN (0x66) - */ - INT_CTSUFN, - -/* - * Padding (0x68) - */ - (void*)0xFFFF, - - -/* - * INT_UT0 (0x6A) - */ - INT_UT0, - -/* - * INT_UR0 (0x6C) - */ - INT_UR0, - -/* - * Padding (0x6E) - */ - (void*)0xFFFF, - -/* - * Padding (0x70) - */ - (void*)0xFFFF, - - -/* - * Padding (0x72) - */ - (void*)0xFFFF, - - -/* - * Padding (0x74) - */ - (void*)0xFFFF, - - -/* - * Padding (0x76) - */ - (void*)0xFFFF, - - -/* - * Padding (0x78) - */ - (void*)0xFFFF, - - - - // Padding - (void*)0xFFFF, - // Padding - (void*)0xFFFF, - -/* - * INT_BRK_I (0x7E) - */ - INT_BRK_I, -}; +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_vect_table.c +* Version : 1.0.0 +* Device(s) : R7F102GGExFB +* Description : None +* Creation Date: 2022/11/04 +***********************************************************************************************************************/ + +#include "r_cg_macrodriver.h" +#include "r_cg_userdefine.h" + +extern void PowerON_Reset (void); + +const unsigned char Option_Bytes[] __attribute__ ((section (".option_bytes"))) = { + 0xEFU, 0xFFU, 0xE8U, 0x04U +}; + +const unsigned char Security_Id[] __attribute__ ((section (".security_id"))) = { + 0x00U,0x00U,0x00U,0x00U,0x00U,0x00U,0x00U,0x00U,0x00U,0x00U +}; + +#define VEC __attribute__ ((section (".vec"))) +const void __near *HardwareVectors[] VEC = { + // Address 0x0 + PowerON_Reset, + // Secure for Debugging + (void*)0xFFFF +}; + +#define VECT_SECT __attribute__ ((section (".vects"))) +const void __near *Vectors[] VECT_SECT = { +/* + * INT_WDTI (0x4) + */ +INT_WDTI, + +/* + * INT_LVI (0x6) + */ + INT_LVI, + +/* + * INT_P0 (0x8) + */ +// INT_P0, + r_Config_INTC_intp0_interrupt, +/* + * INT_P1 (0xA) + */ +// INT_P1, + r_Config_INTC_intp1_interrupt, + +/* + * INT_P2 (0xC) + */ +// INT_P2, + r_Config_INTC_intp2_interrupt, + +/* + * INT_P3 (0xE) + */ +// INT_P3, + r_Config_INTC_intp3_interrupt, + +/* + * INT_P4 (0x10) + */ +// INT_P4, + r_Config_INTC_intp4_interrupt, + +/* + * INT_P5 (0x12) + */ +// INT_P5, + r_Config_INTC_intp5_interrupt, + +/* + * INT_CSI20/INT_IIC20/INT_ST2 (0x14) + */ +// INT_ST2, +#if defined(CSI_CHANNEL4) | (UART2_CHANNEL==2) + r_Config_CSI20_UART2_interrupt_send, +#else + INT_ST2, +#endif + +/* + * INT_CSI21/INT_IIC21/INT_SR2 (0x16) + */ +// INT_SR2, +#if defined(CSI_CHANNEL5) + INT_SR2, +#else + #if (UART2_CHANNEL==2) + r_Config_UART2_interrupt_receive, + #else + INT_SR2, + #endif +#endif +/* + * INT_SRE2/INT_TM11H (0x18) + */ +#if (UART2_CHANNEL==2) + r_Config_UART2_interrupt_error, +#else + INT_SRE2, +#endif + +/* + * Padding (0x1A) + */ + (void*)0xFFFF, + +/* + * INT_SMSE (0x1C) + */ + INT_SMSE, + +/* + * INT_CSI00/INT_IIC00/INT_ST0 (0x1E) + */ +// INT_ST0, +#if defined(UART_CHANNEL) & (UART_CHANNEL==0) + r_Config_UART0_interrupt_send, +#else + INT_ST0, +#endif + +/* + * INT_TM00 (0x20) + */ + r_Config_TAU0_0_PWM_interrupt, + +/* + * INT_SRE0/INT_TM01H (0x22) + */ +// INT_TM01H, +#if defined(UART_CHANNEL) & (UART_CHANNEL==0) + r_Config_UART0_interrupt_error, +#else + INT_TM01H, +#endif + +/* + * INT_ST1 (0x24) + */ +// INT_ST1, +#if ( UART1_CHANNEL == 1 ) + r_Config_UART1_interrupt_send, +#else + INT_ST1, +#endif + +/* + * INT_CSI11/INT_IIC11/INT_SR1 (0x26) + */ +// r_Config_CSI11_interrupt, +#if defined(CSI_CHANNEL3) | (defined(UART1_CHANNEL) & UART1_CHANNEL == 1 ) + r_Config_CSI11_UART1_interrupt_switching, + #else + INT_SR1, +#endif + +/* + * INT_SRE1/INT_TM03H (0x28) + */ +// INT_TM03H, +#if ( UART1_CHANNEL == 1 ) + r_Config_UART1_interrupt_error, +#else + INT_TM03H, +#endif + +/* + * INT_IICA0 (0x2A) + */ + r_Config_IICA0_interrupt, + +/* + * INT_CSI01/INT_IIC01/INT_SR0 (0x2C) + */ +// INT_SR0, +#if defined(CSI_CHANNEL1) + INT_CSI01, +#else + #if defined(UART_CHANNEL) & (UART_CHANNEL==0) + r_Config_UART0_interrupt_receive, + #else + INT_SR0, + #endif +#endif + +/* + * INT_TM01 (0x2E) + */ + INT_TM01, + +/* + * INT_TM02 (0x30) + */ + INT_TM02, + +/* + * INT_TM03 (0x32) + */ + INT_TM03, + +/* + * INT_AD (0x34) + */ + r_Config_ADC_interrupt, + +/* + * INT_RTC (0x36) + */ +// INT_RTC, + r_Config_RTC_interrupt, + +/* + * INT_ITL (0x38) + */ + r_itl_interrupt, + +/* + * INT_KR (0x3A) + */ + INT_KR, + +/* + * Padding (0x3C) + */ + (void*)0xFFFF, + + +/* + * Padding (0x3E) + */ + (void*)0xFFFF, + + +/* + * Padding (0x40) + */ + (void*)0xFFFF, + + +/* + * INT_TM04 (0x42) + */ + INT_TM04, + + +/* + * INT_TM05 (0x44) + */ + INT_TM05, + +/* + * INT_TM06 (0x46) + */ + r_Config_TAU0_6_Micros_interrupt, + +/* + * INT_TM07 (0x48) + */ + INT_TM07, + +/* + * INT_P6 (0x4A) + */ +// INT_P6, + r_Config_INTC_intp6_interrupt, + +/* + * Padding (0x4C) + */ + (void*)0xFFFF, + + +/* + * INT_P8 (0x4E) + */ + INT_P8, + +/* + * INT_P9 (0x50) + */ + INT_P9, + +/* + * INT_FL (0x52) + */ + INT_FL, + +/* + * Padding (0x54) + */ + (void*)0xFFFF, + + +/* + * Padding (0x56) + */ + (void*)0xFFFF, + + +/* + * INT_URE0 (0x58) + */ + INT_URE0, + +/* + * Padding (0x5A) + */ + (void*)0xFFFF, + + +/* + * Padding (0x5C) + */ + (void*)0xFFFF, + + +/* + * Padding (0x5E) + */ + (void*)0xFFFF, + + +/* + * INT_CTSUWR (0x60) + */ + INT_CTSUWR, + +/* + * Padding (0x62) + */ + (void*)0xFFFF, + + +/* + * INT_CTSURD (0x64) + */ + INT_CTSURD, + +/* + * INT_CTSUFN (0x66) + */ + INT_CTSUFN, + +/* + * Padding (0x68) + */ + (void*)0xFFFF, + + +/* + * INT_UT0 (0x6A) + */ + INT_UT0, + +/* + * INT_UR0 (0x6C) + */ + INT_UR0, + +/* + * Padding (0x6E) + */ + (void*)0xFFFF, + +/* + * Padding (0x70) + */ + (void*)0xFFFF, + + +/* + * Padding (0x72) + */ + (void*)0xFFFF, + + +/* + * Padding (0x74) + */ + (void*)0xFFFF, + + +/* + * Padding (0x76) + */ + (void*)0xFFFF, + + +/* + * Padding (0x78) + */ + (void*)0xFFFF, + + + + // Padding + (void*)0xFFFF, + // Padding + (void*)0xFFFF, + +/* + * INT_BRK_I (0x7E) + */ + INT_BRK_I, +}; diff --git a/cores/rl78g22/smc_gen/general/r_cg_wdt.h b/cores/rl78g22/smc_gen/general/r_cg_wdt.h index c24deb1..5c4d00a 100644 --- a/cores/rl78g22/smc_gen/general/r_cg_wdt.h +++ b/cores/rl78g22/smc_gen/general/r_cg_wdt.h @@ -1,49 +1,49 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_cg_wdt.h -* Version : 1.0.1 -* Device(s) : R7F100GLGxFB -* Description : General header file for WDT peripheral. -* Creation Date: 2021-05-14 -***********************************************************************************************************************/ - -#ifndef WDT_H -#define WDT_H - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -/* Start user code for function. Do not edit comment generated here */ -/* End user code. Do not edit comment generated here */ -#endif - +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_cg_wdt.h +* Version : 1.0.1 +* Device(s) : R7F100GLGxFB +* Description : General header file for WDT peripheral. +* Creation Date: 2021-05-14 +***********************************************************************************************************************/ + +#ifndef WDT_H +#define WDT_H + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +/* Start user code for function. Do not edit comment generated here */ +/* End user code. Do not edit comment generated here */ +#endif + diff --git a/cores/rl78g22/smc_gen/general/r_smc_entry.h b/cores/rl78g22/smc_gen/general/r_smc_entry.h index 9f46537..9fd77ff 100644 --- a/cores/rl78g22/smc_gen/general/r_smc_entry.h +++ b/cores/rl78g22/smc_gen/general/r_smc_entry.h @@ -1,97 +1,79 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. -* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED -* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY -* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, -* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR -* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability -* of this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -* File Name : r_smc_entry.h -* Version : 1.0.0 -* Device(s) : R7F102GGExFB -* Description : SMC platform header file.. -* Creation Date: -***********************************************************************************************************************/ - -#ifndef SMC_ENTRY_H -#define SMC_ENTRY_H - -/*********************************************************************************************************************** -Includes -***********************************************************************************************************************/ -#include "r_cg_macrodriver.h" -#include "Config_ADC.h" -#include "Config_IICA0.h" -#include "Config_RTC.h" -#include "Config_ITL000.h" -#include "Config_ITL001.h" -#include "Config_ITL012.h" -#include "Config_UART0.h" -#include "Config_UART1.h" -#include "Config_UART2.h" -// #include "Config_CSI11.h" -#include "Config_CSI20.h" -#include "r_cg_sau_common.h" -#include "r_cg_tau_common.h" -#include "r_cg_itl_common.h" -#include "r_cg_iica_common.h" -#include "r_cg_ad_common.h" -#include "r_cg_rtc_common.h" -#include "r_cg_userdefine.h" - -/*********************************************************************************************************************** -Macro definitions (Register bit) -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Typedef definitions -***********************************************************************************************************************/ - -/*********************************************************************************************************************** -Global functions -***********************************************************************************************************************/ -/* Start user code for function. Do not edit comment generated here */ -/* 1006 Nhu add */ -#include "Config_TAU0_01_PWM.h" -#include "Config_TAU0_23_PWM.h" -#include "Config_TAU0_67_PWM.h" -/* 1006 Nhu add */ - -/* 1108 Ueeda add */ -#include "Config_INTC.h" -/* 1108 Ueeda add */ - -/* 1112 nhu add */ -#include "Config_TAU0_1_Square_Wave.h" -#include "Config_TAU0_2_Square_Wave.h" -#include "Config_TAU0_3_Square_Wave.h" -#include "Config_TAU0_7_Square_Wave.h" - -#include "Config_TAU0_0_Measure_Signal.h" -#include "Config_TAU0_1_Measure_Signal.h" -#include "Config_TAU0_2_Measure_Signal.h" -#include "Config_TAU0_3_Measure_Signal.h" -#include "Config_TAU0_7_Measure_Signal.h" - -#include "Config_TAU0_6_Micros.h" - -/* 1112 nhu add */ -/* End user code. Do not edit comment generated here */ -#endif - +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +* File Name : r_smc_entry.h +* Version : 1.0.0 +* Device(s) : R7F102GGExFB +* Description : SMC platform header file.. +* Creation Date: +***********************************************************************************************************************/ + +#ifndef SMC_ENTRY_H +#define SMC_ENTRY_H + +/*********************************************************************************************************************** +Includes +***********************************************************************************************************************/ +#include "r_cg_macrodriver.h" +#include "Config_ADC.h" +#include "Config_IICA0.h" +#include "Config_INTC.h" +#include "Config_RTC.h" +#include "Config_ITL000.h" +#include "Config_ITL001.h" +#include "Config_ITL012.h" +#include "Config_ITL013.h" +#include "Config_UART0.h" +#include "Config_UART1.h" +#include "Config_UART2.h" +#include "Config_CSI20.h" +#include "r_cg_sau_common.h" +#include "r_cg_tau_common.h" +#include "r_cg_itl_common.h" +#include "r_cg_iica_common.h" +#include "r_cg_ad_common.h" +#include "r_cg_rtc_common.h" +#include "r_cg_userdefine.h" + +/*********************************************************************************************************************** +Macro definitions (Register bit) +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Typedef definitions +***********************************************************************************************************************/ + +/*********************************************************************************************************************** +Global functions +***********************************************************************************************************************/ +/* Start user code for function. Do not edit comment generated here */ +#include "Config_TAU0_0_PWM.h" +#include "Config_TAU0_1_Square_Wave.h" +#include "Config_TAU0_2_Square_Wave.h" +#include "Config_TAU0_3_Square_Wave.h" +#include "Config_TAU0_6_Micros.h" +#include "Config_TAU0_7_Square_Wave.h" +/* End user code. Do not edit comment generated here */ +#endif + diff --git a/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/hdwinit.c b/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/hdwinit.c index c422438..8aa6797 100644 --- a/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/hdwinit.c +++ b/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/hdwinit.c @@ -1,133 +1,133 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -* this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* File Name : hdwinit.c -* H/W Platform : GENERIC_RL78_G22 -* Description : -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* History : DD.MM.YYYY Version Description -* : 20.04.2022 1.50 First Release - -***********************************************************************************************************************/ -/************************************************* - * Includes , "Project Includes" - *************************************************/ -/* I/O Register and board definitions */ -#include "platform.h" -#if BSP_CFG_CONFIGURATOR_SELECT == 1 -#include "r_cg_macrodriver.h" -#endif - -/************************************************* - * Macro definitions - *************************************************/ - -/************************************************* - * Private global variables and functions - *************************************************/ -/* MCU I/O port configuration function declaration */ -static void output_ports_configure (void); - -/* Interrupt configuration function declaration */ -static void interrupts_configure (void); - -/* MCU peripheral module configuration function declaration */ -static void peripheral_modules_enable (void); - -/************************************************* - * Function definition - *************************************************/ -/************************************************* - * Function name: hdwinit - * Description : Peripheral function initialization - * Arguments : none - * Return value : none -**************************************************/ -void hdwinit(void) -{ -#if BSP_CFG_DATA_FLASH_ACCESS_ENABLE == 1 - volatile uint32_t w_count; -#endif - - output_ports_configure(); - interrupts_configure(); - peripheral_modules_enable(); - - /* Safety function setting */ -#if BSP_CFG_INVALID_MEMORY_ACCESS_DETECTION_ENABLE == 0 - IAWCTL = 0x00U; -#else - IAWCTL = (BSP_CFG_INVALID_MEMORY_ACCESS_DETECTION_ENABLE << 7U) | - (BSP_CFG_RAM_GUARD_FUNC << 4U) | - (BSP_CFG_PORT_FUNCTION_GUARD << 2U) | - (BSP_CFG_INT_FUNCTION_GUARD << 1U) | - (BSP_CFG_CHIP_STATE_CTRL_GUARD); -#endif - - /* Data flash access control */ -#if BSP_CFG_DATA_FLASH_ACCESS_ENABLE == 1 - DFLEN = 1U; - /* WAIT_LOOP */ - for (w_count = 0U; w_count < 2U; w_count++) - { - BSP_NOP(); - } -#endif -} /* End of function hdwinit() */ - -/************************************************* - * Function name: output_ports_configure - * Description : Output port setting - * Arguments : none - * Return value : none -**************************************************/ -static void output_ports_configure(void) -{ - /* Add code here to setup additional output ports */ - BSP_NOP(); -} /* End of function output_ports_configure() */ - -/************************************************* - * Function name: interrupts_configure - * Description : Interrupt setting - * Arguments : none - * Return value : none -**************************************************/ -static void interrupts_configure(void) -{ - /* Add code here to setup additional interrupts */ - BSP_NOP(); -} /* End of function interrupts_configure() */ - -/************************************************* - * Function name: peripheral_modules_enable - * Description : Peripheral module setting - * Arguments : none - * Return value : none -**************************************************/ -static void peripheral_modules_enable(void) -{ - /* Add code here to enable peripherals used by the application */ -#if BSP_CFG_CONFIGURATOR_SELECT == 1 - /* Smart Configurator initialization function */ - R_Systeminit(); -#endif -} /* End of function peripheral_modules_enable() */ - +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +* this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* File Name : hdwinit.c +* H/W Platform : GENERIC_RL78_G22 +* Description : +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* History : DD.MM.YYYY Version Description +* : 20.04.2022 1.50 First Release + +***********************************************************************************************************************/ +/************************************************* + * Includes , "Project Includes" + *************************************************/ +/* I/O Register and board definitions */ +#include "platform.h" +#if BSP_CFG_CONFIGURATOR_SELECT == 1 +#include "r_cg_macrodriver.h" +#endif + +/************************************************* + * Macro definitions + *************************************************/ + +/************************************************* + * Private global variables and functions + *************************************************/ +/* MCU I/O port configuration function declaration */ +static void output_ports_configure (void); + +/* Interrupt configuration function declaration */ +static void interrupts_configure (void); + +/* MCU peripheral module configuration function declaration */ +static void peripheral_modules_enable (void); + +/************************************************* + * Function definition + *************************************************/ +/************************************************* + * Function name: hdwinit + * Description : Peripheral function initialization + * Arguments : none + * Return value : none +**************************************************/ +void hdwinit(void) +{ +#if BSP_CFG_DATA_FLASH_ACCESS_ENABLE == 1 + volatile uint32_t w_count; +#endif + + output_ports_configure(); + interrupts_configure(); + peripheral_modules_enable(); + + /* Safety function setting */ +#if BSP_CFG_INVALID_MEMORY_ACCESS_DETECTION_ENABLE == 0 + IAWCTL = 0x00U; +#else + IAWCTL = (BSP_CFG_INVALID_MEMORY_ACCESS_DETECTION_ENABLE << 7U) | + (BSP_CFG_RAM_GUARD_FUNC << 4U) | + (BSP_CFG_PORT_FUNCTION_GUARD << 2U) | + (BSP_CFG_INT_FUNCTION_GUARD << 1U) | + (BSP_CFG_CHIP_STATE_CTRL_GUARD); +#endif + + /* Data flash access control */ +#if BSP_CFG_DATA_FLASH_ACCESS_ENABLE == 1 + DFLEN = 1U; + /* WAIT_LOOP */ + for (w_count = 0U; w_count < 2U; w_count++) + { + BSP_NOP(); + } +#endif +} /* End of function hdwinit() */ + +/************************************************* + * Function name: output_ports_configure + * Description : Output port setting + * Arguments : none + * Return value : none +**************************************************/ +static void output_ports_configure(void) +{ + /* Add code here to setup additional output ports */ + BSP_NOP(); +} /* End of function output_ports_configure() */ + +/************************************************* + * Function name: interrupts_configure + * Description : Interrupt setting + * Arguments : none + * Return value : none +**************************************************/ +static void interrupts_configure(void) +{ + /* Add code here to setup additional interrupts */ + BSP_NOP(); +} /* End of function interrupts_configure() */ + +/************************************************* + * Function name: peripheral_modules_enable + * Description : Peripheral module setting + * Arguments : none + * Return value : none +**************************************************/ +static void peripheral_modules_enable(void) +{ + /* Add code here to enable peripherals used by the application */ +#if BSP_CFG_CONFIGURATOR_SELECT == 1 + /* Smart Configurator initialization function */ + R_Systeminit(); +#endif +} /* End of function peripheral_modules_enable() */ + diff --git a/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/hdwinit.h b/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/hdwinit.h index 5390566..9abef24 100644 --- a/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/hdwinit.h +++ b/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/hdwinit.h @@ -1,45 +1,45 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -* this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* File Name : hdwinit.h -* H/W Platform : GENERIC_RL78_G22 -* Description : -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* History : DD.MM.YYYY Version Description -* : 20.04.2022 1.50 First Release - -***********************************************************************************************************************/ -/************************************************* - * Includes , "Project Includes" - *************************************************/ - -/************************************************* - * Macro definitions - *************************************************/ -/* Multiple inclusion prevention macro */ -#ifndef HDWINIT_H -#define HDWINIT_H - -/************************************************* - * Exported global functions (to be accessed by other files) - *************************************************/ -void hdwinit (void); - -#endif /* #define HDWINIT_H */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +* this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* File Name : hdwinit.h +* H/W Platform : GENERIC_RL78_G22 +* Description : +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* History : DD.MM.YYYY Version Description +* : 20.04.2022 1.50 First Release + +***********************************************************************************************************************/ +/************************************************* + * Includes , "Project Includes" + *************************************************/ + +/************************************************* + * Macro definitions + *************************************************/ +/* Multiple inclusion prevention macro */ +#ifndef HDWINIT_H +#define HDWINIT_H + +/************************************************* + * Exported global functions (to be accessed by other files) + *************************************************/ +void hdwinit (void); + +#endif /* #define HDWINIT_H */ diff --git a/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp.h b/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp.h index ceb2c31..8345dea 100644 --- a/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp.h +++ b/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp.h @@ -1,61 +1,61 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -* this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* File Name : r_bsp.h -* H/W Platform : GENERIC_RL78_G22 -* Description : -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* History : DD.MM.YYYY Version Description -* : 20.04.2022 1.50 First Release -***********************************************************************************************************************/ -/* Make sure that no other platforms have already been defined. Do not touch this! */ -#ifdef PLATFORM_DEFINED -#error "Error - Multiple platforms defined in platform.h!" -#else -#define PLATFORM_DEFINED -#endif - - -/*********************************************************************************************************************** -INCLUDE APPROPRIATE MCU AND BOARD FILES -***********************************************************************************************************************/ -#include "r_bsp_config.h" -#include "mcu/all/r_bsp_rl78_compiler.h" -#include "mcu/all/r_bsp_common.h" -#include "mcu/all/r_rtos.h" - -#include "mcu/all/fsp_common_api.h" -#include "mcu/all/r_fsp_error.h" - -#if defined(__CCRL__) -#include "mcu/rl78_g22/register_access/ccrl/iodefine.h" -#elif defined(__ICCRL78__) -#include "mcu/rl78_g22/register_access/iccrl/iodefine.h" -#include "mcu/rl78_g22/register_access/iccrl/iodefine_ext.h" -#include "mcu/rl78_g22/register_access/iccrl/intrinsics.h" -#elif defined(__llvm__) -#include "mcu/rl78_g22/register_access/llvm/iodefine.h" -#include "mcu/rl78_g22/register_access/llvm/iodefine_ext.h" -#endif /* defined(__CCRL__), defined(__ICCRL__), defined(__llvm__) */ - -#include "mcu/rl78_g22/mcu_clocks.h" -#include "mcu/rl78_g22/mcu_info.h" - -#include "board/generic_rl78_g22/hdwinit.h" +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +* this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* File Name : r_bsp.h +* H/W Platform : GENERIC_RL78_G22 +* Description : +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* History : DD.MM.YYYY Version Description +* : 20.04.2022 1.50 First Release +***********************************************************************************************************************/ +/* Make sure that no other platforms have already been defined. Do not touch this! */ +#ifdef PLATFORM_DEFINED +#error "Error - Multiple platforms defined in platform.h!" +#else +#define PLATFORM_DEFINED +#endif + + +/*********************************************************************************************************************** +INCLUDE APPROPRIATE MCU AND BOARD FILES +***********************************************************************************************************************/ +#include "r_bsp_config.h" +#include "mcu/all/r_bsp_rl78_compiler.h" +#include "mcu/all/r_bsp_common.h" +#include "mcu/all/r_rtos.h" + +#include "mcu/all/fsp_common_api.h" +#include "mcu/all/r_fsp_error.h" + +#if defined(__CCRL__) +#include "mcu/rl78_g22/register_access/ccrl/iodefine.h" +#elif defined(__ICCRL78__) +#include "mcu/rl78_g22/register_access/iccrl/iodefine.h" +#include "mcu/rl78_g22/register_access/iccrl/iodefine_ext.h" +#include "mcu/rl78_g22/register_access/iccrl/intrinsics.h" +#elif defined(__llvm__) +#include "mcu/rl78_g22/register_access/llvm/iodefine.h" +#include "mcu/rl78_g22/register_access/llvm/iodefine_ext.h" +#endif /* defined(__CCRL__), defined(__ICCRL__), defined(__llvm__) */ + +#include "mcu/rl78_g22/mcu_clocks.h" +#include "mcu/rl78_g22/mcu_info.h" + +#include "board/generic_rl78_g22/hdwinit.h" diff --git a/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp_config_reference.h b/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp_config_reference.h index 6051f90..f8ab532 100644 --- a/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp_config_reference.h +++ b/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp_config_reference.h @@ -1,561 +1,561 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -* this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* File Name : r_bsp_config_reference.h -* H/W Platform : GENERIC_RL78_G22 -* Description : -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* History : DD.MM.YYYY Version Description -* : 20.04.2022 1.50 First Release -***********************************************************************************************************************/ - -#ifndef R_BSP_CONFIG_REF_HEADER_FILE -#define R_BSP_CONFIG_REF_HEADER_FILE -/************************************************* - * MCU information - *************************************************/ -/* - R 7 F 102G G E 3 xxx C FB #AA0 - | | | | | | | | | | |__not used Packaging specification - | | | | | | | | | |_____not used Package type - | | | | | | | | |________not used Fields of application - | | | | | | | |___________not used ROM number(omitted with blank products) - | | | | | | |______________not used Ambient operating temperature range - | | | | | |________________BSP_CFG_MCU_PART_ROM_SIZE ROM capacity - | | | | |__________________BSP_CFG_MCU_PART_PIN_NUM Pin count - | | | |______________________not used RL78/G22 - | | |_________________________BSP_CFG_MCU_PART_ROM_TYPE Device type - | |___________________________not used Renesas MCU - |_____________________________not used Renesas semiconductor product -*/ - -/* ROM capacity - C = 32(KB) : 0x0 - E = 64 : 0x1 -*/ -#define BSP_CFG_MCU_PART_ROM_SIZE (0x1) - -/* Pin count - 4 = 16-pin : 0x0 - 6 = 20-pin : 0x1 - 7 = 24-pin : 0x2 - 8 = 25-pin : 0x3 - A = 30-pin : 0x4 - B = 32-pin : 0x5 - C = 36-pin : 0x6 - E = 40-pin : 0x7 - F = 44-pin : 0x8 - G = 48-pin : 0x9 -*/ -#define BSP_CFG_MCU_PART_PIN_NUM (0x9) - -/* group - 102G = RL78/G22 : (true) -*/ -#define BSP_CFG_MCU_PART_HAS_DATA_FLASH (true) - -/* Device type - F = Flash memory : 0 -*/ -#define BSP_CFG_MCU_PART_ROM_TYPE (0) - -#if defined(__ICCRL78__) -/* Option byte setting(When using IAR) */ -#define BSP_CFG_OPTBYTE0_VALUE (0xFFU) -#define BSP_CFG_OPTBYTE1_VALUE (0xFFU) -#define BSP_CFG_OPTBYTE2_VALUE (0xE0U) -#define BSP_CFG_OPTBYTE3_VALUE (0x04U) -/* Security ID Codes for On-Chip Debugging setting(When using IAR) */ -#define BSP_CFG_SECUID0_VALUE (0x00U) -#define BSP_CFG_SECUID1_VALUE (0x00U) -#define BSP_CFG_SECUID2_VALUE (0x00U) -#define BSP_CFG_SECUID3_VALUE (0x00U) -#define BSP_CFG_SECUID4_VALUE (0x00U) -#define BSP_CFG_SECUID5_VALUE (0x00U) -#define BSP_CFG_SECUID6_VALUE (0x00U) -#define BSP_CFG_SECUID7_VALUE (0x00U) -#define BSP_CFG_SECUID8_VALUE (0x00U) -#define BSP_CFG_SECUID9_VALUE (0x00U) -#endif - -/************************************************* - * Pin assignment setting - *************************************************/ -/* Peripheral I/O redirection register(PIOR-PIOR0) - 48/44-pin - 0 : TI02/TO02 - P17 - TI03/TO03 - P31 - TI04/TO04 - - - TI05/TO05 - - - TI06/TO06 - - - TI07/TO07 - P41 - 1 : TI02/TO02 - P15 - TI03/TO03 - P14 - TI04/TO04 - P13 - TI05/TO05 - P12 - TI06/TO06 - P11 - TI07/TO07 - P10 - - 40/36/32/30-pin - 0 : TI02/TO02 - P17 - TI03/TO03 - P31 - TI04/TO04 - - - TI05/TO05 - - - TI06/TO06 - - - TI07/TO07 - - - 1 : TI02/TO02 - P15 - TI03/TO03 - P14 - TI04/TO04 - P13 - TI05/TO05 - P12 - TI06/TO06 - P11 - TI07/TO07 - P10 -*/ -#define BSP_CFG_PIOR0 (0) - -/* Peripheral I/O redirection register(PIOR-PIOR1) - 48/44/40/36/32/30-pin - 0 : TxD2 - P13 - RxD2 - P14 - SCL20 - P15 - SDA20 - P14 - SI20 - P14 - SO20 - P13 - SCK20 - P15 - TxD0 - P12 - RxD0 - P11 - SCL00 - P10 - SDA00 - P11 - SI00 - P11 - SO00 - P12 - SCK00 - P10 - 1 : TxD2 - - - RxD2 - - - SCL20 - - - SDA20 - - - SI20 - - - SO20 - - - SCK20 - - - TxD0 - P17 - RxD0 - P16 - SCL00 - - - SDA00 - - - SI00 - - - SO00 - - - SCK00 - - -*/ -#define BSP_CFG_PIOR1 (0) - -/* Peripheral I/O redirection register(PIOR-PIOR2) - 48/44/40/36/32/30-pin - 0 : SCLA0 - P60 - SDAA0 - P61 - 1 : SCLA0 - P14 - SDAA0 - P13 -*/ -#define BSP_CFG_PIOR2 (0) - -/* Peripheral I/O redirection register(PIOR-PIOR3) - 48-pin - 0 : PCLBUZ0 - P140 - 1 : PCLBUZ0 - P31 - - 44/40/36/32/30-pin - 0 : PCLBUZ0 - - - 1 : PCLBUZ0 - - -*/ -#define BSP_CFG_PIOR3 (0) - -/*********************************************************** - * Invalid memory access detection control register (IAWCTL) - ***********************************************************/ -/* Control of illicit memory access detection(IAWEN) - 0 : Disables the detection of illicit memory accesses. - 1 : Enables the detection of illicit memory accesses. -*/ -#define BSP_CFG_INVALID_MEMORY_ACCESS_DETECTION_ENABLE (0) - -/* Protected area in the RAM(GRAM0-1) - 0 : Disabled. Writing to the RAM is allowed. - 1 : 128 bytes from the base address of the RAM. - 2 : 256 bytes from the base address of the RAM. - 3 : 512 bytes from the base address of the RAM. -*/ -#define BSP_CFG_RAM_GUARD_FUNC (0) - -/* Protection of the port control registers(GPORT) - 0 : Disabled. Reading from and writing to the port control registers are allowed. - 1 : Enabled. Writing to the port control registers is not allowed. Reading from them is allowed. - [Protected SFRs] PMxx, PUxx, PIMxx, POMxx, PMCAxx, PMCTxx, PFOE1, PDIDISxx -*/ -#define BSP_CFG_PORT_FUNCTION_GUARD (0) - -/* Protection of the interrupt control registers(GINT) - 0 : Disabled. Reading from and writing to the interrupt control registers are allowed. - 1 : Enabled. Writing to the interrupt control registers is not allowed. Reading from them is allowed. - [Protected SFRs] IFxx, MKxx, PRxx, EGPx, EGNx -*/ -#define BSP_CFG_INT_FUNCTION_GUARD (0) - -/* Protection of the clock, voltage detector, and RAM parity error detection control registers(GCSC) - 0 : Disabled. Reading from and writing to the clock, voltage detector, and RAM parity error - detection control registers are allowed. - 1 : Enabled. Writing to the clock, voltage detector, and RAM parity error detection control registers - is not allowed. Reading from them is allowed. - [Protected SFRs] CMC, CSC, OSTS, CKC, PERx, OSMC, LVIM, LVIS, RPECTL, - CKSEL, PRRx, MOCODIV, WKUPMD -*/ -#define BSP_CFG_CHIP_STATE_CTRL_GUARD (0) - -/************************************************* - * Data flash - *************************************************/ -/* Data flash memory area access control - Data flash control register(DFLCTL) - DFLEN - 0 : Access to the data flash memory area is disabled. - 1 : Access to the data flash memory area is enabled. -*/ -#define BSP_CFG_DATA_FLASH_ACCESS_ENABLE (0) - -/************************************************* - * Definition for switching functions - *************************************************/ -/* Start up select - 0 : Enable BSP startup program. - 1 : Disable BSP startup program.(e.g. Using user startup program.) -*/ -#define BSP_CFG_STARTUP_DISABLE (0) - -/* Initialization of peripheral functions by Code Generator/Smart Configurator - 0 : Disable initialization of peripheral functions by Code Generator/Smart Configurator. - 1 : Enable initialization of peripheral functions by Code Generator/Smart Configurator. -*/ -#define BSP_CFG_CONFIGURATOR_SELECT (0) - -/* Version number of Smart Configurator. - This macro definitions is updated by Smart Configurator. - If you are using e2studio, set the following values. - 2021-04 : 1001 - 2021-07 : 1010 - 2021-10 : 1010 - 2022-01 : 1030 - If you are using the standalone version of Smart Configurator, - set the following values. - v1.0.1 : 1001 - v1.1.0 : 1010 - v1.3.0 : 1030 -*/ -#define BSP_CFG_CONFIGURATOR_VERSION (1001) - -/* API function disable(R_BSP_StartClock, R_BSP_StopClock) - 0 : Enable API functions - 1 : Disable API functions -*/ -#define BSP_CFG_CLOCK_OPERATION_API_FUNCTIONS_DISABLE (0) - -/* API function disable(R_BSP_GetFclkFreqHz) - 0 : Enable API functions - 1 : Disable API functions -*/ -#define BSP_CFG_GET_FREQ_API_FUNCTIONS_DISABLE (0) - -/* API function disable(R_BSP_SetClockSource) - 0 : Enable API functions - 1 : Disable API functions -*/ -#define BSP_CFG_SET_CLOCK_SOURCE_API_FUNCTIONS_DISABLE (0) - -/* API function disable(R_BSP_ChangeClockSetting) - 0 : Enable API functions - 1 : Disable API functions -*/ -#define BSP_CFG_CHANGE_CLOCK_SETTING_API_FUNCTIONS_DISABLE (0) - -/* Parameter check enable - 0 : Disable parameter check. - 1 : Enable parameter check. -*/ -#define BSP_CFG_PARAM_CHECKING_ENABLE (1) - -/************************************************* - * Clock settings - *************************************************/ -/* High-speed system clock pin operation mode - Clock operation mode control register(CMC) - (Products with 16 to 36 pins) - XTSEL/EXCLK/OSCSEL - (Products with 40 to 48 pins) - EXCLK/OSCSEL - 0 : Port mode - 1 : X1 oscillation mode - 2 : External clock input mode -*/ -#define BSP_CFG_HISYSCLK_SOURCE (1) - -/* High-speed system clock operation control - Clock operation status control register(CSC) - MSTOP - (X1 oscillation mode) - 0 : The X1 oscillator runs. - 1 : The X1 oscillator is stopped. - (External clock input mode) - 0 : An external clock signal on the EXCLK pin is effective. - 1 : An external clock signal on the EXCLK pin is ineffective. - (Port mode) - 0 : I/O port - 1 : I/O port -*/ -#define BSP_CFG_HISYSCLK_OPERATION (0) - -/* Subsystem clock pin operation mode - Clock operation mode control register(CMC) - (Products with 16 to 36 pins) - XTSEL/EXCLKS/OSCSELS - (Products with 40 to 48 pins) - EXCLKS/OSCSELS - 0 : Input port mode - 1 : XT1 oscillation mode -2 : External clock input mode -*/ -#define BSP_CFG_SUBCLK_SOURCE (1) - -/* Subsystem clock operation control - Clock operation status control register(CSC) - XTSTOP - (XT1 oscillation mode) - 0 : The XT1 oscillator runs. - 1 : The XT1 oscillator is stopped. - (External clock input mode) - 0 : An external clock signal on the EXCLKS pin is effective. - 1 : An external clock signal on the EXCLKS pin is ineffective. - (Port mode) - 0 : Input port - 1 : Input port -*/ -#define BSP_CFG_SUBCLK_OPERATION (0) - -/* Middle-speed on-chip oscillator clock operation control - Clock operation status control register(CSC) - MIOEN - 0 : The middle-speed on-chip oscillator is stopped. - 1 : The middle-speed on-chip oscillator runs. -*/ -#define BSP_CFG_MOCO_OPERATION (1) - -/* Main on-chip oscillator clock(fOCO) operation control - System clock control register(CKC) - MCM1 - 0 : High-speed on-chip oscillator clock - 1 : Middle-speed on-chip oscillator clock -*/ -#define BSP_CFG_OCOCLK_SOURCE (0) - -/* Main system clock(fMAIN) operation control - System clock control register(CKC) - MCM0 - 0 : Selects the main on-chip oscillator clock(fOCO) as the main system clock(fMAIN) - 1 : Selects the high-speed system clock(fMX) as the main system clock(fMAIN) -*/ -#define BSP_CFG_MAINCLK_SOURCE (0) - -/* Selection of the subsystem clock X or low-speed on-chip oscillator clock - Subsystem clock select register(CKSEL) - SELLOSC - 0 : Subsystem clock X - 1 : Low-speed on-chip oscillator clock -*/ -#define BSP_CFG_SUBSYSCLK_SOURCE (0) - -/* Selection of the CPU/peripheral hardware clock(fCLK) - System clock control register(CKC) - CSS - 0 : Main system clock(fMAIN) - 1 : Subsystem clock(fSUB) -*/ -#define BSP_CFG_FCLK_SOURCE (0) - -/* Selection of the oscillation mode of the XT1 oscillator - Clock operation mode control register(CMC) - AMPHS1, AMPHS0 - 0 : Low power consumption oscillation 1(default) - 1 : Normal oscillation - 2 : Low power consumption oscillation 2 - 3 : Low power consumption oscillation 3 -*/ -#define BSP_CFG_XT1_OSCMODE (0) - -/* Input clock frequency in Hz(High-speed system clock(X1)) -*/ -#define BSP_CFG_FMX_HZ (20000000) - -/* Control of the X1 clock oscillation frequency - Clock operation mode control register(CMC) - AMPH - 0 : 1 MHz <= fX <= 10 MHz - 1 : 10 MHz < fX <= 20 MHz - Set the value corresponding to the setting of BSP_CFG_FMX_HZ -*/ - -/* Selection of the oscillation stabilization time - Oscillation stabilization time select register(OSTS) - OSTS2, OSTS1, OSTS0 - 0 : 2^8/fX(fX = 10MHz : 25.6us, fX = 20MHz : 12.8us) - 1 : 2^9/fX(fX = 10MHz : 51.2us, fX = 20MHz : 25.6us) - 2 : 2^10/fX(fX = 10MHz : 102us, fX = 20MHz : 51.2us) - 3 : 2^11/fX(fX = 10MHz : 204us, fX = 20MHz : 102us) - 4 : 2^13/fX(fX = 10MHz : 819us, fX = 20MHz : 409us) - 5 : 2^15/fX(fX = 10MHz : 3.27ms, fX = 20MHz : 1.63ms) - 6 : 2^17/fX(fX = 10MHz : 13.1ms, fX = 20MHz : 6.55ms) - 7 : 2^18/fX(fX = 10MHz : 26.2ms, fX = 20MHz : 13.1ms) -*/ -#define BSP_CFG_X1_WAIT_TIME_SEL (0) - -/* Setting in STOP mode or in HALT mode while the CPU is operating with subsystem clock X. - Subsystem clock supply mode control register(OSMC) - RTCLPC - 0 : Enables supply of subsystem clock X to peripheral functions. - 1 : Stops supply of the subsystem clock to peripheral functions other than the realtime clock. -*/ -#define BSP_CFG_ALLOW_FSUB_IN_STOPHALT (1) - -/* Selection of the operating clock for the realtime clock, 32-bit interval timer, - serial interface UARTA0, and clock output/buzzer output controller - Subsystem clock supply mode control register(OSMC) - WUTMMCK0 - 0 : Subsystem clock X - 1 : Low-speed on-chip oscillator clock -*/ -#define BSP_CFG_RTC_OUT_CLK_SOURCE (1) - -/* Selection of the high-speed on-chip oscillator clock frequency - High-speed on-chip oscillator frequency select register(HOCODIV) - HOCODIV2, HOCODIV1, HOCODIV0 - - (FRQSEL3 = 0) - 0 : fIH = 24 MHz - 1 : fIH = 12 MHz - 2 : fIH = 6 MHz - 3 : fIH = 3 MHz - Other than above : Setting prohibited - - (FRQSEL3 = 1) - 0 : fIH = 32 MHz - 1 : fIH = 16 MHz - 2 : fIH = 8 MHz - 3 : fIH = 4 MHz - 4 : fIH = 2 MHz - 5 : fIH = 1 MHz - Other than above : Setting prohibited - */ -#define BSP_CFG_HOCO_DIVIDE (0) - -/* Setting for starting the high-speed on-chip oscillator at the times of release from STOP mode - and of transitions to SNOOZE mode - Standby mode release setting register(WKUPMD) - FWKUP - 0 : Starting of the high-speed on-chip oscillator is at normal speed. - 1 : Starting of the high-speed on-chip oscillator is at high speed. -*/ -#define BSP_CFG_WAKEUP_MODE (1) - -/* Selected division ratio for the high-speed system clock - High-speed system clock division register(MOSCDIV) - MOSCDIV2, MOSCDIV1, MOSCDIV0 - 0 : fMX (fMX = 20MHz : 20MHz) - 1 : fMX/2 (fMX = 20MHz : 10MHz) - 2 : fMX/4 (fMX = 20MHz : 5MHz) - 3 : fMX/8 (fMX = 20MHz : 2.5MHz) - 4 : fMX/16 (fMX = 20MHz : 1.25MHz) - Other than above : Setting prohibited -*/ -#define BSP_CFG_MOSC_DIVIDE (0) - -/* Selection of the middle-speed on-chip oscillator clock frequency - Middle-speed on-chip oscillator frequency select register(MOCODIV) - MOCODIV1, MOCODIV0 - 0 : 4MHz - 1 : 2MHz - 2 : 1MHz - Other than above : Setting prohibited -*/ -#define BSP_CFG_MOCO_DIVIDE (0) - -/* Operation setting at initial setting */ -/* Starts the high-speed on-chip oscillator at initialization - 0 : Stops the high-speed on-chip oscillator at initialization - 1 : Starts the high-speed on-chip oscillator at initialization -*/ -#define BSP_CFG_FIH_START_ON_STARTUP (1) - -/* This macro lets other modules no if a RTOS is being used. - 0 : RTOS is not used. - 1 : FreeRTOS is used.(This is not available.) - 2 : embOS is used.(This is not available.) - 3 : MicroC_OS is used.(This is not available.) - 4 : Renesas ITRON is used. -*/ -#define BSP_CFG_RTOS_USED (0) - -/* Loop count using the main system clock. */ -/* The loop count refers to a loop consisting of a "for" statement that executes a single NOP instruction. */ -/* Subsystem clock oscillation stabilization wait time */ -/* If the main system clock is 32 MHz, 800000 means 550 ms. */ -#define BSP_CFG_SUBWAITTIME (800000U) - -/* High-speed on-chip oscillator clock oscillation stabilization wait time */ -/* If the main system clock 32 MHz, 30 means 22.7us. */ -#define BSP_CFG_FIHWAITTIME (30U) - -/* Middle-speed on-chip oscillator clock oscillation stabilization wait time. */ -/* If the main system clock 32 MHz, 5 means 4.8us. */ -#define BSP_CFG_FIMWAITTIME (5U) - -/* Low-speed on-chip oscillator clock oscillation stabilization wait time */ -/* If the main system clock 32 MHz, 450 means 325us. */ -#define BSP_CFG_FILWAITTIME (450U) - -/* If the user would like to determine if a warm start reset has occurred, then they may enable one or more of the - following callback definitions AND provide a call back function name for the respective callback - function (to be defined by the user). Setting BSP_CFG_USER_WARM_START_CALLBACK_PRE_INITC_ENABLED = 1 will result - in a callback to the user defined my_sw_warmstart_prec_function just prior to the initialization of the C - runtime environment by bsp_init_system. - Setting BSP_CFG_USER_WARM_START_CALLBACK_POST_INITC_ENABLED = 1 will result in a callback to the user defined - my_sw_warmstart_postc_function just after the initialization of the C runtime environment by bsp_init_hardware. -*/ -#define BSP_CFG_USER_WARM_START_CALLBACK_PRE_INITC_ENABLED (0) -#define BSP_CFG_USER_WARM_START_PRE_C_FUNCTION my_sw_warmstart_prec_function - -#define BSP_CFG_USER_WARM_START_CALLBACK_POST_INITC_ENABLED (0) -#define BSP_CFG_USER_WARM_START_POST_C_FUNCTION my_sw_warmstart_postc_function - -/* If the user sets the window open period of watchdog timer to 50%, - set the following macro definition(BSP_CFG_WDT_REFRESH_ENABLE) to 2 - and specify the callback function name for each callback function(to be defined by the user). - Setting BSP_CFG_WDT_REFRESH_ENABLE == 2 will result in a callback to the user defined - my_sw_wdt_refresh_init_function just prior to the clock is set by bsp_init_system. - In addition, a callback to the user defined my_sw_wdt_refresh_setting_function occurs - during the oscillation stabilization wait time od the subsystem clock. -*/ -#define BSP_CFG_WDT_REFRESH_ENABLE (0) -#define BSP_CFG_USER_WDT_REFRESH_INIT_FUNCTION my_sw_wdt_refresh_init_function -#define BSP_CFG_USER_WDT_REFRESH_SETTING_FUNCTION my_sw_wdt_refresh_setting_function - -#endif /* R_BSP_CONFIG_REF_HEADER_FILE */ - +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +* this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* File Name : r_bsp_config_reference.h +* H/W Platform : GENERIC_RL78_G22 +* Description : +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* History : DD.MM.YYYY Version Description +* : 20.04.2022 1.50 First Release +***********************************************************************************************************************/ + +#ifndef R_BSP_CONFIG_REF_HEADER_FILE +#define R_BSP_CONFIG_REF_HEADER_FILE +/************************************************* + * MCU information + *************************************************/ +/* + R 7 F 102G G E 3 xxx C FB #AA0 + | | | | | | | | | | |__not used Packaging specification + | | | | | | | | | |_____not used Package type + | | | | | | | | |________not used Fields of application + | | | | | | | |___________not used ROM number(omitted with blank products) + | | | | | | |______________not used Ambient operating temperature range + | | | | | |________________BSP_CFG_MCU_PART_ROM_SIZE ROM capacity + | | | | |__________________BSP_CFG_MCU_PART_PIN_NUM Pin count + | | | |______________________not used RL78/G22 + | | |_________________________BSP_CFG_MCU_PART_ROM_TYPE Device type + | |___________________________not used Renesas MCU + |_____________________________not used Renesas semiconductor product +*/ + +/* ROM capacity + C = 32(KB) : 0x0 + E = 64 : 0x1 +*/ +#define BSP_CFG_MCU_PART_ROM_SIZE (0x1) + +/* Pin count + 4 = 16-pin : 0x0 + 6 = 20-pin : 0x1 + 7 = 24-pin : 0x2 + 8 = 25-pin : 0x3 + A = 30-pin : 0x4 + B = 32-pin : 0x5 + C = 36-pin : 0x6 + E = 40-pin : 0x7 + F = 44-pin : 0x8 + G = 48-pin : 0x9 +*/ +#define BSP_CFG_MCU_PART_PIN_NUM (0x9) + +/* group + 102G = RL78/G22 : (true) +*/ +#define BSP_CFG_MCU_PART_HAS_DATA_FLASH (true) + +/* Device type + F = Flash memory : 0 +*/ +#define BSP_CFG_MCU_PART_ROM_TYPE (0) + +#if defined(__ICCRL78__) +/* Option byte setting(When using IAR) */ +#define BSP_CFG_OPTBYTE0_VALUE (0xFFU) +#define BSP_CFG_OPTBYTE1_VALUE (0xFFU) +#define BSP_CFG_OPTBYTE2_VALUE (0xE0U) +#define BSP_CFG_OPTBYTE3_VALUE (0x04U) +/* Security ID Codes for On-Chip Debugging setting(When using IAR) */ +#define BSP_CFG_SECUID0_VALUE (0x00U) +#define BSP_CFG_SECUID1_VALUE (0x00U) +#define BSP_CFG_SECUID2_VALUE (0x00U) +#define BSP_CFG_SECUID3_VALUE (0x00U) +#define BSP_CFG_SECUID4_VALUE (0x00U) +#define BSP_CFG_SECUID5_VALUE (0x00U) +#define BSP_CFG_SECUID6_VALUE (0x00U) +#define BSP_CFG_SECUID7_VALUE (0x00U) +#define BSP_CFG_SECUID8_VALUE (0x00U) +#define BSP_CFG_SECUID9_VALUE (0x00U) +#endif + +/************************************************* + * Pin assignment setting + *************************************************/ +/* Peripheral I/O redirection register(PIOR-PIOR0) + 48/44-pin + 0 : TI02/TO02 - P17 + TI03/TO03 - P31 + TI04/TO04 - - + TI05/TO05 - - + TI06/TO06 - - + TI07/TO07 - P41 + 1 : TI02/TO02 - P15 + TI03/TO03 - P14 + TI04/TO04 - P13 + TI05/TO05 - P12 + TI06/TO06 - P11 + TI07/TO07 - P10 + + 40/36/32/30-pin + 0 : TI02/TO02 - P17 + TI03/TO03 - P31 + TI04/TO04 - - + TI05/TO05 - - + TI06/TO06 - - + TI07/TO07 - - + 1 : TI02/TO02 - P15 + TI03/TO03 - P14 + TI04/TO04 - P13 + TI05/TO05 - P12 + TI06/TO06 - P11 + TI07/TO07 - P10 +*/ +#define BSP_CFG_PIOR0 (0) + +/* Peripheral I/O redirection register(PIOR-PIOR1) + 48/44/40/36/32/30-pin + 0 : TxD2 - P13 + RxD2 - P14 + SCL20 - P15 + SDA20 - P14 + SI20 - P14 + SO20 - P13 + SCK20 - P15 + TxD0 - P12 + RxD0 - P11 + SCL00 - P10 + SDA00 - P11 + SI00 - P11 + SO00 - P12 + SCK00 - P10 + 1 : TxD2 - - + RxD2 - - + SCL20 - - + SDA20 - - + SI20 - - + SO20 - - + SCK20 - - + TxD0 - P17 + RxD0 - P16 + SCL00 - - + SDA00 - - + SI00 - - + SO00 - - + SCK00 - - +*/ +#define BSP_CFG_PIOR1 (0) + +/* Peripheral I/O redirection register(PIOR-PIOR2) + 48/44/40/36/32/30-pin + 0 : SCLA0 - P60 + SDAA0 - P61 + 1 : SCLA0 - P14 + SDAA0 - P13 +*/ +#define BSP_CFG_PIOR2 (0) + +/* Peripheral I/O redirection register(PIOR-PIOR3) + 48-pin + 0 : PCLBUZ0 - P140 + 1 : PCLBUZ0 - P31 + + 44/40/36/32/30-pin + 0 : PCLBUZ0 - - + 1 : PCLBUZ0 - - +*/ +#define BSP_CFG_PIOR3 (0) + +/*********************************************************** + * Invalid memory access detection control register (IAWCTL) + ***********************************************************/ +/* Control of illicit memory access detection(IAWEN) + 0 : Disables the detection of illicit memory accesses. + 1 : Enables the detection of illicit memory accesses. +*/ +#define BSP_CFG_INVALID_MEMORY_ACCESS_DETECTION_ENABLE (0) + +/* Protected area in the RAM(GRAM0-1) + 0 : Disabled. Writing to the RAM is allowed. + 1 : 128 bytes from the base address of the RAM. + 2 : 256 bytes from the base address of the RAM. + 3 : 512 bytes from the base address of the RAM. +*/ +#define BSP_CFG_RAM_GUARD_FUNC (0) + +/* Protection of the port control registers(GPORT) + 0 : Disabled. Reading from and writing to the port control registers are allowed. + 1 : Enabled. Writing to the port control registers is not allowed. Reading from them is allowed. + [Protected SFRs] PMxx, PUxx, PIMxx, POMxx, PMCAxx, PMCTxx, PFOE1, PDIDISxx +*/ +#define BSP_CFG_PORT_FUNCTION_GUARD (0) + +/* Protection of the interrupt control registers(GINT) + 0 : Disabled. Reading from and writing to the interrupt control registers are allowed. + 1 : Enabled. Writing to the interrupt control registers is not allowed. Reading from them is allowed. + [Protected SFRs] IFxx, MKxx, PRxx, EGPx, EGNx +*/ +#define BSP_CFG_INT_FUNCTION_GUARD (0) + +/* Protection of the clock, voltage detector, and RAM parity error detection control registers(GCSC) + 0 : Disabled. Reading from and writing to the clock, voltage detector, and RAM parity error + detection control registers are allowed. + 1 : Enabled. Writing to the clock, voltage detector, and RAM parity error detection control registers + is not allowed. Reading from them is allowed. + [Protected SFRs] CMC, CSC, OSTS, CKC, PERx, OSMC, LVIM, LVIS, RPECTL, + CKSEL, PRRx, MOCODIV, WKUPMD +*/ +#define BSP_CFG_CHIP_STATE_CTRL_GUARD (0) + +/************************************************* + * Data flash + *************************************************/ +/* Data flash memory area access control + Data flash control register(DFLCTL) + DFLEN + 0 : Access to the data flash memory area is disabled. + 1 : Access to the data flash memory area is enabled. +*/ +#define BSP_CFG_DATA_FLASH_ACCESS_ENABLE (0) + +/************************************************* + * Definition for switching functions + *************************************************/ +/* Start up select + 0 : Enable BSP startup program. + 1 : Disable BSP startup program.(e.g. Using user startup program.) +*/ +#define BSP_CFG_STARTUP_DISABLE (0) + +/* Initialization of peripheral functions by Code Generator/Smart Configurator + 0 : Disable initialization of peripheral functions by Code Generator/Smart Configurator. + 1 : Enable initialization of peripheral functions by Code Generator/Smart Configurator. +*/ +#define BSP_CFG_CONFIGURATOR_SELECT (0) + +/* Version number of Smart Configurator. + This macro definitions is updated by Smart Configurator. + If you are using e2studio, set the following values. + 2021-04 : 1001 + 2021-07 : 1010 + 2021-10 : 1010 + 2022-01 : 1030 + If you are using the standalone version of Smart Configurator, + set the following values. + v1.0.1 : 1001 + v1.1.0 : 1010 + v1.3.0 : 1030 +*/ +#define BSP_CFG_CONFIGURATOR_VERSION (1001) + +/* API function disable(R_BSP_StartClock, R_BSP_StopClock) + 0 : Enable API functions + 1 : Disable API functions +*/ +#define BSP_CFG_CLOCK_OPERATION_API_FUNCTIONS_DISABLE (0) + +/* API function disable(R_BSP_GetFclkFreqHz) + 0 : Enable API functions + 1 : Disable API functions +*/ +#define BSP_CFG_GET_FREQ_API_FUNCTIONS_DISABLE (0) + +/* API function disable(R_BSP_SetClockSource) + 0 : Enable API functions + 1 : Disable API functions +*/ +#define BSP_CFG_SET_CLOCK_SOURCE_API_FUNCTIONS_DISABLE (0) + +/* API function disable(R_BSP_ChangeClockSetting) + 0 : Enable API functions + 1 : Disable API functions +*/ +#define BSP_CFG_CHANGE_CLOCK_SETTING_API_FUNCTIONS_DISABLE (0) + +/* Parameter check enable + 0 : Disable parameter check. + 1 : Enable parameter check. +*/ +#define BSP_CFG_PARAM_CHECKING_ENABLE (1) + +/************************************************* + * Clock settings + *************************************************/ +/* High-speed system clock pin operation mode + Clock operation mode control register(CMC) + (Products with 16 to 36 pins) + XTSEL/EXCLK/OSCSEL + (Products with 40 to 48 pins) + EXCLK/OSCSEL + 0 : Port mode + 1 : X1 oscillation mode + 2 : External clock input mode +*/ +#define BSP_CFG_HISYSCLK_SOURCE (1) + +/* High-speed system clock operation control + Clock operation status control register(CSC) + MSTOP + (X1 oscillation mode) + 0 : The X1 oscillator runs. + 1 : The X1 oscillator is stopped. + (External clock input mode) + 0 : An external clock signal on the EXCLK pin is effective. + 1 : An external clock signal on the EXCLK pin is ineffective. + (Port mode) + 0 : I/O port + 1 : I/O port +*/ +#define BSP_CFG_HISYSCLK_OPERATION (0) + +/* Subsystem clock pin operation mode + Clock operation mode control register(CMC) + (Products with 16 to 36 pins) + XTSEL/EXCLKS/OSCSELS + (Products with 40 to 48 pins) + EXCLKS/OSCSELS + 0 : Input port mode + 1 : XT1 oscillation mode +2 : External clock input mode +*/ +#define BSP_CFG_SUBCLK_SOURCE (1) + +/* Subsystem clock operation control + Clock operation status control register(CSC) + XTSTOP + (XT1 oscillation mode) + 0 : The XT1 oscillator runs. + 1 : The XT1 oscillator is stopped. + (External clock input mode) + 0 : An external clock signal on the EXCLKS pin is effective. + 1 : An external clock signal on the EXCLKS pin is ineffective. + (Port mode) + 0 : Input port + 1 : Input port +*/ +#define BSP_CFG_SUBCLK_OPERATION (0) + +/* Middle-speed on-chip oscillator clock operation control + Clock operation status control register(CSC) + MIOEN + 0 : The middle-speed on-chip oscillator is stopped. + 1 : The middle-speed on-chip oscillator runs. +*/ +#define BSP_CFG_MOCO_OPERATION (1) + +/* Main on-chip oscillator clock(fOCO) operation control + System clock control register(CKC) + MCM1 + 0 : High-speed on-chip oscillator clock + 1 : Middle-speed on-chip oscillator clock +*/ +#define BSP_CFG_OCOCLK_SOURCE (0) + +/* Main system clock(fMAIN) operation control + System clock control register(CKC) + MCM0 + 0 : Selects the main on-chip oscillator clock(fOCO) as the main system clock(fMAIN) + 1 : Selects the high-speed system clock(fMX) as the main system clock(fMAIN) +*/ +#define BSP_CFG_MAINCLK_SOURCE (0) + +/* Selection of the subsystem clock X or low-speed on-chip oscillator clock + Subsystem clock select register(CKSEL) + SELLOSC + 0 : Subsystem clock X + 1 : Low-speed on-chip oscillator clock +*/ +#define BSP_CFG_SUBSYSCLK_SOURCE (0) + +/* Selection of the CPU/peripheral hardware clock(fCLK) + System clock control register(CKC) + CSS + 0 : Main system clock(fMAIN) + 1 : Subsystem clock(fSUB) +*/ +#define BSP_CFG_FCLK_SOURCE (0) + +/* Selection of the oscillation mode of the XT1 oscillator + Clock operation mode control register(CMC) + AMPHS1, AMPHS0 + 0 : Low power consumption oscillation 1(default) + 1 : Normal oscillation + 2 : Low power consumption oscillation 2 + 3 : Low power consumption oscillation 3 +*/ +#define BSP_CFG_XT1_OSCMODE (0) + +/* Input clock frequency in Hz(High-speed system clock(X1)) +*/ +#define BSP_CFG_FMX_HZ (20000000) + +/* Control of the X1 clock oscillation frequency + Clock operation mode control register(CMC) + AMPH + 0 : 1 MHz <= fX <= 10 MHz + 1 : 10 MHz < fX <= 20 MHz + Set the value corresponding to the setting of BSP_CFG_FMX_HZ +*/ + +/* Selection of the oscillation stabilization time + Oscillation stabilization time select register(OSTS) + OSTS2, OSTS1, OSTS0 + 0 : 2^8/fX(fX = 10MHz : 25.6us, fX = 20MHz : 12.8us) + 1 : 2^9/fX(fX = 10MHz : 51.2us, fX = 20MHz : 25.6us) + 2 : 2^10/fX(fX = 10MHz : 102us, fX = 20MHz : 51.2us) + 3 : 2^11/fX(fX = 10MHz : 204us, fX = 20MHz : 102us) + 4 : 2^13/fX(fX = 10MHz : 819us, fX = 20MHz : 409us) + 5 : 2^15/fX(fX = 10MHz : 3.27ms, fX = 20MHz : 1.63ms) + 6 : 2^17/fX(fX = 10MHz : 13.1ms, fX = 20MHz : 6.55ms) + 7 : 2^18/fX(fX = 10MHz : 26.2ms, fX = 20MHz : 13.1ms) +*/ +#define BSP_CFG_X1_WAIT_TIME_SEL (0) + +/* Setting in STOP mode or in HALT mode while the CPU is operating with subsystem clock X. + Subsystem clock supply mode control register(OSMC) + RTCLPC + 0 : Enables supply of subsystem clock X to peripheral functions. + 1 : Stops supply of the subsystem clock to peripheral functions other than the realtime clock. +*/ +#define BSP_CFG_ALLOW_FSUB_IN_STOPHALT (1) + +/* Selection of the operating clock for the realtime clock, 32-bit interval timer, + serial interface UARTA0, and clock output/buzzer output controller + Subsystem clock supply mode control register(OSMC) + WUTMMCK0 + 0 : Subsystem clock X + 1 : Low-speed on-chip oscillator clock +*/ +#define BSP_CFG_RTC_OUT_CLK_SOURCE (1) + +/* Selection of the high-speed on-chip oscillator clock frequency + High-speed on-chip oscillator frequency select register(HOCODIV) + HOCODIV2, HOCODIV1, HOCODIV0 + + (FRQSEL3 = 0) + 0 : fIH = 24 MHz + 1 : fIH = 12 MHz + 2 : fIH = 6 MHz + 3 : fIH = 3 MHz + Other than above : Setting prohibited + + (FRQSEL3 = 1) + 0 : fIH = 32 MHz + 1 : fIH = 16 MHz + 2 : fIH = 8 MHz + 3 : fIH = 4 MHz + 4 : fIH = 2 MHz + 5 : fIH = 1 MHz + Other than above : Setting prohibited + */ +#define BSP_CFG_HOCO_DIVIDE (0) + +/* Setting for starting the high-speed on-chip oscillator at the times of release from STOP mode + and of transitions to SNOOZE mode + Standby mode release setting register(WKUPMD) + FWKUP + 0 : Starting of the high-speed on-chip oscillator is at normal speed. + 1 : Starting of the high-speed on-chip oscillator is at high speed. +*/ +#define BSP_CFG_WAKEUP_MODE (1) + +/* Selected division ratio for the high-speed system clock + High-speed system clock division register(MOSCDIV) + MOSCDIV2, MOSCDIV1, MOSCDIV0 + 0 : fMX (fMX = 20MHz : 20MHz) + 1 : fMX/2 (fMX = 20MHz : 10MHz) + 2 : fMX/4 (fMX = 20MHz : 5MHz) + 3 : fMX/8 (fMX = 20MHz : 2.5MHz) + 4 : fMX/16 (fMX = 20MHz : 1.25MHz) + Other than above : Setting prohibited +*/ +#define BSP_CFG_MOSC_DIVIDE (0) + +/* Selection of the middle-speed on-chip oscillator clock frequency + Middle-speed on-chip oscillator frequency select register(MOCODIV) + MOCODIV1, MOCODIV0 + 0 : 4MHz + 1 : 2MHz + 2 : 1MHz + Other than above : Setting prohibited +*/ +#define BSP_CFG_MOCO_DIVIDE (0) + +/* Operation setting at initial setting */ +/* Starts the high-speed on-chip oscillator at initialization + 0 : Stops the high-speed on-chip oscillator at initialization + 1 : Starts the high-speed on-chip oscillator at initialization +*/ +#define BSP_CFG_FIH_START_ON_STARTUP (1) + +/* This macro lets other modules no if a RTOS is being used. + 0 : RTOS is not used. + 1 : FreeRTOS is used.(This is not available.) + 2 : embOS is used.(This is not available.) + 3 : MicroC_OS is used.(This is not available.) + 4 : Renesas ITRON is used. +*/ +#define BSP_CFG_RTOS_USED (0) + +/* Loop count using the main system clock. */ +/* The loop count refers to a loop consisting of a "for" statement that executes a single NOP instruction. */ +/* Subsystem clock oscillation stabilization wait time */ +/* If the main system clock is 32 MHz, 800000 means 550 ms. */ +#define BSP_CFG_SUBWAITTIME (800000U) + +/* High-speed on-chip oscillator clock oscillation stabilization wait time */ +/* If the main system clock 32 MHz, 30 means 22.7us. */ +#define BSP_CFG_FIHWAITTIME (30U) + +/* Middle-speed on-chip oscillator clock oscillation stabilization wait time. */ +/* If the main system clock 32 MHz, 5 means 4.8us. */ +#define BSP_CFG_FIMWAITTIME (5U) + +/* Low-speed on-chip oscillator clock oscillation stabilization wait time */ +/* If the main system clock 32 MHz, 450 means 325us. */ +#define BSP_CFG_FILWAITTIME (450U) + +/* If the user would like to determine if a warm start reset has occurred, then they may enable one or more of the + following callback definitions AND provide a call back function name for the respective callback + function (to be defined by the user). Setting BSP_CFG_USER_WARM_START_CALLBACK_PRE_INITC_ENABLED = 1 will result + in a callback to the user defined my_sw_warmstart_prec_function just prior to the initialization of the C + runtime environment by bsp_init_system. + Setting BSP_CFG_USER_WARM_START_CALLBACK_POST_INITC_ENABLED = 1 will result in a callback to the user defined + my_sw_warmstart_postc_function just after the initialization of the C runtime environment by bsp_init_hardware. +*/ +#define BSP_CFG_USER_WARM_START_CALLBACK_PRE_INITC_ENABLED (0) +#define BSP_CFG_USER_WARM_START_PRE_C_FUNCTION my_sw_warmstart_prec_function + +#define BSP_CFG_USER_WARM_START_CALLBACK_POST_INITC_ENABLED (0) +#define BSP_CFG_USER_WARM_START_POST_C_FUNCTION my_sw_warmstart_postc_function + +/* If the user sets the window open period of watchdog timer to 50%, + set the following macro definition(BSP_CFG_WDT_REFRESH_ENABLE) to 2 + and specify the callback function name for each callback function(to be defined by the user). + Setting BSP_CFG_WDT_REFRESH_ENABLE == 2 will result in a callback to the user defined + my_sw_wdt_refresh_init_function just prior to the clock is set by bsp_init_system. + In addition, a callback to the user defined my_sw_wdt_refresh_setting_function occurs + during the oscillation stabilization wait time od the subsystem clock. +*/ +#define BSP_CFG_WDT_REFRESH_ENABLE (0) +#define BSP_CFG_USER_WDT_REFRESH_INIT_FUNCTION my_sw_wdt_refresh_init_function +#define BSP_CFG_USER_WDT_REFRESH_SETTING_FUNCTION my_sw_wdt_refresh_setting_function + +#endif /* R_BSP_CONFIG_REF_HEADER_FILE */ + diff --git a/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp_config_reference_ccrl.inc b/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp_config_reference_ccrl.inc index af1448e..63e62d0 100644 --- a/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp_config_reference_ccrl.inc +++ b/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp_config_reference_ccrl.inc @@ -1,36 +1,36 @@ -;;/*********************************************************************************************************************** -;;* DISCLAIMER -;;* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -;;* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -;;* applicable laws, including copyright laws. -;;* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -;;* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -;;* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -;;* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -;;* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -;;* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -;;* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -;;* this software. By using this software, you agree to the additional terms and conditions found by accessing the -;;* following link: -;;* http://www.renesas.com/disclaimer -;;* -;;* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. -;;***********************************************************************************************************************/ -;;/*********************************************************************************************************************** -;;* File Name : r_bsp_config_reference.inc -;;* H/W Platform : GENERIC_RL78_G22 -;;* Description : -;;***********************************************************************************************************************/ -;;/*********************************************************************************************************************** -;;* History : DD.MM.YYYY Version Description -;;* : 20.04.2022 1.50 First Release -;;* -;;***********************************************************************************************************************/ - -$IFDEF __r_bsp_config_inc__ -$ELSE - -__r_bsp_config_inc__ .EQU 1 -BSP_CFG_ASM_RTOS_USED .EQU 0 - -$ENDIF ; __r_bsp_config_inc__ +;;/*********************************************************************************************************************** +;;* DISCLAIMER +;;* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +;;* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +;;* applicable laws, including copyright laws. +;;* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +;;* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +;;* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +;;* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +;;* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +;;* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;;* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +;;* this software. By using this software, you agree to the additional terms and conditions found by accessing the +;;* following link: +;;* http://www.renesas.com/disclaimer +;;* +;;* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. +;;***********************************************************************************************************************/ +;;/*********************************************************************************************************************** +;;* File Name : r_bsp_config_reference.inc +;;* H/W Platform : GENERIC_RL78_G22 +;;* Description : +;;***********************************************************************************************************************/ +;;/*********************************************************************************************************************** +;;* History : DD.MM.YYYY Version Description +;;* : 20.04.2022 1.50 First Release +;;* +;;***********************************************************************************************************************/ + +$IFDEF __r_bsp_config_inc__ +$ELSE + +__r_bsp_config_inc__ .EQU 1 +BSP_CFG_ASM_RTOS_USED .EQU 0 + +$ENDIF ; __r_bsp_config_inc__ diff --git a/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp_config_reference_iccrl.inc b/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp_config_reference_iccrl.inc index 50e4bb1..6179b99 100644 --- a/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp_config_reference_iccrl.inc +++ b/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp_config_reference_iccrl.inc @@ -1,36 +1,36 @@ -;;/*********************************************************************************************************************** -;;* DISCLAIMER -;;* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -;;* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -;;* applicable laws, including copyright laws. -;;* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -;;* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -;;* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -;;* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -;;* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -;;* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -;;* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -;;* this software. By using this software, you agree to the additional terms and conditions found by accessing the -;;* following link: -;;* http://www.renesas.com/disclaimer -;;* -;;* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. -;;***********************************************************************************************************************/ -;;/*********************************************************************************************************************** -;;* File Name : r_bsp_config_reference.inc -;;* H/W Platform : GENERIC_RL78_G22 -;;* Description : -;;***********************************************************************************************************************/ -;;/*********************************************************************************************************************** -;;* History : DD.MM.YYYY Version Description -;;* : 20.04.2022 1.50 First Release -;;* -;;***********************************************************************************************************************/ - -#ifdef __r_bsp_config_inc__ -#else - -#define __r_bsp_config_inc__ (1) -#define BSP_CFG_ASM_RTOS_USED (0) - -#endif +;;/*********************************************************************************************************************** +;;* DISCLAIMER +;;* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +;;* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +;;* applicable laws, including copyright laws. +;;* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +;;* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +;;* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +;;* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +;;* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +;;* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;;* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +;;* this software. By using this software, you agree to the additional terms and conditions found by accessing the +;;* following link: +;;* http://www.renesas.com/disclaimer +;;* +;;* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. +;;***********************************************************************************************************************/ +;;/*********************************************************************************************************************** +;;* File Name : r_bsp_config_reference.inc +;;* H/W Platform : GENERIC_RL78_G22 +;;* Description : +;;***********************************************************************************************************************/ +;;/*********************************************************************************************************************** +;;* History : DD.MM.YYYY Version Description +;;* : 20.04.2022 1.50 First Release +;;* +;;***********************************************************************************************************************/ + +#ifdef __r_bsp_config_inc__ +#else + +#define __r_bsp_config_inc__ (1) +#define BSP_CFG_ASM_RTOS_USED (0) + +#endif diff --git a/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp_config_reference_llvm.inc b/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp_config_reference_llvm.inc index c32675a..802abe9 100644 --- a/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp_config_reference_llvm.inc +++ b/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp_config_reference_llvm.inc @@ -1,36 +1,36 @@ -;;/*********************************************************************************************************************** -;;* DISCLAIMER -;;* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -;;* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -;;* applicable laws, including copyright laws. -;;* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -;;* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -;;* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -;;* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -;;* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -;;* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -;;* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -;;* this software. By using this software, you agree to the additional terms and conditions found by accessing the -;;* following link: -;;* http://www.renesas.com/disclaimer -;;* -;;* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. -;;***********************************************************************************************************************/ -;;/*********************************************************************************************************************** -;;* File Name : r_bsp_config_reference.inc -;;* H/W Platform : GENERIC_RL78_G22 -;;* Description : -;;***********************************************************************************************************************/ -;;/*********************************************************************************************************************** -;;* History : DD.MM.YYYY Version Description -;;* : 20.04.2022 1.50 First Release -;;* -;;***********************************************************************************************************************/ - -.ifdef __r_bsp_config_inc__ -.else - -.equ __r_bsp_config_inc__,(1) -.equ BSP_CFG_ASM_RTOS_USED, (0) - -.endif +;;/*********************************************************************************************************************** +;;* DISCLAIMER +;;* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +;;* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +;;* applicable laws, including copyright laws. +;;* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +;;* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +;;* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +;;* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +;;* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +;;* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;;* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +;;* this software. By using this software, you agree to the additional terms and conditions found by accessing the +;;* following link: +;;* http://www.renesas.com/disclaimer +;;* +;;* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. +;;***********************************************************************************************************************/ +;;/*********************************************************************************************************************** +;;* File Name : r_bsp_config_reference.inc +;;* H/W Platform : GENERIC_RL78_G22 +;;* Description : +;;***********************************************************************************************************************/ +;;/*********************************************************************************************************************** +;;* History : DD.MM.YYYY Version Description +;;* : 20.04.2022 1.50 First Release +;;* +;;***********************************************************************************************************************/ + +.ifdef __r_bsp_config_inc__ +.else + +.equ __r_bsp_config_inc__,(1) +.equ BSP_CFG_ASM_RTOS_USED, (0) + +.endif diff --git a/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp_init.c b/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp_init.c index b33a2a5..2b1ecb3 100644 --- a/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp_init.c +++ b/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22/r_bsp_init.c @@ -1,113 +1,113 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -* this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* File Name : r_bsp_init.c -* H/W Platform : GENERIC_RL78_G22 -* Description : -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* History : DD.MM.YYYY Version Description -* : 20.04.2022 1.50 First Release -***********************************************************************************************************************/ -/************************************************* - * Includes , "Project Includes" - *************************************************/ -#include "platform.h" - -/************************************************* - * Macro definitions - *************************************************/ - -/************************************************* - * External function Prototypes - *************************************************/ - -#if BSP_CFG_USER_WARM_START_CALLBACK_PRE_INITC_ENABLED != 0 -/* If user is requesting warm start callback functions then these are the prototypes. */ -void BSP_CFG_USER_WARM_START_PRE_C_FUNCTION (void); -#endif - -#if BSP_CFG_USER_WARM_START_CALLBACK_POST_INITC_ENABLED != 0 -/* If user is requesting warm start callback functions then these are the prototypes. */ -void BSP_CFG_USER_WARM_START_POST_C_FUNCTION (void); -#endif - -#if BSP_CFG_WDT_REFRESH_ENABLE == 2 -/* If user is requesting Watchdog Timer callback functions then these are the prototypes. */ -void BSP_CFG_USER_WDT_REFRESH_INIT_FUNCTION (void); -#endif - -/* This prototype is used to suppress the warning message of LLVM compiler. */ -void bsp_init_system (void); - -/* This prototype is used to suppress the warning message of LLVM compiler. */ -void bsp_init_hardware (void); - -/************************************************* - * Private global variables and functions - *************************************************/ - -/************************************************* - * Function definition - *************************************************/ -/************************************************* - * Function name: bsp_init_system - * Description : BSP initial setting(clock) - * Arguments : none - * Return value : none -**************************************************/ -void bsp_init_system (void) -{ - /* Pin setting */ - PIOR = BSP_CFG_PIOR0 | (BSP_CFG_PIOR1 << 1U) | (BSP_CFG_PIOR2 << 2U) | - (BSP_CFG_PIOR3 << 3U); - - - /* If the window open period of watchdog timer is set to 50%, then call it. */ -#if BSP_CFG_WDT_REFRESH_ENABLE == 2 - BSP_CFG_USER_WDT_REFRESH_INIT_FUNCTION(); -#endif - - /* Clock initialization */ -#if BSP_CFG_STARTUP_DISABLE == 0 - mcu_clock_setup(); -#endif - - /* If the warm start Pre C runtime callback is enabled, then call it. */ -#if BSP_CFG_USER_WARM_START_CALLBACK_PRE_INITC_ENABLED == 1 - BSP_CFG_USER_WARM_START_PRE_C_FUNCTION(); -#endif -} /* End of function bsp_init_system() */ - -/************************************************* - * Function name: bsp_init_hardware - * Description : BSP initial setting(Peripheral functions) - * Arguments : none - * Return value : none -**************************************************/ -void bsp_init_hardware (void) -{ - /* If the warm start Post C runtime callback is enabled, the call it. */ -#if BSP_CFG_USER_WARM_START_CALLBACK_POST_INITC_ENABLED == 1 - BSP_CFG_USER_WARM_START_POST_C_FUNCTION(); -#endif - - /* Peripheral function initialization */ - hdwinit(); -} /* End of function bsp_init_hardware() */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +* this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* File Name : r_bsp_init.c +* H/W Platform : GENERIC_RL78_G22 +* Description : +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* History : DD.MM.YYYY Version Description +* : 20.04.2022 1.50 First Release +***********************************************************************************************************************/ +/************************************************* + * Includes , "Project Includes" + *************************************************/ +#include "platform.h" + +/************************************************* + * Macro definitions + *************************************************/ + +/************************************************* + * External function Prototypes + *************************************************/ + +#if BSP_CFG_USER_WARM_START_CALLBACK_PRE_INITC_ENABLED != 0 +/* If user is requesting warm start callback functions then these are the prototypes. */ +void BSP_CFG_USER_WARM_START_PRE_C_FUNCTION (void); +#endif + +#if BSP_CFG_USER_WARM_START_CALLBACK_POST_INITC_ENABLED != 0 +/* If user is requesting warm start callback functions then these are the prototypes. */ +void BSP_CFG_USER_WARM_START_POST_C_FUNCTION (void); +#endif + +#if BSP_CFG_WDT_REFRESH_ENABLE == 2 +/* If user is requesting Watchdog Timer callback functions then these are the prototypes. */ +void BSP_CFG_USER_WDT_REFRESH_INIT_FUNCTION (void); +#endif + +/* This prototype is used to suppress the warning message of LLVM compiler. */ +void bsp_init_system (void); + +/* This prototype is used to suppress the warning message of LLVM compiler. */ +void bsp_init_hardware (void); + +/************************************************* + * Private global variables and functions + *************************************************/ + +/************************************************* + * Function definition + *************************************************/ +/************************************************* + * Function name: bsp_init_system + * Description : BSP initial setting(clock) + * Arguments : none + * Return value : none +**************************************************/ +void bsp_init_system (void) +{ + /* Pin setting */ + PIOR = BSP_CFG_PIOR0 | (BSP_CFG_PIOR1 << 1U) | (BSP_CFG_PIOR2 << 2U) | + (BSP_CFG_PIOR3 << 3U); + + + /* If the window open period of watchdog timer is set to 50%, then call it. */ +#if BSP_CFG_WDT_REFRESH_ENABLE == 2 + BSP_CFG_USER_WDT_REFRESH_INIT_FUNCTION(); +#endif + + /* Clock initialization */ +#if BSP_CFG_STARTUP_DISABLE == 0 + mcu_clock_setup(); +#endif + + /* If the warm start Pre C runtime callback is enabled, then call it. */ +#if BSP_CFG_USER_WARM_START_CALLBACK_PRE_INITC_ENABLED == 1 + BSP_CFG_USER_WARM_START_PRE_C_FUNCTION(); +#endif +} /* End of function bsp_init_system() */ + +/************************************************* + * Function name: bsp_init_hardware + * Description : BSP initial setting(Peripheral functions) + * Arguments : none + * Return value : none +**************************************************/ +void bsp_init_hardware (void) +{ + /* If the warm start Post C runtime callback is enabled, the call it. */ +#if BSP_CFG_USER_WARM_START_CALLBACK_POST_INITC_ENABLED == 1 + BSP_CFG_USER_WARM_START_POST_C_FUNCTION(); +#endif + + /* Peripheral function initialization */ + hdwinit(); +} /* End of function bsp_init_hardware() */ diff --git a/cores/rl78g22/smc_gen/r_bsp/mcu/all/fsp_common_api.h b/cores/rl78g22/smc_gen/r_bsp/mcu/all/fsp_common_api.h index 2198d65..88d9698 100644 --- a/cores/rl78g22/smc_gen/r_bsp/mcu/all/fsp_common_api.h +++ b/cores/rl78g22/smc_gen/r_bsp/mcu/all/fsp_common_api.h @@ -1,176 +1,176 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -* this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2021 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* File Name : fsp_common_api.h -* Description : -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* History : DD.MM.YYYY Version Description -* : 08.09.2021 1.00 First Release -* : 28.02.2022 1.20 Added the following common error codes. -* - FSP_ERR_CTSU_SCANNING -* - FSP_ERR_CTSU_NOT_GET_DATA -* - FSP_ERR_CTSU_INCOMPLETE_TUNING -* - FSP_ERR_CTSU_DIAG_NOT_YET -* - FSP_ERR_CTSU_DIAG_LDO_OVER_VOLTAGE -* - FSP_ERR_CTSU_DIAG_CCO_HIGH -* - FSP_ERR_CTSU_DIAG_CCO_LOW -* - FSP_ERR_CTSU_DIAG_SSCG -* - FSP_ERR_CTSU_DIAG_DAC -* - FSP_ERR_CTSU_DIAG_OUTPUT_VOLTAGE -* - FSP_ERR_CTSU_DIAG_OVER_VOLTAGE -* - FSP_ERR_CTSU_DIAG_OVER_CURRENT -* - FSP_ERR_CTSU_DIAG_LOAD_RESISTANCE -* - FSP_ERR_CTSU_DIAG_CURRENT_SOURCE -* - FSP_ERR_CTSU_DIAG_SENSCLK_GAIN -* - FSP_ERR_CTSU_DIAG_SUCLK_GAIN -* - FSP_ERR_CTSU_DIAG_CLOCK_RECOVERY -* - FSP_ERR_CTSU_DIAG_CFC_GAIN -***********************************************************************************************************************/ - -/* ${REA_DISCLAIMER_PLACEHOLDER} */ - -#ifndef FSP_COMMON_API_H -#define FSP_COMMON_API_H - -/*********************************************************************************************************************** - * Includes - **********************************************************************************************************************/ -#include -#include - -/*******************************************************************************************************************//** - * @ingroup RENESAS_COMMON - * @defgroup RENESAS_ERROR_CODES Common Error Codes - * All FSP modules share these common error codes. - * @{ - **********************************************************************************************************************/ - -/********************************************************************************************************************** - * Macro definitions - **********************************************************************************************************************/ - -/** This macro is used to suppress compiler messages about a parameter not being used in a function. The nice thing - * about using this implementation is that it does not take any extra RAM or ROM. */ - -#define FSP_PARAMETER_NOT_USED(p) (void) ((p)) - -/** Determine if a C++ compiler is being used. - * If so, ensure that standard C is used to process the API information. */ -#if defined(__cplusplus) - #define FSP_CPP_HEADER extern "C" { - #define FSP_CPP_FOOTER } -#else - #define FSP_CPP_HEADER - #define FSP_CPP_FOOTER -#endif - -/** FSP Header and Footer definitions */ -#define FSP_HEADER FSP_CPP_HEADER -#define FSP_FOOTER FSP_CPP_FOOTER - -/** Macro to be used when argument to function is ignored since function call is NSC and the parameter is statically - * defined on the Secure side. */ -#define FSP_SECURE_ARGUMENT (NULL) - -/********************************************************************************************************************** - * Typedef definitions - **********************************************************************************************************************/ - -/** Common error codes */ -typedef enum e_fsp_err -{ - FSP_SUCCESS = 0, - - FSP_ERR_ASSERTION = 1, ///< A critical assertion has failed - FSP_ERR_INVALID_POINTER = 2, ///< Pointer points to invalid memory location - FSP_ERR_INVALID_ARGUMENT = 3, ///< Invalid input parameter - FSP_ERR_INVALID_CHANNEL = 4, ///< Selected channel does not exist - FSP_ERR_INVALID_MODE = 5, ///< Unsupported or incorrect mode - FSP_ERR_UNSUPPORTED = 6, ///< Selected mode not supported by this API - FSP_ERR_NOT_OPEN = 7, ///< Requested channel is not configured or API not open - FSP_ERR_IN_USE = 8, ///< Channel/peripheral is running/busy - FSP_ERR_OUT_OF_MEMORY = 9, ///< Allocate more memory in the driver's cfg.h - FSP_ERR_HW_LOCKED = 10, ///< Hardware is locked - FSP_ERR_IRQ_BSP_DISABLED = 11, ///< IRQ not enabled in BSP - FSP_ERR_OVERFLOW = 12, ///< Hardware overflow - FSP_ERR_UNDERFLOW = 13, ///< Hardware underflow - FSP_ERR_ALREADY_OPEN = 14, ///< Requested channel is already open in a different configuration - FSP_ERR_APPROXIMATION = 15, ///< Could not set value to exact result - FSP_ERR_CLAMPED = 16, ///< Value had to be limited for some reason - FSP_ERR_INVALID_RATE = 17, ///< Selected rate could not be met - FSP_ERR_ABORTED = 18, ///< An operation was aborted - FSP_ERR_NOT_ENABLED = 19, ///< Requested operation is not enabled - FSP_ERR_TIMEOUT = 20, ///< Timeout error - FSP_ERR_INVALID_BLOCKS = 21, ///< Invalid number of blocks supplied - FSP_ERR_INVALID_ADDRESS = 22, ///< Invalid address supplied - FSP_ERR_INVALID_SIZE = 23, ///< Invalid size/length supplied for operation - FSP_ERR_WRITE_FAILED = 24, ///< Write operation failed - FSP_ERR_ERASE_FAILED = 25, ///< Erase operation failed - FSP_ERR_INVALID_CALL = 26, ///< Invalid function call is made - FSP_ERR_INVALID_HW_CONDITION = 27, ///< Detected hardware is in invalid condition - FSP_ERR_INVALID_FACTORY_FLASH = 28, ///< Factory flash is not available on this MCU - FSP_ERR_INVALID_STATE = 30, ///< API or command not valid in the current state - FSP_ERR_NOT_ERASED = 31, ///< Erase verification failed - FSP_ERR_SECTOR_RELEASE_FAILED = 32, ///< Sector release failed - FSP_ERR_NOT_INITIALIZED = 33, ///< Required initialization not complete - FSP_ERR_NOT_FOUND = 34, ///< The requested item could not be found - FSP_ERR_NO_CALLBACK_MEMORY = 35, ///< Non-secure callback memory not provided for non-secure callback - FSP_ERR_BUFFER_EMPTY = 36, ///< No data available in buffer - - /* Start of RTOS only error codes */ - FSP_ERR_INTERNAL = 100, ///< Internal error - FSP_ERR_WAIT_ABORTED = 101, ///< Wait aborted - - /* Start of Sensor specific */ - FSP_ERR_SENSOR_INVALID_DATA, ///< Data is invalid. - FSP_ERR_SENSOR_IN_STABILIZATION, ///< Sensor is stabilizing. - FSP_ERR_SENSOR_MEASUREMENT_NOT_FINISHED, ///< Measurement is not finished. - - /* Start of CTSU Driver specific */ - FSP_ERR_CTSU_SCANNING = 6000, ///< Scanning. - FSP_ERR_CTSU_NOT_GET_DATA = 6001, ///< Not processed previous scan data. - FSP_ERR_CTSU_INCOMPLETE_TUNING = 6002, ///< Incomplete initial offset tuning. - FSP_ERR_CTSU_DIAG_NOT_YET = 6003, ///< Diagnosis of data collected no yet. - FSP_ERR_CTSU_DIAG_LDO_OVER_VOLTAGE = 6004, ///< Diagnosis of LDO over voltage failed. - FSP_ERR_CTSU_DIAG_CCO_HIGH = 6005, ///< Diagnosis of CCO into 19.2uA failed. - FSP_ERR_CTSU_DIAG_CCO_LOW = 6006, ///< Diagnosis of CCO into 2.4uA failed. - FSP_ERR_CTSU_DIAG_SSCG = 6007, ///< Diagnosis of SSCG frequency failed. - FSP_ERR_CTSU_DIAG_DAC = 6008, ///< Diagnosis of non-touch count value failed. - FSP_ERR_CTSU_DIAG_OUTPUT_VOLTAGE = 6009, ///< Diagnosis of LDO output voltage failed. - FSP_ERR_CTSU_DIAG_OVER_VOLTAGE = 6010, ///< Diagnosis of over voltage detection circuit failed. - FSP_ERR_CTSU_DIAG_OVER_CURRENT = 6011, ///< Diagnosis of over current detection circuit failed. - FSP_ERR_CTSU_DIAG_LOAD_RESISTANCE = 6012, ///< Diagnosis of LDO internal resistance value failed. - FSP_ERR_CTSU_DIAG_CURRENT_SOURCE = 6013, ///< Diagnosis of Current source value failed. - FSP_ERR_CTSU_DIAG_SENSCLK_GAIN = 6014, ///< Diagnosis of SENSCLK frequency gain failed. - FSP_ERR_CTSU_DIAG_SUCLK_GAIN = 6015, ///< Diagnosis of SUCLK frequency gain failed. - FSP_ERR_CTSU_DIAG_CLOCK_RECOVERY = 6016, ///< Diagnosis of SUCLK clock recovery function failed. - FSP_ERR_CTSU_DIAG_CFC_GAIN = 6017, ///< Diagnosis of CFC oscillator gain failed. - - /* Start of COMMS specific */ - FSP_ERR_COMMS_BUS_NOT_OPEN, ///< Bus is not open. -} fsp_err_t; - -/** @} */ - -/*********************************************************************************************************************** - * Function prototypes - **********************************************************************************************************************/ - -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +* this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* File Name : fsp_common_api.h +* Description : +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* History : DD.MM.YYYY Version Description +* : 08.09.2021 1.00 First Release +* : 28.02.2022 1.20 Added the following common error codes. +* - FSP_ERR_CTSU_SCANNING +* - FSP_ERR_CTSU_NOT_GET_DATA +* - FSP_ERR_CTSU_INCOMPLETE_TUNING +* - FSP_ERR_CTSU_DIAG_NOT_YET +* - FSP_ERR_CTSU_DIAG_LDO_OVER_VOLTAGE +* - FSP_ERR_CTSU_DIAG_CCO_HIGH +* - FSP_ERR_CTSU_DIAG_CCO_LOW +* - FSP_ERR_CTSU_DIAG_SSCG +* - FSP_ERR_CTSU_DIAG_DAC +* - FSP_ERR_CTSU_DIAG_OUTPUT_VOLTAGE +* - FSP_ERR_CTSU_DIAG_OVER_VOLTAGE +* - FSP_ERR_CTSU_DIAG_OVER_CURRENT +* - FSP_ERR_CTSU_DIAG_LOAD_RESISTANCE +* - FSP_ERR_CTSU_DIAG_CURRENT_SOURCE +* - FSP_ERR_CTSU_DIAG_SENSCLK_GAIN +* - FSP_ERR_CTSU_DIAG_SUCLK_GAIN +* - FSP_ERR_CTSU_DIAG_CLOCK_RECOVERY +* - FSP_ERR_CTSU_DIAG_CFC_GAIN +***********************************************************************************************************************/ + +/* ${REA_DISCLAIMER_PLACEHOLDER} */ + +#ifndef FSP_COMMON_API_H +#define FSP_COMMON_API_H + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include +#include + +/*******************************************************************************************************************//** + * @ingroup RENESAS_COMMON + * @defgroup RENESAS_ERROR_CODES Common Error Codes + * All FSP modules share these common error codes. + * @{ + **********************************************************************************************************************/ + +/********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/** This macro is used to suppress compiler messages about a parameter not being used in a function. The nice thing + * about using this implementation is that it does not take any extra RAM or ROM. */ + +#define FSP_PARAMETER_NOT_USED(p) (void) ((p)) + +/** Determine if a C++ compiler is being used. + * If so, ensure that standard C is used to process the API information. */ +#if defined(__cplusplus) + #define FSP_CPP_HEADER extern "C" { + #define FSP_CPP_FOOTER } +#else + #define FSP_CPP_HEADER + #define FSP_CPP_FOOTER +#endif + +/** FSP Header and Footer definitions */ +#define FSP_HEADER FSP_CPP_HEADER +#define FSP_FOOTER FSP_CPP_FOOTER + +/** Macro to be used when argument to function is ignored since function call is NSC and the parameter is statically + * defined on the Secure side. */ +#define FSP_SECURE_ARGUMENT (NULL) + +/********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ + +/** Common error codes */ +typedef enum e_fsp_err +{ + FSP_SUCCESS = 0, + + FSP_ERR_ASSERTION = 1, ///< A critical assertion has failed + FSP_ERR_INVALID_POINTER = 2, ///< Pointer points to invalid memory location + FSP_ERR_INVALID_ARGUMENT = 3, ///< Invalid input parameter + FSP_ERR_INVALID_CHANNEL = 4, ///< Selected channel does not exist + FSP_ERR_INVALID_MODE = 5, ///< Unsupported or incorrect mode + FSP_ERR_UNSUPPORTED = 6, ///< Selected mode not supported by this API + FSP_ERR_NOT_OPEN = 7, ///< Requested channel is not configured or API not open + FSP_ERR_IN_USE = 8, ///< Channel/peripheral is running/busy + FSP_ERR_OUT_OF_MEMORY = 9, ///< Allocate more memory in the driver's cfg.h + FSP_ERR_HW_LOCKED = 10, ///< Hardware is locked + FSP_ERR_IRQ_BSP_DISABLED = 11, ///< IRQ not enabled in BSP + FSP_ERR_OVERFLOW = 12, ///< Hardware overflow + FSP_ERR_UNDERFLOW = 13, ///< Hardware underflow + FSP_ERR_ALREADY_OPEN = 14, ///< Requested channel is already open in a different configuration + FSP_ERR_APPROXIMATION = 15, ///< Could not set value to exact result + FSP_ERR_CLAMPED = 16, ///< Value had to be limited for some reason + FSP_ERR_INVALID_RATE = 17, ///< Selected rate could not be met + FSP_ERR_ABORTED = 18, ///< An operation was aborted + FSP_ERR_NOT_ENABLED = 19, ///< Requested operation is not enabled + FSP_ERR_TIMEOUT = 20, ///< Timeout error + FSP_ERR_INVALID_BLOCKS = 21, ///< Invalid number of blocks supplied + FSP_ERR_INVALID_ADDRESS = 22, ///< Invalid address supplied + FSP_ERR_INVALID_SIZE = 23, ///< Invalid size/length supplied for operation + FSP_ERR_WRITE_FAILED = 24, ///< Write operation failed + FSP_ERR_ERASE_FAILED = 25, ///< Erase operation failed + FSP_ERR_INVALID_CALL = 26, ///< Invalid function call is made + FSP_ERR_INVALID_HW_CONDITION = 27, ///< Detected hardware is in invalid condition + FSP_ERR_INVALID_FACTORY_FLASH = 28, ///< Factory flash is not available on this MCU + FSP_ERR_INVALID_STATE = 30, ///< API or command not valid in the current state + FSP_ERR_NOT_ERASED = 31, ///< Erase verification failed + FSP_ERR_SECTOR_RELEASE_FAILED = 32, ///< Sector release failed + FSP_ERR_NOT_INITIALIZED = 33, ///< Required initialization not complete + FSP_ERR_NOT_FOUND = 34, ///< The requested item could not be found + FSP_ERR_NO_CALLBACK_MEMORY = 35, ///< Non-secure callback memory not provided for non-secure callback + FSP_ERR_BUFFER_EMPTY = 36, ///< No data available in buffer + + /* Start of RTOS only error codes */ + FSP_ERR_INTERNAL = 100, ///< Internal error + FSP_ERR_WAIT_ABORTED = 101, ///< Wait aborted + + /* Start of Sensor specific */ + FSP_ERR_SENSOR_INVALID_DATA, ///< Data is invalid. + FSP_ERR_SENSOR_IN_STABILIZATION, ///< Sensor is stabilizing. + FSP_ERR_SENSOR_MEASUREMENT_NOT_FINISHED, ///< Measurement is not finished. + + /* Start of CTSU Driver specific */ + FSP_ERR_CTSU_SCANNING = 6000, ///< Scanning. + FSP_ERR_CTSU_NOT_GET_DATA = 6001, ///< Not processed previous scan data. + FSP_ERR_CTSU_INCOMPLETE_TUNING = 6002, ///< Incomplete initial offset tuning. + FSP_ERR_CTSU_DIAG_NOT_YET = 6003, ///< Diagnosis of data collected no yet. + FSP_ERR_CTSU_DIAG_LDO_OVER_VOLTAGE = 6004, ///< Diagnosis of LDO over voltage failed. + FSP_ERR_CTSU_DIAG_CCO_HIGH = 6005, ///< Diagnosis of CCO into 19.2uA failed. + FSP_ERR_CTSU_DIAG_CCO_LOW = 6006, ///< Diagnosis of CCO into 2.4uA failed. + FSP_ERR_CTSU_DIAG_SSCG = 6007, ///< Diagnosis of SSCG frequency failed. + FSP_ERR_CTSU_DIAG_DAC = 6008, ///< Diagnosis of non-touch count value failed. + FSP_ERR_CTSU_DIAG_OUTPUT_VOLTAGE = 6009, ///< Diagnosis of LDO output voltage failed. + FSP_ERR_CTSU_DIAG_OVER_VOLTAGE = 6010, ///< Diagnosis of over voltage detection circuit failed. + FSP_ERR_CTSU_DIAG_OVER_CURRENT = 6011, ///< Diagnosis of over current detection circuit failed. + FSP_ERR_CTSU_DIAG_LOAD_RESISTANCE = 6012, ///< Diagnosis of LDO internal resistance value failed. + FSP_ERR_CTSU_DIAG_CURRENT_SOURCE = 6013, ///< Diagnosis of Current source value failed. + FSP_ERR_CTSU_DIAG_SENSCLK_GAIN = 6014, ///< Diagnosis of SENSCLK frequency gain failed. + FSP_ERR_CTSU_DIAG_SUCLK_GAIN = 6015, ///< Diagnosis of SUCLK frequency gain failed. + FSP_ERR_CTSU_DIAG_CLOCK_RECOVERY = 6016, ///< Diagnosis of SUCLK clock recovery function failed. + FSP_ERR_CTSU_DIAG_CFC_GAIN = 6017, ///< Diagnosis of CFC oscillator gain failed. + + /* Start of COMMS specific */ + FSP_ERR_COMMS_BUS_NOT_OPEN, ///< Bus is not open. +} fsp_err_t; + +/** @} */ + +/*********************************************************************************************************************** + * Function prototypes + **********************************************************************************************************************/ + +#endif diff --git a/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_bsp_common.c b/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_bsp_common.c index 50d346a..19ae8e0 100644 --- a/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_bsp_common.c +++ b/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_bsp_common.c @@ -1,258 +1,258 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -* this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2021 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* File Name : r_bsp_common.c -* Description : -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* History : DD.MM.YYYY Version Description -* : 08.03.2021 1.00 First Release -* : 28.02.2022 1.20 Added the following function. -* - R_BSP_ChangeClockSetting -* Changed to enable/disable for each API function. -* : 31.05.2022 1.30 Added the following function. -* - R_BSP_SoftwareDelay -***********************************************************************************************************************/ - -/************************************************* - * Includes , "Project Includes" - *************************************************/ -#include "platform.h" - -/************************************************* - * Macro definitions - *************************************************/ -#define BSP_PRV_OVERHEAD_CYCLES (1000U) /* R_BSP_SoftwareDelay() overhead per call */ -#define BSP_PRV_OVERHEAD_CYCLES_64 (1000U) /* R_BSP_SoftwareDelay() overhead per call using 64-bit ints */ -#define BSP_CPU_CYCLES_PER_LOOP (6U) - -/************************************************* - * Private global variables and functions - *************************************************/ -/* Delay time definition table */ -#if BSP_CFG_SOFTWARE_DELAY_API_FUNCTIONS_DISABLE == 0 -const unsigned long long bsp_delay_time[] = { - 1, - 1000, - 1000000 -}; -#endif - -/************************************************* - * Function definition - *************************************************/ -extern void delay_wait (uint32_t count); - -/********************************************************************************************************************** - * Function Name: R_BSP_StartClock - ******************************************************************************************************************//** - * @brief Start the specified clock and return. - * @param[in] mode Clock to start. - * @retval BSP_OK BSP_OK if the specified clock is started. - * @retval BSP_ARG_ERROR BSP_ARG_ERROR if the specified clock is incorrect. - * @details This function starts the specified clock. - * Specify one of the following for mode. - * HIOCLK : High-speed on-chip oscillator - * SYSCLK : High-speed system clock - * SXCLK : Subsystem clock - * MIOCLK : Middle-speed on-chip oscillator - * LOCLK : Low-speed on-chip oscillator - */ -#if BSP_CFG_CLOCK_OPERATION_API_FUNCTIONS_DISABLE == 0 -e_bsp_err_t R_BSP_StartClock(e_clock_mode_t mode) -{ - return (start_clock(mode)); -} /* End of function R_BSP_StartClock() */ -#endif - -/********************************************************************************************************************** - * Function Name: R_BSP_StopClock - ******************************************************************************************************************//** - * @brief Stop the specified clock and return. - * @param[in] mode Clock to stop. - * @retval BSP_OK BSP_OK if the specified clock is stopped. - * @retval BSP_ARG_ERROR BSP_ARG_ERROR if the specified clock is incorrect. - * @details This function stops the specified clock. - * Specify one of the following for mode. - * HIOCLK : High-speed on-chip oscillator - * SYSCLK : High-speed system clock - * SXCLK : Subsystem clock - * MIOCLK : Middle-speed on-chip oscillator - * LOCLK : Low-speed on-chip oscillator - */ -#if BSP_CFG_CLOCK_OPERATION_API_FUNCTIONS_DISABLE == 0 -e_bsp_err_t R_BSP_StopClock(e_clock_mode_t mode) -{ - return (stop_clock(mode)); -} /* End of function R_BSP_StopClock() */ -#endif - -/********************************************************************************************************************** - * Function Name: R_BSP_SetClockSource - ******************************************************************************************************************//** - * @brief Switch CPU/peripheral hardware clock(fCLK) clock source and return. - * @param[in] mode Clock to switch. - * @retval BSP_OK BSP_OK when switching to the specified clock. - * @retval BSP_ERROR1 When HIOCLK is specified, but high-speed on-chip oscillator is stopped. - * @retval BSP_ERROR2 When SYSCLK is specified, but high-speed system clock is stopped. - * @retval BSP_ERROR3 When SXCLK is specified, but Subsystem clock is stopped. - * @retval BSP_ERROR4 When MIOCLK is specified, but middle-speed on-chip oscillator is stopped. - * @retval BSP_ARG_ERROR BSP_ARG_ERROR if the specified clock is incorrect. - * @details This function switches the specified clock. - * Specify one of the following for mode. - * HIOCLK : High-speed on-chip oscillator - * SYSCLK : High-speed system clock - * SXCLK : Subsystem clock - * MIOCLK : Middle-speed on-chip oscillator - * LOCLK : Low-speed on-chip oscillator - */ -#if BSP_CFG_SET_CLOCK_SOURCE_API_FUNCTIONS_DISABLE == 0 -e_bsp_err_t R_BSP_SetClockSource(e_clock_mode_t mode) -{ - return (set_fclk_clock_source(mode)); -} /* End of function R_BSP_SetClockSource() */ -#endif - -/********************************************************************************************************************** - * Function Name: R_BSP_GetFclkFreqHz - ******************************************************************************************************************//** - * @brief Returns CPU/peripheral hardware clock(fCLK) frequency. - * @return CPU/peripheral hardware clock(fCLK) frequency specified by the r_bsp. - * @details This function returns the CPU/peripheral hardware clock(fCLK) frequency. - * For example, when the CPU/peripheral hardware clock(fCLK) is set to 20 MHz in r_bsp_config.h - * and the r_bsp has completed to specify the clock setting, then even if the user changed the - * CPU/peripheral hardware clock(fCLK) frequency to 10 MHz, the return value is '10000000'. - */ -#if BSP_CFG_GET_FREQ_API_FUNCTIONS_DISABLE == 0 -uint32_t R_BSP_GetFclkFreqHz(void) -{ - return (get_fclk_freq_hz()); -} /* End of function R_BSP_GetFclkFreqHz() */ -#endif - -/********************************************************************************************************************** - * Function Name: R_BSP_ChangeClockSetting - ******************************************************************************************************************//** - * @brief Change the specified clock setting and return. - * @param[in] mode Clock to change settings. - * @param[in] set_values Value to set for the specified clock. - * @retval BSP_OK BSP_OK if the specified clock setting is changed. - * @retval BSP_ERRPR1 When the specified clock is stopped. - * @retval BSP_ERROR3 An unsupported state transition was specified. Refer to the user's manual. - * @retval BSP_ARG_ERROR BSP_ARG_ERROR if the specified clock is incorrect. - * @details This function changes the specified clock setting. - * Specify one of the following for mode. - * HIOCLK : High-speed on-chip oscillator - * MIOCLK : Middle-speed on-chip oscillator - * PLLCLK : PLL clock - */ -#if BSP_CFG_CHANGE_CLOCK_SETTING_API_FUNCTIONS_DISABLE == 0 -e_bsp_err_t R_BSP_ChangeClockSetting(e_clock_mode_t mode, uint8_t * set_values) -{ - return (change_clock_setting(mode, set_values)); -} /* End of function R_BSP_ChangeClockSetting() */ -#endif - -/********************************************************************************************************************** - * Function Name: R_BSP_SoftwareDelay - ******************************************************************************************************************//** - * @brief Delay the specified duration in units and return. - * @param[in] delay The number of 'units' to delay. - * @param[in] units The 'base' for the unitsspecified. - * @retval BSP_OK BSP_OK if delay executed. - * @retval BSP_ERRPR1 BSP_ERROR1 if delay/units combination resulted in overflow/underflow. - * @details This is function that may be called for all MCU targets to implement a specific wait time. - * The actual delay time is plus the overhead at a specified duration. The overhead changes under the influence of - * the compiler, operating frequency and ROM cache. When the operating frequency is low, or the specified duration in - * units of microsecond level, please note that the error becomes large. - */ -#if BSP_CFG_SOFTWARE_DELAY_API_FUNCTIONS_DISABLE == 0 -e_bsp_err_t R_BSP_SoftwareDelay (uint32_t delay, e_bsp_delay_units_t units) -{ - volatile uint32_t fclk_rate; - volatile uint32_t delay_cycles; - volatile uint32_t loop_cnt; - volatile unsigned long long loop_cnt_64; - volatile unsigned long long delay_cycles_64; - - fclk_rate = R_BSP_GetFclkFreqHz(); /* Get the current ICLK frequency. */ - - /* - * In order to handle all possible combinations of delay/ICLK it is necessary to use 64-bit - * integers (not all MCUs have floating point support). However, there is no native hw support - * for 64 bitintegers so it requires many more clock cycles. This is not an issue if the - * requested delay is long enough and the ICLK is fast, but for delays in the low microseconds - * and/or a slow ICLK we use 32 bit integers to reduce the overhead cycles of this function - * by approximately a third and stand the best chance of achieving the requested delay. - */ - if ((units == BSP_DELAY_MICROSECS) && - (delay <= (0xFFFFFFFFUL / fclk_rate))) /* Ensure (fclk_rate * delay) will not exceed 32 bits. */ - { - delay_cycles = ((fclk_rate * delay) / bsp_delay_time[units]); - - if (delay_cycles > BSP_PRV_OVERHEAD_CYCLES) - { - delay_cycles -= BSP_PRV_OVERHEAD_CYCLES; - } - else - { - delay_cycles = 0U; - } - - loop_cnt = delay_cycles / BSP_CPU_CYCLES_PER_LOOP; - - if (0U == loop_cnt) - { - /* The requested delay is too large/small for the current ICLK. Return BSP_ERROR1 which - * also results in the minimum possible delay. */ - return BSP_ERROR1; - } - } - else - { - /* Casting is valid because it matches the type to the right side or argument. */ - delay_cycles_64 = (((unsigned long long)fclk_rate * (unsigned long long)delay) / bsp_delay_time[units]); - - if (delay_cycles_64 > BSP_PRV_OVERHEAD_CYCLES_64) - { - delay_cycles_64 -= BSP_PRV_OVERHEAD_CYCLES_64; - } - else - { - delay_cycles = 0U; - } - - loop_cnt_64 = delay_cycles_64 / BSP_CPU_CYCLES_PER_LOOP; - - if ((loop_cnt_64 > 0xFFFFFFFFUL) || (0U == loop_cnt_64)) - { - /* The requested delay is too large/small for the current ICLK. Return BSP_ERROR1 which - * also results in the minimum possible delay. */ - return BSP_ERROR1; - } - - /* Casting is valid because it matches the type to the right side or argument. */ - loop_cnt = (uint32_t)loop_cnt_64; - } - - delay_wait (loop_cnt); - - return BSP_OK; -} /* End of function R_BSP_SoftwareDelay() */ -#endif +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +* this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* File Name : r_bsp_common.c +* Description : +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* History : DD.MM.YYYY Version Description +* : 08.03.2021 1.00 First Release +* : 28.02.2022 1.20 Added the following function. +* - R_BSP_ChangeClockSetting +* Changed to enable/disable for each API function. +* : 31.05.2022 1.30 Added the following function. +* - R_BSP_SoftwareDelay +***********************************************************************************************************************/ + +/************************************************* + * Includes , "Project Includes" + *************************************************/ +#include "platform.h" + +/************************************************* + * Macro definitions + *************************************************/ +#define BSP_PRV_OVERHEAD_CYCLES (1000U) /* R_BSP_SoftwareDelay() overhead per call */ +#define BSP_PRV_OVERHEAD_CYCLES_64 (1000U) /* R_BSP_SoftwareDelay() overhead per call using 64-bit ints */ +#define BSP_CPU_CYCLES_PER_LOOP (6U) + +/************************************************* + * Private global variables and functions + *************************************************/ +/* Delay time definition table */ +#if BSP_CFG_SOFTWARE_DELAY_API_FUNCTIONS_DISABLE == 0 +const unsigned long long bsp_delay_time[] = { + 1, + 1000, + 1000000 +}; +#endif + +/************************************************* + * Function definition + *************************************************/ +extern void delay_wait (uint32_t count); + +/********************************************************************************************************************** + * Function Name: R_BSP_StartClock + ******************************************************************************************************************//** + * @brief Start the specified clock and return. + * @param[in] mode Clock to start. + * @retval BSP_OK BSP_OK if the specified clock is started. + * @retval BSP_ARG_ERROR BSP_ARG_ERROR if the specified clock is incorrect. + * @details This function starts the specified clock. + * Specify one of the following for mode. + * HIOCLK : High-speed on-chip oscillator + * SYSCLK : High-speed system clock + * SXCLK : Subsystem clock + * MIOCLK : Middle-speed on-chip oscillator + * LOCLK : Low-speed on-chip oscillator + */ +#if BSP_CFG_CLOCK_OPERATION_API_FUNCTIONS_DISABLE == 0 +e_bsp_err_t R_BSP_StartClock(e_clock_mode_t mode) +{ + return (start_clock(mode)); +} /* End of function R_BSP_StartClock() */ +#endif + +/********************************************************************************************************************** + * Function Name: R_BSP_StopClock + ******************************************************************************************************************//** + * @brief Stop the specified clock and return. + * @param[in] mode Clock to stop. + * @retval BSP_OK BSP_OK if the specified clock is stopped. + * @retval BSP_ARG_ERROR BSP_ARG_ERROR if the specified clock is incorrect. + * @details This function stops the specified clock. + * Specify one of the following for mode. + * HIOCLK : High-speed on-chip oscillator + * SYSCLK : High-speed system clock + * SXCLK : Subsystem clock + * MIOCLK : Middle-speed on-chip oscillator + * LOCLK : Low-speed on-chip oscillator + */ +#if BSP_CFG_CLOCK_OPERATION_API_FUNCTIONS_DISABLE == 0 +e_bsp_err_t R_BSP_StopClock(e_clock_mode_t mode) +{ + return (stop_clock(mode)); +} /* End of function R_BSP_StopClock() */ +#endif + +/********************************************************************************************************************** + * Function Name: R_BSP_SetClockSource + ******************************************************************************************************************//** + * @brief Switch CPU/peripheral hardware clock(fCLK) clock source and return. + * @param[in] mode Clock to switch. + * @retval BSP_OK BSP_OK when switching to the specified clock. + * @retval BSP_ERROR1 When HIOCLK is specified, but high-speed on-chip oscillator is stopped. + * @retval BSP_ERROR2 When SYSCLK is specified, but high-speed system clock is stopped. + * @retval BSP_ERROR3 When SXCLK is specified, but Subsystem clock is stopped. + * @retval BSP_ERROR4 When MIOCLK is specified, but middle-speed on-chip oscillator is stopped. + * @retval BSP_ARG_ERROR BSP_ARG_ERROR if the specified clock is incorrect. + * @details This function switches the specified clock. + * Specify one of the following for mode. + * HIOCLK : High-speed on-chip oscillator + * SYSCLK : High-speed system clock + * SXCLK : Subsystem clock + * MIOCLK : Middle-speed on-chip oscillator + * LOCLK : Low-speed on-chip oscillator + */ +#if BSP_CFG_SET_CLOCK_SOURCE_API_FUNCTIONS_DISABLE == 0 +e_bsp_err_t R_BSP_SetClockSource(e_clock_mode_t mode) +{ + return (set_fclk_clock_source(mode)); +} /* End of function R_BSP_SetClockSource() */ +#endif + +/********************************************************************************************************************** + * Function Name: R_BSP_GetFclkFreqHz + ******************************************************************************************************************//** + * @brief Returns CPU/peripheral hardware clock(fCLK) frequency. + * @return CPU/peripheral hardware clock(fCLK) frequency specified by the r_bsp. + * @details This function returns the CPU/peripheral hardware clock(fCLK) frequency. + * For example, when the CPU/peripheral hardware clock(fCLK) is set to 20 MHz in r_bsp_config.h + * and the r_bsp has completed to specify the clock setting, then even if the user changed the + * CPU/peripheral hardware clock(fCLK) frequency to 10 MHz, the return value is '10000000'. + */ +#if BSP_CFG_GET_FREQ_API_FUNCTIONS_DISABLE == 0 +uint32_t R_BSP_GetFclkFreqHz(void) +{ + return (get_fclk_freq_hz()); +} /* End of function R_BSP_GetFclkFreqHz() */ +#endif + +/********************************************************************************************************************** + * Function Name: R_BSP_ChangeClockSetting + ******************************************************************************************************************//** + * @brief Change the specified clock setting and return. + * @param[in] mode Clock to change settings. + * @param[in] set_values Value to set for the specified clock. + * @retval BSP_OK BSP_OK if the specified clock setting is changed. + * @retval BSP_ERRPR1 When the specified clock is stopped. + * @retval BSP_ERROR3 An unsupported state transition was specified. Refer to the user's manual. + * @retval BSP_ARG_ERROR BSP_ARG_ERROR if the specified clock is incorrect. + * @details This function changes the specified clock setting. + * Specify one of the following for mode. + * HIOCLK : High-speed on-chip oscillator + * MIOCLK : Middle-speed on-chip oscillator + * PLLCLK : PLL clock + */ +#if BSP_CFG_CHANGE_CLOCK_SETTING_API_FUNCTIONS_DISABLE == 0 +e_bsp_err_t R_BSP_ChangeClockSetting(e_clock_mode_t mode, uint8_t * set_values) +{ + return (change_clock_setting(mode, set_values)); +} /* End of function R_BSP_ChangeClockSetting() */ +#endif + +/********************************************************************************************************************** + * Function Name: R_BSP_SoftwareDelay + ******************************************************************************************************************//** + * @brief Delay the specified duration in units and return. + * @param[in] delay The number of 'units' to delay. + * @param[in] units The 'base' for the unitsspecified. + * @retval BSP_OK BSP_OK if delay executed. + * @retval BSP_ERRPR1 BSP_ERROR1 if delay/units combination resulted in overflow/underflow. + * @details This is function that may be called for all MCU targets to implement a specific wait time. + * The actual delay time is plus the overhead at a specified duration. The overhead changes under the influence of + * the compiler, operating frequency and ROM cache. When the operating frequency is low, or the specified duration in + * units of microsecond level, please note that the error becomes large. + */ +#if BSP_CFG_SOFTWARE_DELAY_API_FUNCTIONS_DISABLE == 0 +e_bsp_err_t R_BSP_SoftwareDelay (uint32_t delay, e_bsp_delay_units_t units) +{ + volatile uint32_t fclk_rate; + volatile uint32_t delay_cycles; + volatile uint32_t loop_cnt; + volatile unsigned long long loop_cnt_64; + volatile unsigned long long delay_cycles_64; + + fclk_rate = R_BSP_GetFclkFreqHz(); /* Get the current ICLK frequency. */ + + /* + * In order to handle all possible combinations of delay/ICLK it is necessary to use 64-bit + * integers (not all MCUs have floating point support). However, there is no native hw support + * for 64 bitintegers so it requires many more clock cycles. This is not an issue if the + * requested delay is long enough and the ICLK is fast, but for delays in the low microseconds + * and/or a slow ICLK we use 32 bit integers to reduce the overhead cycles of this function + * by approximately a third and stand the best chance of achieving the requested delay. + */ + if ((units == BSP_DELAY_MICROSECS) && + (delay <= (0xFFFFFFFFUL / fclk_rate))) /* Ensure (fclk_rate * delay) will not exceed 32 bits. */ + { + delay_cycles = ((fclk_rate * delay) / bsp_delay_time[units]); + + if (delay_cycles > BSP_PRV_OVERHEAD_CYCLES) + { + delay_cycles -= BSP_PRV_OVERHEAD_CYCLES; + } + else + { + delay_cycles = 0U; + } + + loop_cnt = delay_cycles / BSP_CPU_CYCLES_PER_LOOP; + + if (0U == loop_cnt) + { + /* The requested delay is too large/small for the current ICLK. Return BSP_ERROR1 which + * also results in the minimum possible delay. */ + return BSP_ERROR1; + } + } + else + { + /* Casting is valid because it matches the type to the right side or argument. */ + delay_cycles_64 = (((unsigned long long)fclk_rate * (unsigned long long)delay) / bsp_delay_time[units]); + + if (delay_cycles_64 > BSP_PRV_OVERHEAD_CYCLES_64) + { + delay_cycles_64 -= BSP_PRV_OVERHEAD_CYCLES_64; + } + else + { + delay_cycles = 0U; + } + + loop_cnt_64 = delay_cycles_64 / BSP_CPU_CYCLES_PER_LOOP; + + if ((loop_cnt_64 > 0xFFFFFFFFUL) || (0U == loop_cnt_64)) + { + /* The requested delay is too large/small for the current ICLK. Return BSP_ERROR1 which + * also results in the minimum possible delay. */ + return BSP_ERROR1; + } + + /* Casting is valid because it matches the type to the right side or argument. */ + loop_cnt = (uint32_t)loop_cnt_64; + } + + delay_wait (loop_cnt); + + return BSP_OK; +} /* End of function R_BSP_SoftwareDelay() */ +#endif diff --git a/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_bsp_common.h b/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_bsp_common.h index 1fedce2..dec490a 100644 --- a/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_bsp_common.h +++ b/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_bsp_common.h @@ -1,134 +1,134 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -* this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2021 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* File Name : r_bsp_common.h -* Description : -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* History : DD.MM.YYYY Version Description -* : 08.03.2021 1.00 First Release -* : 22.04.2021 1.10 Changed Minor version to 1.10 -* : 04.08.2021 1.12 Added include r_bsp_config.h. -* : 29.10.2021 1.13 Added version check of smart configurator. -* : 28.02.2022 1.20 Added PLLCLK,ADCLK to e_clock_mode_t. -* Added the following function. -* - R_BSP_ChangeClockSetting -* Changed to enable/disable for each API function. -* Changed the version of smart configurator to check to 1030. -* Changed to always determine the version of smart configurator. -* : 31.05.2022 1.30 Added the following enumerated variable. -* - e_bsp_delay_units_t -* Added prototype of the following function. -* - R_BSP_SoftwareDelay -***********************************************************************************************************************/ - -/************************************************* - * Includes , "Project Includes" - *************************************************/ -#include -#include -#include -#include -#include "r_bsp_config.h" - -/************************************************* - * Macro definitions - *************************************************/ -/* Multiple inclusion prevention macro */ -#ifndef R_BSP_COMMON_H -#define R_BSP_COMMON_H - -#if BSP_CFG_CONFIGURATOR_VERSION < 1030 -#error "Make sure that the value of BSP_CFG_CONFIGURATOR_VERSION defined in r_config/r_bsp_config.h matches the version of Smart Configurator you are using. If they do not match, change the settings. If they match, you need to upgrade your Smart Configurator. Please upgrade Smart Configurator." -#endif - -/* Interrupt disable/enable(assembler instruction) */ -#define BSP_DI() __DI() /* Interrupt disable */ -#define BSP_EI() __EI() /* Interrupt enable */ - -/* clock mode */ -/* NOTE: - * n = this clock may not be available depending on the number of terminals. - * RL78 MCU supported clocks - * - * Clock G23 F24 F23 G15 G22 - * ------ --- --- --- --- --- - * HIOCLK X X X X X - * SYSCLK X X X Xn X - * SXCLK X Xn Xn X - * MIOCLK X X - * LOCLK X X X X - * PLLCLK X X - * ADCLK X X -*/ -typedef enum -{ - HIOCLK, // High-speed on-chip oscillator - SYSCLK, // High-speed system clock - SXCLK, // Subsystem clock - MIOCLK, // Middle-speed on-chip oscillator - LOCLK, // Low-speed on-chip oscillator - PLLCLK, // PLL clock - ADCLK // A/D conversion clock -} e_clock_mode_t; - -/* Error identification */ -typedef enum -{ - BSP_OK, - BSP_ARG_ERROR, - BSP_ERROR1, - BSP_ERROR2, - BSP_ERROR3 -} e_bsp_err_t; - -/* Available delay units. */ -typedef enum -{ - BSP_DELAY_SECS = 0, /* Requested delay amount is in seconds. */ - BSP_DELAY_MILLISECS, /* Requested delay amount is in milliseconds. */ - BSP_DELAY_MICROSECS /* Requested delay amount is in microseconds. */ -} e_bsp_delay_units_t; - -/************************************************* - * Function declaration - *************************************************/ -#if BSP_CFG_CLOCK_OPERATION_API_FUNCTIONS_DISABLE == 0 -e_bsp_err_t R_BSP_StartClock (e_clock_mode_t mode); -e_bsp_err_t R_BSP_StopClock (e_clock_mode_t mode); -#endif - -#if BSP_CFG_GET_FREQ_API_FUNCTIONS_DISABLE == 0 -uint32_t R_BSP_GetFclkFreqHz (void); -#endif - -#if BSP_CFG_SET_CLOCK_SOURCE_API_FUNCTIONS_DISABLE == 0 -e_bsp_err_t R_BSP_SetClockSource (e_clock_mode_t mode); -#endif - -#if BSP_CFG_CHANGE_CLOCK_SETTING_API_FUNCTIONS_DISABLE == 0 -e_bsp_err_t R_BSP_ChangeClockSetting (e_clock_mode_t mode, uint8_t * set_values); -#endif - -#if BSP_CFG_SOFTWARE_DELAY_API_FUNCTIONS_DISABLE == 0 -e_bsp_err_t R_BSP_SoftwareDelay (uint32_t delay, e_bsp_delay_units_t units); -#endif - -#endif /* #define R_BSP_COMMON_H */ - +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +* this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* File Name : r_bsp_common.h +* Description : +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* History : DD.MM.YYYY Version Description +* : 08.03.2021 1.00 First Release +* : 22.04.2021 1.10 Changed Minor version to 1.10 +* : 04.08.2021 1.12 Added include r_bsp_config.h. +* : 29.10.2021 1.13 Added version check of smart configurator. +* : 28.02.2022 1.20 Added PLLCLK,ADCLK to e_clock_mode_t. +* Added the following function. +* - R_BSP_ChangeClockSetting +* Changed to enable/disable for each API function. +* Changed the version of smart configurator to check to 1030. +* Changed to always determine the version of smart configurator. +* : 31.05.2022 1.30 Added the following enumerated variable. +* - e_bsp_delay_units_t +* Added prototype of the following function. +* - R_BSP_SoftwareDelay +***********************************************************************************************************************/ + +/************************************************* + * Includes , "Project Includes" + *************************************************/ +#include +#include +#include +#include +#include "r_bsp_config.h" + +/************************************************* + * Macro definitions + *************************************************/ +/* Multiple inclusion prevention macro */ +#ifndef R_BSP_COMMON_H +#define R_BSP_COMMON_H + +#if BSP_CFG_CONFIGURATOR_VERSION < 1030 +#error "Make sure that the value of BSP_CFG_CONFIGURATOR_VERSION defined in r_config/r_bsp_config.h matches the version of Smart Configurator you are using. If they do not match, change the settings. If they match, you need to upgrade your Smart Configurator. Please upgrade Smart Configurator." +#endif + +/* Interrupt disable/enable(assembler instruction) */ +#define BSP_DI() __DI() /* Interrupt disable */ +#define BSP_EI() __EI() /* Interrupt enable */ + +/* clock mode */ +/* NOTE: + * n = this clock may not be available depending on the number of terminals. + * RL78 MCU supported clocks + * + * Clock G23 F24 F23 G15 G22 + * ------ --- --- --- --- --- + * HIOCLK X X X X X + * SYSCLK X X X Xn X + * SXCLK X Xn Xn X + * MIOCLK X X + * LOCLK X X X X + * PLLCLK X X + * ADCLK X X +*/ +typedef enum +{ + HIOCLK, // High-speed on-chip oscillator + SYSCLK, // High-speed system clock + SXCLK, // Subsystem clock + MIOCLK, // Middle-speed on-chip oscillator + LOCLK, // Low-speed on-chip oscillator + PLLCLK, // PLL clock + ADCLK // A/D conversion clock +} e_clock_mode_t; + +/* Error identification */ +typedef enum +{ + BSP_OK, + BSP_ARG_ERROR, + BSP_ERROR1, + BSP_ERROR2, + BSP_ERROR3 +} e_bsp_err_t; + +/* Available delay units. */ +typedef enum +{ + BSP_DELAY_SECS = 0, /* Requested delay amount is in seconds. */ + BSP_DELAY_MILLISECS, /* Requested delay amount is in milliseconds. */ + BSP_DELAY_MICROSECS /* Requested delay amount is in microseconds. */ +} e_bsp_delay_units_t; + +/************************************************* + * Function declaration + *************************************************/ +#if BSP_CFG_CLOCK_OPERATION_API_FUNCTIONS_DISABLE == 0 +e_bsp_err_t R_BSP_StartClock (e_clock_mode_t mode); +e_bsp_err_t R_BSP_StopClock (e_clock_mode_t mode); +#endif + +#if BSP_CFG_GET_FREQ_API_FUNCTIONS_DISABLE == 0 +uint32_t R_BSP_GetFclkFreqHz (void); +#endif + +#if BSP_CFG_SET_CLOCK_SOURCE_API_FUNCTIONS_DISABLE == 0 +e_bsp_err_t R_BSP_SetClockSource (e_clock_mode_t mode); +#endif + +#if BSP_CFG_CHANGE_CLOCK_SETTING_API_FUNCTIONS_DISABLE == 0 +e_bsp_err_t R_BSP_ChangeClockSetting (e_clock_mode_t mode, uint8_t * set_values); +#endif + +#if BSP_CFG_SOFTWARE_DELAY_API_FUNCTIONS_DISABLE == 0 +e_bsp_err_t R_BSP_SoftwareDelay (uint32_t delay, e_bsp_delay_units_t units); +#endif + +#endif /* #define R_BSP_COMMON_H */ + diff --git a/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_bsp_common_llvm.S b/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_bsp_common_llvm.S index 054cb80..53f716a 100644 --- a/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_bsp_common_llvm.S +++ b/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_bsp_common_llvm.S @@ -1,56 +1,56 @@ -;;/*********************************************************************************************************************** -;;* DISCLAIMER -;;* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -;;* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -;;* applicable laws, including copyright laws. -;;* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -;;* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -;;* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -;;* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -;;* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -;;* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -;;* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -;;* this software. By using this software, you agree to the additional terms and conditions found by accessing the -;;* following link: -;;* http://www.renesas.com/disclaimer -;;* -;;* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. -;;***********************************************************************************************************************/ -;;/*********************************************************************************************************************** -;;* File Name : r_bsp_common_llvm.asm -;;* Description : -;;***********************************************************************************************************************/ -;;/*********************************************************************************************************************** -;;* History : DD.MM.YYYY Version Description -;;* : 31.05.2022 1.30 First Release -;;***********************************************************************************************************************/ - - .global _delay_wait /*! global delay wait routine */ - .short _delay_wait - -;----------------------------------------------------------------------------- -; delay_wait -;----------------------------------------------------------------------------- -_delay_wait: - ;-------------------------------------------------- - ; wait loop for low word - ;-------------------------------------------------- -loop: - SUBW AX, #1 - BZ $check - BR $loop - - ;-------------------------------------------------- - ; check loop for high word carried - ;-------------------------------------------------- -check: - CMPW AX, BC - DECW BC - BNZ $loop - - ;-------------------------------------------------- - ; setting the stack pointer - ;-------------------------------------------------- - -_exit: - RET +;;/*********************************************************************************************************************** +;;* DISCLAIMER +;;* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +;;* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +;;* applicable laws, including copyright laws. +;;* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +;;* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +;;* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +;;* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +;;* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +;;* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;;* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +;;* this software. By using this software, you agree to the additional terms and conditions found by accessing the +;;* following link: +;;* http://www.renesas.com/disclaimer +;;* +;;* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. +;;***********************************************************************************************************************/ +;;/*********************************************************************************************************************** +;;* File Name : r_bsp_common_llvm.asm +;;* Description : +;;***********************************************************************************************************************/ +;;/*********************************************************************************************************************** +;;* History : DD.MM.YYYY Version Description +;;* : 31.05.2022 1.30 First Release +;;***********************************************************************************************************************/ + + .global _delay_wait /*! global delay wait routine */ + .short _delay_wait + +;----------------------------------------------------------------------------- +; delay_wait +;----------------------------------------------------------------------------- +_delay_wait: + ;-------------------------------------------------- + ; wait loop for low word + ;-------------------------------------------------- +loop: + SUBW AX, #1 + BZ $check + BR $loop + + ;-------------------------------------------------- + ; check loop for high word carried + ;-------------------------------------------------- +check: + CMPW AX, BC + DECW BC + BNZ $loop + + ;-------------------------------------------------- + ; setting the stack pointer + ;-------------------------------------------------- + +_exit: + RET diff --git a/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_bsp_rl78_compiler.h b/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_bsp_rl78_compiler.h index a432069..3608e31 100644 --- a/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_bsp_rl78_compiler.h +++ b/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_bsp_rl78_compiler.h @@ -1,184 +1,184 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -* this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2021 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* File Name : r_bsp_rl78_compiler.h -* Description : -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* History : DD.MM.YYYY Version Description -* : 08.03.2021 1.00 First Release -* : 22.04.2021 1.10 Added "__far" to the address of the option byte. -* : 04.08.2021 1.12 Added include guard. -* : 28.02.2022 1.20 Added macro definition for option byte(000C4H). - -***********************************************************************************************************************/ - -/************************************************* - * Includes , "Project Includes" - *************************************************/ - -#ifndef R_RL78_COMPILER_H -#define R_RL78_COMPILER_H - -/* Macro definition for option byte reference */ -/* 000C0H or 040C0H - * Setting of watchdog timer operation - * - Enabling or disabling of counter operation - * - Enabling or stopping of counter operation in the HALT or STOP mode - * Setting of overflow time of watchdog timer - * Setting of window open period of watchdog timer - * Setting of interval interrupt of watchdog timer - * - Interval interrupt is used or not used - */ -#if defined(__CCRL__) -#define OPTBYTE_C0 (*(volatile __far unsigned char *)0x000C0) -#elif defined(__ICCRL78__) -#define OPTBYTE_C0 (*(volatile __far unsigned char *)0x000C0) -#elif defined(__llvm__) -#define OPTBYTE_C0 (*(volatile __far unsigned char *)0x000C0) -#endif - -/* 000C1H or 040C1H - * Setting of LVD0 operation mode - * - Reset mode - * - Interrupt mode - * - -LVD0 off(by controlling the externally input reset signal on the RESET pin) - * Setting of LVD0 detection level(VLVD0) - */ -#if defined(__CCRL__) -#define OPTBYTE_C1 (*(volatile __far unsigned char *)0x000C1) -#elif defined(__ICCRL78__) -#define OPTBYTE_C1 (*(volatile __far unsigned char *)0x000C1) -#elif defined(__llvm__) -#define OPTBYTE_C1 (*(volatile __far unsigned char *)0x000C1) -#endif - -/* 000C2H or 040C2H - * Setting of flash operation mode - * Make the setting depending on the main system clock frequency(fMAIN) - * and power supply voltage(VDD) to be used. - * - LS(low-speed main) mode - * - HS(high-speed main) mode - * - LP(low-power main) mode - * Setting of the frequency of the high-speed on-chip oscillator - * - Select from 1 MHz to 32 MHz - */ -#if defined(__CCRL__) -#define OPTBYTE_C2 (*(volatile __far unsigned char *)0x000C2) -#elif defined(__ICCRL78__) -#define OPTBYTE_C2 (*(volatile __far unsigned char *)0x000C2) -#elif defined(__llvm__) -#define OPTBYTE_C2 (*(volatile __far unsigned char *)0x000C2) -#endif - -/* 000C3H or 040C3H - * Control of on-chip debug operation - * - On-chip debug operation is disabled or enabled. - * Handling of data of flash memory in case of failure in security ID codes for on-chip debug authentication - * - Data of flash memory is erased or not erased in case of failure in - * security ID codes for on-chip debug authentication - */ -#if defined(__CCRL__) -#define OPTBYTE_C3 (*(volatile __far unsigned char *)0x000C3) -#elif defined(__ICCRL78__) -#define OPTBYTE_C3 (*(volatile __far unsigned char *)0x000C3) -#elif defined(__llvm__) -#define OPTBYTE_C3 (*(volatile __far unsigned char *)0x000C3) -#endif - -/* 000C4H or 040C4H - * Control of on-chip debug and flash serial programming security ID read - * - On-chip debug and flash serial programming security ID read are disabled or enabled. - */ -#if defined(__CCRL__) -#define OPTBYTE_C4 (*(volatile __far unsigned char *)0x000C4) -#elif defined(__ICCRL78__) -#define OPTBYTE_C4 (*(volatile __far unsigned char *)0x000C4) -#elif defined(__llvm__) -#define OPTBYTE_C4 (*(volatile __far unsigned char *)0x000C4) -#endif - -#if defined(__CCRL__) -#define BSP_FAR_FUNC __far -#define BSP_NOP() __nop() /* NOP instruction */ -#define BSP_DISABLE_INTERRUPT() __DI() -#define BSP_ENABLE_INTERRUPT() __EI() -#elif defined(__ICCRL78__) -#define BSP_FAR_FUNC __far_func -#define BSP_NOP() __no_operation() -#define BSP_DISABLE_INTERRUPT() __disable_interrupt() -#define BSP_ENABLE_INTERRUPT() __enable_interrupt() -#elif defined(__llvm__) -#define BSP_NOP() NOP() -#define BSP_DISABLE_INTERRUPT() DI() -#define BSP_ENABLE_INTERRUPT() EI() -#endif - -/* Sections */ -#if defined(__CCRL__) -#define R_BSP_SECTOP(name) __sectop(#name) -#define R_BSP_SECEND(name) __secend(#name) -#define R_BSP_SECSIZE(name) __secsize(#name) -#elif defined(__ICCRL78__) -#elif defined(__llvm__) -#endif - -/* ========== #pragma Directive ========== */ -#if defined(__CCRL__) -#define R_BSP_PRAGMA(...) _Pragma(#__VA_ARGS__) -/* Define __R_BSP_ATTRIB_SECTION_CHANGE_ */ -#define __R_BSP_ATTRIB_SECTION_CHANGE_F(type, section_name) R_BSP_PRAGMA(section (type) (section_name)) -#define _R_BSP_ATTRIB_SECTION_CHANGE_text(section_tag) __R_BSP_ATTRIB_SECTION_CHANGE_F(text, ##section_tag) -#define _R_BSP_ATTRIB_SECTION_CHANGE_data(section_tag) __R_BSP_ATTRIB_SECTION_CHANGE_F(data, ##section_tag) -#define R_BSP_ATTRIB_SECTION_CHANGE(type, section_tag) _R_BSP_ATTRIB_SECTION_CHANGE_##type(section_tag) -#define R_BSP_ATTRIB_SECTION_CHANGE_END R_BSP_PRAGMA(section) -#elif defined(__ICCRL78__) -#define R_BSP_PRAGMA(...) _Pragma(#__VA_ARGS__) -#elif defined(__llvm__) -#endif - -/* ---------- Interrupt Function Creation ---------- */ -#if defined(__CCRL__) -/* Standard */ -#define R_BSP_PRAGMA_INTERRUPT(function_name, vector) R_BSP_PRAGMA(interrupt function_name(vect=vector))\ - extern void function_name(void); -#define R_BSP_PRAGMA_STATIC_INTERRUPT(function_name, vector) R_BSP_PRAGMA(interrupt function_name(vect=vector))\ - static void function_name(void); -#define R_BSP_ATTRIB_INTERRUPT extern -#define R_BSP_ATTRIB_STATIC_INTERRUPT static - -#elif defined(__ICCRL78__) -/* Standard */ -#define R_BSP_PRAGMA_INTERRUPT(function_name, vect) R_BSP_PRAGMA(vector=vect)\ - extern __interrupt void function_name(void); -#define R_BSP_PRAGMA_STATIC_INTERRUPT(function_name, vect) R_BSP_PRAGMA(vector=vect)\ - static __interrupt void function_name(void); -#define R_BSP_ATTRIB_INTERRUPT extern __interrupt -#define R_BSP_ATTRIB_STATIC_INTERRUPT static __interrupt - -#elif defined(__llvm__) -/* R_BSP_PRAGMA_INTERRUPT */ -#define R_BSP_PRAGMA_INTERRUPT(function_name, vector) extern void function_name(void) __attribute__((interrupt(vect=vector), used)); -#define R_BSP_PRAGMA_STATIC_INTERRUPT(function_name, vector) static void function_name(void) __attribute__((interrupt(vect=vector), used)); -#define R_BSP_ATTRIB_INTERRUPT extern -#define R_BSP_ATTRIB_STATIC_INTERRUPT static -#endif - -#endif /* R_RL78_COMPILER_H */ - +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +* this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* File Name : r_bsp_rl78_compiler.h +* Description : +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* History : DD.MM.YYYY Version Description +* : 08.03.2021 1.00 First Release +* : 22.04.2021 1.10 Added "__far" to the address of the option byte. +* : 04.08.2021 1.12 Added include guard. +* : 28.02.2022 1.20 Added macro definition for option byte(000C4H). + +***********************************************************************************************************************/ + +/************************************************* + * Includes , "Project Includes" + *************************************************/ + +#ifndef R_RL78_COMPILER_H +#define R_RL78_COMPILER_H + +/* Macro definition for option byte reference */ +/* 000C0H or 040C0H + * Setting of watchdog timer operation + * - Enabling or disabling of counter operation + * - Enabling or stopping of counter operation in the HALT or STOP mode + * Setting of overflow time of watchdog timer + * Setting of window open period of watchdog timer + * Setting of interval interrupt of watchdog timer + * - Interval interrupt is used or not used + */ +#if defined(__CCRL__) +#define OPTBYTE_C0 (*(volatile __far unsigned char *)0x000C0) +#elif defined(__ICCRL78__) +#define OPTBYTE_C0 (*(volatile __far unsigned char *)0x000C0) +#elif defined(__llvm__) +#define OPTBYTE_C0 (*(volatile __far unsigned char *)0x000C0) +#endif + +/* 000C1H or 040C1H + * Setting of LVD0 operation mode + * - Reset mode + * - Interrupt mode + * - -LVD0 off(by controlling the externally input reset signal on the RESET pin) + * Setting of LVD0 detection level(VLVD0) + */ +#if defined(__CCRL__) +#define OPTBYTE_C1 (*(volatile __far unsigned char *)0x000C1) +#elif defined(__ICCRL78__) +#define OPTBYTE_C1 (*(volatile __far unsigned char *)0x000C1) +#elif defined(__llvm__) +#define OPTBYTE_C1 (*(volatile __far unsigned char *)0x000C1) +#endif + +/* 000C2H or 040C2H + * Setting of flash operation mode + * Make the setting depending on the main system clock frequency(fMAIN) + * and power supply voltage(VDD) to be used. + * - LS(low-speed main) mode + * - HS(high-speed main) mode + * - LP(low-power main) mode + * Setting of the frequency of the high-speed on-chip oscillator + * - Select from 1 MHz to 32 MHz + */ +#if defined(__CCRL__) +#define OPTBYTE_C2 (*(volatile __far unsigned char *)0x000C2) +#elif defined(__ICCRL78__) +#define OPTBYTE_C2 (*(volatile __far unsigned char *)0x000C2) +#elif defined(__llvm__) +#define OPTBYTE_C2 (*(volatile __far unsigned char *)0x000C2) +#endif + +/* 000C3H or 040C3H + * Control of on-chip debug operation + * - On-chip debug operation is disabled or enabled. + * Handling of data of flash memory in case of failure in security ID codes for on-chip debug authentication + * - Data of flash memory is erased or not erased in case of failure in + * security ID codes for on-chip debug authentication + */ +#if defined(__CCRL__) +#define OPTBYTE_C3 (*(volatile __far unsigned char *)0x000C3) +#elif defined(__ICCRL78__) +#define OPTBYTE_C3 (*(volatile __far unsigned char *)0x000C3) +#elif defined(__llvm__) +#define OPTBYTE_C3 (*(volatile __far unsigned char *)0x000C3) +#endif + +/* 000C4H or 040C4H + * Control of on-chip debug and flash serial programming security ID read + * - On-chip debug and flash serial programming security ID read are disabled or enabled. + */ +#if defined(__CCRL__) +#define OPTBYTE_C4 (*(volatile __far unsigned char *)0x000C4) +#elif defined(__ICCRL78__) +#define OPTBYTE_C4 (*(volatile __far unsigned char *)0x000C4) +#elif defined(__llvm__) +#define OPTBYTE_C4 (*(volatile __far unsigned char *)0x000C4) +#endif + +#if defined(__CCRL__) +#define BSP_FAR_FUNC __far +#define BSP_NOP() __nop() /* NOP instruction */ +#define BSP_DISABLE_INTERRUPT() __DI() +#define BSP_ENABLE_INTERRUPT() __EI() +#elif defined(__ICCRL78__) +#define BSP_FAR_FUNC __far_func +#define BSP_NOP() __no_operation() +#define BSP_DISABLE_INTERRUPT() __disable_interrupt() +#define BSP_ENABLE_INTERRUPT() __enable_interrupt() +#elif defined(__llvm__) +#define BSP_NOP() NOP() +#define BSP_DISABLE_INTERRUPT() DI() +#define BSP_ENABLE_INTERRUPT() EI() +#endif + +/* Sections */ +#if defined(__CCRL__) +#define R_BSP_SECTOP(name) __sectop(#name) +#define R_BSP_SECEND(name) __secend(#name) +#define R_BSP_SECSIZE(name) __secsize(#name) +#elif defined(__ICCRL78__) +#elif defined(__llvm__) +#endif + +/* ========== #pragma Directive ========== */ +#if defined(__CCRL__) +#define R_BSP_PRAGMA(...) _Pragma(#__VA_ARGS__) +/* Define __R_BSP_ATTRIB_SECTION_CHANGE_ */ +#define __R_BSP_ATTRIB_SECTION_CHANGE_F(type, section_name) R_BSP_PRAGMA(section (type) (section_name)) +#define _R_BSP_ATTRIB_SECTION_CHANGE_text(section_tag) __R_BSP_ATTRIB_SECTION_CHANGE_F(text, ##section_tag) +#define _R_BSP_ATTRIB_SECTION_CHANGE_data(section_tag) __R_BSP_ATTRIB_SECTION_CHANGE_F(data, ##section_tag) +#define R_BSP_ATTRIB_SECTION_CHANGE(type, section_tag) _R_BSP_ATTRIB_SECTION_CHANGE_##type(section_tag) +#define R_BSP_ATTRIB_SECTION_CHANGE_END R_BSP_PRAGMA(section) +#elif defined(__ICCRL78__) +#define R_BSP_PRAGMA(...) _Pragma(#__VA_ARGS__) +#elif defined(__llvm__) +#endif + +/* ---------- Interrupt Function Creation ---------- */ +#if defined(__CCRL__) +/* Standard */ +#define R_BSP_PRAGMA_INTERRUPT(function_name, vector) R_BSP_PRAGMA(interrupt function_name(vect=vector))\ + extern void function_name(void); +#define R_BSP_PRAGMA_STATIC_INTERRUPT(function_name, vector) R_BSP_PRAGMA(interrupt function_name(vect=vector))\ + static void function_name(void); +#define R_BSP_ATTRIB_INTERRUPT extern +#define R_BSP_ATTRIB_STATIC_INTERRUPT static + +#elif defined(__ICCRL78__) +/* Standard */ +#define R_BSP_PRAGMA_INTERRUPT(function_name, vect) R_BSP_PRAGMA(vector=vect)\ + extern __interrupt void function_name(void); +#define R_BSP_PRAGMA_STATIC_INTERRUPT(function_name, vect) R_BSP_PRAGMA(vector=vect)\ + static __interrupt void function_name(void); +#define R_BSP_ATTRIB_INTERRUPT extern __interrupt +#define R_BSP_ATTRIB_STATIC_INTERRUPT static __interrupt + +#elif defined(__llvm__) +/* R_BSP_PRAGMA_INTERRUPT */ +#define R_BSP_PRAGMA_INTERRUPT(function_name, vector) extern void function_name(void) __attribute__((interrupt(vect=vector), used)); +#define R_BSP_PRAGMA_STATIC_INTERRUPT(function_name, vector) static void function_name(void) __attribute__((interrupt(vect=vector), used)); +#define R_BSP_ATTRIB_INTERRUPT extern +#define R_BSP_ATTRIB_STATIC_INTERRUPT static +#endif + +#endif /* R_RL78_COMPILER_H */ + diff --git a/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_fsp_error.h b/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_fsp_error.h index 0c99d8f..43c307c 100644 --- a/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_fsp_error.h +++ b/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_fsp_error.h @@ -1,72 +1,72 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -* this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2021 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* File Name : r_fsp_error.h -* Description : The user chooses which MCU and board they are developing for in this file. If the board you are using -* is not listed below, please add your own or use the default 'User Board'. -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* History : DD.MM.YYYY Version Description -* : 08.09.2021 1.00 First Release -***********************************************************************************************************************/ -#ifndef R_FSP_ERROR_H_ -#define R_FSP_ERROR_H_ - - -/*********************************************************************************************************************** - * Includes - **********************************************************************************************************************/ -#include "fsp_common_api.h" - -/*********************************************************************************************************************** - * Macro definitions - **********************************************************************************************************************/ -/** Macro to log and return error without an assertion. */ -#ifndef FSP_RETURN - - #define FSP_RETURN(err) FSP_ERROR_LOG((err)); \ - return err; -#endif - -/** This function is called before returning an error code. To stop on a runtime error, define fsp_error_log in - * user code and do required debugging (breakpoints, stack dump, etc) in this function.*/ - #define FSP_ERROR_LOG(err) - -/** Default assertion calls ::FSP_ERROR_RETURN if condition "a" is false. Used to identify incorrect use of API's in FSP - * functions. */ - #define FSP_ASSERT(a) FSP_ERROR_RETURN((a), FSP_ERR_ASSERTION) - -/** All FSP error codes are returned using this macro. Calls ::FSP_ERROR_LOG function if condition "a" is false. Used - * to identify runtime errors in FSP functions. */ - -#define FSP_ERROR_RETURN(a, err) \ - { \ - if ((a)) \ - { \ - (void) 0; /* Do nothing */ \ - } \ - else \ - { \ - FSP_ERROR_LOG(err); \ - return err; \ - } \ - } - - -#endif /* R_FSP_ERROR_H_ */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +* this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* File Name : r_fsp_error.h +* Description : The user chooses which MCU and board they are developing for in this file. If the board you are using +* is not listed below, please add your own or use the default 'User Board'. +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* History : DD.MM.YYYY Version Description +* : 08.09.2021 1.00 First Release +***********************************************************************************************************************/ +#ifndef R_FSP_ERROR_H_ +#define R_FSP_ERROR_H_ + + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include "fsp_common_api.h" + +/*********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ +/** Macro to log and return error without an assertion. */ +#ifndef FSP_RETURN + + #define FSP_RETURN(err) FSP_ERROR_LOG((err)); \ + return err; +#endif + +/** This function is called before returning an error code. To stop on a runtime error, define fsp_error_log in + * user code and do required debugging (breakpoints, stack dump, etc) in this function.*/ + #define FSP_ERROR_LOG(err) + +/** Default assertion calls ::FSP_ERROR_RETURN if condition "a" is false. Used to identify incorrect use of API's in FSP + * functions. */ + #define FSP_ASSERT(a) FSP_ERROR_RETURN((a), FSP_ERR_ASSERTION) + +/** All FSP error codes are returned using this macro. Calls ::FSP_ERROR_LOG function if condition "a" is false. Used + * to identify runtime errors in FSP functions. */ + +#define FSP_ERROR_RETURN(a, err) \ + { \ + if ((a)) \ + { \ + (void) 0; /* Do nothing */ \ + } \ + else \ + { \ + FSP_ERROR_LOG(err); \ + return err; \ + } \ + } + + +#endif /* R_FSP_ERROR_H_ */ diff --git a/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_rtos.h b/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_rtos.h index bb378ba..2d04e20 100644 --- a/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_rtos.h +++ b/cores/rl78g22/smc_gen/r_bsp/mcu/all/r_rtos.h @@ -1,55 +1,55 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -* this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2021 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* File Name : r_rtos.h -* Description : This module implements functions of rtos. -***********************************************************************************************************************/ -/********************************************************************************************************************** -* History : DD.MM.YYYY Version Description -* : 22.04.2021 1.00 First Release - -**********************************************************************************************************************/ - -/*********************************************************************************************************************** -Includes , "Project Includes" -***********************************************************************************************************************/ -#include "r_bsp_config.h" - -#if BSP_CFG_RTOS_USED == 0 /* Non-OS */ -#elif BSP_CFG_RTOS_USED == 1 /* FreeRTOS(This is not available.) */ -#elif BSP_CFG_RTOS_USED == 2 /* SEGGER embOS(This is not available.) */ -#elif BSP_CFG_RTOS_USED == 3 /* Micrium MicroC/OS(This is not available.) */ -#elif BSP_CFG_RTOS_USED == 4 /* Renesas RI78V4 */ -#ifndef __CCRL__ -#error "The RI78V4 supports CC-RL compiler only." -#endif -#include "kernel.h" -#include "kernel_id.h" -#else -#endif - -/*********************************************************************************************************************** -Macro definitions -***********************************************************************************************************************/ -/* Multiple inclusion prevention macro */ -#ifndef R_RTOS_H -#define R_RTOS_H - -#endif /* R_RTOS_H */ - +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +* this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* File Name : r_rtos.h +* Description : This module implements functions of rtos. +***********************************************************************************************************************/ +/********************************************************************************************************************** +* History : DD.MM.YYYY Version Description +* : 22.04.2021 1.00 First Release + +**********************************************************************************************************************/ + +/*********************************************************************************************************************** +Includes , "Project Includes" +***********************************************************************************************************************/ +#include "r_bsp_config.h" + +#if BSP_CFG_RTOS_USED == 0 /* Non-OS */ +#elif BSP_CFG_RTOS_USED == 1 /* FreeRTOS(This is not available.) */ +#elif BSP_CFG_RTOS_USED == 2 /* SEGGER embOS(This is not available.) */ +#elif BSP_CFG_RTOS_USED == 3 /* Micrium MicroC/OS(This is not available.) */ +#elif BSP_CFG_RTOS_USED == 4 /* Renesas RI78V4 */ +#ifndef __CCRL__ +#error "The RI78V4 supports CC-RL compiler only." +#endif +#include "kernel.h" +#include "kernel_id.h" +#else +#endif + +/*********************************************************************************************************************** +Macro definitions +***********************************************************************************************************************/ +/* Multiple inclusion prevention macro */ +#ifndef R_RTOS_H +#define R_RTOS_H + +#endif /* R_RTOS_H */ + diff --git a/cores/rl78g22/smc_gen/r_bsp/mcu/all/start.S b/cores/rl78g22/smc_gen/r_bsp/mcu/all/start.S index de7afd8..b416671 100644 --- a/cores/rl78g22/smc_gen/r_bsp/mcu/all/start.S +++ b/cores/rl78g22/smc_gen/r_bsp/mcu/all/start.S @@ -1,275 +1,275 @@ -;;/*********************************************************************************************************************** -;;* DISCLAIMER -;;* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -;;* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -;;* applicable laws, including copyright laws. -;;* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -;;* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -;;* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -;;* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -;;* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -;;* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -;;* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -;;* this software. By using this software, you agree to the additional terms and conditions found by accessing the -;;* following link: -;;* http://www.renesas.com/disclaimer -;;* -;;* Copyright (C) 2021 Renesas Electronics Corporation. All rights reserved. -;;***********************************************************************************************************************/ -;;/*********************************************************************************************************************** -;;* File Name : start.S -;;* Description : -;;***********************************************************************************************************************/ -;;/*********************************************************************************************************************** -;;* History : DD.MM.YYYY Version Description -;;* : 08.03.2021 1.00 First Release -;;* : 23.06.2021 1.11 Renamed the following section -;;* - __mdata -;;* - __ebss -;;* - __bss -;;* - __edata -;;* : 04.08.2021 1.12 Updated base file version 1.05 to 1.06 -;;* Added processing for C++ -;;* : 25.11.2021 1.13 Deleted processing for C++ -;;* : 28.02.2022 1.20 Added inclusion of r_bsp_config.inc. -;;* Added RAMSAR register setting. -;; -;;***********************************************************************************************************************/ - -/************************************************************************/ -/* File Version: V1.06 */ -/* Date Generated: 09/06/2021 */ -/************************************************************************/ - - /*reset_program.asm*/ - - .global _PowerON_Reset /*! global Start routine */ - .short _PowerON_Reset - -#ifdef CPPAPP -___dso_handle: - .global ___dso_handle -#endif - - - .extern _bsp_init_system /*! external Sub-routine to initialise BSP*/ - .extern __data - .extern __mdata - .extern __ebss - .extern __bss - .extern __edata - .extern _bsp_init_hardware /*! external Sub-routine to initialise Hardware*/ - .extern _main - .extern __stack - .extern _exit - .extern ___do_init - .extern ___do_fini - - /* ;; HL = start of list - ;; DE = end of list - ;; BC = step direction (+2 or -2) - */ - - .include "r_bsp_config.inc" - - .text - -/* call to _PowerON_Reset */ -_PowerON_Reset: -/* initialise RAMSAR register */ -.ifdef BSP_CFG_ASM_RAM_GUARD_START_ADDRESS - movw hl, #BSP_CFG_ASM_RAMSAR_ADDRESS - mov [hl], #BSP_CFG_ASM_RAM_GUARD_START_ADDRESS -.endif - -/* initialise user stack pointer */ - movw sp,#__stack /* Set stack pointer */ - -/* call the bsp initialiser */ - call !!_bsp_init_system - nop - -/* load data section from ROM to RAM */ -;; block move to initialize .data - - mov es, #0 - movw bc, #__romdatacopysize -1: - movw ax, bc - cmpw ax, #0 - bz $1f - decw bc - decw bc - movw ax, es:__romdatastart[bc] - movw __datastart[bc], ax - br $1b - -1: - mov es, #0 - movw bc, #__romdatafcopysize -1: - movw ax, bc - cmpw ax, #0 - bz $1f - decw bc - decw bc - movw ax, es:__romdatafstart[bc] - movw __datafstart[bc], ax - br $1b - -1: - mov es, #0 - movw bc, #__romsdatacopysize -1: - movw ax, bc - cmpw ax, #0 - bz $1f - decw bc - decw bc - movw ax, es:__romsdatastart[bc] - movw __sdatastart[bc], ax - br $1b - -1: - mov es, #0 - movw bc, #__romsaddrcopysize -1: - movw ax, bc - cmpw ax, #0 - bz $1f - decw bc - decw bc - movw ax, es:__romsaddrstart[bc] - movw __saddrstart[bc], ax - br $1b -1: - -;; block fill to .sbss - movw bc, #__sbsssize - movw ax, #0 - cmpw ax, bc - bz $_sbss_zero_done -1: - decw bc - decw bc - movw __sbssstart[bc], ax - cmpw ax, bc - bnz $1b - -_sbss_zero_done: - -;; block fill to .bss - - movw bc, #__bsssize - movw ax, #0 - cmpw ax, bc - bz $_bss_zero_done -1: - decw bc - decw bc - movw __bssstart[bc], ax - cmpw ax, bc - bnz $1b - -_bss_zero_done: - - -;; block fill to .bssf - - movw bc, #__bssfsize - movw ax, #0 - cmpw ax, bc - bz $_bssf_zero_done -1: - decw bc - decw bc - movw __bssfstart[bc], ax - cmpw ax, bc - bnz $1b - -_bssf_zero_done: - - -/* call the hardware initialiser */ - call !!_bsp_init_hardware - nop - - call !!__rl78_init - -/* start user program */ - - clrw ax /* argv */ - clrw bc /* argc */ - call !!_main - -/* call to exit*/ -_exit: - br $_exit - - -.global _rl78_run_preinit_array -.type _rl78_run_preinit_array,@function -_rl78_run_preinit_array: - movw hl, #__preinit_array_start - movw de, #__preinit_array_end - movw bc, #-2 - br $_rl78_run_inilist - - .global _rl78_run_init_array - .type _rl78_run_init_array,@function -_rl78_run_init_array: - movw hl, #__init_array_start - movw de, #__init_array_end - movw bc, #2 - br $_rl78_run_inilist - - .global _rl78_run_fini_array - .type _rl78_run_fini_array,@function -_rl78_run_fini_array: - movw hl, #__fini_array_start - movw de, #__fini_array_end - movw bc, #-2 - /* fall through */ - - ;; HL = start of list - ;; DE = end of list - ;; BC = step direction (+2 or -2) -_rl78_run_inilist: -next_inilist: - movw ax, hl - cmpw ax, de - bz $done_inilist - movw ax, [hl] - cmpw ax, #-1 - bz $skip_inilist - cmpw ax, #0 - bz $skip_inilist - push ax - push bc - push de - push hl - call ax - pop hl - pop de - pop bc - pop ax -skip_inilist: - movw ax, hl - addw ax, bc - movw hl, ax - br $next_inilist -done_inilist: - ret - - .section .init,"ax" - - .global __rl78_init -__rl78_init: - call !!_rl78_run_preinit_array - call !!_rl78_run_init_array - ret - - .section .fini,"ax" - - .global __rl78_fini -.end +;;/*********************************************************************************************************************** +;;* DISCLAIMER +;;* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +;;* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +;;* applicable laws, including copyright laws. +;;* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +;;* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +;;* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +;;* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +;;* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +;;* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;;* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +;;* this software. By using this software, you agree to the additional terms and conditions found by accessing the +;;* following link: +;;* http://www.renesas.com/disclaimer +;;* +;;* Copyright (C) 2021 Renesas Electronics Corporation. All rights reserved. +;;***********************************************************************************************************************/ +;;/*********************************************************************************************************************** +;;* File Name : start.S +;;* Description : +;;***********************************************************************************************************************/ +;;/*********************************************************************************************************************** +;;* History : DD.MM.YYYY Version Description +;;* : 08.03.2021 1.00 First Release +;;* : 23.06.2021 1.11 Renamed the following section +;;* - __mdata +;;* - __ebss +;;* - __bss +;;* - __edata +;;* : 04.08.2021 1.12 Updated base file version 1.05 to 1.06 +;;* Added processing for C++ +;;* : 25.11.2021 1.13 Deleted processing for C++ +;;* : 28.02.2022 1.20 Added inclusion of r_bsp_config.inc. +;;* Added RAMSAR register setting. +;; +;;***********************************************************************************************************************/ + +/************************************************************************/ +/* File Version: V1.06 */ +/* Date Generated: 09/06/2021 */ +/************************************************************************/ + + /*reset_program.asm*/ + + .global _PowerON_Reset /*! global Start routine */ + .short _PowerON_Reset + +#ifdef CPPAPP +___dso_handle: + .global ___dso_handle +#endif + + + .extern _bsp_init_system /*! external Sub-routine to initialise BSP*/ + .extern __data + .extern __mdata + .extern __ebss + .extern __bss + .extern __edata + .extern _bsp_init_hardware /*! external Sub-routine to initialise Hardware*/ + .extern _main + .extern __stack + .extern _exit + .extern ___do_init + .extern ___do_fini + + /* ;; HL = start of list + ;; DE = end of list + ;; BC = step direction (+2 or -2) + */ + + .include "r_bsp_config.inc" + + .text + +/* call to _PowerON_Reset */ +_PowerON_Reset: +/* initialise RAMSAR register */ +.ifdef BSP_CFG_ASM_RAM_GUARD_START_ADDRESS + movw hl, #BSP_CFG_ASM_RAMSAR_ADDRESS + mov [hl], #BSP_CFG_ASM_RAM_GUARD_START_ADDRESS +.endif + +/* initialise user stack pointer */ + movw sp,#__stack /* Set stack pointer */ + +/* call the bsp initialiser */ + call !!_bsp_init_system + nop + +/* load data section from ROM to RAM */ +;; block move to initialize .data + + mov es, #0 + movw bc, #__romdatacopysize +1: + movw ax, bc + cmpw ax, #0 + bz $1f + decw bc + decw bc + movw ax, es:__romdatastart[bc] + movw __datastart[bc], ax + br $1b + +1: + mov es, #0 + movw bc, #__romdatafcopysize +1: + movw ax, bc + cmpw ax, #0 + bz $1f + decw bc + decw bc + movw ax, es:__romdatafstart[bc] + movw __datafstart[bc], ax + br $1b + +1: + mov es, #0 + movw bc, #__romsdatacopysize +1: + movw ax, bc + cmpw ax, #0 + bz $1f + decw bc + decw bc + movw ax, es:__romsdatastart[bc] + movw __sdatastart[bc], ax + br $1b + +1: + mov es, #0 + movw bc, #__romsaddrcopysize +1: + movw ax, bc + cmpw ax, #0 + bz $1f + decw bc + decw bc + movw ax, es:__romsaddrstart[bc] + movw __saddrstart[bc], ax + br $1b +1: + +;; block fill to .sbss + movw bc, #__sbsssize + movw ax, #0 + cmpw ax, bc + bz $_sbss_zero_done +1: + decw bc + decw bc + movw __sbssstart[bc], ax + cmpw ax, bc + bnz $1b + +_sbss_zero_done: + +;; block fill to .bss + + movw bc, #__bsssize + movw ax, #0 + cmpw ax, bc + bz $_bss_zero_done +1: + decw bc + decw bc + movw __bssstart[bc], ax + cmpw ax, bc + bnz $1b + +_bss_zero_done: + + +;; block fill to .bssf + + movw bc, #__bssfsize + movw ax, #0 + cmpw ax, bc + bz $_bssf_zero_done +1: + decw bc + decw bc + movw __bssfstart[bc], ax + cmpw ax, bc + bnz $1b + +_bssf_zero_done: + + +/* call the hardware initialiser */ + call !!_bsp_init_hardware + nop + + call !!__rl78_init + +/* start user program */ + + clrw ax /* argv */ + clrw bc /* argc */ + call !!_main + +/* call to exit*/ +_exit: + br $_exit + + +.global _rl78_run_preinit_array +.type _rl78_run_preinit_array,@function +_rl78_run_preinit_array: + movw hl, #__preinit_array_start + movw de, #__preinit_array_end + movw bc, #-2 + br $_rl78_run_inilist + + .global _rl78_run_init_array + .type _rl78_run_init_array,@function +_rl78_run_init_array: + movw hl, #__init_array_start + movw de, #__init_array_end + movw bc, #2 + br $_rl78_run_inilist + + .global _rl78_run_fini_array + .type _rl78_run_fini_array,@function +_rl78_run_fini_array: + movw hl, #__fini_array_start + movw de, #__fini_array_end + movw bc, #-2 + /* fall through */ + + ;; HL = start of list + ;; DE = end of list + ;; BC = step direction (+2 or -2) +_rl78_run_inilist: +next_inilist: + movw ax, hl + cmpw ax, de + bz $done_inilist + movw ax, [hl] + cmpw ax, #-1 + bz $skip_inilist + cmpw ax, #0 + bz $skip_inilist + push ax + push bc + push de + push hl + call ax + pop hl + pop de + pop bc + pop ax +skip_inilist: + movw ax, hl + addw ax, bc + movw hl, ax + br $next_inilist +done_inilist: + ret + + .section .init,"ax" + + .global __rl78_init +__rl78_init: + call !!_rl78_run_preinit_array + call !!_rl78_run_init_array + ret + + .section .fini,"ax" + + .global __rl78_fini +.end diff --git a/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/mcu_clocks.c b/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/mcu_clocks.c index a7858e1..63fb2d5 100644 --- a/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/mcu_clocks.c +++ b/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/mcu_clocks.c @@ -1,911 +1,911 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -* this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* File Name : mcu_clocks.c -* Description : -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* History : DD.MM.YYYY Version Description -* : 20.04.2022 1.50 First Release - -***********************************************************************************************************************/ -/************************************************* - * Includes , "Project Includes" - *************************************************/ -#include "platform.h" - -/************************************************* - * Macro definitions - *************************************************/ - -/************************************************* - * External function Prototypes - *************************************************/ - -#if BSP_CFG_WDT_REFRESH_ENABLE == 2 -/* If user is requesting Watchdog Timer callback functions then these are the prototypes. */ -void BSP_CFG_USER_WDT_REFRESH_SETTING_FUNCTION(void); -#endif - -/************************************************* - * Private global variables and functions - *************************************************/ -/* Frequency of the high-speed on-chip oscillator */ -#if BSP_CFG_GET_FREQ_API_FUNCTIONS_DISABLE == 0 -const uint32_t g_fih_hz[] = { - 24000000, - 12000000, - 6000000, - 3000000, - 0, /* Setting prohibited */ - 0, /* Setting prohibited */ - 0, /* Setting prohibited */ - 0, /* Setting prohibited */ - 32000000, - 16000000, - 8000000, - 4000000, - 2000000, - 1000000, - 0, /* Setting prohibited */ - 0 /* Setting prohibited */ -}; -#endif - -/* Frequency of Middle-speed on-chip oscillator */ -#if BSP_CFG_GET_FREQ_API_FUNCTIONS_DISABLE == 0 -const uint32_t g_fim_hz[] = { - 4000000, - 2000000, - 1000000, - 0 -}; -#endif - -/************************************************* - * Function definition - *************************************************/ -/************************************************* - * Function name: start_clock - * Description : Start the specified clock - * Arguments : Clock to start - * Return value : BSP_OK if the specified clock is started. - * BSP_ARG_ERROR if the specified clock is incorrect. -**************************************************/ -#if BSP_CFG_CLOCK_OPERATION_API_FUNCTIONS_DISABLE == 0 -e_bsp_err_t start_clock(e_clock_mode_t mode) -{ - e_bsp_err_t status = BSP_OK; -#if BSP_CFG_HISYSCLK_SOURCE == 1 - uint8_t tmp_stab_wait; - uint8_t tmp_stab_set; -#endif - volatile uint32_t w_count; - - switch (mode) - { - case SYSCLK: - - if (1U == MSTOP) - { - MSTOP = 0U; - -#if BSP_CFG_HISYSCLK_SOURCE == 1 - tmp_stab_set = (uint8_t)~(0x7FU >> OSTS); - - /* WAIT_LOOP */ - do - { - tmp_stab_wait = OSTC; - tmp_stab_wait &= tmp_stab_set; - } - while (tmp_stab_wait != tmp_stab_set); -#endif - } - - break; - - case SXCLK: - - if (1U == XTSTOP) - { - XTSTOP = 0U; - -#if BSP_CFG_SUBCLK_SOURCE == 1 - /* WAIT_LOOP */ - for (w_count = 0U; w_count <= BSP_CFG_SUBWAITTIME; w_count++) - { -#if BSP_CFG_WDT_REFRESH_ENABLE == 0 - BSP_NOP(); -#elif BSP_CFG_WDT_REFRESH_ENABLE == 1 - WDTE = 0xACU; -#else - BSP_CFG_USER_WDT_REFRESH_SETTING_FUNCTION(); -#endif - } -#endif - } - - break; - - case HIOCLK: - - if (1U == HIOSTOP) - { - HIOSTOP = 0U; - - /* WAIT_LOOP */ - for (w_count = 0U; w_count <= BSP_CFG_FIHWAITTIME; w_count++) - { - BSP_NOP(); - } - } - - break; - - case MIOCLK: - - if (0U == MIOEN) - { - MIOEN = 1U; - - /* WAIT_LOOP */ - for (w_count = 0U; w_count <= BSP_CFG_FIMWAITTIME; w_count++) - { - BSP_NOP(); - } - } - - break; - - default: - - status = BSP_ARG_ERROR; - - break; - - } - - return status; -} /* End of function start_clock() */ -#endif /* BSP_CFG_CLOCK_OPERATION_API_FUNCTIONS_DISABLE == 0 */ - -/************************************************* - * Function name: stop_clock - * Description : Stop the specified clock - * Arguments : Clock to stop - * Return value : BSP_OK if the specified clock is stopped. - * BSP_ARG_ERROR if the specified clock is incorrect. -**************************************************/ -#if BSP_CFG_CLOCK_OPERATION_API_FUNCTIONS_DISABLE == 0 -e_bsp_err_t stop_clock(e_clock_mode_t mode) -{ - e_bsp_err_t status = BSP_OK; - - switch (mode) - { - case SYSCLK: - - MSTOP = 1U; - - break; - - case SXCLK: - - XTSTOP = 1U; - - break; - - case HIOCLK: - - HIOSTOP = 1U; - - break; - - case MIOCLK: - - MIOEN = 0U; - - break; - - default: - - status = BSP_ARG_ERROR; - - break; - - } - - return status; -} /* End of function stop_clock() */ -#endif /* BSP_CFG_CLOCK_OPERATION_API_FUNCTIONS_DISABLE == 0 */ - -/************************************************* - * Function name: set_fclk_clock_source - * Description : Switch CPU/peripheral hardware clock(fCLK) clock source. - * Arguments : Clock to switch. - * Return value : BSP_OK when switching to the specified clock. - * BSP_ERROR1 The specified clock is not oscillating. - * BSP_ERROR2 When switching between clock resource, a clock resource that is not - * oscillating may have been switched to. - * BSP_ERROR3 An unsupported state transition was specified. Refer to the user's manual. - * BSP_ARG_ERROR An invalid argument was input. - * Attention : Start the clock to switch to before calling this function. -**************************************************/ -#if BSP_CFG_SET_CLOCK_SOURCE_API_FUNCTIONS_DISABLE == 0 -e_bsp_err_t set_fclk_clock_source(e_clock_mode_t mode) -{ - e_bsp_err_t status = BSP_OK; - e_clock_mode_t old_mode; - volatile uint32_t w_count; - - /* Get current clock source */ - if (1U == CLS) - { - if (1U == SELLOSC) - { - old_mode = LOCLK; - } - else - { - old_mode = SXCLK; - } - } - else - { - if (1U == MCS) - { - old_mode = SYSCLK; - } - else - { - if (1U == MCS1) - { - old_mode = MIOCLK; - } - else - { - old_mode = HIOCLK; - } - } - } - - /* Only switch if the current clock source and the - * specified clock source are different. - */ - if (mode != old_mode) - { - switch (mode) - { - case HIOCLK: - - if (1U == HIOSTOP) - { - /* Error if the high-speed on-chip oscillator is stopped. */ - status = BSP_ERROR1; - } -#if BSP_CFG_PARAM_CHECKING_ENABLE == 1 - else if ((1U == CLS) && ((0U != MCS) || (0U != MCS1))) - { - /* Error if the high-speed on-chip oscillator is not selected. */ - status = BSP_ERROR2; - } - else if ((SYSCLK == old_mode) && (0U != MCS1)) - { - /* Error if the high-speed on-chip oscillator is not selected. */ - status = BSP_ERROR2; - } -#endif - else - { - CSS = 0U; - - /* WAIT_LOOP */ - while (1U == CLS) - { - ; - } - - MCM0 = 0U; - MCM1 = 0U; - } - - break; - - case SYSCLK: - - if (1U == MSTOP) - { - /* Error if the high-speed system clock is stopped. */ - status = BSP_ERROR1; - } -#if BSP_CFG_PARAM_CHECKING_ENABLE == 1 -#if BSP_CFG_MCU_PART_PIN_NUM <= 6 - else if ((CMC & 0x48U) != 0x40U) - { - // Error if the high-speed system clock is invalid. - status = BSP_ERROR1; - } -#else - else if ((CMC & 0x40U) != 0x40U) - { - /* Error if the high-speed system clock is invalid. */ - status = BSP_ERROR1; - } -#endif - else if ((1U == CLS) && (1U != MCS)) - { - /* Error if the high-speed system clock is not selected. */ - status = BSP_ERROR2; - } -#endif - else - { - CSS = 0U; - - /* WAIT_LOOP */ - while (1U == CLS) - { - ; - } - - MCM0 = 1U; - } - - break; - - case SXCLK: - - if (1U == XTSTOP) - { - /* Error if the subsystem clock is stopped. */ - status = BSP_ERROR1; - } -#if BSP_CFG_PARAM_CHECKING_ENABLE == 1 -#if BSP_CFG_MCU_PART_PIN_NUM <= 6 - else if ((CMC & 0x18U) != 0x18U) - { - // Error if the subsystem clock is invalid. - status = BSP_ERROR1; - } -#else - else if ((CMC & 0x10U) != 0x10U) - { - /* Error if the subsystem clock is invalid. */ - status = BSP_ERROR1; - } -#endif - else if (LOCLK == old_mode) - { - status = BSP_ERROR3; - } -#endif - else - { - SELLOSC = 0U; - CSS = 1U; - - /* WAIT_LOOP */ - while (0U == CLS) - { - ; - } - } - - break; - - case MIOCLK: - - if (0U == MIOEN) - { - /* Error if the middle-speed on-chip oscillator is stopped. */ - status = BSP_ERROR1; - } -#if BSP_CFG_PARAM_CHECKING_ENABLE == 1 - else if ((1U == CLS) && ((0U != MCS) || (1U != MCS1))) - { - /* Error if the middle-speed on-chip oscillator is not selected. */ - status = BSP_ERROR2; - } - else if ((SYSCLK == old_mode) && (1U != MCS1)) - { - /* Error if the middle-speed on-chip oscillator is not selected. */ - status = BSP_ERROR2; - } -#endif - else - { - CSS = 0U; - - /* WAIT_LOOP */ - while (1U == CLS) - { - ; - } - - MCM0 = 0U; - MCM1 = 1U; - } - - break; - - case LOCLK: - -#if BSP_CFG_PARAM_CHECKING_ENABLE == 1 - if (SXCLK == old_mode) - { - status = BSP_ERROR3; - } - else if ((SYSCLK == old_mode) && (0U == XTSTOP)) - { - status = BSP_ERROR3; - } - else - { -#endif - SELLOSC = 1U; - - /* WAIT_LOOP */ - for (w_count = 0U; w_count <= BSP_CFG_FILWAITTIME; w_count++) - { - BSP_NOP(); - } - CSS = 1U; - - /* WAIT_LOOP */ - while (0U == CLS) - { - ; - } -#if BSP_CFG_PARAM_CHECKING_ENABLE == 1 - } -#endif - - break; - - default: - - status = BSP_ARG_ERROR; - - break; - - } - } - - return status; -} /* End of function set_fclk_clock_source() */ -#endif /* BSP_CFG_SET_CLOCK_SOURCE_API_FUNCTIONS_DISABLE == 0 */ - -/************************************************* - * Function name: get_fclk_freq_hz - * Description : Returns CPU/peripheral hardware clock(fCLK) frequency. - * Arguments : none - * Return value : CPU/peripheral hardware clock(fCLK) frequency specified by the r_bsp. - * Attention : Error if 0Hz is returned. - * When fCLK is a high-speed on-chip oscillator, 0Hz is returned - * when the value of the register to which it refers is out of the allowable range. -**************************************************/ -#if BSP_CFG_GET_FREQ_API_FUNCTIONS_DISABLE == 0 -uint32_t get_fclk_freq_hz(void) -{ - uint32_t sys_clock_src_freq; - - /* fCLK clock source is fSUB */ - /* fCLK : CPU/peripheral hardware clock */ - /* fSUB : Subsystem clock */ - if (1U == CLS) - { - /* fSUB clock source is fIL */ - /* fSUB : Subsystem clock */ - /* fIL : Low-speed on-chip oscillator clock */ - if (1U == SELLOSC) - { - sys_clock_src_freq = BSP_LOCO_HZ; - } - /* fSUB clock source is fSX */ - /* fSUB : Subsystem clock */ - /* fSX : Subsystem clock oscillator clock */ - else - { - /* fSX clock source is fXT */ - /* fSX : Subsystem clock oscillator clock */ - /* fXT : XT1 clock oscillation */ - sys_clock_src_freq = BSP_SUB_CLOCK_HZ; - } - } - /* fCLK clock source is fMAIN */ - /* fCLK : CPU/peripheral hardware clock */ - /* fMAIN : Main system clock */ - else - { - /* fMAIN clock source is fMX */ - /* fMAIN : Main system clock */ - /* fMX : High-speed system clock */ - if (1U == MCS) - { - /* fMX clock source is fX */ - /* fMX : High-speed system clock */ - /* fX : X1 clock oscillation */ - uint8_t i; - - /* WAIT_LOOP */ - sys_clock_src_freq = BSP_CFG_FMX_HZ; - - for (i = MOSCDIV; i > 0U; i--) - { - sys_clock_src_freq /= 2U; - } - } - /* fMAIN clock source is fOCO */ - /* fMAIN : Main system clock */ - /* fOCO : Main on-chip oscillator clock */ - else - { - /* fOCO clock source is fIM */ - /* fOCO : Main on-chip oscillator clock */ - /* fIM : Middle-speed on-chip oscillator clock */ - if (1U == MCS1) - { - sys_clock_src_freq = g_fim_hz[MOCODIV & 0x03U]; - } - /* fOCO clock source is fIH */ - /* fOCO : Main on-chip oscillator clock */ - /* fIH : High-speed on-chip oscillator clock */ - else - { - uint8_t temp1; - uint8_t temp2; - - temp1 = OPTBYTE_C2; - temp2 = HOCODIV; - - sys_clock_src_freq = g_fih_hz[(temp1 & 0x08U) | (temp2 & 0x07U)]; - } - } - } - - return sys_clock_src_freq; -} /* End of function get_fclk_freq_hz() */ -#endif /* BSP_CFG_GET_FREQ_API_FUNCTIONS_DISABLE == 0 */ - -/************************************************** - * Function name: change_clock_setting - * Description : Change the specified clock setting. - * Arguments : Clock to change setting. - * : Value to set for the specified clock. - * Return value : BSP_OK if the specified clock setting is changed. - * BSP_ERROR1 When the specified clock is stopped. - * BSP_ARG_ERROR An invalid argument was input. - * Attention : Stop the specified clock before calling this function. -**************************************************/ -#if BSP_CFG_CHANGE_CLOCK_SETTING_API_FUNCTIONS_DISABLE == 0 -e_bsp_err_t change_clock_setting(e_clock_mode_t mode, uint8_t *set_values) -{ - e_bsp_err_t status = BSP_OK; - - switch (mode) - { - case HIOCLK: - - if ((1U == HIOSTOP) || (1U == CLS) || (1U == MCS) || (1U == MCS1)) - { - status = BSP_ERROR1; - } - else - { - HOCODIV = set_values[0]; - } - - break; - - case MIOCLK: - - if (1U == MIOEN) - { - status = BSP_ERROR1; - } - else - { - MOCODIV = set_values[0]; - } - - break; - - case SYSCLK: - - if (0U == MSTOP) - { - status = BSP_ERROR1; - } - else - { - MOSCDIV = set_values[0]; - } - - break; - - default: - - /* Setting prohibited */ - status = BSP_ARG_ERROR; - - break; - - } - - return status; -} /* End of function change_clock_setting() */ -#endif /* BSP_CFG_CHANGE_CLOCK_SETTING_API_FUNCTIONS_DISABLE == 0 */ - -/************************************************* - * Function name: mcu_clock_setup - * Description : Clock initialization. - * Arguments : none - * Return value : none -**************************************************/ -#if BSP_CFG_STARTUP_DISABLE == 0 -void mcu_clock_setup(void) -{ - uint8_t cmc_tmp; - -#if BSP_CFG_MOCO_OPERATION == 1 || ((BSP_CFG_SUBCLK_OPERATION == 0) && (BSP_CFG_SUBCLK_SOURCE == 1)) || BSP_CFG_SUBSYSCLK_SOURCE == 1 - volatile uint32_t w_count; -#endif -#if (BSP_CFG_HISYSCLK_OPERATION == 0) && (BSP_CFG_HISYSCLK_SOURCE == 1) - uint8_t tmp_stab_wait; - uint8_t tmp_stab_set; -#endif - - cmc_tmp = 0x00U; - - /* High-speed system clock(fMX) setting */ -#if BSP_CFG_HISYSCLK_SOURCE == 0 - /* Not used. - * When using high-speed on-chip oscillator, - * when using middle-speed on-chip oscillator or - * when not using main system clock - */ -#elif BSP_CFG_HISYSCLK_SOURCE == 1 - /* fX(Crystal/ceramic resonator connection */ - /* High-speed system clock division register(MOSCDIV) setting */ - MOSCDIV = BSP_CFG_MOSC_DIVIDE; - - /* Control of X1 clock oscillation frequency(AMPH) setting */ -#if BSP_CFG_FMX_HZ >= 1000000 && BSP_CFG_FMX_HZ <= 10000000 - /* 1MHz <= fX <= 10MHz */ - cmc_tmp |= 0x40U; -#else - /* 10MHz < fX <= 20MHz */ - cmc_tmp |= 0x41U; -#endif -#else - /* fEX(External clock input) */ - /* High-speed system clock division register(MOSCDIV) setting */ - MOSCDIV = BSP_CFG_MOSC_DIVIDE; - - /* Control of X1 clock oscillation frequency(AMPH) setting */ -#if BSP_CFG_FMX_HZ >= 1000000 && BSP_CFG_FMX_HZ <= 10000000 - /* 1MHz <= fX <= 10MHz */ - cmc_tmp |= 0xC0U; -#else - /* 10MHz < fX <= 20MHz */ - cmc_tmp |= 0xC1U; -#endif -#endif /* BSP_CFG_HISYSCLK_SOURCE == 0 */ - - /* High-speed on-chip oscillator(fIH) setting */ - /* High-speed on-chip oscillator frequency select register(HOCODIV) setting */ - HOCODIV = BSP_CFG_HOCO_DIVIDE; - - /* Subsystem clock oscillator clock(fSX) setting */ -#if BSP_CFG_SUBCLK_SOURCE == 0 - /* Not used. - * When using the low-speed on-chip oscillator or - * when not using subsystem clock(fSUB) - */ -#elif BSP_CFG_SUBCLK_SOURCE == 1 -#if BSP_CFG_MCU_PART_PIN_NUM <= 6 - /* 30 - 36 pin device */ - /* XTSEL setting */ - cmc_tmp |= 0x08U; -#endif - /* fXT(Crystal resonator connection) */ -#if BSP_CFG_XT1_OSCMODE == 0 - /* Low power consumption oscillation 1(default) */ - /* EXCLKS/OSCSELS/AMPHS1/AMPHS0 setting */ - cmc_tmp |= 0x10U; -#elif BSP_CFG_XT1_OSCMODE == 1 - /* Normal oscillation */ - /* EXCLKS/OSCSELS/AMPHS1/AMPHS0 setting */ - cmc_tmp |= 0x12U; -#elif BSP_CFG_XT1_OSCMODE == 2 - /* Low power consumption oscillation 2 */ - /* EXCLKS/OSCSELS/AMPHS1/AMPHS0 setting */ - cmc_tmp |= 0x14U; -#else - /* Low power consumption oscillation 3 */ - /* EXCLKS/OSCSELS/AMPHS1/AMPHS0 setting */ - cmc_tmp |= 0x16U; -#endif -#else -#if BSP_CFG_MCU_PART_PIN_NUM <= 6 - /* 30 - 36 pin device */ - /* XTSEL setting */ - cmc_tmp |= 0x08U; -#endif - /* fEXS(External subsystem clock) */ - /* EXCLKS/OSCSELS setting */ - cmc_tmp |= 0x30U; -#endif /* BSP_CFG_SUBCLK_SOURCE == 0 */ - /* Clock operation mode control register(CMC) setting */ - CMC = cmc_tmp; - - /* Middle-speed on-chip oscillator clock(fIM) setting */ -#if BSP_CFG_MOCO_OPERATION == 1 - MOCODIV = BSP_CFG_MOCO_DIVIDE; -#endif - - /* When to use X1 clock oscillator(fX) */ -#if BSP_CFG_HISYSCLK_SOURCE == 1 - /* Oscillation stabilization time select register(OSTS) setting */ - OSTS = BSP_CFG_X1_WAIT_TIME_SEL; -#endif - - /* High-speed system clock oscillation */ -#if BSP_CFG_HISYSCLK_OPERATION == 0 - /* Start oscillation */ - MSTOP = 0U; - -#if BSP_CFG_HISYSCLK_SOURCE == 1 - /* Wait for oscillation stabilization unless external clock input */ - tmp_stab_set = (uint8_t)~(0x7FU >> OSTS); - - /* WAIT_LOOP */ - do - { - tmp_stab_wait = OSTC; - tmp_stab_wait &= tmp_stab_set; - } - while (tmp_stab_wait != tmp_stab_set); -#endif -#else - /* X1 oscillation stopped if high-speed system clock is not used */ - MSTOP = 1U; -#endif - - /* When to use middle-speed on-chip oscillator clock(fIM) */ -#if BSP_CFG_MOCO_OPERATION == 1 - MIOEN = 1U; - - /* WAIT_LOOP */ - for (w_count = 0U; w_count <= BSP_CFG_FIMWAITTIME; w_count++) - { - BSP_NOP(); - } -#else - /* Oscillation stopped if middle-speed on-chip oscillator clock(fIM) is not used */ - MIOEN = 0U; -#endif - - /* Main on-chip oscillator clock(fOCO) setting */ -#if BSP_CFG_OCOCLK_SOURCE == 0 - /* High-speed on-chip oscillator clock(fIH) */ - MCM1 = 0U; -#else - /* Middle-speed on-chip oscillator clock(fIM) */ - MCM1 = 1U; -#endif - - /* Main system clock(fMAIN) setting */ -#if BSP_CFG_MAINCLK_SOURCE == 0 - /* Main on-chip oscillator clock(fOCO) */ - MCM0 = 0U; -#else - /* High-speed system clock(fMX) */ - MCM0 = 1U; -#endif - - /* Subsystem clock oscillation */ - - /* Subsystem clock supply mode control register(OSMC) setting */ -#if BSP_CFG_ALLOW_FSUB_IN_STOPHALT == 0 && BSP_CFG_RTC_OUT_CLK_SOURCE == 0 - OSMC |= 0x00U; -#elif BSP_CFG_ALLOW_FSUB_IN_STOPHALT == 1 && BSP_CFG_RTC_OUT_CLK_SOURCE == 0 - OSMC |= 0x80U; -#elif BSP_CFG_ALLOW_FSUB_IN_STOPHALT == 0 && BSP_CFG_RTC_OUT_CLK_SOURCE == 1 - OSMC |= 0x10U; -#else - OSMC |= 0x90U; -#endif - - /* When to use subsystem clock oscillator clock(fSX) */ - /* Subsystem clock oscillator clock oscillation */ -#if BSP_CFG_SUBCLK_OPERATION == 0 - /* Start oscillation */ - XTSTOP = 0U; - -#if BSP_CFG_SUBCLK_SOURCE == 1 - /* Wait for oscillation stabilization unless external clock input */ - /* WAIT_LOOP */ - for (w_count = 0U; w_count <= BSP_CFG_SUBWAITTIME; w_count++) - { -#if BSP_CFG_WDT_REFRESH_ENABLE == 0 - BSP_NOP(); -#elif BSP_CFG_WDT_REFRESH_ENABLE == 1 - WDTE = 0xACU; -#else - BSP_CFG_USER_WDT_REFRESH_SETTING_FUNCTION(); -#endif - } -#endif - -#else - /* XT1 oscillator stopped if subsystem clock oscillator clock is not used */ - XTSTOP = 1U; -#endif - -#if BSP_CFG_SUBSYSCLK_SOURCE == 1 - SELLOSC = 1U; - /* WAIT_LOOP */ - for (w_count = 0U; w_count <= BSP_CFG_FILWAITTIME; w_count++) - { - BSP_NOP(); - } -#endif - - /* fCLK selection */ -#if BSP_CFG_FCLK_SOURCE == 0 - /* When using a high-speed system clock, high-speed on-chip oscillator, - * or middle-speed on-chip oscillator - */ - CSS = 0U; - - /* WAIT_LOOP */ - while (1U == CLS) - { - ; - } -#else - /* When using subsystem clock or low-speed on-chip oscillator */ - CSS = 1U; - - /* WAIT_LOOP */ - while (0U == CLS) - { - ; - } -#endif - - /* Starts high-speed on-chip oscillator */ - /* Only the high-speed on-chip oscillator is activated after reset, - * so stop this clock last. - */ -#if BSP_CFG_FIH_START_ON_STARTUP == 1 - /* High-speed on-chip oscillator startup setting at - * STOP mode release and SNOOZE mode transition. - */ -#if (BSP_CFG_OCOCLK_SOURCE == 0) && (BSP_CFG_MAINCLK_SOURCE == 0) && (BSP_CFG_FCLK_SOURCE == 0) - FWKUP = BSP_CFG_WAKEUP_MODE; -#endif - HIOSTOP = 0U; -#else - HIOSTOP = 1U; -#endif -} /* End of function mcu_clock_setup() */ -#endif /* BSP_CFG_STARTUP_DISABLE == 0 */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +* this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* File Name : mcu_clocks.c +* Description : +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* History : DD.MM.YYYY Version Description +* : 20.04.2022 1.50 First Release + +***********************************************************************************************************************/ +/************************************************* + * Includes , "Project Includes" + *************************************************/ +#include "platform.h" + +/************************************************* + * Macro definitions + *************************************************/ + +/************************************************* + * External function Prototypes + *************************************************/ + +#if BSP_CFG_WDT_REFRESH_ENABLE == 2 +/* If user is requesting Watchdog Timer callback functions then these are the prototypes. */ +void BSP_CFG_USER_WDT_REFRESH_SETTING_FUNCTION(void); +#endif + +/************************************************* + * Private global variables and functions + *************************************************/ +/* Frequency of the high-speed on-chip oscillator */ +#if BSP_CFG_GET_FREQ_API_FUNCTIONS_DISABLE == 0 +const uint32_t g_fih_hz[] = { + 24000000, + 12000000, + 6000000, + 3000000, + 0, /* Setting prohibited */ + 0, /* Setting prohibited */ + 0, /* Setting prohibited */ + 0, /* Setting prohibited */ + 32000000, + 16000000, + 8000000, + 4000000, + 2000000, + 1000000, + 0, /* Setting prohibited */ + 0 /* Setting prohibited */ +}; +#endif + +/* Frequency of Middle-speed on-chip oscillator */ +#if BSP_CFG_GET_FREQ_API_FUNCTIONS_DISABLE == 0 +const uint32_t g_fim_hz[] = { + 4000000, + 2000000, + 1000000, + 0 +}; +#endif + +/************************************************* + * Function definition + *************************************************/ +/************************************************* + * Function name: start_clock + * Description : Start the specified clock + * Arguments : Clock to start + * Return value : BSP_OK if the specified clock is started. + * BSP_ARG_ERROR if the specified clock is incorrect. +**************************************************/ +#if BSP_CFG_CLOCK_OPERATION_API_FUNCTIONS_DISABLE == 0 +e_bsp_err_t start_clock(e_clock_mode_t mode) +{ + e_bsp_err_t status = BSP_OK; +#if BSP_CFG_HISYSCLK_SOURCE == 1 + uint8_t tmp_stab_wait; + uint8_t tmp_stab_set; +#endif + volatile uint32_t w_count; + + switch (mode) + { + case SYSCLK: + + if (1U == MSTOP) + { + MSTOP = 0U; + +#if BSP_CFG_HISYSCLK_SOURCE == 1 + tmp_stab_set = (uint8_t)~(0x7FU >> OSTS); + + /* WAIT_LOOP */ + do + { + tmp_stab_wait = OSTC; + tmp_stab_wait &= tmp_stab_set; + } + while (tmp_stab_wait != tmp_stab_set); +#endif + } + + break; + + case SXCLK: + + if (1U == XTSTOP) + { + XTSTOP = 0U; + +#if BSP_CFG_SUBCLK_SOURCE == 1 + /* WAIT_LOOP */ + for (w_count = 0U; w_count <= BSP_CFG_SUBWAITTIME; w_count++) + { +#if BSP_CFG_WDT_REFRESH_ENABLE == 0 + BSP_NOP(); +#elif BSP_CFG_WDT_REFRESH_ENABLE == 1 + WDTE = 0xACU; +#else + BSP_CFG_USER_WDT_REFRESH_SETTING_FUNCTION(); +#endif + } +#endif + } + + break; + + case HIOCLK: + + if (1U == HIOSTOP) + { + HIOSTOP = 0U; + + /* WAIT_LOOP */ + for (w_count = 0U; w_count <= BSP_CFG_FIHWAITTIME; w_count++) + { + BSP_NOP(); + } + } + + break; + + case MIOCLK: + + if (0U == MIOEN) + { + MIOEN = 1U; + + /* WAIT_LOOP */ + for (w_count = 0U; w_count <= BSP_CFG_FIMWAITTIME; w_count++) + { + BSP_NOP(); + } + } + + break; + + default: + + status = BSP_ARG_ERROR; + + break; + + } + + return status; +} /* End of function start_clock() */ +#endif /* BSP_CFG_CLOCK_OPERATION_API_FUNCTIONS_DISABLE == 0 */ + +/************************************************* + * Function name: stop_clock + * Description : Stop the specified clock + * Arguments : Clock to stop + * Return value : BSP_OK if the specified clock is stopped. + * BSP_ARG_ERROR if the specified clock is incorrect. +**************************************************/ +#if BSP_CFG_CLOCK_OPERATION_API_FUNCTIONS_DISABLE == 0 +e_bsp_err_t stop_clock(e_clock_mode_t mode) +{ + e_bsp_err_t status = BSP_OK; + + switch (mode) + { + case SYSCLK: + + MSTOP = 1U; + + break; + + case SXCLK: + + XTSTOP = 1U; + + break; + + case HIOCLK: + + HIOSTOP = 1U; + + break; + + case MIOCLK: + + MIOEN = 0U; + + break; + + default: + + status = BSP_ARG_ERROR; + + break; + + } + + return status; +} /* End of function stop_clock() */ +#endif /* BSP_CFG_CLOCK_OPERATION_API_FUNCTIONS_DISABLE == 0 */ + +/************************************************* + * Function name: set_fclk_clock_source + * Description : Switch CPU/peripheral hardware clock(fCLK) clock source. + * Arguments : Clock to switch. + * Return value : BSP_OK when switching to the specified clock. + * BSP_ERROR1 The specified clock is not oscillating. + * BSP_ERROR2 When switching between clock resource, a clock resource that is not + * oscillating may have been switched to. + * BSP_ERROR3 An unsupported state transition was specified. Refer to the user's manual. + * BSP_ARG_ERROR An invalid argument was input. + * Attention : Start the clock to switch to before calling this function. +**************************************************/ +#if BSP_CFG_SET_CLOCK_SOURCE_API_FUNCTIONS_DISABLE == 0 +e_bsp_err_t set_fclk_clock_source(e_clock_mode_t mode) +{ + e_bsp_err_t status = BSP_OK; + e_clock_mode_t old_mode; + volatile uint32_t w_count; + + /* Get current clock source */ + if (1U == CLS) + { + if (1U == SELLOSC) + { + old_mode = LOCLK; + } + else + { + old_mode = SXCLK; + } + } + else + { + if (1U == MCS) + { + old_mode = SYSCLK; + } + else + { + if (1U == MCS1) + { + old_mode = MIOCLK; + } + else + { + old_mode = HIOCLK; + } + } + } + + /* Only switch if the current clock source and the + * specified clock source are different. + */ + if (mode != old_mode) + { + switch (mode) + { + case HIOCLK: + + if (1U == HIOSTOP) + { + /* Error if the high-speed on-chip oscillator is stopped. */ + status = BSP_ERROR1; + } +#if BSP_CFG_PARAM_CHECKING_ENABLE == 1 + else if ((1U == CLS) && ((0U != MCS) || (0U != MCS1))) + { + /* Error if the high-speed on-chip oscillator is not selected. */ + status = BSP_ERROR2; + } + else if ((SYSCLK == old_mode) && (0U != MCS1)) + { + /* Error if the high-speed on-chip oscillator is not selected. */ + status = BSP_ERROR2; + } +#endif + else + { + CSS = 0U; + + /* WAIT_LOOP */ + while (1U == CLS) + { + ; + } + + MCM0 = 0U; + MCM1 = 0U; + } + + break; + + case SYSCLK: + + if (1U == MSTOP) + { + /* Error if the high-speed system clock is stopped. */ + status = BSP_ERROR1; + } +#if BSP_CFG_PARAM_CHECKING_ENABLE == 1 +#if BSP_CFG_MCU_PART_PIN_NUM <= 6 + else if ((CMC & 0x48U) != 0x40U) + { + // Error if the high-speed system clock is invalid. + status = BSP_ERROR1; + } +#else + else if ((CMC & 0x40U) != 0x40U) + { + /* Error if the high-speed system clock is invalid. */ + status = BSP_ERROR1; + } +#endif + else if ((1U == CLS) && (1U != MCS)) + { + /* Error if the high-speed system clock is not selected. */ + status = BSP_ERROR2; + } +#endif + else + { + CSS = 0U; + + /* WAIT_LOOP */ + while (1U == CLS) + { + ; + } + + MCM0 = 1U; + } + + break; + + case SXCLK: + + if (1U == XTSTOP) + { + /* Error if the subsystem clock is stopped. */ + status = BSP_ERROR1; + } +#if BSP_CFG_PARAM_CHECKING_ENABLE == 1 +#if BSP_CFG_MCU_PART_PIN_NUM <= 6 + else if ((CMC & 0x18U) != 0x18U) + { + // Error if the subsystem clock is invalid. + status = BSP_ERROR1; + } +#else + else if ((CMC & 0x10U) != 0x10U) + { + /* Error if the subsystem clock is invalid. */ + status = BSP_ERROR1; + } +#endif + else if (LOCLK == old_mode) + { + status = BSP_ERROR3; + } +#endif + else + { + SELLOSC = 0U; + CSS = 1U; + + /* WAIT_LOOP */ + while (0U == CLS) + { + ; + } + } + + break; + + case MIOCLK: + + if (0U == MIOEN) + { + /* Error if the middle-speed on-chip oscillator is stopped. */ + status = BSP_ERROR1; + } +#if BSP_CFG_PARAM_CHECKING_ENABLE == 1 + else if ((1U == CLS) && ((0U != MCS) || (1U != MCS1))) + { + /* Error if the middle-speed on-chip oscillator is not selected. */ + status = BSP_ERROR2; + } + else if ((SYSCLK == old_mode) && (1U != MCS1)) + { + /* Error if the middle-speed on-chip oscillator is not selected. */ + status = BSP_ERROR2; + } +#endif + else + { + CSS = 0U; + + /* WAIT_LOOP */ + while (1U == CLS) + { + ; + } + + MCM0 = 0U; + MCM1 = 1U; + } + + break; + + case LOCLK: + +#if BSP_CFG_PARAM_CHECKING_ENABLE == 1 + if (SXCLK == old_mode) + { + status = BSP_ERROR3; + } + else if ((SYSCLK == old_mode) && (0U == XTSTOP)) + { + status = BSP_ERROR3; + } + else + { +#endif + SELLOSC = 1U; + + /* WAIT_LOOP */ + for (w_count = 0U; w_count <= BSP_CFG_FILWAITTIME; w_count++) + { + BSP_NOP(); + } + CSS = 1U; + + /* WAIT_LOOP */ + while (0U == CLS) + { + ; + } +#if BSP_CFG_PARAM_CHECKING_ENABLE == 1 + } +#endif + + break; + + default: + + status = BSP_ARG_ERROR; + + break; + + } + } + + return status; +} /* End of function set_fclk_clock_source() */ +#endif /* BSP_CFG_SET_CLOCK_SOURCE_API_FUNCTIONS_DISABLE == 0 */ + +/************************************************* + * Function name: get_fclk_freq_hz + * Description : Returns CPU/peripheral hardware clock(fCLK) frequency. + * Arguments : none + * Return value : CPU/peripheral hardware clock(fCLK) frequency specified by the r_bsp. + * Attention : Error if 0Hz is returned. + * When fCLK is a high-speed on-chip oscillator, 0Hz is returned + * when the value of the register to which it refers is out of the allowable range. +**************************************************/ +#if BSP_CFG_GET_FREQ_API_FUNCTIONS_DISABLE == 0 +uint32_t get_fclk_freq_hz(void) +{ + uint32_t sys_clock_src_freq; + + /* fCLK clock source is fSUB */ + /* fCLK : CPU/peripheral hardware clock */ + /* fSUB : Subsystem clock */ + if (1U == CLS) + { + /* fSUB clock source is fIL */ + /* fSUB : Subsystem clock */ + /* fIL : Low-speed on-chip oscillator clock */ + if (1U == SELLOSC) + { + sys_clock_src_freq = BSP_LOCO_HZ; + } + /* fSUB clock source is fSX */ + /* fSUB : Subsystem clock */ + /* fSX : Subsystem clock oscillator clock */ + else + { + /* fSX clock source is fXT */ + /* fSX : Subsystem clock oscillator clock */ + /* fXT : XT1 clock oscillation */ + sys_clock_src_freq = BSP_SUB_CLOCK_HZ; + } + } + /* fCLK clock source is fMAIN */ + /* fCLK : CPU/peripheral hardware clock */ + /* fMAIN : Main system clock */ + else + { + /* fMAIN clock source is fMX */ + /* fMAIN : Main system clock */ + /* fMX : High-speed system clock */ + if (1U == MCS) + { + /* fMX clock source is fX */ + /* fMX : High-speed system clock */ + /* fX : X1 clock oscillation */ + uint8_t i; + + /* WAIT_LOOP */ + sys_clock_src_freq = BSP_CFG_FMX_HZ; + + for (i = MOSCDIV; i > 0U; i--) + { + sys_clock_src_freq /= 2U; + } + } + /* fMAIN clock source is fOCO */ + /* fMAIN : Main system clock */ + /* fOCO : Main on-chip oscillator clock */ + else + { + /* fOCO clock source is fIM */ + /* fOCO : Main on-chip oscillator clock */ + /* fIM : Middle-speed on-chip oscillator clock */ + if (1U == MCS1) + { + sys_clock_src_freq = g_fim_hz[MOCODIV & 0x03U]; + } + /* fOCO clock source is fIH */ + /* fOCO : Main on-chip oscillator clock */ + /* fIH : High-speed on-chip oscillator clock */ + else + { + uint8_t temp1; + uint8_t temp2; + + temp1 = OPTBYTE_C2; + temp2 = HOCODIV; + + sys_clock_src_freq = g_fih_hz[(temp1 & 0x08U) | (temp2 & 0x07U)]; + } + } + } + + return sys_clock_src_freq; +} /* End of function get_fclk_freq_hz() */ +#endif /* BSP_CFG_GET_FREQ_API_FUNCTIONS_DISABLE == 0 */ + +/************************************************** + * Function name: change_clock_setting + * Description : Change the specified clock setting. + * Arguments : Clock to change setting. + * : Value to set for the specified clock. + * Return value : BSP_OK if the specified clock setting is changed. + * BSP_ERROR1 When the specified clock is stopped. + * BSP_ARG_ERROR An invalid argument was input. + * Attention : Stop the specified clock before calling this function. +**************************************************/ +#if BSP_CFG_CHANGE_CLOCK_SETTING_API_FUNCTIONS_DISABLE == 0 +e_bsp_err_t change_clock_setting(e_clock_mode_t mode, uint8_t *set_values) +{ + e_bsp_err_t status = BSP_OK; + + switch (mode) + { + case HIOCLK: + + if ((1U == HIOSTOP) || (1U == CLS) || (1U == MCS) || (1U == MCS1)) + { + status = BSP_ERROR1; + } + else + { + HOCODIV = set_values[0]; + } + + break; + + case MIOCLK: + + if (1U == MIOEN) + { + status = BSP_ERROR1; + } + else + { + MOCODIV = set_values[0]; + } + + break; + + case SYSCLK: + + if (0U == MSTOP) + { + status = BSP_ERROR1; + } + else + { + MOSCDIV = set_values[0]; + } + + break; + + default: + + /* Setting prohibited */ + status = BSP_ARG_ERROR; + + break; + + } + + return status; +} /* End of function change_clock_setting() */ +#endif /* BSP_CFG_CHANGE_CLOCK_SETTING_API_FUNCTIONS_DISABLE == 0 */ + +/************************************************* + * Function name: mcu_clock_setup + * Description : Clock initialization. + * Arguments : none + * Return value : none +**************************************************/ +#if BSP_CFG_STARTUP_DISABLE == 0 +void mcu_clock_setup(void) +{ + uint8_t cmc_tmp; + +#if BSP_CFG_MOCO_OPERATION == 1 || ((BSP_CFG_SUBCLK_OPERATION == 0) && (BSP_CFG_SUBCLK_SOURCE == 1)) || BSP_CFG_SUBSYSCLK_SOURCE == 1 + volatile uint32_t w_count; +#endif +#if (BSP_CFG_HISYSCLK_OPERATION == 0) && (BSP_CFG_HISYSCLK_SOURCE == 1) + uint8_t tmp_stab_wait; + uint8_t tmp_stab_set; +#endif + + cmc_tmp = 0x00U; + + /* High-speed system clock(fMX) setting */ +#if BSP_CFG_HISYSCLK_SOURCE == 0 + /* Not used. + * When using high-speed on-chip oscillator, + * when using middle-speed on-chip oscillator or + * when not using main system clock + */ +#elif BSP_CFG_HISYSCLK_SOURCE == 1 + /* fX(Crystal/ceramic resonator connection */ + /* High-speed system clock division register(MOSCDIV) setting */ + MOSCDIV = BSP_CFG_MOSC_DIVIDE; + + /* Control of X1 clock oscillation frequency(AMPH) setting */ +#if BSP_CFG_FMX_HZ >= 1000000 && BSP_CFG_FMX_HZ <= 10000000 + /* 1MHz <= fX <= 10MHz */ + cmc_tmp |= 0x40U; +#else + /* 10MHz < fX <= 20MHz */ + cmc_tmp |= 0x41U; +#endif +#else + /* fEX(External clock input) */ + /* High-speed system clock division register(MOSCDIV) setting */ + MOSCDIV = BSP_CFG_MOSC_DIVIDE; + + /* Control of X1 clock oscillation frequency(AMPH) setting */ +#if BSP_CFG_FMX_HZ >= 1000000 && BSP_CFG_FMX_HZ <= 10000000 + /* 1MHz <= fX <= 10MHz */ + cmc_tmp |= 0xC0U; +#else + /* 10MHz < fX <= 20MHz */ + cmc_tmp |= 0xC1U; +#endif +#endif /* BSP_CFG_HISYSCLK_SOURCE == 0 */ + + /* High-speed on-chip oscillator(fIH) setting */ + /* High-speed on-chip oscillator frequency select register(HOCODIV) setting */ + HOCODIV = BSP_CFG_HOCO_DIVIDE; + + /* Subsystem clock oscillator clock(fSX) setting */ +#if BSP_CFG_SUBCLK_SOURCE == 0 + /* Not used. + * When using the low-speed on-chip oscillator or + * when not using subsystem clock(fSUB) + */ +#elif BSP_CFG_SUBCLK_SOURCE == 1 +#if BSP_CFG_MCU_PART_PIN_NUM <= 6 + /* 30 - 36 pin device */ + /* XTSEL setting */ + cmc_tmp |= 0x08U; +#endif + /* fXT(Crystal resonator connection) */ +#if BSP_CFG_XT1_OSCMODE == 0 + /* Low power consumption oscillation 1(default) */ + /* EXCLKS/OSCSELS/AMPHS1/AMPHS0 setting */ + cmc_tmp |= 0x10U; +#elif BSP_CFG_XT1_OSCMODE == 1 + /* Normal oscillation */ + /* EXCLKS/OSCSELS/AMPHS1/AMPHS0 setting */ + cmc_tmp |= 0x12U; +#elif BSP_CFG_XT1_OSCMODE == 2 + /* Low power consumption oscillation 2 */ + /* EXCLKS/OSCSELS/AMPHS1/AMPHS0 setting */ + cmc_tmp |= 0x14U; +#else + /* Low power consumption oscillation 3 */ + /* EXCLKS/OSCSELS/AMPHS1/AMPHS0 setting */ + cmc_tmp |= 0x16U; +#endif +#else +#if BSP_CFG_MCU_PART_PIN_NUM <= 6 + /* 30 - 36 pin device */ + /* XTSEL setting */ + cmc_tmp |= 0x08U; +#endif + /* fEXS(External subsystem clock) */ + /* EXCLKS/OSCSELS setting */ + cmc_tmp |= 0x30U; +#endif /* BSP_CFG_SUBCLK_SOURCE == 0 */ + /* Clock operation mode control register(CMC) setting */ + CMC = cmc_tmp; + + /* Middle-speed on-chip oscillator clock(fIM) setting */ +#if BSP_CFG_MOCO_OPERATION == 1 + MOCODIV = BSP_CFG_MOCO_DIVIDE; +#endif + + /* When to use X1 clock oscillator(fX) */ +#if BSP_CFG_HISYSCLK_SOURCE == 1 + /* Oscillation stabilization time select register(OSTS) setting */ + OSTS = BSP_CFG_X1_WAIT_TIME_SEL; +#endif + + /* High-speed system clock oscillation */ +#if BSP_CFG_HISYSCLK_OPERATION == 0 + /* Start oscillation */ + MSTOP = 0U; + +#if BSP_CFG_HISYSCLK_SOURCE == 1 + /* Wait for oscillation stabilization unless external clock input */ + tmp_stab_set = (uint8_t)~(0x7FU >> OSTS); + + /* WAIT_LOOP */ + do + { + tmp_stab_wait = OSTC; + tmp_stab_wait &= tmp_stab_set; + } + while (tmp_stab_wait != tmp_stab_set); +#endif +#else + /* X1 oscillation stopped if high-speed system clock is not used */ + MSTOP = 1U; +#endif + + /* When to use middle-speed on-chip oscillator clock(fIM) */ +#if BSP_CFG_MOCO_OPERATION == 1 + MIOEN = 1U; + + /* WAIT_LOOP */ + for (w_count = 0U; w_count <= BSP_CFG_FIMWAITTIME; w_count++) + { + BSP_NOP(); + } +#else + /* Oscillation stopped if middle-speed on-chip oscillator clock(fIM) is not used */ + MIOEN = 0U; +#endif + + /* Main on-chip oscillator clock(fOCO) setting */ +#if BSP_CFG_OCOCLK_SOURCE == 0 + /* High-speed on-chip oscillator clock(fIH) */ + MCM1 = 0U; +#else + /* Middle-speed on-chip oscillator clock(fIM) */ + MCM1 = 1U; +#endif + + /* Main system clock(fMAIN) setting */ +#if BSP_CFG_MAINCLK_SOURCE == 0 + /* Main on-chip oscillator clock(fOCO) */ + MCM0 = 0U; +#else + /* High-speed system clock(fMX) */ + MCM0 = 1U; +#endif + + /* Subsystem clock oscillation */ + + /* Subsystem clock supply mode control register(OSMC) setting */ +#if BSP_CFG_ALLOW_FSUB_IN_STOPHALT == 0 && BSP_CFG_RTC_OUT_CLK_SOURCE == 0 + OSMC |= 0x00U; +#elif BSP_CFG_ALLOW_FSUB_IN_STOPHALT == 1 && BSP_CFG_RTC_OUT_CLK_SOURCE == 0 + OSMC |= 0x80U; +#elif BSP_CFG_ALLOW_FSUB_IN_STOPHALT == 0 && BSP_CFG_RTC_OUT_CLK_SOURCE == 1 + OSMC |= 0x10U; +#else + OSMC |= 0x90U; +#endif + + /* When to use subsystem clock oscillator clock(fSX) */ + /* Subsystem clock oscillator clock oscillation */ +#if BSP_CFG_SUBCLK_OPERATION == 0 + /* Start oscillation */ + XTSTOP = 0U; + +#if BSP_CFG_SUBCLK_SOURCE == 1 + /* Wait for oscillation stabilization unless external clock input */ + /* WAIT_LOOP */ + for (w_count = 0U; w_count <= BSP_CFG_SUBWAITTIME; w_count++) + { +#if BSP_CFG_WDT_REFRESH_ENABLE == 0 + BSP_NOP(); +#elif BSP_CFG_WDT_REFRESH_ENABLE == 1 + WDTE = 0xACU; +#else + BSP_CFG_USER_WDT_REFRESH_SETTING_FUNCTION(); +#endif + } +#endif + +#else + /* XT1 oscillator stopped if subsystem clock oscillator clock is not used */ + XTSTOP = 1U; +#endif + +#if BSP_CFG_SUBSYSCLK_SOURCE == 1 + SELLOSC = 1U; + /* WAIT_LOOP */ + for (w_count = 0U; w_count <= BSP_CFG_FILWAITTIME; w_count++) + { + BSP_NOP(); + } +#endif + + /* fCLK selection */ +#if BSP_CFG_FCLK_SOURCE == 0 + /* When using a high-speed system clock, high-speed on-chip oscillator, + * or middle-speed on-chip oscillator + */ + CSS = 0U; + + /* WAIT_LOOP */ + while (1U == CLS) + { + ; + } +#else + /* When using subsystem clock or low-speed on-chip oscillator */ + CSS = 1U; + + /* WAIT_LOOP */ + while (0U == CLS) + { + ; + } +#endif + + /* Starts high-speed on-chip oscillator */ + /* Only the high-speed on-chip oscillator is activated after reset, + * so stop this clock last. + */ +#if BSP_CFG_FIH_START_ON_STARTUP == 1 + /* High-speed on-chip oscillator startup setting at + * STOP mode release and SNOOZE mode transition. + */ +#if (BSP_CFG_OCOCLK_SOURCE == 0) && (BSP_CFG_MAINCLK_SOURCE == 0) && (BSP_CFG_FCLK_SOURCE == 0) + FWKUP = BSP_CFG_WAKEUP_MODE; +#endif + HIOSTOP = 0U; +#else + HIOSTOP = 1U; +#endif +} /* End of function mcu_clock_setup() */ +#endif /* BSP_CFG_STARTUP_DISABLE == 0 */ diff --git a/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/mcu_clocks.h b/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/mcu_clocks.h index e621fbe..8006b7b 100644 --- a/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/mcu_clocks.h +++ b/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/mcu_clocks.h @@ -1,61 +1,61 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -* this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* File Name : mcu_clocks.h -* Description : -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* History : DD.MM.YYYY Version Description -* : 20.04.2022 1.50 First Release -***********************************************************************************************************************/ - -/************************************************* - * Includes , "Project Includes" - *************************************************/ - -/************************************************* - * Macro definitions - *************************************************/ -/* Multiple inclusion prevention macro */ -#ifndef MCU_CLOCKS_H -#define MCU_CLOCKS_H - -/************************************************* - * Function declaration - *************************************************/ -#if BSP_CFG_CLOCK_OPERATION_API_FUNCTIONS_DISABLE == 0 -e_bsp_err_t start_clock (e_clock_mode_t mode); -e_bsp_err_t stop_clock (e_clock_mode_t mode); -#endif - -#if BSP_CFG_SET_CLOCK_SOURCE_API_FUNCTIONS_DISABLE == 0 -e_bsp_err_t set_fclk_clock_source (e_clock_mode_t mode); -#endif - -#if BSP_CFG_GET_FREQ_API_FUNCTIONS_DISABLE == 0 -uint32_t get_fclk_freq_hz (void); -#endif - -#if BSP_CFG_CHANGE_CLOCK_SETTING_API_FUNCTIONS_DISABLE == 0 -e_bsp_err_t change_clock_setting (e_clock_mode_t mode, uint8_t * set_values); -#endif - -void mcu_clock_setup (void); - -#endif /* #ifndef MCU_CLOCKS_H */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +* this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* File Name : mcu_clocks.h +* Description : +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* History : DD.MM.YYYY Version Description +* : 20.04.2022 1.50 First Release +***********************************************************************************************************************/ + +/************************************************* + * Includes , "Project Includes" + *************************************************/ + +/************************************************* + * Macro definitions + *************************************************/ +/* Multiple inclusion prevention macro */ +#ifndef MCU_CLOCKS_H +#define MCU_CLOCKS_H + +/************************************************* + * Function declaration + *************************************************/ +#if BSP_CFG_CLOCK_OPERATION_API_FUNCTIONS_DISABLE == 0 +e_bsp_err_t start_clock (e_clock_mode_t mode); +e_bsp_err_t stop_clock (e_clock_mode_t mode); +#endif + +#if BSP_CFG_SET_CLOCK_SOURCE_API_FUNCTIONS_DISABLE == 0 +e_bsp_err_t set_fclk_clock_source (e_clock_mode_t mode); +#endif + +#if BSP_CFG_GET_FREQ_API_FUNCTIONS_DISABLE == 0 +uint32_t get_fclk_freq_hz (void); +#endif + +#if BSP_CFG_CHANGE_CLOCK_SETTING_API_FUNCTIONS_DISABLE == 0 +e_bsp_err_t change_clock_setting (e_clock_mode_t mode, uint8_t * set_values); +#endif + +void mcu_clock_setup (void); + +#endif /* #ifndef MCU_CLOCKS_H */ diff --git a/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/mcu_info.h b/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/mcu_info.h index 89ef85e..6e75890 100644 --- a/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/mcu_info.h +++ b/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/mcu_info.h @@ -1,53 +1,53 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -* this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* File Name : mcu_info.h -* Description : -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* History : DD.MM.YYYY Version Description -* : 20.04.2022 1.50 First Release -***********************************************************************************************************************/ - -/************************************************* - * Includes , "Project Includes" - *************************************************/ - -/************************************************* - * Macro definitions - *************************************************/ -/* Multiple inclusion prevention macro */ -#ifndef MCU_INFO -#define MCU_INFO - -/* These macros define clock speeds for fixed speed clocks. */ -#define BSP_LOCO_HZ (32768) -#define BSP_SUB_CLOCK_HZ (32768) - -/* MCU Family name. */ -#define BSP_MCU_FAMILY_RL78 (1) - -/* MCU Series name. */ -#define BSP_MCU_SERIES_RL78G2X (1) - -/* MCU Group name. */ -#define BSP_MCU_GROUP_RL78G22 (1) - -#endif /* #define MCU_INFO */ - +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +* this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* File Name : mcu_info.h +* Description : +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* History : DD.MM.YYYY Version Description +* : 20.04.2022 1.50 First Release +***********************************************************************************************************************/ + +/************************************************* + * Includes , "Project Includes" + *************************************************/ + +/************************************************* + * Macro definitions + *************************************************/ +/* Multiple inclusion prevention macro */ +#ifndef MCU_INFO +#define MCU_INFO + +/* These macros define clock speeds for fixed speed clocks. */ +#define BSP_LOCO_HZ (32768) +#define BSP_SUB_CLOCK_HZ (32768) + +/* MCU Family name. */ +#define BSP_MCU_FAMILY_RL78 (1) + +/* MCU Series name. */ +#define BSP_MCU_SERIES_RL78G2X (1) + +/* MCU Group name. */ +#define BSP_MCU_GROUP_RL78G22 (1) + +#endif /* #define MCU_INFO */ + diff --git a/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/register_access/llvm/iodefine.h b/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/register_access/llvm/iodefine.h index 6e80698..a737af8 100644 --- a/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/register_access/llvm/iodefine.h +++ b/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/register_access/llvm/iodefine.h @@ -1,925 +1,925 @@ -/************************************************************************/ -/* Header file generated from device file: */ -/* DR7F102GGE.DVF */ -/* E1.00b (2022/06/16) */ -/* Copyright(C) 2022 Renesas */ -/* Tool Version: 4.0.11 */ -/* Date Generated: 2022/07/25 */ -/************************************************************************/ - -#ifndef __INTRINSIC_FUNCTIONS -#define __INTRINSIC_FUNCTIONS - -#define DI() asm("di") -#define EI() asm("ei") -#define HALT() asm("halt") -#define NOP() asm("nop") -#define STOP() asm("stop") - -#endif - -#ifndef __IOREG_BIT_STRUCTURES -#define __IOREG_BIT_STRUCTURES -typedef struct { - unsigned char no0 :1; - unsigned char no1 :1; - unsigned char no2 :1; - unsigned char no3 :1; - unsigned char no4 :1; - unsigned char no5 :1; - unsigned char no6 :1; - unsigned char no7 :1; -} __BITS8; - -typedef struct { - unsigned short no0 :1; - unsigned short no1 :1; - unsigned short no2 :1; - unsigned short no3 :1; - unsigned short no4 :1; - unsigned short no5 :1; - unsigned short no6 :1; - unsigned short no7 :1; - unsigned short no8 :1; - unsigned short no9 :1; - unsigned short no10 :1; - unsigned short no11 :1; - unsigned short no12 :1; - unsigned short no13 :1; - unsigned short no14 :1; - unsigned short no15 :1; -} __BITS16; - -#endif - -#ifndef IODEFINE_H -#define IODEFINE_H - -/* - IO Registers - */ -union un_p0 { - unsigned char p0; - __BITS8 BIT; -}; -union un_p1 { - unsigned char p1; - __BITS8 BIT; -}; -union un_p2 { - unsigned char p2; - __BITS8 BIT; -}; -union un_p3 { - unsigned char p3; - __BITS8 BIT; -}; -union un_p4 { - unsigned char p4; - __BITS8 BIT; -}; -union un_p5 { - unsigned char p5; - __BITS8 BIT; -}; -union un_p6 { - unsigned char p6; - __BITS8 BIT; -}; -union un_p7 { - unsigned char p7; - __BITS8 BIT; -}; -union un_p12 { - unsigned char p12; - __BITS8 BIT; -}; -union un_p13 { - unsigned char p13; - __BITS8 BIT; -}; -union un_p14 { - unsigned char p14; - __BITS8 BIT; -}; -union un_pm0 { - unsigned char pm0; - __BITS8 BIT; -}; -union un_pm1 { - unsigned char pm1; - __BITS8 BIT; -}; -union un_pm2 { - unsigned char pm2; - __BITS8 BIT; -}; -union un_pm3 { - unsigned char pm3; - __BITS8 BIT; -}; -union un_pm4 { - unsigned char pm4; - __BITS8 BIT; -}; -union un_pm5 { - unsigned char pm5; - __BITS8 BIT; -}; -union un_pm6 { - unsigned char pm6; - __BITS8 BIT; -}; -union un_pm7 { - unsigned char pm7; - __BITS8 BIT; -}; -union un_pm12 { - unsigned char pm12; - __BITS8 BIT; -}; -union un_pm14 { - unsigned char pm14; - __BITS8 BIT; -}; -union un_adm0 { - unsigned char adm0; - __BITS8 BIT; -}; -union un_ads { - unsigned char ads; - __BITS8 BIT; -}; -union un_adm1 { - unsigned char adm1; - __BITS8 BIT; -}; -union un_krctl { - unsigned char krctl; - __BITS8 BIT; -}; -union un_krm0 { - unsigned char krm0; - __BITS8 BIT; -}; -union un_egp0 { - unsigned char egp0; - __BITS8 BIT; -}; -union un_egn0 { - unsigned char egn0; - __BITS8 BIT; -}; -union un_egp1 { - unsigned char egp1; - __BITS8 BIT; -}; -union un_egn1 { - unsigned char egn1; - __BITS8 BIT; -}; -union un_iics0 { - unsigned char iics0; - __BITS8 BIT; -}; -union un_iicf0 { - unsigned char iicf0; - __BITS8 BIT; -}; -union un_csc { - unsigned char csc; - __BITS8 BIT; -}; -union un_ostc { - unsigned char ostc; - __BITS8 BIT; -}; -union un_ckc { - unsigned char ckc; - __BITS8 BIT; -}; -union un_cks0 { - unsigned char cks0; - __BITS8 BIT; -}; -union un_cks1 { - unsigned char cks1; - __BITS8 BIT; -}; -union un_cksel { - unsigned char cksel; - __BITS8 BIT; -}; -union un_lvim { - unsigned char lvim; - __BITS8 BIT; -}; -union un_lvis { - unsigned char lvis; - __BITS8 BIT; -}; -union un_if2 { - unsigned short if2; - __BITS16 BIT; -}; -union un_if2l { - unsigned char if2l; - __BITS8 BIT; -}; -union un_if2h { - unsigned char if2h; - __BITS8 BIT; -}; -union un_if3 { - unsigned short if3; - __BITS16 BIT; -}; -union un_if3l { - unsigned char if3l; - __BITS8 BIT; -}; -union un_mk2 { - unsigned short mk2; - __BITS16 BIT; -}; -union un_mk2l { - unsigned char mk2l; - __BITS8 BIT; -}; -union un_mk2h { - unsigned char mk2h; - __BITS8 BIT; -}; -union un_mk3 { - unsigned short mk3; - __BITS16 BIT; -}; -union un_mk3l { - unsigned char mk3l; - __BITS8 BIT; -}; -union un_pr02 { - unsigned short pr02; - __BITS16 BIT; -}; -union un_pr02l { - unsigned char pr02l; - __BITS8 BIT; -}; -union un_pr02h { - unsigned char pr02h; - __BITS8 BIT; -}; -union un_pr03 { - unsigned short pr03; - __BITS16 BIT; -}; -union un_pr03l { - unsigned char pr03l; - __BITS8 BIT; -}; -union un_pr12 { - unsigned short pr12; - __BITS16 BIT; -}; -union un_pr12l { - unsigned char pr12l; - __BITS8 BIT; -}; -union un_pr12h { - unsigned char pr12h; - __BITS8 BIT; -}; -union un_pr13 { - unsigned short pr13; - __BITS16 BIT; -}; -union un_pr13l { - unsigned char pr13l; - __BITS8 BIT; -}; -union un_if0 { - unsigned short if0; - __BITS16 BIT; -}; -union un_if0l { - unsigned char if0l; - __BITS8 BIT; -}; -union un_if0h { - unsigned char if0h; - __BITS8 BIT; -}; -union un_if1 { - unsigned short if1; - __BITS16 BIT; -}; -union un_if1l { - unsigned char if1l; - __BITS8 BIT; -}; -union un_if1h { - unsigned char if1h; - __BITS8 BIT; -}; -union un_mk0 { - unsigned short mk0; - __BITS16 BIT; -}; -union un_mk0l { - unsigned char mk0l; - __BITS8 BIT; -}; -union un_mk0h { - unsigned char mk0h; - __BITS8 BIT; -}; -union un_mk1 { - unsigned short mk1; - __BITS16 BIT; -}; -union un_mk1l { - unsigned char mk1l; - __BITS8 BIT; -}; -union un_mk1h { - unsigned char mk1h; - __BITS8 BIT; -}; -union un_pr00 { - unsigned short pr00; - __BITS16 BIT; -}; -union un_pr00l { - unsigned char pr00l; - __BITS8 BIT; -}; -union un_pr00h { - unsigned char pr00h; - __BITS8 BIT; -}; -union un_pr01 { - unsigned short pr01; - __BITS16 BIT; -}; -union un_pr01l { - unsigned char pr01l; - __BITS8 BIT; -}; -union un_pr01h { - unsigned char pr01h; - __BITS8 BIT; -}; -union un_pr10 { - unsigned short pr10; - __BITS16 BIT; -}; -union un_pr10l { - unsigned char pr10l; - __BITS8 BIT; -}; -union un_pr10h { - unsigned char pr10h; - __BITS8 BIT; -}; -union un_pr11 { - unsigned short pr11; - __BITS16 BIT; -}; -union un_pr11l { - unsigned char pr11l; - __BITS8 BIT; -}; -union un_pr11h { - unsigned char pr11h; - __BITS8 BIT; -}; -union un_pmc { - unsigned char pmc; - __BITS8 BIT; -}; - -#define P0 (*(volatile union un_p0 *)0xFFF00).p0 -#define P0_bit (*(volatile union un_p0 *)0xFFF00).BIT -#define P1 (*(volatile union un_p1 *)0xFFF01).p1 -#define P1_bit (*(volatile union un_p1 *)0xFFF01).BIT -#define P2 (*(volatile union un_p2 *)0xFFF02).p2 -#define P2_bit (*(volatile union un_p2 *)0xFFF02).BIT -#define P3 (*(volatile union un_p3 *)0xFFF03).p3 -#define P3_bit (*(volatile union un_p3 *)0xFFF03).BIT -#define P4 (*(volatile union un_p4 *)0xFFF04).p4 -#define P4_bit (*(volatile union un_p4 *)0xFFF04).BIT -#define P5 (*(volatile union un_p5 *)0xFFF05).p5 -#define P5_bit (*(volatile union un_p5 *)0xFFF05).BIT -#define P6 (*(volatile union un_p6 *)0xFFF06).p6 -#define P6_bit (*(volatile union un_p6 *)0xFFF06).BIT -#define P7 (*(volatile union un_p7 *)0xFFF07).p7 -#define P7_bit (*(volatile union un_p7 *)0xFFF07).BIT -#define P12 (*(volatile union un_p12 *)0xFFF0C).p12 -#define P12_bit (*(volatile union un_p12 *)0xFFF0C).BIT -#define P13 (*(volatile union un_p13 *)0xFFF0D).p13 -#define P13_bit (*(volatile union un_p13 *)0xFFF0D).BIT -#define P14 (*(volatile union un_p14 *)0xFFF0E).p14 -#define P14_bit (*(volatile union un_p14 *)0xFFF0E).BIT -#define SDR00 (*(volatile unsigned short *)0xFFF10) -#define SIO00 (*(volatile unsigned char *)0xFFF10) -#define TXD0 (*(volatile unsigned char *)0xFFF10) -#define SDR01 (*(volatile unsigned short *)0xFFF12) -#define SIO01 (*(volatile unsigned char *)0xFFF12) -#define RXD0 (*(volatile unsigned char *)0xFFF12) -#define TDR00 (*(volatile unsigned short *)0xFFF18) -#define TDR01 (*(volatile unsigned short *)0xFFF1A) -#define TDR01L (*(volatile unsigned char *)0xFFF1A) -#define TDR01H (*(volatile unsigned char *)0xFFF1B) -#define ADCR (*(volatile unsigned short *)0xFFF1E) -#define ADCRH (*(volatile unsigned char *)0xFFF1F) -#define PM0 (*(volatile union un_pm0 *)0xFFF20).pm0 -#define PM0_bit (*(volatile union un_pm0 *)0xFFF20).BIT -#define PM1 (*(volatile union un_pm1 *)0xFFF21).pm1 -#define PM1_bit (*(volatile union un_pm1 *)0xFFF21).BIT -#define PM2 (*(volatile union un_pm2 *)0xFFF22).pm2 -#define PM2_bit (*(volatile union un_pm2 *)0xFFF22).BIT -#define PM3 (*(volatile union un_pm3 *)0xFFF23).pm3 -#define PM3_bit (*(volatile union un_pm3 *)0xFFF23).BIT -#define PM4 (*(volatile union un_pm4 *)0xFFF24).pm4 -#define PM4_bit (*(volatile union un_pm4 *)0xFFF24).BIT -#define PM5 (*(volatile union un_pm5 *)0xFFF25).pm5 -#define PM5_bit (*(volatile union un_pm5 *)0xFFF25).BIT -#define PM6 (*(volatile union un_pm6 *)0xFFF26).pm6 -#define PM6_bit (*(volatile union un_pm6 *)0xFFF26).BIT -#define PM7 (*(volatile union un_pm7 *)0xFFF27).pm7 -#define PM7_bit (*(volatile union un_pm7 *)0xFFF27).BIT -#define PM12 (*(volatile union un_pm12 *)0xFFF2C).pm12 -#define PM12_bit (*(volatile union un_pm12 *)0xFFF2C).BIT -#define PM14 (*(volatile union un_pm14 *)0xFFF2E).pm14 -#define PM14_bit (*(volatile union un_pm14 *)0xFFF2E).BIT -#define ADM0 (*(volatile union un_adm0 *)0xFFF30).adm0 -#define ADM0_bit (*(volatile union un_adm0 *)0xFFF30).BIT -#define ADS (*(volatile union un_ads *)0xFFF31).ads -#define ADS_bit (*(volatile union un_ads *)0xFFF31).BIT -#define ADM1 (*(volatile union un_adm1 *)0xFFF32).adm1 -#define ADM1_bit (*(volatile union un_adm1 *)0xFFF32).BIT -#define KRCTL (*(volatile union un_krctl *)0xFFF34).krctl -#define KRCTL_bit (*(volatile union un_krctl *)0xFFF34).BIT -#define KRF (*(volatile unsigned char *)0xFFF35) -#define KRM0 (*(volatile union un_krm0 *)0xFFF37).krm0 -#define KRM0_bit (*(volatile union un_krm0 *)0xFFF37).BIT -#define EGP0 (*(volatile union un_egp0 *)0xFFF38).egp0 -#define EGP0_bit (*(volatile union un_egp0 *)0xFFF38).BIT -#define EGN0 (*(volatile union un_egn0 *)0xFFF39).egn0 -#define EGN0_bit (*(volatile union un_egn0 *)0xFFF39).BIT -#define EGP1 (*(volatile union un_egp1 *)0xFFF3A).egp1 -#define EGP1_bit (*(volatile union un_egp1 *)0xFFF3A).BIT -#define EGN1 (*(volatile union un_egn1 *)0xFFF3B).egn1 -#define EGN1_bit (*(volatile union un_egn1 *)0xFFF3B).BIT -#define SDR02 (*(volatile unsigned short *)0xFFF44) -#define TXD1 (*(volatile unsigned char *)0xFFF44) -#define SDR03 (*(volatile unsigned short *)0xFFF46) -#define RXD1 (*(volatile unsigned char *)0xFFF46) -#define SIO11 (*(volatile unsigned char *)0xFFF46) -#define SDR10 (*(volatile unsigned short *)0xFFF48) -#define TXD2 (*(volatile unsigned char *)0xFFF48) -#define SIO20 (*(volatile unsigned char *)0xFFF48) -#define SDR11 (*(volatile unsigned short *)0xFFF4A) -#define RXD2 (*(volatile unsigned char *)0xFFF4A) -#define SIO21 (*(volatile unsigned char *)0xFFF4A) -#define IICA0 (*(volatile unsigned char *)0xFFF50) -#define IICS0 (*(volatile union un_iics0 *)0xFFF51).iics0 -#define IICS0_bit (*(volatile union un_iics0 *)0xFFF51).BIT -#define IICF0 (*(volatile union un_iicf0 *)0xFFF52).iicf0 -#define IICF0_bit (*(volatile union un_iicf0 *)0xFFF52).BIT -#define TDR02 (*(volatile unsigned short *)0xFFF64) -#define TDR03 (*(volatile unsigned short *)0xFFF66) -#define TDR03L (*(volatile unsigned char *)0xFFF66) -#define TDR03H (*(volatile unsigned char *)0xFFF67) -#define TDR04 (*(volatile unsigned short *)0xFFF68) -#define TDR05 (*(volatile unsigned short *)0xFFF6A) -#define TDR06 (*(volatile unsigned short *)0xFFF6C) -#define TDR07 (*(volatile unsigned short *)0xFFF6E) -#define CMC (*(volatile unsigned char *)0xFFFA0) -#define CSC (*(volatile union un_csc *)0xFFFA1).csc -#define CSC_bit (*(volatile union un_csc *)0xFFFA1).BIT -#define OSTC (*(volatile union un_ostc *)0xFFFA2).ostc -#define OSTC_bit (*(volatile union un_ostc *)0xFFFA2).BIT -#define OSTS (*(volatile unsigned char *)0xFFFA3) -#define CKC (*(volatile union un_ckc *)0xFFFA4).ckc -#define CKC_bit (*(volatile union un_ckc *)0xFFFA4).BIT -#define CKS0 (*(volatile union un_cks0 *)0xFFFA5).cks0 -#define CKS0_bit (*(volatile union un_cks0 *)0xFFFA5).BIT -#define CKS1 (*(volatile union un_cks1 *)0xFFFA6).cks1 -#define CKS1_bit (*(volatile union un_cks1 *)0xFFFA6).BIT -#define CKSEL (*(volatile union un_cksel *)0xFFFA7).cksel -#define CKSEL_bit (*(volatile union un_cksel *)0xFFFA7).BIT -#define RESF (*(volatile unsigned char *)0xFFFA8) -#define LVIM (*(volatile union un_lvim *)0xFFFA9).lvim -#define LVIM_bit (*(volatile union un_lvim *)0xFFFA9).BIT -#define LVIS (*(volatile union un_lvis *)0xFFFAA).lvis -#define LVIS_bit (*(volatile union un_lvis *)0xFFFAA).BIT -#define WDTE (*(volatile unsigned char *)0xFFFAB) -#define CRCIN (*(volatile unsigned char *)0xFFFAC) -#define IF2 (*(volatile union un_if2 *)0xFFFD0).if2 -#define IF2_bit (*(volatile union un_if2 *)0xFFFD0).BIT -#define IF2L (*(volatile union un_if2l *)0xFFFD0).if2l -#define IF2L_bit (*(volatile union un_if2l *)0xFFFD0).BIT -#define IF2H (*(volatile union un_if2h *)0xFFFD1).if2h -#define IF2H_bit (*(volatile union un_if2h *)0xFFFD1).BIT -#define IF3 (*(volatile union un_if3 *)0xFFFD2).if3 -#define IF3_bit (*(volatile union un_if3 *)0xFFFD2).BIT -#define IF3L (*(volatile union un_if3l *)0xFFFD2).if3l -#define IF3L_bit (*(volatile union un_if3l *)0xFFFD2).BIT -#define MK2 (*(volatile union un_mk2 *)0xFFFD4).mk2 -#define MK2_bit (*(volatile union un_mk2 *)0xFFFD4).BIT -#define MK2L (*(volatile union un_mk2l *)0xFFFD4).mk2l -#define MK2L_bit (*(volatile union un_mk2l *)0xFFFD4).BIT -#define MK2H (*(volatile union un_mk2h *)0xFFFD5).mk2h -#define MK2H_bit (*(volatile union un_mk2h *)0xFFFD5).BIT -#define MK3 (*(volatile union un_mk3 *)0xFFFD6).mk3 -#define MK3_bit (*(volatile union un_mk3 *)0xFFFD6).BIT -#define MK3L (*(volatile union un_mk3l *)0xFFFD6).mk3l -#define MK3L_bit (*(volatile union un_mk3l *)0xFFFD6).BIT -#define PR02 (*(volatile union un_pr02 *)0xFFFD8).pr02 -#define PR02_bit (*(volatile union un_pr02 *)0xFFFD8).BIT -#define PR02L (*(volatile union un_pr02l *)0xFFFD8).pr02l -#define PR02L_bit (*(volatile union un_pr02l *)0xFFFD8).BIT -#define PR02H (*(volatile union un_pr02h *)0xFFFD9).pr02h -#define PR02H_bit (*(volatile union un_pr02h *)0xFFFD9).BIT -#define PR03 (*(volatile union un_pr03 *)0xFFFDA).pr03 -#define PR03_bit (*(volatile union un_pr03 *)0xFFFDA).BIT -#define PR03L (*(volatile union un_pr03l *)0xFFFDA).pr03l -#define PR03L_bit (*(volatile union un_pr03l *)0xFFFDA).BIT -#define PR12 (*(volatile union un_pr12 *)0xFFFDC).pr12 -#define PR12_bit (*(volatile union un_pr12 *)0xFFFDC).BIT -#define PR12L (*(volatile union un_pr12l *)0xFFFDC).pr12l -#define PR12L_bit (*(volatile union un_pr12l *)0xFFFDC).BIT -#define PR12H (*(volatile union un_pr12h *)0xFFFDD).pr12h -#define PR12H_bit (*(volatile union un_pr12h *)0xFFFDD).BIT -#define PR13 (*(volatile union un_pr13 *)0xFFFDE).pr13 -#define PR13_bit (*(volatile union un_pr13 *)0xFFFDE).BIT -#define PR13L (*(volatile union un_pr13l *)0xFFFDE).pr13l -#define PR13L_bit (*(volatile union un_pr13l *)0xFFFDE).BIT -#define IF0 (*(volatile union un_if0 *)0xFFFE0).if0 -#define IF0_bit (*(volatile union un_if0 *)0xFFFE0).BIT -#define IF0L (*(volatile union un_if0l *)0xFFFE0).if0l -#define IF0L_bit (*(volatile union un_if0l *)0xFFFE0).BIT -#define IF0H (*(volatile union un_if0h *)0xFFFE1).if0h -#define IF0H_bit (*(volatile union un_if0h *)0xFFFE1).BIT -#define IF1 (*(volatile union un_if1 *)0xFFFE2).if1 -#define IF1_bit (*(volatile union un_if1 *)0xFFFE2).BIT -#define IF1L (*(volatile union un_if1l *)0xFFFE2).if1l -#define IF1L_bit (*(volatile union un_if1l *)0xFFFE2).BIT -#define IF1H (*(volatile union un_if1h *)0xFFFE3).if1h -#define IF1H_bit (*(volatile union un_if1h *)0xFFFE3).BIT -#define MK0 (*(volatile union un_mk0 *)0xFFFE4).mk0 -#define MK0_bit (*(volatile union un_mk0 *)0xFFFE4).BIT -#define MK0L (*(volatile union un_mk0l *)0xFFFE4).mk0l -#define MK0L_bit (*(volatile union un_mk0l *)0xFFFE4).BIT -#define MK0H (*(volatile union un_mk0h *)0xFFFE5).mk0h -#define MK0H_bit (*(volatile union un_mk0h *)0xFFFE5).BIT -#define MK1 (*(volatile union un_mk1 *)0xFFFE6).mk1 -#define MK1_bit (*(volatile union un_mk1 *)0xFFFE6).BIT -#define MK1L (*(volatile union un_mk1l *)0xFFFE6).mk1l -#define MK1L_bit (*(volatile union un_mk1l *)0xFFFE6).BIT -#define MK1H (*(volatile union un_mk1h *)0xFFFE7).mk1h -#define MK1H_bit (*(volatile union un_mk1h *)0xFFFE7).BIT -#define PR00 (*(volatile union un_pr00 *)0xFFFE8).pr00 -#define PR00_bit (*(volatile union un_pr00 *)0xFFFE8).BIT -#define PR00L (*(volatile union un_pr00l *)0xFFFE8).pr00l -#define PR00L_bit (*(volatile union un_pr00l *)0xFFFE8).BIT -#define PR00H (*(volatile union un_pr00h *)0xFFFE9).pr00h -#define PR00H_bit (*(volatile union un_pr00h *)0xFFFE9).BIT -#define PR01 (*(volatile union un_pr01 *)0xFFFEA).pr01 -#define PR01_bit (*(volatile union un_pr01 *)0xFFFEA).BIT -#define PR01L (*(volatile union un_pr01l *)0xFFFEA).pr01l -#define PR01L_bit (*(volatile union un_pr01l *)0xFFFEA).BIT -#define PR01H (*(volatile union un_pr01h *)0xFFFEB).pr01h -#define PR01H_bit (*(volatile union un_pr01h *)0xFFFEB).BIT -#define PR10 (*(volatile union un_pr10 *)0xFFFEC).pr10 -#define PR10_bit (*(volatile union un_pr10 *)0xFFFEC).BIT -#define PR10L (*(volatile union un_pr10l *)0xFFFEC).pr10l -#define PR10L_bit (*(volatile union un_pr10l *)0xFFFEC).BIT -#define PR10H (*(volatile union un_pr10h *)0xFFFED).pr10h -#define PR10H_bit (*(volatile union un_pr10h *)0xFFFED).BIT -#define PR11 (*(volatile union un_pr11 *)0xFFFEE).pr11 -#define PR11_bit (*(volatile union un_pr11 *)0xFFFEE).BIT -#define PR11L (*(volatile union un_pr11l *)0xFFFEE).pr11l -#define PR11L_bit (*(volatile union un_pr11l *)0xFFFEE).BIT -#define PR11H (*(volatile union un_pr11h *)0xFFFEF).pr11h -#define PR11H_bit (*(volatile union un_pr11h *)0xFFFEF).BIT -#define MACRL (*(volatile unsigned short *)0xFFFF0) -#define MACRH (*(volatile unsigned short *)0xFFFF2) -#define PMC (*(volatile union un_pmc *)0xFFFFE).pmc -#define PMC_bit (*(volatile union un_pmc *)0xFFFFE).BIT - -/* - Sfr bits - */ -#define ADCE ADM0_bit.no0 -#define ADCS ADM0_bit.no7 -#define KREG KRCTL_bit.no0 -#define KRMD KRCTL_bit.no7 -#define SPD0 IICS0_bit.no0 -#define STD0 IICS0_bit.no1 -#define ACKD0 IICS0_bit.no2 -#define TRC0 IICS0_bit.no3 -#define COI0 IICS0_bit.no4 -#define EXC0 IICS0_bit.no5 -#define ALD0 IICS0_bit.no6 -#define MSTS0 IICS0_bit.no7 -#define IICRSV0 IICF0_bit.no0 -#define STCEN0 IICF0_bit.no1 -#define IICBSY0 IICF0_bit.no6 -#define STCF0 IICF0_bit.no7 -#define HIOSTOP CSC_bit.no0 -#define MIOEN CSC_bit.no1 -#define XTSTOP CSC_bit.no6 -#define MSTOP CSC_bit.no7 -#define MCM1 CKC_bit.no0 -#define MCS1 CKC_bit.no1 -#define MCM0 CKC_bit.no4 -#define MCS CKC_bit.no5 -#define CSS CKC_bit.no6 -#define CLS CKC_bit.no7 -#define PCLOE0 CKS0_bit.no7 -#define PCLOE1 CKS1_bit.no7 -#define SELLOSC CKSEL_bit.no0 -#define LVD0F LVIM_bit.no0 -#define LVD1F LVIM_bit.no1 -#define DLVD0F LVIM_bit.no2 -#define DLVD1F LVIM_bit.no3 -#define LVISEN LVIM_bit.no7 -#define LVD1SEL LVIS_bit.no6 -#define LVD1EN LVIS_bit.no7 -#define TMIF05 IF2_bit.no0 -#define TMIF06 IF2_bit.no1 -#define TMIF07 IF2_bit.no2 -#define PIF6 IF2_bit.no3 -#define PIF8 IF2_bit.no5 -#define PIF9 IF2_bit.no6 -#define FLIF IF2_bit.no7 -#define UREIF0 IF2H_bit.no2 -#define CTSUWRIF IF2H_bit.no6 -#define CTSURDIF IF3_bit.no0 -#define CTSUFNIF IF3_bit.no1 -#define UTIF0 IF3_bit.no3 -#define URIF0 IF3_bit.no4 -#define TMMK05 MK2_bit.no0 -#define TMMK06 MK2_bit.no1 -#define TMMK07 MK2_bit.no2 -#define PMK6 MK2_bit.no3 -#define PMK8 MK2_bit.no5 -#define PMK9 MK2_bit.no6 -#define FLMK MK2_bit.no7 -#define UREMK0 MK2H_bit.no2 -#define CTSUWRMK MK2H_bit.no6 -#define CTSURDMK MK3_bit.no0 -#define CTSUFNMK MK3_bit.no1 -#define UTMK0 MK3_bit.no3 -#define URMK0 MK3_bit.no4 -#define TMPR005 PR02_bit.no0 -#define TMPR006 PR02_bit.no1 -#define TMPR007 PR02_bit.no2 -#define PPR06 PR02_bit.no3 -#define PPR08 PR02_bit.no5 -#define PPR09 PR02_bit.no6 -#define FLPR0 PR02_bit.no7 -#define UREPR00 PR02H_bit.no2 -#define CTSUWRPR0 PR02H_bit.no6 -#define CTSURDPR0 PR03_bit.no0 -#define CTSUFNPR0 PR03_bit.no1 -#define UTPR00 PR03_bit.no3 -#define URPR00 PR03_bit.no4 -#define TMPR105 PR12_bit.no0 -#define TMPR106 PR12_bit.no1 -#define TMPR107 PR12_bit.no2 -#define PPR16 PR12_bit.no3 -#define PPR18 PR12_bit.no5 -#define PPR19 PR12_bit.no6 -#define FLPR1 PR12_bit.no7 -#define UREPR10 PR12H_bit.no2 -#define CTSUWRPR1 PR12H_bit.no6 -#define CTSURDPR1 PR13_bit.no0 -#define CTSUFNPR1 PR13_bit.no1 -#define UTPR10 PR13_bit.no3 -#define URPR10 PR13_bit.no4 -#define WDTIIF IF0_bit.no0 -#define LVIIF IF0_bit.no1 -#define PIF0 IF0_bit.no2 -#define PIF1 IF0_bit.no3 -#define PIF2 IF0_bit.no4 -#define PIF3 IF0_bit.no5 -#define PIF4 IF0_bit.no6 -#define PIF5 IF0_bit.no7 -#define STIF2 IF0H_bit.no0 -#define CSIIF20 IF0H_bit.no0 -#define IICIF20 IF0H_bit.no0 -#define CSIIF21 IF0H_bit.no1 -#define SRIF2 IF0H_bit.no1 -#define IICIF21 IF0H_bit.no1 -#define SREIF2 IF0H_bit.no2 -#define SMSEIF IF0H_bit.no4 -#define STIF0 IF0H_bit.no5 -#define CSIIF00 IF0H_bit.no5 -#define IICIF00 IF0H_bit.no5 -#define TMIF00 IF0H_bit.no6 -#define SREIF0 IF0H_bit.no7 -#define TMIF01H IF0H_bit.no7 -#define STIF1 IF1_bit.no0 -#define IICIF11 IF1_bit.no1 -#define CSIIF11 IF1_bit.no1 -#define SRIF1 IF1_bit.no1 -#define SREIF1 IF1_bit.no2 -#define TMIF03H IF1_bit.no2 -#define IICAIF0 IF1_bit.no3 -#define CSIIF01 IF1_bit.no4 -#define IICIF01 IF1_bit.no4 -#define SRIF0 IF1_bit.no4 -#define TMIF01 IF1_bit.no5 -#define TMIF02 IF1_bit.no6 -#define TMIF03 IF1_bit.no7 -#define ADIF IF1H_bit.no0 -#define RTCIF IF1H_bit.no1 -#define ITLIF IF1H_bit.no2 -#define KRIF IF1H_bit.no3 -#define TMIF04 IF1H_bit.no7 -#define WDTIMK MK0_bit.no0 -#define LVIMK MK0_bit.no1 -#define PMK0 MK0_bit.no2 -#define PMK1 MK0_bit.no3 -#define PMK2 MK0_bit.no4 -#define PMK3 MK0_bit.no5 -#define PMK4 MK0_bit.no6 -#define PMK5 MK0_bit.no7 -#define STMK2 MK0H_bit.no0 -#define CSIMK20 MK0H_bit.no0 -#define IICMK20 MK0H_bit.no0 -#define CSIMK21 MK0H_bit.no1 -#define SRMK2 MK0H_bit.no1 -#define IICMK21 MK0H_bit.no1 -#define SREMK2 MK0H_bit.no2 -#define SMSEMK MK0H_bit.no4 -#define STMK0 MK0H_bit.no5 -#define IICMK00 MK0H_bit.no5 -#define CSIMK00 MK0H_bit.no5 -#define TMMK00 MK0H_bit.no6 -#define SREMK0 MK0H_bit.no7 -#define TMMK01H MK0H_bit.no7 -#define STMK1 MK1_bit.no0 -#define IICMK11 MK1_bit.no1 -#define CSIMK11 MK1_bit.no1 -#define SRMK1 MK1_bit.no1 -#define TMMK03H MK1_bit.no2 -#define SREMK1 MK1_bit.no2 -#define IICAMK0 MK1_bit.no3 -#define IICMK01 MK1_bit.no4 -#define SRMK0 MK1_bit.no4 -#define CSIMK01 MK1_bit.no4 -#define TMMK01 MK1_bit.no5 -#define TMMK02 MK1_bit.no6 -#define TMMK03 MK1_bit.no7 -#define ADMK MK1H_bit.no0 -#define RTCMK MK1H_bit.no1 -#define ITLMK MK1H_bit.no2 -#define KRMK MK1H_bit.no3 -#define TMMK04 MK1H_bit.no7 -#define WDTIPR0 PR00_bit.no0 -#define LVIPR0 PR00_bit.no1 -#define PPR00 PR00_bit.no2 -#define PPR01 PR00_bit.no3 -#define PPR02 PR00_bit.no4 -#define PPR03 PR00_bit.no5 -#define PPR04 PR00_bit.no6 -#define PPR05 PR00_bit.no7 -#define STPR02 PR00H_bit.no0 -#define CSIPR020 PR00H_bit.no0 -#define IICPR020 PR00H_bit.no0 -#define CSIPR021 PR00H_bit.no1 -#define SRPR02 PR00H_bit.no1 -#define IICPR021 PR00H_bit.no1 -#define SREPR02 PR00H_bit.no2 -#define SMSEPR0 PR00H_bit.no4 -#define STPR00 PR00H_bit.no5 -#define CSIPR000 PR00H_bit.no5 -#define IICPR000 PR00H_bit.no5 -#define TMPR000 PR00H_bit.no6 -#define SREPR00 PR00H_bit.no7 -#define TMPR001H PR00H_bit.no7 -#define STPR01 PR01_bit.no0 -#define SRPR01 PR01_bit.no1 -#define CSIPR011 PR01_bit.no1 -#define IICPR011 PR01_bit.no1 -#define SREPR01 PR01_bit.no2 -#define TMPR003H PR01_bit.no2 -#define IICAPR00 PR01_bit.no3 -#define CSIPR001 PR01_bit.no4 -#define SRPR00 PR01_bit.no4 -#define IICPR001 PR01_bit.no4 -#define TMPR001 PR01_bit.no5 -#define TMPR002 PR01_bit.no6 -#define TMPR003 PR01_bit.no7 -#define ADPR0 PR01H_bit.no0 -#define RTCPR0 PR01H_bit.no1 -#define ITLPR0 PR01H_bit.no2 -#define KRPR0 PR01H_bit.no3 -#define TMPR004 PR01H_bit.no7 -#define WDTIPR1 PR10_bit.no0 -#define LVIPR1 PR10_bit.no1 -#define PPR10 PR10_bit.no2 -#define PPR11 PR10_bit.no3 -#define PPR12 PR10_bit.no4 -#define PPR13 PR10_bit.no5 -#define PPR14 PR10_bit.no6 -#define PPR15 PR10_bit.no7 -#define STPR12 PR10H_bit.no0 -#define IICPR120 PR10H_bit.no0 -#define CSIPR120 PR10H_bit.no0 -#define SRPR12 PR10H_bit.no1 -#define IICPR121 PR10H_bit.no1 -#define CSIPR121 PR10H_bit.no1 -#define SREPR12 PR10H_bit.no2 -#define SMSEPR1 PR10H_bit.no4 -#define STPR10 PR10H_bit.no5 -#define CSIPR100 PR10H_bit.no5 -#define IICPR100 PR10H_bit.no5 -#define TMPR100 PR10H_bit.no6 -#define TMPR101H PR10H_bit.no7 -#define SREPR10 PR10H_bit.no7 -#define STPR11 PR11_bit.no0 -#define SRPR11 PR11_bit.no1 -#define IICPR111 PR11_bit.no1 -#define CSIPR111 PR11_bit.no1 -#define TMPR103H PR11_bit.no2 -#define SREPR11 PR11_bit.no2 -#define IICAPR10 PR11_bit.no3 -#define IICPR101 PR11_bit.no4 -#define CSIPR101 PR11_bit.no4 -#define SRPR10 PR11_bit.no4 -#define TMPR101 PR11_bit.no5 -#define TMPR102 PR11_bit.no6 -#define TMPR103 PR11_bit.no7 -#define ADPR1 PR11H_bit.no0 -#define RTCPR1 PR11H_bit.no1 -#define ITLPR1 PR11H_bit.no2 -#define KRPR1 PR11H_bit.no3 -#define TMPR104 PR11H_bit.no7 -#define MAA PMC_bit.no0 - -/* - Interrupt vector addresses - */ -#define RST_vect 0x0 -#define INTDBG_vect 0x2 -#define INTWDTI_vect 0x4 -#define INTLVI_vect 0x6 -#define INTP0_vect 0x8 -#define INTP1_vect 0xA -#define INTP2_vect 0xC -#define INTP3_vect 0xE -#define INTP4_vect 0x10 -#define INTP5_vect 0x12 -#define INTCSI20_vect 0x14 -#define INTIIC20_vect 0x14 -#define INTST2_vect 0x14 -#define INTCSI21_vect 0x16 -#define INTIIC21_vect 0x16 -#define INTSR2_vect 0x16 -#define INTSRE2_vect 0x18 -#define INTSMSE_vect 0x1C -#define INTCSI00_vect 0x1E -#define INTIIC00_vect 0x1E -#define INTST0_vect 0x1E -#define INTTM00_vect 0x20 -#define INTSRE0_vect 0x22 -#define INTTM01H_vect 0x22 -#define INTST1_vect 0x24 -#define INTCSI11_vect 0x26 -#define INTIIC11_vect 0x26 -#define INTSR1_vect 0x26 -#define INTSRE1_vect 0x28 -#define INTTM03H_vect 0x28 -#define INTIICA0_vect 0x2A -#define INTCSI01_vect 0x2C -#define INTIIC01_vect 0x2C -#define INTSR0_vect 0x2C -#define INTTM01_vect 0x2E -#define INTTM02_vect 0x30 -#define INTTM03_vect 0x32 -#define INTAD_vect 0x34 -#define INTRTC_vect 0x36 -#define INTITL_vect 0x38 -#define INTKR_vect 0x3A -#define INTTM04_vect 0x42 -#define INTTM05_vect 0x44 -#define INTTM06_vect 0x46 -#define INTTM07_vect 0x48 -#define INTP6_vect 0x4A -#define INTP8_vect 0x4E -#define INTP9_vect 0x50 -#define INTFL_vect 0x52 -#define INTURE0_vect 0x58 -#define INTCTSUWR_vect 0x60 -#define INTCTSURD_vect 0x64 -#define INTCTSUFN_vect 0x66 -#define INTUT0_vect 0x6A -#define INTUR0_vect 0x6C -#define BRK_I_vect 0x7E -#endif +/************************************************************************/ +/* Header file generated from device file: */ +/* DR7F102GGE.DVF */ +/* E1.00b (2022/06/16) */ +/* Copyright(C) 2022 Renesas */ +/* Tool Version: 4.0.11 */ +/* Date Generated: 2022/07/25 */ +/************************************************************************/ + +#ifndef __INTRINSIC_FUNCTIONS +#define __INTRINSIC_FUNCTIONS + +#define DI() asm("di") +#define EI() asm("ei") +#define HALT() asm("halt") +#define NOP() asm("nop") +#define STOP() asm("stop") + +#endif + +#ifndef __IOREG_BIT_STRUCTURES +#define __IOREG_BIT_STRUCTURES +typedef struct { + unsigned char no0 :1; + unsigned char no1 :1; + unsigned char no2 :1; + unsigned char no3 :1; + unsigned char no4 :1; + unsigned char no5 :1; + unsigned char no6 :1; + unsigned char no7 :1; +} __BITS8; + +typedef struct { + unsigned short no0 :1; + unsigned short no1 :1; + unsigned short no2 :1; + unsigned short no3 :1; + unsigned short no4 :1; + unsigned short no5 :1; + unsigned short no6 :1; + unsigned short no7 :1; + unsigned short no8 :1; + unsigned short no9 :1; + unsigned short no10 :1; + unsigned short no11 :1; + unsigned short no12 :1; + unsigned short no13 :1; + unsigned short no14 :1; + unsigned short no15 :1; +} __BITS16; + +#endif + +#ifndef IODEFINE_H +#define IODEFINE_H + +/* + IO Registers + */ +union un_p0 { + unsigned char p0; + __BITS8 BIT; +}; +union un_p1 { + unsigned char p1; + __BITS8 BIT; +}; +union un_p2 { + unsigned char p2; + __BITS8 BIT; +}; +union un_p3 { + unsigned char p3; + __BITS8 BIT; +}; +union un_p4 { + unsigned char p4; + __BITS8 BIT; +}; +union un_p5 { + unsigned char p5; + __BITS8 BIT; +}; +union un_p6 { + unsigned char p6; + __BITS8 BIT; +}; +union un_p7 { + unsigned char p7; + __BITS8 BIT; +}; +union un_p12 { + unsigned char p12; + __BITS8 BIT; +}; +union un_p13 { + unsigned char p13; + __BITS8 BIT; +}; +union un_p14 { + unsigned char p14; + __BITS8 BIT; +}; +union un_pm0 { + unsigned char pm0; + __BITS8 BIT; +}; +union un_pm1 { + unsigned char pm1; + __BITS8 BIT; +}; +union un_pm2 { + unsigned char pm2; + __BITS8 BIT; +}; +union un_pm3 { + unsigned char pm3; + __BITS8 BIT; +}; +union un_pm4 { + unsigned char pm4; + __BITS8 BIT; +}; +union un_pm5 { + unsigned char pm5; + __BITS8 BIT; +}; +union un_pm6 { + unsigned char pm6; + __BITS8 BIT; +}; +union un_pm7 { + unsigned char pm7; + __BITS8 BIT; +}; +union un_pm12 { + unsigned char pm12; + __BITS8 BIT; +}; +union un_pm14 { + unsigned char pm14; + __BITS8 BIT; +}; +union un_adm0 { + unsigned char adm0; + __BITS8 BIT; +}; +union un_ads { + unsigned char ads; + __BITS8 BIT; +}; +union un_adm1 { + unsigned char adm1; + __BITS8 BIT; +}; +union un_krctl { + unsigned char krctl; + __BITS8 BIT; +}; +union un_krm0 { + unsigned char krm0; + __BITS8 BIT; +}; +union un_egp0 { + unsigned char egp0; + __BITS8 BIT; +}; +union un_egn0 { + unsigned char egn0; + __BITS8 BIT; +}; +union un_egp1 { + unsigned char egp1; + __BITS8 BIT; +}; +union un_egn1 { + unsigned char egn1; + __BITS8 BIT; +}; +union un_iics0 { + unsigned char iics0; + __BITS8 BIT; +}; +union un_iicf0 { + unsigned char iicf0; + __BITS8 BIT; +}; +union un_csc { + unsigned char csc; + __BITS8 BIT; +}; +union un_ostc { + unsigned char ostc; + __BITS8 BIT; +}; +union un_ckc { + unsigned char ckc; + __BITS8 BIT; +}; +union un_cks0 { + unsigned char cks0; + __BITS8 BIT; +}; +union un_cks1 { + unsigned char cks1; + __BITS8 BIT; +}; +union un_cksel { + unsigned char cksel; + __BITS8 BIT; +}; +union un_lvim { + unsigned char lvim; + __BITS8 BIT; +}; +union un_lvis { + unsigned char lvis; + __BITS8 BIT; +}; +union un_if2 { + unsigned short if2; + __BITS16 BIT; +}; +union un_if2l { + unsigned char if2l; + __BITS8 BIT; +}; +union un_if2h { + unsigned char if2h; + __BITS8 BIT; +}; +union un_if3 { + unsigned short if3; + __BITS16 BIT; +}; +union un_if3l { + unsigned char if3l; + __BITS8 BIT; +}; +union un_mk2 { + unsigned short mk2; + __BITS16 BIT; +}; +union un_mk2l { + unsigned char mk2l; + __BITS8 BIT; +}; +union un_mk2h { + unsigned char mk2h; + __BITS8 BIT; +}; +union un_mk3 { + unsigned short mk3; + __BITS16 BIT; +}; +union un_mk3l { + unsigned char mk3l; + __BITS8 BIT; +}; +union un_pr02 { + unsigned short pr02; + __BITS16 BIT; +}; +union un_pr02l { + unsigned char pr02l; + __BITS8 BIT; +}; +union un_pr02h { + unsigned char pr02h; + __BITS8 BIT; +}; +union un_pr03 { + unsigned short pr03; + __BITS16 BIT; +}; +union un_pr03l { + unsigned char pr03l; + __BITS8 BIT; +}; +union un_pr12 { + unsigned short pr12; + __BITS16 BIT; +}; +union un_pr12l { + unsigned char pr12l; + __BITS8 BIT; +}; +union un_pr12h { + unsigned char pr12h; + __BITS8 BIT; +}; +union un_pr13 { + unsigned short pr13; + __BITS16 BIT; +}; +union un_pr13l { + unsigned char pr13l; + __BITS8 BIT; +}; +union un_if0 { + unsigned short if0; + __BITS16 BIT; +}; +union un_if0l { + unsigned char if0l; + __BITS8 BIT; +}; +union un_if0h { + unsigned char if0h; + __BITS8 BIT; +}; +union un_if1 { + unsigned short if1; + __BITS16 BIT; +}; +union un_if1l { + unsigned char if1l; + __BITS8 BIT; +}; +union un_if1h { + unsigned char if1h; + __BITS8 BIT; +}; +union un_mk0 { + unsigned short mk0; + __BITS16 BIT; +}; +union un_mk0l { + unsigned char mk0l; + __BITS8 BIT; +}; +union un_mk0h { + unsigned char mk0h; + __BITS8 BIT; +}; +union un_mk1 { + unsigned short mk1; + __BITS16 BIT; +}; +union un_mk1l { + unsigned char mk1l; + __BITS8 BIT; +}; +union un_mk1h { + unsigned char mk1h; + __BITS8 BIT; +}; +union un_pr00 { + unsigned short pr00; + __BITS16 BIT; +}; +union un_pr00l { + unsigned char pr00l; + __BITS8 BIT; +}; +union un_pr00h { + unsigned char pr00h; + __BITS8 BIT; +}; +union un_pr01 { + unsigned short pr01; + __BITS16 BIT; +}; +union un_pr01l { + unsigned char pr01l; + __BITS8 BIT; +}; +union un_pr01h { + unsigned char pr01h; + __BITS8 BIT; +}; +union un_pr10 { + unsigned short pr10; + __BITS16 BIT; +}; +union un_pr10l { + unsigned char pr10l; + __BITS8 BIT; +}; +union un_pr10h { + unsigned char pr10h; + __BITS8 BIT; +}; +union un_pr11 { + unsigned short pr11; + __BITS16 BIT; +}; +union un_pr11l { + unsigned char pr11l; + __BITS8 BIT; +}; +union un_pr11h { + unsigned char pr11h; + __BITS8 BIT; +}; +union un_pmc { + unsigned char pmc; + __BITS8 BIT; +}; + +#define P0 (*(volatile union un_p0 *)0xFFF00).p0 +#define P0_bit (*(volatile union un_p0 *)0xFFF00).BIT +#define P1 (*(volatile union un_p1 *)0xFFF01).p1 +#define P1_bit (*(volatile union un_p1 *)0xFFF01).BIT +#define P2 (*(volatile union un_p2 *)0xFFF02).p2 +#define P2_bit (*(volatile union un_p2 *)0xFFF02).BIT +#define P3 (*(volatile union un_p3 *)0xFFF03).p3 +#define P3_bit (*(volatile union un_p3 *)0xFFF03).BIT +#define P4 (*(volatile union un_p4 *)0xFFF04).p4 +#define P4_bit (*(volatile union un_p4 *)0xFFF04).BIT +#define P5 (*(volatile union un_p5 *)0xFFF05).p5 +#define P5_bit (*(volatile union un_p5 *)0xFFF05).BIT +#define P6 (*(volatile union un_p6 *)0xFFF06).p6 +#define P6_bit (*(volatile union un_p6 *)0xFFF06).BIT +#define P7 (*(volatile union un_p7 *)0xFFF07).p7 +#define P7_bit (*(volatile union un_p7 *)0xFFF07).BIT +#define P12 (*(volatile union un_p12 *)0xFFF0C).p12 +#define P12_bit (*(volatile union un_p12 *)0xFFF0C).BIT +#define P13 (*(volatile union un_p13 *)0xFFF0D).p13 +#define P13_bit (*(volatile union un_p13 *)0xFFF0D).BIT +#define P14 (*(volatile union un_p14 *)0xFFF0E).p14 +#define P14_bit (*(volatile union un_p14 *)0xFFF0E).BIT +#define SDR00 (*(volatile unsigned short *)0xFFF10) +#define SIO00 (*(volatile unsigned char *)0xFFF10) +#define TXD0 (*(volatile unsigned char *)0xFFF10) +#define SDR01 (*(volatile unsigned short *)0xFFF12) +#define SIO01 (*(volatile unsigned char *)0xFFF12) +#define RXD0 (*(volatile unsigned char *)0xFFF12) +#define TDR00 (*(volatile unsigned short *)0xFFF18) +#define TDR01 (*(volatile unsigned short *)0xFFF1A) +#define TDR01L (*(volatile unsigned char *)0xFFF1A) +#define TDR01H (*(volatile unsigned char *)0xFFF1B) +#define ADCR (*(volatile unsigned short *)0xFFF1E) +#define ADCRH (*(volatile unsigned char *)0xFFF1F) +#define PM0 (*(volatile union un_pm0 *)0xFFF20).pm0 +#define PM0_bit (*(volatile union un_pm0 *)0xFFF20).BIT +#define PM1 (*(volatile union un_pm1 *)0xFFF21).pm1 +#define PM1_bit (*(volatile union un_pm1 *)0xFFF21).BIT +#define PM2 (*(volatile union un_pm2 *)0xFFF22).pm2 +#define PM2_bit (*(volatile union un_pm2 *)0xFFF22).BIT +#define PM3 (*(volatile union un_pm3 *)0xFFF23).pm3 +#define PM3_bit (*(volatile union un_pm3 *)0xFFF23).BIT +#define PM4 (*(volatile union un_pm4 *)0xFFF24).pm4 +#define PM4_bit (*(volatile union un_pm4 *)0xFFF24).BIT +#define PM5 (*(volatile union un_pm5 *)0xFFF25).pm5 +#define PM5_bit (*(volatile union un_pm5 *)0xFFF25).BIT +#define PM6 (*(volatile union un_pm6 *)0xFFF26).pm6 +#define PM6_bit (*(volatile union un_pm6 *)0xFFF26).BIT +#define PM7 (*(volatile union un_pm7 *)0xFFF27).pm7 +#define PM7_bit (*(volatile union un_pm7 *)0xFFF27).BIT +#define PM12 (*(volatile union un_pm12 *)0xFFF2C).pm12 +#define PM12_bit (*(volatile union un_pm12 *)0xFFF2C).BIT +#define PM14 (*(volatile union un_pm14 *)0xFFF2E).pm14 +#define PM14_bit (*(volatile union un_pm14 *)0xFFF2E).BIT +#define ADM0 (*(volatile union un_adm0 *)0xFFF30).adm0 +#define ADM0_bit (*(volatile union un_adm0 *)0xFFF30).BIT +#define ADS (*(volatile union un_ads *)0xFFF31).ads +#define ADS_bit (*(volatile union un_ads *)0xFFF31).BIT +#define ADM1 (*(volatile union un_adm1 *)0xFFF32).adm1 +#define ADM1_bit (*(volatile union un_adm1 *)0xFFF32).BIT +#define KRCTL (*(volatile union un_krctl *)0xFFF34).krctl +#define KRCTL_bit (*(volatile union un_krctl *)0xFFF34).BIT +#define KRF (*(volatile unsigned char *)0xFFF35) +#define KRM0 (*(volatile union un_krm0 *)0xFFF37).krm0 +#define KRM0_bit (*(volatile union un_krm0 *)0xFFF37).BIT +#define EGP0 (*(volatile union un_egp0 *)0xFFF38).egp0 +#define EGP0_bit (*(volatile union un_egp0 *)0xFFF38).BIT +#define EGN0 (*(volatile union un_egn0 *)0xFFF39).egn0 +#define EGN0_bit (*(volatile union un_egn0 *)0xFFF39).BIT +#define EGP1 (*(volatile union un_egp1 *)0xFFF3A).egp1 +#define EGP1_bit (*(volatile union un_egp1 *)0xFFF3A).BIT +#define EGN1 (*(volatile union un_egn1 *)0xFFF3B).egn1 +#define EGN1_bit (*(volatile union un_egn1 *)0xFFF3B).BIT +#define SDR02 (*(volatile unsigned short *)0xFFF44) +#define TXD1 (*(volatile unsigned char *)0xFFF44) +#define SDR03 (*(volatile unsigned short *)0xFFF46) +#define RXD1 (*(volatile unsigned char *)0xFFF46) +#define SIO11 (*(volatile unsigned char *)0xFFF46) +#define SDR10 (*(volatile unsigned short *)0xFFF48) +#define TXD2 (*(volatile unsigned char *)0xFFF48) +#define SIO20 (*(volatile unsigned char *)0xFFF48) +#define SDR11 (*(volatile unsigned short *)0xFFF4A) +#define RXD2 (*(volatile unsigned char *)0xFFF4A) +#define SIO21 (*(volatile unsigned char *)0xFFF4A) +#define IICA0 (*(volatile unsigned char *)0xFFF50) +#define IICS0 (*(volatile union un_iics0 *)0xFFF51).iics0 +#define IICS0_bit (*(volatile union un_iics0 *)0xFFF51).BIT +#define IICF0 (*(volatile union un_iicf0 *)0xFFF52).iicf0 +#define IICF0_bit (*(volatile union un_iicf0 *)0xFFF52).BIT +#define TDR02 (*(volatile unsigned short *)0xFFF64) +#define TDR03 (*(volatile unsigned short *)0xFFF66) +#define TDR03L (*(volatile unsigned char *)0xFFF66) +#define TDR03H (*(volatile unsigned char *)0xFFF67) +#define TDR04 (*(volatile unsigned short *)0xFFF68) +#define TDR05 (*(volatile unsigned short *)0xFFF6A) +#define TDR06 (*(volatile unsigned short *)0xFFF6C) +#define TDR07 (*(volatile unsigned short *)0xFFF6E) +#define CMC (*(volatile unsigned char *)0xFFFA0) +#define CSC (*(volatile union un_csc *)0xFFFA1).csc +#define CSC_bit (*(volatile union un_csc *)0xFFFA1).BIT +#define OSTC (*(volatile union un_ostc *)0xFFFA2).ostc +#define OSTC_bit (*(volatile union un_ostc *)0xFFFA2).BIT +#define OSTS (*(volatile unsigned char *)0xFFFA3) +#define CKC (*(volatile union un_ckc *)0xFFFA4).ckc +#define CKC_bit (*(volatile union un_ckc *)0xFFFA4).BIT +#define CKS0 (*(volatile union un_cks0 *)0xFFFA5).cks0 +#define CKS0_bit (*(volatile union un_cks0 *)0xFFFA5).BIT +#define CKS1 (*(volatile union un_cks1 *)0xFFFA6).cks1 +#define CKS1_bit (*(volatile union un_cks1 *)0xFFFA6).BIT +#define CKSEL (*(volatile union un_cksel *)0xFFFA7).cksel +#define CKSEL_bit (*(volatile union un_cksel *)0xFFFA7).BIT +#define RESF (*(volatile unsigned char *)0xFFFA8) +#define LVIM (*(volatile union un_lvim *)0xFFFA9).lvim +#define LVIM_bit (*(volatile union un_lvim *)0xFFFA9).BIT +#define LVIS (*(volatile union un_lvis *)0xFFFAA).lvis +#define LVIS_bit (*(volatile union un_lvis *)0xFFFAA).BIT +#define WDTE (*(volatile unsigned char *)0xFFFAB) +#define CRCIN (*(volatile unsigned char *)0xFFFAC) +#define IF2 (*(volatile union un_if2 *)0xFFFD0).if2 +#define IF2_bit (*(volatile union un_if2 *)0xFFFD0).BIT +#define IF2L (*(volatile union un_if2l *)0xFFFD0).if2l +#define IF2L_bit (*(volatile union un_if2l *)0xFFFD0).BIT +#define IF2H (*(volatile union un_if2h *)0xFFFD1).if2h +#define IF2H_bit (*(volatile union un_if2h *)0xFFFD1).BIT +#define IF3 (*(volatile union un_if3 *)0xFFFD2).if3 +#define IF3_bit (*(volatile union un_if3 *)0xFFFD2).BIT +#define IF3L (*(volatile union un_if3l *)0xFFFD2).if3l +#define IF3L_bit (*(volatile union un_if3l *)0xFFFD2).BIT +#define MK2 (*(volatile union un_mk2 *)0xFFFD4).mk2 +#define MK2_bit (*(volatile union un_mk2 *)0xFFFD4).BIT +#define MK2L (*(volatile union un_mk2l *)0xFFFD4).mk2l +#define MK2L_bit (*(volatile union un_mk2l *)0xFFFD4).BIT +#define MK2H (*(volatile union un_mk2h *)0xFFFD5).mk2h +#define MK2H_bit (*(volatile union un_mk2h *)0xFFFD5).BIT +#define MK3 (*(volatile union un_mk3 *)0xFFFD6).mk3 +#define MK3_bit (*(volatile union un_mk3 *)0xFFFD6).BIT +#define MK3L (*(volatile union un_mk3l *)0xFFFD6).mk3l +#define MK3L_bit (*(volatile union un_mk3l *)0xFFFD6).BIT +#define PR02 (*(volatile union un_pr02 *)0xFFFD8).pr02 +#define PR02_bit (*(volatile union un_pr02 *)0xFFFD8).BIT +#define PR02L (*(volatile union un_pr02l *)0xFFFD8).pr02l +#define PR02L_bit (*(volatile union un_pr02l *)0xFFFD8).BIT +#define PR02H (*(volatile union un_pr02h *)0xFFFD9).pr02h +#define PR02H_bit (*(volatile union un_pr02h *)0xFFFD9).BIT +#define PR03 (*(volatile union un_pr03 *)0xFFFDA).pr03 +#define PR03_bit (*(volatile union un_pr03 *)0xFFFDA).BIT +#define PR03L (*(volatile union un_pr03l *)0xFFFDA).pr03l +#define PR03L_bit (*(volatile union un_pr03l *)0xFFFDA).BIT +#define PR12 (*(volatile union un_pr12 *)0xFFFDC).pr12 +#define PR12_bit (*(volatile union un_pr12 *)0xFFFDC).BIT +#define PR12L (*(volatile union un_pr12l *)0xFFFDC).pr12l +#define PR12L_bit (*(volatile union un_pr12l *)0xFFFDC).BIT +#define PR12H (*(volatile union un_pr12h *)0xFFFDD).pr12h +#define PR12H_bit (*(volatile union un_pr12h *)0xFFFDD).BIT +#define PR13 (*(volatile union un_pr13 *)0xFFFDE).pr13 +#define PR13_bit (*(volatile union un_pr13 *)0xFFFDE).BIT +#define PR13L (*(volatile union un_pr13l *)0xFFFDE).pr13l +#define PR13L_bit (*(volatile union un_pr13l *)0xFFFDE).BIT +#define IF0 (*(volatile union un_if0 *)0xFFFE0).if0 +#define IF0_bit (*(volatile union un_if0 *)0xFFFE0).BIT +#define IF0L (*(volatile union un_if0l *)0xFFFE0).if0l +#define IF0L_bit (*(volatile union un_if0l *)0xFFFE0).BIT +#define IF0H (*(volatile union un_if0h *)0xFFFE1).if0h +#define IF0H_bit (*(volatile union un_if0h *)0xFFFE1).BIT +#define IF1 (*(volatile union un_if1 *)0xFFFE2).if1 +#define IF1_bit (*(volatile union un_if1 *)0xFFFE2).BIT +#define IF1L (*(volatile union un_if1l *)0xFFFE2).if1l +#define IF1L_bit (*(volatile union un_if1l *)0xFFFE2).BIT +#define IF1H (*(volatile union un_if1h *)0xFFFE3).if1h +#define IF1H_bit (*(volatile union un_if1h *)0xFFFE3).BIT +#define MK0 (*(volatile union un_mk0 *)0xFFFE4).mk0 +#define MK0_bit (*(volatile union un_mk0 *)0xFFFE4).BIT +#define MK0L (*(volatile union un_mk0l *)0xFFFE4).mk0l +#define MK0L_bit (*(volatile union un_mk0l *)0xFFFE4).BIT +#define MK0H (*(volatile union un_mk0h *)0xFFFE5).mk0h +#define MK0H_bit (*(volatile union un_mk0h *)0xFFFE5).BIT +#define MK1 (*(volatile union un_mk1 *)0xFFFE6).mk1 +#define MK1_bit (*(volatile union un_mk1 *)0xFFFE6).BIT +#define MK1L (*(volatile union un_mk1l *)0xFFFE6).mk1l +#define MK1L_bit (*(volatile union un_mk1l *)0xFFFE6).BIT +#define MK1H (*(volatile union un_mk1h *)0xFFFE7).mk1h +#define MK1H_bit (*(volatile union un_mk1h *)0xFFFE7).BIT +#define PR00 (*(volatile union un_pr00 *)0xFFFE8).pr00 +#define PR00_bit (*(volatile union un_pr00 *)0xFFFE8).BIT +#define PR00L (*(volatile union un_pr00l *)0xFFFE8).pr00l +#define PR00L_bit (*(volatile union un_pr00l *)0xFFFE8).BIT +#define PR00H (*(volatile union un_pr00h *)0xFFFE9).pr00h +#define PR00H_bit (*(volatile union un_pr00h *)0xFFFE9).BIT +#define PR01 (*(volatile union un_pr01 *)0xFFFEA).pr01 +#define PR01_bit (*(volatile union un_pr01 *)0xFFFEA).BIT +#define PR01L (*(volatile union un_pr01l *)0xFFFEA).pr01l +#define PR01L_bit (*(volatile union un_pr01l *)0xFFFEA).BIT +#define PR01H (*(volatile union un_pr01h *)0xFFFEB).pr01h +#define PR01H_bit (*(volatile union un_pr01h *)0xFFFEB).BIT +#define PR10 (*(volatile union un_pr10 *)0xFFFEC).pr10 +#define PR10_bit (*(volatile union un_pr10 *)0xFFFEC).BIT +#define PR10L (*(volatile union un_pr10l *)0xFFFEC).pr10l +#define PR10L_bit (*(volatile union un_pr10l *)0xFFFEC).BIT +#define PR10H (*(volatile union un_pr10h *)0xFFFED).pr10h +#define PR10H_bit (*(volatile union un_pr10h *)0xFFFED).BIT +#define PR11 (*(volatile union un_pr11 *)0xFFFEE).pr11 +#define PR11_bit (*(volatile union un_pr11 *)0xFFFEE).BIT +#define PR11L (*(volatile union un_pr11l *)0xFFFEE).pr11l +#define PR11L_bit (*(volatile union un_pr11l *)0xFFFEE).BIT +#define PR11H (*(volatile union un_pr11h *)0xFFFEF).pr11h +#define PR11H_bit (*(volatile union un_pr11h *)0xFFFEF).BIT +#define MACRL (*(volatile unsigned short *)0xFFFF0) +#define MACRH (*(volatile unsigned short *)0xFFFF2) +#define PMC (*(volatile union un_pmc *)0xFFFFE).pmc +#define PMC_bit (*(volatile union un_pmc *)0xFFFFE).BIT + +/* + Sfr bits + */ +#define ADCE ADM0_bit.no0 +#define ADCS ADM0_bit.no7 +#define KREG KRCTL_bit.no0 +#define KRMD KRCTL_bit.no7 +#define SPD0 IICS0_bit.no0 +#define STD0 IICS0_bit.no1 +#define ACKD0 IICS0_bit.no2 +#define TRC0 IICS0_bit.no3 +#define COI0 IICS0_bit.no4 +#define EXC0 IICS0_bit.no5 +#define ALD0 IICS0_bit.no6 +#define MSTS0 IICS0_bit.no7 +#define IICRSV0 IICF0_bit.no0 +#define STCEN0 IICF0_bit.no1 +#define IICBSY0 IICF0_bit.no6 +#define STCF0 IICF0_bit.no7 +#define HIOSTOP CSC_bit.no0 +#define MIOEN CSC_bit.no1 +#define XTSTOP CSC_bit.no6 +#define MSTOP CSC_bit.no7 +#define MCM1 CKC_bit.no0 +#define MCS1 CKC_bit.no1 +#define MCM0 CKC_bit.no4 +#define MCS CKC_bit.no5 +#define CSS CKC_bit.no6 +#define CLS CKC_bit.no7 +#define PCLOE0 CKS0_bit.no7 +#define PCLOE1 CKS1_bit.no7 +#define SELLOSC CKSEL_bit.no0 +#define LVD0F LVIM_bit.no0 +#define LVD1F LVIM_bit.no1 +#define DLVD0F LVIM_bit.no2 +#define DLVD1F LVIM_bit.no3 +#define LVISEN LVIM_bit.no7 +#define LVD1SEL LVIS_bit.no6 +#define LVD1EN LVIS_bit.no7 +#define TMIF05 IF2_bit.no0 +#define TMIF06 IF2_bit.no1 +#define TMIF07 IF2_bit.no2 +#define PIF6 IF2_bit.no3 +#define PIF8 IF2_bit.no5 +#define PIF9 IF2_bit.no6 +#define FLIF IF2_bit.no7 +#define UREIF0 IF2H_bit.no2 +#define CTSUWRIF IF2H_bit.no6 +#define CTSURDIF IF3_bit.no0 +#define CTSUFNIF IF3_bit.no1 +#define UTIF0 IF3_bit.no3 +#define URIF0 IF3_bit.no4 +#define TMMK05 MK2_bit.no0 +#define TMMK06 MK2_bit.no1 +#define TMMK07 MK2_bit.no2 +#define PMK6 MK2_bit.no3 +#define PMK8 MK2_bit.no5 +#define PMK9 MK2_bit.no6 +#define FLMK MK2_bit.no7 +#define UREMK0 MK2H_bit.no2 +#define CTSUWRMK MK2H_bit.no6 +#define CTSURDMK MK3_bit.no0 +#define CTSUFNMK MK3_bit.no1 +#define UTMK0 MK3_bit.no3 +#define URMK0 MK3_bit.no4 +#define TMPR005 PR02_bit.no0 +#define TMPR006 PR02_bit.no1 +#define TMPR007 PR02_bit.no2 +#define PPR06 PR02_bit.no3 +#define PPR08 PR02_bit.no5 +#define PPR09 PR02_bit.no6 +#define FLPR0 PR02_bit.no7 +#define UREPR00 PR02H_bit.no2 +#define CTSUWRPR0 PR02H_bit.no6 +#define CTSURDPR0 PR03_bit.no0 +#define CTSUFNPR0 PR03_bit.no1 +#define UTPR00 PR03_bit.no3 +#define URPR00 PR03_bit.no4 +#define TMPR105 PR12_bit.no0 +#define TMPR106 PR12_bit.no1 +#define TMPR107 PR12_bit.no2 +#define PPR16 PR12_bit.no3 +#define PPR18 PR12_bit.no5 +#define PPR19 PR12_bit.no6 +#define FLPR1 PR12_bit.no7 +#define UREPR10 PR12H_bit.no2 +#define CTSUWRPR1 PR12H_bit.no6 +#define CTSURDPR1 PR13_bit.no0 +#define CTSUFNPR1 PR13_bit.no1 +#define UTPR10 PR13_bit.no3 +#define URPR10 PR13_bit.no4 +#define WDTIIF IF0_bit.no0 +#define LVIIF IF0_bit.no1 +#define PIF0 IF0_bit.no2 +#define PIF1 IF0_bit.no3 +#define PIF2 IF0_bit.no4 +#define PIF3 IF0_bit.no5 +#define PIF4 IF0_bit.no6 +#define PIF5 IF0_bit.no7 +#define STIF2 IF0H_bit.no0 +#define CSIIF20 IF0H_bit.no0 +#define IICIF20 IF0H_bit.no0 +#define CSIIF21 IF0H_bit.no1 +#define SRIF2 IF0H_bit.no1 +#define IICIF21 IF0H_bit.no1 +#define SREIF2 IF0H_bit.no2 +#define SMSEIF IF0H_bit.no4 +#define STIF0 IF0H_bit.no5 +#define CSIIF00 IF0H_bit.no5 +#define IICIF00 IF0H_bit.no5 +#define TMIF00 IF0H_bit.no6 +#define SREIF0 IF0H_bit.no7 +#define TMIF01H IF0H_bit.no7 +#define STIF1 IF1_bit.no0 +#define IICIF11 IF1_bit.no1 +#define CSIIF11 IF1_bit.no1 +#define SRIF1 IF1_bit.no1 +#define SREIF1 IF1_bit.no2 +#define TMIF03H IF1_bit.no2 +#define IICAIF0 IF1_bit.no3 +#define CSIIF01 IF1_bit.no4 +#define IICIF01 IF1_bit.no4 +#define SRIF0 IF1_bit.no4 +#define TMIF01 IF1_bit.no5 +#define TMIF02 IF1_bit.no6 +#define TMIF03 IF1_bit.no7 +#define ADIF IF1H_bit.no0 +#define RTCIF IF1H_bit.no1 +#define ITLIF IF1H_bit.no2 +#define KRIF IF1H_bit.no3 +#define TMIF04 IF1H_bit.no7 +#define WDTIMK MK0_bit.no0 +#define LVIMK MK0_bit.no1 +#define PMK0 MK0_bit.no2 +#define PMK1 MK0_bit.no3 +#define PMK2 MK0_bit.no4 +#define PMK3 MK0_bit.no5 +#define PMK4 MK0_bit.no6 +#define PMK5 MK0_bit.no7 +#define STMK2 MK0H_bit.no0 +#define CSIMK20 MK0H_bit.no0 +#define IICMK20 MK0H_bit.no0 +#define CSIMK21 MK0H_bit.no1 +#define SRMK2 MK0H_bit.no1 +#define IICMK21 MK0H_bit.no1 +#define SREMK2 MK0H_bit.no2 +#define SMSEMK MK0H_bit.no4 +#define STMK0 MK0H_bit.no5 +#define IICMK00 MK0H_bit.no5 +#define CSIMK00 MK0H_bit.no5 +#define TMMK00 MK0H_bit.no6 +#define SREMK0 MK0H_bit.no7 +#define TMMK01H MK0H_bit.no7 +#define STMK1 MK1_bit.no0 +#define IICMK11 MK1_bit.no1 +#define CSIMK11 MK1_bit.no1 +#define SRMK1 MK1_bit.no1 +#define TMMK03H MK1_bit.no2 +#define SREMK1 MK1_bit.no2 +#define IICAMK0 MK1_bit.no3 +#define IICMK01 MK1_bit.no4 +#define SRMK0 MK1_bit.no4 +#define CSIMK01 MK1_bit.no4 +#define TMMK01 MK1_bit.no5 +#define TMMK02 MK1_bit.no6 +#define TMMK03 MK1_bit.no7 +#define ADMK MK1H_bit.no0 +#define RTCMK MK1H_bit.no1 +#define ITLMK MK1H_bit.no2 +#define KRMK MK1H_bit.no3 +#define TMMK04 MK1H_bit.no7 +#define WDTIPR0 PR00_bit.no0 +#define LVIPR0 PR00_bit.no1 +#define PPR00 PR00_bit.no2 +#define PPR01 PR00_bit.no3 +#define PPR02 PR00_bit.no4 +#define PPR03 PR00_bit.no5 +#define PPR04 PR00_bit.no6 +#define PPR05 PR00_bit.no7 +#define STPR02 PR00H_bit.no0 +#define CSIPR020 PR00H_bit.no0 +#define IICPR020 PR00H_bit.no0 +#define CSIPR021 PR00H_bit.no1 +#define SRPR02 PR00H_bit.no1 +#define IICPR021 PR00H_bit.no1 +#define SREPR02 PR00H_bit.no2 +#define SMSEPR0 PR00H_bit.no4 +#define STPR00 PR00H_bit.no5 +#define CSIPR000 PR00H_bit.no5 +#define IICPR000 PR00H_bit.no5 +#define TMPR000 PR00H_bit.no6 +#define SREPR00 PR00H_bit.no7 +#define TMPR001H PR00H_bit.no7 +#define STPR01 PR01_bit.no0 +#define SRPR01 PR01_bit.no1 +#define CSIPR011 PR01_bit.no1 +#define IICPR011 PR01_bit.no1 +#define SREPR01 PR01_bit.no2 +#define TMPR003H PR01_bit.no2 +#define IICAPR00 PR01_bit.no3 +#define CSIPR001 PR01_bit.no4 +#define SRPR00 PR01_bit.no4 +#define IICPR001 PR01_bit.no4 +#define TMPR001 PR01_bit.no5 +#define TMPR002 PR01_bit.no6 +#define TMPR003 PR01_bit.no7 +#define ADPR0 PR01H_bit.no0 +#define RTCPR0 PR01H_bit.no1 +#define ITLPR0 PR01H_bit.no2 +#define KRPR0 PR01H_bit.no3 +#define TMPR004 PR01H_bit.no7 +#define WDTIPR1 PR10_bit.no0 +#define LVIPR1 PR10_bit.no1 +#define PPR10 PR10_bit.no2 +#define PPR11 PR10_bit.no3 +#define PPR12 PR10_bit.no4 +#define PPR13 PR10_bit.no5 +#define PPR14 PR10_bit.no6 +#define PPR15 PR10_bit.no7 +#define STPR12 PR10H_bit.no0 +#define IICPR120 PR10H_bit.no0 +#define CSIPR120 PR10H_bit.no0 +#define SRPR12 PR10H_bit.no1 +#define IICPR121 PR10H_bit.no1 +#define CSIPR121 PR10H_bit.no1 +#define SREPR12 PR10H_bit.no2 +#define SMSEPR1 PR10H_bit.no4 +#define STPR10 PR10H_bit.no5 +#define CSIPR100 PR10H_bit.no5 +#define IICPR100 PR10H_bit.no5 +#define TMPR100 PR10H_bit.no6 +#define TMPR101H PR10H_bit.no7 +#define SREPR10 PR10H_bit.no7 +#define STPR11 PR11_bit.no0 +#define SRPR11 PR11_bit.no1 +#define IICPR111 PR11_bit.no1 +#define CSIPR111 PR11_bit.no1 +#define TMPR103H PR11_bit.no2 +#define SREPR11 PR11_bit.no2 +#define IICAPR10 PR11_bit.no3 +#define IICPR101 PR11_bit.no4 +#define CSIPR101 PR11_bit.no4 +#define SRPR10 PR11_bit.no4 +#define TMPR101 PR11_bit.no5 +#define TMPR102 PR11_bit.no6 +#define TMPR103 PR11_bit.no7 +#define ADPR1 PR11H_bit.no0 +#define RTCPR1 PR11H_bit.no1 +#define ITLPR1 PR11H_bit.no2 +#define KRPR1 PR11H_bit.no3 +#define TMPR104 PR11H_bit.no7 +#define MAA PMC_bit.no0 + +/* + Interrupt vector addresses + */ +#define RST_vect 0x0 +#define INTDBG_vect 0x2 +#define INTWDTI_vect 0x4 +#define INTLVI_vect 0x6 +#define INTP0_vect 0x8 +#define INTP1_vect 0xA +#define INTP2_vect 0xC +#define INTP3_vect 0xE +#define INTP4_vect 0x10 +#define INTP5_vect 0x12 +#define INTCSI20_vect 0x14 +#define INTIIC20_vect 0x14 +#define INTST2_vect 0x14 +#define INTCSI21_vect 0x16 +#define INTIIC21_vect 0x16 +#define INTSR2_vect 0x16 +#define INTSRE2_vect 0x18 +#define INTSMSE_vect 0x1C +#define INTCSI00_vect 0x1E +#define INTIIC00_vect 0x1E +#define INTST0_vect 0x1E +#define INTTM00_vect 0x20 +#define INTSRE0_vect 0x22 +#define INTTM01H_vect 0x22 +#define INTST1_vect 0x24 +#define INTCSI11_vect 0x26 +#define INTIIC11_vect 0x26 +#define INTSR1_vect 0x26 +#define INTSRE1_vect 0x28 +#define INTTM03H_vect 0x28 +#define INTIICA0_vect 0x2A +#define INTCSI01_vect 0x2C +#define INTIIC01_vect 0x2C +#define INTSR0_vect 0x2C +#define INTTM01_vect 0x2E +#define INTTM02_vect 0x30 +#define INTTM03_vect 0x32 +#define INTAD_vect 0x34 +#define INTRTC_vect 0x36 +#define INTITL_vect 0x38 +#define INTKR_vect 0x3A +#define INTTM04_vect 0x42 +#define INTTM05_vect 0x44 +#define INTTM06_vect 0x46 +#define INTTM07_vect 0x48 +#define INTP6_vect 0x4A +#define INTP8_vect 0x4E +#define INTP9_vect 0x50 +#define INTFL_vect 0x52 +#define INTURE0_vect 0x58 +#define INTCTSUWR_vect 0x60 +#define INTCTSURD_vect 0x64 +#define INTCTSUFN_vect 0x66 +#define INTUT0_vect 0x6A +#define INTUR0_vect 0x6C +#define BRK_I_vect 0x7E +#endif diff --git a/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/register_access/llvm/iodefine_ext.h b/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/register_access/llvm/iodefine_ext.h index 08ccfab..1b719af 100644 --- a/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/register_access/llvm/iodefine_ext.h +++ b/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/register_access/llvm/iodefine_ext.h @@ -1,1009 +1,1009 @@ -/************************************************************************/ -/* Header file generated from device file: */ -/* DR7F102GGE.DVF */ -/* E1.00b (2022/06/16) */ -/* Copyright(C) 2022 Renesas */ -/* Tool Version: 4.0.11 */ -/* Date Generated: 2022/07/25 */ -/************************************************************************/ - -#ifndef __INTRINSIC_FUNCTIONS -#define __INTRINSIC_FUNCTIONS - -#define DI() asm("di") -#define EI() asm("ei") -#define HALT() asm("halt") -#define NOP() asm("nop") -#define STOP() asm("stop") - -#endif - -#ifndef __IOREG_BIT_STRUCTURES -#define __IOREG_BIT_STRUCTURES -typedef struct { - unsigned char no0 :1; - unsigned char no1 :1; - unsigned char no2 :1; - unsigned char no3 :1; - unsigned char no4 :1; - unsigned char no5 :1; - unsigned char no6 :1; - unsigned char no7 :1; -} __BITS8; - -typedef struct { - unsigned short no0 :1; - unsigned short no1 :1; - unsigned short no2 :1; - unsigned short no3 :1; - unsigned short no4 :1; - unsigned short no5 :1; - unsigned short no6 :1; - unsigned short no7 :1; - unsigned short no8 :1; - unsigned short no9 :1; - unsigned short no10 :1; - unsigned short no11 :1; - unsigned short no12 :1; - unsigned short no13 :1; - unsigned short no14 :1; - unsigned short no15 :1; -} __BITS16; - -#endif - -#ifndef IODEFINE_EXT_H -#define IODEFINE_EXT_H - -/* - IO Registers - */ -union un_adm2 { - unsigned char adm2; - __BITS8 BIT; -}; -union un_pu0 { - unsigned char pu0; - __BITS8 BIT; -}; -union un_pu1 { - unsigned char pu1; - __BITS8 BIT; -}; -union un_pu3 { - unsigned char pu3; - __BITS8 BIT; -}; -union un_pu4 { - unsigned char pu4; - __BITS8 BIT; -}; -union un_pu5 { - unsigned char pu5; - __BITS8 BIT; -}; -union un_pu7 { - unsigned char pu7; - __BITS8 BIT; -}; -union un_pu12 { - unsigned char pu12; - __BITS8 BIT; -}; -union un_pu14 { - unsigned char pu14; - __BITS8 BIT; -}; -union un_pim0 { - unsigned char pim0; - __BITS8 BIT; -}; -union un_pim1 { - unsigned char pim1; - __BITS8 BIT; -}; -union un_pim4 { - unsigned char pim4; - __BITS8 BIT; -}; -union un_pim7 { - unsigned char pim7; - __BITS8 BIT; -}; -union un_pom0 { - unsigned char pom0; - __BITS8 BIT; -}; -union un_pom1 { - unsigned char pom1; - __BITS8 BIT; -}; -union un_pom5 { - unsigned char pom5; - __BITS8 BIT; -}; -union un_pom7 { - unsigned char pom7; - __BITS8 BIT; -}; -union un_pom12 { - unsigned char pom12; - __BITS8 BIT; -}; -union un_pmca0 { - unsigned char pmca0; - __BITS8 BIT; -}; -union un_pmca2 { - unsigned char pmca2; - __BITS8 BIT; -}; -union un_pmca12 { - unsigned char pmca12; - __BITS8 BIT; -}; -union un_pmca14 { - unsigned char pmca14; - __BITS8 BIT; -}; -union un_nfen0 { - unsigned char nfen0; - __BITS8 BIT; -}; -union un_nfen1 { - unsigned char nfen1; - __BITS8 BIT; -}; -union un_isc { - unsigned char isc; - __BITS8 BIT; -}; -union un_ulbs { - unsigned char ulbs; - __BITS8 BIT; -}; -union un_pms { - unsigned char pms; - __BITS8 BIT; -}; -union un_dflctl { - unsigned char dflctl; - __BITS8 BIT; -}; -union un_flmode { - unsigned char flmode; - __BITS8 BIT; -}; -union un_flmwrp { - unsigned char flmwrp; - __BITS8 BIT; -}; -union un_fsse { - unsigned char fsse; - __BITS8 BIT; -}; -union un_pfs { - unsigned char pfs; - __BITS8 BIT; -}; -union un_per0 { - unsigned char per0; - __BITS8 BIT; -}; -union un_prr0 { - unsigned char prr0; - __BITS8 BIT; -}; -union un_osmc { - unsigned char osmc; - __BITS8 BIT; -}; -union un_rpectl { - unsigned char rpectl; - __BITS8 BIT; -}; -union un_porsr { - unsigned char porsr; - __BITS8 BIT; -}; -union un_per1 { - unsigned char per1; - __BITS8 BIT; -}; -union un_prr1 { - unsigned char prr1; - __BITS8 BIT; -}; -union un_se0l { - unsigned char se0l; - __BITS8 BIT; -}; -union un_ss0l { - unsigned char ss0l; - __BITS8 BIT; -}; -union un_st0l { - unsigned char st0l; - __BITS8 BIT; -}; -union un_soe0l { - unsigned char soe0l; - __BITS8 BIT; -}; -union un_se1l { - unsigned char se1l; - __BITS8 BIT; -}; -union un_ss1l { - unsigned char ss1l; - __BITS8 BIT; -}; -union un_st1l { - unsigned char st1l; - __BITS8 BIT; -}; -union un_soe1l { - unsigned char soe1l; - __BITS8 BIT; -}; -union un_te0l { - unsigned char te0l; - __BITS8 BIT; -}; -union un_ts0l { - unsigned char ts0l; - __BITS8 BIT; -}; -union un_tt0l { - unsigned char tt0l; - __BITS8 BIT; -}; -union un_toe0l { - unsigned char toe0l; - __BITS8 BIT; -}; -union un_wkupmd { - unsigned char wkupmd; - __BITS8 BIT; -}; -union un_lvdfclr { - unsigned char lvdfclr; - __BITS8 BIT; -}; -union un_rtcc0 { - unsigned char rtcc0; - __BITS8 BIT; -}; -union un_rtcc1 { - unsigned char rtcc1; - __BITS8 BIT; -}; -union un_iicctl00 { - unsigned char iicctl00; - __BITS8 BIT; -}; -union un_iicctl01 { - unsigned char iicctl01; - __BITS8 BIT; -}; -union un_pmct0 { - unsigned char pmct0; - __BITS8 BIT; -}; -union un_pmct1 { - unsigned char pmct1; - __BITS8 BIT; -}; -union un_pmct2 { - unsigned char pmct2; - __BITS8 BIT; -}; -union un_pmct3 { - unsigned char pmct3; - __BITS8 BIT; -}; -union un_pmct5 { - unsigned char pmct5; - __BITS8 BIT; -}; -union un_pmct7 { - unsigned char pmct7; - __BITS8 BIT; -}; -union un_pmct13 { - unsigned char pmct13; - __BITS8 BIT; -}; -union un_pmct14 { - unsigned char pmct14; - __BITS8 BIT; -}; -union un_pfoe1 { - unsigned char pfoe1; - __BITS8 BIT; -}; -union un_pdidis0 { - unsigned char pdidis0; - __BITS8 BIT; -}; -union un_pdidis1 { - unsigned char pdidis1; - __BITS8 BIT; -}; -union un_pdidis5 { - unsigned char pdidis5; - __BITS8 BIT; -}; -union un_pdidis7 { - unsigned char pdidis7; - __BITS8 BIT; -}; -union un_pdidis12 { - unsigned char pdidis12; - __BITS8 BIT; -}; -union un_pdidis13 { - unsigned char pdidis13; - __BITS8 BIT; -}; -union un_flars { - unsigned char flars; - __BITS8 BIT; -}; -union un_fssq { - unsigned char fssq; - __BITS8 BIT; -}; -union un_flrst { - unsigned char flrst; - __BITS8 BIT; -}; -union un_fsastl { - unsigned char fsastl; - __BITS8 BIT; -}; -union un_fsasth { - unsigned char fsasth; - __BITS8 BIT; -}; -union un_dtcen0 { - unsigned char dtcen0; - __BITS8 BIT; -}; -union un_dtcen1 { - unsigned char dtcen1; - __BITS8 BIT; -}; -union un_dtcen2 { - unsigned char dtcen2; - __BITS8 BIT; -}; -union un_dtcen3 { - unsigned char dtcen3; - __BITS8 BIT; -}; -union un_dtcen4 { - unsigned char dtcen4; - __BITS8 BIT; -}; -union un_crc0ctl { - unsigned char crc0ctl; - __BITS8 BIT; -}; -union un_asima00 { - unsigned char asima00; - __BITS8 BIT; -}; -union un_asima01 { - unsigned char asima01; - __BITS8 BIT; -}; -union un_ascta0 { - unsigned char ascta0; - __BITS8 BIT; -}; -union un_uta0ck { - unsigned char uta0ck; - __BITS8 BIT; -}; -union un_itlctl0 { - unsigned char itlctl0; - __BITS8 BIT; -}; -union un_itlcc0 { - unsigned char itlcc0; - __BITS8 BIT; -}; -union un_smsc { - unsigned char smsc; - __BITS8 BIT; -}; -union un_smss { - unsigned char smss; - __BITS8 BIT; -}; -union un_trngscr0 { - unsigned char trngscr0; - __BITS8 BIT; -}; - -#define ADM2 (*(volatile union un_adm2 *)0xF0010).adm2 -#define ADM2_bit (*(volatile union un_adm2 *)0xF0010).BIT -#define ADUL (*(volatile unsigned char *)0xF0011) -#define ADLL (*(volatile unsigned char *)0xF0012) -#define ADTES (*(volatile unsigned char *)0xF0013) -#define PU0 (*(volatile union un_pu0 *)0xF0030).pu0 -#define PU0_bit (*(volatile union un_pu0 *)0xF0030).BIT -#define PU1 (*(volatile union un_pu1 *)0xF0031).pu1 -#define PU1_bit (*(volatile union un_pu1 *)0xF0031).BIT -#define PU3 (*(volatile union un_pu3 *)0xF0033).pu3 -#define PU3_bit (*(volatile union un_pu3 *)0xF0033).BIT -#define PU4 (*(volatile union un_pu4 *)0xF0034).pu4 -#define PU4_bit (*(volatile union un_pu4 *)0xF0034).BIT -#define PU5 (*(volatile union un_pu5 *)0xF0035).pu5 -#define PU5_bit (*(volatile union un_pu5 *)0xF0035).BIT -#define PU7 (*(volatile union un_pu7 *)0xF0037).pu7 -#define PU7_bit (*(volatile union un_pu7 *)0xF0037).BIT -#define PU12 (*(volatile union un_pu12 *)0xF003C).pu12 -#define PU12_bit (*(volatile union un_pu12 *)0xF003C).BIT -#define PU14 (*(volatile union un_pu14 *)0xF003E).pu14 -#define PU14_bit (*(volatile union un_pu14 *)0xF003E).BIT -#define PIM0 (*(volatile union un_pim0 *)0xF0040).pim0 -#define PIM0_bit (*(volatile union un_pim0 *)0xF0040).BIT -#define PIM1 (*(volatile union un_pim1 *)0xF0041).pim1 -#define PIM1_bit (*(volatile union un_pim1 *)0xF0041).BIT -#define PIM4 (*(volatile union un_pim4 *)0xF0044).pim4 -#define PIM4_bit (*(volatile union un_pim4 *)0xF0044).BIT -#define PIM7 (*(volatile union un_pim7 *)0xF0047).pim7 -#define PIM7_bit (*(volatile union un_pim7 *)0xF0047).BIT -#define POM0 (*(volatile union un_pom0 *)0xF0050).pom0 -#define POM0_bit (*(volatile union un_pom0 *)0xF0050).BIT -#define POM1 (*(volatile union un_pom1 *)0xF0051).pom1 -#define POM1_bit (*(volatile union un_pom1 *)0xF0051).BIT -#define POM5 (*(volatile union un_pom5 *)0xF0055).pom5 -#define POM5_bit (*(volatile union un_pom5 *)0xF0055).BIT -#define POM7 (*(volatile union un_pom7 *)0xF0057).pom7 -#define POM7_bit (*(volatile union un_pom7 *)0xF0057).BIT -#define POM12 (*(volatile union un_pom12 *)0xF005C).pom12 -#define POM12_bit (*(volatile union un_pom12 *)0xF005C).BIT -#define PMCA0 (*(volatile union un_pmca0 *)0xF0060).pmca0 -#define PMCA0_bit (*(volatile union un_pmca0 *)0xF0060).BIT -#define PMCA2 (*(volatile union un_pmca2 *)0xF0062).pmca2 -#define PMCA2_bit (*(volatile union un_pmca2 *)0xF0062).BIT -#define PMCA12 (*(volatile union un_pmca12 *)0xF006C).pmca12 -#define PMCA12_bit (*(volatile union un_pmca12 *)0xF006C).BIT -#define PMCA14 (*(volatile union un_pmca14 *)0xF006E).pmca14 -#define PMCA14_bit (*(volatile union un_pmca14 *)0xF006E).BIT -#define NFEN0 (*(volatile union un_nfen0 *)0xF0070).nfen0 -#define NFEN0_bit (*(volatile union un_nfen0 *)0xF0070).BIT -#define NFEN1 (*(volatile union un_nfen1 *)0xF0071).nfen1 -#define NFEN1_bit (*(volatile union un_nfen1 *)0xF0071).BIT -#define ISC (*(volatile union un_isc *)0xF0073).isc -#define ISC_bit (*(volatile union un_isc *)0xF0073).BIT -#define TIS0 (*(volatile unsigned char *)0xF0074) -#define TIS1 (*(volatile unsigned char *)0xF0075) -#define PIOR (*(volatile unsigned char *)0xF0077) -#define IAWCTL (*(volatile unsigned char *)0xF0078) -#define ULBS (*(volatile union un_ulbs *)0xF0079).ulbs -#define ULBS_bit (*(volatile union un_ulbs *)0xF0079).BIT -#define PMS (*(volatile union un_pms *)0xF007B).pms -#define PMS_bit (*(volatile union un_pms *)0xF007B).BIT -#define DFLCTL (*(volatile union un_dflctl *)0xF0090).dflctl -#define DFLCTL_bit (*(volatile union un_dflctl *)0xF0090).BIT -#define HIOTRM (*(volatile unsigned char *)0xF00A0) -#define HOCODIV (*(volatile unsigned char *)0xF00A8) -#define FLMODE (*(volatile union un_flmode *)0xF00AA).flmode -#define FLMODE_bit (*(volatile union un_flmode *)0xF00AA).BIT -#define FLMWRP (*(volatile union un_flmwrp *)0xF00AB).flmwrp -#define FLMWRP_bit (*(volatile union un_flmwrp *)0xF00AB).BIT -#define FLSEC (*(volatile unsigned short *)0xF00B0) -#define FLFSWS (*(volatile unsigned short *)0xF00B2) -#define FLFSWE (*(volatile unsigned short *)0xF00B4) -#define FSSET (*(volatile unsigned char *)0xF00B6) -#define FSSE (*(volatile union un_fsse *)0xF00B7).fsse -#define FSSE_bit (*(volatile union un_fsse *)0xF00B7).BIT -#define PFCMD (*(volatile unsigned char *)0xF00C0) -#define PFS (*(volatile union un_pfs *)0xF00C1).pfs -#define PFS_bit (*(volatile union un_pfs *)0xF00C1).BIT -#define PER0 (*(volatile union un_per0 *)0xF00F0).per0 -#define PER0_bit (*(volatile union un_per0 *)0xF00F0).BIT -#define PRR0 (*(volatile union un_prr0 *)0xF00F1).prr0 -#define PRR0_bit (*(volatile union un_prr0 *)0xF00F1).BIT -#define MOCODIV (*(volatile unsigned char *)0xF00F2) -#define OSMC (*(volatile union un_osmc *)0xF00F3).osmc -#define OSMC_bit (*(volatile union un_osmc *)0xF00F3).BIT -#define RPECTL (*(volatile union un_rpectl *)0xF00F5).rpectl -#define RPECTL_bit (*(volatile union un_rpectl *)0xF00F5).BIT -#define PORSR (*(volatile union un_porsr *)0xF00F9).porsr -#define PORSR_bit (*(volatile union un_porsr *)0xF00F9).BIT -#define PER1 (*(volatile union un_per1 *)0xF00FA).per1 -#define PER1_bit (*(volatile union un_per1 *)0xF00FA).BIT -#define PRR1 (*(volatile union un_prr1 *)0xF00FB).prr1 -#define PRR1_bit (*(volatile union un_prr1 *)0xF00FB).BIT -#define BCDADJ (*(volatile unsigned char *)0xF00FE) -#define VECTCTRL (*(volatile unsigned char *)0xF00FF) -#define SSR00 (*(volatile unsigned short *)0xF0100) -#define SSR00L (*(volatile unsigned char *)0xF0100) -#define SSR01 (*(volatile unsigned short *)0xF0102) -#define SSR01L (*(volatile unsigned char *)0xF0102) -#define SSR02 (*(volatile unsigned short *)0xF0104) -#define SSR02L (*(volatile unsigned char *)0xF0104) -#define SSR03 (*(volatile unsigned short *)0xF0106) -#define SSR03L (*(volatile unsigned char *)0xF0106) -#define SIR00 (*(volatile unsigned short *)0xF0108) -#define SIR00L (*(volatile unsigned char *)0xF0108) -#define SIR01 (*(volatile unsigned short *)0xF010A) -#define SIR01L (*(volatile unsigned char *)0xF010A) -#define SIR02 (*(volatile unsigned short *)0xF010C) -#define SIR02L (*(volatile unsigned char *)0xF010C) -#define SIR03 (*(volatile unsigned short *)0xF010E) -#define SIR03L (*(volatile unsigned char *)0xF010E) -#define SMR00 (*(volatile unsigned short *)0xF0110) -#define SMR01 (*(volatile unsigned short *)0xF0112) -#define SMR02 (*(volatile unsigned short *)0xF0114) -#define SMR03 (*(volatile unsigned short *)0xF0116) -#define SCR00 (*(volatile unsigned short *)0xF0118) -#define SCR01 (*(volatile unsigned short *)0xF011A) -#define SCR02 (*(volatile unsigned short *)0xF011C) -#define SCR03 (*(volatile unsigned short *)0xF011E) -#define SE0 (*(volatile unsigned short *)0xF0120) -#define SE0L (*(volatile union un_se0l *)0xF0120).se0l -#define SE0L_bit (*(volatile union un_se0l *)0xF0120).BIT -#define SS0 (*(volatile unsigned short *)0xF0122) -#define SS0L (*(volatile union un_ss0l *)0xF0122).ss0l -#define SS0L_bit (*(volatile union un_ss0l *)0xF0122).BIT -#define ST0 (*(volatile unsigned short *)0xF0124) -#define ST0L (*(volatile union un_st0l *)0xF0124).st0l -#define ST0L_bit (*(volatile union un_st0l *)0xF0124).BIT -#define SPS0 (*(volatile unsigned short *)0xF0126) -#define SPS0L (*(volatile unsigned char *)0xF0126) -#define SO0 (*(volatile unsigned short *)0xF0128) -#define SOE0 (*(volatile unsigned short *)0xF012A) -#define SOE0L (*(volatile union un_soe0l *)0xF012A).soe0l -#define SOE0L_bit (*(volatile union un_soe0l *)0xF012A).BIT -#define SOL0 (*(volatile unsigned short *)0xF0134) -#define SOL0L (*(volatile unsigned char *)0xF0134) -#define SSC0 (*(volatile unsigned short *)0xF0138) -#define SSC0L (*(volatile unsigned char *)0xF0138) -#define SSR10 (*(volatile unsigned short *)0xF0140) -#define SSR10L (*(volatile unsigned char *)0xF0140) -#define SSR11 (*(volatile unsigned short *)0xF0142) -#define SSR11L (*(volatile unsigned char *)0xF0142) -#define SIR10 (*(volatile unsigned short *)0xF0148) -#define SIR10L (*(volatile unsigned char *)0xF0148) -#define SIR11 (*(volatile unsigned short *)0xF014A) -#define SIR11L (*(volatile unsigned char *)0xF014A) -#define SMR10 (*(volatile unsigned short *)0xF0150) -#define SMR11 (*(volatile unsigned short *)0xF0152) -#define SCR10 (*(volatile unsigned short *)0xF0158) -#define SCR11 (*(volatile unsigned short *)0xF015A) -#define SE1 (*(volatile unsigned short *)0xF0160) -#define SE1L (*(volatile union un_se1l *)0xF0160).se1l -#define SE1L_bit (*(volatile union un_se1l *)0xF0160).BIT -#define SS1 (*(volatile unsigned short *)0xF0162) -#define SS1L (*(volatile union un_ss1l *)0xF0162).ss1l -#define SS1L_bit (*(volatile union un_ss1l *)0xF0162).BIT -#define ST1 (*(volatile unsigned short *)0xF0164) -#define ST1L (*(volatile union un_st1l *)0xF0164).st1l -#define ST1L_bit (*(volatile union un_st1l *)0xF0164).BIT -#define SPS1 (*(volatile unsigned short *)0xF0166) -#define SPS1L (*(volatile unsigned char *)0xF0166) -#define SO1 (*(volatile unsigned short *)0xF0168) -#define SOE1 (*(volatile unsigned short *)0xF016A) -#define SOE1L (*(volatile union un_soe1l *)0xF016A).soe1l -#define SOE1L_bit (*(volatile union un_soe1l *)0xF016A).BIT -#define SOL1 (*(volatile unsigned short *)0xF0174) -#define SOL1L (*(volatile unsigned char *)0xF0174) -#define TCR00 (*(volatile unsigned short *)0xF0180) -#define TCR01 (*(volatile unsigned short *)0xF0182) -#define TCR02 (*(volatile unsigned short *)0xF0184) -#define TCR03 (*(volatile unsigned short *)0xF0186) -#define TCR04 (*(volatile unsigned short *)0xF0188) -#define TCR05 (*(volatile unsigned short *)0xF018A) -#define TCR06 (*(volatile unsigned short *)0xF018C) -#define TCR07 (*(volatile unsigned short *)0xF018E) -#define TMR00 (*(volatile unsigned short *)0xF0190) -#define TMR01 (*(volatile unsigned short *)0xF0192) -#define TMR02 (*(volatile unsigned short *)0xF0194) -#define TMR03 (*(volatile unsigned short *)0xF0196) -#define TMR04 (*(volatile unsigned short *)0xF0198) -#define TMR05 (*(volatile unsigned short *)0xF019A) -#define TMR06 (*(volatile unsigned short *)0xF019C) -#define TMR07 (*(volatile unsigned short *)0xF019E) -#define TSR00 (*(volatile unsigned short *)0xF01A0) -#define TSR00L (*(volatile unsigned char *)0xF01A0) -#define TSR01 (*(volatile unsigned short *)0xF01A2) -#define TSR01L (*(volatile unsigned char *)0xF01A2) -#define TSR02 (*(volatile unsigned short *)0xF01A4) -#define TSR02L (*(volatile unsigned char *)0xF01A4) -#define TSR03 (*(volatile unsigned short *)0xF01A6) -#define TSR03L (*(volatile unsigned char *)0xF01A6) -#define TSR04 (*(volatile unsigned short *)0xF01A8) -#define TSR04L (*(volatile unsigned char *)0xF01A8) -#define TSR05 (*(volatile unsigned short *)0xF01AA) -#define TSR05L (*(volatile unsigned char *)0xF01AA) -#define TSR06 (*(volatile unsigned short *)0xF01AC) -#define TSR06L (*(volatile unsigned char *)0xF01AC) -#define TSR07 (*(volatile unsigned short *)0xF01AE) -#define TSR07L (*(volatile unsigned char *)0xF01AE) -#define TE0 (*(volatile unsigned short *)0xF01B0) -#define TE0L (*(volatile union un_te0l *)0xF01B0).te0l -#define TE0L_bit (*(volatile union un_te0l *)0xF01B0).BIT -#define TS0 (*(volatile unsigned short *)0xF01B2) -#define TS0L (*(volatile union un_ts0l *)0xF01B2).ts0l -#define TS0L_bit (*(volatile union un_ts0l *)0xF01B2).BIT -#define TT0 (*(volatile unsigned short *)0xF01B4) -#define TT0L (*(volatile union un_tt0l *)0xF01B4).tt0l -#define TT0L_bit (*(volatile union un_tt0l *)0xF01B4).BIT -#define TPS0 (*(volatile unsigned short *)0xF01B6) -#define TO0 (*(volatile unsigned short *)0xF01B8) -#define TO0L (*(volatile unsigned char *)0xF01B8) -#define TOE0 (*(volatile unsigned short *)0xF01BA) -#define TOE0L (*(volatile union un_toe0l *)0xF01BA).toe0l -#define TOE0L_bit (*(volatile union un_toe0l *)0xF01BA).BIT -#define TOL0 (*(volatile unsigned short *)0xF01BC) -#define TOL0L (*(volatile unsigned char *)0xF01BC) -#define TOM0 (*(volatile unsigned short *)0xF01BE) -#define TOM0L (*(volatile unsigned char *)0xF01BE) -#define MIOTRM (*(volatile unsigned char *)0xF0212) -#define LIOTRM (*(volatile unsigned char *)0xF0213) -#define MOSCDIV (*(volatile unsigned char *)0xF0214) -#define WKUPMD (*(volatile union un_wkupmd *)0xF0215).wkupmd -#define WKUPMD_bit (*(volatile union un_wkupmd *)0xF0215).BIT -#define LVDFCLR (*(volatile union un_lvdfclr *)0xF0218).lvdfclr -#define LVDFCLR_bit (*(volatile union un_lvdfclr *)0xF0218).BIT -#define SEC (*(volatile unsigned char *)0xF0220) -#define MIN (*(volatile unsigned char *)0xF0221) -#define HOUR (*(volatile unsigned char *)0xF0222) -#define WEEK (*(volatile unsigned char *)0xF0223) -#define DAY (*(volatile unsigned char *)0xF0224) -#define MONTH (*(volatile unsigned char *)0xF0225) -#define YEAR (*(volatile unsigned char *)0xF0226) -#define SUBCUD (*(volatile unsigned char *)0xF0227) -#define ALARMWM (*(volatile unsigned char *)0xF0228) -#define ALARMWH (*(volatile unsigned char *)0xF0229) -#define ALARMWW (*(volatile unsigned char *)0xF022A) -#define RTCC0 (*(volatile union un_rtcc0 *)0xF022B).rtcc0 -#define RTCC0_bit (*(volatile union un_rtcc0 *)0xF022B).BIT -#define RTCC1 (*(volatile union un_rtcc1 *)0xF022C).rtcc1 -#define RTCC1_bit (*(volatile union un_rtcc1 *)0xF022C).BIT -#define IICCTL00 (*(volatile union un_iicctl00 *)0xF0230).iicctl00 -#define IICCTL00_bit (*(volatile union un_iicctl00 *)0xF0230).BIT -#define IICCTL01 (*(volatile union un_iicctl01 *)0xF0231).iicctl01 -#define IICCTL01_bit (*(volatile union un_iicctl01 *)0xF0231).BIT -#define IICWL0 (*(volatile unsigned char *)0xF0232) -#define IICWH0 (*(volatile unsigned char *)0xF0233) -#define SVA0 (*(volatile unsigned char *)0xF0234) -#define ELSELR00 (*(volatile unsigned char *)0xF0240) -#define ELSELR01 (*(volatile unsigned char *)0xF0241) -#define ELSELR02 (*(volatile unsigned char *)0xF0242) -#define ELSELR03 (*(volatile unsigned char *)0xF0243) -#define ELSELR04 (*(volatile unsigned char *)0xF0244) -#define ELSELR05 (*(volatile unsigned char *)0xF0245) -#define ELSELR06 (*(volatile unsigned char *)0xF0246) -#define ELSELR07 (*(volatile unsigned char *)0xF0247) -#define ELSELR08 (*(volatile unsigned char *)0xF0248) -#define ELSELR10 (*(volatile unsigned char *)0xF024A) -#define ELSELR11 (*(volatile unsigned char *)0xF024B) -#define ELSELR12 (*(volatile unsigned char *)0xF024C) -#define ELSELR13 (*(volatile unsigned char *)0xF024D) -#define ELSELR14 (*(volatile unsigned char *)0xF024E) -#define ELSELR15 (*(volatile unsigned char *)0xF024F) -#define ELSELR16 (*(volatile unsigned char *)0xF0250) -#define ELSELR17 (*(volatile unsigned char *)0xF0251) -#define ELSELR18 (*(volatile unsigned char *)0xF0252) -#define ELSELR19 (*(volatile unsigned char *)0xF0253) -#define PMCT0 (*(volatile union un_pmct0 *)0xF0260).pmct0 -#define PMCT0_bit (*(volatile union un_pmct0 *)0xF0260).BIT -#define PMCT1 (*(volatile union un_pmct1 *)0xF0261).pmct1 -#define PMCT1_bit (*(volatile union un_pmct1 *)0xF0261).BIT -#define PMCT2 (*(volatile union un_pmct2 *)0xF0262).pmct2 -#define PMCT2_bit (*(volatile union un_pmct2 *)0xF0262).BIT -#define PMCT3 (*(volatile union un_pmct3 *)0xF0263).pmct3 -#define PMCT3_bit (*(volatile union un_pmct3 *)0xF0263).BIT -#define PMCT5 (*(volatile union un_pmct5 *)0xF0265).pmct5 -#define PMCT5_bit (*(volatile union un_pmct5 *)0xF0265).BIT -#define PMCT7 (*(volatile union un_pmct7 *)0xF0267).pmct7 -#define PMCT7_bit (*(volatile union un_pmct7 *)0xF0267).BIT -#define PMCT13 (*(volatile union un_pmct13 *)0xF026D).pmct13 -#define PMCT13_bit (*(volatile union un_pmct13 *)0xF026D).BIT -#define PMCT14 (*(volatile union un_pmct14 *)0xF026E).pmct14 -#define PMCT14_bit (*(volatile union un_pmct14 *)0xF026E).BIT -#define PFOE1 (*(volatile union un_pfoe1 *)0xF02AB).pfoe1 -#define PFOE1_bit (*(volatile union un_pfoe1 *)0xF02AB).BIT -#define PDIDIS0 (*(volatile union un_pdidis0 *)0xF02B0).pdidis0 -#define PDIDIS0_bit (*(volatile union un_pdidis0 *)0xF02B0).BIT -#define PDIDIS1 (*(volatile union un_pdidis1 *)0xF02B1).pdidis1 -#define PDIDIS1_bit (*(volatile union un_pdidis1 *)0xF02B1).BIT -#define PDIDIS5 (*(volatile union un_pdidis5 *)0xF02B5).pdidis5 -#define PDIDIS5_bit (*(volatile union un_pdidis5 *)0xF02B5).BIT -#define PDIDIS7 (*(volatile union un_pdidis7 *)0xF02B7).pdidis7 -#define PDIDIS7_bit (*(volatile union un_pdidis7 *)0xF02B7).BIT -#define PDIDIS12 (*(volatile union un_pdidis12 *)0xF02BC).pdidis12 -#define PDIDIS12_bit (*(volatile union un_pdidis12 *)0xF02BC).BIT -#define PDIDIS13 (*(volatile union un_pdidis13 *)0xF02BD).pdidis13 -#define PDIDIS13_bit (*(volatile union un_pdidis13 *)0xF02BD).BIT -#define FLPMC (*(volatile unsigned char *)0xF02C0) -#define FLARS (*(volatile union un_flars *)0xF02C1).flars -#define FLARS_bit (*(volatile union un_flars *)0xF02C1).BIT -#define FLAPL (*(volatile unsigned short *)0xF02C2) -#define FLAPH (*(volatile unsigned char *)0xF02C4) -#define FSSQ (*(volatile union un_fssq *)0xF02C5).fssq -#define FSSQ_bit (*(volatile union un_fssq *)0xF02C5).BIT -#define FLSEDL (*(volatile unsigned short *)0xF02C6) -#define FLSEDH (*(volatile unsigned char *)0xF02C8) -#define FLRST (*(volatile union un_flrst *)0xF02C9).flrst -#define FLRST_bit (*(volatile union un_flrst *)0xF02C9).BIT -#define FSASTL (*(volatile union un_fsastl *)0xF02CA).fsastl -#define FSASTL_bit (*(volatile union un_fsastl *)0xF02CA).BIT -#define FSASTH (*(volatile union un_fsasth *)0xF02CB).fsasth -#define FSASTH_bit (*(volatile union un_fsasth *)0xF02CB).BIT -#define FLWL (*(volatile unsigned short *)0xF02CC) -#define FLWH (*(volatile unsigned short *)0xF02CE) -#define DTCBAR (*(volatile unsigned char *)0xF02E0) -#define DTCEN0 (*(volatile union un_dtcen0 *)0xF02E8).dtcen0 -#define DTCEN0_bit (*(volatile union un_dtcen0 *)0xF02E8).BIT -#define DTCEN1 (*(volatile union un_dtcen1 *)0xF02E9).dtcen1 -#define DTCEN1_bit (*(volatile union un_dtcen1 *)0xF02E9).BIT -#define DTCEN2 (*(volatile union un_dtcen2 *)0xF02EA).dtcen2 -#define DTCEN2_bit (*(volatile union un_dtcen2 *)0xF02EA).BIT -#define DTCEN3 (*(volatile union un_dtcen3 *)0xF02EB).dtcen3 -#define DTCEN3_bit (*(volatile union un_dtcen3 *)0xF02EB).BIT -#define DTCEN4 (*(volatile union un_dtcen4 *)0xF02EC).dtcen4 -#define DTCEN4_bit (*(volatile union un_dtcen4 *)0xF02EC).BIT -#define CRC0CTL (*(volatile union un_crc0ctl *)0xF02F0).crc0ctl -#define CRC0CTL_bit (*(volatile union un_crc0ctl *)0xF02F0).BIT -#define PGCRCL (*(volatile unsigned short *)0xF02F2) -#define CRCD (*(volatile unsigned short *)0xF02FA) -#define TXBA0 (*(volatile unsigned char *)0xF0300) -#define RXBA0 (*(volatile unsigned char *)0xF0301) -#define ASIMA00 (*(volatile union un_asima00 *)0xF0302).asima00 -#define ASIMA00_bit (*(volatile union un_asima00 *)0xF0302).BIT -#define ASIMA01 (*(volatile union un_asima01 *)0xF0303).asima01 -#define ASIMA01_bit (*(volatile union un_asima01 *)0xF0303).BIT -#define BRGCA0 (*(volatile unsigned char *)0xF0304) -#define ASISA0 (*(volatile unsigned char *)0xF0305) -#define ASCTA0 (*(volatile union un_ascta0 *)0xF0306).ascta0 -#define ASCTA0_bit (*(volatile union un_ascta0 *)0xF0306).BIT -#define UTA0CK (*(volatile union un_uta0ck *)0xF0310).uta0ck -#define UTA0CK_bit (*(volatile union un_uta0ck *)0xF0310).BIT -#define ITLCMP00 (*(volatile unsigned short *)0xF0360) -#define ITLCMP000 (*(volatile unsigned char *)0xF0360) -#define ITLCMP001 (*(volatile unsigned char *)0xF0361) -#define ITLCMP01 (*(volatile unsigned short *)0xF0362) -#define ITLCMP012 (*(volatile unsigned char *)0xF0362) -#define ITLCMP013 (*(volatile unsigned char *)0xF0363) -#define ITLCAP00 (*(volatile unsigned short *)0xF0364) -#define ITLCTL0 (*(volatile union un_itlctl0 *)0xF0366).itlctl0 -#define ITLCTL0_bit (*(volatile union un_itlctl0 *)0xF0366).BIT -#define ITLCSEL0 (*(volatile unsigned char *)0xF0367) -#define ITLFDIV00 (*(volatile unsigned char *)0xF0368) -#define ITLFDIV01 (*(volatile unsigned char *)0xF0369) -#define ITLCC0 (*(volatile union un_itlcc0 *)0xF036A).itlcc0 -#define ITLCC0_bit (*(volatile union un_itlcc0 *)0xF036A).BIT -#define ITLS0 (*(volatile unsigned char *)0xF036B) -#define ITLMKF0 (*(volatile unsigned char *)0xF036C) -#define SMSI0 (*(volatile unsigned short *)0xF0380) -#define SMSI1 (*(volatile unsigned short *)0xF0382) -#define SMSI2 (*(volatile unsigned short *)0xF0384) -#define SMSI3 (*(volatile unsigned short *)0xF0386) -#define SMSI4 (*(volatile unsigned short *)0xF0388) -#define SMSI5 (*(volatile unsigned short *)0xF038A) -#define SMSI6 (*(volatile unsigned short *)0xF038C) -#define SMSI7 (*(volatile unsigned short *)0xF038E) -#define SMSI8 (*(volatile unsigned short *)0xF0390) -#define SMSI9 (*(volatile unsigned short *)0xF0392) -#define SMSI10 (*(volatile unsigned short *)0xF0394) -#define SMSI11 (*(volatile unsigned short *)0xF0396) -#define SMSI12 (*(volatile unsigned short *)0xF0398) -#define SMSI13 (*(volatile unsigned short *)0xF039A) -#define SMSI14 (*(volatile unsigned short *)0xF039C) -#define SMSI15 (*(volatile unsigned short *)0xF039E) -#define SMSI16 (*(volatile unsigned short *)0xF03A0) -#define SMSI17 (*(volatile unsigned short *)0xF03A2) -#define SMSI18 (*(volatile unsigned short *)0xF03A4) -#define SMSI19 (*(volatile unsigned short *)0xF03A6) -#define SMSI20 (*(volatile unsigned short *)0xF03A8) -#define SMSI21 (*(volatile unsigned short *)0xF03AA) -#define SMSI22 (*(volatile unsigned short *)0xF03AC) -#define SMSI23 (*(volatile unsigned short *)0xF03AE) -#define SMSI24 (*(volatile unsigned short *)0xF03B0) -#define SMSI25 (*(volatile unsigned short *)0xF03B2) -#define SMSI26 (*(volatile unsigned short *)0xF03B4) -#define SMSI27 (*(volatile unsigned short *)0xF03B6) -#define SMSI28 (*(volatile unsigned short *)0xF03B8) -#define SMSI29 (*(volatile unsigned short *)0xF03BA) -#define SMSI30 (*(volatile unsigned short *)0xF03BC) -#define SMSI31 (*(volatile unsigned short *)0xF03BE) -#define SMSG0 (*(volatile unsigned short *)0xF03C0) -#define SMSG1 (*(volatile unsigned short *)0xF03C2) -#define SMSG2 (*(volatile unsigned short *)0xF03C4) -#define SMSG3 (*(volatile unsigned short *)0xF03C6) -#define SMSG4 (*(volatile unsigned short *)0xF03C8) -#define SMSG5 (*(volatile unsigned short *)0xF03CA) -#define SMSG6 (*(volatile unsigned short *)0xF03CC) -#define SMSG7 (*(volatile unsigned short *)0xF03CE) -#define SMSG8 (*(volatile unsigned short *)0xF03D0) -#define SMSG9 (*(volatile unsigned short *)0xF03D2) -#define SMSG10 (*(volatile unsigned short *)0xF03D4) -#define SMSG11 (*(volatile unsigned short *)0xF03D6) -#define SMSG12 (*(volatile unsigned short *)0xF03D8) -#define SMSG13 (*(volatile unsigned short *)0xF03DA) -#define SMSG14 (*(volatile unsigned short *)0xF03DC) -#define SMSG15 (*(volatile unsigned short *)0xF03DE) -#define SMSC (*(volatile union un_smsc *)0xF03E0).smsc -#define SMSC_bit (*(volatile union un_smsc *)0xF03E0).BIT -#define SMSS (*(volatile union un_smss *)0xF03E1).smss -#define SMSS_bit (*(volatile union un_smss *)0xF03E1).BIT -#define FLSIVC0 (*(volatile unsigned short *)0xF0480) -#define FLSIVC1 (*(volatile unsigned short *)0xF0482) -#define GFLASH0 (*(volatile unsigned short *)0xF0488) -#define GFLASH1 (*(volatile unsigned short *)0xF048A) -#define GFLASH2 (*(volatile unsigned short *)0xF048C) -#define GIAWCTL (*(volatile unsigned short *)0xF048E) -#define CTSUCRAL (*(volatile unsigned short *)0xF0500) -#define CTSUCR0 (*(volatile unsigned char *)0xF0500) -#define CTSUCR1 (*(volatile unsigned char *)0xF0501) -#define CTSUCRAH (*(volatile unsigned short *)0xF0502) -#define CTSUCR2 (*(volatile unsigned char *)0xF0502) -#define CTSUCR3 (*(volatile unsigned char *)0xF0503) -#define CTSUCRBL (*(volatile unsigned short *)0xF0504) -#define CTSUSDPRS (*(volatile unsigned char *)0xF0504) -#define CTSUSST (*(volatile unsigned char *)0xF0505) -#define CTSUCRBH (*(volatile unsigned short *)0xF0506) -#define CTSUDCLKC (*(volatile unsigned char *)0xF0507) -#define CTSUMCHL (*(volatile unsigned short *)0xF0508) -#define CTSUMCH0 (*(volatile unsigned char *)0xF0508) -#define CTSUMCH1 (*(volatile unsigned char *)0xF0509) -#define CTSUMCHH (*(volatile unsigned short *)0xF050A) -#define CTSUMFAF (*(volatile unsigned char *)0xF050A) -#define CTSUCHACAL (*(volatile unsigned short *)0xF050C) -#define CTSUCHAC0 (*(volatile unsigned char *)0xF050C) -#define CTSUCHAC1 (*(volatile unsigned char *)0xF050D) -#define CTSUCHACAH (*(volatile unsigned short *)0xF050E) -#define CTSUCHAC2 (*(volatile unsigned char *)0xF050E) -#define CTSUCHAC3 (*(volatile unsigned char *)0xF050F) -#define CTSUCHACBL (*(volatile unsigned short *)0xF0510) -#define CTSUCHAC4 (*(volatile unsigned char *)0xF0510) -#define CTSUCHAC5 (*(volatile unsigned char *)0xF0511) -#define CTSUCHACBH (*(volatile unsigned short *)0xF0512) -#define CTSUCHAC6 (*(volatile unsigned char *)0xF0512) -#define CTSUCHAC7 (*(volatile unsigned char *)0xF0513) -#define CTSUCHTRCAL (*(volatile unsigned short *)0xF0514) -#define CTSUCHTRC0 (*(volatile unsigned char *)0xF0514) -#define CTSUCHTRC1 (*(volatile unsigned char *)0xF0515) -#define CTSUCHTRCAH (*(volatile unsigned short *)0xF0516) -#define CTSUCHTRC2 (*(volatile unsigned char *)0xF0516) -#define CTSUCHTRC3 (*(volatile unsigned char *)0xF0517) -#define CTSUCHTRCBL (*(volatile unsigned short *)0xF0518) -#define CTSUCHTRC4 (*(volatile unsigned char *)0xF0518) -#define CTSUCHTRC5 (*(volatile unsigned char *)0xF0519) -#define CTSUCHTRCBH (*(volatile unsigned short *)0xF051A) -#define CTSUCHTRC6 (*(volatile unsigned char *)0xF051A) -#define CTSUCHTRC7 (*(volatile unsigned char *)0xF051B) -#define CTSUSRL (*(volatile unsigned short *)0xF051C) -#define CTSUST1 (*(volatile unsigned char *)0xF051C) -#define CTSUST (*(volatile unsigned char *)0xF051D) -#define CTSUSO0 (*(volatile unsigned short *)0xF0520) -#define CTSUSO1 (*(volatile unsigned short *)0xF0522) -#define CTSUSC (*(volatile unsigned short *)0xF0524) -#define CTSUUC (*(volatile unsigned short *)0xF0526) -#define CTSUDBGR0 (*(volatile unsigned short *)0xF0528) -#define CTSUDBGR1 (*(volatile unsigned short *)0xF052A) -#define CTSUSUCLK0 (*(volatile unsigned short *)0xF052C) -#define CTSUSUCLK1 (*(volatile unsigned short *)0xF052E) -#define CTSUSUCLK2 (*(volatile unsigned short *)0xF0530) -#define CTSUSUCLK3 (*(volatile unsigned short *)0xF0532) -#define TRNGSDR (*(volatile unsigned char *)0xF0540) -#define TRNGSCR0 (*(volatile union un_trngscr0 *)0xF0542).trngscr0 -#define TRNGSCR0_bit (*(volatile union un_trngscr0 *)0xF0542).BIT -#define CTSUTRIM0 (*(volatile unsigned short *)0xF0600) -#define RTRIM (*(volatile unsigned char *)0xF0600) -#define DACTRIM (*(volatile unsigned char *)0xF0601) -#define CTSUTRIM1 (*(volatile unsigned short *)0xF0602) -#define SUADJD (*(volatile unsigned char *)0xF0602) -#define TRESULT4 (*(volatile unsigned char *)0xF0603) -#define CTSUTRIM2 (*(volatile unsigned short *)0xF0604) -#define TRESULT0 (*(volatile unsigned char *)0xF0604) -#define TRESULT1 (*(volatile unsigned char *)0xF0605) -#define CTSUTRIM3 (*(volatile unsigned short *)0xF0606) -#define TRESULT2 (*(volatile unsigned char *)0xF0606) -#define TRESULT3 (*(volatile unsigned char *)0xF0607) - -/* - Sfr bits - */ -#define ADTYP ADM2_bit.no0 -#define AWC ADM2_bit.no2 -#define ADRCK ADM2_bit.no3 -#define ULBS0 ULBS_bit.no0 -#define ULBS1 ULBS_bit.no1 -#define ULBS2 ULBS_bit.no2 -#define ULBS4 ULBS_bit.no4 -#define DFLEN DFLCTL_bit.no0 -#define MODE0 FLMODE_bit.no6 -#define MODE1 FLMODE_bit.no7 -#define FLMWEN FLMWRP_bit.no0 -#define ESQST FSSE_bit.no7 -#define TAU0EN PER0_bit.no0 -#define SAU0EN PER0_bit.no2 -#define SAU1EN PER0_bit.no3 -#define IICA0EN PER0_bit.no4 -#define ADCEN PER0_bit.no5 -#define RTCWEN PER0_bit.no7 -#define TAU0RES PRR0_bit.no0 -#define SAU0RES PRR0_bit.no2 -#define SAU1RES PRR0_bit.no3 -#define IICA0RES PRR0_bit.no4 -#define ADCRES PRR0_bit.no5 -#define HIPREC OSMC_bit.no0 -#define WUTMMCK0 OSMC_bit.no4 -#define RTCLPC OSMC_bit.no7 -#define RPEF RPECTL_bit.no0 -#define RPERDIS RPECTL_bit.no7 -#define PORF PORSR_bit.no0 -#define CTSUEN PER1_bit.no0 -#define UTAEN PER1_bit.no2 -#define DTCEN PER1_bit.no3 -#define TML32EN PER1_bit.no4 -#define SMSEN PER1_bit.no6 -#define CTSURES PRR1_bit.no0 -#define TML32RES PRR1_bit.no4 -#define SMSRES PRR1_bit.no6 -#define FWKUP WKUPMD_bit.no0 -#define DLVD0FCLR LVDFCLR_bit.no2 -#define DLVD1FCLR LVDFCLR_bit.no3 -#define RTC128EN RTCC0_bit.no4 -#define RCLOE1 RTCC0_bit.no5 -#define RTCE RTCC0_bit.no7 -#define RWAIT RTCC1_bit.no0 -#define RWST RTCC1_bit.no1 -#define RIFG RTCC1_bit.no3 -#define WAFG RTCC1_bit.no4 -#define WALIE RTCC1_bit.no6 -#define WALE RTCC1_bit.no7 -#define SPT0 IICCTL00_bit.no0 -#define STT0 IICCTL00_bit.no1 -#define ACKE0 IICCTL00_bit.no2 -#define WTIM0 IICCTL00_bit.no3 -#define SPIE0 IICCTL00_bit.no4 -#define WREL0 IICCTL00_bit.no5 -#define LREL0 IICCTL00_bit.no6 -#define IICE0 IICCTL00_bit.no7 -#define PRS0 IICCTL01_bit.no0 -#define DFC0 IICCTL01_bit.no2 -#define SMC0 IICCTL01_bit.no3 -#define DAD0 IICCTL01_bit.no4 -#define CLD0 IICCTL01_bit.no5 -#define SVADIS0 IICCTL01_bit.no6 -#define WUP0 IICCTL01_bit.no7 -#define FSSTP FSSQ_bit.no6 -#define SQST FSSQ_bit.no7 -#define CRC0EN CRC0CTL_bit.no7 -#define ISRMA0 ASIMA00_bit.no0 -#define ISSMA0 ASIMA00_bit.no1 -#define RXEA0 ASIMA00_bit.no5 -#define TXEA0 ASIMA00_bit.no6 -#define UARTAEN0 ASIMA00_bit.no7 -#define OVECTA0 ASCTA0_bit.no0 -#define FECTA0 ASCTA0_bit.no1 -#define PECTA0 ASCTA0_bit.no2 -#define ITLEN00 ITLCTL0_bit.no0 -#define ITLEN01 ITLCTL0_bit.no1 -#define ITLEN02 ITLCTL0_bit.no2 -#define ITLEN03 ITLCTL0_bit.no3 -#define CAPR0 ITLCC0_bit.no4 -#define CAPF0CR ITLCC0_bit.no6 -#define LONGWAIT SMSC_bit.no4 -#define SMSTRGWAIT SMSC_bit.no5 -#define SMSSTOP SMSC_bit.no6 -#define SMSSTART SMSC_bit.no7 -#define SMSSTAT SMSS_bit.no7 -#define TRNGST TRNGSCR0_bit.no2 -#define TRNGEN TRNGSCR0_bit.no3 -#define TRNGRDY TRNGSCR0_bit.no7 - -/* - Interrupt vector addresses - */ -#endif +/************************************************************************/ +/* Header file generated from device file: */ +/* DR7F102GGE.DVF */ +/* E1.00b (2022/06/16) */ +/* Copyright(C) 2022 Renesas */ +/* Tool Version: 4.0.11 */ +/* Date Generated: 2022/07/25 */ +/************************************************************************/ + +#ifndef __INTRINSIC_FUNCTIONS +#define __INTRINSIC_FUNCTIONS + +#define DI() asm("di") +#define EI() asm("ei") +#define HALT() asm("halt") +#define NOP() asm("nop") +#define STOP() asm("stop") + +#endif + +#ifndef __IOREG_BIT_STRUCTURES +#define __IOREG_BIT_STRUCTURES +typedef struct { + unsigned char no0 :1; + unsigned char no1 :1; + unsigned char no2 :1; + unsigned char no3 :1; + unsigned char no4 :1; + unsigned char no5 :1; + unsigned char no6 :1; + unsigned char no7 :1; +} __BITS8; + +typedef struct { + unsigned short no0 :1; + unsigned short no1 :1; + unsigned short no2 :1; + unsigned short no3 :1; + unsigned short no4 :1; + unsigned short no5 :1; + unsigned short no6 :1; + unsigned short no7 :1; + unsigned short no8 :1; + unsigned short no9 :1; + unsigned short no10 :1; + unsigned short no11 :1; + unsigned short no12 :1; + unsigned short no13 :1; + unsigned short no14 :1; + unsigned short no15 :1; +} __BITS16; + +#endif + +#ifndef IODEFINE_EXT_H +#define IODEFINE_EXT_H + +/* + IO Registers + */ +union un_adm2 { + unsigned char adm2; + __BITS8 BIT; +}; +union un_pu0 { + unsigned char pu0; + __BITS8 BIT; +}; +union un_pu1 { + unsigned char pu1; + __BITS8 BIT; +}; +union un_pu3 { + unsigned char pu3; + __BITS8 BIT; +}; +union un_pu4 { + unsigned char pu4; + __BITS8 BIT; +}; +union un_pu5 { + unsigned char pu5; + __BITS8 BIT; +}; +union un_pu7 { + unsigned char pu7; + __BITS8 BIT; +}; +union un_pu12 { + unsigned char pu12; + __BITS8 BIT; +}; +union un_pu14 { + unsigned char pu14; + __BITS8 BIT; +}; +union un_pim0 { + unsigned char pim0; + __BITS8 BIT; +}; +union un_pim1 { + unsigned char pim1; + __BITS8 BIT; +}; +union un_pim4 { + unsigned char pim4; + __BITS8 BIT; +}; +union un_pim7 { + unsigned char pim7; + __BITS8 BIT; +}; +union un_pom0 { + unsigned char pom0; + __BITS8 BIT; +}; +union un_pom1 { + unsigned char pom1; + __BITS8 BIT; +}; +union un_pom5 { + unsigned char pom5; + __BITS8 BIT; +}; +union un_pom7 { + unsigned char pom7; + __BITS8 BIT; +}; +union un_pom12 { + unsigned char pom12; + __BITS8 BIT; +}; +union un_pmca0 { + unsigned char pmca0; + __BITS8 BIT; +}; +union un_pmca2 { + unsigned char pmca2; + __BITS8 BIT; +}; +union un_pmca12 { + unsigned char pmca12; + __BITS8 BIT; +}; +union un_pmca14 { + unsigned char pmca14; + __BITS8 BIT; +}; +union un_nfen0 { + unsigned char nfen0; + __BITS8 BIT; +}; +union un_nfen1 { + unsigned char nfen1; + __BITS8 BIT; +}; +union un_isc { + unsigned char isc; + __BITS8 BIT; +}; +union un_ulbs { + unsigned char ulbs; + __BITS8 BIT; +}; +union un_pms { + unsigned char pms; + __BITS8 BIT; +}; +union un_dflctl { + unsigned char dflctl; + __BITS8 BIT; +}; +union un_flmode { + unsigned char flmode; + __BITS8 BIT; +}; +union un_flmwrp { + unsigned char flmwrp; + __BITS8 BIT; +}; +union un_fsse { + unsigned char fsse; + __BITS8 BIT; +}; +union un_pfs { + unsigned char pfs; + __BITS8 BIT; +}; +union un_per0 { + unsigned char per0; + __BITS8 BIT; +}; +union un_prr0 { + unsigned char prr0; + __BITS8 BIT; +}; +union un_osmc { + unsigned char osmc; + __BITS8 BIT; +}; +union un_rpectl { + unsigned char rpectl; + __BITS8 BIT; +}; +union un_porsr { + unsigned char porsr; + __BITS8 BIT; +}; +union un_per1 { + unsigned char per1; + __BITS8 BIT; +}; +union un_prr1 { + unsigned char prr1; + __BITS8 BIT; +}; +union un_se0l { + unsigned char se0l; + __BITS8 BIT; +}; +union un_ss0l { + unsigned char ss0l; + __BITS8 BIT; +}; +union un_st0l { + unsigned char st0l; + __BITS8 BIT; +}; +union un_soe0l { + unsigned char soe0l; + __BITS8 BIT; +}; +union un_se1l { + unsigned char se1l; + __BITS8 BIT; +}; +union un_ss1l { + unsigned char ss1l; + __BITS8 BIT; +}; +union un_st1l { + unsigned char st1l; + __BITS8 BIT; +}; +union un_soe1l { + unsigned char soe1l; + __BITS8 BIT; +}; +union un_te0l { + unsigned char te0l; + __BITS8 BIT; +}; +union un_ts0l { + unsigned char ts0l; + __BITS8 BIT; +}; +union un_tt0l { + unsigned char tt0l; + __BITS8 BIT; +}; +union un_toe0l { + unsigned char toe0l; + __BITS8 BIT; +}; +union un_wkupmd { + unsigned char wkupmd; + __BITS8 BIT; +}; +union un_lvdfclr { + unsigned char lvdfclr; + __BITS8 BIT; +}; +union un_rtcc0 { + unsigned char rtcc0; + __BITS8 BIT; +}; +union un_rtcc1 { + unsigned char rtcc1; + __BITS8 BIT; +}; +union un_iicctl00 { + unsigned char iicctl00; + __BITS8 BIT; +}; +union un_iicctl01 { + unsigned char iicctl01; + __BITS8 BIT; +}; +union un_pmct0 { + unsigned char pmct0; + __BITS8 BIT; +}; +union un_pmct1 { + unsigned char pmct1; + __BITS8 BIT; +}; +union un_pmct2 { + unsigned char pmct2; + __BITS8 BIT; +}; +union un_pmct3 { + unsigned char pmct3; + __BITS8 BIT; +}; +union un_pmct5 { + unsigned char pmct5; + __BITS8 BIT; +}; +union un_pmct7 { + unsigned char pmct7; + __BITS8 BIT; +}; +union un_pmct13 { + unsigned char pmct13; + __BITS8 BIT; +}; +union un_pmct14 { + unsigned char pmct14; + __BITS8 BIT; +}; +union un_pfoe1 { + unsigned char pfoe1; + __BITS8 BIT; +}; +union un_pdidis0 { + unsigned char pdidis0; + __BITS8 BIT; +}; +union un_pdidis1 { + unsigned char pdidis1; + __BITS8 BIT; +}; +union un_pdidis5 { + unsigned char pdidis5; + __BITS8 BIT; +}; +union un_pdidis7 { + unsigned char pdidis7; + __BITS8 BIT; +}; +union un_pdidis12 { + unsigned char pdidis12; + __BITS8 BIT; +}; +union un_pdidis13 { + unsigned char pdidis13; + __BITS8 BIT; +}; +union un_flars { + unsigned char flars; + __BITS8 BIT; +}; +union un_fssq { + unsigned char fssq; + __BITS8 BIT; +}; +union un_flrst { + unsigned char flrst; + __BITS8 BIT; +}; +union un_fsastl { + unsigned char fsastl; + __BITS8 BIT; +}; +union un_fsasth { + unsigned char fsasth; + __BITS8 BIT; +}; +union un_dtcen0 { + unsigned char dtcen0; + __BITS8 BIT; +}; +union un_dtcen1 { + unsigned char dtcen1; + __BITS8 BIT; +}; +union un_dtcen2 { + unsigned char dtcen2; + __BITS8 BIT; +}; +union un_dtcen3 { + unsigned char dtcen3; + __BITS8 BIT; +}; +union un_dtcen4 { + unsigned char dtcen4; + __BITS8 BIT; +}; +union un_crc0ctl { + unsigned char crc0ctl; + __BITS8 BIT; +}; +union un_asima00 { + unsigned char asima00; + __BITS8 BIT; +}; +union un_asima01 { + unsigned char asima01; + __BITS8 BIT; +}; +union un_ascta0 { + unsigned char ascta0; + __BITS8 BIT; +}; +union un_uta0ck { + unsigned char uta0ck; + __BITS8 BIT; +}; +union un_itlctl0 { + unsigned char itlctl0; + __BITS8 BIT; +}; +union un_itlcc0 { + unsigned char itlcc0; + __BITS8 BIT; +}; +union un_smsc { + unsigned char smsc; + __BITS8 BIT; +}; +union un_smss { + unsigned char smss; + __BITS8 BIT; +}; +union un_trngscr0 { + unsigned char trngscr0; + __BITS8 BIT; +}; + +#define ADM2 (*(volatile union un_adm2 *)0xF0010).adm2 +#define ADM2_bit (*(volatile union un_adm2 *)0xF0010).BIT +#define ADUL (*(volatile unsigned char *)0xF0011) +#define ADLL (*(volatile unsigned char *)0xF0012) +#define ADTES (*(volatile unsigned char *)0xF0013) +#define PU0 (*(volatile union un_pu0 *)0xF0030).pu0 +#define PU0_bit (*(volatile union un_pu0 *)0xF0030).BIT +#define PU1 (*(volatile union un_pu1 *)0xF0031).pu1 +#define PU1_bit (*(volatile union un_pu1 *)0xF0031).BIT +#define PU3 (*(volatile union un_pu3 *)0xF0033).pu3 +#define PU3_bit (*(volatile union un_pu3 *)0xF0033).BIT +#define PU4 (*(volatile union un_pu4 *)0xF0034).pu4 +#define PU4_bit (*(volatile union un_pu4 *)0xF0034).BIT +#define PU5 (*(volatile union un_pu5 *)0xF0035).pu5 +#define PU5_bit (*(volatile union un_pu5 *)0xF0035).BIT +#define PU7 (*(volatile union un_pu7 *)0xF0037).pu7 +#define PU7_bit (*(volatile union un_pu7 *)0xF0037).BIT +#define PU12 (*(volatile union un_pu12 *)0xF003C).pu12 +#define PU12_bit (*(volatile union un_pu12 *)0xF003C).BIT +#define PU14 (*(volatile union un_pu14 *)0xF003E).pu14 +#define PU14_bit (*(volatile union un_pu14 *)0xF003E).BIT +#define PIM0 (*(volatile union un_pim0 *)0xF0040).pim0 +#define PIM0_bit (*(volatile union un_pim0 *)0xF0040).BIT +#define PIM1 (*(volatile union un_pim1 *)0xF0041).pim1 +#define PIM1_bit (*(volatile union un_pim1 *)0xF0041).BIT +#define PIM4 (*(volatile union un_pim4 *)0xF0044).pim4 +#define PIM4_bit (*(volatile union un_pim4 *)0xF0044).BIT +#define PIM7 (*(volatile union un_pim7 *)0xF0047).pim7 +#define PIM7_bit (*(volatile union un_pim7 *)0xF0047).BIT +#define POM0 (*(volatile union un_pom0 *)0xF0050).pom0 +#define POM0_bit (*(volatile union un_pom0 *)0xF0050).BIT +#define POM1 (*(volatile union un_pom1 *)0xF0051).pom1 +#define POM1_bit (*(volatile union un_pom1 *)0xF0051).BIT +#define POM5 (*(volatile union un_pom5 *)0xF0055).pom5 +#define POM5_bit (*(volatile union un_pom5 *)0xF0055).BIT +#define POM7 (*(volatile union un_pom7 *)0xF0057).pom7 +#define POM7_bit (*(volatile union un_pom7 *)0xF0057).BIT +#define POM12 (*(volatile union un_pom12 *)0xF005C).pom12 +#define POM12_bit (*(volatile union un_pom12 *)0xF005C).BIT +#define PMCA0 (*(volatile union un_pmca0 *)0xF0060).pmca0 +#define PMCA0_bit (*(volatile union un_pmca0 *)0xF0060).BIT +#define PMCA2 (*(volatile union un_pmca2 *)0xF0062).pmca2 +#define PMCA2_bit (*(volatile union un_pmca2 *)0xF0062).BIT +#define PMCA12 (*(volatile union un_pmca12 *)0xF006C).pmca12 +#define PMCA12_bit (*(volatile union un_pmca12 *)0xF006C).BIT +#define PMCA14 (*(volatile union un_pmca14 *)0xF006E).pmca14 +#define PMCA14_bit (*(volatile union un_pmca14 *)0xF006E).BIT +#define NFEN0 (*(volatile union un_nfen0 *)0xF0070).nfen0 +#define NFEN0_bit (*(volatile union un_nfen0 *)0xF0070).BIT +#define NFEN1 (*(volatile union un_nfen1 *)0xF0071).nfen1 +#define NFEN1_bit (*(volatile union un_nfen1 *)0xF0071).BIT +#define ISC (*(volatile union un_isc *)0xF0073).isc +#define ISC_bit (*(volatile union un_isc *)0xF0073).BIT +#define TIS0 (*(volatile unsigned char *)0xF0074) +#define TIS1 (*(volatile unsigned char *)0xF0075) +#define PIOR (*(volatile unsigned char *)0xF0077) +#define IAWCTL (*(volatile unsigned char *)0xF0078) +#define ULBS (*(volatile union un_ulbs *)0xF0079).ulbs +#define ULBS_bit (*(volatile union un_ulbs *)0xF0079).BIT +#define PMS (*(volatile union un_pms *)0xF007B).pms +#define PMS_bit (*(volatile union un_pms *)0xF007B).BIT +#define DFLCTL (*(volatile union un_dflctl *)0xF0090).dflctl +#define DFLCTL_bit (*(volatile union un_dflctl *)0xF0090).BIT +#define HIOTRM (*(volatile unsigned char *)0xF00A0) +#define HOCODIV (*(volatile unsigned char *)0xF00A8) +#define FLMODE (*(volatile union un_flmode *)0xF00AA).flmode +#define FLMODE_bit (*(volatile union un_flmode *)0xF00AA).BIT +#define FLMWRP (*(volatile union un_flmwrp *)0xF00AB).flmwrp +#define FLMWRP_bit (*(volatile union un_flmwrp *)0xF00AB).BIT +#define FLSEC (*(volatile unsigned short *)0xF00B0) +#define FLFSWS (*(volatile unsigned short *)0xF00B2) +#define FLFSWE (*(volatile unsigned short *)0xF00B4) +#define FSSET (*(volatile unsigned char *)0xF00B6) +#define FSSE (*(volatile union un_fsse *)0xF00B7).fsse +#define FSSE_bit (*(volatile union un_fsse *)0xF00B7).BIT +#define PFCMD (*(volatile unsigned char *)0xF00C0) +#define PFS (*(volatile union un_pfs *)0xF00C1).pfs +#define PFS_bit (*(volatile union un_pfs *)0xF00C1).BIT +#define PER0 (*(volatile union un_per0 *)0xF00F0).per0 +#define PER0_bit (*(volatile union un_per0 *)0xF00F0).BIT +#define PRR0 (*(volatile union un_prr0 *)0xF00F1).prr0 +#define PRR0_bit (*(volatile union un_prr0 *)0xF00F1).BIT +#define MOCODIV (*(volatile unsigned char *)0xF00F2) +#define OSMC (*(volatile union un_osmc *)0xF00F3).osmc +#define OSMC_bit (*(volatile union un_osmc *)0xF00F3).BIT +#define RPECTL (*(volatile union un_rpectl *)0xF00F5).rpectl +#define RPECTL_bit (*(volatile union un_rpectl *)0xF00F5).BIT +#define PORSR (*(volatile union un_porsr *)0xF00F9).porsr +#define PORSR_bit (*(volatile union un_porsr *)0xF00F9).BIT +#define PER1 (*(volatile union un_per1 *)0xF00FA).per1 +#define PER1_bit (*(volatile union un_per1 *)0xF00FA).BIT +#define PRR1 (*(volatile union un_prr1 *)0xF00FB).prr1 +#define PRR1_bit (*(volatile union un_prr1 *)0xF00FB).BIT +#define BCDADJ (*(volatile unsigned char *)0xF00FE) +#define VECTCTRL (*(volatile unsigned char *)0xF00FF) +#define SSR00 (*(volatile unsigned short *)0xF0100) +#define SSR00L (*(volatile unsigned char *)0xF0100) +#define SSR01 (*(volatile unsigned short *)0xF0102) +#define SSR01L (*(volatile unsigned char *)0xF0102) +#define SSR02 (*(volatile unsigned short *)0xF0104) +#define SSR02L (*(volatile unsigned char *)0xF0104) +#define SSR03 (*(volatile unsigned short *)0xF0106) +#define SSR03L (*(volatile unsigned char *)0xF0106) +#define SIR00 (*(volatile unsigned short *)0xF0108) +#define SIR00L (*(volatile unsigned char *)0xF0108) +#define SIR01 (*(volatile unsigned short *)0xF010A) +#define SIR01L (*(volatile unsigned char *)0xF010A) +#define SIR02 (*(volatile unsigned short *)0xF010C) +#define SIR02L (*(volatile unsigned char *)0xF010C) +#define SIR03 (*(volatile unsigned short *)0xF010E) +#define SIR03L (*(volatile unsigned char *)0xF010E) +#define SMR00 (*(volatile unsigned short *)0xF0110) +#define SMR01 (*(volatile unsigned short *)0xF0112) +#define SMR02 (*(volatile unsigned short *)0xF0114) +#define SMR03 (*(volatile unsigned short *)0xF0116) +#define SCR00 (*(volatile unsigned short *)0xF0118) +#define SCR01 (*(volatile unsigned short *)0xF011A) +#define SCR02 (*(volatile unsigned short *)0xF011C) +#define SCR03 (*(volatile unsigned short *)0xF011E) +#define SE0 (*(volatile unsigned short *)0xF0120) +#define SE0L (*(volatile union un_se0l *)0xF0120).se0l +#define SE0L_bit (*(volatile union un_se0l *)0xF0120).BIT +#define SS0 (*(volatile unsigned short *)0xF0122) +#define SS0L (*(volatile union un_ss0l *)0xF0122).ss0l +#define SS0L_bit (*(volatile union un_ss0l *)0xF0122).BIT +#define ST0 (*(volatile unsigned short *)0xF0124) +#define ST0L (*(volatile union un_st0l *)0xF0124).st0l +#define ST0L_bit (*(volatile union un_st0l *)0xF0124).BIT +#define SPS0 (*(volatile unsigned short *)0xF0126) +#define SPS0L (*(volatile unsigned char *)0xF0126) +#define SO0 (*(volatile unsigned short *)0xF0128) +#define SOE0 (*(volatile unsigned short *)0xF012A) +#define SOE0L (*(volatile union un_soe0l *)0xF012A).soe0l +#define SOE0L_bit (*(volatile union un_soe0l *)0xF012A).BIT +#define SOL0 (*(volatile unsigned short *)0xF0134) +#define SOL0L (*(volatile unsigned char *)0xF0134) +#define SSC0 (*(volatile unsigned short *)0xF0138) +#define SSC0L (*(volatile unsigned char *)0xF0138) +#define SSR10 (*(volatile unsigned short *)0xF0140) +#define SSR10L (*(volatile unsigned char *)0xF0140) +#define SSR11 (*(volatile unsigned short *)0xF0142) +#define SSR11L (*(volatile unsigned char *)0xF0142) +#define SIR10 (*(volatile unsigned short *)0xF0148) +#define SIR10L (*(volatile unsigned char *)0xF0148) +#define SIR11 (*(volatile unsigned short *)0xF014A) +#define SIR11L (*(volatile unsigned char *)0xF014A) +#define SMR10 (*(volatile unsigned short *)0xF0150) +#define SMR11 (*(volatile unsigned short *)0xF0152) +#define SCR10 (*(volatile unsigned short *)0xF0158) +#define SCR11 (*(volatile unsigned short *)0xF015A) +#define SE1 (*(volatile unsigned short *)0xF0160) +#define SE1L (*(volatile union un_se1l *)0xF0160).se1l +#define SE1L_bit (*(volatile union un_se1l *)0xF0160).BIT +#define SS1 (*(volatile unsigned short *)0xF0162) +#define SS1L (*(volatile union un_ss1l *)0xF0162).ss1l +#define SS1L_bit (*(volatile union un_ss1l *)0xF0162).BIT +#define ST1 (*(volatile unsigned short *)0xF0164) +#define ST1L (*(volatile union un_st1l *)0xF0164).st1l +#define ST1L_bit (*(volatile union un_st1l *)0xF0164).BIT +#define SPS1 (*(volatile unsigned short *)0xF0166) +#define SPS1L (*(volatile unsigned char *)0xF0166) +#define SO1 (*(volatile unsigned short *)0xF0168) +#define SOE1 (*(volatile unsigned short *)0xF016A) +#define SOE1L (*(volatile union un_soe1l *)0xF016A).soe1l +#define SOE1L_bit (*(volatile union un_soe1l *)0xF016A).BIT +#define SOL1 (*(volatile unsigned short *)0xF0174) +#define SOL1L (*(volatile unsigned char *)0xF0174) +#define TCR00 (*(volatile unsigned short *)0xF0180) +#define TCR01 (*(volatile unsigned short *)0xF0182) +#define TCR02 (*(volatile unsigned short *)0xF0184) +#define TCR03 (*(volatile unsigned short *)0xF0186) +#define TCR04 (*(volatile unsigned short *)0xF0188) +#define TCR05 (*(volatile unsigned short *)0xF018A) +#define TCR06 (*(volatile unsigned short *)0xF018C) +#define TCR07 (*(volatile unsigned short *)0xF018E) +#define TMR00 (*(volatile unsigned short *)0xF0190) +#define TMR01 (*(volatile unsigned short *)0xF0192) +#define TMR02 (*(volatile unsigned short *)0xF0194) +#define TMR03 (*(volatile unsigned short *)0xF0196) +#define TMR04 (*(volatile unsigned short *)0xF0198) +#define TMR05 (*(volatile unsigned short *)0xF019A) +#define TMR06 (*(volatile unsigned short *)0xF019C) +#define TMR07 (*(volatile unsigned short *)0xF019E) +#define TSR00 (*(volatile unsigned short *)0xF01A0) +#define TSR00L (*(volatile unsigned char *)0xF01A0) +#define TSR01 (*(volatile unsigned short *)0xF01A2) +#define TSR01L (*(volatile unsigned char *)0xF01A2) +#define TSR02 (*(volatile unsigned short *)0xF01A4) +#define TSR02L (*(volatile unsigned char *)0xF01A4) +#define TSR03 (*(volatile unsigned short *)0xF01A6) +#define TSR03L (*(volatile unsigned char *)0xF01A6) +#define TSR04 (*(volatile unsigned short *)0xF01A8) +#define TSR04L (*(volatile unsigned char *)0xF01A8) +#define TSR05 (*(volatile unsigned short *)0xF01AA) +#define TSR05L (*(volatile unsigned char *)0xF01AA) +#define TSR06 (*(volatile unsigned short *)0xF01AC) +#define TSR06L (*(volatile unsigned char *)0xF01AC) +#define TSR07 (*(volatile unsigned short *)0xF01AE) +#define TSR07L (*(volatile unsigned char *)0xF01AE) +#define TE0 (*(volatile unsigned short *)0xF01B0) +#define TE0L (*(volatile union un_te0l *)0xF01B0).te0l +#define TE0L_bit (*(volatile union un_te0l *)0xF01B0).BIT +#define TS0 (*(volatile unsigned short *)0xF01B2) +#define TS0L (*(volatile union un_ts0l *)0xF01B2).ts0l +#define TS0L_bit (*(volatile union un_ts0l *)0xF01B2).BIT +#define TT0 (*(volatile unsigned short *)0xF01B4) +#define TT0L (*(volatile union un_tt0l *)0xF01B4).tt0l +#define TT0L_bit (*(volatile union un_tt0l *)0xF01B4).BIT +#define TPS0 (*(volatile unsigned short *)0xF01B6) +#define TO0 (*(volatile unsigned short *)0xF01B8) +#define TO0L (*(volatile unsigned char *)0xF01B8) +#define TOE0 (*(volatile unsigned short *)0xF01BA) +#define TOE0L (*(volatile union un_toe0l *)0xF01BA).toe0l +#define TOE0L_bit (*(volatile union un_toe0l *)0xF01BA).BIT +#define TOL0 (*(volatile unsigned short *)0xF01BC) +#define TOL0L (*(volatile unsigned char *)0xF01BC) +#define TOM0 (*(volatile unsigned short *)0xF01BE) +#define TOM0L (*(volatile unsigned char *)0xF01BE) +#define MIOTRM (*(volatile unsigned char *)0xF0212) +#define LIOTRM (*(volatile unsigned char *)0xF0213) +#define MOSCDIV (*(volatile unsigned char *)0xF0214) +#define WKUPMD (*(volatile union un_wkupmd *)0xF0215).wkupmd +#define WKUPMD_bit (*(volatile union un_wkupmd *)0xF0215).BIT +#define LVDFCLR (*(volatile union un_lvdfclr *)0xF0218).lvdfclr +#define LVDFCLR_bit (*(volatile union un_lvdfclr *)0xF0218).BIT +#define SEC (*(volatile unsigned char *)0xF0220) +#define MIN (*(volatile unsigned char *)0xF0221) +#define HOUR (*(volatile unsigned char *)0xF0222) +#define WEEK (*(volatile unsigned char *)0xF0223) +#define DAY (*(volatile unsigned char *)0xF0224) +#define MONTH (*(volatile unsigned char *)0xF0225) +#define YEAR (*(volatile unsigned char *)0xF0226) +#define SUBCUD (*(volatile unsigned char *)0xF0227) +#define ALARMWM (*(volatile unsigned char *)0xF0228) +#define ALARMWH (*(volatile unsigned char *)0xF0229) +#define ALARMWW (*(volatile unsigned char *)0xF022A) +#define RTCC0 (*(volatile union un_rtcc0 *)0xF022B).rtcc0 +#define RTCC0_bit (*(volatile union un_rtcc0 *)0xF022B).BIT +#define RTCC1 (*(volatile union un_rtcc1 *)0xF022C).rtcc1 +#define RTCC1_bit (*(volatile union un_rtcc1 *)0xF022C).BIT +#define IICCTL00 (*(volatile union un_iicctl00 *)0xF0230).iicctl00 +#define IICCTL00_bit (*(volatile union un_iicctl00 *)0xF0230).BIT +#define IICCTL01 (*(volatile union un_iicctl01 *)0xF0231).iicctl01 +#define IICCTL01_bit (*(volatile union un_iicctl01 *)0xF0231).BIT +#define IICWL0 (*(volatile unsigned char *)0xF0232) +#define IICWH0 (*(volatile unsigned char *)0xF0233) +#define SVA0 (*(volatile unsigned char *)0xF0234) +#define ELSELR00 (*(volatile unsigned char *)0xF0240) +#define ELSELR01 (*(volatile unsigned char *)0xF0241) +#define ELSELR02 (*(volatile unsigned char *)0xF0242) +#define ELSELR03 (*(volatile unsigned char *)0xF0243) +#define ELSELR04 (*(volatile unsigned char *)0xF0244) +#define ELSELR05 (*(volatile unsigned char *)0xF0245) +#define ELSELR06 (*(volatile unsigned char *)0xF0246) +#define ELSELR07 (*(volatile unsigned char *)0xF0247) +#define ELSELR08 (*(volatile unsigned char *)0xF0248) +#define ELSELR10 (*(volatile unsigned char *)0xF024A) +#define ELSELR11 (*(volatile unsigned char *)0xF024B) +#define ELSELR12 (*(volatile unsigned char *)0xF024C) +#define ELSELR13 (*(volatile unsigned char *)0xF024D) +#define ELSELR14 (*(volatile unsigned char *)0xF024E) +#define ELSELR15 (*(volatile unsigned char *)0xF024F) +#define ELSELR16 (*(volatile unsigned char *)0xF0250) +#define ELSELR17 (*(volatile unsigned char *)0xF0251) +#define ELSELR18 (*(volatile unsigned char *)0xF0252) +#define ELSELR19 (*(volatile unsigned char *)0xF0253) +#define PMCT0 (*(volatile union un_pmct0 *)0xF0260).pmct0 +#define PMCT0_bit (*(volatile union un_pmct0 *)0xF0260).BIT +#define PMCT1 (*(volatile union un_pmct1 *)0xF0261).pmct1 +#define PMCT1_bit (*(volatile union un_pmct1 *)0xF0261).BIT +#define PMCT2 (*(volatile union un_pmct2 *)0xF0262).pmct2 +#define PMCT2_bit (*(volatile union un_pmct2 *)0xF0262).BIT +#define PMCT3 (*(volatile union un_pmct3 *)0xF0263).pmct3 +#define PMCT3_bit (*(volatile union un_pmct3 *)0xF0263).BIT +#define PMCT5 (*(volatile union un_pmct5 *)0xF0265).pmct5 +#define PMCT5_bit (*(volatile union un_pmct5 *)0xF0265).BIT +#define PMCT7 (*(volatile union un_pmct7 *)0xF0267).pmct7 +#define PMCT7_bit (*(volatile union un_pmct7 *)0xF0267).BIT +#define PMCT13 (*(volatile union un_pmct13 *)0xF026D).pmct13 +#define PMCT13_bit (*(volatile union un_pmct13 *)0xF026D).BIT +#define PMCT14 (*(volatile union un_pmct14 *)0xF026E).pmct14 +#define PMCT14_bit (*(volatile union un_pmct14 *)0xF026E).BIT +#define PFOE1 (*(volatile union un_pfoe1 *)0xF02AB).pfoe1 +#define PFOE1_bit (*(volatile union un_pfoe1 *)0xF02AB).BIT +#define PDIDIS0 (*(volatile union un_pdidis0 *)0xF02B0).pdidis0 +#define PDIDIS0_bit (*(volatile union un_pdidis0 *)0xF02B0).BIT +#define PDIDIS1 (*(volatile union un_pdidis1 *)0xF02B1).pdidis1 +#define PDIDIS1_bit (*(volatile union un_pdidis1 *)0xF02B1).BIT +#define PDIDIS5 (*(volatile union un_pdidis5 *)0xF02B5).pdidis5 +#define PDIDIS5_bit (*(volatile union un_pdidis5 *)0xF02B5).BIT +#define PDIDIS7 (*(volatile union un_pdidis7 *)0xF02B7).pdidis7 +#define PDIDIS7_bit (*(volatile union un_pdidis7 *)0xF02B7).BIT +#define PDIDIS12 (*(volatile union un_pdidis12 *)0xF02BC).pdidis12 +#define PDIDIS12_bit (*(volatile union un_pdidis12 *)0xF02BC).BIT +#define PDIDIS13 (*(volatile union un_pdidis13 *)0xF02BD).pdidis13 +#define PDIDIS13_bit (*(volatile union un_pdidis13 *)0xF02BD).BIT +#define FLPMC (*(volatile unsigned char *)0xF02C0) +#define FLARS (*(volatile union un_flars *)0xF02C1).flars +#define FLARS_bit (*(volatile union un_flars *)0xF02C1).BIT +#define FLAPL (*(volatile unsigned short *)0xF02C2) +#define FLAPH (*(volatile unsigned char *)0xF02C4) +#define FSSQ (*(volatile union un_fssq *)0xF02C5).fssq +#define FSSQ_bit (*(volatile union un_fssq *)0xF02C5).BIT +#define FLSEDL (*(volatile unsigned short *)0xF02C6) +#define FLSEDH (*(volatile unsigned char *)0xF02C8) +#define FLRST (*(volatile union un_flrst *)0xF02C9).flrst +#define FLRST_bit (*(volatile union un_flrst *)0xF02C9).BIT +#define FSASTL (*(volatile union un_fsastl *)0xF02CA).fsastl +#define FSASTL_bit (*(volatile union un_fsastl *)0xF02CA).BIT +#define FSASTH (*(volatile union un_fsasth *)0xF02CB).fsasth +#define FSASTH_bit (*(volatile union un_fsasth *)0xF02CB).BIT +#define FLWL (*(volatile unsigned short *)0xF02CC) +#define FLWH (*(volatile unsigned short *)0xF02CE) +#define DTCBAR (*(volatile unsigned char *)0xF02E0) +#define DTCEN0 (*(volatile union un_dtcen0 *)0xF02E8).dtcen0 +#define DTCEN0_bit (*(volatile union un_dtcen0 *)0xF02E8).BIT +#define DTCEN1 (*(volatile union un_dtcen1 *)0xF02E9).dtcen1 +#define DTCEN1_bit (*(volatile union un_dtcen1 *)0xF02E9).BIT +#define DTCEN2 (*(volatile union un_dtcen2 *)0xF02EA).dtcen2 +#define DTCEN2_bit (*(volatile union un_dtcen2 *)0xF02EA).BIT +#define DTCEN3 (*(volatile union un_dtcen3 *)0xF02EB).dtcen3 +#define DTCEN3_bit (*(volatile union un_dtcen3 *)0xF02EB).BIT +#define DTCEN4 (*(volatile union un_dtcen4 *)0xF02EC).dtcen4 +#define DTCEN4_bit (*(volatile union un_dtcen4 *)0xF02EC).BIT +#define CRC0CTL (*(volatile union un_crc0ctl *)0xF02F0).crc0ctl +#define CRC0CTL_bit (*(volatile union un_crc0ctl *)0xF02F0).BIT +#define PGCRCL (*(volatile unsigned short *)0xF02F2) +#define CRCD (*(volatile unsigned short *)0xF02FA) +#define TXBA0 (*(volatile unsigned char *)0xF0300) +#define RXBA0 (*(volatile unsigned char *)0xF0301) +#define ASIMA00 (*(volatile union un_asima00 *)0xF0302).asima00 +#define ASIMA00_bit (*(volatile union un_asima00 *)0xF0302).BIT +#define ASIMA01 (*(volatile union un_asima01 *)0xF0303).asima01 +#define ASIMA01_bit (*(volatile union un_asima01 *)0xF0303).BIT +#define BRGCA0 (*(volatile unsigned char *)0xF0304) +#define ASISA0 (*(volatile unsigned char *)0xF0305) +#define ASCTA0 (*(volatile union un_ascta0 *)0xF0306).ascta0 +#define ASCTA0_bit (*(volatile union un_ascta0 *)0xF0306).BIT +#define UTA0CK (*(volatile union un_uta0ck *)0xF0310).uta0ck +#define UTA0CK_bit (*(volatile union un_uta0ck *)0xF0310).BIT +#define ITLCMP00 (*(volatile unsigned short *)0xF0360) +#define ITLCMP000 (*(volatile unsigned char *)0xF0360) +#define ITLCMP001 (*(volatile unsigned char *)0xF0361) +#define ITLCMP01 (*(volatile unsigned short *)0xF0362) +#define ITLCMP012 (*(volatile unsigned char *)0xF0362) +#define ITLCMP013 (*(volatile unsigned char *)0xF0363) +#define ITLCAP00 (*(volatile unsigned short *)0xF0364) +#define ITLCTL0 (*(volatile union un_itlctl0 *)0xF0366).itlctl0 +#define ITLCTL0_bit (*(volatile union un_itlctl0 *)0xF0366).BIT +#define ITLCSEL0 (*(volatile unsigned char *)0xF0367) +#define ITLFDIV00 (*(volatile unsigned char *)0xF0368) +#define ITLFDIV01 (*(volatile unsigned char *)0xF0369) +#define ITLCC0 (*(volatile union un_itlcc0 *)0xF036A).itlcc0 +#define ITLCC0_bit (*(volatile union un_itlcc0 *)0xF036A).BIT +#define ITLS0 (*(volatile unsigned char *)0xF036B) +#define ITLMKF0 (*(volatile unsigned char *)0xF036C) +#define SMSI0 (*(volatile unsigned short *)0xF0380) +#define SMSI1 (*(volatile unsigned short *)0xF0382) +#define SMSI2 (*(volatile unsigned short *)0xF0384) +#define SMSI3 (*(volatile unsigned short *)0xF0386) +#define SMSI4 (*(volatile unsigned short *)0xF0388) +#define SMSI5 (*(volatile unsigned short *)0xF038A) +#define SMSI6 (*(volatile unsigned short *)0xF038C) +#define SMSI7 (*(volatile unsigned short *)0xF038E) +#define SMSI8 (*(volatile unsigned short *)0xF0390) +#define SMSI9 (*(volatile unsigned short *)0xF0392) +#define SMSI10 (*(volatile unsigned short *)0xF0394) +#define SMSI11 (*(volatile unsigned short *)0xF0396) +#define SMSI12 (*(volatile unsigned short *)0xF0398) +#define SMSI13 (*(volatile unsigned short *)0xF039A) +#define SMSI14 (*(volatile unsigned short *)0xF039C) +#define SMSI15 (*(volatile unsigned short *)0xF039E) +#define SMSI16 (*(volatile unsigned short *)0xF03A0) +#define SMSI17 (*(volatile unsigned short *)0xF03A2) +#define SMSI18 (*(volatile unsigned short *)0xF03A4) +#define SMSI19 (*(volatile unsigned short *)0xF03A6) +#define SMSI20 (*(volatile unsigned short *)0xF03A8) +#define SMSI21 (*(volatile unsigned short *)0xF03AA) +#define SMSI22 (*(volatile unsigned short *)0xF03AC) +#define SMSI23 (*(volatile unsigned short *)0xF03AE) +#define SMSI24 (*(volatile unsigned short *)0xF03B0) +#define SMSI25 (*(volatile unsigned short *)0xF03B2) +#define SMSI26 (*(volatile unsigned short *)0xF03B4) +#define SMSI27 (*(volatile unsigned short *)0xF03B6) +#define SMSI28 (*(volatile unsigned short *)0xF03B8) +#define SMSI29 (*(volatile unsigned short *)0xF03BA) +#define SMSI30 (*(volatile unsigned short *)0xF03BC) +#define SMSI31 (*(volatile unsigned short *)0xF03BE) +#define SMSG0 (*(volatile unsigned short *)0xF03C0) +#define SMSG1 (*(volatile unsigned short *)0xF03C2) +#define SMSG2 (*(volatile unsigned short *)0xF03C4) +#define SMSG3 (*(volatile unsigned short *)0xF03C6) +#define SMSG4 (*(volatile unsigned short *)0xF03C8) +#define SMSG5 (*(volatile unsigned short *)0xF03CA) +#define SMSG6 (*(volatile unsigned short *)0xF03CC) +#define SMSG7 (*(volatile unsigned short *)0xF03CE) +#define SMSG8 (*(volatile unsigned short *)0xF03D0) +#define SMSG9 (*(volatile unsigned short *)0xF03D2) +#define SMSG10 (*(volatile unsigned short *)0xF03D4) +#define SMSG11 (*(volatile unsigned short *)0xF03D6) +#define SMSG12 (*(volatile unsigned short *)0xF03D8) +#define SMSG13 (*(volatile unsigned short *)0xF03DA) +#define SMSG14 (*(volatile unsigned short *)0xF03DC) +#define SMSG15 (*(volatile unsigned short *)0xF03DE) +#define SMSC (*(volatile union un_smsc *)0xF03E0).smsc +#define SMSC_bit (*(volatile union un_smsc *)0xF03E0).BIT +#define SMSS (*(volatile union un_smss *)0xF03E1).smss +#define SMSS_bit (*(volatile union un_smss *)0xF03E1).BIT +#define FLSIVC0 (*(volatile unsigned short *)0xF0480) +#define FLSIVC1 (*(volatile unsigned short *)0xF0482) +#define GFLASH0 (*(volatile unsigned short *)0xF0488) +#define GFLASH1 (*(volatile unsigned short *)0xF048A) +#define GFLASH2 (*(volatile unsigned short *)0xF048C) +#define GIAWCTL (*(volatile unsigned short *)0xF048E) +#define CTSUCRAL (*(volatile unsigned short *)0xF0500) +#define CTSUCR0 (*(volatile unsigned char *)0xF0500) +#define CTSUCR1 (*(volatile unsigned char *)0xF0501) +#define CTSUCRAH (*(volatile unsigned short *)0xF0502) +#define CTSUCR2 (*(volatile unsigned char *)0xF0502) +#define CTSUCR3 (*(volatile unsigned char *)0xF0503) +#define CTSUCRBL (*(volatile unsigned short *)0xF0504) +#define CTSUSDPRS (*(volatile unsigned char *)0xF0504) +#define CTSUSST (*(volatile unsigned char *)0xF0505) +#define CTSUCRBH (*(volatile unsigned short *)0xF0506) +#define CTSUDCLKC (*(volatile unsigned char *)0xF0507) +#define CTSUMCHL (*(volatile unsigned short *)0xF0508) +#define CTSUMCH0 (*(volatile unsigned char *)0xF0508) +#define CTSUMCH1 (*(volatile unsigned char *)0xF0509) +#define CTSUMCHH (*(volatile unsigned short *)0xF050A) +#define CTSUMFAF (*(volatile unsigned char *)0xF050A) +#define CTSUCHACAL (*(volatile unsigned short *)0xF050C) +#define CTSUCHAC0 (*(volatile unsigned char *)0xF050C) +#define CTSUCHAC1 (*(volatile unsigned char *)0xF050D) +#define CTSUCHACAH (*(volatile unsigned short *)0xF050E) +#define CTSUCHAC2 (*(volatile unsigned char *)0xF050E) +#define CTSUCHAC3 (*(volatile unsigned char *)0xF050F) +#define CTSUCHACBL (*(volatile unsigned short *)0xF0510) +#define CTSUCHAC4 (*(volatile unsigned char *)0xF0510) +#define CTSUCHAC5 (*(volatile unsigned char *)0xF0511) +#define CTSUCHACBH (*(volatile unsigned short *)0xF0512) +#define CTSUCHAC6 (*(volatile unsigned char *)0xF0512) +#define CTSUCHAC7 (*(volatile unsigned char *)0xF0513) +#define CTSUCHTRCAL (*(volatile unsigned short *)0xF0514) +#define CTSUCHTRC0 (*(volatile unsigned char *)0xF0514) +#define CTSUCHTRC1 (*(volatile unsigned char *)0xF0515) +#define CTSUCHTRCAH (*(volatile unsigned short *)0xF0516) +#define CTSUCHTRC2 (*(volatile unsigned char *)0xF0516) +#define CTSUCHTRC3 (*(volatile unsigned char *)0xF0517) +#define CTSUCHTRCBL (*(volatile unsigned short *)0xF0518) +#define CTSUCHTRC4 (*(volatile unsigned char *)0xF0518) +#define CTSUCHTRC5 (*(volatile unsigned char *)0xF0519) +#define CTSUCHTRCBH (*(volatile unsigned short *)0xF051A) +#define CTSUCHTRC6 (*(volatile unsigned char *)0xF051A) +#define CTSUCHTRC7 (*(volatile unsigned char *)0xF051B) +#define CTSUSRL (*(volatile unsigned short *)0xF051C) +#define CTSUST1 (*(volatile unsigned char *)0xF051C) +#define CTSUST (*(volatile unsigned char *)0xF051D) +#define CTSUSO0 (*(volatile unsigned short *)0xF0520) +#define CTSUSO1 (*(volatile unsigned short *)0xF0522) +#define CTSUSC (*(volatile unsigned short *)0xF0524) +#define CTSUUC (*(volatile unsigned short *)0xF0526) +#define CTSUDBGR0 (*(volatile unsigned short *)0xF0528) +#define CTSUDBGR1 (*(volatile unsigned short *)0xF052A) +#define CTSUSUCLK0 (*(volatile unsigned short *)0xF052C) +#define CTSUSUCLK1 (*(volatile unsigned short *)0xF052E) +#define CTSUSUCLK2 (*(volatile unsigned short *)0xF0530) +#define CTSUSUCLK3 (*(volatile unsigned short *)0xF0532) +#define TRNGSDR (*(volatile unsigned char *)0xF0540) +#define TRNGSCR0 (*(volatile union un_trngscr0 *)0xF0542).trngscr0 +#define TRNGSCR0_bit (*(volatile union un_trngscr0 *)0xF0542).BIT +#define CTSUTRIM0 (*(volatile unsigned short *)0xF0600) +#define RTRIM (*(volatile unsigned char *)0xF0600) +#define DACTRIM (*(volatile unsigned char *)0xF0601) +#define CTSUTRIM1 (*(volatile unsigned short *)0xF0602) +#define SUADJD (*(volatile unsigned char *)0xF0602) +#define TRESULT4 (*(volatile unsigned char *)0xF0603) +#define CTSUTRIM2 (*(volatile unsigned short *)0xF0604) +#define TRESULT0 (*(volatile unsigned char *)0xF0604) +#define TRESULT1 (*(volatile unsigned char *)0xF0605) +#define CTSUTRIM3 (*(volatile unsigned short *)0xF0606) +#define TRESULT2 (*(volatile unsigned char *)0xF0606) +#define TRESULT3 (*(volatile unsigned char *)0xF0607) + +/* + Sfr bits + */ +#define ADTYP ADM2_bit.no0 +#define AWC ADM2_bit.no2 +#define ADRCK ADM2_bit.no3 +#define ULBS0 ULBS_bit.no0 +#define ULBS1 ULBS_bit.no1 +#define ULBS2 ULBS_bit.no2 +#define ULBS4 ULBS_bit.no4 +#define DFLEN DFLCTL_bit.no0 +#define MODE0 FLMODE_bit.no6 +#define MODE1 FLMODE_bit.no7 +#define FLMWEN FLMWRP_bit.no0 +#define ESQST FSSE_bit.no7 +#define TAU0EN PER0_bit.no0 +#define SAU0EN PER0_bit.no2 +#define SAU1EN PER0_bit.no3 +#define IICA0EN PER0_bit.no4 +#define ADCEN PER0_bit.no5 +#define RTCWEN PER0_bit.no7 +#define TAU0RES PRR0_bit.no0 +#define SAU0RES PRR0_bit.no2 +#define SAU1RES PRR0_bit.no3 +#define IICA0RES PRR0_bit.no4 +#define ADCRES PRR0_bit.no5 +#define HIPREC OSMC_bit.no0 +#define WUTMMCK0 OSMC_bit.no4 +#define RTCLPC OSMC_bit.no7 +#define RPEF RPECTL_bit.no0 +#define RPERDIS RPECTL_bit.no7 +#define PORF PORSR_bit.no0 +#define CTSUEN PER1_bit.no0 +#define UTAEN PER1_bit.no2 +#define DTCEN PER1_bit.no3 +#define TML32EN PER1_bit.no4 +#define SMSEN PER1_bit.no6 +#define CTSURES PRR1_bit.no0 +#define TML32RES PRR1_bit.no4 +#define SMSRES PRR1_bit.no6 +#define FWKUP WKUPMD_bit.no0 +#define DLVD0FCLR LVDFCLR_bit.no2 +#define DLVD1FCLR LVDFCLR_bit.no3 +#define RTC128EN RTCC0_bit.no4 +#define RCLOE1 RTCC0_bit.no5 +#define RTCE RTCC0_bit.no7 +#define RWAIT RTCC1_bit.no0 +#define RWST RTCC1_bit.no1 +#define RIFG RTCC1_bit.no3 +#define WAFG RTCC1_bit.no4 +#define WALIE RTCC1_bit.no6 +#define WALE RTCC1_bit.no7 +#define SPT0 IICCTL00_bit.no0 +#define STT0 IICCTL00_bit.no1 +#define ACKE0 IICCTL00_bit.no2 +#define WTIM0 IICCTL00_bit.no3 +#define SPIE0 IICCTL00_bit.no4 +#define WREL0 IICCTL00_bit.no5 +#define LREL0 IICCTL00_bit.no6 +#define IICE0 IICCTL00_bit.no7 +#define PRS0 IICCTL01_bit.no0 +#define DFC0 IICCTL01_bit.no2 +#define SMC0 IICCTL01_bit.no3 +#define DAD0 IICCTL01_bit.no4 +#define CLD0 IICCTL01_bit.no5 +#define SVADIS0 IICCTL01_bit.no6 +#define WUP0 IICCTL01_bit.no7 +#define FSSTP FSSQ_bit.no6 +#define SQST FSSQ_bit.no7 +#define CRC0EN CRC0CTL_bit.no7 +#define ISRMA0 ASIMA00_bit.no0 +#define ISSMA0 ASIMA00_bit.no1 +#define RXEA0 ASIMA00_bit.no5 +#define TXEA0 ASIMA00_bit.no6 +#define UARTAEN0 ASIMA00_bit.no7 +#define OVECTA0 ASCTA0_bit.no0 +#define FECTA0 ASCTA0_bit.no1 +#define PECTA0 ASCTA0_bit.no2 +#define ITLEN00 ITLCTL0_bit.no0 +#define ITLEN01 ITLCTL0_bit.no1 +#define ITLEN02 ITLCTL0_bit.no2 +#define ITLEN03 ITLCTL0_bit.no3 +#define CAPR0 ITLCC0_bit.no4 +#define CAPF0CR ITLCC0_bit.no6 +#define LONGWAIT SMSC_bit.no4 +#define SMSTRGWAIT SMSC_bit.no5 +#define SMSSTOP SMSC_bit.no6 +#define SMSSTART SMSC_bit.no7 +#define SMSSTAT SMSS_bit.no7 +#define TRNGST TRNGSCR0_bit.no2 +#define TRNGEN TRNGSCR0_bit.no3 +#define TRNGRDY TRNGSCR0_bit.no7 + +/* + Interrupt vector addresses + */ +#endif diff --git a/cores/rl78g22/smc_gen/r_bsp/platform.h b/cores/rl78g22/smc_gen/r_bsp/platform.h index 140e47a..41a294d 100644 --- a/cores/rl78g22/smc_gen/r_bsp/platform.h +++ b/cores/rl78g22/smc_gen/r_bsp/platform.h @@ -1,62 +1,62 @@ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -* this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2021 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* File Name : platform.h -* Description : The user chooses which MCU and board they are developing for in this file. If the board you are using -* is not listed below, please add your own or use the default 'User Board'. -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* History : DD.MM.YYYY Version Description -* : 08.03.2021 1.00 First Release -* : 28.02.2022 1.20 Added RL78F23,RL78F24 -* : 31.05.2022 1.30 Added RL78G15 -* : 31.08.2022 1.40 Added RL78G22 -***********************************************************************************************************************/ - -/* Multiple inclusion prevention macro */ -#ifndef PLATFORM_H -#define PLATFORM_H - -/*********************************************************************************************************************** -DEFINE YOUR SYSTEM - UNCOMMENT THE INCLUDE PATH FOR THE PLATFORM YOU ARE USING. -***********************************************************************************************************************/ -// GENERIC_RL78_G23 -//#include "./board/generic_rl78_g23/r_bsp.h" - -// GENERIC_RL78_F23 -//#include "./board/generic_rl78_f23/r_bsp.h" - -// GENERIC_RL78_F24 -//#include "./board/generic_rl78_f24/r_bsp.h" - -// GENERIC_RL78_G15 -//#include "./board/generic_rl78_g15/r_bsp.h" - -// GENERIC_RL78_G22 -#include "./board/generic_rl78_g22/r_bsp.h" - -/*********************************************************************************************************************** -MAKE SURE AT LEAST ONE PLATFORM WAS DEFINED - DO NOT EDIT BELOW THIS POINT -***********************************************************************************************************************/ -#ifndef PLATFORM_DEFINED -#error "Error - No platform defined in platform.h!" -#endif - -#endif /* PLATFORM_H */ - +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +* this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2021 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* File Name : platform.h +* Description : The user chooses which MCU and board they are developing for in this file. If the board you are using +* is not listed below, please add your own or use the default 'User Board'. +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* History : DD.MM.YYYY Version Description +* : 08.03.2021 1.00 First Release +* : 28.02.2022 1.20 Added RL78F23,RL78F24 +* : 31.05.2022 1.30 Added RL78G15 +* : 31.08.2022 1.40 Added RL78G22 +***********************************************************************************************************************/ + +/* Multiple inclusion prevention macro */ +#ifndef PLATFORM_H +#define PLATFORM_H + +/*********************************************************************************************************************** +DEFINE YOUR SYSTEM - UNCOMMENT THE INCLUDE PATH FOR THE PLATFORM YOU ARE USING. +***********************************************************************************************************************/ +// GENERIC_RL78_G23 +//#include "./board/generic_rl78_g23/r_bsp.h" + +// GENERIC_RL78_F23 +//#include "./board/generic_rl78_f23/r_bsp.h" + +// GENERIC_RL78_F24 +//#include "./board/generic_rl78_f24/r_bsp.h" + +// GENERIC_RL78_G15 +//#include "./board/generic_rl78_g15/r_bsp.h" + +// GENERIC_RL78_G22 +#include "./board/generic_rl78_g22/r_bsp.h" + +/*********************************************************************************************************************** +MAKE SURE AT LEAST ONE PLATFORM WAS DEFINED - DO NOT EDIT BELOW THIS POINT +***********************************************************************************************************************/ +#ifndef PLATFORM_DEFINED +#error "Error - No platform defined in platform.h!" +#endif + +#endif /* PLATFORM_H */ + diff --git a/cores/rl78g22/smc_gen/r_bsp/readme.txt b/cores/rl78g22/smc_gen/r_bsp/readme.txt index 19be9ea..4483b64 100644 --- a/cores/rl78g22/smc_gen/r_bsp/readme.txt +++ b/cores/rl78g22/smc_gen/r_bsp/readme.txt @@ -1,4 +1,4 @@ -Version : BSP v1.40 (Alpha3) -Release Date : 2022/08/31 -Support Compiler : CCRL, LLVM, ICCRL - +Version : BSP v1.40 (Alpha3) +Release Date : 2022/08/31 +Support Compiler : CCRL, LLVM, ICCRL + diff --git a/cores/rl78g22/smc_gen/r_config/r_bsp_config.h b/cores/rl78g22/smc_gen/r_config/r_bsp_config.h index 8c433b2..6498f59 100644 --- a/cores/rl78g22/smc_gen/r_config/r_bsp_config.h +++ b/cores/rl78g22/smc_gen/r_config/r_bsp_config.h @@ -1,563 +1,563 @@ -/* Generated configuration header file - do not edit */ -/*********************************************************************************************************************** -* DISCLAIMER -* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -* applicable laws, including copyright laws. -* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -* this software. By using this software, you agree to the additional terms and conditions found by accessing the -* following link: -* http://www.renesas.com/disclaimer -* -* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* File Name : r_bsp_config_reference.h -* H/W Platform : GENERIC_RL78_G22 -* Description : -***********************************************************************************************************************/ -/*********************************************************************************************************************** -* History : DD.MM.YYYY Version Description -* : 20.04.2022 1.50 First Release -***********************************************************************************************************************/ - -#ifndef R_BSP_CONFIG_REF_HEADER_FILE -#define R_BSP_CONFIG_REF_HEADER_FILE -/************************************************* - * MCU information - *************************************************/ -/* - R 7 F 102G G E 3 xxx C FB #AA0 - | | | | | | | | | | |__not used Packaging specification - | | | | | | | | | |_____not used Package type - | | | | | | | | |________not used Fields of application - | | | | | | | |___________not used ROM number(omitted with blank products) - | | | | | | |______________not used Ambient operating temperature range - | | | | | |________________BSP_CFG_MCU_PART_ROM_SIZE ROM capacity - | | | | |__________________BSP_CFG_MCU_PART_PIN_NUM Pin count - | | | |______________________not used RL78/G22 - | | |_________________________BSP_CFG_MCU_PART_ROM_TYPE Device type - | |___________________________not used Renesas MCU - |_____________________________not used Renesas semiconductor product -*/ - -/* ROM capacity - C = 32(KB) : 0x0 - E = 64 : 0x1 -*/ -#define BSP_CFG_MCU_PART_ROM_SIZE (0x1) /* Generated value. Do not edit this manually */ - -/* Pin count - 4 = 16-pin : 0x0 - 6 = 20-pin : 0x1 - 7 = 24-pin : 0x2 - 8 = 25-pin : 0x3 - A = 30-pin : 0x4 - B = 32-pin : 0x5 - C = 36-pin : 0x6 - E = 40-pin : 0x7 - F = 44-pin : 0x8 - G = 48-pin : 0x9 -*/ -#define BSP_CFG_MCU_PART_PIN_NUM (0x9) /* Generated value. Do not edit this manually */ - -/* group - 102G = RL78/G22 : (true) -*/ -#define BSP_CFG_MCU_PART_HAS_DATA_FLASH (true) - -/* Device type - F = Flash memory : 0 -*/ -#define BSP_CFG_MCU_PART_ROM_TYPE (0) - -#if defined(__ICCRL78__) -/* Option byte setting(When using IAR) */ -#define BSP_CFG_OPTBYTE0_VALUE (0xEFU) /* Generated value. Do not edit this manually */ -#define BSP_CFG_OPTBYTE1_VALUE (0x7FU) /* Generated value. Do not edit this manually */ -#define BSP_CFG_OPTBYTE2_VALUE (0xE8U) /* Generated value. Do not edit this manually */ -#define BSP_CFG_OPTBYTE3_VALUE (0x04U) /* Generated value. Do not edit this manually */ -/* Security ID Codes for On-Chip Debugging setting(When using IAR) */ -#define BSP_CFG_SECUID0_VALUE (0x00U) /* Generated value. Do not edit this manually */ -#define BSP_CFG_SECUID1_VALUE (0x00U) /* Generated value. Do not edit this manually */ -#define BSP_CFG_SECUID2_VALUE (0x00U) /* Generated value. Do not edit this manually */ -#define BSP_CFG_SECUID3_VALUE (0x00U) /* Generated value. Do not edit this manually */ -#define BSP_CFG_SECUID4_VALUE (0x00U) /* Generated value. Do not edit this manually */ -#define BSP_CFG_SECUID5_VALUE (0x00U) /* Generated value. Do not edit this manually */ -#define BSP_CFG_SECUID6_VALUE (0x00U) /* Generated value. Do not edit this manually */ -#define BSP_CFG_SECUID7_VALUE (0x00U) /* Generated value. Do not edit this manually */ -#define BSP_CFG_SECUID8_VALUE (0x00U) /* Generated value. Do not edit this manually */ -#define BSP_CFG_SECUID9_VALUE (0x00U) /* Generated value. Do not edit this manually */ -#endif - -/************************************************* - * Pin assignment setting - *************************************************/ -/* Peripheral I/O redirection register(PIOR-PIOR0) - 48/44-pin - 0 : TI02/TO02 - P17 - TI03/TO03 - P31 - TI04/TO04 - - - TI05/TO05 - - - TI06/TO06 - - - TI07/TO07 - P41 - 1 : TI02/TO02 - P15 - TI03/TO03 - P14 - TI04/TO04 - P13 - TI05/TO05 - P12 - TI06/TO06 - P11 - TI07/TO07 - P10 - - 40/36/32/30-pin - 0 : TI02/TO02 - P17 - TI03/TO03 - P31 - TI04/TO04 - - - TI05/TO05 - - - TI06/TO06 - - - TI07/TO07 - - - 1 : TI02/TO02 - P15 - TI03/TO03 - P14 - TI04/TO04 - P13 - TI05/TO05 - P12 - TI06/TO06 - P11 - TI07/TO07 - P10 -*/ -// 2022/11/11 -#define BSP_CFG_PIOR0 (0) /* Generated value. Do not edit this manually */ - -/* Peripheral I/O redirection register(PIOR-PIOR1) - 48/44/40/36/32/30-pin - 0 : TxD2 - P13 - RxD2 - P14 - SCL20 - P15 - SDA20 - P14 - SI20 - P14 - SO20 - P13 - SCK20 - P15 - TxD0 - P12 - RxD0 - P11 - SCL00 - P10 - SDA00 - P11 - SI00 - P11 - SO00 - P12 - SCK00 - P10 - 1 : TxD2 - - - RxD2 - - - SCL20 - - - SDA20 - - - SI20 - - - SO20 - - - SCK20 - - - TxD0 - P17 - RxD0 - P16 - SCL00 - - - SDA00 - - - SI00 - - - SO00 - - - SCK00 - - -*/ -#define BSP_CFG_PIOR1 (0) /* Generated value. Do not edit this manually */ - -/* Peripheral I/O redirection register(PIOR-PIOR2) - 48/44/40/36/32/30-pin - 0 : SCLA0 - P60 - SDAA0 - P61 - 1 : SCLA0 - P14 - SDAA0 - P13 -*/ -#define BSP_CFG_PIOR2 (0) /* Generated value. Do not edit this manually */ - -/* Peripheral I/O redirection register(PIOR-PIOR3) - 48-pin - 0 : PCLBUZ0 - P140 - 1 : PCLBUZ0 - P31 - - 44/40/36/32/30-pin - 0 : PCLBUZ0 - - - 1 : PCLBUZ0 - - -*/ -#define BSP_CFG_PIOR3 (0) /* Generated value. Do not edit this manually */ - -/*********************************************************** - * Invalid memory access detection control register (IAWCTL) - ***********************************************************/ -/* Control of illicit memory access detection(IAWEN) - 0 : Disables the detection of illicit memory accesses. - 1 : Enables the detection of illicit memory accesses. -*/ -#define BSP_CFG_INVALID_MEMORY_ACCESS_DETECTION_ENABLE (0) - -/* Protected area in the RAM(GRAM0-1) - 0 : Disabled. Writing to the RAM is allowed. - 1 : 128 bytes from the base address of the RAM. - 2 : 256 bytes from the base address of the RAM. - 3 : 512 bytes from the base address of the RAM. -*/ -#define BSP_CFG_RAM_GUARD_FUNC (0) - -/* Protection of the port control registers(GPORT) - 0 : Disabled. Reading from and writing to the port control registers are allowed. - 1 : Enabled. Writing to the port control registers is not allowed. Reading from them is allowed. - [Protected SFRs] PMxx, PUxx, PIMxx, POMxx, PMCAxx, PMCTxx, PFOE1, PDIDISxx -*/ -#define BSP_CFG_PORT_FUNCTION_GUARD (0) - -/* Protection of the interrupt control registers(GINT) - 0 : Disabled. Reading from and writing to the interrupt control registers are allowed. - 1 : Enabled. Writing to the interrupt control registers is not allowed. Reading from them is allowed. - [Protected SFRs] IFxx, MKxx, PRxx, EGPx, EGNx -*/ -#define BSP_CFG_INT_FUNCTION_GUARD (0) - -/* Protection of the clock, voltage detector, and RAM parity error detection control registers(GCSC) - 0 : Disabled. Reading from and writing to the clock, voltage detector, and RAM parity error - detection control registers are allowed. - 1 : Enabled. Writing to the clock, voltage detector, and RAM parity error detection control registers - is not allowed. Reading from them is allowed. - [Protected SFRs] CMC, CSC, OSTS, CKC, PERx, OSMC, LVIM, LVIS, RPECTL, - CKSEL, PRRx, MOCODIV, WKUPMD -*/ -#define BSP_CFG_CHIP_STATE_CTRL_GUARD (0) - -/************************************************* - * Data flash - *************************************************/ -/* Data flash memory area access control - Data flash control register(DFLCTL) - DFLEN - 0 : Access to the data flash memory area is disabled. - 1 : Access to the data flash memory area is enabled. -*/ -#define BSP_CFG_DATA_FLASH_ACCESS_ENABLE (0) - -/************************************************* - * Definition for switching functions - *************************************************/ -/* Start up select - 0 : Enable BSP startup program. - 1 : Disable BSP startup program.(e.g. Using user startup program.) -*/ -#define BSP_CFG_STARTUP_DISABLE (0) - -/* Initialization of peripheral functions by Code Generator/Smart Configurator - 0 : Disable initialization of peripheral functions by Code Generator/Smart Configurator. - 1 : Enable initialization of peripheral functions by Code Generator/Smart Configurator. -*/ -#define BSP_CFG_CONFIGURATOR_SELECT (1) - -/* Version number of Smart Configurator. - This macro definitions is updated by Smart Configurator. - If you are using e2studio, set the following values. - 2021-04 : 1001 - 2021-07 : 1010 - 2021-10 : 1010 - 2022-01 : 1030 - If you are using the standalone version of Smart Configurator, - set the following values. - v1.0.1 : 1001 - v1.1.0 : 1010 - v1.3.0 : 1030 -*/ -#define BSP_CFG_CONFIGURATOR_VERSION (1030) /* Generated value. Do not edit this manually */ - -/* API function disable(R_BSP_StartClock, R_BSP_StopClock) - 0 : Enable API functions - 1 : Disable API functions -*/ -#define BSP_CFG_CLOCK_OPERATION_API_FUNCTIONS_DISABLE (0) - -/* API function disable(R_BSP_GetFclkFreqHz) - 0 : Enable API functions - 1 : Disable API functions -*/ -#define BSP_CFG_GET_FREQ_API_FUNCTIONS_DISABLE (0) - -/* API function disable(R_BSP_SetClockSource) - 0 : Enable API functions - 1 : Disable API functions -*/ -#define BSP_CFG_SET_CLOCK_SOURCE_API_FUNCTIONS_DISABLE (0) - -/* API function disable(R_BSP_ChangeClockSetting) - 0 : Enable API functions - 1 : Disable API functions -*/ -#define BSP_CFG_CHANGE_CLOCK_SETTING_API_FUNCTIONS_DISABLE (0) - -/* Parameter check enable - 0 : Disable parameter check. - 1 : Enable parameter check. -*/ -#define BSP_CFG_PARAM_CHECKING_ENABLE (1) - -/************************************************* - * Clock settings - *************************************************/ -/* High-speed system clock pin operation mode - Clock operation mode control register(CMC) - (Products with 16 to 36 pins) - XTSEL/EXCLK/OSCSEL - (Products with 40 to 48 pins) - EXCLK/OSCSEL - 0 : Port mode - 1 : X1 oscillation mode - 2 : External clock input mode -*/ -#define BSP_CFG_HISYSCLK_SOURCE (0) /* Generated value. Do not edit this manually */ - -/* High-speed system clock operation control - Clock operation status control register(CSC) - MSTOP - (X1 oscillation mode) - 0 : The X1 oscillator runs. - 1 : The X1 oscillator is stopped. - (External clock input mode) - 0 : An external clock signal on the EXCLK pin is effective. - 1 : An external clock signal on the EXCLK pin is ineffective. - (Port mode) - 0 : I/O port - 1 : I/O port -*/ -#define BSP_CFG_HISYSCLK_OPERATION (1) /* Generated value. Do not edit this manually */ - -/* Subsystem clock pin operation mode - Clock operation mode control register(CMC) - (Products with 16 to 36 pins) - XTSEL/EXCLKS/OSCSELS - (Products with 40 to 48 pins) - EXCLKS/OSCSELS - 0 : Input port mode - 1 : XT1 oscillation mode -2 : External clock input mode -*/ -#define BSP_CFG_SUBCLK_SOURCE (1) /* Generated value. Do not edit this manually */ - -/* Subsystem clock operation control - Clock operation status control register(CSC) - XTSTOP - (XT1 oscillation mode) - 0 : The XT1 oscillator runs. - 1 : The XT1 oscillator is stopped. - (External clock input mode) - 0 : An external clock signal on the EXCLKS pin is effective. - 1 : An external clock signal on the EXCLKS pin is ineffective. - (Port mode) - 0 : Input port - 1 : Input port -*/ -#define BSP_CFG_SUBCLK_OPERATION (0) /* Generated value. Do not edit this manually */ - -/* Middle-speed on-chip oscillator clock operation control - Clock operation status control register(CSC) - MIOEN - 0 : The middle-speed on-chip oscillator is stopped. - 1 : The middle-speed on-chip oscillator runs. -*/ -#define BSP_CFG_MOCO_OPERATION (0) /* Generated value. Do not edit this manually */ - -/* Main on-chip oscillator clock(fOCO) operation control - System clock control register(CKC) - MCM1 - 0 : High-speed on-chip oscillator clock - 1 : Middle-speed on-chip oscillator clock -*/ -#define BSP_CFG_OCOCLK_SOURCE (0) /* Generated value. Do not edit this manually */ - -/* Main system clock(fMAIN) operation control - System clock control register(CKC) - MCM0 - 0 : Selects the main on-chip oscillator clock(fOCO) as the main system clock(fMAIN) - 1 : Selects the high-speed system clock(fMX) as the main system clock(fMAIN) -*/ -#define BSP_CFG_MAINCLK_SOURCE (0) /* Generated value. Do not edit this manually */ - -/* Selection of the subsystem clock X or low-speed on-chip oscillator clock - Subsystem clock select register(CKSEL) - SELLOSC - 0 : Subsystem clock X - 1 : Low-speed on-chip oscillator clock -*/ -#define BSP_CFG_SUBSYSCLK_SOURCE (0) /* Generated value. Do not edit this manually */ - -/* Selection of the CPU/peripheral hardware clock(fCLK) - System clock control register(CKC) - CSS - 0 : Main system clock(fMAIN) - 1 : Subsystem clock(fSUB) -*/ -#define BSP_CFG_FCLK_SOURCE (0) /* Generated value. Do not edit this manually */ - -/* Selection of the oscillation mode of the XT1 oscillator - Clock operation mode control register(CMC) - AMPHS1, AMPHS0 - 0 : Low power consumption oscillation 1(default) - 1 : Normal oscillation - 2 : Low power consumption oscillation 2 - 3 : Low power consumption oscillation 3 -*/ -#define BSP_CFG_XT1_OSCMODE (0) /* Generated value. Do not edit this manually */ - -/* Input clock frequency in Hz(High-speed system clock(X1)) -*/ -#define BSP_CFG_FMX_HZ (20000000) - -/* Control of the X1 clock oscillation frequency - Clock operation mode control register(CMC) - AMPH - 0 : 1 MHz <= fX <= 10 MHz - 1 : 10 MHz < fX <= 20 MHz - Set the value corresponding to the setting of BSP_CFG_FMX_HZ -*/ - -/* Selection of the oscillation stabilization time - Oscillation stabilization time select register(OSTS) - OSTS2, OSTS1, OSTS0 - 0 : 2^8/fX(fX = 10MHz : 25.6us, fX = 20MHz : 12.8us) - 1 : 2^9/fX(fX = 10MHz : 51.2us, fX = 20MHz : 25.6us) - 2 : 2^10/fX(fX = 10MHz : 102us, fX = 20MHz : 51.2us) - 3 : 2^11/fX(fX = 10MHz : 204us, fX = 20MHz : 102us) - 4 : 2^13/fX(fX = 10MHz : 819us, fX = 20MHz : 409us) - 5 : 2^15/fX(fX = 10MHz : 3.27ms, fX = 20MHz : 1.63ms) - 6 : 2^17/fX(fX = 10MHz : 13.1ms, fX = 20MHz : 6.55ms) - 7 : 2^18/fX(fX = 10MHz : 26.2ms, fX = 20MHz : 13.1ms) -*/ -#define BSP_CFG_X1_WAIT_TIME_SEL (0) - -/* Setting in STOP mode or in HALT mode while the CPU is operating with subsystem clock X. - Subsystem clock supply mode control register(OSMC) - RTCLPC - 0 : Enables supply of subsystem clock X to peripheral functions. - 1 : Stops supply of the subsystem clock to peripheral functions other than the realtime clock. -*/ -#define BSP_CFG_ALLOW_FSUB_IN_STOPHALT (0) /* Generated value. Do not edit this manually */ - -/* Selection of the operating clock for the realtime clock, 32-bit interval timer, - serial interface UARTA0, and clock output/buzzer output controller - Subsystem clock supply mode control register(OSMC) - WUTMMCK0 - 0 : Subsystem clock X - 1 : Low-speed on-chip oscillator clock -*/ -#define BSP_CFG_RTC_OUT_CLK_SOURCE (0) /* Generated value. Do not edit this manually */ - -/* Selection of the high-speed on-chip oscillator clock frequency - High-speed on-chip oscillator frequency select register(HOCODIV) - HOCODIV2, HOCODIV1, HOCODIV0 - - (FRQSEL3 = 0) - 0 : fIH = 24 MHz - 1 : fIH = 12 MHz - 2 : fIH = 6 MHz - 3 : fIH = 3 MHz - Other than above : Setting prohibited - - (FRQSEL3 = 1) - 0 : fIH = 32 MHz - 1 : fIH = 16 MHz - 2 : fIH = 8 MHz - 3 : fIH = 4 MHz - 4 : fIH = 2 MHz - 5 : fIH = 1 MHz - Other than above : Setting prohibited - */ -#define BSP_CFG_HOCO_DIVIDE (0) /* Generated value. Do not edit this manually */ - -/* Setting for starting the high-speed on-chip oscillator at the times of release from STOP mode - and of transitions to SNOOZE mode - Standby mode release setting register(WKUPMD) - FWKUP - 0 : Starting of the high-speed on-chip oscillator is at normal speed. - 1 : Starting of the high-speed on-chip oscillator is at high speed. -*/ -#define BSP_CFG_WAKEUP_MODE (0) /* Generated value. Do not edit this manually */ - -/* Selected division ratio for the high-speed system clock - High-speed system clock division register(MOSCDIV) - MOSCDIV2, MOSCDIV1, MOSCDIV0 - 0 : fMX (fMX = 20MHz : 20MHz) - 1 : fMX/2 (fMX = 20MHz : 10MHz) - 2 : fMX/4 (fMX = 20MHz : 5MHz) - 3 : fMX/8 (fMX = 20MHz : 2.5MHz) - 4 : fMX/16 (fMX = 20MHz : 1.25MHz) - Other than above : Setting prohibited -*/ -#define BSP_CFG_MOSC_DIVIDE (0) /* Generated value. Do not edit this manually */ - -/* Selection of the middle-speed on-chip oscillator clock frequency - Middle-speed on-chip oscillator frequency select register(MOCODIV) - MOCODIV1, MOCODIV0 - 0 : 4MHz - 1 : 2MHz - 2 : 1MHz - Other than above : Setting prohibited -*/ -#define BSP_CFG_MOCO_DIVIDE (0) /* Generated value. Do not edit this manually */ - -/* Operation setting at initial setting */ -/* Starts the high-speed on-chip oscillator at initialization - 0 : Stops the high-speed on-chip oscillator at initialization - 1 : Starts the high-speed on-chip oscillator at initialization -*/ -#define BSP_CFG_FIH_START_ON_STARTUP (1) /* Generated value. Do not edit this manually */ - -/* This macro lets other modules no if a RTOS is being used. - 0 : RTOS is not used. - 1 : FreeRTOS is used.(This is not available.) - 2 : embOS is used.(This is not available.) - 3 : MicroC_OS is used.(This is not available.) - 4 : Renesas ITRON is used. -*/ -#define BSP_CFG_RTOS_USED (0) - -/* Loop count using the main system clock. */ -/* The loop count refers to a loop consisting of a "for" statement that executes a single NOP instruction. */ -/* Subsystem clock oscillation stabilization wait time */ -/* If the main system clock is 32 MHz, 800000 means 550 ms. */ -#define BSP_CFG_SUBWAITTIME (800000U) - -/* High-speed on-chip oscillator clock oscillation stabilization wait time */ -/* If the main system clock 32 MHz, 30 means 22.7us. */ -#define BSP_CFG_FIHWAITTIME (30U) - -/* Middle-speed on-chip oscillator clock oscillation stabilization wait time. */ -/* If the main system clock 32 MHz, 5 means 4.8us. */ -#define BSP_CFG_FIMWAITTIME (5U) - -/* Low-speed on-chip oscillator clock oscillation stabilization wait time */ -/* If the main system clock 32 MHz, 450 means 325us. */ -#define BSP_CFG_FILWAITTIME (450U) - -/* If the user would like to determine if a warm start reset has occurred, then they may enable one or more of the - following callback definitions AND provide a call back function name for the respective callback - function (to be defined by the user). Setting BSP_CFG_USER_WARM_START_CALLBACK_PRE_INITC_ENABLED = 1 will result - in a callback to the user defined my_sw_warmstart_prec_function just prior to the initialization of the C - runtime environment by bsp_init_system. - Setting BSP_CFG_USER_WARM_START_CALLBACK_POST_INITC_ENABLED = 1 will result in a callback to the user defined - my_sw_warmstart_postc_function just after the initialization of the C runtime environment by bsp_init_hardware. -*/ -#define BSP_CFG_USER_WARM_START_CALLBACK_PRE_INITC_ENABLED (0) -#define BSP_CFG_USER_WARM_START_PRE_C_FUNCTION my_sw_warmstart_prec_function - -#define BSP_CFG_USER_WARM_START_CALLBACK_POST_INITC_ENABLED (0) -#define BSP_CFG_USER_WARM_START_POST_C_FUNCTION my_sw_warmstart_postc_function - -/* If the user sets the window open period of watchdog timer to 50%, - set the following macro definition(BSP_CFG_WDT_REFRESH_ENABLE) to 2 - and specify the callback function name for each callback function(to be defined by the user). - Setting BSP_CFG_WDT_REFRESH_ENABLE == 2 will result in a callback to the user defined - my_sw_wdt_refresh_init_function just prior to the clock is set by bsp_init_system. - In addition, a callback to the user defined my_sw_wdt_refresh_setting_function occurs - during the oscillation stabilization wait time od the subsystem clock. -*/ -#define BSP_CFG_WDT_REFRESH_ENABLE (0) -#define BSP_CFG_USER_WDT_REFRESH_INIT_FUNCTION my_sw_wdt_refresh_init_function -#define BSP_CFG_USER_WDT_REFRESH_SETTING_FUNCTION my_sw_wdt_refresh_setting_function - -#endif /* R_BSP_CONFIG_REF_HEADER_FILE */ - +/* Generated configuration header file - do not edit */ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +* this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* File Name : r_bsp_config_reference.h +* H/W Platform : GENERIC_RL78_G22 +* Description : +***********************************************************************************************************************/ +/*********************************************************************************************************************** +* History : DD.MM.YYYY Version Description +* : 20.04.2022 1.50 First Release +***********************************************************************************************************************/ + +#ifndef R_BSP_CONFIG_REF_HEADER_FILE +#define R_BSP_CONFIG_REF_HEADER_FILE +/************************************************* + * MCU information + *************************************************/ +/* + R 7 F 102G G E 3 xxx C FB #AA0 + | | | | | | | | | | |__not used Packaging specification + | | | | | | | | | |_____not used Package type + | | | | | | | | |________not used Fields of application + | | | | | | | |___________not used ROM number(omitted with blank products) + | | | | | | |______________not used Ambient operating temperature range + | | | | | |________________BSP_CFG_MCU_PART_ROM_SIZE ROM capacity + | | | | |__________________BSP_CFG_MCU_PART_PIN_NUM Pin count + | | | |______________________not used RL78/G22 + | | |_________________________BSP_CFG_MCU_PART_ROM_TYPE Device type + | |___________________________not used Renesas MCU + |_____________________________not used Renesas semiconductor product +*/ + +/* ROM capacity + C = 32(KB) : 0x0 + E = 64 : 0x1 +*/ +#define BSP_CFG_MCU_PART_ROM_SIZE (0x1) /* Generated value. Do not edit this manually */ + +/* Pin count + 4 = 16-pin : 0x0 + 6 = 20-pin : 0x1 + 7 = 24-pin : 0x2 + 8 = 25-pin : 0x3 + A = 30-pin : 0x4 + B = 32-pin : 0x5 + C = 36-pin : 0x6 + E = 40-pin : 0x7 + F = 44-pin : 0x8 + G = 48-pin : 0x9 +*/ +#define BSP_CFG_MCU_PART_PIN_NUM (0x9) /* Generated value. Do not edit this manually */ + +/* group + 102G = RL78/G22 : (true) +*/ +#define BSP_CFG_MCU_PART_HAS_DATA_FLASH (true) + +/* Device type + F = Flash memory : 0 +*/ +#define BSP_CFG_MCU_PART_ROM_TYPE (0) + +#if defined(__ICCRL78__) +/* Option byte setting(When using IAR) */ +#define BSP_CFG_OPTBYTE0_VALUE (0xEFU) /* Generated value. Do not edit this manually */ +#define BSP_CFG_OPTBYTE1_VALUE (0x7FU) /* Generated value. Do not edit this manually */ +#define BSP_CFG_OPTBYTE2_VALUE (0xE8U) /* Generated value. Do not edit this manually */ +#define BSP_CFG_OPTBYTE3_VALUE (0x04U) /* Generated value. Do not edit this manually */ +/* Security ID Codes for On-Chip Debugging setting(When using IAR) */ +#define BSP_CFG_SECUID0_VALUE (0x00U) /* Generated value. Do not edit this manually */ +#define BSP_CFG_SECUID1_VALUE (0x00U) /* Generated value. Do not edit this manually */ +#define BSP_CFG_SECUID2_VALUE (0x00U) /* Generated value. Do not edit this manually */ +#define BSP_CFG_SECUID3_VALUE (0x00U) /* Generated value. Do not edit this manually */ +#define BSP_CFG_SECUID4_VALUE (0x00U) /* Generated value. Do not edit this manually */ +#define BSP_CFG_SECUID5_VALUE (0x00U) /* Generated value. Do not edit this manually */ +#define BSP_CFG_SECUID6_VALUE (0x00U) /* Generated value. Do not edit this manually */ +#define BSP_CFG_SECUID7_VALUE (0x00U) /* Generated value. Do not edit this manually */ +#define BSP_CFG_SECUID8_VALUE (0x00U) /* Generated value. Do not edit this manually */ +#define BSP_CFG_SECUID9_VALUE (0x00U) /* Generated value. Do not edit this manually */ +#endif + +/************************************************* + * Pin assignment setting + *************************************************/ +/* Peripheral I/O redirection register(PIOR-PIOR0) + 48/44-pin + 0 : TI02/TO02 - P17 + TI03/TO03 - P31 + TI04/TO04 - - + TI05/TO05 - - + TI06/TO06 - - + TI07/TO07 - P41 + 1 : TI02/TO02 - P15 + TI03/TO03 - P14 + TI04/TO04 - P13 + TI05/TO05 - P12 + TI06/TO06 - P11 + TI07/TO07 - P10 + + 40/36/32/30-pin + 0 : TI02/TO02 - P17 + TI03/TO03 - P31 + TI04/TO04 - - + TI05/TO05 - - + TI06/TO06 - - + TI07/TO07 - - + 1 : TI02/TO02 - P15 + TI03/TO03 - P14 + TI04/TO04 - P13 + TI05/TO05 - P12 + TI06/TO06 - P11 + TI07/TO07 - P10 +*/ +// 2022/11/11 +#define BSP_CFG_PIOR0 (0) /* Generated value. Do not edit this manually */ + +/* Peripheral I/O redirection register(PIOR-PIOR1) + 48/44/40/36/32/30-pin + 0 : TxD2 - P13 + RxD2 - P14 + SCL20 - P15 + SDA20 - P14 + SI20 - P14 + SO20 - P13 + SCK20 - P15 + TxD0 - P12 + RxD0 - P11 + SCL00 - P10 + SDA00 - P11 + SI00 - P11 + SO00 - P12 + SCK00 - P10 + 1 : TxD2 - - + RxD2 - - + SCL20 - - + SDA20 - - + SI20 - - + SO20 - - + SCK20 - - + TxD0 - P17 + RxD0 - P16 + SCL00 - - + SDA00 - - + SI00 - - + SO00 - - + SCK00 - - +*/ +#define BSP_CFG_PIOR1 (0) /* Generated value. Do not edit this manually */ + +/* Peripheral I/O redirection register(PIOR-PIOR2) + 48/44/40/36/32/30-pin + 0 : SCLA0 - P60 + SDAA0 - P61 + 1 : SCLA0 - P14 + SDAA0 - P13 +*/ +#define BSP_CFG_PIOR2 (0) /* Generated value. Do not edit this manually */ + +/* Peripheral I/O redirection register(PIOR-PIOR3) + 48-pin + 0 : PCLBUZ0 - P140 + 1 : PCLBUZ0 - P31 + + 44/40/36/32/30-pin + 0 : PCLBUZ0 - - + 1 : PCLBUZ0 - - +*/ +#define BSP_CFG_PIOR3 (0) /* Generated value. Do not edit this manually */ + +/*********************************************************** + * Invalid memory access detection control register (IAWCTL) + ***********************************************************/ +/* Control of illicit memory access detection(IAWEN) + 0 : Disables the detection of illicit memory accesses. + 1 : Enables the detection of illicit memory accesses. +*/ +#define BSP_CFG_INVALID_MEMORY_ACCESS_DETECTION_ENABLE (0) + +/* Protected area in the RAM(GRAM0-1) + 0 : Disabled. Writing to the RAM is allowed. + 1 : 128 bytes from the base address of the RAM. + 2 : 256 bytes from the base address of the RAM. + 3 : 512 bytes from the base address of the RAM. +*/ +#define BSP_CFG_RAM_GUARD_FUNC (0) + +/* Protection of the port control registers(GPORT) + 0 : Disabled. Reading from and writing to the port control registers are allowed. + 1 : Enabled. Writing to the port control registers is not allowed. Reading from them is allowed. + [Protected SFRs] PMxx, PUxx, PIMxx, POMxx, PMCAxx, PMCTxx, PFOE1, PDIDISxx +*/ +#define BSP_CFG_PORT_FUNCTION_GUARD (0) + +/* Protection of the interrupt control registers(GINT) + 0 : Disabled. Reading from and writing to the interrupt control registers are allowed. + 1 : Enabled. Writing to the interrupt control registers is not allowed. Reading from them is allowed. + [Protected SFRs] IFxx, MKxx, PRxx, EGPx, EGNx +*/ +#define BSP_CFG_INT_FUNCTION_GUARD (0) + +/* Protection of the clock, voltage detector, and RAM parity error detection control registers(GCSC) + 0 : Disabled. Reading from and writing to the clock, voltage detector, and RAM parity error + detection control registers are allowed. + 1 : Enabled. Writing to the clock, voltage detector, and RAM parity error detection control registers + is not allowed. Reading from them is allowed. + [Protected SFRs] CMC, CSC, OSTS, CKC, PERx, OSMC, LVIM, LVIS, RPECTL, + CKSEL, PRRx, MOCODIV, WKUPMD +*/ +#define BSP_CFG_CHIP_STATE_CTRL_GUARD (0) + +/************************************************* + * Data flash + *************************************************/ +/* Data flash memory area access control + Data flash control register(DFLCTL) + DFLEN + 0 : Access to the data flash memory area is disabled. + 1 : Access to the data flash memory area is enabled. +*/ +#define BSP_CFG_DATA_FLASH_ACCESS_ENABLE (0) + +/************************************************* + * Definition for switching functions + *************************************************/ +/* Start up select + 0 : Enable BSP startup program. + 1 : Disable BSP startup program.(e.g. Using user startup program.) +*/ +#define BSP_CFG_STARTUP_DISABLE (0) + +/* Initialization of peripheral functions by Code Generator/Smart Configurator + 0 : Disable initialization of peripheral functions by Code Generator/Smart Configurator. + 1 : Enable initialization of peripheral functions by Code Generator/Smart Configurator. +*/ +#define BSP_CFG_CONFIGURATOR_SELECT (1) + +/* Version number of Smart Configurator. + This macro definitions is updated by Smart Configurator. + If you are using e2studio, set the following values. + 2021-04 : 1001 + 2021-07 : 1010 + 2021-10 : 1010 + 2022-01 : 1030 + If you are using the standalone version of Smart Configurator, + set the following values. + v1.0.1 : 1001 + v1.1.0 : 1010 + v1.3.0 : 1030 +*/ +#define BSP_CFG_CONFIGURATOR_VERSION (1030) /* Generated value. Do not edit this manually */ + +/* API function disable(R_BSP_StartClock, R_BSP_StopClock) + 0 : Enable API functions + 1 : Disable API functions +*/ +#define BSP_CFG_CLOCK_OPERATION_API_FUNCTIONS_DISABLE (0) + +/* API function disable(R_BSP_GetFclkFreqHz) + 0 : Enable API functions + 1 : Disable API functions +*/ +#define BSP_CFG_GET_FREQ_API_FUNCTIONS_DISABLE (0) + +/* API function disable(R_BSP_SetClockSource) + 0 : Enable API functions + 1 : Disable API functions +*/ +#define BSP_CFG_SET_CLOCK_SOURCE_API_FUNCTIONS_DISABLE (0) + +/* API function disable(R_BSP_ChangeClockSetting) + 0 : Enable API functions + 1 : Disable API functions +*/ +#define BSP_CFG_CHANGE_CLOCK_SETTING_API_FUNCTIONS_DISABLE (0) + +/* Parameter check enable + 0 : Disable parameter check. + 1 : Enable parameter check. +*/ +#define BSP_CFG_PARAM_CHECKING_ENABLE (1) + +/************************************************* + * Clock settings + *************************************************/ +/* High-speed system clock pin operation mode + Clock operation mode control register(CMC) + (Products with 16 to 36 pins) + XTSEL/EXCLK/OSCSEL + (Products with 40 to 48 pins) + EXCLK/OSCSEL + 0 : Port mode + 1 : X1 oscillation mode + 2 : External clock input mode +*/ +#define BSP_CFG_HISYSCLK_SOURCE (0) /* Generated value. Do not edit this manually */ + +/* High-speed system clock operation control + Clock operation status control register(CSC) + MSTOP + (X1 oscillation mode) + 0 : The X1 oscillator runs. + 1 : The X1 oscillator is stopped. + (External clock input mode) + 0 : An external clock signal on the EXCLK pin is effective. + 1 : An external clock signal on the EXCLK pin is ineffective. + (Port mode) + 0 : I/O port + 1 : I/O port +*/ +#define BSP_CFG_HISYSCLK_OPERATION (1) /* Generated value. Do not edit this manually */ + +/* Subsystem clock pin operation mode + Clock operation mode control register(CMC) + (Products with 16 to 36 pins) + XTSEL/EXCLKS/OSCSELS + (Products with 40 to 48 pins) + EXCLKS/OSCSELS + 0 : Input port mode + 1 : XT1 oscillation mode +2 : External clock input mode +*/ +#define BSP_CFG_SUBCLK_SOURCE (1) /* Generated value. Do not edit this manually */ + +/* Subsystem clock operation control + Clock operation status control register(CSC) + XTSTOP + (XT1 oscillation mode) + 0 : The XT1 oscillator runs. + 1 : The XT1 oscillator is stopped. + (External clock input mode) + 0 : An external clock signal on the EXCLKS pin is effective. + 1 : An external clock signal on the EXCLKS pin is ineffective. + (Port mode) + 0 : Input port + 1 : Input port +*/ +#define BSP_CFG_SUBCLK_OPERATION (0) /* Generated value. Do not edit this manually */ + +/* Middle-speed on-chip oscillator clock operation control + Clock operation status control register(CSC) + MIOEN + 0 : The middle-speed on-chip oscillator is stopped. + 1 : The middle-speed on-chip oscillator runs. +*/ +#define BSP_CFG_MOCO_OPERATION (0) /* Generated value. Do not edit this manually */ + +/* Main on-chip oscillator clock(fOCO) operation control + System clock control register(CKC) + MCM1 + 0 : High-speed on-chip oscillator clock + 1 : Middle-speed on-chip oscillator clock +*/ +#define BSP_CFG_OCOCLK_SOURCE (0) /* Generated value. Do not edit this manually */ + +/* Main system clock(fMAIN) operation control + System clock control register(CKC) + MCM0 + 0 : Selects the main on-chip oscillator clock(fOCO) as the main system clock(fMAIN) + 1 : Selects the high-speed system clock(fMX) as the main system clock(fMAIN) +*/ +#define BSP_CFG_MAINCLK_SOURCE (0) /* Generated value. Do not edit this manually */ + +/* Selection of the subsystem clock X or low-speed on-chip oscillator clock + Subsystem clock select register(CKSEL) + SELLOSC + 0 : Subsystem clock X + 1 : Low-speed on-chip oscillator clock +*/ +#define BSP_CFG_SUBSYSCLK_SOURCE (0) /* Generated value. Do not edit this manually */ + +/* Selection of the CPU/peripheral hardware clock(fCLK) + System clock control register(CKC) + CSS + 0 : Main system clock(fMAIN) + 1 : Subsystem clock(fSUB) +*/ +#define BSP_CFG_FCLK_SOURCE (0) /* Generated value. Do not edit this manually */ + +/* Selection of the oscillation mode of the XT1 oscillator + Clock operation mode control register(CMC) + AMPHS1, AMPHS0 + 0 : Low power consumption oscillation 1(default) + 1 : Normal oscillation + 2 : Low power consumption oscillation 2 + 3 : Low power consumption oscillation 3 +*/ +#define BSP_CFG_XT1_OSCMODE (0) /* Generated value. Do not edit this manually */ + +/* Input clock frequency in Hz(High-speed system clock(X1)) +*/ +#define BSP_CFG_FMX_HZ (20000000) + +/* Control of the X1 clock oscillation frequency + Clock operation mode control register(CMC) + AMPH + 0 : 1 MHz <= fX <= 10 MHz + 1 : 10 MHz < fX <= 20 MHz + Set the value corresponding to the setting of BSP_CFG_FMX_HZ +*/ + +/* Selection of the oscillation stabilization time + Oscillation stabilization time select register(OSTS) + OSTS2, OSTS1, OSTS0 + 0 : 2^8/fX(fX = 10MHz : 25.6us, fX = 20MHz : 12.8us) + 1 : 2^9/fX(fX = 10MHz : 51.2us, fX = 20MHz : 25.6us) + 2 : 2^10/fX(fX = 10MHz : 102us, fX = 20MHz : 51.2us) + 3 : 2^11/fX(fX = 10MHz : 204us, fX = 20MHz : 102us) + 4 : 2^13/fX(fX = 10MHz : 819us, fX = 20MHz : 409us) + 5 : 2^15/fX(fX = 10MHz : 3.27ms, fX = 20MHz : 1.63ms) + 6 : 2^17/fX(fX = 10MHz : 13.1ms, fX = 20MHz : 6.55ms) + 7 : 2^18/fX(fX = 10MHz : 26.2ms, fX = 20MHz : 13.1ms) +*/ +#define BSP_CFG_X1_WAIT_TIME_SEL (0) + +/* Setting in STOP mode or in HALT mode while the CPU is operating with subsystem clock X. + Subsystem clock supply mode control register(OSMC) + RTCLPC + 0 : Enables supply of subsystem clock X to peripheral functions. + 1 : Stops supply of the subsystem clock to peripheral functions other than the realtime clock. +*/ +#define BSP_CFG_ALLOW_FSUB_IN_STOPHALT (0) /* Generated value. Do not edit this manually */ + +/* Selection of the operating clock for the realtime clock, 32-bit interval timer, + serial interface UARTA0, and clock output/buzzer output controller + Subsystem clock supply mode control register(OSMC) + WUTMMCK0 + 0 : Subsystem clock X + 1 : Low-speed on-chip oscillator clock +*/ +#define BSP_CFG_RTC_OUT_CLK_SOURCE (0) /* Generated value. Do not edit this manually */ + +/* Selection of the high-speed on-chip oscillator clock frequency + High-speed on-chip oscillator frequency select register(HOCODIV) + HOCODIV2, HOCODIV1, HOCODIV0 + + (FRQSEL3 = 0) + 0 : fIH = 24 MHz + 1 : fIH = 12 MHz + 2 : fIH = 6 MHz + 3 : fIH = 3 MHz + Other than above : Setting prohibited + + (FRQSEL3 = 1) + 0 : fIH = 32 MHz + 1 : fIH = 16 MHz + 2 : fIH = 8 MHz + 3 : fIH = 4 MHz + 4 : fIH = 2 MHz + 5 : fIH = 1 MHz + Other than above : Setting prohibited + */ +#define BSP_CFG_HOCO_DIVIDE (0) /* Generated value. Do not edit this manually */ + +/* Setting for starting the high-speed on-chip oscillator at the times of release from STOP mode + and of transitions to SNOOZE mode + Standby mode release setting register(WKUPMD) + FWKUP + 0 : Starting of the high-speed on-chip oscillator is at normal speed. + 1 : Starting of the high-speed on-chip oscillator is at high speed. +*/ +#define BSP_CFG_WAKEUP_MODE (0) /* Generated value. Do not edit this manually */ + +/* Selected division ratio for the high-speed system clock + High-speed system clock division register(MOSCDIV) + MOSCDIV2, MOSCDIV1, MOSCDIV0 + 0 : fMX (fMX = 20MHz : 20MHz) + 1 : fMX/2 (fMX = 20MHz : 10MHz) + 2 : fMX/4 (fMX = 20MHz : 5MHz) + 3 : fMX/8 (fMX = 20MHz : 2.5MHz) + 4 : fMX/16 (fMX = 20MHz : 1.25MHz) + Other than above : Setting prohibited +*/ +#define BSP_CFG_MOSC_DIVIDE (0) /* Generated value. Do not edit this manually */ + +/* Selection of the middle-speed on-chip oscillator clock frequency + Middle-speed on-chip oscillator frequency select register(MOCODIV) + MOCODIV1, MOCODIV0 + 0 : 4MHz + 1 : 2MHz + 2 : 1MHz + Other than above : Setting prohibited +*/ +#define BSP_CFG_MOCO_DIVIDE (0) /* Generated value. Do not edit this manually */ + +/* Operation setting at initial setting */ +/* Starts the high-speed on-chip oscillator at initialization + 0 : Stops the high-speed on-chip oscillator at initialization + 1 : Starts the high-speed on-chip oscillator at initialization +*/ +#define BSP_CFG_FIH_START_ON_STARTUP (1) /* Generated value. Do not edit this manually */ + +/* This macro lets other modules no if a RTOS is being used. + 0 : RTOS is not used. + 1 : FreeRTOS is used.(This is not available.) + 2 : embOS is used.(This is not available.) + 3 : MicroC_OS is used.(This is not available.) + 4 : Renesas ITRON is used. +*/ +#define BSP_CFG_RTOS_USED (0) + +/* Loop count using the main system clock. */ +/* The loop count refers to a loop consisting of a "for" statement that executes a single NOP instruction. */ +/* Subsystem clock oscillation stabilization wait time */ +/* If the main system clock is 32 MHz, 800000 means 550 ms. */ +#define BSP_CFG_SUBWAITTIME (800000U) + +/* High-speed on-chip oscillator clock oscillation stabilization wait time */ +/* If the main system clock 32 MHz, 30 means 22.7us. */ +#define BSP_CFG_FIHWAITTIME (30U) + +/* Middle-speed on-chip oscillator clock oscillation stabilization wait time. */ +/* If the main system clock 32 MHz, 5 means 4.8us. */ +#define BSP_CFG_FIMWAITTIME (5U) + +/* Low-speed on-chip oscillator clock oscillation stabilization wait time */ +/* If the main system clock 32 MHz, 450 means 325us. */ +#define BSP_CFG_FILWAITTIME (450U) + +/* If the user would like to determine if a warm start reset has occurred, then they may enable one or more of the + following callback definitions AND provide a call back function name for the respective callback + function (to be defined by the user). Setting BSP_CFG_USER_WARM_START_CALLBACK_PRE_INITC_ENABLED = 1 will result + in a callback to the user defined my_sw_warmstart_prec_function just prior to the initialization of the C + runtime environment by bsp_init_system. + Setting BSP_CFG_USER_WARM_START_CALLBACK_POST_INITC_ENABLED = 1 will result in a callback to the user defined + my_sw_warmstart_postc_function just after the initialization of the C runtime environment by bsp_init_hardware. +*/ +#define BSP_CFG_USER_WARM_START_CALLBACK_PRE_INITC_ENABLED (0) +#define BSP_CFG_USER_WARM_START_PRE_C_FUNCTION my_sw_warmstart_prec_function + +#define BSP_CFG_USER_WARM_START_CALLBACK_POST_INITC_ENABLED (0) +#define BSP_CFG_USER_WARM_START_POST_C_FUNCTION my_sw_warmstart_postc_function + +/* If the user sets the window open period of watchdog timer to 50%, + set the following macro definition(BSP_CFG_WDT_REFRESH_ENABLE) to 2 + and specify the callback function name for each callback function(to be defined by the user). + Setting BSP_CFG_WDT_REFRESH_ENABLE == 2 will result in a callback to the user defined + my_sw_wdt_refresh_init_function just prior to the clock is set by bsp_init_system. + In addition, a callback to the user defined my_sw_wdt_refresh_setting_function occurs + during the oscillation stabilization wait time od the subsystem clock. +*/ +#define BSP_CFG_WDT_REFRESH_ENABLE (0) +#define BSP_CFG_USER_WDT_REFRESH_INIT_FUNCTION my_sw_wdt_refresh_init_function +#define BSP_CFG_USER_WDT_REFRESH_SETTING_FUNCTION my_sw_wdt_refresh_setting_function + +#endif /* R_BSP_CONFIG_REF_HEADER_FILE */ + diff --git a/cores/rl78g22/smc_gen/r_config/r_bsp_config.inc b/cores/rl78g22/smc_gen/r_config/r_bsp_config.inc index 077802a..535f8ae 100644 --- a/cores/rl78g22/smc_gen/r_config/r_bsp_config.inc +++ b/cores/rl78g22/smc_gen/r_config/r_bsp_config.inc @@ -1,37 +1,37 @@ -; Generated configuration header file - do not edit -;;/*********************************************************************************************************************** -;;* DISCLAIMER -;;* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No -;;* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all -;;* applicable laws, including copyright laws. -;;* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING -;;* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, -;;* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM -;;* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES -;;* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS -;;* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -;;* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of -;;* this software. By using this software, you agree to the additional terms and conditions found by accessing the -;;* following link: -;;* http://www.renesas.com/disclaimer -;;* -;;* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. -;;***********************************************************************************************************************/ -;;/*********************************************************************************************************************** -;;* File Name : r_bsp_config_reference.inc -;;* H/W Platform : GENERIC_RL78_G22 -;;* Description : -;;***********************************************************************************************************************/ -;;/*********************************************************************************************************************** -;;* History : DD.MM.YYYY Version Description -;;* : 20.04.2022 1.50 First Release -;;* -;;***********************************************************************************************************************/ - -.ifdef __r_bsp_config_inc__ -.else - -.equ __r_bsp_config_inc__,(1) -.equ BSP_CFG_ASM_RTOS_USED, (0) - -.endif +; Generated configuration header file - do not edit +;;/*********************************************************************************************************************** +;;* DISCLAIMER +;;* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No +;;* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +;;* applicable laws, including copyright laws. +;;* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING +;;* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, +;;* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM +;;* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES +;;* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS +;;* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +;;* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of +;;* this software. By using this software, you agree to the additional terms and conditions found by accessing the +;;* following link: +;;* http://www.renesas.com/disclaimer +;;* +;;* Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. +;;***********************************************************************************************************************/ +;;/*********************************************************************************************************************** +;;* File Name : r_bsp_config_reference.inc +;;* H/W Platform : GENERIC_RL78_G22 +;;* Description : +;;***********************************************************************************************************************/ +;;/*********************************************************************************************************************** +;;* History : DD.MM.YYYY Version Description +;;* : 20.04.2022 1.50 First Release +;;* +;;***********************************************************************************************************************/ + +.ifdef __r_bsp_config_inc__ +.else + +.equ __r_bsp_config_inc__,(1) +.equ BSP_CFG_ASM_RTOS_USED, (0) + +.endif diff --git a/cores/rl78g22/utilities.cpp b/cores/rl78g22/utilities.cpp index 1cb56bf..24c4ac1 100644 --- a/cores/rl78g22/utilities.cpp +++ b/cores/rl78g22/utilities.cpp @@ -1,674 +1,686 @@ -#include "wiring_private.h" -#include "wiring_variant.h" -#include "pins_arduino.h" -#include "pintable.h" -#include "r_cg_interrupt_handlers.h" - -#define ADS_TEMP_SENSOR (0x80) -#define ADS_REF_VOLTAGE (0x81) - -uint8_t g_u8ResetFlag; -uint8_t g_u8PowerManagementMode = PM_NORMAL_MODE; -uint8_t g_u8OperationClockMode = CLK_HIGH_SPEED_MODE; - -extern uint8_t g_u8ResetFlag; -extern uint8_t g_u8PowerManagementMode; -extern uint8_t g_u8OperationClockMode; -extern volatile unsigned long g_u32delay_timer; - -extern uint8_t g_delay_cnt_flg; -extern uint8_t g_delay_cnt_micros_flg; -extern volatile unsigned long g_u32delay_micros_timer; - -extern uint16_t g_u16ADUL; -extern uint16_t g_u16ADLL; - -// Add 20221005 -volatile unsigned long g_u32timer_periodic = 0u; // ms周期処理用インターバルタイマ変数 -volatile unsigned long g_u32microtimer_periodic = 0u; // us周期処理用インターバルタイマ変数 - -// void (*INT_TM_HOOK)() ; - -extern "C" { -#include "r_smc_entry.h" -// #include "Config_TAU0_7_MSTimer2.h" -} - - -// 周期起動ハンドラ関数テーブル -static struct { - fITInterruptFunc_t afCyclicHandler; - uint32_t au32CyclicTime; - uint32_t au32RemainTime; - uint32_t au32LastTime; -} g_CyclicHandlerTable[MAX_CYCLIC_HANDLER] = { - {NULL, 0, 0, 0}, -}; -fITInterruptFunc_t g_fITInterruptFunc = NULL; //!< ユーザー定義インターバルタイマハンドラ - -fInterruptFunc_t g_fMicroInterruptFunc = NULL; - - -/** - * タイマーアレイユニットの停止 - * -* @return なし - * - * @attention なし - ***************************************************************************/ -void _stopTAU0() -{ - // タイマ・アレイ・ユニットが動作しているか? - if (TAU0EN != 0) { - if (TE0 == 0x00000) { -#ifdef WORKAROUND_READ_MODIFY_WRITE - CBI2(SFR2_PER0, SFR2_BIT_TAU0EN);// タイマ・アレイ・ユニットにクロック供 -#else /* WORKAROUND_READ_MODIFY_WRITE*/ - TAU0EN = 0; // タイマ・アレイ・ユニットにクロック供給停止 -#endif - } - } -} - -/** - * タイマー周期の変更 - * - * @param[in] u8Timer 変更するタイマ番号 - * - * @return なし - * - * @attention なし - ***************************************************************************/ -void _modifyTimerPeriodic(uint8_t u8TimerChannel, uint16_t u16Interval) -{ - switch (u8TimerChannel) { - case 1: - TDR01 = u16Interval; // インターバル(周期)の設定 - break; - - case 2: - TDR02 = u16Interval; // インターバル(周期)の設定 - break; - - case 3: - TDR03 = u16Interval; // インターバル(周期)の設定 - break; - - case 4: - TDR04 = u16Interval; // インターバル(周期)の設定 - break; - - case 5: - TDR05 = u16Interval; // インターバル(周期)の設定 - break; - - case 6: - TDR06 = u16Interval; // インターバル(周期)の設定 - break; - - case 7: - TDR07 = u16Interval; // インターバル(周期)の設定 - break; - } - -} - -/** - * タイマーチャンネルの停止 - * - * @param[in] u8Timer 停止するタイマ番号 - * - * @return なし - * - * @attention なし - ***************************************************************************/ -void _stopTimerChannel(uint8_t u8TimerChannel) -{ - TT0 |= (1 << u8TimerChannel); // タイマ動作停止 - TOE0 &= ~(1 << u8TimerChannel); // タイマ出力禁止の設定 - TO0 &= ~(1 << u8TimerChannel); // タイマ出力の設定 - // 割り込みマスクを禁止に設定 - switch (u8TimerChannel) { - case 1: TMMK01 = 1; break; - case 2: TMMK02 = 1; break; - case 3: TMMK03 = 1; break; - case 4: TMMK04 = 1; break; - case 5: TMMK05 = 1; break; - case 6: TMMK06 = 1; break; - case 7: TMMK07 = 1; break; - } - if (!(TE0 & 0x009E)) { - TT0 |= 0x0001; // Master チャンネルの停止 - } -} - -/** - * Software Reset - * - * Generate software reset. - * - * @return なし - * - * @attention: This function uses trap instruction. - * So RESF register in MCU is set to 0x80 after reset. - * Unable to use when using debugger. - * - ***************************************************************************/ - -void softwareReset(void) { - __asm __volatile(" .byte 0xff"); -} - -/** - * Get Reset Flag - * - * Get the flag why reset occur. - * - * @return 0x00: External reset or Power on reset - * 0x01: Low voltage detection - * 0x02: Illegal memory access - * 0x04: RAM parity error ( read from no initialized area ) - * 0x10: Watch dog timer - * 0x80: Illegal instruction - * - * @attention: - * - ***************************************************************************/ - -uint8_t getResetFlag() { - return g_u8ResetFlag; -} - -/** - * RLduino78のバージョン情報を取得します。 - * - * @return バージョン情報を返却します。 - * - * @attention なし - ***************************************************************************/ -uint16_t getVersion() -{ - return RLDUINO78_VERSION; -} - -#define USE_POWER_MANAGEMENT (1) // Set 1 when issue was solved. //KAD change from 0 to 1 - -#if USE_POWER_MANAGEMENT == 1 -/** @} group14 その他 */ - -/** ************************************************************************ - * @defgroup group15 パワーマネージメント/クロック制御関数 - * - * @{ - ***************************************************************************/ -/** - * パワーマネージメントモードを取得します。 - * - * 現在のパワーマネージメントモードを取得します。 - * - 通常モード:PM_NORMAL_MODE - * - 省電力(HALT)モード:PM_HALT_MODE - * - 省電力(STOP)モード:PM_STOP_MODE - * - 省電力(SNOOZE)モード:PM_SNOOZE_MODE - * - * @return パワーマネージメントモードを返却します。 - * - * @attention なし - ***************************************************************************/ -uint8_t getPowerManagementMode() -{ - return g_u8PowerManagementMode; -} - -/** - * パワーマネージメントモードを設定します。 - * - * パワーマネージメントモードを設定します。 - * - 通常モード:PM_NORMAL_MODE - * - 省電力(HALT)モード :PM_HALT_MODE - * - 省電力(STOP)モード :PM_STOP_MODE - * - 省電力(SNOOZE)モード:PM_SNOOZE_MODE - * - * パワーマネージメントモードに省電力(HALT/STOP/SNOOZE)モードを指定して delay() - * 関数を呼び出すと、一時停止期間中はHALT/STOP命令によりスタンバイ状態になります。 - * また、パワーマネージメントモードに省電力(SNOOZE)モード指定して、 analogRead() - * 関数を呼び出すと、SNOOZE状態になります。 - * - * @param[in] u8PowerManagementMode パワーマネージメントモードを指定します。 - * @param[in] u16ADLL A/D変換結果範囲の下限値を指定します。省略した場合デフォルト値(0)が設定されます。 - * @param[in] u16ADUL A/D変換結果範囲の上限値を指定します。省略した場合デフォルト値(1023)が設定されます。 - * - * @return なし - * - * @attention - * - 動作クロックの状態によっては、パワーマネージメントモードが変更されない - * 場合があります。 - * - A/D変換結果下限値/上限値には0から1023の範囲を指定してください。 - * なお、下限値/上限値の下位2bitは無視されます。 - ***************************************************************************/ -void setPowerManagementMode(uint8_t u8PowerManagementMode, uint16_t u16ADLL, uint16_t u16ADUL) -{ - - switch (u8PowerManagementMode) { - case PM_NORMAL_MODE: - case PM_HALT_MODE: - g_u16ADLL = 0; - g_u16ADUL = 1023; - g_u8PowerManagementMode = u8PowerManagementMode; - break; - - case PM_STOP_MODE: - if (CLS == 0) { - g_u16ADLL = 0; - g_u16ADUL = 1023; - g_u8PowerManagementMode = u8PowerManagementMode; - } - break; - - case PM_SNOOZE_MODE: - if ((CLS == 0) && (MCS == 0)) { - if (u16ADLL > 1023) { - u16ADLL = 1023; - } - if (u16ADUL > 1023) { - u16ADUL = 1023; - } - if (u16ADLL > u16ADUL) { - u16ADLL = 0; - u16ADUL = 1023; - } - g_u16ADLL = u16ADLL; - g_u16ADUL = u16ADUL; - g_u8PowerManagementMode = u8PowerManagementMode; - } - break; - - default: - break; - } -} - - -/** - * 動作クロックモードを取得します。 - * - * CPU/周辺ハードウェアの動作クロックモードを取得します。 - * - 高速動作モード(高速オンチップ・オシレータ):CLK_HIGH_SPEED_MODE - * - 低速動作モード(XT1発信回路) :CLK_LOW_SPEED_MODE - * - * @return 動作クロックモードを返却します。 - * - * @attention なし - ***************************************************************************/ -uint8_t getOperationClockMode() -{ - return g_u8OperationClockMode; -} - - -/** - * 動作クロックを設定します。 - * - * CPU/周辺ハードウェアの動作クロックを設定します。 - * - 高速動作モード(高速オンチップ・オシレータ):CLK_HIGH_SPEED_MODE - * - 低速動作モード(XT1発信回路) :CLK_LOW_SPEED_MODE - * - * 高速動作モードを指定すると、CPU/周辺ハードウェアに供給するクロックに - * メイン・システム・クロック(高速オンチップ・オシレータ)を設定します。 - * 低速動作モードを指定すると、CPU/周辺ハードウェアに供給するクロックに - * サブシステム・クロック(XT1発信回路)を設定します。 - * - * @param[in] u8ClockMode 動作クロックを指定します。 - * - * @return なし - * - * @attention - * - パワーマネージメントモードが省電力(STOP/SNOOZE)の場合は低速動作モード - * を設定することができません。 - * - GR-KURUMIの場合、高速動作モード(CLK_HIGH_SPEED_MODE)を指定すると - * 32 MHzで動作し、低速動作モード(CLK_LOW_SPEED_MODE)を指定すると 32.768 - * kHzで動作します。 - ***************************************************************************/ -void setOperationClockMode(uint8_t u8ClockMode) -{ - if (g_u8OperationClockMode == u8ClockMode) - { - // If there is no change from the existing mode, it will not be processed. - return; - } - else - if (u8ClockMode == CLK_HIGH_SPEED_MODE) - { - // The high-speed on-chip oscillator starts operating. - R_BSP_StartClock (HIOCLK); - // Switch to a high-speed on-chip oscillator. - if (BSP_OK == R_BSP_SetClockSource (HIOCLK)) - { - g_u8OperationClockMode = CLK_HIGH_SPEED_MODE; - } - else - { - /* not implementation */ - } - } - else - if (u8ClockMode == CLK_LOW_SPEED_MODE) - { - // Stops the operation of the high-speed on-chip oscillator. - R_BSP_StopClock (HIOCLK); - // Switch to a low-speed on-chip oscillator. - if (BSP_OK == R_BSP_SetClockSource (LOCLK)) - { - g_u8OperationClockMode = CLK_LOW_SPEED_MODE; - } - else - { - /* not implementation */ - } - } - -} -/** @} group15 パワーマネージメント/クロック制御関数 */ -#endif // USE_POWER_MANAGEMENT == 1 - - -// ************************************************************************* -// * @defgroup group16 割込みハンドラ/周期起動関数 -// * -// * @{ -// ************************************************************************** - -/* - * インターバル・タイマ割り込みハンドラ内から実行するコールバック関数を登録します。 - * - * コールバック関数を登録すると1[ms]のインターバル・タイマ割り込み毎に登録した - * コールバック関数が呼び出されます。また、コールバック関数呼び出し時にはシステム - * 開始からの時間(ms)が引数として渡されます。 - * - * @param[in] fFunction インターバル・タイマ割り込み時に実行するハンドラを指定します。 - * - * @return なし - * - * @attention - * - コールバック関数内では時間のかかる処理は行わないでください。 - * - コールバック関数内では以下の関数が呼び出し可能です。 - * - * pinMode()、 digitalWrite()、 digitalRead()、 millis()、 micros()、 delayMicroseconds()、 - * min()、 max()、 constrain()、 map()、 lowByte()、 highByte()、 bitRead()、 bitWrite()、 - * bitSet()、 bitClear()、 bit()、 randomSeed()、 random() - * - pinMode()関数と digitalWrite()関数は、 loop()関数内とコールバック関数内で同じピン - * 番号を指定すると誤動作する可能性があります。 - ************************************************************************** */ - -void attachIntervalTimerHandler(void (*fFunction)(unsigned long u32Milles)) -{ - g_fITInterruptFunc = fFunction; -} - -/** - * インターバル・タイマ割り込みハンドラ内から実行するコールバック関数の登録を解除します。 - * - * @return なし - * - * @attention なし - ***************************************************************************/ -void detachIntervalTimerHandler() -{ - g_fITInterruptFunc = NULL; -} - -void attachMicroIntervalTimerHandler(void (*fFunction)(void), uint16_t interval) -{ - g_fMicroInterruptFunc = fFunction; -// R_Config_TAU0_7_MSTimer2_Create(); -// R_Config_TAU0_7_MSTimer2_SetPeriod(interval); -// R_Config_TAU0_7_MSTimer2_Start(); -} - - -/** - * 周期起動コールバック関数を登録します。 - * - * 登録したコールバック関数は、u32CyclicTimeで指定した周期間隔[ms]で呼び出されます。 - * また、コールバック関数呼び出し時にはシステム開始からの時間(ms)が引数として渡されます。 - * - * @param[in] u8HandlerNumber 周期起動コールバック関数の識別番号(0~7)を指定します。 - * @param[in] fFunction インターバル・タイマ割り込み時に実行するハンドラを指定します。 - * @param[in] u32CyclicTime 周期起動する間隔[ms]を指定します。 - * - * @return なし - * - * @attention なし - ***************************************************************************/ -void attachCyclicHandler(uint8_t u8HandlerNumber, void (*fFunction)(unsigned long u32Milles), uint32_t u32CyclicTime) -{ - if (u8HandlerNumber < MAX_CYCLIC_HANDLER) { - detachCyclicHandler(u8HandlerNumber); - g_CyclicHandlerTable[u8HandlerNumber].au32CyclicTime = u32CyclicTime; - g_CyclicHandlerTable[u8HandlerNumber].au32RemainTime = u32CyclicTime; - g_CyclicHandlerTable[u8HandlerNumber].au32LastTime = millis(); - g_CyclicHandlerTable[u8HandlerNumber].afCyclicHandler = fFunction; - } -} - - -/** - * 周期起動コールバック関数の登録を解除します。 - * - * @param[in] u8HandlerNumber 周期起動コールバック関数の識別番号( 0 ~ 7 )を指定します。 - * - * @return なし - * - * @attention - ***************************************************************************/ -void detachCyclicHandler(uint8_t u8HandlerNumber) -{ - if (u8HandlerNumber < MAX_CYCLIC_HANDLER) { - g_CyclicHandlerTable[u8HandlerNumber].afCyclicHandler = NULL; - g_CyclicHandlerTable[u8HandlerNumber].au32CyclicTime = 0; - g_CyclicHandlerTable[u8HandlerNumber].au32RemainTime = 0; - g_CyclicHandlerTable[u8HandlerNumber].au32LastTime = 0; - } -} - -extern "C" { -/** - * 周期起動コールバック関数を起動します。 - * - * @return なし - * - * @attention - ***************************************************************************/ -void execCyclicHandler(void) -{ - int i; - - for (i = 0; i < MAX_CYCLIC_HANDLER; i++) { - if (g_CyclicHandlerTable[i].afCyclicHandler != NULL) { - unsigned long currentTime = millis(); - unsigned long elapsedTime = currentTime - g_CyclicHandlerTable[i].au32LastTime; - g_CyclicHandlerTable[i].au32LastTime = currentTime; - bool exec = g_CyclicHandlerTable[i].au32RemainTime <= elapsedTime; - g_CyclicHandlerTable[i].au32RemainTime -= elapsedTime; - if (exec) { - g_CyclicHandlerTable[i].au32RemainTime += g_CyclicHandlerTable[i].au32CyclicTime; - g_CyclicHandlerTable[i].afCyclicHandler(currentTime); - } - } - } -} - -} - -/** - * MCUに内蔵されている温度センサから温度(摂氏/華氏)を取得します。 - * - * @param[in] u8Mode 摂氏/華氏を指定します。 - * @arg TEMP_MODE_CELSIUS : 摂氏 - * @arg TEMP_MODE_FAHRENHEIT : 華氏 - * - * @return 温度を返却します。 - * - ***************************************************************************/ -int getTemperature(uint8_t u8Mode) -{ - extern uint8_t g_adc_int_flg; - uint8_t u8count; - uint16_t u16temp; - uint16_t u16temp1; //温度センサ出力の値を入れる変数 - uint16_t u16temp2; //内部基準電圧出力の値を入れる変数 - int32_t s32Temp; - int s16Result = 0; - - //温度センサ出力電圧で値を取得するためのレジスタの設定をします。 - R_Config_ADC_Set_TemperatureSensor(); - - R_Config_ADC_Set_OperationOn(); - - for (u8count = 0; u8count < 2; u8count ++) - { - g_adc_int_flg = 0; - R_Config_ADC_Start(); - while(1) - { - if(g_adc_int_flg == 1) - { - R_Config_ADC_Get_Result_10bit(&u16temp); - u16temp1 = u16temp;//温度センサ出力の値を入れる - g_adc_int_flg = 0; - break; - } - } - - } - - u8count = 0; - //内部基準電圧出力で値を取得します。 - R_Config_ADC_Set_InternalReferenceVoltage(); - R_Config_ADC_Set_OperationOn(); - - for (u8count = 0; u8count < 2; u8count ++) - { - g_adc_int_flg = 0; - R_Config_ADC_Start(); - while(1) - { - if(g_adc_int_flg == 1) - { - R_Config_ADC_Get_Result_10bit(&u16temp); - u16temp2 = u16temp;//内部基準電圧出力の値を入れる - g_adc_int_flg = 0; - break; - } - } - } - - //取得した値を使用し、温度を導きます。 - volatile long n14800L = 14800L; - s32Temp = n14800L *u16temp1 / u16temp2 - 10500L; - if (u8Mode == TEMP_MODE_FAHRENHEIT) - { - //華氏 - s16Result = s32Temp / -33 * 18 / 10; - s16Result += 77; - } - else - { - //摂氏 - s16Result = s32Temp / -33; - s16Result += 25; - } - return s16Result; - -} - -void enterPowerManagementMode(unsigned long u32ms) -{ - uint8_t u8PMmode; - - /* Check the set power saving mode and the status of RL78, - and determine the instruction that can be actually issued. - */ - u8PMmode = g_u8PowerManagementMode; - - if (u32ms == 0xFFFFFFFF) - { -// ITLMK = 1; // Mask Interval Timer - /* When the interrupt of TML32 is masked and the mode is changed to STOP mode, - the interrupt mask is not applied as a temporary measure because the - implementation that clears ITLS0 to 0 has not been completed. - */ - _STOP(); -// ITLMK = 0; // Unmask Interval Timer - } - else - { - if (1U == g_delay_cnt_flg) - { - while (g_u32delay_timer < u32ms) { - if (u8PMmode == PM_STOP_MODE) { - _STOP(); - } - else if (u8PMmode == PM_HALT_MODE){ - _HALT(); - } - else - { - NOP(); - } - } - } - else - if (1U == g_delay_cnt_micros_flg) - { - while (g_u32delay_micros_timer < u32ms) { - if (u8PMmode == PM_STOP_MODE) { - _STOP(); - } - else if (u8PMmode == PM_HALT_MODE){ - _HALT(); - } - else - { - NOP(); - } - } - } - } -} - -/* リセット要因の読み出し */ -void _readResetFlag() -{ - uint8_t resetflag; - - resetflag = RESF; - RESF = 0x00; - - if(resetflag == 0x80) /* 不正命令の実行によるリセット */ - { - g_u8ResetFlag = 0x80; - } - else if(resetflag == 0x10) /* ウォッチドックタイマによるリセット */ - { - g_u8ResetFlag = 0x10; - } - else if(resetflag == 0x04) /* RAMパリティエラーによるリセット */ - { - g_u8ResetFlag = 0x04; - } - else if(resetflag == 0x02) /* 不正メモリアクセスによるリセット */ - { - g_u8ResetFlag = 0x02; - } - else if(resetflag == 0x01) /* 低電圧検出によるリセット */ - { - g_u8ResetFlag = 0x01; - } - else /* 外部リセットorパワーオンリセットによるリセット */ - { - g_u8ResetFlag = 0x00; - } - - return; -} - +#include "wiring_private.h" +#include "wiring_variant.h" +#include "pins_arduino.h" +#include "pintable.h" +#include "r_cg_interrupt_handlers.h" + +extern "C" { +// #include "Config_ITL013.h" +} + +#define ADS_TEMP_SENSOR (0x80) +#define ADS_REF_VOLTAGE (0x81) + +uint8_t g_u8ResetFlag; +uint8_t g_u8PowerManagementMode = PM_NORMAL_MODE; +uint8_t g_u8OperationClockMode = CLK_HIGH_SPEED_MODE; + +extern uint8_t g_u8ResetFlag; +extern uint8_t g_u8PowerManagementMode; +extern uint8_t g_u8OperationClockMode; +extern volatile unsigned long g_u32delay_timer; + +extern uint8_t g_delay_cnt_flg; +extern uint8_t g_delay_cnt_micros_flg; +extern volatile unsigned long g_u32delay_micros_timer; + +extern uint16_t g_u16ADUL; +extern uint16_t g_u16ADLL; + +volatile unsigned long g_u32timer_periodic = 0u; // ms周期処理用インターバルタイマ変数 +#if 0 +volatile unsigned long g_u32microtimer_periodic = 0u; // us周期処理用インターバルタイマ変数 +#endif + +extern "C" { +#include "r_smc_entry.h" +} + + +// 周期起動ハンドラ関数テーブル +static struct { + fITInterruptFunc_t afCyclicHandler; + uint32_t au32CyclicTime; + uint32_t au32RemainTime; + uint32_t au32LastTime; +} g_CyclicHandlerTable[MAX_CYCLIC_HANDLER] = { + {NULL, 0, 0, 0}, +}; +fITInterruptFunc_t g_fITInterruptFunc = NULL; //!< ユーザー定義インターバルタイマハンドラ + +fInterruptFunc_t g_fMicroInterruptFunc = NULL; +#if 0 +extern volatile unsigned long g_u32timer_periodic; + +static void PeriodicMillisIntervalFunc() +{ + if (g_u32timer_periodic > 0) { + if (g_fITInterruptFunc) { + g_fITInterruptFunc(g_u32timer_periodic); + } + g_u32timer_periodic = 0; + } +} +#endif + +/** + * タイマーアレイユニットの停止 + * +* @return なし + * + * @attention なし + ***************************************************************************/ +void _stopTAU0() +{ + // タイマ・アレイ・ユニットが動作しているか? + if (TAU0EN != 0) { + if (TE0 == 0x00000) { +#ifdef WORKAROUND_READ_MODIFY_WRITE + CBI2(SFR2_PER0, SFR2_BIT_TAU0EN);// タイマ・アレイ・ユニットにクロック供 +#else /* WORKAROUND_READ_MODIFY_WRITE*/ + TAU0EN = 0; // タイマ・アレイ・ユニットにクロック供給停止 +#endif + } + } +} + +/** + * タイマー周期の変更 + * + * @param[in] u8Timer 変更するタイマ番号 + * + * @return なし + * + * @attention なし + ***************************************************************************/ +void _modifyTimerPeriodic(uint8_t u8TimerChannel, uint16_t u16Interval) +{ + switch (u8TimerChannel) { + case 1: + TDR01 = u16Interval; // インターバル(周期)の設定 + break; + + case 2: + TDR02 = u16Interval; // インターバル(周期)の設定 + break; + + case 3: + TDR03 = u16Interval; // インターバル(周期)の設定 + break; + + case 4: + TDR04 = u16Interval; // インターバル(周期)の設定 + break; + + case 5: + TDR05 = u16Interval; // インターバル(周期)の設定 + break; + + case 6: + TDR06 = u16Interval; // インターバル(周期)の設定 + break; + + case 7: + TDR07 = u16Interval; // インターバル(周期)の設定 + break; + } + +} + +/** + * タイマーチャンネルの停止 + * + * @param[in] u8Timer 停止するタイマ番号 + * + * @return なし + * + * @attention なし + ***************************************************************************/ +void _stopTimerChannel(uint8_t u8TimerChannel) +{ + TT0 |= (1 << u8TimerChannel); // タイマ動作停止 + TOE0 &= ~(1 << u8TimerChannel); // タイマ出力禁止の設定 + TO0 &= ~(1 << u8TimerChannel); // タイマ出力の設定 + // 割り込みマスクを禁止に設定 + switch (u8TimerChannel) { + case 1: TMMK01 = 1; break; + case 2: TMMK02 = 1; break; + case 3: TMMK03 = 1; break; + case 4: TMMK04 = 1; break; + case 5: TMMK05 = 1; break; + case 6: TMMK06 = 1; break; + case 7: TMMK07 = 1; break; + } + if (!(TE0 & 0x009E)) { + TT0 |= 0x0001; // Master チャンネルの停止 + } +} + +/** + * Software Reset + * + * Generate software reset. + * + * @return なし + * + * @attention: This function uses trap instruction. + * So RESF register in MCU is set to 0x80 after reset. + * Unable to use when using debugger. + * + ***************************************************************************/ + +void softwareReset(void) { + __asm __volatile(" .byte 0xff"); +} + +/** + * Get Reset Flag + * + * Get the flag why reset occur. + * + * @return 0x00: External reset or Power on reset + * 0x01: Low voltage detection + * 0x02: Illegal memory access + * 0x04: RAM parity error ( read from no initialized area ) + * 0x10: Watch dog timer + * 0x80: Illegal instruction + * + * @attention: + * + ***************************************************************************/ + +uint8_t getResetFlag() { + return g_u8ResetFlag; +} + +/** + * RLduino78のバージョン情報を取得します。 + * + * @return バージョン情報を返却します。 + * + * @attention なし + ***************************************************************************/ +uint16_t getVersion() +{ + return RLDUINO78_VERSION; +} + +#define USE_POWER_MANAGEMENT (1) // Set 1 when issue was solved. //KAD change from 0 to 1 + +#if USE_POWER_MANAGEMENT == 1 +/** @} group14 その他 */ + +/** ************************************************************************ + * @defgroup group15 パワーマネージメント/クロック制御関数 + * + * @{ + ***************************************************************************/ +/** + * パワーマネージメントモードを取得します。 + * + * 現在のパワーマネージメントモードを取得します。 + * - 通常モード:PM_NORMAL_MODE + * - 省電力(HALT)モード:PM_HALT_MODE + * - 省電力(STOP)モード:PM_STOP_MODE + * - 省電力(SNOOZE)モード:PM_SNOOZE_MODE + * + * @return パワーマネージメントモードを返却します。 + * + * @attention なし + ***************************************************************************/ +uint8_t getPowerManagementMode() +{ + return g_u8PowerManagementMode; +} + +/** + * パワーマネージメントモードを設定します。 + * + * パワーマネージメントモードを設定します。 + * - 通常モード:PM_NORMAL_MODE + * - 省電力(HALT)モード :PM_HALT_MODE + * - 省電力(STOP)モード :PM_STOP_MODE + * - 省電力(SNOOZE)モード:PM_SNOOZE_MODE + * + * パワーマネージメントモードに省電力(HALT/STOP/SNOOZE)モードを指定して delay() + * 関数を呼び出すと、一時停止期間中はHALT/STOP命令によりスタンバイ状態になります。 + * また、パワーマネージメントモードに省電力(SNOOZE)モード指定して、 analogRead() + * 関数を呼び出すと、SNOOZE状態になります。 + * + * @param[in] u8PowerManagementMode パワーマネージメントモードを指定します。 + * @param[in] u16ADLL A/D変換結果範囲の下限値を指定します。省略した場合デフォルト値(0)が設定されます。 + * @param[in] u16ADUL A/D変換結果範囲の上限値を指定します。省略した場合デフォルト値(1023)が設定されます。 + * + * @return なし + * + * @attention + * - 動作クロックの状態によっては、パワーマネージメントモードが変更されない + * 場合があります。 + * - A/D変換結果下限値/上限値には0から1023の範囲を指定してください。 + * なお、下限値/上限値の下位2bitは無視されます。 + ***************************************************************************/ +void setPowerManagementMode(uint8_t u8PowerManagementMode, uint16_t u16ADLL, uint16_t u16ADUL) +{ + + switch (u8PowerManagementMode) { + case PM_NORMAL_MODE: + case PM_HALT_MODE: + g_u16ADLL = 0; + g_u16ADUL = 1023; + g_u8PowerManagementMode = u8PowerManagementMode; + break; + + case PM_STOP_MODE: + if (CLS == 0) { + g_u16ADLL = 0; + g_u16ADUL = 1023; + g_u8PowerManagementMode = u8PowerManagementMode; + } + break; + + case PM_SNOOZE_MODE: + if ((CLS == 0) && (MCS == 0)) { + if (u16ADLL > 1023) { + u16ADLL = 1023; + } + if (u16ADUL > 1023) { + u16ADUL = 1023; + } + if (u16ADLL > u16ADUL) { + u16ADLL = 0; + u16ADUL = 1023; + } + g_u16ADLL = u16ADLL; + g_u16ADUL = u16ADUL; + g_u8PowerManagementMode = u8PowerManagementMode; + } + break; + + default: + break; + } +} + + +/** + * 動作クロックモードを取得します。 + * + * CPU/周辺ハードウェアの動作クロックモードを取得します。 + * - 高速動作モード(高速オンチップ・オシレータ):CLK_HIGH_SPEED_MODE + * - 低速動作モード(XT1発信回路) :CLK_LOW_SPEED_MODE + * + * @return 動作クロックモードを返却します。 + * + * @attention なし + ***************************************************************************/ +uint8_t getOperationClockMode() +{ + return g_u8OperationClockMode; +} + + +/** + * 動作クロックを設定します。 + * + * CPU/周辺ハードウェアの動作クロックを設定します。 + * - 高速動作モード(高速オンチップ・オシレータ):CLK_HIGH_SPEED_MODE + * - 低速動作モード(XT1発信回路) :CLK_LOW_SPEED_MODE + * + * 高速動作モードを指定すると、CPU/周辺ハードウェアに供給するクロックに + * メイン・システム・クロック(高速オンチップ・オシレータ)を設定します。 + * 低速動作モードを指定すると、CPU/周辺ハードウェアに供給するクロックに + * サブシステム・クロック(XT1発信回路)を設定します。 + * + * @param[in] u8ClockMode 動作クロックを指定します。 + * + * @return なし + * + * @attention + * - パワーマネージメントモードが省電力(STOP/SNOOZE)の場合は低速動作モード + * を設定することができません。 + * - GR-KURUMIの場合、高速動作モード(CLK_HIGH_SPEED_MODE)を指定すると + * 32 MHzで動作し、低速動作モード(CLK_LOW_SPEED_MODE)を指定すると 32.768 + * kHzで動作します。 + ***************************************************************************/ +void setOperationClockMode(uint8_t u8ClockMode) +{ + if (g_u8OperationClockMode == u8ClockMode) + { + // If there is no change from the existing mode, it will not be processed. + return; + } + else + if (u8ClockMode == CLK_HIGH_SPEED_MODE) + { + // The high-speed on-chip oscillator starts operating. + R_BSP_StartClock (HIOCLK); + // Switch to a high-speed on-chip oscillator. + if (BSP_OK == R_BSP_SetClockSource (HIOCLK)) + { + g_u8OperationClockMode = CLK_HIGH_SPEED_MODE; + } + else + { + /* not implementation */ + } + } + else + if (u8ClockMode == CLK_LOW_SPEED_MODE) + { + // Stops the operation of the high-speed on-chip oscillator. + R_BSP_StopClock (HIOCLK); + // Switch to a low-speed on-chip oscillator. + if (BSP_OK == R_BSP_SetClockSource (LOCLK)) + { + g_u8OperationClockMode = CLK_LOW_SPEED_MODE; + } + else + { + /* not implementation */ + } + } + +} +/** @} group15 パワーマネージメント/クロック制御関数 */ +#endif // USE_POWER_MANAGEMENT == 1 + + +// ************************************************************************* +// * @defgroup group16 割込みハンドラ/周期起動関数 +// * +// * @{ +// ************************************************************************** + +/* + * インターバル・タイマ割り込みハンドラ内から実行するコールバック関数を登録します。 + * + * コールバック関数を登録すると1[ms]のインターバル・タイマ割り込み毎に登録した + * コールバック関数が呼び出されます。また、コールバック関数呼び出し時にはシステム + * 開始からの時間(ms)が引数として渡されます。 + * + * @param[in] fFunction インターバル・タイマ割り込み時に実行するハンドラを指定します。 + * + * @return なし + * + * @attention + * - コールバック関数内では時間のかかる処理は行わないでください。 + * - コールバック関数内では以下の関数が呼び出し可能です。 + * + * pinMode()、 digitalWrite()、 digitalRead()、 millis()、 micros()、 delayMicroseconds()、 + * min()、 max()、 constrain()、 map()、 lowByte()、 highByte()、 bitRead()、 bitWrite()、 + * bitSet()、 bitClear()、 bit()、 randomSeed()、 random() + * - pinMode()関数と digitalWrite()関数は、 loop()関数内とコールバック関数内で同じピン + * 番号を指定すると誤動作する可能性があります。 + ************************************************************************** */ + +void attachIntervalTimerHandler(void (*fFunction)(unsigned long u32Milles)) +{ + g_fITInterruptFunc = fFunction; +} + +/** + * インターバル・タイマ割り込みハンドラ内から実行するコールバック関数の登録を解除します。 + * + * @return なし + * + * @attention なし + ***************************************************************************/ +void detachIntervalTimerHandler() +{ + g_fITInterruptFunc = NULL; +} + +void attachMicroIntervalTimerHandler(void (*fFunction)(void), uint16_t interval) +{ + (void)interval; //Warning measures + g_fMicroInterruptFunc = fFunction; +} + + +/** + * 周期起動コールバック関数を登録します。 + * + * 登録したコールバック関数は、u32CyclicTimeで指定した周期間隔[ms]で呼び出されます。 + * また、コールバック関数呼び出し時にはシステム開始からの時間(ms)が引数として渡されます。 + * + * @param[in] u8HandlerNumber 周期起動コールバック関数の識別番号(0~7)を指定します。 + * @param[in] fFunction インターバル・タイマ割り込み時に実行するハンドラを指定します。 + * @param[in] u32CyclicTime 周期起動する間隔[ms]を指定します。 + * + * @return なし + * + * @attention なし + ***************************************************************************/ +void attachCyclicHandler(uint8_t u8HandlerNumber, void (*fFunction)(unsigned long u32Milles), uint32_t u32CyclicTime) +{ + if (u8HandlerNumber < MAX_CYCLIC_HANDLER) { + detachCyclicHandler(u8HandlerNumber); + g_CyclicHandlerTable[u8HandlerNumber].au32CyclicTime = u32CyclicTime; + g_CyclicHandlerTable[u8HandlerNumber].au32RemainTime = u32CyclicTime; + g_CyclicHandlerTable[u8HandlerNumber].au32LastTime = millis(); + g_CyclicHandlerTable[u8HandlerNumber].afCyclicHandler = fFunction; + } +} + + +/** + * 周期起動コールバック関数の登録を解除します。 + * + * @param[in] u8HandlerNumber 周期起動コールバック関数の識別番号( 0 ~ 7 )を指定します。 + * + * @return なし + * + * @attention + ***************************************************************************/ +void detachCyclicHandler(uint8_t u8HandlerNumber) +{ + if (u8HandlerNumber < MAX_CYCLIC_HANDLER) { + g_CyclicHandlerTable[u8HandlerNumber].afCyclicHandler = NULL; + g_CyclicHandlerTable[u8HandlerNumber].au32CyclicTime = 0; + g_CyclicHandlerTable[u8HandlerNumber].au32RemainTime = 0; + g_CyclicHandlerTable[u8HandlerNumber].au32LastTime = 0; + } +} + +extern "C" { +/** + * 周期起動コールバック関数を起動します。 + * + * @return なし + * + * @attention + ***************************************************************************/ +void execCyclicHandler(void) +{ + int i; + + for (i = 0; i < MAX_CYCLIC_HANDLER; i++) { + if (g_CyclicHandlerTable[i].afCyclicHandler != NULL) { + unsigned long currentTime = millis(); + unsigned long elapsedTime = currentTime - g_CyclicHandlerTable[i].au32LastTime; + g_CyclicHandlerTable[i].au32LastTime = currentTime; + bool exec = g_CyclicHandlerTable[i].au32RemainTime <= elapsedTime; + g_CyclicHandlerTable[i].au32RemainTime -= elapsedTime; + if (exec) { + g_CyclicHandlerTable[i].au32RemainTime += g_CyclicHandlerTable[i].au32CyclicTime; + g_CyclicHandlerTable[i].afCyclicHandler(currentTime); + } + } + } +} + +} + +/** + * MCUに内蔵されている温度センサから温度(摂氏/華氏)を取得します。 + * + * @param[in] u8Mode 摂氏/華氏を指定します。 + * @arg TEMP_MODE_CELSIUS : 摂氏 + * @arg TEMP_MODE_FAHRENHEIT : 華氏 + * + * @return 温度を返却します。 + * + ***************************************************************************/ +int getTemperature(uint8_t u8Mode) +{ + extern uint8_t g_adc_int_flg; + uint8_t u8count; + uint16_t u16temp; + uint16_t u16temp1; //温度センサ出力の値を入れる変数 + uint16_t u16temp2; //内部基準電圧出力の値を入れる変数 + int32_t s32Temp; + int s16Result = 0; + + //温度センサ出力電圧で値を取得するためのレジスタの設定をします。 + R_Config_ADC_Set_TemperatureSensor(); + + R_Config_ADC_Set_OperationOn(); + + for (u8count = 0; u8count < 2; u8count ++) + { + g_adc_int_flg = 0; + R_Config_ADC_Start(); + while(1) + { + if(g_adc_int_flg == 1) + { + R_Config_ADC_Get_Result_10bit(&u16temp); + u16temp1 = u16temp;//温度センサ出力の値を入れる + g_adc_int_flg = 0; + break; + } + } + + } + + u8count = 0; + //内部基準電圧出力で値を取得します。 + R_Config_ADC_Set_InternalReferenceVoltage(); + R_Config_ADC_Set_OperationOn(); + + for (u8count = 0; u8count < 2; u8count ++) + { + g_adc_int_flg = 0; + R_Config_ADC_Start(); + while(1) + { + if(g_adc_int_flg == 1) + { + R_Config_ADC_Get_Result_10bit(&u16temp); + u16temp2 = u16temp;//内部基準電圧出力の値を入れる + g_adc_int_flg = 0; + break; + } + } + } + + //取得した値を使用し、温度を導きます。 + volatile long n14800L = 14800L; + s32Temp = n14800L *u16temp1 / u16temp2 - 10500L; + if (u8Mode == TEMP_MODE_FAHRENHEIT) + { + //華氏 + s16Result = s32Temp / -33 * 18 / 10; + s16Result += 77; + } + else + { + //摂氏 + s16Result = s32Temp / -33; + s16Result += 25; + } + return s16Result; + +} + +void enterPowerManagementMode(unsigned long u32ms) +{ + uint8_t u8PMmode; + + /* Check the set power saving mode and the status of RL78, + and determine the instruction that can be actually issued. + */ + u8PMmode = g_u8PowerManagementMode; + + if (u32ms == 0xFFFFFFFF) + { +// ITLMK = 1; // Mask Interval Timer + /* When the interrupt of TML32 is masked and the mode is changed to STOP mode, + the interrupt mask is not applied as a temporary measure because the + implementation that clears ITLS0 to 0 has not been completed. + */ + _STOP(); +// ITLMK = 0; // Unmask Interval Timer + } + else + { + if (1U == g_delay_cnt_flg) + { + while (g_u32delay_timer < u32ms) { + if (u8PMmode == PM_STOP_MODE) { + _STOP(); + } + else if (u8PMmode == PM_HALT_MODE){ + _HALT(); + } + else + { + NOP(); + } + } + } + else + if (1U == g_delay_cnt_micros_flg) + { + while (g_u32delay_micros_timer < u32ms) { + if (u8PMmode == PM_STOP_MODE) { + _STOP(); + } + else if (u8PMmode == PM_HALT_MODE){ + _HALT(); + } + else + { + NOP(); + } + } + } + } +} + +/* リセット要因の読み出し */ +void _readResetFlag() +{ + uint8_t resetflag; + + resetflag = RESF; + RESF = 0x00; + + if(resetflag == 0x80) /* 不正命令の実行によるリセット */ + { + g_u8ResetFlag = 0x80; + } + else if(resetflag == 0x10) /* ウォッチドックタイマによるリセット */ + { + g_u8ResetFlag = 0x10; + } + else if(resetflag == 0x04) /* RAMパリティエラーによるリセット */ + { + g_u8ResetFlag = 0x04; + } + else if(resetflag == 0x02) /* 不正メモリアクセスによるリセット */ + { + g_u8ResetFlag = 0x02; + } + else if(resetflag == 0x01) /* 低電圧検出によるリセット */ + { + g_u8ResetFlag = 0x01; + } + else /* 外部リセットorパワーオンリセットによるリセット */ + { + g_u8ResetFlag = 0x00; + } + + return; +} + diff --git a/cores/rl78g22/utilities.h b/cores/rl78g22/utilities.h index 00d8db1..fe47ca5 100644 --- a/cores/rl78g22/utilities.h +++ b/cores/rl78g22/utilities.h @@ -1,75 +1,74 @@ - -#ifndef UTILITIES_H_ -#define UTILITIES_H_ -#include -#include - -/* Power Management Mode. */ -#define PM_NORMAL_MODE 0 -#define PM_HALT_MODE 1 -#define PM_STOP_MODE 2 -#define PM_SNOOZE_MODE 3 - -/* Operation Clock Mode. */ -#define CLK_HIGH_SPEED_MODE 0 -#define CLK_LOW_SPEED_MODE 1 - -/* Temperature Mode. */ -#define TEMP_MODE_CELSIUS 0 -#define TEMP_MODE_FAHRENHEIT 1 - -typedef void (*fInterruptFunc_t)(void); -typedef void (*fITInterruptFunc_t)(unsigned long u32timer_millis); - -extern uint8_t g_u8ResetFlag; -extern uint8_t g_u8PowerManagementMode; -extern uint8_t g_u8OperationClockMode; -extern fITInterruptFunc_t g_fITInterruptFunc; - -extern fInterruptFunc_t g_fMicroInterruptFunc; - -uint16_t getVersion(); -uint8_t getPowerManagementMode(); -#ifdef __cplusplus -void setPowerManagementMode(uint8_t u8PowerManagementMode, uint16_t u16ADLL = 0, uint16_t u16ADUL = 1023); -#else -void setPowerManagementMode(uint8_t u8PowerManagementMode, uint16_t u16ADLL, uint16_t u16ADUL); -#endif -uint8_t getOperationClockMode(); -void setOperationClockMode(uint8_t u8ClockMode); -void attachIntervalTimerHandler(void (*fFunction)(unsigned long u32Milles)); -void detachIntervalTimerHandler(); - -void attachMicroIntervalTimerHandler(void (*fFunction)(void), uint16_t interval); - -void attachClockIntervalTimerHandler(void (*fFunction)(void), uint16_t interval); -void detachMicroIntervalTimerHandler(); -void detachClockIntervalTimerHandler(); -void attachCyclicHandler(uint8_t u8HandlerNumber, void (*fFunction)(unsigned long u32Milles), uint32_t u32CyclicTime); -void detachCyclicHandler(uint8_t u8HandlerNumber); -void outputClock(uint8_t u8Pin, uint32_t u32Frequency); -int getTemperature(uint8_t u8Mode); -void softwareReset(void); -uint8_t getResetFlag(void); -// void execCyclicHandler(void); - -#ifdef __cplusplus -extern "C" { -#endif -void _startTAU0(uint16_t u16TimerClock); -void _stopTAU0(); -void _startTimerChannel(uint8_t u8TimerChannel, uint16_t u16TimerMode, uint16_t u16Interval, bool bPWM, bool bInterrupt); -void _modifyTimerPeriodic(uint8_t u8TimerChannel, uint16_t u16Interval); -void _stopTimerChannel(uint8_t u8TimerChannel); -void _turnOffPwmPin(uint8_t u8Pin); -void _softwarePWM(void); -void enterPowerManagementMode(unsigned long u32ms); -void _readResetFlag(); -// 2022/10/11 -void execCyclicHandler(void); -#ifdef __cplusplus -} -#endif - - -#endif // UTILITIES_H_ + +#ifndef UTILITIES_H_ +#define UTILITIES_H_ +#include +#include + +/* Power Management Mode. */ +#define PM_NORMAL_MODE 0 +#define PM_HALT_MODE 1 +#define PM_STOP_MODE 2 +#define PM_SNOOZE_MODE 3 + +/* Operation Clock Mode. */ +#define CLK_HIGH_SPEED_MODE 0 +#define CLK_LOW_SPEED_MODE 1 + +/* Temperature Mode. */ +#define TEMP_MODE_CELSIUS 0 +#define TEMP_MODE_FAHRENHEIT 1 + +typedef void (*fInterruptFunc_t)(void); +typedef void (*fITInterruptFunc_t)(unsigned long u32timer_millis); + +extern uint8_t g_u8ResetFlag; +extern uint8_t g_u8PowerManagementMode; +extern uint8_t g_u8OperationClockMode; +extern fITInterruptFunc_t g_fITInterruptFunc; + +extern fInterruptFunc_t g_fMicroInterruptFunc; + +uint16_t getVersion(); +uint8_t getPowerManagementMode(); +#ifdef __cplusplus +void setPowerManagementMode(uint8_t u8PowerManagementMode, uint16_t u16ADLL = 0, uint16_t u16ADUL = 1023); +#else +void setPowerManagementMode(uint8_t u8PowerManagementMode, uint16_t u16ADLL, uint16_t u16ADUL); +#endif +uint8_t getOperationClockMode(); +void setOperationClockMode(uint8_t u8ClockMode); +void attachIntervalTimerHandler(void (*fFunction)(unsigned long u32Milles)); +void detachIntervalTimerHandler(); + +void attachMicroIntervalTimerHandler(void (*fFunction)(void), uint16_t interval); + +void attachClockIntervalTimerHandler(void (*fFunction)(void), uint16_t interval); +void detachMicroIntervalTimerHandler(); +void detachClockIntervalTimerHandler(); +void attachCyclicHandler(uint8_t u8HandlerNumber, void (*fFunction)(unsigned long u32Milles), uint32_t u32CyclicTime); +void detachCyclicHandler(uint8_t u8HandlerNumber); +void outputClock(uint8_t u8Pin, uint32_t u32Frequency); +int getTemperature(uint8_t u8Mode); +void softwareReset(void); +uint8_t getResetFlag(void); +// void execCyclicHandler(void); + +#ifdef __cplusplus +extern "C" { +#endif +void _startTAU0(uint16_t u16TimerClock); +void _stopTAU0(); +void _startTimerChannel(uint8_t u8TimerChannel, uint16_t u16TimerMode, uint16_t u16Interval, bool bPWM, bool bInterrupt); +void _modifyTimerPeriodic(uint8_t u8TimerChannel, uint16_t u16Interval); +void _stopTimerChannel(uint8_t u8TimerChannel); +void _turnOffPwmPin(uint8_t u8Pin); +void _softwarePWM(void); +void enterPowerManagementMode(unsigned long u32ms); +void _readResetFlag(); +void execCyclicHandler(void); +#ifdef __cplusplus +} +#endif + + +#endif // UTILITIES_H_ diff --git a/cores/rl78g22/wiring.c b/cores/rl78g22/wiring.c index 342f747..e710a43 100644 --- a/cores/rl78g22/wiring.c +++ b/cores/rl78g22/wiring.c @@ -1,590 +1,238 @@ -/* - wiring.c - Partial implementation of the Wiring API for the ATmega8. - Part of Arduino - http://www.arduino.cc/ - - Copyright (c) 2005-2006 David A. Mellis - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - $Id$ -*/ -/* - * Modified 15 July 2014 by Nozomu Fujita for GR-SAKURA - * Modified 4 Mar 2017 by Yuuki Okamiya for RL78/G13 -*/ - -#include "wiring_private.h" -#ifdef __RL78__ -#include "utilities.h" -#include "r_smc_entry.h" -#endif -// #include "ArduinoClassics.h" - -#ifndef __RL78__ -// the prescaler is set so that timer0 ticks every 64 clock cycles, and the -// the overflow handler is called every 256 ticks. -#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 256)) - -// the whole number of milliseconds per timer0 overflow -#define MILLIS_INC (MICROSECONDS_PER_TIMER0_OVERFLOW / 1000) - -// the fractional number of milliseconds per timer0 overflow. we shift right -// by three to fit these numbers into a byte. (for the clock speeds we care -// about - 8 and 16 MHz - this doesn't lose precision.) -#define FRACT_INC ((MICROSECONDS_PER_TIMER0_OVERFLOW % 1000) >> 3) -#define FRACT_MAX (1000 >> 3) -#else /*__RL78__*/ -volatile unsigned long g_u32timer_millis = 0u; //!< インターバルタイマ変数 -volatile unsigned long g_u32delay_timer = 0u; //!< delay() 用タイマ変数 - -volatile unsigned long g_timer06_overflow_count = 0;// -uint8_t g_delay_cnt_flg = 0; -uint8_t g_delay_cnt_micros_flg = 0; - -volatile unsigned long g_u32timer_micros = 0u; //!< インターバルタイマ変数 -volatile unsigned long g_u32delay_micros_timer = 0u; //!< delay() 用タイマ変数 -volatile uint8_t g_u8delay_micros_timer_flg = 0u; //!< microSecondタイマ割り込み検出フラグ - -volatile uint16_t g_u16delay_micros_timer_set; //!< delay() 用タイマ変数 -volatile uint16_t g_u16delay_micros_timer_total = 0; //!< delay() 用タイマ変数 - - -uint8_t g_timer_millis_overflow_cnt = 0; /* mills over flow couner */ -unsigned long g_starttime_ms = 0u; /* mills starttime counter */ - -extern void delay_wait (uint32_t count); - -#endif /*__RL78__*/ - -#ifndef __RL78__ -volatile unsigned long timer0_overflow_count = 0; -volatile unsigned long timer0_millis = 0; -static unsigned char timer0_fract = 0; - -#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) -ISR(TIM0_OVF_vect) -#else -ISR(TIMER0_OVF_vect) -#endif -{ - // copy these to local variables so they can be stored in registers - // (volatile variables must be read from memory on every access) - unsigned long m = timer0_millis; - unsigned char f = timer0_fract; - - m += MILLIS_INC; - f += FRACT_INC; - if (f >= FRACT_MAX) { - f -= FRACT_MAX; - m += 1; - } - - timer0_fract = f; - timer0_millis = m; - timer0_overflow_count++; -} -#else /*__RL78__*/ - -#endif/*__RL78__*/ - -unsigned long millis() -{ -#ifndef __RL78__ - unsigned long m; - uint8_t oldSREG = SREG; - - // disable interrupts while we read timer0_millis or we might get an - // inconsistent value (e.g. in the middle of a write to timer0_millis) - cli(); - m = timer0_millis; - SREG = oldSREG; - - return m; -#else /*__RL78__*/ - unsigned long u32ms; - - noInterrupts(); - u32ms = g_u32timer_millis; - interrupts(); - - return u32ms; -#endif/*__RL78__*/ -} - -unsigned long micros() { -#ifndef __RL78__ - unsigned long m; - uint8_t oldSREG = SREG, t; - - cli(); - m = timer0_overflow_count; -#if defined(TCNT0) - t = TCNT0; -#elif defined(TCNT0L) - t = TCNT0L; -#else - #error TIMER 0 not defined -#endif - - -#ifdef TIFR0 - if ((TIFR0 & _BV(TOV0)) && (t < 255)) - m++; -#else - if ((TIFR & _BV(TOV0)) && (t < 255)) - m++; -#endif - - SREG = oldSREG; - - return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond()); -#else /*__RL78__*/ - unsigned long a; - unsigned long m; - uint16_t t; - boolean ov0,ov1; - -#ifdef USE_RTOS - u32us = (unsigned long)xTaskGetTickCount() / portTICK_RATE_MS * 1000; -#else - - // 割り込み禁止状態で - if (isNoInterrupts()) { - // TCR05.tcr05 を参照する前の g_timer05_overflow_count の値 - m = g_timer06_overflow_count; - // TCR05.tcr05 を参照する直前でオーバーフローしてるか? - ov0 = TMIF06; - // TCR05.tcr05 の値 - t = TCR06; - // TCR05.tcr05 を参照した直前でオーバーフローしてるか? - ov1 = TMIF06; - - if (!ov0 && ov1) { - // TCR05.tcr05 を参照した付近でオーバーフローしたのであれば、 - // t の値は捨てて TDR の初期値を代入し、オーバーフローの補正を行う - t = INTERVAL_MICRO_TDR; - m++; - } else if (ov0) { - // タイマーが最初っからオーバーフローしてるのであれば、g_timer05_overflow_count の値の補正を行う - m++; - } - // 割り込み許可状態で - } else { - // TCR05.tcr05 を参照する直前の g_timer05_overflow_count の値 - a = g_timer06_overflow_count; - // TCR05.tcr05 の値 - t = TCR06; - // TCR05.tcr05 を参照した直後の g_timer05_overflow_count の値 - m = g_timer06_overflow_count; - - if (a != m) { - // TCR05.tcr05 を参照する直前と直後の g_timer05_overflow_count の値が - // 異なっているのであれば、これはどう考えても TCR05.tcr05 の値を参照した付近で - // インターバルのタイミングが発生してたということなので、t に格納されてる値は捨てて、 - // TCR05.tcr05 の値は TDR の値に設定して問題ない - t = INTERVAL_MICRO_TDR; - } else if (t == INTERVAL_MICRO_TDR) { - // TCR05 がオーバーフローを起こし、割り込みが発生していれば割り込みの処理で - // 32クロック以上掛かるので、TCR05.tcr05 の値は TDR05 の値より -1 以上 - // 小さくなっている筈。それがなく、TCR05.tcr05 の値が TDR05 と等しいということは - // 割り込み処理がまだ行われてないということなので補正を行う - m++; - } - } - m = m * MICROSECONDS_PER_TIMER05_OVERFLOW + (INTERVAL_MICRO_TDR - t); -#endif - - return m; -#endif/*__RL78__*/ -} - -void delay(unsigned long ms) -{ -#ifndef __RL78__ - uint16_t start = (uint16_t)micros(); - - while (ms > 0) { - yield(); - if (((uint16_t)micros() - start) >= 1000) { - ms--; - start += 1000; - } - } -#else /*__RL78__*/ - - volatile unsigned long lms = ms; - g_delay_cnt_flg = 1U; - g_u32delay_timer = 0U; - if (g_u8PowerManagementMode == PM_NORMAL_MODE) - { -// g_u32delay_timer = 0U; // todo:初期化の位置を変更 -// g_delay_cnt_flg = 1U; // todo:flagの設定位置を変更 -// while (g_u32delay_timer < ms) - while (g_u32delay_timer < lms) - { -// HALT(); - // todo: 通常モード動作のためHALT移行を停止 - } -// g_delay_cnt_flg = 0U; // todo:flagの解除位置を変更 - } - else - { - enterPowerManagementMode (ms); - } - g_delay_cnt_flg = 0U; - -#endif/*__RL78__*/ -} - -/* Delay for the given number of microseconds. Assumes a 8 or 16 MHz clock. */ -// void delayMicroseconds(unsigned long us) -void delayMicroseconds(unsigned int us) -{ -#ifndef __RL78__ - // calling avrlib's delay_us() function with low values (e.g. 1 or - // 2 microseconds) gives delays longer than desired. - //delay_us(us); -#if F_CPU >= 20000000L - // for the 20 MHz clock on rare Arduino boards - - // for a one-microsecond delay, simply wait 2 cycle and return. The overhead - // of the function call yields a delay of exactly a one microsecond. - __asm__ __volatile__ ( - "nop" "\n\t" - "nop"); //just waiting 2 cycle - if (--us == 0) - return; - - // the following loop takes a 1/5 of a microsecond (4 cycles) - // per iteration, so execute it five times for each microsecond of - // delay requested. - us = (us<<2) + us; // x5 us - - // account for the time taken in the preceeding commands. - us -= 2; - -#elif F_CPU >= 16000000L - // for the 16 MHz clock on most Arduino boards - - // for a one-microsecond delay, simply return. the overhead - // of the function call yields a delay of approximately 1 1/8 us. - if (--us == 0) - return; - - // the following loop takes a quarter of a microsecond (4 cycles) - // per iteration, so execute it four times for each microsecond of - // delay requested. - us <<= 2; - - // account for the time taken in the preceeding commands. - us -= 2; -#else - // for the 8 MHz internal clock on the ATmega168 - - // for a one- or two-microsecond delay, simply return. the overhead of - // the function calls takes more than two microseconds. can't just - // subtract two, since us is unsigned; we'd overflow. - if (--us == 0) - return; - if (--us == 0) - return; - - // the following loop takes half of a microsecond (4 cycles) - // per iteration, so execute it twice for each microsecond of - // delay requested. - us <<= 1; - - // partially compensate for the time taken by the preceeding commands. - // we can't subtract any more than this or we'd overflow w/ small delays. - us--; -#endif - - // busy wait - __asm__ __volatile__ ( - "1: sbiw %0,1" "\n\t" // 2 cycles - "brne 1b" : "=w" (us) : "0" (us) // 2 cycles - ); -#elif 0 /*__RL78__(1)*/ - - g_u32delay_micros_timer = 0U; - g_delay_cnt_micros_flg = 1U; - - if(us>999) - { - uint32_t ms = us/1000; - delay(ms); - us = us - ms * 1000; - } - - R_Config_ITL000_Stop(); // Stop 1msec Timer -#if 0 //KAD - R_Config_ITL000_SetCompareMatch_For_MainClock(); // Configuration 1msec Timer as Main Clock - R_Config_ITL000_Start(); // Start 1msec Timer -#endif - uint8_t timer_count ; - uint8_t timer_div; - if (us<=128) - { - timer_count = us/2 -1 ; - timer_div = 0x40 ; - } - else if (us<=256) - { - timer_count = us/4 -1 ; - timer_div = 0x50 ; - } - else if (us<=512) - { - timer_count = us/8 -1 ; - timer_div = 0x60 ; - } - else - { - timer_count = us/16 -1 ; - timer_div = 0x70 ; - } - R_Config_ITL001_SetCompareMatch(timer_count,timer_div); - R_Config_ITL001_Start(); - while (g_u32delay_micros_timer<1) - { - if (g_u8PowerManagementMode == PM_HALT_MODE | g_u8PowerManagementMode == PM_STOP_MODE) - { - HALT(); - } - } - R_Config_ITL001_Stop(); -#if 0 //KAD - R_Config_ITL000_Stop(); // Stop 1msec Timer -#endif - R_Config_ITL000_SetCompareMatch(); - R_Config_ITL000_Start(); // Start 1msec Timer - -#elif 0 /*__RL78__*/ - uint8_t timer_count; - uint8_t timer_div; - uint8_t before_timer_div = 0xFF; - uint8_t before_timer_count = 0xFF; - uint32_t u32us = us; - uint32_t u32us_millis; - uint16_t u16ush; - uint16_t u16usl; - - g_delay_cnt_micros_flg = 1U; - - R_Config_ITL000_Stop(); // Stop 1msec Timer - while (0 < u32us) - { - g_u8delay_micros_timer_flg = 0; - - u16ush = (uint16_t)(u32us >> 16); - u16usl = (uint16_t)(u32us); - if (0 < u16ush) - { - /* more than 65536 us */ - g_u16delay_micros_timer_set = 1024; - timer_count = 1024 / 4 - 1; - timer_div = 0x70; - } - else if (8 >= u16usl) - { - /* 1 ~ 8us */ - g_u16delay_micros_timer_set = u16usl; - timer_count = u16usl * 32 - 1; - timer_div = 0x00; - } - else if (16 >= u16usl) - { - /* 9 ~ 16us */ - g_u16delay_micros_timer_set = u16usl; - timer_count = u16usl * 16 - 1; - timer_div = 0x10; - } - else if (32 >= u16usl) - { - /* 17 ~ 32us */ - g_u16delay_micros_timer_set = u16usl; - timer_count = u16usl * 8 - 1; - timer_div = 0x20; - } - else if (64 >= u16usl) - { - /* 33 ~ 64us */ - g_u16delay_micros_timer_set = u16usl; - timer_count = u16usl * 4 - 1; - timer_div = 0x30; - } - else if (128 >= u16usl) - { - /* 65 ~ 128us */ - g_u16delay_micros_timer_set = u16usl; - timer_count = u16usl * 2 - 1; - timer_div = 0x40; - } - else if (256 >= u16usl) - { - /* 128 ~ 256us */ - g_u16delay_micros_timer_set = u16usl; - timer_count = u16usl - 1; - timer_div = 0x50; - } - else if (u16usl<=512) - { - /* 257 ~ 512us */ - g_u16delay_micros_timer_set = u16usl; - timer_count = u16usl / 2 - 1; - timer_div = 0x60; - } - else if(u16usl <= 1024) - { - /* 512 ~ 1023 */ - g_u16delay_micros_timer_set = u16usl; - timer_count = u16usl / 4 - 1; - timer_div = 0x70; - } - else - { - /* 1024 ~ */ - g_u16delay_micros_timer_set = 1024; - timer_count = 1024 / 4 - 1; - timer_div = 0x70; - } - - - if ((before_timer_div != timer_div) || (before_timer_count != timer_count)) - { - /* タイマ設定変更 */ - before_timer_div = timer_div; - before_timer_count = timer_count; - R_Config_ITL001_SetCompareMatch(timer_count,timer_div); - } - - if ((PM_HALT_MODE == g_u8PowerManagementMode) || (PM_STOP_MODE == g_u8PowerManagementMode)) - { - R_Config_ITL001_Start(); - do - { - HALT(); - } while (0 == g_u8delay_micros_timer_flg); - } - else - { - R_Config_ITL001_Start(); - do - { - NOP(); - } while (0 == g_u8delay_micros_timer_flg); - } - u32us -= g_u16delay_micros_timer_set; - } - - R_Config_ITL000_SetCompareMatch(); - R_Config_ITL000_Start(); // Start 1msec Timer - -#else /*__RL78__*/ - - if(DELAYMICROSECONDS_ADJUST1 >= us) - { - return; - } - if(DELAYMICROSECONDS_ADJUST3 > us) - { - delay_wait((us-DELAYMICROSECONDS_ADJUST1) * DELAYMICROSECONDS_ADJUST4); - return; - } - - g_delay_cnt_micros_flg = 1U; - - if (g_u8PowerManagementMode == PM_NORMAL_MODE) { - unsigned long s, w, d; - s = micros(); - w = us - DELAYMICROSECONDS_ADJUST2 ; - d = 0; - while (w > d) { - d = micros() - s; - } - } else { - unsigned long s, w, d; - s = micros(); - w = us - DELAYMICROSECONDS_ADJUST2 ; - d = 0; - while (w > d) { - _HALT(); - d = micros() - s; - } - } - g_delay_cnt_micros_flg = 0U; - -#endif/*__RL78__*/ -} - -#ifdef __RL78__ -/********************************************************************************************************************** - * Function Name: start time setting - * Description : Set the current count value to startup_ms. - * Arguments : - - * Return Value : - - *********************************************************************************************************************/ -void set_starttime(void) -{ - noInterrupts(); - g_timer_millis_overflow_cnt = 0; - g_starttime_ms = g_u32timer_millis; /* set current time */ - interrupts(); -} - -/********************************************************************************************************************** - * Function Name: set_endtime - * Description : Get elapsed time form set_starttime. - * Arguments : - - * Return Value : result - * 0 : OK - * -1 : NG - * -2 : parameter error - *********************************************************************************************************************/ -long set_endtime() -{ - long ret; - unsigned long val = 0; - - noInterrupts(); - if (0 == g_timer_millis_overflow_cnt){ - val = g_u32timer_millis - g_starttime_ms; - } - else if (1 == g_timer_millis_overflow_cnt){ - if (g_starttime_ms <= g_u32timer_millis){ - val = 0xffffffff; /* 32bit over flow */ - } - else{ - val = (0xffffffffu - g_starttime_ms) + g_u32timer_millis + 1; - } - } - else{ - val = 0xffffffff; /* 32bit over flow */ - } - interrupts(); - - if (0x80000000 <= val){ - ret = -1; - } - else{ - ret = (long)val; - } - - return ret; -} - -#endif/*__RL78__*/ - +/* + wiring.c - Partial implementation of the Wiring API for the ATmega8. + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2005-2006 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + $Id$ +*/ +/* + * Modified 15 July 2014 by Nozomu Fujita for GR-SAKURA + * Modified 4 Mar 2017 by Yuuki Okamiya for RL78/G13 +*/ + +#include "wiring_private.h" +#include "utilities.h" +#include "r_smc_entry.h" + +volatile unsigned long g_u32timer_millis = 0u; //!< インターバルタイマ変数 +volatile unsigned long g_u32delay_timer = 0u; //!< delay() 用タイマ変数 +volatile unsigned long g_micros_timer_ovfl_count = 0; +uint8_t g_delay_cnt_flg = 0; +uint8_t g_delay_cnt_micros_flg = 0; +volatile unsigned long g_u32timer_micros = 0u; //!< インターバルタイマ変数 +volatile unsigned long g_u32delay_micros_timer = 0u; //!< delay() 用タイマ変数 +volatile uint8_t g_u8delay_micros_timer_flg = 0u; //!< microSecondタイマ割り込み検出フラグ +volatile uint16_t g_u16delay_micros_timer_set; //!< delay() 用タイマ変数 +volatile uint16_t g_u16delay_micros_timer_total = 0; //!< delay() 用タイマ変数 +uint8_t g_timer_millis_overflow_cnt = 0; /* mills over flow couner */ +unsigned long g_starttime_ms = 0u; /* mills starttime counter */ +extern void delay_wait (uint32_t count); + +unsigned long millis() +{ + unsigned long u32ms; + + noInterrupts(); + u32ms = g_u32timer_millis; + interrupts(); + return u32ms; +} + +unsigned long micros() { + unsigned long a; + unsigned long m; + uint16_t t; + boolean ov0,ov1; + + // 割り込み禁止状態で + if (isNoInterrupts()) { + // TCR05.tcr05 を参照する前の g_timer05_overflow_count の値 + m = g_micros_timer_ovfl_count ; + // TCR05.tcr05 を参照する直前でオーバーフローしてるか? + ov0 = MICROSEC_OVFL_FLAG; + // TCR05.tcr05 の値 + t = MICROSEC_TIMER_CNT; + // TCR05.tcr05 を参照した直前でオーバーフローしてるか? + ov1 = MICROSEC_OVFL_FLAG; + + if (!ov0 && ov1) { + // TCR05.tcr05 を参照した付近でオーバーフローしたのであれば、 + // t の値は捨てて TDR の初期値を代入し、オーバーフローの補正を行う + t = INTERVAL_MICRO_TDR; + m++; + } else if (ov0) { + // タイマーが最初っからオーバーフローしてるのであれば、g_timer05_overflow_count の値の補正を行う + m++; + } + // 割り込み許可状態で + } + else + { + // TCR05.tcr05 を参照する直前の g_timer05_overflow_count の値 + a = g_micros_timer_ovfl_count; + // TCR05.tcr05 の値 + t = MICROSEC_TIMER_CNT; + // TCR05.tcr05 を参照した直後の g_timer05_overflow_count の値 + m = g_micros_timer_ovfl_count; + + if (a != m) + { + // TCR05.tcr05 を参照する直前と直後の g_timer05_overflow_count の値が + // 異なっているのであれば、これはどう考えても TCR05.tcr05 の値を参照した付近で + // インターバルのタイミングが発生してたということなので、t に格納されてる値は捨てて、 + // TCR05.tcr05 の値は TDR の値に設定して問題ない + t = INTERVAL_MICRO_TDR; + } + else if (t == INTERVAL_MICRO_TDR) + { + // TCR05 がオーバーフローを起こし、割り込みが発生していれば割り込みの処理で + // 32クロック以上掛かるので、TCR05.tcr05 の値は TDR05 の値より -1 以上 + // 小さくなっている筈。それがなく、TCR05.tcr05 の値が TDR05 と等しいということは + // 割り込み処理がまだ行われてないということなので補正を行う + m++; + } + } + m = ( m * MICROSECONDS_PER_TIMER05_OVERFLOW + (INTERVAL_MICRO_TDR - t) ) / MICROS_TIMER_DIVIDE_FACTOR; + return m; +} + + +void delay(unsigned long ms) +{ + volatile unsigned long lms = ms; + g_delay_cnt_flg = 1U; + g_u32delay_timer = 0U; + if (g_u8PowerManagementMode == PM_NORMAL_MODE) + { +// g_u32delay_timer = 0U; // todo:初期化の位置を変更 +// g_delay_cnt_flg = 1U; // todo:flagの設定位置を変更 +// while (g_u32delay_timer < ms) + while (g_u32delay_timer < lms) + { +// HALT(); + // todo: 通常モード動作のためHALT移行を停止 + } +// g_delay_cnt_flg = 0U; // todo:flagの解除位置を変更 + } + else + { + enterPowerManagementMode (ms); + } + g_delay_cnt_flg = 0U; +} + +/* Delay for the given number of microseconds. Assumes a 8 or 16 MHz clock. */ +// void delayMicroseconds(unsigned long us) +void delayMicroseconds(unsigned int us) +{ + if(DELAYMICROSECONDS_ADJUST1 >= us) + { + return; + } + if(DELAYMICROSECONDS_ADJUST3 > us) + { + delay_wait((us-DELAYMICROSECONDS_ADJUST1) * DELAYMICROSECONDS_ADJUST4); + return; + } + g_delay_cnt_micros_flg = 1U; + if (g_u8PowerManagementMode == PM_NORMAL_MODE) { + unsigned long s, w, d; + s = micros(); + w = us - DELAYMICROSECONDS_ADJUST2 ; + d = 0; + while (w > d) + { + d = micros() - s; + } + } + else + { + unsigned long s, w, d; + s = micros(); + w = us - DELAYMICROSECONDS_ADJUST2 ; + d = 0; + while (w > d) + { + _HALT(); + d = micros() - s; + } + } + g_delay_cnt_micros_flg = 0U; +} + +/********************************************************************************************************************** + * Function Name: start time setting + * Description : Set the current count value to startup_ms. + * Arguments : - + * Return Value : - + *********************************************************************************************************************/ +void set_starttime(void) +{ + noInterrupts(); + g_timer_millis_overflow_cnt = 0; + g_starttime_ms = g_u32timer_millis; /* set current time */ + interrupts(); +} + +/********************************************************************************************************************** + * Function Name: set_endtime + * Description : Get elapsed time form set_starttime. + * Arguments : - + * Return Value : result + * 0 : OK + * -1 : NG + * -2 : parameter error + *********************************************************************************************************************/ +long set_endtime() +{ + long ret; + unsigned long val = 0; + + noInterrupts(); + if (0 == g_timer_millis_overflow_cnt) + { + val = g_u32timer_millis - g_starttime_ms; + } + else if (1 == g_timer_millis_overflow_cnt) + { + if (g_starttime_ms <= g_u32timer_millis) + { + val = 0xffffffff; /* 32bit over flow */ + } + else + { + val = (0xffffffffu - g_starttime_ms) + g_u32timer_millis + 1; + } + } + else + { + val = 0xffffffff; /* 32bit over flow */ + } + interrupts(); + + if (0x80000000 <= val) + { + ret = -1; + } + else + { + ret = (long)val; + } + return ret; +} diff --git a/cores/rl78g22/wiring_analog.c b/cores/rl78g22/wiring_analog.c index 77e9e57..908860a 100644 --- a/cores/rl78g22/wiring_analog.c +++ b/cores/rl78g22/wiring_analog.c @@ -1,440 +1,500 @@ -/* - wiring_analog.c - analog input and output - Part of Arduino - http://www.arduino.cc/ - - Copyright (c) 2005-2006 David A. Mellis - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - Modified 28 September 2010 by Mark Sproul - - $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ - */ -/* - * Modified 4 Mar 2017 by Yuuki Okamiya for RL78/G13 - */ -#include "wiring_private.h" -#include "wiring_variant.h" -#include "pins_variant.h" -#include "pintable.h" -#include "r_smc_entry.h" - -extern const PinTableType * pinTablelist[NUM_DIGITAL_PINS]; -extern uint8_t g_adc_int_flg; -static uint8_t g_u8AnalogReference = DEFAULT; -boolean g_bAdcInterruptFlag = false; -uint16_t g_u16ADUL; -uint16_t g_u16ADLL; -extern uint32_t R_BSP_GetFclkFreqHz(void); - -/* Match to the value of PWM_PIN */ -extern volatile unsigned short *g_timer_period_reg[PWM_CH_NUM]; -extern volatile unsigned short *g_timer_duty_reg[PWM_CH_NUM]; -extern volatile unsigned short *g_timer_analog_mode_reg[PWM_CH_NUM]; -extern volatile unsigned short *g_timer_analog_clock_select_reg; -extern const uint8_t pwm_channel_table[PWM_CH_NUM]; -extern Pwm_func pwm_ch[PWM_CH_NUM]; -extern const uint8_t g_au8AnalogPinTable[NUM_ANALOG_INPUTS]; -extern const uint8_t g_analog_pin_input[NUM_ANALOG_INPUTS]; - -static void _analogPinRead(uint8_t pin); -static int _analogRead(uint8_t u8ADS); -static int _analogDuty(int val, uint16_t frequency); -static uint16_t _analogFrequency (uint8_t pin, uint32_t u32Hz); - -volatile SwPwm g_SwPwm[NUM_SWPWM_PINS] = { { 0, 0, 0, 0, 0, 0 }, }; -bool g_u8AnalogReadAvailableTable[NUM_ANALOG_INPUTS] = { 0 }; -bool g_u8AnalogWriteAvailableTable[NUM_DIGITAL_PINS] = { -false, false, false, false, -false, false, false, false, -false, false, false, false, -false, false, false, false, -false, false, false, false, -false, false, false, false, -false, }; - - -int8_t get_pwm_channel(uint8_t pwm_num) -{ - int8_t pwm_cnt; - for(pwm_cnt=0;pwm_cnt> 8; - timer_frequency = fclk_frequency / (1 << (operating_clock_select * 2)) ; /* fclk/2^2 ~ 2^6 */ - } - } - else if (timer_clock_mode == _C000_TAU_CLOCK_SELECT_CKM3) /* CK03 Clock Selected */ - { - operating_clock_select = *g_timer_analog_clock_select_reg & CK03_OPERATION; - - operating_clock_select = operating_clock_select >> 12; - timer_frequency = fclk_frequency / (1 << (operating_clock_select * 2 + 8)); /* fclk/2^8 ~ 2^14 */ - } - else /* CK00, CK01 Clock Selected */ - { - operating_clock_select = *g_timer_analog_clock_select_reg & CK00_CK01_OPERATION; - timer_frequency = fclk_frequency / (1 << operating_clock_select) ; /* ckm00, ckm01 - fclk/2^0 ~ 2^15 */ - } - - /* 490 Hz <= frequency <= 8MHz */ - u32Hz = max(u32Hz, (uint32_t)FREQUENCY_MIN_VAL); - u32Hz = min(u32Hz, (uint32_t)FREQUENCY_MAX_VAL); - - /* Pulse period = {Set value of TDRmn (master) + 1} × Count clock period - Set value of TDRmn (master) = (Pulse period / Count clock period) - 1 */ - Result = (uint16_t)((timer_frequency / u32Hz) - 1); - return Result; -} - -static int _analogDuty(int val, uint16_t frequency) -{ -/* Duty factor [0 ~ 255] = {Set value of TDRmp (slave)}/{Set value of TDRmn (master) + 1} × 255 - {Set value of TDRmp (slave)} = Duty factor * {Set value of TDRmn (master) + 1} / 255 */ - int u16Duty = 0; - /* Duty set */ - if(val> PWM_MAX) - { - val = PWM_MAX; - } - else - { - u16Duty = (int) (((unsigned long) val - * (frequency + 1)) / PWM_MAX); - } - return u16Duty; -} - -/* 1011 Nhu add */ -static void _analogPinRead (uint8_t pin) -{ - uint8_t pin_index; - if (pin==29) - { - pin_index = 8; - } - else if (pin==40) - { - pin_index = 9; - } - else if (pinpmca) - { - pinMode(pin, INPUT); - /* アナログピンの場合PMCAをセットする */ - *p->portModeControlARegisterAddr |= (unsigned long)(p->pmca); - -// *p->portModeControlARegisterAddr &= (unsigned long)~(p->pmca); - g_u8AnalogReadAvailableTable[pin_index] = true; - } - } -} - -static int _analogRead(uint8_t u8ADS) { - int s16Result = 0; - - uint8_t adc_end_flg = 0; - // 1. AD reference setting - R_Config_ADC_Set_Reference (g_u8AnalogReference); - // 3. Snooze mode return upper / lower limit setting - R_Config_ADC_Set_ComparisonLimit((uint8_t)(g_u16ADUL >> 2), (uint8_t)(g_u16ADLL >> 2)); - // 4. AD channel setting - R_Config_ADC_Set_ADChannel(u8ADS); - while(0 == adc_end_flg) - { - g_adc_int_flg=0; - // 2. Trigger mode setting - if (PM_SNOOZE_MODE == g_u8PowerManagementMode) - { - R_Config_ITL000_Stop(); - // Hardware trigger wait mode(RTC), one-shot conversion - R_Config_ADC_Set_ModeTrigger(PM_SNOOZE_MODE); - // 6. Snooze mode ON (interrupt enabled) - R_Config_ADC_Set_SnoozeOn(); //AWC =1 - // 5. AD comparator ON - R_Config_ADC_Snooze_Start(); //enable interrupt & ADCS=1 - } - else - { - // Software trigger mode, one-shot conversion - R_Config_ADC_Set_ModeTrigger(PM_NORMAL_MODE); - // 5. AD comparator ON - R_Config_ADC_Set_OperationOn(); //ADCE=1 & wait - R_Config_ADC_Start(); //ADCS=1 & enable interrupt - } - // 7. After STOP mode until AD interrupt occurs (loop processing) - while (0 == g_adc_int_flg) - { - if (PM_SNOOZE_MODE == g_u8PowerManagementMode) - { - enterPowerManagementMode (0xFFFFFFFF); - } - else - { - NOP(); - } - } - // 8. Snooze mode Off (interrupt stop) - if (PM_SNOOZE_MODE == g_u8PowerManagementMode) - { - R_Config_ADC_Set_SnoozeOff(); - R_Config_ADC_Snooze_Stop(); - R_Config_ITL000_Start(); - } - else - { - R_Config_ADC_Stop(); - } - // 9. Get AD conversion result - if (DEFAULT == g_u8AnalogReference) - { - R_Config_ADC_Get_Result_10bit ((uint16_t*) &s16Result); - } - else if (INTERNAL == g_u8AnalogReference) - { - R_Config_ADC_Get_Result_8bit ((uint8_t*) &s16Result); - } - if (PM_SNOOZE_MODE == g_u8PowerManagementMode) - { - if((g_u16ADLL <= (uint16_t)s16Result) && ((uint16_t)s16Result <= g_u16ADUL)) - { - adc_end_flg = 1; - } - } - else - { - adc_end_flg = 1; - } - } - // 10.AD Comparator Off - R_Config_ADC_Set_OperationOff(); - return s16Result; -} +/* + wiring_analog.c - analog input and output + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2005-2006 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + Modified 28 September 2010 by Mark Sproul + + $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ + */ +/* + * Modified 4 Mar 2017 by Yuuki Okamiya for RL78/G13 + */ +#include "wiring_private.h" +#include "wiring_variant.h" +#include "pins_variant.h" +#include "pintable.h" +#include "r_smc_entry.h" +#if defined(G23_FPB) +#include "Config_Through.h" +#endif // G23_FPB + +extern const PinTableType * pinTablelist[NUM_DIGITAL_PINS]; +extern uint8_t g_adc_int_flg; +static uint8_t g_u8AnalogReference = DEFAULT; +boolean g_bAdcInterruptFlag = false; +uint16_t g_u16ADUL; +uint16_t g_u16ADLL; +extern uint32_t R_BSP_GetFclkFreqHz(void); +uint8_t g_pwm_create_flg=0; +uint8_t g_analogWrite_enable_interrupt_flag=0; + +/* Match to the value of PWM_PIN */ +extern volatile unsigned short *g_timer_period_reg[PWM_CH_NUM]; +extern volatile unsigned short *g_timer_duty_reg[PWM_CH_NUM]; +extern volatile unsigned short *g_timer_analog_mode_reg[PWM_CH_NUM]; +extern volatile unsigned short *g_timer_analog_clock_select_reg; +extern const uint8_t pwm_channel_table[PWM_CH_NUM]; +extern Pwm_func pwm_ch[PWM_CH_NUM]; +extern const uint8_t g_au8AnalogPinTable[NUM_ANALOG_INPUTS]; +extern const uint8_t g_analog_pin_input[NUM_ANALOG_INPUTS]; + +static void _analogPinRead(uint8_t pin); +static int _analogRead(uint8_t u8ADS); +static uint16_t _analogDuty(int val, uint16_t frequency); +static uint16_t _analogFrequency (uint8_t pin, uint32_t u32Hz); + +volatile SwPwm g_SwPwm[NUM_SWPWM_PINS] = { { 0, 0, 0, 0, 0, 0 }, }; +bool g_u8AnalogReadAvailableTable[NUM_ANALOG_INPUTS] = { 0 }; +bool g_u8AnalogWriteAvailableTable[NUM_DIGITAL_PINS] = {}; + +int8_t get_pwm_channel(uint8_t pwm_num) +{ + int8_t pwm_cnt; + for(pwm_cnt=0;pwm_cnt> 8; + timer_frequency = fclk_frequency / (1 << (operating_clock_select * 2)) ; /* fclk/2^2 ~ 2^6 */ + } + } + else if (timer_clock_mode == _C000_TAU_CLOCK_SELECT_CKM3) /* CK03 Clock Selected */ + { + operating_clock_select = *g_timer_analog_clock_select_reg & CK03_OPERATION; + + operating_clock_select = operating_clock_select >> 12; + timer_frequency = fclk_frequency / (1 << (operating_clock_select * 2 + 8)); /* fclk/2^8 ~ 2^14 */ + } + else /* CK00, CK01 Clock Selected */ + { + operating_clock_select = *g_timer_analog_clock_select_reg & CK00_CK01_OPERATION; + timer_frequency = fclk_frequency / (1 << operating_clock_select) ; /* ckm00, ckm01 - fclk/2^0 ~ 2^15 */ + } + + /* 490 Hz <= frequency <= 8MHz */ + u32Hz = max(u32Hz, (uint32_t)FREQUENCY_MIN_VAL); + u32Hz = min(u32Hz, (uint32_t)FREQUENCY_MAX_VAL); + + /* Pulse period = {Set value of TDRmn (master) + 1} × Count clock period + Set value of TDRmn (master) = (Pulse period / Count clock period) - 1 */ + Result = (uint16_t)((timer_frequency / u32Hz) - 1); + return Result; +} + +static uint16_t _analogDuty(int val, uint16_t frequency) +{ +/* Duty factor [0 ~ 255] = {Set value of TDRmp (slave)}/{Set value of TDRmn (master) + 1} × 255 + {Set value of TDRmp (slave)} = Duty factor * {Set value of TDRmn (master) + 1} / 255 */ + uint16_t u16Duty = 0; + /* Duty set */ + if(val >= PWM_MAX) + { + u16Duty = 0; + } + else if(val == PWM_MIN) + { + u16Duty = frequency + 1; + + } + else + { + u16Duty = (uint16_t)(((unsigned long) val + * (frequency + 1)) / PWM_MAX); + u16Duty = (frequency + 1) - u16Duty; + } + return u16Duty; +} + +/* 1011 Nhu add */ +static void _analogPinRead (uint8_t pin) +{ + uint8_t pin_index; + if (pin==29) + { + pin_index = 8; + } + else if (pin==40) + { + pin_index = 9; + } + else if (pinpmca) + { + pinMode(pin, INPUT); + /* アナログピンの場合PMCAをセットする */ + *p->portModeControlARegisterAddr |= (unsigned long)(p->pmca); + + + g_u8AnalogReadAvailableTable[pin_index] = true; + } +#elif defined(G16_FPB) + if (0!=p->pmc) + { + pinMode(pin, INPUT); + /* アナログピンの場合PMCAセットする */ + *p->portModeControlRegisterAddr |= (unsigned long)(p->pmc); + *p->portModeControlRegisterAddr &= (unsigned long)~(p->pmc); + g_u8AnalogReadAvailableTable[pin_index] = true; + } +#endif + } +} + +static int _analogRead(uint8_t u8ADS) { + int s16Result = 0; + + uint8_t adc_end_flg = 0; + // 1. AD reference setting + R_Config_ADC_Set_Reference (g_u8AnalogReference); + // 3. Snooze mode return upper / lower limit setting +#if defined(G22_FPB) || defined(G23_FPB) + R_Config_ADC_Set_ComparisonLimit((uint8_t)(g_u16ADUL >> 2), (uint8_t)(g_u16ADLL >> 2)); +#endif // defined(G22_FPB) || defined(G23_FPB) + // 4. AD channel setting + R_Config_ADC_Set_ADChannel(u8ADS); + while(0 == adc_end_flg) + { + g_adc_int_flg=0; + // 2. Trigger mode setting + if (PM_SNOOZE_MODE == g_u8PowerManagementMode) + { +#if defined(G22_FPB) || defined(G23_FPB) + R_Config_ITL000_Stop(); + // Hardware trigger wait mode(RTC), one-shot conversion + R_Config_ADC_Set_ModeTrigger(PM_SNOOZE_MODE); + // 6. Snooze mode ON (interrupt enabled) + R_Config_ADC_Set_SnoozeOn(); //AWC =1 + // 5. AD comparator ON + R_Config_ADC_Snooze_Start(); //enable interrupt & ADCS=1 +#endif // defined(G22_FPB) || defined(G23_FPB) + } + else + { + // Software trigger mode, one-shot conversion +#if defined(G22_FPB) || defined(G23_FPB) + R_Config_ADC_Set_ModeTrigger(PM_NORMAL_MODE); +#endif // defined(G22_FPB) || defined(G23_FPB) + // 5. AD comparator ON + R_Config_ADC_Set_OperationOn(); //ADCE=1 & wait + R_Config_ADC_Start(); //ADCS=1 & enable interrupt + } + // 7. After STOP mode until AD interrupt occurs (loop processing) + while (0 == g_adc_int_flg) + { + if (PM_SNOOZE_MODE == g_u8PowerManagementMode) + { + enterPowerManagementMode (0xFFFFFFFF); + } + else + { + NOP(); + } + } + // 8. Snooze mode Off (interrupt stop) + if (PM_SNOOZE_MODE == g_u8PowerManagementMode) + { +#if defined(G22_FPB) || defined(G23_FPB) + R_Config_ADC_Set_SnoozeOff(); + R_Config_ADC_Snooze_Stop(); + R_Config_ITL000_Start(); +#endif // defined(G22_FPB) || defined(G23_FPB) + } + else + { + R_Config_ADC_Stop(); + } + // 9. Get AD conversion result + if (DEFAULT == g_u8AnalogReference) + { + R_Config_ADC_Get_Result_10bit ((uint16_t*) &s16Result); + } + else if (INTERNAL == g_u8AnalogReference) + { + R_Config_ADC_Get_Result_8bit ((uint8_t*) &s16Result); + } + if (PM_SNOOZE_MODE == g_u8PowerManagementMode) + { + if((g_u16ADLL <= (uint16_t)s16Result) && ((uint16_t)s16Result <= g_u16ADUL)) + { + adc_end_flg = 1; + } + } + else + { + adc_end_flg = 1; + } + } + // 10.AD Comparator Off + R_Config_ADC_Set_OperationOff(); + return s16Result; +} diff --git a/cores/rl78g22/wiring_digital.c b/cores/rl78g22/wiring_digital.c index 1af51fd..83b2748 100644 --- a/cores/rl78g22/wiring_digital.c +++ b/cores/rl78g22/wiring_digital.c @@ -1,387 +1,354 @@ -/* - wiring_digital.c - digital input and output functions - Part of Arduino - http://www.arduino.cc/ - - Copyright (c) 2005-2006 David A. Mellis - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - Modified 28 September 2010 by Mark Sproul - - $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ -*/ -/* - * Modified 4 Mar 2017 by Yuuki Okamiya for RL78/G13 -*/ - -#define ARDUINO_MAIN -#include "wiring_private.h" -#include "pins_variant.h" -#include "wiring_private.h" -#include "api/Common.h" -#include "pintable.h" - -#define PMPUPIMPOM_CHECK_ENABLE /* Do not change invalid bits */ - -extern bool g_u8AnalogWriteAvailableTable[NUM_DIGITAL_PINS]; -extern volatile SwPwm g_SwPwm[NUM_SWPWM_PINS]; -extern const PinTableType * pinTablelist[NUM_DIGITAL_PINS]; - -/********************************************************************************************************************** - * Function Name: pintable setting - * Description : Set the pintable. - * Arguments : pin - pin number - * : pp - pin table - * Return Value : - - *********************************************************************************************************************/ - -/** - * PWM STOP~ - * - * @param[in] u8Timer Timer Number of PWM - * - * @return Nothing - * - * @attention Nothing - ***************************************************************************/ -void _turnOffPwmPin(uint8_t u8Pin) -{ - unsigned int u16TMR0x; - - uint8_t u8Timer = 0xFF; - if (u8Pin < NUM_DIGITAL_PINS) { - g_u8AnalogWriteAvailableTable[u8Pin] = false; - } - if (u8Timer == SWPWM_PIN) - { - int i; - - for (i = 0; i < NUM_SWPWM_PINS; i++) { - if (g_SwPwm[i].valid) { - if (g_SwPwm[i].pin == u8Pin) { - g_SwPwm[i].valid = false; - } else { - break; - } - } - } - if (i >= NUM_SWPWM_PINS) { // SoftwarePWM�̐ݒ�Ȃ� - _stopTimerChannel(SW_PWM_TIMER); - } - } - else - { - switch (u8Timer) { - case 1: - u16TMR0x = TMR01; - break; - case 2: - u16TMR0x = TMR02; - break; - case 3: - u16TMR0x = TMR03; - break; - case 4: - u16TMR0x = TMR04; - break; - case 5: - u16TMR0x = TMR05; - break; - case 6: - u16TMR0x = TMR06; - break; - case 7: - u16TMR0x = TMR07; - break; - default: - u16TMR0x = PWM_MASTER_MODE; - break; - } - if (u16TMR0x == PWM_SLAVE_MODE) { - _stopTimerChannel(u8Timer); - } - } -} - -/********************************************************************************************************************** - * Function Name: pinmode setting - * Description : Set the port register. - * Arguments : - - * Return Value : - - *********************************************************************************************************************/ -// void pinMode(uint8_t pin, uint8_t u8Mode) -void pinMode(pin_size_t pin, PinMode pinMode) -{ - uint8_t u8Mode = (uint8_t)pinMode; - if (pin < NUM_DIGITAL_PINS) { - if(CHECK_PINMODE_INHIBIT_RL78(pin)) - { - return; - } - - //PinTableType pin_tbl; - //p = (PinTableType*)&pin_tbl; - //getPinTable(pin,p); - - const PinTableType **pp; - PinTableType *p; - pp = &pinTablelist[pin]; - p = (PinTableType *)*pp; - -#ifdef PMPUPIMPOM_CHECK_ENABLE - if (0 != p->pm){ -#endif - switch (u8Mode) { - case OUTPUT: - *p->portModeRegisterAddr &= (unsigned long)~(0x1 << p->bit); - break; - case INPUT: - *p->portModeRegisterAddr |= (unsigned long)(0x1 << p->bit); - break; - default: - break; - } -#ifdef PMPUPIMPOM_CHECK_ENABLE - } -#endif - - /* clear pmca register when analog pin */ - if (0!=p->pmca) - { - *p->portModeControlARegisterAddr &= (unsigned long)~(p->pmca); - } - - /* clear pmct register when touch pin */ - if (0!=p->pmct) - { - *p->portModeControlTRegisterAddr &= (unsigned long)~(p->pmct); - } - - /* clear pmce register when ELCL pin */ -#if defined(G23_FPB) - if (0!=p->pmce) - { - *p->portModeControlERegisterAddr &= (unsigned long)~(p->pmce); - } -#endif // G23_FPB - /* clear ccde register */ -#if defined(G23_FPB) - if (0!=p->ccde) - { - *p->portOutCurControlRegisterAddr &= (unsigned long)~(p->ccde); - } -#endif // G23_FPB - - if (g_u8AnalogWriteAvailableTable[pin]) { - _turnOffPwmPin(pin); /* PWM setting cancel */ - } - if (!(*p->portModeRegisterAddr & p->mask)) { - if (*p->portRegisterAddr & p->mask) { - if (u8Mode == INPUT) { - u8Mode = INPUT_PULLUP; - } else if (u8Mode == INPUT_TTL) { - u8Mode = INPUT_TTL_PULLUP; - } - } - } - - switch (u8Mode) { - case INPUT: - case INPUT_PULLUP: - case INPUT_TTL: - case INPUT_TTL_PULLUP: - if (0 != p->pu){ - if (u8Mode == INPUT_PULLUP || u8Mode == INPUT_TTL_PULLUP) { - *p->portPullUpRegisterAddr |= (unsigned long)(0x1 << p->bit); /* Enable Pullup Reg */ - } else { - *p->portPullUpRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* Disable Pullup Reg */ - } - } - if (0 != p->pim){ - if (u8Mode == INPUT_TTL || u8Mode == INPUT_TTL_PULLUP) { - *p->portInputModeRegisterAddr |= (unsigned long)(0x1 << p->bit); /* set TTL Input */ - } else { - *p->portInputModeRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* set CMOS Onput */ - } - } - if (0 != p->pm){ - *p->portModeRegisterAddr |= (unsigned long)(1U << p->bit); /* set Input Mode */ - } - if (0 != p->pom){ - *p->portOutputModeRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* set Normal Output */ - } -#if defined(G23_FPB) - if (0 != p->pdidis){ - *p->portDigInputDisRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* set Input enable */ - } -#endif // G23_FPB - break; - case OUTPUT: - case OUTPUT_OPENDRAIN: -// 2023/03/02 -// if((pin==27) || (pin==28) || (pin==41)) - if(CHECK_OUTPUT_INHIBIT_RL78(pin)) - { - break; - } - if (u8Mode == OUTPUT_OPENDRAIN) { - if (0 != p->pom){ - *p->portOutputModeRegisterAddr |= (unsigned long)(0x1 << p->bit); /* set N-ch OpenDrain output */ - } -#if defined(G23_FPB) - if (0 != p->pdidis){ - *p->portDigInputDisRegisterAddr |= (unsigned long)(0x1 << p->bit); /* set N-ch Input disable */ - } -#endif // G23_FPB - } else { - if (0 != p->pom){ - *p->portOutputModeRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* set Normal Output */ - } -#if defined(G23_FPB) - if (0 != p->pdidis){ - *p->portDigInputDisRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* set Input enable */ - } -#endif // G23_FPB - } - if (0 != p->pm){ - *p->portModeRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* set Output Mode */ - } - if (0 != p->pu){ - *p->portPullUpRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* Disable Pullup Reg */ - } - if (0 != p->pim){ - *p->portInputModeRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* set CMOS Input */ - } - *p->portRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* clear Port */ - break; - default: - break; - } - } -} - -/********************************************************************************************************************** - * Function Name: pin output - * Description : Perform port output - * Arguments : pin - pin number - * : pp - output value - * Return Value : - - *********************************************************************************************************************/ -// void digitalWrite(uint8_t pin, uint8_t val) -void digitalWrite(pin_size_t pin, PinStatus val) -{ - const PinTableType ** pp; - PinTableType * p; - if (pin < NUM_DIGITAL_PINS) - { - if(CHECK_OUTPUT_INHIBIT_RL78(pin)) - { - return; - } - pp = &pinTablelist[pin]; - p = (PinTableType *)*pp; - /* When Output Mode */ - if (val == LOW) { - *p->portRegisterAddr &= ~p->mask; /* Write "0" to Port */ - } else { - *p->portRegisterAddr |= p->mask; /* Write "1" to Port */ - } - } -} - -/********************************************************************************************************************** - * Function Name: pin input - * Description : Perform port input - * Arguments : pin - pin number - * Return Value : input value - *********************************************************************************************************************/ -// int digitalRead(uint8_t pin) -PinStatus digitalRead(pin_size_t pin){ - if (pin < NUM_DIGITAL_PINS) { - //PinTableType* p; - //PinTableType pin_tbl; - //p =(PinTableType*)&pin_tbl; - //getPinTable(pin,p); - - const PinTableType ** pp; - PinTableType * p; - pp = &pinTablelist[pin]; - p = (PinTableType *)*pp; - if (*p->portRegisterAddr & p->mask) { - - return HIGH; - } - } - return LOW; - -} - -#ifdef __RL78__ -/********************************************************************************************************************** - * Function Name: disable input pin - * Description : Prohibits the input of the specified pin. - * Arguments : pin - pin number - * Return Value : - - *********************************************************************************************************************/ -void DisableDigitalInput(uint8_t pin) -{ - - if (pin < NUM_DIGITAL_PINS) { - //PinTableType *p; - //PinTableType pin_tbl; - //p = (PinTableType*)&pin_tbl; - //getPinTable(pin,p); - - const PinTableType ** pp; - PinTableType * p; - pp = &pinTablelist[pin]; - p = (PinTableType *)*pp; -#if defined(G23_FPB) - if (0 != p->pdidis){ /* can be changed */ - *p->portDigInputDisRegisterAddr |= (unsigned long)(0x1 << p->bit); /* Input disable */ - } -#endif // G23_FPB - } -} - -/********************************************************************************************************************** - * Function Name: enable input pin - * Description : Allows the input of the specified pin. - * Arguments : pin - pin number - * Return Value : - - *********************************************************************************************************************/ -void EnableDigitalInput(uint8_t pin) -{ - - if (pin < NUM_DIGITAL_PINS) { - //PinTableType *p; - //PinTableType pin_tbl; - //p = (PinTableType*)&pin_tbl; - //getPinTable(pin,p); - - const PinTableType ** pp; - PinTableType * p; - pp = &pinTablelist[pin]; - p = (PinTableType *)*pp; -#if defined(G23_FPB) - if (0 != p->pdidis){ /* can be changed */ - *p->portDigInputDisRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* set Input enable */ - } -#endif // G23_FPB - } -} -#endif /*__RL78__*/ - +/* + wiring_digital.c - digital input and output functions + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2005-2006 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + Modified 28 September 2010 by Mark Sproul + + $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ +*/ +/* + * Modified 4 Mar 2017 by Yuuki Okamiya for RL78/G13 +*/ + +#define ARDUINO_MAIN +#include "wiring_private.h" +#include "pins_variant.h" +#include "wiring_private.h" +#include "api/Common.h" +#include "pintable.h" + +#define PMPUPIMPOM_CHECK_ENABLE /* Do not change invalid bits */ + +extern bool g_u8AnalogWriteAvailableTable[NUM_DIGITAL_PINS]; +extern volatile SwPwm g_SwPwm[NUM_SWPWM_PINS]; +extern const PinTableType * pinTablelist[NUM_DIGITAL_PINS]; +extern Pwm_func pwm_ch[PWM_CH_NUM]; +extern int8_t get_pwm_channel(uint8_t pwm_num); + +/********************************************************************************************************************** + * Function Name: pintable setting + * Description : Set the pintable. + * Arguments : pin - pin number + * : pp - pin table + * Return Value : - + *********************************************************************************************************************/ + +/** + * PWM STOP~ + * + * @param[in] u8Timer Timer Number of PWM + * + * @return Nothing + * + * @attention Nothing + ***************************************************************************/ +void _turnOffPwmPin(uint8_t u8Pin) +{ + if (u8Pin < NUM_DIGITAL_PINS) { + g_u8AnalogWriteAvailableTable[u8Pin] = false; + } + int8_t pwm_channel = get_pwm_channel(u8Pin); + if(pwm_channel != -1) + { + pwm_ch[pwm_channel].stop_slave(); + } +} + +/********************************************************************************************************************** + * Function Name: pinmode setting + * Description : Set the port register. + * Arguments : - + * Return Value : - + *********************************************************************************************************************/ +// void pinMode(uint8_t pin, uint8_t u8Mode) +void pinMode(pin_size_t pin, PinMode pinMode) +{ + uint8_t u8Mode = (uint8_t)pinMode; + if (pin < NUM_DIGITAL_PINS) { + if(CHECK_PINMODE_INHIBIT_RL78(pin)) + { + return; + } + + //PinTableType pin_tbl; + //p = (PinTableType*)&pin_tbl; + //getPinTable(pin,p); + + const PinTableType **pp; + PinTableType *p; + pp = &pinTablelist[pin]; + p = (PinTableType *)*pp; + +#ifdef PMPUPIMPOM_CHECK_ENABLE + if (0 != p->pm){ +#endif + switch (u8Mode) { + case OUTPUT: + *p->portModeRegisterAddr &= (unsigned long)~(0x1 << p->bit); + break; + case INPUT: + *p->portModeRegisterAddr |= (unsigned long)(0x1 << p->bit); + break; + default: + break; + } +#ifdef PMPUPIMPOM_CHECK_ENABLE + } +#endif + + /* clear pmca register when analog pin */ +#if defined(G22_FPB) || defined(G23_FPB) + + if (0!=p->pmca) + { + *p->portModeControlARegisterAddr &= (unsigned long)~(p->pmca); + } +#endif // defined(G22_FPB) || defined(G23_FPB) +#if defined(G16_FPB) + if (0!=p->pmc) + { + *p->portModeControlRegisterAddr &= (unsigned long)~(p->pmc); + } +#endif + /* clear pmct register when touch pin */ +#if defined(G22_FPB) || defined(G23_FPB) + if (0!=p->pmct) + { + *p->portModeControlTRegisterAddr &= (unsigned long)~(p->pmct); + } +#endif // defined(G22_FPB) || defined(G23_FPB) + + /* clear pmce register when ELCL pin */ +#if defined(G23_FPB) + if (0!=p->pmce) + { + *p->portModeControlERegisterAddr &= (unsigned long)~(p->pmce); + } +#endif // G23_FPB + /* clear ccde register */ +#if defined(G23_FPB) + if (0!=p->ccde) + { + *p->portOutCurControlRegisterAddr &= (unsigned long)~(p->ccde); + } +#endif // G23_FPB + + if (g_u8AnalogWriteAvailableTable[pin]) { + _turnOffPwmPin(pin); /* PWM setting cancel */ + } + if (!(*p->portModeRegisterAddr & p->mask)) { + if (*p->portRegisterAddr & p->mask) { + if (u8Mode == INPUT) { + u8Mode = INPUT_PULLUP; + } else if (u8Mode == INPUT_TTL) { + u8Mode = INPUT_TTL_PULLUP; + } + } + } + + switch (u8Mode) { + case INPUT: + case INPUT_PULLUP: + case INPUT_TTL: + case INPUT_TTL_PULLUP: + if (0 != p->pu){ + if (u8Mode == INPUT_PULLUP || u8Mode == INPUT_TTL_PULLUP) { + *p->portPullUpRegisterAddr |= (unsigned long)(0x1 << p->bit); /* Enable Pullup Reg */ + } else { + *p->portPullUpRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* Disable Pullup Reg */ + } + } +#if defined(G22_FPB) || defined(G23_FPB) + if (0 != p->pim){ + if (u8Mode == INPUT_TTL || u8Mode == INPUT_TTL_PULLUP) { + *p->portInputModeRegisterAddr |= (unsigned long)(0x1 << p->bit); /* set TTL Input */ + } else { + *p->portInputModeRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* set CMOS Onput */ + } + } +#endif // G23_FPB + if (0 != p->pm){ + *p->portModeRegisterAddr |= (unsigned long)(1U << p->bit); /* set Input Mode */ + } + if (0 != p->pom){ + *p->portOutputModeRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* set Normal Output */ + } +#if defined(G23_FPB) + if (0 != p->pdidis){ + *p->portDigInputDisRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* set Input enable */ + } +#endif // G23_FPB + break; + case OUTPUT: + case OUTPUT_OPENDRAIN: + if(CHECK_OUTPUT_INHIBIT_RL78(pin)) + { + break; + } + if (u8Mode == OUTPUT_OPENDRAIN) { + if (0 != p->pom){ + *p->portOutputModeRegisterAddr |= (unsigned long)(0x1 << p->bit); /* set N-ch OpenDrain output */ + } +#if defined(G23_FPB) + if (0 != p->pdidis){ + *p->portDigInputDisRegisterAddr |= (unsigned long)(0x1 << p->bit); /* set N-ch Input disable */ + } +#endif // G23_FPB + } else { + if (0 != p->pom){ + *p->portOutputModeRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* set Normal Output */ + } +#if defined(G23_FPB) + if (0 != p->pdidis){ + *p->portDigInputDisRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* set Input enable */ + } +#endif // G23_FPB + } + if (0 != p->pm){ + *p->portModeRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* set Output Mode */ + } + if (0 != p->pu){ + *p->portPullUpRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* Disable Pullup Reg */ + } +#if defined(G22_FPB) || defined(G23_FPB) + if (0 != p->pim){ + *p->portInputModeRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* set CMOS Input */ + } +#endif // G23_FPB + *p->portRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* clear Port */ + break; + default: + break; + } + } +} + +/********************************************************************************************************************** + * Function Name: pin output + * Description : Perform port output + * Arguments : pin - pin number + * : pp - output value + * Return Value : - + *********************************************************************************************************************/ +// void digitalWrite(uint8_t pin, uint8_t val) +void digitalWrite(pin_size_t pin, PinStatus val) +{ + const PinTableType ** pp; + PinTableType * p; + if (pin < NUM_DIGITAL_PINS) + { + if(CHECK_OUTPUT_INHIBIT_RL78(pin)) + { + return; + } + pp = &pinTablelist[pin]; + p = (PinTableType *)*pp; + /* When Output Mode */ + if (val == LOW) { + *p->portRegisterAddr &= ~p->mask; /* Write "0" to Port */ + } else { + *p->portRegisterAddr |= p->mask; /* Write "1" to Port */ + } + } +} + +/********************************************************************************************************************** + * Function Name: pin input + * Description : Perform port input + * Arguments : pin - pin number + * Return Value : input value + *********************************************************************************************************************/ +// int digitalRead(uint8_t pin) +PinStatus digitalRead(pin_size_t pin){ + if (pin < NUM_DIGITAL_PINS) { + //PinTableType* p; + //PinTableType pin_tbl; + //p =(PinTableType*)&pin_tbl; + //getPinTable(pin,p); + + const PinTableType ** pp; + PinTableType * p; + pp = &pinTablelist[pin]; + p = (PinTableType *)*pp; + if (*p->portRegisterAddr & p->mask) { + + return HIGH; + } + } + return LOW; + +} + +#ifdef __RL78__ +/********************************************************************************************************************** + * Function Name: disable input pin + * Description : Prohibits the input of the specified pin. + * Arguments : pin - pin number + * Return Value : - + *********************************************************************************************************************/ +void DisableDigitalInput(uint8_t pin) +{ + + if (pin < NUM_DIGITAL_PINS) { + //PinTableType *p; + //PinTableType pin_tbl; + //p = (PinTableType*)&pin_tbl; + //getPinTable(pin,p); + + const PinTableType ** pp; + PinTableType * p; + pp = &pinTablelist[pin]; + p = (PinTableType *)*pp; +#if defined(G23_FPB) + if (0 != p->pdidis){ /* can be changed */ + *p->portDigInputDisRegisterAddr |= (unsigned long)(0x1 << p->bit); /* Input disable */ + } +#endif // G23_FPB + } +} + +/********************************************************************************************************************** + * Function Name: enable input pin + * Description : Allows the input of the specified pin. + * Arguments : pin - pin number + * Return Value : - + *********************************************************************************************************************/ +void EnableDigitalInput(uint8_t pin) +{ + + if (pin < NUM_DIGITAL_PINS) { + //PinTableType *p; + //PinTableType pin_tbl; + //p = (PinTableType*)&pin_tbl; + //getPinTable(pin,p); + + const PinTableType ** pp; + PinTableType * p; + pp = &pinTablelist[pin]; + p = (PinTableType *)*pp; +#if defined(G23_FPB) + if (0 != p->pdidis){ /* can be changed */ + *p->portDigInputDisRegisterAddr &= (unsigned long)~(0x1 << p->bit); /* set Input enable */ + } +#endif // G23_FPB + } +} +#endif /*__RL78__*/ + diff --git a/cores/rl78g22/wiring_private.h b/cores/rl78g22/wiring_private.h index c39dfda..1ab32bd 100644 --- a/cores/rl78g22/wiring_private.h +++ b/cores/rl78g22/wiring_private.h @@ -1,74 +1,80 @@ -/* - wiring_private.h - Internal header file. - Part of Arduino - http://www.arduino.cc/ - - Copyright (c) 2005-2006 David A. Mellis - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - $Id: wiring.h 239 2007-01-12 17:58:39Z mellis $ -*/ -/* - Modified 13 July 2014 by Nozomu Fujita for GR-SAKURA - Modified 1 Mar 2017 by Yuuki Okamiya for RL78/G13 -*/ - -#ifndef WiringPrivate_h -#define WiringPrivate_h - -#include -#include -#include "Arduino.h" -#include "utilities.h" -#include "wiring_variant.h" - -#ifdef __cplusplus -extern "C"{ -#endif -fInterruptFunc_t g_afInterruptFuncTable[EXTERNAL_NUM_INTERRUPTS] __attribute__((weak)); -#define CYCLE_VALUE (0) -#define TAU_OPERATION_CLOCK (0xC000U) /* operation clock set by PRS register */ -#define CK00_CK01_OPERATION (0x000F) /* Selection of operation clock CK00, CK01 */ -#define CK02_OPERATION (0x0300) /* Selection of operation clock CK02 */ -#define CK03_OPERATION (0x3000) /* Selection of operation clock CK03 */ -#define TIMEOUT_MAX_VAL (65535) -#define PULSE_INTERUPT (1) - -typedef struct { - uint8_t valid:1; - uint8_t pin:7; - uint8_t value; - volatile uint8_t* port; - uint8_t mask; - uint8_t newValue; -} SwPwm; - -typedef struct { - void (*open)(); - void (*start)(); - uint16_t cycle; -} Pwm_func; - -int8_t get_pwm_channel(uint8_t pwm_num); -int8_t get_analog_channel(uint8_t analog_num); -int8_t get_pulse_in_channel(uint8_t pulse_in_num); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif /* WiringPrivate_h */ - +/* + wiring_private.h - Internal header file. + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2005-2006 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + $Id: wiring.h 239 2007-01-12 17:58:39Z mellis $ +*/ +/* + Modified 13 July 2014 by Nozomu Fujita for GR-SAKURA + Modified 1 Mar 2017 by Yuuki Okamiya for RL78/G13 +*/ + +#ifndef WiringPrivate_h +#define WiringPrivate_h + +#include +#include +#include "Arduino.h" +#include "utilities.h" +#include "wiring_variant.h" + +#ifdef __cplusplus +extern "C"{ +#endif +fInterruptFunc_t g_afInterruptFuncTable[EXTERNAL_NUM_INTERRUPTS] __attribute__((weak)); + +#define CYCLE_VALUE (0) +#define TAU_OPERATION_CLOCK (0xC000U) /* operation clock set by PRS register */ +#define CK00_CK01_OPERATION (0x000F) /* Selection of operation clock CK00, CK01 */ +#define CK02_OPERATION (0x0300) /* Selection of operation clock CK02 */ +#define CK03_OPERATION (0x3000) /* Selection of operation clock CK03 */ +#define TIMEOUT_MAX_VAL (65535) +#define PULSE_INTERUPT (1) + +#define MICROSEC_OVFL_FLAG (TMIF06) +#define MICROSEC_TIMER_CNT (TCR06) +typedef struct { + uint8_t valid:1; + uint8_t pin:7; + uint8_t value; + volatile uint8_t* port; + uint8_t mask; + uint8_t newValue; +} SwPwm; + +typedef struct { + void (*open)(); + void (*open_slave)(); + void (*start)(); + void (*start_slave)(); + void (*stop_slave)(); + void (*enable_interrupt)(); + uint16_t cycle; +} Pwm_func; + +int8_t get_pwm_channel(uint8_t pwm_num); +int8_t get_analog_channel(uint8_t analog_num); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif /* WiringPrivate_h */ + diff --git a/cores/rl78g22/wiring_pulse.c b/cores/rl78g22/wiring_pulse.c index eb6f636..db53ffc 100644 --- a/cores/rl78g22/wiring_pulse.c +++ b/cores/rl78g22/wiring_pulse.c @@ -1,268 +1,89 @@ -/* - wiring_pulse.c - pulseIn() function - Part of Arduino - http://www.arduino.cc/ - - Copyright (c) 2005-2006 David A. Mellis - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ -*/ -/* - * Modified 5 Mar 2017 by Yuuki Okamiya for RL78/G13 - * Modified 18 Mar 2017 by Nozomu Fujita for pulseInWait, pulseInCount -*/ - -#include "wiring_private.h" -#include "wiring_variant.h" -#include "pins_variant.h" -#include "pintable.h" -#include "r_smc_entry.h" - - -int8_t get_pulse_in_channel(uint8_t pulse_in_num) -{ - int8_t pulse_in_cnt; - - for(pulse_in_cnt=0;pulse_in_cnt> 8; - timer_frequency = fclk_frequency / (1 << (operating_clock_select * 2)) ; /* fclk/2^2 ~ 2^6 */ - } - } - else if (clock_mode == _C000_TAU_CLOCK_SELECT_CKM3) - { - operating_clock_select = *g_timer_pulse_clock_select_reg & CK03_OPERATION; - - operating_clock_select = operating_clock_select >> 12; - timer_frequency = fclk_frequency / (1 << (operating_clock_select * 2 + 8)); /* fclk/2^8 ~ 2^14 */ - } - else /* CK00, CK01 Clock Select */ - { - operating_clock_select = *g_timer_pulse_clock_select_reg & CK00_CK01_OPERATION; - timer_frequency = fclk_frequency / (1 << operating_clock_select) ; /* ckm00, ckm01 - fclk/2^0 ~ 2^15 */ - } - return timer_frequency; -} +/* + wiring_pulse.c - pulseIn() function + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2005-2006 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ +*/ +/* + * Modified 5 Mar 2017 by Yuuki Okamiya for RL78/G13 + * Modified 18 Mar 2017 by Nozomu Fujita for pulseInWait, pulseInCount +*/ + +#include "wiring_variant.h" + +extern const PinTableType * pinTablelist[NUM_DIGITAL_PINS]; + +static uint32_t countPulse(volatile uint8_t *port, uint8_t bit, uint8_t stateMask, unsigned long maxloops) { + unsigned long width = 0; + // wait for any previous pulse to end + while ((*port & bit) == stateMask) { + if (--maxloops == 0) + return 0; + } + + // wait for the pulse to start + while ((*port & bit) != stateMask) { + if (--maxloops == 0) + return 0; + } + + // wait for the pulse to stop + while ((*port & bit) == stateMask) { + if (++width == maxloops) + return 0; + } + return width; +} + +/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH + * or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds + * to 3 minutes in length, but must be called at least a few dozen microseconds + * before the start of the pulse. */ +uint32_t pulseIn(pin_size_t pin, uint8_t state, uint32_t timeout) +{ + const PinTableType **pp; + PinTableType *p; + pp = &pinTablelist[pin]; + p = (PinTableType *)*pp; + // unsigned long start; + // unsigned long startMicros = micros(); + // cache the port and bit of the pin in order to speed up the + // pulse width measuring loop and achieve finer resolution. calling + // digitalRead() instead yields much coarser resolution. + //uint16_t port = digitalPinToPort(pin); + //uint16_t bit = digitalPinToBitMask(pin); + uint8_t bit = p->mask; + uint8_t stateMask = state ? bit : 0; + + // convert the timeout from microseconds to a number of times through + // the initial loop; it takes (roughly) 18 clock cycles per iteration. + uint32_t maxloops = microsecondsToClockCycles(timeout) / PULSEIN_CLOCK_CYCLE; + + uint32_t width = countPulse((volatile uint8_t*)p->portRegisterAddr, bit, stateMask, maxloops); + + // convert the reading to microseconds. The loop has been determined + // to be 18 clock cycles long and have about 16 clocks between the edge + // and the start of the loop. There will be some error introduced by + // the interrupt handlers. + if (width) + return clockCyclesToMicroseconds(width * PULSEIN_CLOCK_CYCLE + 0); + else + return 0; +} diff --git a/cores/rl78g22/wiring_pulse_long.c b/cores/rl78g22/wiring_pulse_long.c new file mode 100644 index 0000000..933ac80 --- /dev/null +++ b/cores/rl78g22/wiring_pulse_long.c @@ -0,0 +1,92 @@ +/*********************************************************************************************************************** +* DISCLAIMER +* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. +* No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all +* applicable laws, including copyright laws. +* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED +* OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY +* LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, +* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR +* ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability +* of this software. By using this software, you agree to the additional terms and conditions found by accessing the +* following link: +* http://www.renesas.com/disclaimer +* +* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. +***********************************************************************************************************************/ + +/*********************************************************************************************************************** + wiring_pulse.c - pulseIn() function + + +***********************************************************************************************************************/ + +#include "Arduino.h" +#include "pins_arduino.h" + +extern const PinTableType * pinTablelist[NUM_DIGITAL_PINS]; + +unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout) +{ + // cache the port and bit of the pin in order to speed up the + // pulse width measuring loop and achieve finer resolution. calling + // digitalRead() instead yields much coarser resolution. + const PinTableType **pp; + PinTableType *p; + pp = &pinTablelist[pin]; + p = (PinTableType *)*pp; + unsigned long start; + unsigned long startMicros = micros(); + if(state == HIGH) + { + // wait for any previous pulse to end + while ((*p->portRegisterAddr & p->mask) != 0) + { + if (micros() - startMicros > timeout) + return 0; + } + + // wait for the pulse to start + while ((*p->portRegisterAddr & p->mask) == 0) + { + if (micros() - startMicros > timeout) + return 0; + } + + start = micros(); + // wait for the pulse to stop + while ((*p->portRegisterAddr & p->mask) > 0) + { + if (micros() - startMicros > timeout) + return 0; + } + } + else + { + // wait for any previous pulse to end + while ((*p->portRegisterAddr & p->mask) == 0) + { + if (micros() - startMicros > timeout) + return 0; + } + + // wait for the pulse to start + while ((*p->portRegisterAddr & p->mask) != 0) + { + if (micros() - startMicros > timeout) + return 0; + } + + start = micros(); + // wait for the pulse to stop + while ((*p->portRegisterAddr & p->mask) == 0) + { + if (micros() - startMicros > timeout) + return 0; + } + } + return micros() - start; +} + diff --git a/cores/rl78g22/wiring_shift.c b/cores/rl78g22/wiring_shift.c index 025a62d..5580d01 100644 --- a/cores/rl78g22/wiring_shift.c +++ b/cores/rl78g22/wiring_shift.c @@ -1,106 +1,106 @@ -/* - wiring_shift.c - shiftOut() function - Part of Arduino - http://www.arduino.cc/ - - Copyright (c) 2005-2006 David A. Mellis - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ -*/ - -#include "api/ArduinoAPI.h" -#include "wiring_private.h" -// #include "ArduinoClassics.h" - - -uint8_t shiftIn(pin_size_t dataPin, pin_size_t clockPin, BitOrder bitOrder) -// uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) -{ - uint8_t value = 0; - uint8_t i; - - for (i = 0; i < 8; ++i) - { - digitalWrite(clockPin, HIGH); - - if (bitOrder == LSBFIRST) - { - value |= digitalRead(dataPin) << i; - } - else - { - value |= digitalRead(dataPin) << (7 - i); - } - digitalWrite(clockPin, LOW); - } - - return value; -} - -// void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t value) -void shiftOut(pin_size_t dataPin, pin_size_t clockPin, BitOrder bitOrder, uint8_t value){ - uint8_t i; - - for (i = 0; i < 8; i++) - { - if (bitOrder == LSBFIRST) - { - digitalWrite(dataPin, !!(value & (1 << i))); - } - else - { - digitalWrite(dataPin, !!(value & (1 << (7 - i)))); - } - - digitalWrite(clockPin, HIGH); - digitalWrite(clockPin, LOW); - } - -} - -/* 1112 nhu add */ -void shiftOutEx(uint8_t dataPin, uint8_t clockPin, BitOrder bitOrder, uint8_t len, uint32_t value) -{ - uint8_t i; - - if(len <= 32) - { - if (bitOrder == LSBFIRST) - { - for(i = 0; i < len; i++) - { - digitalWrite(dataPin, ((value >> i) & 0x00000001)); - digitalWrite(clockPin, HIGH); - digitalWrite(clockPin, LOW); - } - } - else - { - for(i = len ; i > 0 ; i--) - { - digitalWrite(dataPin, ((value >> (i-1)) & 0x00000001)); - digitalWrite(clockPin, HIGH); - digitalWrite(clockPin, LOW); - } - } - - } - -} - - -/* 1112 nhu add */ +/* + wiring_shift.c - shiftOut() function + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2005-2006 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ +*/ + +#include "api/ArduinoAPI.h" +#include "wiring_private.h" +// #include "ArduinoClassics.h" + + +uint8_t shiftIn(pin_size_t dataPin, pin_size_t clockPin, BitOrder bitOrder) +// uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) +{ + uint8_t value = 0; + uint8_t i; + + for (i = 0; i < 8; ++i) + { + digitalWrite(clockPin, HIGH); + + if (bitOrder == LSBFIRST) + { + value |= digitalRead(dataPin) << i; + } + else + { + value |= digitalRead(dataPin) << (7 - i); + } + digitalWrite(clockPin, LOW); + } + + return value; +} + +// void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t value) +void shiftOut(pin_size_t dataPin, pin_size_t clockPin, BitOrder bitOrder, uint8_t value){ + uint8_t i; + + for (i = 0; i < 8; i++) + { + if (bitOrder == LSBFIRST) + { + digitalWrite(dataPin, !!(value & (1 << i))); + } + else + { + digitalWrite(dataPin, !!(value & (1 << (7 - i)))); + } + + digitalWrite(clockPin, HIGH); + digitalWrite(clockPin, LOW); + } + +} + +/* 1112 nhu add */ +void shiftOutEx(uint8_t dataPin, uint8_t clockPin, BitOrder bitOrder, uint8_t len, uint32_t value) +{ + uint8_t i; + + if(len <= 32) + { + if (bitOrder == LSBFIRST) + { + for(i = 0; i < len; i++) + { + digitalWrite(dataPin, ((value >> i) & 0x00000001)); + digitalWrite(clockPin, HIGH); + digitalWrite(clockPin, LOW); + } + } + else + { + for(i = len ; i > 0 ; i--) + { + digitalWrite(dataPin, ((value >> (i-1)) & 0x00000001)); + digitalWrite(clockPin, HIGH); + digitalWrite(clockPin, LOW); + } + } + + } + +} + + +/* 1112 nhu add */ diff --git a/cores/rl78g22/wiring_tone.cpp b/cores/rl78g22/wiring_tone.cpp index 855f258..c53ac11 100644 --- a/cores/rl78g22/wiring_tone.cpp +++ b/cores/rl78g22/wiring_tone.cpp @@ -1,139 +1,141 @@ -/* - * writing_tone.c - * - * Created on: 2021/11/02 - * Author: hmU11983 - */ - -//#include "pins_arduino_classics.h" -#include "pins_variant.h" -#include "iodefine.h" -#include "iodefine_ext.h" -#include "api/Common.h" -#include "wiring_private_tone.h" - - -extern "C" uint32_t R_BSP_GetFclkFreqHz(void); - -int8_t get_tone_channel(uint8_t tone_num) -{ - int8_t tone_cnt; - - for(tone_cnt=0;tone_cnt> 8; - timer_frequency = fclk_frequency / (1 << (operating_clock_select * 2)) ; /* fclk/2^2 ~ 2^6 */ - } - } - else if (timer_clock_mode == _C000_TAU_CLOCK_SELECT_CKM3) - { - operating_clock_select = *g_timer_tone_clock_select_reg & CK03_OPERATION; - - operating_clock_select = operating_clock_select >> 12; - timer_frequency = fclk_frequency / (1 << (operating_clock_select * 2 + 8)); /* fclk/2^8 ~ 2^14 */ - } - else /* CK00, CK01 Clock Select */ - { - operating_clock_select = *g_timer_tone_clock_select_reg & CK00_CK01_OPERATION; - timer_frequency = fclk_frequency / (1 << operating_clock_select) ; /* ckm00, ckm01 - fclk/2^0 ~ 2^15 */ - } - - /* 500 Hz <= frequency <= 65535Hz */ - frequency = max(frequency, (unsigned int)FREQUENCY_MIN_VAL); - frequency = min(frequency, (unsigned int)65535); - - *g_tone_period_reg[tone_channel] = (uint16_t)((timer_frequency / 2 / frequency) - 1); - - tone_ch[tone_channel].start(); - - if(duration != 0) - { - delay(duration); - noTone(pin); - } - } -} - -// XXX: this function only works properly for timer 2 (the only one we use -// currently). for the others, it should end the tone, but won't restore -// proper PWM functionality for the timer. -/* -void disableTimer(uint8_t _timer) -{ -; -} -*/ - - +/* + * writing_tone.c + * + * Created on: 2021/11/02 + * Author: hmU11983 + */ + +//#include "pins_arduino_classics.h" +#include "pins_variant.h" +#include "iodefine.h" +#include "iodefine_ext.h" +#include "api/Common.h" +#include "wiring_private.h" +#include "wiring_private_tone.h" + + +extern "C" +{ +#if defined(G23_FPB) +#include "Config_Through.h" +#endif // G23_FPB +} + +int8_t get_tone_channel(uint8_t tone_num) +{ + int8_t tone_cnt; + + for(tone_cnt=0;tone_cnt> 8; + timer_frequency = fclk_frequency / (1 << (operating_clock_select * 2)) ; /* fclk/2^2 ~ 2^6 */ + } + } + else if (timer_clock_mode == _C000_TAU_CLOCK_SELECT_CKM3) + { + operating_clock_select = *g_timer_tone_clock_select_reg & CK03_OPERATION; + + operating_clock_select = operating_clock_select >> 12; + timer_frequency = fclk_frequency / (1 << (operating_clock_select * 2 + 8)); /* fclk/2^8 ~ 2^14 */ + } + else /* CK00, CK01 Clock Select */ + { + operating_clock_select = *g_timer_tone_clock_select_reg & CK00_CK01_OPERATION; + timer_frequency = fclk_frequency / (1 << operating_clock_select) ; /* ckm00, ckm01 - fclk/2^0 ~ 2^15 */ + } + + /* 500 Hz <= frequency <= 65535Hz */ + frequency = max(frequency, (unsigned int)FREQUENCY_MIN_VAL); + frequency = min(frequency, (unsigned int)65535); + + *g_tone_period_reg[tone_channel] = (uint16_t)((timer_frequency / 2 / frequency) - 1); + + tone_ch[tone_channel].start(); + + if(duration != 0) + { + delay(duration); + noTone(pin); + } + } +} + + diff --git a/libraries/Ethernet3/.gitignore b/libraries/Ethernet3/.gitignore new file mode 100644 index 0000000..0e4802d --- /dev/null +++ b/libraries/Ethernet3/.gitignore @@ -0,0 +1,2 @@ +*.DS_Store +.DS_Store diff --git a/libraries/Ethernet3/README.md b/libraries/Ethernet3/README.md new file mode 100644 index 0000000..9ab3538 --- /dev/null +++ b/libraries/Ethernet3/README.md @@ -0,0 +1,275 @@ +# Ethernet3 v1.5.x +Ethernet library for Arduino and Ethernetshield2 / WIZ550io / WIZ850io / USR-ES1 with Wiznet W5500 chip +based on the Ethernet2 library of arduino.org + +I added many new functionalities. + +## new in 1.5 +- custom hostname for DHCP +- the PHY is configurable +- Wake on LAN +- added new example for webclient "WebClientReadResponse.ino" + +You need to include + +```cpp +#include // instead Ethernet.h +#include // instead EthernetUdp.h for UDP functionality +``` + +## Custom Hostname + +For use with DHCP you can set a custom hostname, this must be done before Ethernet.begin(mac). + +```cpp +Ethernet.setHostname(char* hostname); +``` + +## PHY Configuration + +The PHY is now configurable, this must done after Ethernet.begin() +Following modes are possible: +HALF_DUPLEX_10, +FULL_DUPLEX_10, +HALF_DUPLEX_100, +FULL_DUPLEX_100, +FULL_DUPLEX_100_AUTONEG, +POWER_DOWN, +ALL_AUTONEG (default) + +```cpp +Ethernet.phyMode(phyMode_t mode); +``` + +## Wake on LAN + +You can set the Wake on LAN functionality + +```cpp +Ethernet.WoL(bool wol); +``` + +## what's next + +In version 2 there will mDNS and a large code cleanup + +A new NTP library is published https://github.com/sstaub/NTP + +## New init procedure **!!!** + +The init of the Ethernetinterface changed, the ordner is now: + +```cpp +Ethernet.begin(mac, ip, subnet, gateway, dns); +``` + +This is more logical. + + +## Multicast support + +Multicast for udp added. You need to set the Multicast IP address and port to listen. + +***example*** + +```cpp +EthernetUdp udp +upd.beginMulticast(multicastIP, port); +``` + +## Unicast blocking support + +An Unicast blocking function is added to set and get the flag in a UDP socket. + +```cpp +void setUnicastBlock(bool block); +bool getUnicastBlock(); +``` + +***example*** + +```cpp +EthernetUDP udp; +udp.setUnicastBlock(true); // to restore the value to standard +udp.setUnicastBlock(false); +udp.setUnicastBlock(); +``` + +## PHY support + +Added some function to read the PHYCFGR in Ethernet3. + +```cpp +uint8_t phyState(); // returns the PHYCFGR +uint8_t link(); // returns the linkstate, 1 = linked, 0 = no link +const char* linkReport(); // returns the linkstate as a string +uint8_t speed(); // returns speed in MB/s +const char* speedReport(); // returns speed as a string +uint8_t duplex(); // returns duplex mode 0 = no link, 1 = Half Duplex, 2 = Full Duplex +const char* duplexReport(); // returns duplex mode as a string +``` + +***example*** + +```cpp +Serial.println(Ethernet.linkReport()); +``` + +## MAC address + +Added some function to read the MAC address in Ethernet3, this is helpfull when you use Wiznet boards like WIZ550io with build in MAC address. + +```cpp +void macAddress(uint8_t mac[]); // get the MAC Address +const char* macAddressReport(); // returns the the MAC Address as a string +``` + +***example*** + +```cpp +uint8_t mac[6]; // array for mac address +Ethernet.macAddress(mac); +``` + +## Socket RAM-Size + +You can de- or increase the RAM-Size for the sockets, this must be done before Ethernet.begin(...) + +The possible socketnumbers are: + +```cpp +Ethernet.init(1); -> 1 Socket with 16k RX/TX buffer +Ethernet.init(2); -> 2 Socket with 8k RX/TX buffer +Ethernet.init(4); -> 4 Socket with 4k RX/TX buffer +Ethernet.init(); -> 8 Socket with 2k RX/TX buffer +``` + +Be carefull with the MAX_SOCK_NUM in w5500.h , it cannot changed dynamicly. + +***example*** + +```cpp +Ethernet.init(4); // reduce to 4 Socket, each with 4k RX/TX buffer +Ethernet.begin(); +``` + +## RST and CS pin settings + +You can set the CS and (Hardware) RST (e.g. WIZ550io or USR-ES1), this must be done before Ethernet.begin(...) + +Standard is Pin 10 for CS and Pin 9 for RST + +```cpp +Ethernet.setCsPin(3); // set Pin 3 for CS +Ethernet.setRstPin(4); // set Pin 4 for RST +``` + +***example*** + +```cpp +Ethernet.setRstPin(); // set Pin 9 for RST +Ethernet.begin(); +``` + +## Hard- and Software Reset + +Two new functions to make resets, Softreset can done only after Ethernet.begin(...) + +For Hardware Reset you need to set the Pin number. + +```cpp +Ethernet.softreset(); // performs a software reset +Ethernet.hardreset(); // performs a hardware reset +``` + +***example*** + +```cpp +Ethernet.setRstPin(); // set Pin 9 for RST +Ethernet.begin(); +Ethernet.hardreset(); +``` + +## Additional TCP settings in Ethernet + +There are two function to set and get the retransmission timeout and retry count, this helps to solve problem with TCP connections with unexpected very long timeouts. Beware the the timeout value multiplier is 100us! + +```cpp +void Ethernet.setRtTimeOut(uint16_t timeout); +uint16_t Ethernet.getRtTimeOut(); +void Ethernet.setRtCount(uint8_t count); +uint8_t Ethernet.getRtCount(); +``` + +***example*** + +```cpp +Ethernet.setRtTimeOut(500); // timeout 50ms +Ethernet.setRtCount(2); + +// to restore the value to standard +Ethernet.setRtTimeOut(); +Ethernet.setRtCount(); +``` + +## Additional settings in EthernetClient + +### ACK feature + +A 'No Delayed ACK' function is added to set and get the flag in a TCP socket. + +```cpp +void setNoDelayedACK(bool ack); +bool getNoDelayedACK(); +``` + +***example*** + +```cpp +EthernetClient tcp; +tcp.setNoDelayedACK(true); + +// to restore the value to standard +tcp.setNoDelayedACK(false); +tcp.setNoDelayedACK(); +``` + +### remoteIP and remoteMAC adresses + +Two new functions for getting the IP and MAC address of a remote host. + +```cpp +void remoteIP(uint8_t *ip); +void remoteMAC(uint8_t *mac); +``` + +## Additional settings in EthernetUDP + +### Broadcast feature in EthernetUDP + +A Broadcast blocking function is added to set and get the flag in a UDP socket. + +```cpp +void setBroadcastBlock(bool block); +bool getBroadcastBlock(); +``` + +***example*** + +```cpp +EthernetUDP udp; +udp.setBroadcastBlock(true); + +// to restore the value to standard +udp.setBroadcastBlock(false); +udp.setBroadcastBlock(); +``` + +### remoteIP and remoteMAC adresses + +Two new functions for getting the IP and MAC address of a remote host. + +```cpp +void remoteIP(uint8_t *ip); +void remoteMAC(uint8_t *mac); +``` diff --git a/libraries/Ethernet3/__library.json__ b/libraries/Ethernet3/__library.json__ new file mode 100644 index 0000000..4485f90 --- /dev/null +++ b/libraries/Ethernet3/__library.json__ @@ -0,0 +1,14 @@ +{ + "name": "Ethernet3", + "keywords": "Ethernet, LAN, Wiznet, W5500, WIZ550io, WIZ850io, USR-ES1, EthernetShield2", + "description": "Ethernet library for Arduino and Ethernetshield2 / WIZ550io / WIZ850io / USR-ES1 with Wiznet W5500 chip.", + "repository": + { + "type": "git", + "url": "https://github.com/sstaub/Ethernet3" + }, + "version": "1.5.5", + "frameworks": "arduino", + "platforms": "*" +} + diff --git a/libraries/Ethernet3/examples/AdvancedChatServer/AdvancedChatServer.ino b/libraries/Ethernet3/examples/AdvancedChatServer/AdvancedChatServer.ino new file mode 100644 index 0000000..0640c4a --- /dev/null +++ b/libraries/Ethernet3/examples/AdvancedChatServer/AdvancedChatServer.ino @@ -0,0 +1,110 @@ +/* + Advanced Chat Server + + A more advanced server that distributes any incoming messages + to all connected clients but the client the message comes from. + To use telnet to your device's IP address and type. + You can see the client's input in the serial monitor as well. + Using an Arduino Wiznet Ethernet shield. + + Circuit: + * Ethernet shield attached to pins 10, 11, 12, 13 + * Analog inputs attached to pins A0 through A5 (optional) + + created 18 Dec 2009 + by David A. Mellis + modified 9 Apr 2012 + by Tom Igoe + redesigned to make use of operator== 25 Nov 2013 + by Norbert Truchsess + + */ + +#include +#include + +// Enter a MAC address and IP address for your controller below. +// The IP address will be dependent on your local network. +// gateway and subnet are optional: +byte mac[] = { + 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; +IPAddress ip(192,168,1, 177); +IPAddress gateway(192,168,1, 1); +IPAddress subnet(255, 255, 0, 0); + + +// telnet defaults to port 23 +EthernetServer server(23); + +EthernetClient clients[4]; + +void setup() { + Ethernet.setRstPin(9); + Ethernet.setCsPin(10); + // initialize the ethernet device + Ethernet.begin(mac, ip, subnet, gateway); + // start listening for clients + server.begin(); + // Open serial communications and wait for port to open: + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + + + Serial.print("Chat server address:"); + Serial.println(Ethernet.localIP()); +} + +void loop() { + // wait for a new client: + EthernetClient client = server.available(); + + // when the client sends the first byte, say hello: + if (client) { + + boolean newClient = true; + for (byte i=0;i<4;i++) { + //check whether this client refers to the same socket as one of the existing instances: + if (clients[i]==client) { + newClient = false; + break; + } + } + + if (newClient) { + //check which of the existing clients can be overridden: + for (byte i=0;i<4;i++) { + if (!clients[i] && clients[i]!=client) { + clients[i] = client; + // clead out the input buffer: + client.flush(); + Serial.println("We have a new client"); + client.print("Hello, client number: "); + client.print(i); + client.println(); + break; + } + } + } + + if (client.available() > 0) { + // read the bytes incoming from the client: + char thisChar = client.read(); + // echo the bytes back to all other connected clients: + for (byte i=0;i<4;i++) { + if (clients[i] && (clients[i]!=client)) { + clients[i].write(thisChar); + } + } + // echo the bytes to the server as well: + Serial.write(thisChar); + } + } + for (byte i=0;i<4;i++) { + if (!(clients[i].connected())) { + // client.stop() invalidates the internal socket-descriptor, so next use of == will allways return false; + clients[i].stop(); + } + } +} diff --git a/libraries/Ethernet3/examples/ChatServer/ChatServer.ino b/libraries/Ethernet3/examples/ChatServer/ChatServer.ino new file mode 100644 index 0000000..9e41be7 --- /dev/null +++ b/libraries/Ethernet3/examples/ChatServer/ChatServer.ino @@ -0,0 +1,79 @@ +/* + Chat Server + + A simple server that distributes any incoming messages to all + connected clients. To use telnet to your device's IP address and type. + You can see the client's input in the serial monitor as well. + Using an Arduino Wiznet Ethernet shield. + + Circuit: + * Ethernet shield attached to pins 10, 11, 12, 13 + * Analog inputs attached to pins A0 through A5 (optional) + + created 18 Dec 2009 + by David A. Mellis + modified 9 Apr 2012 + by Tom Igoe + + */ + +#include +#include + +// Enter a MAC address and IP address for your controller below. +// The IP address will be dependent on your local network. +// gateway and subnet are optional: +byte mac[] = { + 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED +}; +IPAddress ip(192, 168, 1, 177); +IPAddress gateway(192, 168, 1, 1); +IPAddress subnet(255, 255, 0, 0); + + +// telnet defaults to port 23 +EthernetServer server(23); +boolean alreadyConnected = false; // whether or not the client was connected previously + +void setup() { + // initialize the ethernet device + Ethernet.setRstPin(9); + Ethernet.setCsPin(10); + Ethernet.begin(mac, ip, subnet, gateway); + // start listening for clients + server.begin(); + // Open serial communications and wait for port to open: + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + + + Serial.print("Chat server address:"); + Serial.println(Ethernet.localIP()); +} + +void loop() { + // wait for a new client: + EthernetClient client = server.available(); + + // when the client sends the first byte, say hello: + if (client) { + if (!alreadyConnected) { + // clead out the input buffer: + client.flush(); + Serial.println("We have a new client"); + client.println("Hello, client!"); + alreadyConnected = true; + } + + if (client.available() > 0) { + // read the bytes incoming from the client: + char thisChar = client.read(); + // echo the bytes back to the client: + server.write(thisChar); + // echo the bytes to the server as well: + Serial.write(thisChar); + } + } +} diff --git a/libraries/Ethernet3/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino b/libraries/Ethernet3/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino new file mode 100644 index 0000000..ee2fcb7 --- /dev/null +++ b/libraries/Ethernet3/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino @@ -0,0 +1,62 @@ +/* + DHCP-based IP printer + + This sketch uses the DHCP extensions to the Ethernet library + to get an IP address via DHCP and print the address obtained. + using an Arduino Wiznet Ethernet shield. + + Circuit: + * Ethernet shield attached to pins 10, 11, 12, 13 + + created 12 April 2011 + modified 9 Apr 2012 + by Tom Igoe + + */ + +#include +#include + +// Enter a MAC address for your controller below. +// Newer Ethernet shields have a MAC address printed on a sticker on the shield +byte mac[] = { + 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 +}; + +// Initialize the Ethernet client library +// with the IP address and port of the server +// that you want to connect to (port 80 is default for HTTP): +EthernetClient client; + +void setup() { + Ethernet.setRstPin(9); + Ethernet.setCsPin(10); + // Open serial communications and wait for port to open: + Serial.begin(9600); + // this check is only needed on the Leonardo: + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + + // start the Ethernet connection: + if (Ethernet.begin(mac) == 0) { + Serial.println("Failed to configure Ethernet using DHCP"); + // no point in carrying on, so do nothing forevermore: + for (;;) + ; + } + // print your local IP address: + Serial.print("My IP address: "); + for (byte thisByte = 0; thisByte < 4; thisByte++) { + // print the value of each byte of the IP address: + Serial.print(Ethernet.localIP()[thisByte], DEC); + Serial.print("."); + } + Serial.println(); +} + +void loop() { + +} + + diff --git a/libraries/Ethernet3/examples/DhcpChatServer/DhcpChatServer.ino b/libraries/Ethernet3/examples/DhcpChatServer/DhcpChatServer.ino new file mode 100644 index 0000000..ec69ad1 --- /dev/null +++ b/libraries/Ethernet3/examples/DhcpChatServer/DhcpChatServer.ino @@ -0,0 +1,89 @@ +/* + DHCP Chat Server + + A simple server that distributes any incoming messages to all + connected clients. To use telnet to your device's IP address and type. + You can see the client's input in the serial monitor as well. + Using an Arduino Wiznet Ethernet shield. + + THis version attempts to get an IP address using DHCP + + Circuit: + * Ethernet shield attached to pins 10, 11, 12, 13 + + created 21 May 2011 + modified 9 Apr 2012 + by Tom Igoe + Based on ChatServer example by David A. Mellis + + */ + +#include +#include + +// Enter a MAC address and IP address for your controller below. +// The IP address will be dependent on your local network. +// gateway and subnet are optional: +byte mac[] = { + 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 +}; +IPAddress ip(192, 168, 1, 177); +IPAddress gateway(192, 168, 1, 1); +IPAddress subnet(255, 255, 0, 0); + +// telnet defaults to port 23 +EthernetServer server(23); +boolean gotAMessage = false; // whether or not you got a message from the client yet + +void setup() { + Ethernet.setRstPin(9); + Ethernet.setCsPin(10); + // Open serial communications and wait for port to open: + Serial.begin(9600); + // this check is only needed on the Leonardo: + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + + + // start the Ethernet connection: + Serial.println("Trying to get an IP address using DHCP"); + if (Ethernet.begin(mac) == 0) { + Serial.println("Failed to configure Ethernet using DHCP"); + // initialize the ethernet device not using DHCP: + Ethernet.begin(mac, ip, subnet, gateway); + } + // print your local IP address: + Serial.print("My IP address: "); + ip = Ethernet.localIP(); + for (byte thisByte = 0; thisByte < 4; thisByte++) { + // print the value of each byte of the IP address: + Serial.print(ip[thisByte], DEC); + Serial.print("."); + } + Serial.println(); + // start listening for clients + server.begin(); + +} + +void loop() { + // wait for a new client: + EthernetClient client = server.available(); + + // when the client sends the first byte, say hello: + if (client) { + if (!gotAMessage) { + Serial.println("We have a new client"); + client.println("Hello, client!"); + gotAMessage = true; + } + + // read the bytes incoming from the client: + char thisChar = client.read(); + // echo the bytes back to the client: + server.write(thisChar); + // echo the bytes to the server as well: + Serial.print(thisChar); + } +} diff --git a/libraries/Ethernet3/examples/TelnetClient/TelnetClient.ino b/libraries/Ethernet3/examples/TelnetClient/TelnetClient.ino new file mode 100644 index 0000000..eae1145 --- /dev/null +++ b/libraries/Ethernet3/examples/TelnetClient/TelnetClient.ino @@ -0,0 +1,95 @@ +/* + Telnet client + + This sketch connects to a a telnet server (http://www.google.com) + using an Arduino Wiznet Ethernet shield. You'll need a telnet server + to test this with. + Processing's ChatServer example (part of the network library) works well, + running on port 10002. It can be found as part of the examples + in the Processing application, available at + http://processing.org/ + + Circuit: + * Ethernet shield attached to pins 10, 11, 12, 13 + + created 14 Sep 2010 + modified 9 Apr 2012 + by Tom Igoe + + */ + +#include +#include + +// Enter a MAC address and IP address for your controller below. +// The IP address will be dependent on your local network: +byte mac[] = { + 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED +}; +IPAddress ip(192, 168, 1, 177); + +// Enter the IP address of the server you're connecting to: +IPAddress server(192, 168, 1, 2); +// Initialize the Ethernet client library +// with the IP address and port of the server +// that you want to connect to (port 23 is default for telnet; +// if you're using Processing's ChatServer, use port 10002): +EthernetClient client; + +void setup() { + Ethernet.setRstPin(9); + Ethernet.setCsPin(10); + // start the Ethernet connection: + Ethernet.begin(mac, ip); + // Open serial communications and wait for port to open: + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + + + // give the Ethernet shield a second to initialize: + delay(1000); + Serial.println("connecting..."); + + // if you get a connection, report back via serial: + if (client.connect(server, 10002)) { + Serial.println("connected"); + } + else { + // if you didn't get a connection to the server: + Serial.println("connection failed"); + } +} + +void loop() +{ + // if there are incoming bytes available + // from the server, read them and print them: + if (client.available()) { + char c = client.read(); + Serial.print(c); + } + + // as long as there are bytes in the serial queue, + // read them and send them out the socket if it's open: + while (Serial.available() > 0) { + char inChar = Serial.read(); + if (client.connected()) { + client.print(inChar); + } + } + + // if the server's disconnected, stop the client: + if (!client.connected()) { + Serial.println(); + Serial.println("disconnecting."); + client.stop(); + // do nothing: + while (true); + } +} + + + + diff --git a/libraries/Ethernet3/examples/WebClient/WebClient.ino b/libraries/Ethernet3/examples/WebClient/WebClient.ino new file mode 100644 index 0000000..077f84a --- /dev/null +++ b/libraries/Ethernet3/examples/WebClient/WebClient.ino @@ -0,0 +1,89 @@ +/* + Web client + + This sketch connects to a website (http://www.google.com) + using an Arduino Wiznet Ethernet shield. + + Circuit: + * Ethernet shield attached to pins 10, 11, 12, 13 + + created 18 Dec 2009 + by David A. Mellis + modified 9 Apr 2012 + by Tom Igoe, based on work by Adrian McEwen + + */ + +#include +#include + +// Enter a MAC address for your controller below. +// Newer Ethernet shields have a MAC address printed on a sticker on the shield +byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; +// if you don't want to use DNS (and reduce your sketch size) +// use the numeric IP instead of the name for the server: +//IPAddress server(74,125,232,128); // numeric IP for Google (no DNS) +char server[] = "www.google.com"; // name address for Google (using DNS) + +// Set the static IP address to use if the DHCP fails to assign +IPAddress ip(192, 168, 0, 177); + +// Initialize the Ethernet client library +// with the IP address and port of the server +// that you want to connect to (port 80 is default for HTTP): +EthernetClient client; + +void setup() { + // Open serial communications and wait for port to open: + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + Ethernet.setRstPin(9); + Ethernet.setCsPin(10); + // start the Ethernet connection: + if (Ethernet.begin(mac) == 0) { + Serial.println("Failed to configure Ethernet using DHCP"); + // no point in carrying on, so do nothing forevermore: + // try to congifure using IP address instead of DHCP: + Ethernet.begin(mac, ip); + } + // give the Ethernet shield a second to initialize: + delay(1000); + Serial.println("connecting..."); + + // if you get a connection, report back via serial: + if (client.connect(server, 80)) { + Serial.println("connected"); + // Make a HTTP request: + client.println("GET /search?q=arduino HTTP/1.1"); + client.println("Host: www.google.com"); + client.println("Connection: close"); + client.println(); + } + else { + // kf you didn't get a connection to the server: + Serial.println("connection failed"); + } +} + +void loop() +{ + // if there are incoming bytes available + // from the server, read them and print them: + if (client.available()) { + char c = client.read(); + Serial.print(c); + } + + // if the server's disconnected, stop the client: + if (!client.connected()) { + Serial.println(); + Serial.println("disconnecting."); + client.stop(); + + // do nothing forevermore: + while (true); + } +} + diff --git a/libraries/Ethernet3/examples/WebServer/WebServer.ino b/libraries/Ethernet3/examples/WebServer/WebServer.ino new file mode 100644 index 0000000..73b3fc2 --- /dev/null +++ b/libraries/Ethernet3/examples/WebServer/WebServer.ino @@ -0,0 +1,103 @@ +/* + Web Server + + A simple web server that shows the value of the analog input pins. + using an Arduino Wiznet Ethernet shield. + + Circuit: + * Ethernet shield attached to pins 10, 11, 12, 13 + * Analog inputs attached to pins A0 through A5 (optional) + + created 18 Dec 2009 + by David A. Mellis + modified 9 Apr 2012 + by Tom Igoe + + */ + +#include +#include + +// Enter a MAC address and IP address for your controller below. +// The IP address will be dependent on your local network: +byte mac[] = { + 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED +}; +IPAddress ip(192, 168, 1, 177); + +// Initialize the Ethernet server library +// with the IP address and port you want to use +// (port 80 is default for HTTP): +EthernetServer server(80); + +void setup() { + Ethernet.setRstPin(9); + Ethernet.setCsPin(10); + // Open serial communications and wait for port to open: + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + + + // start the Ethernet connection and the server: + Ethernet.begin(mac, ip); + server.begin(); + Serial.print("server is at "); + Serial.println(Ethernet.localIP()); +} + + +void loop() { + // listen for incoming clients + EthernetClient client = server.available(); + if (client) { + Serial.println("new client"); + // an http request ends with a blank line + boolean currentLineIsBlank = true; + while (client.connected()) { + if (client.available()) { + char c = client.read(); + Serial.write(c); + // if you've gotten to the end of the line (received a newline + // character) and the line is blank, the http request has ended, + // so you can send a reply + if (c == '\n' && currentLineIsBlank) { + // send a standard http response header + client.println("HTTP/1.1 200 OK"); + client.println("Content-Type: text/html"); + client.println("Connection: close"); // the connection will be closed after completion of the response + client.println("Refresh: 5"); // refresh the page automatically every 5 sec + client.println(); + client.println(""); + client.println(""); + // output the value of each analog input pin + for (int analogChannel = 0; analogChannel < 2; analogChannel++) { + int sensorReading = analogRead(A0 + analogChannel); + client.print("analog input A"); + client.print(analogChannel); + client.print(" is "); + client.print(sensorReading); + client.println("
"); + } + client.println(""); + break; + } + if (c == '\n') { + // you're starting a new line + currentLineIsBlank = true; + } + else if (c != '\r') { + // you've gotten a character on the current line + currentLineIsBlank = false; + } + } + } + // give the web browser time to receive the data + delay(1); + // close the connection: + client.stop(); + Serial.println("client disconnected"); + } +} + diff --git a/libraries/Ethernet3/keywords.txt b/libraries/Ethernet3/keywords.txt new file mode 100644 index 0000000..9ef9eb4 --- /dev/null +++ b/libraries/Ethernet3/keywords.txt @@ -0,0 +1,73 @@ +####################################### +# Syntax Coloring Map For Ethernet +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +Ethernet3 KEYWORD1 +EthernetClient KEYWORD1 +EthernetServer KEYWORD1 +IPAddress KEYWORD1 +EthernetUdp3 KEYWORD1 +DNS KEYWORD1 +DCHP KEYWORD1 +Twitter KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +status KEYWORD2 +connect KEYWORD2 +write KEYWORD2 +available KEYWORD2 +read KEYWORD2 +peek KEYWORD2 +flush KEYWORD2 +stop KEYWORD2 +connected KEYWORD2 +begin KEYWORD2 +beginMulticast KEYWORD2 +beginPacket KEYWORD2 +endPacket KEYWORD2 +parsePacket KEYWORD2 +remoteIP KEYWORD2 +remotePort KEYWORD2 +getSocketNumber KEYWORD2 +localIP KEYWORD2 +maintain KEYWORD2 +WoL KEYWORD2 +phyMode KEYWORD2 +phyState KEYWORD2 +speed KEYWORD2 +speedReport KEYWORD2 +link KEYWORD2 +linkReport KEYWORD2 +duplex KEYWORD2 +duplexReport KEYWORD2 +macAddress KEYWORD2 +macAddressReport KEYWORD2 +init KEYWORD2 +setHostname KEYWORD2 +softreset KEYWORD2 +hardreset KEYWORD2 +setCsPin KEYWORD2 +setRstPin KEYWORD2 +setUnicastBlock KEYWORD2 +getUnicastBlock KEYWORD2 +setBroadcastBlock KEYWORD2 +getBroadcastBlock KEYWORD2 +setRtTimeOut KEYWORD2 +getRtTimeOut KEYWORD2 +setRtCount KEYWORD2 +getRtCount KEYWORD2 +setNoDelayedACK KEYWORD2 +getNoDelayedACK KEYWORD2 +remoteIP KEYWORD2 +remoteMAC KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### diff --git a/libraries/Ethernet3/library.properties b/libraries/Ethernet3/library.properties new file mode 100644 index 0000000..85b6321 --- /dev/null +++ b/libraries/Ethernet3/library.properties @@ -0,0 +1,9 @@ +name=Ethernet3 +version=1.5.5 +author=Arduino/sstaub +maintainer=Renesas Electronics Corporation +sentence=Enables network connection (local and Internet) using the Arduino Ethernet board or shield. For all Arduino boards. +paragraph=With this library you can use the Arduino Ethernet (shield or board) to connect to Internet. The library provides both Client and server functionalities. The library permits you to connect to a local network also with DHCP and to resolve DNS. +category=Communication +url=http://www.arduino.cc/en/Reference/Ethernet +architectures=rl78g22_fpb diff --git a/libraries/Ethernet3/src/Dhcp.cpp b/libraries/Ethernet3/src/Dhcp.cpp new file mode 100644 index 0000000..618c94d --- /dev/null +++ b/libraries/Ethernet3/src/Dhcp.cpp @@ -0,0 +1,489 @@ +// DHCP Library v0.3 - April 25, 2009 +// Author: Jordan Terrell - blog.jordanterrell.com + +#include "utility/w5500.h" + +#include +#include +#include "Dhcp.h" +#include "Arduino.h" +#include "utility/util.h" + +int DhcpClass::beginWithDHCP(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout) +{ + _dhcpLeaseTime=0; + _dhcpT1=0; + _dhcpT2=0; + _lastCheck=0; + _timeout = timeout; + _responseTimeout = responseTimeout; + + // zero out _dhcpMacAddr + memset(_dhcpMacAddr, 0, 6); + reset_DHCP_lease(); + memcpy((void*)_dhcpMacAddr, (void*)mac, 6); + _dhcp_state = STATE_DHCP_START; + return request_DHCP_lease(); +} + +void DhcpClass::reset_DHCP_lease(){ + // zero out _dhcpSubnetMask, _dhcpGatewayIp, _dhcpLocalIp, _dhcpDhcpServerIp, _dhcpDnsServerIp + memset(_dhcpLocalIp, 0, 20); +} + +//return:0 on error, 1 if request is sent and response is received +int DhcpClass::request_DHCP_lease(){ + + uint8_t messageType = 0; + + + + // Pick an initial transaction ID + _dhcpTransactionId = random(1UL, 2000UL); + _dhcpInitialTransactionId = _dhcpTransactionId; + + _dhcpUdpSocket.stop(); + if (_dhcpUdpSocket.begin(DHCP_CLIENT_PORT) == 0) + { + // Couldn't get a socket + return 0; + } + + presend_DHCP(); + + int result = 0; + + unsigned long startTime = millis(); + + while(_dhcp_state != STATE_DHCP_LEASED) + { + if(_dhcp_state == STATE_DHCP_START) + { + //Serial.println("DHCP_START"); + _dhcpTransactionId++; + + send_DHCP_MESSAGE(DHCP_DISCOVER, ((uint16_t)((millis() - startTime) / 1000))); + _dhcp_state = STATE_DHCP_DISCOVER; + } + else if(_dhcp_state == STATE_DHCP_REREQUEST){ + _dhcpTransactionId++; + send_DHCP_MESSAGE(DHCP_REQUEST, ((uint16_t)((millis() - startTime)/1000))); + _dhcp_state = STATE_DHCP_REQUEST; + } + else if(_dhcp_state == STATE_DHCP_DISCOVER) + { + uint32_t respId; + + messageType = parseDHCPResponse(_responseTimeout, respId); + if(messageType == DHCP_OFFER) + { + + // We'll use the transaction ID that the offer came with, + // rather than the one we were up to + _dhcpTransactionId = respId; + send_DHCP_MESSAGE(DHCP_REQUEST, ((uint16_t)((millis() - startTime) / 1000))); + _dhcp_state = STATE_DHCP_REQUEST; + } + } + else if(_dhcp_state == STATE_DHCP_REQUEST) + { + uint32_t respId; + messageType = parseDHCPResponse(_responseTimeout, respId); + if(messageType == DHCP_ACK) + { + _dhcp_state = STATE_DHCP_LEASED; + result = 1; + //use default lease time if we didn't get it + if(_dhcpLeaseTime == 0){ + _dhcpLeaseTime = DEFAULT_LEASE; + } + //calculate T1 & T2 if we didn't get it + if(_dhcpT1 == 0){ + //T1 should be 50% of _dhcpLeaseTime + _dhcpT1 = _dhcpLeaseTime >> 1; + } + if(_dhcpT2 == 0){ + //T2 should be 87.5% (7/8ths) of _dhcpLeaseTime + _dhcpT2 = _dhcpT1 << 1; + } + _renewInSec = _dhcpT1; + _rebindInSec = _dhcpT2; + } + else if(messageType == DHCP_NAK) + _dhcp_state = STATE_DHCP_START; + } + + if(messageType == 255) + { + messageType = 0; + _dhcp_state = STATE_DHCP_START; + } + + if(result != 1 && ((millis() - startTime) > _timeout)) + break; + } + + // We're done with the socket now + _dhcpUdpSocket.stop(); + _dhcpTransactionId++; + + return result; +} + +void DhcpClass::presend_DHCP() +{ +} + +void DhcpClass::send_DHCP_MESSAGE(uint8_t messageType, uint16_t secondsElapsed) +{ + uint8_t buffer[32]; + memset(buffer, 0, 32); + IPAddress dest_addr( 255, 255, 255, 255 ); // Broadcast address + + if (-1 == _dhcpUdpSocket.beginPacket(dest_addr, DHCP_SERVER_PORT)) + { + // FIXME Need to return errors + return; + } + + buffer[0] = DHCP_BOOTREQUEST; // op + buffer[1] = DHCP_HTYPE10MB; // htype + buffer[2] = DHCP_HLENETHERNET; // hlen + buffer[3] = DHCP_HOPS; // hops + + // xid + unsigned long xid = htonl(_dhcpTransactionId); + memcpy(buffer + 4, &(xid), 4); + + // 8, 9 - seconds elapsed + buffer[8] = ((secondsElapsed & 0xff00) >> 8); + buffer[9] = (secondsElapsed & 0x00ff); + + // flags + unsigned short flags = htons(DHCP_FLAGSBROADCAST); + memcpy(buffer + 10, &(flags), 2); + + // ciaddr: already zeroed + // yiaddr: already zeroed + // siaddr: already zeroed + // giaddr: already zeroed + + //put data in w5500 transmit buffer + _dhcpUdpSocket.write(buffer, 28); + + memset(buffer, 0, 32); // clear local buffer + + memcpy(buffer, _dhcpMacAddr, 6); // chaddr + + //put data in w5500 transmit buffer + _dhcpUdpSocket.write(buffer, 16); + + memset(buffer, 0, 32); // clear local buffer + + // leave zeroed out for sname && file + // put in w5500 transmit buffer x 6 (192 bytes) + + for(int i = 0; i < 6; i++) { + _dhcpUdpSocket.write(buffer, 32); + } + + // OPT - Magic Cookie + buffer[0] = (uint8_t)((MAGIC_COOKIE >> 24)& 0xFF); + buffer[1] = (uint8_t)((MAGIC_COOKIE >> 16)& 0xFF); + buffer[2] = (uint8_t)((MAGIC_COOKIE >> 8)& 0xFF); + buffer[3] = (uint8_t)(MAGIC_COOKIE& 0xFF); + + // OPT - message type + buffer[4] = dhcpMessageType; + buffer[5] = 0x01; + buffer[6] = messageType; //DHCP_REQUEST; + + // OPT - client identifier + buffer[7] = dhcpClientIdentifier; + buffer[8] = 0x07; + buffer[9] = 0x01; + memcpy(buffer + 10, _dhcpMacAddr, 6); + + // OPT - host name + buffer[16] = hostName; + + if(_customHostname == 0) + { + // use default hostname + buffer[17] = strlen(HOST_NAME) + 6; // length of hostname + last 3 bytes of mac address + strcpy((char*)&(buffer[18]), HOST_NAME); + printByte((char*)&(buffer[24]), _dhcpMacAddr[3]); + printByte((char*)&(buffer[26]), _dhcpMacAddr[4]); + printByte((char*)&(buffer[28]), _dhcpMacAddr[5]); + _dhcpUdpSocket.write(buffer, 30); + } + else + { + // use custom hostname + buffer[17] = strlen(_customHostname); // length of _customHostname + _dhcpUdpSocket.write(buffer, 18); + _dhcpUdpSocket.write(_customHostname, strlen(_customHostname)); + } + + if(messageType == DHCP_REQUEST) + { + buffer[0] = dhcpRequestedIPaddr; + buffer[1] = 0x04; + buffer[2] = _dhcpLocalIp[0]; + buffer[3] = _dhcpLocalIp[1]; + buffer[4] = _dhcpLocalIp[2]; + buffer[5] = _dhcpLocalIp[3]; + + buffer[6] = dhcpServerIdentifier; + buffer[7] = 0x04; + buffer[8] = _dhcpDhcpServerIp[0]; + buffer[9] = _dhcpDhcpServerIp[1]; + buffer[10] = _dhcpDhcpServerIp[2]; + buffer[11] = _dhcpDhcpServerIp[3]; + + //put data in w5500 transmit buffer + _dhcpUdpSocket.write(buffer, 12); + } + + buffer[0] = dhcpParamRequest; + buffer[1] = 0x06; + buffer[2] = subnetMask; + buffer[3] = routersOnSubnet; + buffer[4] = dns; + buffer[5] = domainName; + buffer[6] = dhcpT1value; + buffer[7] = dhcpT2value; + buffer[8] = endOption; + + //put data in w5500 transmit buffer + _dhcpUdpSocket.write(buffer, 9); + + _dhcpUdpSocket.endPacket(); +} + +uint8_t DhcpClass::parseDHCPResponse(unsigned long responseTimeout, uint32_t& transactionId) +{ + uint8_t type = 0; + uint8_t opt_len = 0; + unsigned long startTime = millis(); + + while(_dhcpUdpSocket.parsePacket() <= 0) + { + if((millis() - startTime) > responseTimeout) + { + return 255; + } + delay(50); + } + + // start reading in the packet + RIP_MSG_FIXED fixedMsg; + _dhcpUdpSocket.read((uint8_t*)&fixedMsg, sizeof(RIP_MSG_FIXED)); + + if(fixedMsg.op == DHCP_BOOTREPLY && _dhcpUdpSocket.remotePort() == DHCP_SERVER_PORT) + { + transactionId = ntohl(fixedMsg.xid); + if(memcmp(fixedMsg.chaddr, _dhcpMacAddr, 6) != 0 || (transactionId < _dhcpInitialTransactionId) || (transactionId > _dhcpTransactionId)) + { + // Need to read the rest of the packet here regardless + _dhcpUdpSocket.flush(); + return 0; + } + + memcpy(_dhcpLocalIp, fixedMsg.yiaddr, 4); + + // Skip to the option part + // Doing this a byte at a time so we don't have to put a big buffer + // on the stack (as we don't have lots of memory lying around) + for (int i =0; i < (240 - (int)sizeof(RIP_MSG_FIXED)); i++) + { + _dhcpUdpSocket.read(); // we don't care about the returned byte + } + + while (_dhcpUdpSocket.available() > 0) + { + switch (_dhcpUdpSocket.read()) + { + case endOption : + break; + case padOption : + break; + case dhcpMessageType : + opt_len = _dhcpUdpSocket.read(); + type = _dhcpUdpSocket.read(); + break; + case subnetMask : + opt_len = _dhcpUdpSocket.read(); + _dhcpUdpSocket.read(_dhcpSubnetMask, 4); + break; + case routersOnSubnet : + opt_len = _dhcpUdpSocket.read(); + _dhcpUdpSocket.read(_dhcpGatewayIp, 4); + for (int i = 0; i < opt_len-4; i++) + { + _dhcpUdpSocket.read(); + } + break; + case dns : + opt_len = _dhcpUdpSocket.read(); + _dhcpUdpSocket.read(_dhcpDnsServerIp, 4); + for (int i = 0; i < opt_len-4; i++) + { + _dhcpUdpSocket.read(); + } + break; + case dhcpServerIdentifier : + opt_len = _dhcpUdpSocket.read(); + if(((_dhcpDhcpServerIp[0] == 0) && (_dhcpDhcpServerIp[1] == 0) && (_dhcpDhcpServerIp[2] == 0) && (_dhcpDhcpServerIp[3] == 0)) || (IPAddress(_dhcpDhcpServerIp) == _dhcpUdpSocket.remoteIP())) + { + _dhcpUdpSocket.read(_dhcpDhcpServerIp, sizeof(_dhcpDhcpServerIp)); + } + else + { + // Skip over the rest of this option + while (opt_len--) + { + _dhcpUdpSocket.read(); + } + } + break; + case dhcpT1value : + opt_len = _dhcpUdpSocket.read(); + _dhcpUdpSocket.read((uint8_t*)&_dhcpT1, sizeof(_dhcpT1)); + _dhcpT1 = ntohl(_dhcpT1); + break; + case dhcpT2value : + opt_len = _dhcpUdpSocket.read(); + _dhcpUdpSocket.read((uint8_t*)&_dhcpT2, sizeof(_dhcpT2)); + _dhcpT2 = ntohl(_dhcpT2); + break; + case dhcpIPaddrLeaseTime : + opt_len = _dhcpUdpSocket.read(); + _dhcpUdpSocket.read((uint8_t*)&_dhcpLeaseTime, sizeof(_dhcpLeaseTime)); + _dhcpLeaseTime = ntohl(_dhcpLeaseTime); + _renewInSec = _dhcpLeaseTime; + break; + default : + opt_len = _dhcpUdpSocket.read(); + // Skip over the rest of this option + while (opt_len--) + { + _dhcpUdpSocket.read(); + } + break; + } + } + } + + // Need to skip to end of the packet regardless here + _dhcpUdpSocket.flush(); + + return type; +} + +void DhcpClass::setCustomHostname(char* hostname) +{ + _customHostname = hostname; +} + +/* + returns: + 0/DHCP_CHECK_NONE: nothing happened + 1/DHCP_CHECK_RENEW_FAIL: renew failed + 2/DHCP_CHECK_RENEW_OK: renew success + 3/DHCP_CHECK_REBIND_FAIL: rebind fail + 4/DHCP_CHECK_REBIND_OK: rebind success +*/ +int DhcpClass::checkLease(){ + //this uses a signed / unsigned trick to deal with millis overflow + unsigned long now = millis(); + signed long snow = (long)now; + int rc=DHCP_CHECK_NONE; + if (_lastCheck != 0){ + signed long factor; + //calc how many ms past the timeout we are + factor = snow - (long)_secTimeout; + //if on or passed the timeout, reduce the counters + if ( factor >= 0 ){ + //next timeout should be now plus 1000 ms minus parts of second in factor + _secTimeout = snow + 1000 - factor % 1000; + //how many seconds late are we, minimum 1 + factor = factor / 1000 +1; + + //reduce the counters by that mouch + //if we can assume that the cycle time (factor) is fairly constant + //and if the remainder is less than cycle time * 2 + //do it early instead of late + if(_renewInSec < factor*2 ) + _renewInSec = 0; + else + _renewInSec -= factor; + + if(_rebindInSec < factor*2 ) + _rebindInSec = 0; + else + _rebindInSec -= factor; + } + + //if we have a lease but should renew, do it + if (_dhcp_state == STATE_DHCP_LEASED && _renewInSec <=0){ + _dhcp_state = STATE_DHCP_REREQUEST; + rc = 1 + request_DHCP_lease(); + } + + //if we have a lease or is renewing but should bind, do it + if( (_dhcp_state == STATE_DHCP_LEASED || _dhcp_state == STATE_DHCP_START) && _rebindInSec <=0){ + //this should basically restart completely + _dhcp_state = STATE_DHCP_START; + reset_DHCP_lease(); + rc = 3 + request_DHCP_lease(); + } + } + else{ + _secTimeout = snow + 1000; + } + + _lastCheck = now; + return rc; +} + +IPAddress DhcpClass::getLocalIp() +{ + return IPAddress(_dhcpLocalIp); +} + +IPAddress DhcpClass::getSubnetMask() +{ + return IPAddress(_dhcpSubnetMask); +} + +IPAddress DhcpClass::getGatewayIp() +{ + return IPAddress(_dhcpGatewayIp); +} + +IPAddress DhcpClass::getDhcpServerIp() +{ + return IPAddress(_dhcpDhcpServerIp); +} + +IPAddress DhcpClass::getDnsServerIp() +{ + return IPAddress(_dhcpDnsServerIp); +} + +void DhcpClass::printByte(char * buf, uint8_t n ) { + char *str = &buf[1]; + buf[0]='0'; + do { + unsigned long m = n; + n /= 16; + char c = m - 16 * n; + *str-- = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); +} + +// Because of the uncertainty of malloc on LLVM compller, DhcpClass instance has declared in advance +DhcpClass temp_Dhcp; + + diff --git a/libraries/Ethernet3/src/Dhcp.h b/libraries/Ethernet3/src/Dhcp.h new file mode 100644 index 0000000..866d623 --- /dev/null +++ b/libraries/Ethernet3/src/Dhcp.h @@ -0,0 +1,180 @@ +// DHCP Library v0.3 - April 25, 2009 +// Author: Jordan Terrell - blog.jordanterrell.com + +#ifndef Dhcp_h +#define Dhcp_h + +#include "EthernetUdp3.h" + +/* DHCP state machine. */ +#define STATE_DHCP_START 0 +#define STATE_DHCP_DISCOVER 1 +#define STATE_DHCP_REQUEST 2 +#define STATE_DHCP_LEASED 3 +#define STATE_DHCP_REREQUEST 4 +#define STATE_DHCP_RELEASE 5 + +#define DHCP_FLAGSBROADCAST 0x8000 + +/* UDP port numbers for DHCP */ +#define DHCP_SERVER_PORT 67 /* from server to client */ +#define DHCP_CLIENT_PORT 68 /* from client to server */ + +/* DHCP message OP code */ +#define DHCP_BOOTREQUEST 1 +#define DHCP_BOOTREPLY 2 + +/* DHCP message type */ +#define DHCP_DISCOVER 1 +#define DHCP_OFFER 2 +#define DHCP_REQUEST 3 +#define DHCP_DECLINE 4 +#define DHCP_ACK 5 +#define DHCP_NAK 6 +#define DHCP_RELEASE 7 +#define DHCP_INFORM 8 + +#define DHCP_HTYPE10MB 1 +#define DHCP_HTYPE100MB 2 + +#define DHCP_HLENETHERNET 6 +#define DHCP_HOPS 0 +#define DHCP_SECS 0 + +#define MAGIC_COOKIE 0x63825363 +#define MAX_DHCP_OPT 16 + +#define HOST_NAME "WIZnet" +#define DEFAULT_LEASE (900) //default lease time in seconds + +#define DHCP_CHECK_NONE (0) +#define DHCP_CHECK_RENEW_FAIL (1) +#define DHCP_CHECK_RENEW_OK (2) +#define DHCP_CHECK_REBIND_FAIL (3) +#define DHCP_CHECK_REBIND_OK (4) + +enum +{ + padOption = 0, + subnetMask = 1, + timerOffset = 2, + routersOnSubnet = 3, + /* timeServer = 4, + nameServer = 5,*/ + dns = 6, + /*logServer = 7, + cookieServer = 8, + lprServer = 9, + impressServer = 10, + resourceLocationServer = 11,*/ + hostName = 12, + /*bootFileSize = 13, + meritDumpFile = 14,*/ + domainName = 15, + /*swapServer = 16, + rootPath = 17, + extentionsPath = 18, + IPforwarding = 19, + nonLocalSourceRouting = 20, + policyFilter = 21, + maxDgramReasmSize = 22, + defaultIPTTL = 23, + pathMTUagingTimeout = 24, + pathMTUplateauTable = 25, + ifMTU = 26, + allSubnetsLocal = 27, + broadcastAddr = 28, + performMaskDiscovery = 29, + maskSupplier = 30, + performRouterDiscovery = 31, + routerSolicitationAddr = 32, + staticRoute = 33, + trailerEncapsulation = 34, + arpCacheTimeout = 35, + ethernetEncapsulation = 36, + tcpDefaultTTL = 37, + tcpKeepaliveInterval = 38, + tcpKeepaliveGarbage = 39, + nisDomainName = 40, + nisServers = 41, + ntpServers = 42, + vendorSpecificInfo = 43, + netBIOSnameServer = 44, + netBIOSdgramDistServer = 45, + netBIOSnodeType = 46, + netBIOSscope = 47, + xFontServer = 48, + xDisplayManager = 49,*/ + dhcpRequestedIPaddr = 50, + dhcpIPaddrLeaseTime = 51, + /*dhcpOptionOverload = 52,*/ + dhcpMessageType = 53, + dhcpServerIdentifier = 54, + dhcpParamRequest = 55, + /*dhcpMsg = 56, + dhcpMaxMsgSize = 57,*/ + dhcpT1value = 58, + dhcpT2value = 59, + /*dhcpClassIdentifier = 60,*/ + dhcpClientIdentifier = 61, + endOption = 255 +}; + +typedef struct _RIP_MSG_FIXED +{ + uint8_t op; + uint8_t htype; + uint8_t hlen; + uint8_t hops; + uint32_t xid; + uint16_t secs; + uint16_t flags; + uint8_t ciaddr[4]; + uint8_t yiaddr[4]; + uint8_t siaddr[4]; + uint8_t giaddr[4]; + uint8_t chaddr[6]; +}RIP_MSG_FIXED; + +class DhcpClass { + +private: + uint32_t _dhcpInitialTransactionId; + uint32_t _dhcpTransactionId; + char* _customHostname; + uint8_t _dhcpMacAddr[6]; + uint8_t _dhcpLocalIp[4]; + uint8_t _dhcpSubnetMask[4]; + uint8_t _dhcpGatewayIp[4]; + uint8_t _dhcpDhcpServerIp[4]; + uint8_t _dhcpDnsServerIp[4]; + uint32_t _dhcpLeaseTime; + uint32_t _dhcpT1, _dhcpT2; + signed long _renewInSec; + signed long _rebindInSec; + signed long _lastCheck; + unsigned long _timeout; + unsigned long _responseTimeout; + unsigned long _secTimeout; + uint8_t _dhcp_state; + EthernetUDP _dhcpUdpSocket; + int request_DHCP_lease(); + void reset_DHCP_lease(); + void presend_DHCP(); + void send_DHCP_MESSAGE(uint8_t, uint16_t); + void printByte(char *, uint8_t); + + uint8_t parseDHCPResponse(unsigned long responseTimeout, uint32_t& transactionId); +public: + IPAddress getLocalIp(); + IPAddress getSubnetMask(); + IPAddress getGatewayIp(); + IPAddress getDhcpServerIp(); + IPAddress getDnsServerIp(); + + int beginWithDHCP(uint8_t *, unsigned long timeout = 60000, unsigned long responseTimeout = 5000); + int checkLease(); + void setCustomHostname(char* hostname); +}; + +#endif diff --git a/libraries/Ethernet3/src/Dns.cpp b/libraries/Ethernet3/src/Dns.cpp new file mode 100644 index 0000000..7c6bd80 --- /dev/null +++ b/libraries/Ethernet3/src/Dns.cpp @@ -0,0 +1,421 @@ +// Arduino DNS client for WizNet5100-based Ethernet shield +// (c) Copyright 2009-2010 MCQN Ltd. +// Released under Apache License, version 2.0 + +#include "utility/w5500.h" +#include "EthernetUdp3.h" +#include "utility/util.h" + +#include "Dns.h" +#include +#include "Arduino.h" + +#define SOCKET_NONE 255 +// Various flags and header field values for a DNS message +#define UDP_HEADER_SIZE 8 +#define DNS_HEADER_SIZE 12 +#define TTL_SIZE 4 +#define QUERY_FLAG (0) +#define RESPONSE_FLAG (1<<15) +#define QUERY_RESPONSE_MASK (1<<15) +#define OPCODE_STANDARD_QUERY (0) +#define OPCODE_INVERSE_QUERY (1<<11) +#define OPCODE_STATUS_REQUEST (2<<11) +#define OPCODE_MASK (15<<11) +#define AUTHORITATIVE_FLAG (1<<10) +#define TRUNCATION_FLAG (1<<9) +#define RECURSION_DESIRED_FLAG (1<<8) +#define RECURSION_AVAILABLE_FLAG (1<<7) +#define RESP_NO_ERROR (0) +#define RESP_FORMAT_ERROR (1) +#define RESP_SERVER_FAILURE (2) +#define RESP_NAME_ERROR (3) +#define RESP_NOT_IMPLEMENTED (4) +#define RESP_REFUSED (5) +#define RESP_MASK (15) +#define TYPE_A (0x0001) +#define CLASS_IN (0x0001) +#define LABEL_COMPRESSION_MASK (0xC0) +// Port number that DNS servers listen on +#define DNS_PORT 53 + +// Possible return codes from ProcessResponse +#define SUCCESS 1 +#define TIMED_OUT -1 +#define INVALID_SERVER -2 +#define TRUNCATED -3 +#define INVALID_RESPONSE -4 + +void DNSClient::begin(const IPAddress& aDNSServer) +{ + iDNSServer = aDNSServer; + iRequestId = 0; +} + + +int DNSClient::inet_aton(const char* aIPAddrString, IPAddress& aResult) +{ + // See if we've been given a valid IP address + const char* p =aIPAddrString; + while (*p && + ( (*p == '.') || (*p >= '0') || (*p <= '9') )) + { + p++; + } + + if (*p == '\0') + { + // It's looking promising, we haven't found any invalid characters + p = aIPAddrString; + int segment =0; + int segmentValue =0; + while (*p && (segment < 4)) + { + if (*p == '.') + { + // We've reached the end of a segment + if (segmentValue > 255) + { + // You can't have IP address segments that don't fit in a byte + return 0; + } + else + { + aResult[segment] = (byte)segmentValue; + segment++; + segmentValue = 0; + } + } + else + { + // Next digit + segmentValue = (segmentValue*10)+(*p - '0'); + } + p++; + } + // We've reached the end of address, but there'll still be the last + // segment to deal with + if ((segmentValue > 255) || (segment > 3)) + { + // You can't have IP address segments that don't fit in a byte, + // or more than four segments + return 0; + } + else + { + aResult[segment] = (byte)segmentValue; + return 1; + } + } + else + { + return 0; + } +} + +int DNSClient::getHostByName(const char* aHostname, IPAddress& aResult) +{ + int ret =0; + + // See if it's a numeric IP address + if (inet_aton(aHostname, aResult)) + { + // It is, our work here is done + return 1; + } + + // Check we've got a valid DNS server to use + if (iDNSServer == INADDR_NONE) + { + return INVALID_SERVER; + } + + // Find a socket to use + if (iUdp.begin(1024+(millis() & 0xF)) == 1) + { + // Try up to three times + int retries = 0; +// while ((retries < 3) && (ret <= 0)) + { + // Send DNS request + ret = iUdp.beginPacket(iDNSServer, DNS_PORT); + if (ret != 0) + { + // Now output the request data + ret = BuildRequest(aHostname); + if (ret != 0) + { + // And finally send the request + ret = iUdp.endPacket(); + if (ret != 0) + { + // Now wait for a response + int wait_retries = 0; + ret = TIMED_OUT; + while ((wait_retries < 3) && (ret == TIMED_OUT)) + { + ret = ProcessResponse(5000, aResult); + wait_retries++; + } + } + } + } + retries++; + } + + // We're done with the socket now + iUdp.stop(); + } + + return ret; +} + +uint16_t DNSClient::BuildRequest(const char* aName) +{ + // Build header + // 1 1 1 1 1 1 + // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 + // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + // | ID | + // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + // |QR| Opcode |AA|TC|RD|RA| Z | RCODE | + // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + // | QDCOUNT | + // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + // | ANCOUNT | + // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + // | NSCOUNT | + // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + // | ARCOUNT | + // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + // As we only support one request at a time at present, we can simplify + // some of this header + iRequestId = millis(); // generate a random ID + uint16_t twoByteBuffer; + + // FIXME We should also check that there's enough space available to write to, rather + // FIXME than assume there's enough space (as the code does at present) + iUdp.write((uint8_t*)&iRequestId, sizeof(iRequestId)); + + twoByteBuffer = htons(QUERY_FLAG | OPCODE_STANDARD_QUERY | RECURSION_DESIRED_FLAG); + iUdp.write((uint8_t*)&twoByteBuffer, sizeof(twoByteBuffer)); + + twoByteBuffer = htons(1); // One question record + iUdp.write((uint8_t*)&twoByteBuffer, sizeof(twoByteBuffer)); + + twoByteBuffer = 0; // Zero answer records + iUdp.write((uint8_t*)&twoByteBuffer, sizeof(twoByteBuffer)); + + iUdp.write((uint8_t*)&twoByteBuffer, sizeof(twoByteBuffer)); + // and zero additional records + iUdp.write((uint8_t*)&twoByteBuffer, sizeof(twoByteBuffer)); + + // Build question + const char* start =aName; + const char* end =start; + uint8_t len; + // Run through the name being requested + while (*end) + { + // Find out how long this section of the name is + end = start; + while (*end && (*end != '.') ) + { + end++; + } + + if (end-start > 0) + { + // Write out the size of this section + len = end-start; + iUdp.write(&len, sizeof(len)); + // And then write out the section + iUdp.write((uint8_t*)start, end-start); + } + start = end+1; + } + + // We've got to the end of the question name, so + // terminate it with a zero-length section + len = 0; + iUdp.write(&len, sizeof(len)); + // Finally the type and class of question + twoByteBuffer = htons(TYPE_A); + iUdp.write((uint8_t*)&twoByteBuffer, sizeof(twoByteBuffer)); + + twoByteBuffer = htons(CLASS_IN); // Internet class of question + iUdp.write((uint8_t*)&twoByteBuffer, sizeof(twoByteBuffer)); + // Success! Everything buffered okay + return 1; +} + + +uint16_t DNSClient::ProcessResponse(uint16_t aTimeout, IPAddress& aAddress) +{ + uint32_t startTime = millis(); + + // Wait for a response packet + while(iUdp.parsePacket() <= 0) + { + if((millis() - startTime) > aTimeout) + return TIMED_OUT; + delay(50); + } + + // We've had a reply! + // Read the UDP header + uint8_t header[DNS_HEADER_SIZE]; // Enough space to reuse for the DNS header + // Check that it's a response from the right server and the right port + if ( (iDNSServer != iUdp.remoteIP()) || + (iUdp.remotePort() != DNS_PORT) ) + { + // It's not from who we expected + return INVALID_SERVER; + } + + // Read through the rest of the response + if (iUdp.available() < DNS_HEADER_SIZE) + { + return TRUNCATED; + } + iUdp.read(header, DNS_HEADER_SIZE); + + uint16_t header_flags = htons(*((uint16_t*)&header[2])); + // Check that it's a response to this request + if ( ( iRequestId != (*((uint16_t*)&header[0])) ) || + ((header_flags & QUERY_RESPONSE_MASK) != (uint16_t)RESPONSE_FLAG) ) + { + // Mark the entire packet as read + iUdp.flush(); + return INVALID_RESPONSE; + } + // Check for any errors in the response (or in our request) + // although we don't do anything to get round these + if ( (header_flags & TRUNCATION_FLAG) || (header_flags & RESP_MASK) ) + { + // Mark the entire packet as read + iUdp.flush(); + return -5; //INVALID_RESPONSE; + } + + // And make sure we've got (at least) one answer + uint16_t answerCount = htons(*((uint16_t*)&header[6])); + if (answerCount == 0 ) + { + // Mark the entire packet as read + iUdp.flush(); + return -6; //INVALID_RESPONSE; + } + + // Skip over any questions + for (uint16_t i =0; i < htons(*((uint16_t*)&header[4])); i++) + { + // Skip over the name + uint8_t len; + do + { + iUdp.read(&len, sizeof(len)); + if (len > 0) + { + // Don't need to actually read the data out for the string, just + // advance ptr to beyond it + while(len--) + { + iUdp.read(); // we don't care about the returned byte + } + } + } while (len != 0); + + // Now jump over the type and class + for (int ii =0; ii < 4; ii++) + { + iUdp.read(); // we don't care about the returned byte + } + } + + // Now we're up to the bit we're interested in, the answer + // There might be more than one answer (although we'll just use the first + // type A answer) and some authority and additional resource records but + // we're going to ignore all of them. + + for (uint16_t i =0; i < answerCount; i++) + { + // Skip the name + uint8_t len; + do + { + iUdp.read(&len, sizeof(len)); + if ((len & LABEL_COMPRESSION_MASK) == 0) + { + // It's just a normal label + if (len > 0) + { + // And it's got a length + // Don't need to actually read the data out for the string, + // just advance ptr to beyond it + while(len--) + { + iUdp.read(); // we don't care about the returned byte + } + } + } + else + { + // This is a pointer to a somewhere else in the message for the + // rest of the name. We don't care about the name, and RFC1035 + // says that a name is either a sequence of labels ended with a + // 0 length octet or a pointer or a sequence of labels ending in + // a pointer. Either way, when we get here we're at the end of + // the name + // Skip over the pointer + iUdp.read(); // we don't care about the returned byte + // And set len so that we drop out of the name loop + len = 0; + } + } while (len != 0); + + // Check the type and class + uint16_t answerType; + uint16_t answerClass; + iUdp.read((uint8_t*)&answerType, sizeof(answerType)); + iUdp.read((uint8_t*)&answerClass, sizeof(answerClass)); + + // Ignore the Time-To-Live as we don't do any caching + for (int ii =0; ii < TTL_SIZE; ii++) + { + iUdp.read(); // we don't care about the returned byte + } + + // And read out the length of this answer + // Don't need header_flags anymore, so we can reuse it here + iUdp.read((uint8_t*)&header_flags, sizeof(header_flags)); + + if ( (htons(answerType) == TYPE_A) && (htons(answerClass) == CLASS_IN) ) + { + if (htons(header_flags) != 4) + { + // It's a weird size + // Mark the entire packet as read + iUdp.flush(); + return -9;//INVALID_RESPONSE; + } + iUdp.read(aAddress.raw_address(), 4); + return SUCCESS; + } + else + { + // This isn't an answer type we're after, move onto the next one + for (uint16_t ii =0; ii < htons(header_flags); ii++) + { + iUdp.read(); // we don't care about the returned byte + } + } + } + + // Mark the entire packet as read + iUdp.flush(); + + // If we get here then we haven't found an answer + return -10;//INVALID_RESPONSE; +} + diff --git a/libraries/Ethernet3/src/Dns.h b/libraries/Ethernet3/src/Dns.h new file mode 100644 index 0000000..481c5c4 --- /dev/null +++ b/libraries/Ethernet3/src/Dns.h @@ -0,0 +1,41 @@ +// Arduino DNS client for WizNet5100-based Ethernet shield +// (c) Copyright 2009-2010 MCQN Ltd. +// Released under Apache License, version 2.0 + +#ifndef DNSClient_h +#define DNSClient_h + +#include + +class DNSClient +{ +public: + // ctor + void begin(const IPAddress& aDNSServer); + + /** Convert a numeric IP address string into a four-byte IP address. + @param aIPAddrString IP address to convert + @param aResult IPAddress structure to store the returned IP address + @result 1 if aIPAddrString was successfully converted to an IP address, + else error code + */ + int inet_aton(const char *aIPAddrString, IPAddress& aResult); + + /** Resolve the given hostname to an IP address. + @param aHostname Name to be resolved + @param aResult IPAddress structure to store the returned IP address + @result 1 if aIPAddrString was successfully converted to an IP address, + else error code + */ + int getHostByName(const char* aHostname, IPAddress& aResult); + +protected: + uint16_t BuildRequest(const char* aName); + uint16_t ProcessResponse(uint16_t aTimeout, IPAddress& aAddress); + + IPAddress iDNSServer; + uint16_t iRequestId; + EthernetUDP iUdp; +}; + +#endif diff --git a/libraries/Ethernet3/src/Ethernet3.cpp b/libraries/Ethernet3/src/Ethernet3.cpp new file mode 100644 index 0000000..257a25d --- /dev/null +++ b/libraries/Ethernet3/src/Ethernet3.cpp @@ -0,0 +1,398 @@ +/* + modified 12 Aug 2013 + by Soohwan Kim (suhwan@wiznet.co.kr) + +- 10 Apr. 2015 + Added support for Arduino Ethernet Shield 2 + by Arduino.org team + + */ + +#include "Ethernet3.h" +#include "Dhcp.h" + +extern DhcpClass temp_Dhcp; + +// XXX: don't make assumptions about the value of MAX_SOCK_NUM. +uint8_t EthernetClass::_state[MAX_SOCK_NUM] = { 0, }; +uint16_t EthernetClass::_server_port[MAX_SOCK_NUM] = { 0, }; + +void EthernetClass::setRstPin(uint8_t pinRST) { + _pinRST = pinRST; + pinMode(_pinRST, OUTPUT); + digitalWrite(_pinRST, HIGH); + } +void EthernetClass::setCsPin(uint8_t pinCS) { + _pinCS = pinCS; + } + +void EthernetClass::init(uint8_t maxSockNum) { + _maxSockNum = maxSockNum; + } + +uint8_t EthernetClass::softreset() { + return w5500.softReset(); + } + +void EthernetClass::hardreset() { + if(_pinRST != 0) { + digitalWrite(_pinRST, LOW); + delay(1); + digitalWrite(_pinRST, HIGH); + delay(150); + } + } + +#if defined(WIZ550io_WITH_MACADDRESS) + +int EthernetClass::begin(void) +{ + uint8_t mac_address[6] ={0,}; + +// _dhcp = new DhcpClass(); + _dhcp = &temp_Dhcp; + + // Initialise the basic info + w5500.init(_maxSockNum, _pinCS); + w5500.setIPAddress(IPAddress(0,0,0,0).raw_address()); + w5500.getMACAddress(mac_address); + + if (strlen(_customHostname) != 0) + { + _dhcp->setCustomHostname(_customHostname); + } + + // Now try to get our config info from a DHCP server + int ret = _dhcp->beginWithDHCP(mac_address); + if(ret == 1) + { + // We've successfully found a DHCP server and got our configuration info, so set things + // accordingly + w5500.setIPAddress(_dhcp->getLocalIp().raw_address()); + w5500.setGatewayIp(_dhcp->getGatewayIp().raw_address()); + w5500.setSubnetMask(_dhcp->getSubnetMask().raw_address()); + _dnsServerAddress = _dhcp->getDnsServerIp(); + } + return ret; +} + +void EthernetClass::begin(IPAddress local_ip) +{ + IPAddress subnet(255, 255, 255, 0); + begin(local_ip, subnet); +} + +void EthernetClass::begin(IPAddress local_ip, IPAddress subnet) +{ + // Assume the gateway will be the machine on the same network as the local IP + // but with last octet being '1' + IPAddress gateway = local_ip; + gateway[3] = 1; + begin(local_ip, subnet, gateway); +} + +void EthernetClass::begin(IPAddress local_ip, IPAddress subnet, IPAddress gateway) +{ + // Assume the DNS server will be the machine on the same network as the local IP + // but with last octet being '1' + IPAddress dns_server = local_ip; + dns_server[3] = 1; + begin(local_ip, subnet, gateway, dns_server); +} + +void EthernetClass::begin(IPAddress local_ip, IPAddress subnet, IPAddress gateway, IPAddress dns_server) +{ + w5500.init(_maxSockNum, _pinCS); + w5500.setIPAddress(local_ip.raw_address()); + w5500.setGatewayIp(gateway.raw_address()); + w5500.setSubnetMask(subnet.raw_address()); + _dnsServerAddress = dns_server; +} + +#else +int tempMem; +int EthernetClass::begin(uint8_t *mac_address) +{ + +// _dhcp = new DhcpClass(); + _dhcp = &temp_Dhcp; + + // Initialise the basic info + w5500.init(_maxSockNum, _pinCS); + w5500.setMACAddress(mac_address); + w5500.setIPAddress(IPAddress(0,0,0,0).raw_address()); + + if (strlen(_customHostname) != 0) + { + _dhcp->setCustomHostname(_customHostname); + } + + // Now try to get our config info from a DHCP server + int ret = _dhcp->beginWithDHCP(mac_address); + if(ret == 1) + { + // We've successfully found a DHCP server and got our configuration info, so set things + // accordingly + w5500.setIPAddress(_dhcp->getLocalIp().raw_address()); + w5500.setGatewayIp(_dhcp->getGatewayIp().raw_address()); + w5500.setSubnetMask(_dhcp->getSubnetMask().raw_address()); + _dnsServerAddress = _dhcp->getDnsServerIp(); + } + + return ret; +} + +void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip) +{ + IPAddress subnet(255, 255, 255, 0); + begin(mac_address, local_ip, subnet); +} + +void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress subnet) +{ + // Assume the gateway will be the machine on the same network as the local IP + // but with last octet being '1' + IPAddress gateway = local_ip; + gateway[3] = 1; + begin(mac_address, local_ip, subnet, gateway); +} + +void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress subnet, IPAddress gateway) +{ + // Assume the DNS server will be the machine on the same network as the local IP + // but with last octet being '1' + IPAddress dns_server = local_ip; + dns_server[3] = 1; + begin(mac_address, local_ip, subnet, gateway, dns_server); +} + +void EthernetClass::begin(uint8_t *mac, IPAddress local_ip, IPAddress subnet, IPAddress gateway, IPAddress dns_server) +{ + w5500.init(_maxSockNum, _pinCS); + w5500.setMACAddress(mac); + w5500.setIPAddress(local_ip.raw_address()); + w5500.setGatewayIp(gateway.raw_address()); + w5500.setSubnetMask(subnet.raw_address()); + _dnsServerAddress = dns_server; +} + +#endif + +int EthernetClass::maintain(){ + int rc = DHCP_CHECK_NONE; + if(_dhcp != NULL){ + //we have a pointer to dhcp, use it + rc = _dhcp->checkLease(); + switch ( rc ){ + case DHCP_CHECK_NONE: + //nothing done + break; + case DHCP_CHECK_RENEW_OK: + case DHCP_CHECK_REBIND_OK: + //we might have got a new IP. + w5500.setIPAddress(_dhcp->getLocalIp().raw_address()); + w5500.setGatewayIp(_dhcp->getGatewayIp().raw_address()); + w5500.setSubnetMask(_dhcp->getSubnetMask().raw_address()); + _dnsServerAddress = _dhcp->getDnsServerIp(); + break; + default: + //this is actually a error, it will retry though + break; + } + } + return rc; +} + +void EthernetClass::WoL(bool wol) { + uint8_t val = w5500.readMR(); + bitWrite(val, 5, wol); + w5500.writeMR(val); + } + +bool EthernetClass::WoL() { + uint8_t val = w5500.readMR(); + return bitRead(val, 5); + } + +void EthernetClass::phyMode(phyMode_t mode) { + uint8_t val = w5500.getPHYCFGR(); + bitWrite(val, 6, 1); + if (mode == HALF_DUPLEX_10) { + bitWrite(val, 3, 0); + bitWrite(val, 4, 0); + bitWrite(val, 5, 0); + w5500.setPHYCFGR(val); + } + else if (mode == FULL_DUPLEX_10) { + bitWrite(val, 3, 1); + bitWrite(val, 4, 0); + bitWrite(val, 5, 0); + w5500.setPHYCFGR(val); + } + else if (mode == HALF_DUPLEX_100) { + bitWrite(val, 3, 0); + bitWrite(val, 4, 1); + bitWrite(val, 5, 0); + w5500.setPHYCFGR(val); + } + else if (mode == FULL_DUPLEX_100) { + bitWrite(val, 3, 1); + bitWrite(val, 4, 1); + bitWrite(val, 5, 0); + w5500.setPHYCFGR(val); + } + else if (mode == FULL_DUPLEX_100_AUTONEG) { + bitWrite(val, 3, 0); + bitWrite(val, 4, 0); + bitWrite(val, 5, 1); + w5500.setPHYCFGR(val); + } + else if (mode == POWER_DOWN) { + bitWrite(val, 3, 0); + bitWrite(val, 4, 1); + bitWrite(val, 5, 1); + w5500.setPHYCFGR(val); + } + else if (mode == ALL_AUTONEG) { + bitWrite(val, 3, 1); + bitWrite(val, 4, 1); + bitWrite(val, 5, 1); + w5500.setPHYCFGR(val); + } + bitWrite(val, 7, 0); + w5500.setPHYCFGR(val); + bitWrite(val, 7, 1); + w5500.setPHYCFGR(val); + } + +void EthernetClass::setHostname(const char* hostname) { + memset(_customHostname, 0, 32); + memcpy((void*)_customHostname, (void*)hostname, strlen(hostname) >= 31 ? 31 : strlen(hostname)); + } + +uint8_t EthernetClass::phyState() { + return w5500.getPHYCFGR(); + } + +uint8_t EthernetClass::link() { + return bitRead(w5500.getPHYCFGR(), 0); + } + +const char* EthernetClass::linkReport() { + if(bitRead(w5500.getPHYCFGR(), 0) == 1) return "LINK"; + else return "NO LINK"; + } + +uint8_t EthernetClass::speed() { + if(bitRead(w5500.getPHYCFGR(), 0) == 1) { + if(bitRead(w5500.getPHYCFGR(), 1) == 1) return 100; + if(bitRead(w5500.getPHYCFGR(), 1) == 0) return 10; + } + return 0; + } + +const char* EthernetClass::speedReport() { + if(bitRead(w5500.getPHYCFGR(), 0) == 1) { + if(bitRead(w5500.getPHYCFGR(), 1) == 1) return "100 MB"; + if(bitRead(w5500.getPHYCFGR(), 1) == 0) return "10 MB"; + } + return "NO LINK"; + } + +uint8_t EthernetClass::duplex() { + if(bitRead(w5500.getPHYCFGR(), 0) == 1) { + if(bitRead(w5500.getPHYCFGR(), 2) == 1) return 2; + if(bitRead(w5500.getPHYCFGR(), 2) == 0) return 1; + } + return 0; + } + +const char* EthernetClass::duplexReport() { + if(bitRead(w5500.getPHYCFGR(), 0) == 1) { + if(bitRead(w5500.getPHYCFGR(), 2) == 1) return "FULL DUPLEX"; + if(bitRead(w5500.getPHYCFGR(), 2) == 0) return "HALF DUPLEX"; + } + return "NO LINK"; + } + +void EthernetClass::setRtTimeOut(uint16_t timeout) { + w5500.setRetransmissionTime(timeout); + } + +uint16_t EthernetClass::getRtTimeOut() { + return w5500.getRetransmissionTime(); + } + +void EthernetClass::setRtCount(uint8_t count) { + w5500.setRetransmissionCount(count); + } + +uint8_t EthernetClass::getRtCount() { + return w5500.getRetransmissionCount(); + } + +void EthernetClass::macAddress(uint8_t mac[]) { + w5500.getMACAddress(mac); +} + +#ifdef __RL78__ +char my_NumToHex(uint8_t num) +{ + if(num < 10) + { + return char(num +'0'); + } + else + { + return char(num - 10 +'A'); + } +} +#endif /* __RL78__ */ + +const char* EthernetClass::macAddressReport() { + uint8_t mac[6]; + static char str[18]; + w5500.getMACAddress(mac); + +#ifdef __RL78__ + for(int i=0;i<6;i++) + { + str[i*3] = my_NumToHex(mac[i] / 16); + str[i*3 + 1] = my_NumToHex(mac[i] % 16); + str[i*3 + 2] = ':'; + } + str[17] = 0; +#else + sprintf(str, "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); +#endif /* __RL78__ */ + + return str; +} + +IPAddress EthernetClass::localIP() +{ + IPAddress ret; + w5500.getIPAddress(ret.raw_address()); + return ret; +} + +IPAddress EthernetClass::subnetMask() +{ + IPAddress ret; + w5500.getSubnetMask(ret.raw_address()); + return ret; +} + +IPAddress EthernetClass::gatewayIP() +{ + IPAddress ret; + w5500.getGatewayIp(ret.raw_address()); + return ret; +} + +IPAddress EthernetClass::dnsServerIP() +{ + return _dnsServerAddress; +} + +EthernetClass Ethernet; diff --git a/libraries/Ethernet3/src/Ethernet3.h b/libraries/Ethernet3/src/Ethernet3.h new file mode 100644 index 0000000..451f73a --- /dev/null +++ b/libraries/Ethernet3/src/Ethernet3.h @@ -0,0 +1,114 @@ +/* + modified 12 Aug 2013 + by Soohwan Kim (suhwan@wiznet.co.kr) + + - 10 Apr. 2015 + Added support for Arduino Ethernet Shield 2 + by Arduino.org team + + */ +#ifndef ethernet3_h +#define ethernet3_h + +#include +#include "utility/w5500.h" +#include "api/IPAddress.h" +#include "EthernetClient.h" +#include "EthernetServer.h" +#include "Dhcp.h" + +enum phyMode_t { + HALF_DUPLEX_10, + FULL_DUPLEX_10, + HALF_DUPLEX_100, + FULL_DUPLEX_100, + FULL_DUPLEX_100_AUTONEG, + POWER_DOWN, + ALL_AUTONEG + }; + +class EthernetClass { +private: + IPAddress _dnsServerAddress; + DhcpClass* _dhcp; + char _customHostname[32]; +public: + uint8_t _maxSockNum; + uint8_t _pinCS; + uint8_t _pinRST; + + static uint8_t _state[MAX_SOCK_NUM]; + static uint16_t _server_port[MAX_SOCK_NUM]; + + EthernetClass() { _dhcp = NULL; _pinCS = 10; _maxSockNum = 8; } + + void setRstPin(uint8_t pinRST = 9); // for WIZ550io or USR-ES1, must set befor Ethernet.begin + void setCsPin(uint8_t pinCS = 10); // must set befor Ethernet.begin + + // Initialize with less sockets but more RX/TX Buffer + // maxSockNum = 1 Socket 0 -> RX/TX Buffer 16k + // maxSockNum = 2 Socket 0, 1 -> RX/TX Buffer 8k + // maxSockNum = 4 Socket 0...3 -> RX/TX Buffer 4k + // maxSockNum = 8 (Standard) all sockets -> RX/TX Buffer 2k + // be carefull of the MAX_SOCK_NUM, because in the moment it can't dynamicly changed + void init(uint8_t maxSockNum = 8); + + uint8_t softreset(); // can set only after Ethernet.begin + void hardreset(); // You need to set the Rst pin + +#if defined(WIZ550io_WITH_MACADDRESS) + + // Initialize function when use the ioShield serise (included WIZ550io) + // WIZ550io has a MAC address which is written after reset. + // Default IP, Gateway and subnet address are also writen. + // so, It needs some initial time. please refer WIZ550io Datasheet in details. + int begin(void); + void begin(IPAddress local_ip); + void begin(IPAddress local_ip, IPAddress subnet); + void begin(IPAddress local_ip, IPAddress subnet, IPAddress gateway); + void begin(IPAddress local_ip, IPAddress subnet, IPAddress gateway, IPAddress dns_server); +#else + // Initialize the Ethernet shield to use the provided MAC address and gain the rest of the + // configuration through DHCP. + // Returns 0 if the DHCP configuration failed, and 1 if it succeeded + int begin(uint8_t *mac_address); + void begin(uint8_t *mac_address, IPAddress local_ip); + void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress subnet); + void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress subnet, IPAddress gateway); + void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress subnet, IPAddress gateway, IPAddress dns_server); +#endif + + int maintain(); + void WoL(bool wol); // set Wake on LAN + bool WoL(); // get the WoL state + void phyMode(phyMode_t mode); // set PHYCFGR + uint8_t phyState(); // returns the PHYCFGR + uint8_t link(); // returns the linkstate, 1 = linked, 0 = no link + const char* linkReport(); // returns the linkstate as a string + uint8_t speed(); // returns speed in MB/s + const char* speedReport(); // returns speed as a string + uint8_t duplex(); // returns duplex mode 0 = no link, 1 = Half Duplex, 2 = Full Duplex + const char* duplexReport(); // returns duplex mode as a string + + void setRtTimeOut(uint16_t timeout = 2000); // set the retransmission timout *100us + uint16_t getRtTimeOut(); // get the retransmission timout + void setRtCount(uint8_t count = 8); // set the retransmission count + uint8_t getRtCount(); // get the retransmission count + + void macAddress(uint8_t mac[]); // get the MAC Address + const char* macAddressReport(); // returns the the MAC Address as a string + + void setHostname(const char* hostname); + + IPAddress localIP(); + IPAddress subnetMask(); + IPAddress gatewayIP(); + IPAddress dnsServerIP(); + + friend class EthernetClient; + friend class EthernetServer; +}; + +extern EthernetClass Ethernet; + +#endif diff --git a/libraries/Ethernet3/src/EthernetClient.cpp b/libraries/Ethernet3/src/EthernetClient.cpp new file mode 100644 index 0000000..c1b1c7b --- /dev/null +++ b/libraries/Ethernet3/src/EthernetClient.cpp @@ -0,0 +1,202 @@ +#include "utility/w5500.h" +#include "utility/socket.h" + +extern "C" { + #include "string.h" +} + +#include "Arduino.h" + +#include "Ethernet3.h" +#include "EthernetClient.h" +#include "EthernetServer.h" +#include "Dns.h" + +uint16_t EthernetClient::_srcport = 49152; //Use IANA recommended ephemeral port range 49152-65535 + +EthernetClient::EthernetClient() : _sock(MAX_SOCK_NUM) { +} + +EthernetClient::EthernetClient(uint8_t sock) : _sock(sock) { +} + +int EthernetClient::connect(const char* host, uint16_t port) { + // Look up the host first + int ret = 0; + DNSClient dns; + IPAddress remote_addr; + + dns.begin(Ethernet.dnsServerIP()); + ret = dns.getHostByName(host, remote_addr); + if (ret == 1) { + return connect(remote_addr, port); + } else { + return ret; + } +} + +int EthernetClient::connect(IPAddress ip, uint16_t port) { + if (_sock != MAX_SOCK_NUM) + return 0; + + for (SOCKET i = 0; i < MAX_SOCK_NUM; i++) { + uint8_t s = w5500.readSnSR(i); + if (s == SnSR::CLOSED || s == SnSR::FIN_WAIT || s == SnSR::CLOSE_WAIT) { + _sock = i; + break; + } + } + + if (_sock == MAX_SOCK_NUM) + return 0; + + _srcport++; + if (_srcport == 0) _srcport = 49152; //Use IANA recommended ephemeral port range 49152-65535 + socket(_sock, SnMR::TCP, _srcport, 0); + + if (!::connect(_sock, rawIPAddress(ip), port)) { + _sock = MAX_SOCK_NUM; + return 0; + } + + while (status() != SnSR::ESTABLISHED) { + delay(1); + if (status() == SnSR::CLOSED) { + _sock = MAX_SOCK_NUM; + return 0; + } + } + + return 1; +} + +size_t EthernetClient::write(uint8_t b) { + return write(&b, 1); +} + +size_t EthernetClient::write(const uint8_t *buf, size_t size) { + if (_sock == MAX_SOCK_NUM) { + setWriteError(); + return 0; + } + if (!send(_sock, buf, size)) { + setWriteError(); + return 0; + } + return size; +} + +int EthernetClient::available() { + if (_sock != MAX_SOCK_NUM) + return w5500.getRXReceivedSize(_sock); + return 0; +} + +int EthernetClient::read() { + uint8_t b; + if ( recv(_sock, &b, 1) > 0 ) + { + // recv worked + return b; + } + else + { + // No data available + return -1; + } +} + +int EthernetClient::read(uint8_t *buf, size_t size) { + return recv(_sock, buf, size); +} + +int EthernetClient::peek() { + uint8_t b; + // Unlike recv, peek doesn't check to see if there's any data available, so we must + if (!available()) + return -1; + ::peek(_sock, &b); + return b; +} + +void EthernetClient::flush() { + ::flush(_sock); +} + +void EthernetClient::stop() { + if (_sock == MAX_SOCK_NUM) + return; + + // attempt to close the connection gracefully (send a FIN to other side) + disconnect(_sock); + unsigned long start = millis(); + + // wait a second for the connection to close + uint8_t s; + do { + s = status(); + if (s == SnSR::CLOSED) + break; // exit the loop + delay(1); + } while (millis() - start < 1000); + + // if it hasn't closed, close it forcefully + if (status() != SnSR::CLOSED) + close(_sock); + + EthernetClass::_server_port[_sock] = 0; + _sock = MAX_SOCK_NUM; +} + +uint8_t EthernetClient::connected() { + if (_sock == MAX_SOCK_NUM) return 0; + + uint8_t s = status(); + return !(s == SnSR::LISTEN || s == SnSR::CLOSED || s == SnSR::FIN_WAIT || + (s == SnSR::CLOSE_WAIT && !available())); +} + +uint8_t EthernetClient::status() { + if (_sock == MAX_SOCK_NUM) return SnSR::CLOSED; + return w5500.readSnSR(_sock); +} + +// the next function allows us to use the client returned by +// EthernetServer::available() as the condition in an if-statement. + +EthernetClient::operator bool() { + return _sock != MAX_SOCK_NUM; +} + +bool EthernetClient::operator==(const EthernetClient& rhs) { + return _sock == rhs._sock && _sock != MAX_SOCK_NUM && rhs._sock != MAX_SOCK_NUM; +} + +uint8_t EthernetClient::getSocketNumber() { + return _sock; +} + +void EthernetClient::remoteIP(uint8_t *ip) { + w5500.readSnDIPR(_sock, ip); +} + +void EthernetClient::remoteMAC(uint8_t *mac) { + w5500.readSnDHAR(_sock, mac); +} + +uint8_t EthernetClient::getSocketMode() { + return w5500.readSnMR(_sock); +} + +void EthernetClient::setNoDelayedACK(bool ack) { + uint8_t value; + value = w5500.readSnMR(_sock); + bitWrite(value, 5, ack); + w5500.writeSnMR(_sock, value); +} + +bool EthernetClient::getNoDelayedACK() { + uint8_t value; + value = w5500.readSnMR(_sock); + return bitRead(value, 5); +} diff --git a/libraries/Ethernet3/src/EthernetClient.h b/libraries/Ethernet3/src/EthernetClient.h new file mode 100644 index 0000000..0a17e8c --- /dev/null +++ b/libraries/Ethernet3/src/EthernetClient.h @@ -0,0 +1,54 @@ +#ifndef ethernetclient_h +#define ethernetclient_h +#include "Arduino.h" +#include "api/Print.h" +#include "api/Client.h" +#include "api/IPAddress.h" + +class EthernetClient : public Client { + +public: + EthernetClient(); + EthernetClient(uint8_t sock); + + uint8_t status(); + virtual int connect(IPAddress ip, uint16_t port); + virtual int connect(const char *host, uint16_t port); + virtual size_t write(uint8_t); + virtual size_t write(const uint8_t *buf, size_t size); + virtual int available(); + virtual int read(); + virtual int read(uint8_t *buf, size_t size); + virtual int peek(); + virtual void flush(); + virtual void stop(); + virtual uint8_t connected(); + virtual operator bool(); + virtual bool operator==(const bool value) { return bool() == value; } + virtual bool operator!=(const bool value) { return bool() != value; } + virtual bool operator==(const EthernetClient&); + virtual bool operator!=(const EthernetClient& rhs) { return !this->operator==(rhs); }; + uint8_t getSocketNumber(); + + // Return the IP address of the host who sent the current incoming packet + virtual void remoteIP(uint8_t *ip); + // Return the MAC address of the host who sent the current incoming packet + virtual void remoteMAC(uint8_t *mac); + + // get the value of the socket mode register + virtual uint8_t getSocketMode(); + // set the 'no Delayed ACK' option + virtual void setNoDelayedACK(bool ack = false); + // get the state of 'no Delayed ACK' option + virtual bool getNoDelayedACK(); + + friend class EthernetServer; + + using Print::write; + +private: + static uint16_t _srcport; + uint8_t _sock; +}; + +#endif diff --git a/libraries/Ethernet3/src/EthernetServer.cpp b/libraries/Ethernet3/src/EthernetServer.cpp new file mode 100644 index 0000000..406f0b3 --- /dev/null +++ b/libraries/Ethernet3/src/EthernetServer.cpp @@ -0,0 +1,91 @@ +#include "utility/w5500.h" +#include "utility/socket.h" +extern "C" { +#include "string.h" +} + +#include "Ethernet3.h" +#include "EthernetClient.h" +#include "EthernetServer.h" + +EthernetServer::EthernetServer(uint16_t port) +{ + _port = port; +} + +void EthernetServer::begin() +{ + for (int sock = 0; sock < MAX_SOCK_NUM; sock++) { + EthernetClient client(sock); + if (client.status() == SnSR::CLOSED) { + socket(sock, SnMR::TCP, _port, 0); + listen(sock); + EthernetClass::_server_port[sock] = _port; + break; + } + } +} + +void EthernetServer::accept() +{ + int listening = 0; + + for (int sock = 0; sock < MAX_SOCK_NUM; sock++) { + EthernetClient client(sock); + + if (EthernetClass::_server_port[sock] == _port) { + if (client.status() == SnSR::LISTEN) { + listening = 1; + } + else if (client.status() == SnSR::CLOSE_WAIT && !client.available()) { + client.stop(); + } + } + } + + if (!listening) { + begin(); + } +} + +EthernetClient EthernetServer::available() +{ + accept(); + + for (int sock = 0; sock < MAX_SOCK_NUM; sock++) { + EthernetClient client(sock); + if (EthernetClass::_server_port[sock] == _port && + (client.status() == SnSR::ESTABLISHED || + client.status() == SnSR::CLOSE_WAIT)) { + if (client.available()) { + // XXX: don't always pick the lowest numbered socket. + return client; + } + } + } + + return EthernetClient(MAX_SOCK_NUM); +} + +size_t EthernetServer::write(uint8_t b) +{ + return write(&b, 1); +} + +size_t EthernetServer::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + + accept(); + + for (int sock = 0; sock < MAX_SOCK_NUM; sock++) { + EthernetClient client(sock); + + if (EthernetClass::_server_port[sock] == _port && + client.status() == SnSR::ESTABLISHED) { + n += client.write(buffer, size); + } + } + + return n; +} diff --git a/libraries/Ethernet3/src/EthernetServer.h b/libraries/Ethernet3/src/EthernetServer.h new file mode 100644 index 0000000..e09945f --- /dev/null +++ b/libraries/Ethernet3/src/EthernetServer.h @@ -0,0 +1,22 @@ +#ifndef ethernetserver_h +#define ethernetserver_h + +#include "api/Server.h" + +class EthernetClient; + +class EthernetServer : +public Server { +private: + uint16_t _port; + void accept(); +public: + EthernetServer(uint16_t); + EthernetClient available(); + virtual void begin(); + virtual size_t write(uint8_t); + virtual size_t write(const uint8_t *buf, size_t size); + using Print::write; +}; + +#endif diff --git a/libraries/Ethernet3/src/EthernetUdp3.cpp b/libraries/Ethernet3/src/EthernetUdp3.cpp new file mode 100644 index 0000000..e639bf7 --- /dev/null +++ b/libraries/Ethernet3/src/EthernetUdp3.cpp @@ -0,0 +1,293 @@ +/* + * Udp.cpp: Library to send/receive UDP packets with the Arduino ethernet shield. + * This version only offers minimal wrapping of socket.c/socket.h + * Drop Udp.h/.cpp into the Ethernet library directory at hardware/libraries/Ethernet/ + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + * + * - 10 Apr. 2015 + * Added support for Arduino Ethernet Shield 2 + * by Arduino.org team + */ + +#include "utility/w5500.h" +#include "utility/socket.h" +#include "Ethernet3.h" +#include "api/Udp.h" +#include "Dns.h" + +/* Constructor */ +EthernetUDP::EthernetUDP() : _sock(MAX_SOCK_NUM) {} + +/* Start EthernetUDP socket, listening at local port PORT */ +uint8_t EthernetUDP::begin(uint16_t port) { + if (_sock != MAX_SOCK_NUM) + return 0; + + for (int i = 0; i < MAX_SOCK_NUM; i++) { + uint8_t s = w5500.readSnSR(i); + if (s == SnSR::CLOSED || s == SnSR::FIN_WAIT) { + _sock = i; + break; + } + } + + if (_sock == MAX_SOCK_NUM) + return 0; + + _port = port; + _remaining = 0; + socket(_sock, SnMR::UDP, _port, 0); + + return 1; +} + +/* Start EthernetUDP socket, listening at local port PORT */ +uint8_t EthernetUDP::beginMulticast(IPAddress ip, uint16_t port) +{ + if (_sock != MAX_SOCK_NUM) + return 0; + + for (int i = 0; i < MAX_SOCK_NUM; i++) { + uint8_t s = w5500.readSnSR(i); + if (s == SnSR::CLOSED || s == SnSR::FIN_WAIT) { + _sock = i; + break; + } + } + + if (_sock == MAX_SOCK_NUM) + return 0; + + // Calculate MAC address from Multicast IP Address + byte mac[] = { 0x01, 0x00, 0x5E, 0x00, 0x00, 0x00 }; + + mac[3] = ip[1] & 0x7F; + mac[4] = ip[2]; + mac[5] = ip[3]; + + w5500.writeSnDIPR(_sock, rawIPAddress(ip)); //239.255.0.1 + w5500.writeSnDPORT(_sock, port); + w5500.writeSnDHAR(_sock,mac); + + _remaining = 0; + socket(_sock, SnMR::UDP, port, SnMR::MULTI); + return 1; +} + +/* return number of bytes available in the current packet, + will return zero if parsePacket hasn't been called yet */ +int EthernetUDP::available() { + return _remaining; +} + +/* Release any resources being used by this EthernetUDP instance */ +void EthernetUDP::stop() +{ + if (_sock == MAX_SOCK_NUM) + return; + + close(_sock); + + EthernetClass::_server_port[_sock] = 0; + _sock = MAX_SOCK_NUM; +} + +int EthernetUDP::beginPacket(const char *host, uint16_t port) +{ + // Look up the host first + int ret = 0; + DNSClient dns; + IPAddress remote_addr; + + dns.begin(Ethernet.dnsServerIP()); + ret = dns.getHostByName(host, remote_addr); + if (ret == 1) { + return beginPacket(remote_addr, port); + } else { + return ret; + } +} + +int EthernetUDP::beginPacket(IPAddress ip, uint16_t port) +{ + _offset = 0; + return startUDP(_sock, rawIPAddress(ip), port); +} + +int EthernetUDP::endPacket() +{ + return sendUDP(_sock); +} + +size_t EthernetUDP::write(uint8_t byte) +{ + return write(&byte, 1); +} + +size_t EthernetUDP::write(const uint8_t *buffer, size_t size) +{ + uint16_t bytes_written = bufferData(_sock, _offset, buffer, size); + _offset += bytes_written; + return bytes_written; +} + +int EthernetUDP::parsePacket() +{ + // discard any remaining bytes in the last packet + flush(); + + if (w5500.getRXReceivedSize(_sock) > 0) + { + //HACK - hand-parse the UDP packet using TCP recv method + uint8_t tmpBuf[8]; + int ret =0; + //read 8 header bytes and get IP and port from it + ret = recv(_sock,tmpBuf,8); + if (ret > 0) + { + _remoteIP = tmpBuf; + _remotePort = tmpBuf[4]; + _remotePort = (_remotePort << 8) + tmpBuf[5]; + _remaining = tmpBuf[6]; + _remaining = (_remaining << 8) + tmpBuf[7]; + + // When we get here, any remaining bytes are the data + ret = _remaining; + } + return ret; + } + // There aren't any packets available + return 0; +} + +int EthernetUDP::read() +{ + uint8_t byte; + + if ((_remaining > 0) && (recv(_sock, &byte, 1) > 0)) + { + // We read things without any problems + _remaining--; + return byte; + } + + // If we get here, there's no data available + return -1; +} + +int EthernetUDP::read(uint8_t* buffer, size_t len) +{ + + if (_remaining > 0) + { + + int got; + + if (_remaining <= len) + { + // data should fit in the buffer + got = recv(_sock, buffer, _remaining); + } + else + { + // too much data for the buffer, + // grab as much as will fit + got = recv(_sock, buffer, len); + } + + if (got > 0) + { + _remaining -= got; + return got; + } + + } + + // If we get here, there's no data available or recv failed + return -1; + +} + +int EthernetUDP::peek() +{ + uint8_t b; + // Unlike recv, peek doesn't check to see if there's any data available, so we must. + // If the user hasn't called parsePacket yet then return nothing otherwise they + // may get the UDP header + if (!_remaining) + return -1; + ::peek(_sock, &b); + return b; +} + +void EthernetUDP::flush() +{ + // could this fail (loop endlessly) if _remaining > 0 and recv in read fails? + // should only occur if recv fails after telling us the data is there, lets + // hope the w5500 always behaves :) + + while (_remaining) + { + read(); + } +} + +void EthernetUDP::remoteIP(uint8_t *ip) { + w5500.readSnDIPR(_sock, ip); +} + +void EthernetUDP::remoteMAC(uint8_t *mac) { + w5500.readSnDHAR(_sock, mac); +} + +uint8_t EthernetUDP::getSocketMode() { + return w5500.readSnMR(_sock); +} + +void EthernetUDP::setBroadcastBlock(bool block) { + uint8_t value; + value = w5500.readSnMR(_sock); + bitWrite(value, 6, block); + w5500.writeSnMR(_sock, value); +} + +bool EthernetUDP::getBroadcastBlock() { + uint8_t value; + value = w5500.readSnMR(_sock); + return bitRead(value, 6); +} + +void EthernetUDP::setUnicastBlock(bool block) { + uint8_t value; + value = w5500.readSnMR(_sock); + bitWrite(value, 4, block); + w5500.writeSnMR(_sock, value); +} + +bool EthernetUDP::getUnicastBlock() { + uint8_t value; + value = w5500.readSnMR(_sock); + return bitRead(value, 4); +} + diff --git a/libraries/Ethernet3/src/EthernetUdp3.h b/libraries/Ethernet3/src/EthernetUdp3.h new file mode 100644 index 0000000..fd5a6aa --- /dev/null +++ b/libraries/Ethernet3/src/EthernetUdp3.h @@ -0,0 +1,116 @@ +/* + * Udp.cpp: Library to send/receive UDP packets with the Arduino ethernet shield. + * This version only offers minimal wrapping of socket.c/socket.h + * Drop Udp.h/.cpp into the Ethernet library directory at hardware/libraries/Ethernet/ + * + * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) + * 1) UDP does not guarantee the order in which assembled UDP packets are received. This + * might not happen often in practice, but in larger network topologies, a UDP + * packet can be received out of sequence. + * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being + * aware of it. Again, this may not be a concern in practice on small local networks. + * For more information, see http://www.cafeaulait.org/course/week12/35.html + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + * + * - 10 Apr. 2015 + * Added support for Arduino Ethernet Shield 2 + * by Arduino.org team + * + */ + + +#ifndef ethernetudp3_h +#define ethernetudp3_h + +#include "api/Udp.h" + +#define UDP_TX_PACKET_MAX_SIZE 24 + +class EthernetUDP : public UDP { +private: + uint8_t _sock; // socket ID for Wiz5100 + uint16_t _port; // local port to listen on + IPAddress _remoteIP; // remote IP address for the incoming packet whilst it's being processed + uint16_t _remotePort; // remote port for the incoming packet whilst it's being processed + uint16_t _offset; // offset into the packet being sent + uint16_t _remaining; // remaining bytes of incoming packet yet to be processed + +public: + EthernetUDP(); // Constructor + virtual uint8_t begin(uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + virtual uint8_t beginMulticast(IPAddress, uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + virtual void stop(); // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port); + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port); + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket(); + // Write a single byte into the packet + virtual size_t write(uint8_t); + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size); + + using Print::write; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket(); + // Number of bytes remaining in the current packet + virtual int available(); + // Read a single byte from the current packet + virtual int read(); + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(uint8_t* buffer, size_t len); + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) { return read((uint8_t*)buffer, len); }; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek(); + virtual void flush(); // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() { return _remoteIP; }; + virtual void remoteIP(uint8_t *ip); + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() { return _remotePort; }; + // Return the MAC address of the host who sent the current incoming packet + virtual void remoteMAC(uint8_t *mac); + + virtual uint8_t getSocketMode(); + virtual void setBroadcastBlock(bool block = false); // set Broadcast blocking + virtual bool getBroadcastBlock(); // get Broadcast blocking state + virtual void setUnicastBlock(bool block = false); // set Unicast blocking, only when socketin Multicast mode + virtual bool getUnicastBlock(); // get Unicast blocking state + +}; + +#endif diff --git a/libraries/Ethernet3/src/utility/socket.cpp b/libraries/Ethernet3/src/utility/socket.cpp new file mode 100644 index 0000000..579def6 --- /dev/null +++ b/libraries/Ethernet3/src/utility/socket.cpp @@ -0,0 +1,416 @@ + /* + * - 10 Apr. 2015 + * Added support for Arduino Ethernet Shield 2 + * by Arduino.org team + */ + +#include "utility/w5500.h" +#include "utility/socket.h" + +static uint16_t local_port; + +/** + * @brief This Socket function initialize the channel in perticular mode, and set the port and wait for w5500 done it. + * @return 1 for success else 0. + */ +uint8_t socket(SOCKET s, uint8_t protocol, uint16_t port, uint8_t flag) +{ + if ((protocol == SnMR::TCP) || (protocol == SnMR::UDP) || (protocol == SnMR::IPRAW) || (protocol == SnMR::MACRAW) || (protocol == SnMR::PPPOE)) + { + close(s); + w5500.writeSnMR(s, protocol | flag); + if (port != 0) { + w5500.writeSnPORT(s, port); + } + else { + local_port++; // if don't set the source port, set local_port number. + w5500.writeSnPORT(s, local_port); + } + + w5500.execCmdSn(s, Sock_OPEN); + + return 1; + } + + return 0; +} + + +/** + * @brief This function close the socket and parameter is "s" which represent the socket number + */ +void close(SOCKET s) +{ + w5500.execCmdSn(s, Sock_CLOSE); + w5500.writeSnIR(s, 0xFF); +} + + +/** + * @brief This function established the connection for the channel in passive (server) mode. This function waits for the request from the peer. + * @return 1 for success else 0. + */ +uint8_t listen(SOCKET s) +{ + if (w5500.readSnSR(s) != SnSR::INIT) + return 0; + w5500.execCmdSn(s, Sock_LISTEN); + return 1; +} + + +/** + * @brief This function established the connection for the channel in Active (client) mode. + * This function waits for the untill the connection is established. + * + * @return 1 for success else 0. + */ +uint8_t connect(SOCKET s, uint8_t * addr, uint16_t port) +{ + if + ( + ((addr[0] == 0xFF) && (addr[1] == 0xFF) && (addr[2] == 0xFF) && (addr[3] == 0xFF)) || + ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && (addr[3] == 0x00)) || + (port == 0x00) + ) + return 0; + + // set destination IP + w5500.writeSnDIPR(s, addr); + w5500.writeSnDPORT(s, port); + w5500.execCmdSn(s, Sock_CONNECT); + + return 1; +} + + + +/** + * @brief This function used for disconnect the socket and parameter is "s" which represent the socket number + * @return 1 for success else 0. + */ +void disconnect(SOCKET s) +{ + w5500.execCmdSn(s, Sock_DISCON); +} + + +/** + * @brief This function used to send the data in TCP mode + * @return 1 for success else 0. + */ +uint16_t send(SOCKET s, const uint8_t * buf, uint16_t len) +{ + uint8_t status=0; + uint16_t ret=0; + uint16_t freesize=0; + + if (len > w5500.SSIZE) + ret = w5500.SSIZE; // check size not to exceed MAX size. + else + ret = len; + + // if freebuf is available, start. + do + { + freesize = w5500.getTXFreeSize(s); + status = w5500.readSnSR(s); + if ((status != SnSR::ESTABLISHED) && (status != SnSR::CLOSE_WAIT)) + { + ret = 0; + break; + } + } + while (freesize < ret); + + // copy data + w5500.send_data_processing(s, (uint8_t *)buf, ret); + w5500.execCmdSn(s, Sock_SEND); + + /* +2008.01 bj */ + while ( (w5500.readSnIR(s) & SnIR::SEND_OK) != SnIR::SEND_OK ) + { + /* m2008.01 [bj] : reduce code */ + if ( w5500.readSnSR(s) == SnSR::CLOSED ) + { + close(s); + return 0; + } + } + /* +2008.01 bj */ + w5500.writeSnIR(s, SnIR::SEND_OK); + return ret; +} + + +/** + * @brief This function is an application I/F function which is used to receive the data in TCP mode. + * It continues to wait for data as much as the application wants to receive. + * + * @return received data size for success else -1. + */ +int16_t recv(SOCKET s, uint8_t *buf, int16_t len) +{ + // Check how much data is available + int16_t ret = w5500.getRXReceivedSize(s); + if ( ret == 0 ) + { + // No data available. + uint8_t status = w5500.readSnSR(s); + if ( status == SnSR::LISTEN || status == SnSR::CLOSED || status == SnSR::CLOSE_WAIT ) + { + // The remote end has closed its side of the connection, so this is the eof state + ret = 0; + } + else + { + // The connection is still up, but there's no data waiting to be read + ret = -1; + } + } + else if (ret > len) + { + ret = len; + } + + if ( ret > 0 ) + { + w5500.recv_data_processing(s, buf, ret); + w5500.execCmdSn(s, Sock_RECV); + } + return ret; +} + + +/** + * @brief Returns the first byte in the receive queue (no checking) + * + * @return + */ +uint16_t peek(SOCKET s, uint8_t *buf) +{ + w5500.recv_data_processing(s, buf, 1, 1); + + return 1; +} + + +/** + * @brief This function is an application I/F function which is used to send the data for other then TCP mode. + * Unlike TCP transmission, The peer's destination address and the port is needed. + * + * @return This function return send data size for success else -1. + */ +uint16_t sendto(SOCKET s, const uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t port) +{ + uint16_t ret=0; + + if (len > w5500.SSIZE) ret = w5500.SSIZE; // check size not to exceed MAX size. + else ret = len; + + if + ( + ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && (addr[3] == 0x00)) || + ((port == 0x00)) ||(ret == 0) + ) + { + /* +2008.01 [bj] : added return value */ + ret = 0; + } + else + { + w5500.writeSnDIPR(s, addr); + w5500.writeSnDPORT(s, port); + + // copy data + w5500.send_data_processing(s, (uint8_t *)buf, ret); + w5500.execCmdSn(s, Sock_SEND); + + /* +2008.01 bj */ + while ( (w5500.readSnIR(s) & SnIR::SEND_OK) != SnIR::SEND_OK ) + { + if (w5500.readSnIR(s) & SnIR::TIMEOUT) + { + /* +2008.01 [bj]: clear interrupt */ + w5500.writeSnIR(s, (SnIR::SEND_OK | SnIR::TIMEOUT)); /* clear SEND_OK & TIMEOUT */ + return 0; + } + } + + /* +2008.01 bj */ + w5500.writeSnIR(s, SnIR::SEND_OK); + } + return ret; +} + + +/** + * @brief This function is an application I/F function which is used to receive the data in other then + * TCP mode. This function is used to receive UDP, IP_RAW and MAC_RAW mode, and handle the header as well. + * + * @return This function return received data size for success else -1. + */ +uint16_t recvfrom(SOCKET s, uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t *port) +{ + uint8_t head[8]; + uint16_t data_len=0; + uint16_t ptr=0; + + if ( len > 0 ) + { + ptr = w5500.readSnRX_RD(s); + switch (w5500.readSnMR(s) & 0x07) + { + case SnMR::UDP : + w5500.read_data(s, ptr, head, 0x08); + ptr += 8; + // read peer's IP address, port number. + addr[0] = head[0]; + addr[1] = head[1]; + addr[2] = head[2]; + addr[3] = head[3]; + *port = head[4]; + *port = (*port << 8) + head[5]; + data_len = head[6]; + data_len = (data_len << 8) + head[7]; + + w5500.read_data(s, ptr, buf, data_len); // data copy. + ptr += data_len; + + w5500.writeSnRX_RD(s, ptr); + break; + + case SnMR::IPRAW : + w5500.read_data(s, ptr, head, 0x06); + ptr += 6; + + addr[0] = head[0]; + addr[1] = head[1]; + addr[2] = head[2]; + addr[3] = head[3]; + data_len = head[4]; + data_len = (data_len << 8) + head[5]; + + w5500.read_data(s, ptr, buf, data_len); // data copy. + ptr += data_len; + + w5500.writeSnRX_RD(s, ptr); + break; + + case SnMR::MACRAW: + w5500.read_data(s, ptr, head, 2); + ptr+=2; + data_len = head[0]; + data_len = (data_len<<8) + head[1] - 2; + + w5500.read_data(s, ptr, buf, data_len); + ptr += data_len; + w5500.writeSnRX_RD(s, ptr); + break; + + default : + break; + } + w5500.execCmdSn(s, Sock_RECV); + } + return data_len; +} + +/** + * @brief Wait for buffered transmission to complete. + */ +void flush(SOCKET s) { + // TODO +#ifdef __RL78__ + (void)s; //Warning measures +#endif /* __RL78__ */ + +} + +uint16_t igmpsend(SOCKET s, const uint8_t * buf, uint16_t len) +{ + uint8_t status=0; + uint16_t ret=0; + + if (len > w5500.SSIZE) + ret = w5500.SSIZE; // check size not to exceed MAX size. + else + ret = len; + + if (ret == 0) + return 0; + + w5500.send_data_processing(s, (uint8_t *)buf, ret); + w5500.execCmdSn(s, Sock_SEND); + + while ( (w5500.readSnIR(s) & SnIR::SEND_OK) != SnIR::SEND_OK ) + { + status = w5500.readSnSR(s); + if (w5500.readSnIR(s) & SnIR::TIMEOUT) + { + /* in case of igmp, if send fails, then socket closed */ + /* if you want change, remove this code. */ + close(s); + return 0; + } + } + + w5500.writeSnIR(s, SnIR::SEND_OK); + return ret; +} + +uint16_t bufferData(SOCKET s, uint16_t offset, const uint8_t* buf, uint16_t len) +{ + uint16_t ret =0; + if (len > w5500.getTXFreeSize(s)) + { + ret = w5500.getTXFreeSize(s); // check size not to exceed MAX size. + } + else + { + ret = len; + } + w5500.send_data_processing_offset(s, offset, buf, ret); + return ret; +} + +int startUDP(SOCKET s, uint8_t* addr, uint16_t port) +{ + if + ( + ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && (addr[3] == 0x00)) || + ((port == 0x00)) + ) + { + return 0; + } + else + { + w5500.writeSnDIPR(s, addr); + w5500.writeSnDPORT(s, port); + return 1; + } +} + +int sendUDP(SOCKET s) +{ + w5500.execCmdSn(s, Sock_SEND); + + /* +2008.01 bj */ + while ( (w5500.readSnIR(s) & SnIR::SEND_OK) != SnIR::SEND_OK ) + { + if (w5500.readSnIR(s) & SnIR::TIMEOUT) + { + /* +2008.01 [bj]: clear interrupt */ + w5500.writeSnIR(s, (SnIR::SEND_OK|SnIR::TIMEOUT)); + return 0; + } + } + + /* +2008.01 bj */ + w5500.writeSnIR(s, SnIR::SEND_OK); + + /* Sent ok */ + return 1; +} + diff --git a/libraries/Ethernet3/src/utility/socket.h b/libraries/Ethernet3/src/utility/socket.h new file mode 100644 index 0000000..903280c --- /dev/null +++ b/libraries/Ethernet3/src/utility/socket.h @@ -0,0 +1,48 @@ + /* + * - 10 Apr. 2015 + * Added support for Arduino Ethernet Shield 2 + * by Arduino.org team + */ + +#ifndef _SOCKET_H_ +#define _SOCKET_H_ + +#include "utility/w5500.h" + +extern uint8_t socket(SOCKET s, uint8_t protocol, uint16_t port, uint8_t flag); // Opens a socket(TCP or UDP or IP_RAW mode) +extern void close(SOCKET s); // Close socket +extern uint8_t connect(SOCKET s, uint8_t * addr, uint16_t port); // Establish TCP connection (Active connection) +extern void disconnect(SOCKET s); // disconnect the connection +extern uint8_t listen(SOCKET s); // Establish TCP connection (Passive connection) +extern uint16_t send(SOCKET s, const uint8_t * buf, uint16_t len); // Send data (TCP) +extern int16_t recv(SOCKET s, uint8_t * buf, int16_t len); // Receive data (TCP) +extern uint16_t peek(SOCKET s, uint8_t *buf); +extern uint16_t sendto(SOCKET s, const uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); // Send data (UDP/IP RAW) +extern uint16_t recvfrom(SOCKET s, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); // Receive data (UDP/IP RAW) +extern void flush(SOCKET s); // Wait for transmission to complete + +extern uint16_t igmpsend(SOCKET s, const uint8_t * buf, uint16_t len); + +// Functions to allow buffered UDP send (i.e. where the UDP datagram is built up over a +// number of calls before being sent +/* + @brief This function sets up a UDP datagram, the data for which will be provided by one + or more calls to bufferData and then finally sent with sendUDP. + @return 1 if the datagram was successfully set up, or 0 if there was an error +*/ +extern int startUDP(SOCKET s, uint8_t* addr, uint16_t port); +/* + @brief This function copies up to len bytes of data from buf into a UDP datagram to be + sent later by sendUDP. Allows datagrams to be built up from a series of bufferData calls. + @return Number of bytes successfully buffered +*/ +uint16_t bufferData(SOCKET s, uint16_t offset, const uint8_t* buf, uint16_t len); +/* + @brief Send a UDP datagram built up from a sequence of startUDP followed by one or more + calls to bufferData. + @return 1 if the datagram was successfully sent, or 0 if there was an error +*/ +int sendUDP(SOCKET s); + +#endif +/* _SOCKET_H_ */ diff --git a/libraries/Ethernet3/src/utility/util.h b/libraries/Ethernet3/src/utility/util.h new file mode 100644 index 0000000..33d32a9 --- /dev/null +++ b/libraries/Ethernet3/src/utility/util.h @@ -0,0 +1,14 @@ +#ifndef UTIL_H +#define UTIL_H + +#define htons(x) ( ((x)<< 8 & 0xFF00) | \ + ((x)>> 8 & 0x00FF) ) +#define ntohs(x) htons(x) + +#define htonl(x) ( ((x)<<24 & 0xFF000000UL) | \ + ((x)<< 8 & 0x00FF0000UL) | \ + ((x)>> 8 & 0x0000FF00UL) | \ + ((x)>>24 & 0x000000FFUL) ) +#define ntohl(x) htonl(x) + +#endif diff --git a/libraries/Ethernet3/src/utility/w5500.cpp b/libraries/Ethernet3/src/utility/w5500.cpp new file mode 100644 index 0000000..e828b6f --- /dev/null +++ b/libraries/Ethernet3/src/utility/w5500.cpp @@ -0,0 +1,240 @@ +/* + * Copyright (c) 2010 by WIZnet + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of either the GNU General Public License version 2 + * or the GNU Lesser General Public License version 2.1, both as + * published by the Free Software Foundation. + * + * - 10 Apr. 2015 + * Added support for Arduino Ethernet Shield 2 + * by Arduino.org team + */ + +#include +#include +#include "Arduino.h" + +#include "utility/w5500.h" + +// W5500 controller instance +W5500Class w5500; + +// SPI details +SPISettings wiznet_SPI_settings(8000000, MSBFIRST, SPI_MODE0); + +uint8_t SPI_CS; + +void W5500Class::init(uint8_t socketNumbers, uint8_t ss_pin) +{ + SPI_CS = ss_pin; + + delay(1000); + initSS(); + SPI.begin(); + + if(socketNumbers == 1) { + for (int i = 1; i < MAX_SOCK_NUM; i++) { + uint8_t cntl_byte = (uint8_t)(0x0C + (i<<5)); + write( 0x1E, cntl_byte, 0); //0x1E - Sn_RXBUF_SIZE + write( 0x1F, cntl_byte, 0); //0x1F - Sn_TXBUF_SIZE + } + uint8_t cntl_byte = (0x0C + (0<<5)); + write( 0x1E, cntl_byte, 16); //0x1E - Sn_RXBUF_SIZE + write( 0x1F, cntl_byte, 16); //0x1F - Sn_TXBUF_SIZE + } + + else if(socketNumbers == 2) { + for (int i = 2; i < MAX_SOCK_NUM; i++) { + uint8_t cntl_byte = (uint8_t)(0x0C + (i<<5)); + write( 0x1E, cntl_byte, 0); //0x1E - Sn_RXBUF_SIZE + write( 0x1F, cntl_byte, 0); //0x1F - Sn_TXBUF_SIZE + } + for (int i = 0; i < 2; i++) { + uint8_t cntl_byte = (uint8_t)(0x0C + (i<<5)); + write( 0x1E, cntl_byte, 8); //0x1E - Sn_RXBUF_SIZE + write( 0x1F, cntl_byte, 8); //0x1F - Sn_TXBUF_SIZE + } + } + + else if(socketNumbers == 4) { + for (int i = 4; i < MAX_SOCK_NUM; i++) { + uint8_t cntl_byte = (uint8_t)(0x0C + (i<<5)); + write( 0x1E, cntl_byte, 0); //0x1E - Sn_RXBUF_SIZE + write( 0x1F, cntl_byte, 0); //0x1F - Sn_TXBUF_SIZE + } + for (int i = 0; i < 4; i++) { + uint8_t cntl_byte = (uint8_t)(0x0C + (i<<5)); + write( 0x1E, cntl_byte, 4); //0x1E - Sn_RXBUF_SIZE + write( 0x1F, cntl_byte, 4); //0x1F - Sn_TXBUF_SIZE + } + } + + else { + for (int i = 0; i < MAX_SOCK_NUM; i++) { + uint8_t cntl_byte = (uint8_t)(0x0C + (i<<5)); + write( 0x1E, cntl_byte, 2); //0x1E - Sn_RXBUF_SIZE + write( 0x1F, cntl_byte, 2); //0x1F - Sn_TXBUF_SIZE + } + } +} + +uint16_t W5500Class::getTXFreeSize(SOCKET s) +{ + uint16_t val=0, val1=0; + do { + val1 = readSnTX_FSR(s); + if (val1 != 0) + val = readSnTX_FSR(s); + } + while (val != val1); + return val; +} + +uint16_t W5500Class::getRXReceivedSize(SOCKET s) +{ + uint16_t val=0,val1=0; + do { + val1 = readSnRX_RSR(s); + if (val1 != 0) + val = readSnRX_RSR(s); + } + while (val != val1); + return val; +} + +void W5500Class::send_data_processing(SOCKET s, const uint8_t *data, uint16_t len) +{ + // This is same as having no offset in a call to send_data_processing_offset + send_data_processing_offset(s, 0, data, len); + +} + +void W5500Class::send_data_processing_offset(SOCKET s, uint16_t data_offset, const uint8_t *data, uint16_t len) +{ + uint16_t ptr = readSnTX_WR(s); + uint8_t cntl_byte = (uint8_t)(0x14+(s<<5)); + ptr += data_offset; + write(ptr, cntl_byte, data, len); + ptr += len; + writeSnTX_WR(s, ptr); +} + +void W5500Class::recv_data_processing(SOCKET s, uint8_t *data, uint16_t len, uint8_t peek) +{ + uint16_t ptr; + ptr = readSnRX_RD(s); + + read_data(s, ptr, data, len); + if (!peek) + { + ptr += len; + writeSnRX_RD(s, ptr); + } +} + +void W5500Class::read_data(SOCKET s, volatile uint16_t src, volatile uint8_t *dst, uint16_t len) +{ + uint8_t cntl_byte = (uint8_t)(0x18+(s<<5)); + read((uint16_t)src , cntl_byte, (uint8_t *)dst, len); +} + +uint8_t W5500Class::write(uint16_t _addr, uint8_t _cb, uint8_t _data) +{ + SPI.beginTransaction(wiznet_SPI_settings); + setSS(); + SPI.transfer(_addr >> 8); + SPI.transfer(_addr & 0xFF); + SPI.transfer(_cb); + SPI.transfer(_data); + resetSS(); + SPI.endTransaction(); + + return 1; +} + +uint16_t W5500Class::write(uint16_t _addr, uint8_t _cb, const uint8_t *_buf, uint16_t _len) +{ + SPI.beginTransaction(wiznet_SPI_settings); + setSS(); + SPI.transfer(_addr >> 8); + SPI.transfer(_addr & 0xFF); + SPI.transfer(_cb); + for (uint16_t i=0; i<_len; i++){ + SPI.transfer(_buf[i]); + } + resetSS(); + SPI.endTransaction(); + + return _len; +} + +uint8_t W5500Class::read(uint16_t _addr, uint8_t _cb) +{ + SPI.beginTransaction(wiznet_SPI_settings); + setSS(); + SPI.transfer(_addr >> 8); + SPI.transfer(_addr & 0xFF); + SPI.transfer(_cb); + uint8_t _data = SPI.transfer(0); + resetSS(); + SPI.endTransaction(); + + return _data; +} + +uint16_t W5500Class::read(uint16_t _addr, uint8_t _cb, uint8_t *_buf, uint16_t _len) +{ + SPI.beginTransaction(wiznet_SPI_settings); + setSS(); + SPI.transfer(_addr >> 8); + SPI.transfer(_addr & 0xFF); + SPI.transfer(_cb); + for (uint16_t i=0; i<_len; i++){ + _buf[i] = SPI.transfer(0); + } + resetSS(); + SPI.endTransaction(); + + return _len; +} + +void W5500Class::execCmdSn(SOCKET s, SockCMD _cmd) { + // Send command to socket + writeSnCR(s, _cmd); + // Wait for command to complete + while (readSnCR(s)) + ; +} + + +uint8_t W5500Class::readVersion(void) +{ + SPI.beginTransaction(wiznet_SPI_settings); + setSS(); + SPI.transfer( 0x00 ); + SPI.transfer( 0x39 ); + SPI.transfer( 0x01); + uint8_t _data = SPI.transfer(0); + resetSS(); + SPI.endTransaction(); + + return _data; +} + +// Soft reset the Wiznet chip, by writing to its MR register reset bit +uint8_t W5500Class::softReset(void) +{ + uint16_t count=0; + // write to reset bit + writeMR(0x80); + // then wait for soft reset to complete + do { + uint8_t mr = readMR(); + if (mr == 0) return 1; + delay(1); + } while (++count < 20); + return 0; +} + +//#endif diff --git a/libraries/Ethernet3/src/utility/w5500.h b/libraries/Ethernet3/src/utility/w5500.h new file mode 100644 index 0000000..eedaa0d --- /dev/null +++ b/libraries/Ethernet3/src/utility/w5500.h @@ -0,0 +1,427 @@ +/* +* Copyright (c) 2010 by WIZnet + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of either the GNU General Public License version 2 + * or the GNU Lesser General Public License version 2.1, both as + * published by the Free Software Foundation. + * + * - 10 Apr. 2015 + * Added support for Arduino Ethernet Shield 2 + * by Arduino.org team + */ + +#ifndef W5500_H_INCLUDED +#define W5500_H_INCLUDED + +#define MAX_SOCK_NUM 8 + + +#include +#include + +extern uint8_t SPI_CS; + +typedef uint8_t SOCKET; +/* +class MR { +public: + static const uint8_t RST = 0x80; + static const uint8_t PB = 0x10; + static const uint8_t PPPOE = 0x08; + static const uint8_t LB = 0x04; + static const uint8_t AI = 0x02; + static const uint8_t IND = 0x01; +}; +*/ +/* +class IR { +public: + static const uint8_t CONFLICT = 0x80; + static const uint8_t UNREACH = 0x40; + static const uint8_t PPPoE = 0x20; + static const uint8_t SOCK0 = 0x01; + static const uint8_t SOCK1 = 0x02; + static const uint8_t SOCK2 = 0x04; + static const uint8_t SOCK3 = 0x08; + static inline uint8_t SOCK(SOCKET ch) { return (0x01 << ch); }; +}; +*/ + +class SnMR { +public: + static const uint8_t CLOSE = 0x00; + static const uint8_t TCP = 0x01; + static const uint8_t UDP = 0x02; + static const uint8_t IPRAW = 0x03; + static const uint8_t MACRAW = 0x04; + static const uint8_t PPPOE = 0x05; + static const uint8_t ND = 0x20; + static const uint8_t MULTI = 0x80; +}; + +enum SockCMD { + Sock_OPEN = 0x01, + Sock_LISTEN = 0x02, + Sock_CONNECT = 0x04, + Sock_DISCON = 0x08, + Sock_CLOSE = 0x10, + Sock_SEND = 0x20, + Sock_SEND_MAC = 0x21, + Sock_SEND_KEEP = 0x22, + Sock_RECV = 0x40 +}; + +/*class SnCmd { +public: + static const uint8_t OPEN = 0x01; + static const uint8_t LISTEN = 0x02; + static const uint8_t CONNECT = 0x04; + static const uint8_t DISCON = 0x08; + static const uint8_t CLOSE = 0x10; + static const uint8_t SEND = 0x20; + static const uint8_t SEND_MAC = 0x21; + static const uint8_t SEND_KEEP = 0x22; + static const uint8_t RECV = 0x40; +}; +*/ + +class SnIR { +public: + static const uint8_t SEND_OK = 0x10; + static const uint8_t TIMEOUT = 0x08; + static const uint8_t RECV = 0x04; + static const uint8_t DISCON = 0x02; + static const uint8_t CON = 0x01; +}; + +class SnSR { +public: + static const uint8_t CLOSED = 0x00; + static const uint8_t INIT = 0x13; + static const uint8_t LISTEN = 0x14; + static const uint8_t SYNSENT = 0x15; + static const uint8_t SYNRECV = 0x16; + static const uint8_t ESTABLISHED = 0x17; + static const uint8_t FIN_WAIT = 0x18; + static const uint8_t CLOSING = 0x1A; + static const uint8_t TIME_WAIT = 0x1B; + static const uint8_t CLOSE_WAIT = 0x1C; + static const uint8_t LAST_ACK = 0x1D; + static const uint8_t UDP = 0x22; + static const uint8_t IPRAW = 0x32; + static const uint8_t MACRAW = 0x42; + static const uint8_t PPPOE = 0x5F; +}; + +class IPPROTO { +public: + static const uint8_t IP = 0; + static const uint8_t ICMP = 1; + static const uint8_t IGMP = 2; + static const uint8_t GGP = 3; + static const uint8_t TCP = 6; + static const uint8_t PUP = 12; + static const uint8_t UDP = 17; + static const uint8_t IDP = 22; + static const uint8_t ND = 77; + static const uint8_t RAW = 255; +}; + +class W5500Class { + +public: + void init(uint8_t socketNumbers, uint8_t ss_pin = 10); + static uint8_t softReset(void); + uint8_t readVersion(void); + + /** + * @brief This function is being used for copy the data form Receive buffer of the chip to application buffer. + * + * It calculate the actual physical address where one has to read + * the data from Receive buffer. Here also take care of the condition while it exceed + * the Rx memory uper-bound of socket. + */ + void read_data(SOCKET s, volatile uint16_t src, volatile uint8_t * dst, uint16_t len); + + /** + * @brief This function is being called by send() and sendto() function also. + * + * This function read the Tx write pointer register and after copy the data in buffer update the Tx write pointer + * register. User should read upper byte first and lower byte later to get proper value. + */ + void send_data_processing(SOCKET s, const uint8_t *data, uint16_t len); + /** + * @brief A copy of send_data_processing that uses the provided ptr for the + * write offset. Only needed for the "streaming" UDP API, where + * a single UDP packet is built up over a number of calls to + * send_data_processing_ptr, because TX_WR doesn't seem to get updated + * correctly in those scenarios + * @param ptr value to use in place of TX_WR. If 0, then the value is read + * in from TX_WR + * @return New value for ptr, to be used in the next call + */ + // FIXME Update documentation + void send_data_processing_offset(SOCKET s, uint16_t data_offset, const uint8_t *data, uint16_t len); + + /** + * @brief This function is being called by recv() also. + * + * This function read the Rx read pointer register + * and after copy the data from receive buffer update the Rx write pointer register. + * User should read upper byte first and lower byte later to get proper value. + */ + void recv_data_processing(SOCKET s, uint8_t *data, uint16_t len, uint8_t peek = 0); + + inline void setGatewayIp(uint8_t *_addr); + inline void getGatewayIp(uint8_t *_addr); + + inline void setSubnetMask(uint8_t *_addr); + inline void getSubnetMask(uint8_t *_addr); + + inline void setMACAddress(uint8_t * addr); + inline void getMACAddress(uint8_t * addr); + + inline void setIPAddress(uint8_t * addr); + inline void getIPAddress(uint8_t * addr); + + inline void setRetransmissionTime(uint16_t timeout); + inline uint16_t getRetransmissionTime(); + inline void setRetransmissionCount(uint8_t _retry); + inline uint8_t getRetransmissionCount(); + + inline void setPHYCFGR(uint8_t _val); + inline uint8_t getPHYCFGR(); + + void execCmdSn(SOCKET s, SockCMD _cmd); + + uint16_t getTXFreeSize(SOCKET s); + uint16_t getRXReceivedSize(SOCKET s); + + + // W5500 Registers + // --------------- +private: + static uint8_t write(uint16_t _addr, uint8_t _cb, uint8_t _data); + static uint16_t write(uint16_t _addr, uint8_t _cb, const uint8_t *buf, uint16_t len); + static uint8_t read(uint16_t _addr, uint8_t _cb ); + static uint16_t read(uint16_t _addr, uint8_t _cb, uint8_t *buf, uint16_t len); + +#define __GP_REGISTER8(name, address) \ + static inline void write##name(uint8_t _data) { \ + write(address, 0x04, _data); \ + } \ + static inline uint8_t read##name() { \ + return read(address, 0x00); \ + } +#define __GP_REGISTER16(name, address) \ + static void write##name(uint16_t _data) { \ + write(address, 0x04, _data >> 8); \ + write(address+1, 0x04, _data & 0xFF); \ + } \ + static uint16_t read##name() { \ + uint16_t res = read(address, 0x00); \ + res = (res << 8) + read(address + 1, 0x00); \ + return res; \ + } +#define __GP_REGISTER_N(name, address, size) \ + static uint16_t write##name(uint8_t *_buff) { \ + return write(address, 0x04, _buff, size); \ + } \ + static uint16_t read##name(uint8_t *_buff) { \ + return read(address, 0x00, _buff, size); \ + } + +public: + __GP_REGISTER8 (MR, 0x0000); // Mode + __GP_REGISTER_N(GAR, 0x0001, 4); // Gateway IP address + __GP_REGISTER_N(SUBR, 0x0005, 4); // Subnet mask address + __GP_REGISTER_N(SHAR, 0x0009, 6); // Source MAC address + __GP_REGISTER_N(SIPR, 0x000F, 4); // Source IP address + __GP_REGISTER8 (IR, 0x0015); // Interrupt + __GP_REGISTER8 (IMR, 0x0016); // Interrupt Mask + __GP_REGISTER16(RTR, 0x0019); // Timeout address + __GP_REGISTER8 (RCR, 0x001B); // Retry count + __GP_REGISTER_N(UIPR, 0x0028, 4); // Unreachable IP address in UDP mode + __GP_REGISTER16(UPORT, 0x002C); // Unreachable Port address in UDP mode + __GP_REGISTER8 (PHYCFGR, 0x002E); // PHY Configuration register, default value: 0b 1011 1xxx + + +#undef __GP_REGISTER8 +#undef __GP_REGISTER16 +#undef __GP_REGISTER_N + + // W5500 Socket registers + // ---------------------- +private: + static inline uint8_t readSn(SOCKET _s, uint16_t _addr); + static inline uint8_t writeSn(SOCKET _s, uint16_t _addr, uint8_t _data); + static inline uint16_t readSn(SOCKET _s, uint16_t _addr, uint8_t *_buf, uint16_t len); + static inline uint16_t writeSn(SOCKET _s, uint16_t _addr, uint8_t *_buf, uint16_t len); + + //static const uint16_t CH_BASE = 0x0000; + //static const uint16_t CH_SIZE = 0x0000; + +#define __SOCKET_REGISTER8(name, address) \ + static inline void write##name(SOCKET _s, uint8_t _data) { \ + writeSn(_s, address, _data); \ + } \ + static inline uint8_t read##name(SOCKET _s) { \ + return readSn(_s, address); \ + } +#if defined(REL_GR_KURUMI) || defined(REL_GR_KURUMI_PROTOTYPE) +#define __SOCKET_REGISTER16(name, address) \ + static void write##name(SOCKET _s, uint16_t _data) { \ + writeSn(_s, address, _data >> 8); \ + writeSn(_s, address+1, _data & 0xFF); \ + } \ + static uint16_t read##name(SOCKET _s) { \ + uint16_t res = readSn(_s, address); \ + uint16_t res2 = readSn(_s,address + 1); \ + res = res << 8; \ + res2 = res2 & 0xFF; \ + res = res | res2; \ + return res; \ + } +#else +#define __SOCKET_REGISTER16(name, address) \ + static void write##name(SOCKET _s, uint16_t _data) { \ + writeSn(_s, address, _data >> 8); \ + writeSn(_s, address+1, _data & 0xFF); \ + } \ + static uint16_t read##name(SOCKET _s) { \ + uint16_t res = readSn(_s, address); \ + res = (res << 8) + readSn(_s, address + 1); \ + return res; \ + } +#endif +#define __SOCKET_REGISTER_N(name, address, size) \ + static uint16_t write##name(SOCKET _s, uint8_t *_buff) { \ + return writeSn(_s, address, _buff, size); \ + } \ + static uint16_t read##name(SOCKET _s, uint8_t *_buff) { \ + return readSn(_s, address, _buff, size); \ + } + +public: + __SOCKET_REGISTER8(SnMR, 0x0000) // Mode + __SOCKET_REGISTER8(SnCR, 0x0001) // Command + __SOCKET_REGISTER8(SnIR, 0x0002) // Interrupt + __SOCKET_REGISTER8(SnSR, 0x0003) // Status + __SOCKET_REGISTER16(SnPORT, 0x0004) // Source Port + __SOCKET_REGISTER_N(SnDHAR, 0x0006, 6) // Destination Hardw Addr + __SOCKET_REGISTER_N(SnDIPR, 0x000C, 4) // Destination IP Addr + __SOCKET_REGISTER16(SnDPORT, 0x0010) // Destination Port + __SOCKET_REGISTER16(SnMSSR, 0x0012) // Max Segment Size + __SOCKET_REGISTER8(SnPROTO, 0x0014) // Protocol in IP RAW Mode + __SOCKET_REGISTER8(SnTOS, 0x0015) // IP TOS + __SOCKET_REGISTER8(SnTTL, 0x0016) // IP TTL + __SOCKET_REGISTER8(SnRX_SIZE, 0x001E) // RX Memory Size + __SOCKET_REGISTER8(SnTX_SIZE, 0x001F) // TX Memory Size + __SOCKET_REGISTER16(SnTX_FSR, 0x0020) // TX Free Size + __SOCKET_REGISTER16(SnTX_RD, 0x0022) // TX Read Pointer + __SOCKET_REGISTER16(SnTX_WR, 0x0024) // TX Write Pointer + __SOCKET_REGISTER16(SnRX_RSR, 0x0026) // RX Free Size + __SOCKET_REGISTER16(SnRX_RD, 0x0028) // RX Read Pointer + __SOCKET_REGISTER16(SnRX_WR, 0x002A) // RX Write Pointer (supported?) + +#undef __SOCKET_REGISTER8 +#undef __SOCKET_REGISTER16 +#undef __SOCKET_REGISTER_N + + +private: + static const uint8_t RST = 7; // Reset BIT + static const int SOCKETS = 8; + +public: + static const uint16_t SSIZE = 2048; // Max Tx buffer size +private: + static const uint16_t RSIZE = 2048; // Max Rx buffer size + +private: + // could do inline optimizations + static inline void initSS() { pinMode(SPI_CS, OUTPUT); } + static inline void setSS() { digitalWrite(SPI_CS, LOW); } + static inline void resetSS() { digitalWrite(SPI_CS, HIGH); } +}; + +extern W5500Class w5500; + +uint8_t W5500Class::readSn(SOCKET _s, uint16_t _addr) { + uint8_t cntl_byte = (uint8_t)((_s<<5)+0x08); + return read(_addr, cntl_byte); +} + +uint8_t W5500Class::writeSn(SOCKET _s, uint16_t _addr, uint8_t _data) { + uint8_t cntl_byte = (uint8_t)((_s<<5)+0x0C); + return write(_addr, cntl_byte, _data); +} + +uint16_t W5500Class::readSn(SOCKET _s, uint16_t _addr, uint8_t *_buf, uint16_t _len) { + uint8_t cntl_byte = (uint8_t)((_s<<5)+0x08); + return read(_addr, cntl_byte, _buf, _len ); +} + +uint16_t W5500Class::writeSn(SOCKET _s, uint16_t _addr, uint8_t *_buf, uint16_t _len) { + uint8_t cntl_byte = (uint8_t)((_s<<5)+0x0C); + return write(_addr, cntl_byte, _buf, _len); +} + +void W5500Class::getGatewayIp(uint8_t *_addr) { + readGAR(_addr); +} + +void W5500Class::setGatewayIp(uint8_t *_addr) { + writeGAR(_addr); +} + +void W5500Class::getSubnetMask(uint8_t *_addr) { + readSUBR(_addr); +} + +void W5500Class::setSubnetMask(uint8_t *_addr) { + writeSUBR(_addr); +} + +void W5500Class::getMACAddress(uint8_t *_addr) { + readSHAR(_addr); +} + +void W5500Class::setMACAddress(uint8_t *_addr) { + writeSHAR(_addr); +} + +void W5500Class::getIPAddress(uint8_t *_addr) { + readSIPR(_addr); +} + +void W5500Class::setIPAddress(uint8_t *_addr) { + writeSIPR(_addr); +} + +void W5500Class::setRetransmissionTime(uint16_t _timeout) { + writeRTR(_timeout); +} + +uint16_t W5500Class::getRetransmissionTime() { + return readRTR(); +} + +void W5500Class::setRetransmissionCount(uint8_t _retry) { + writeRCR(_retry); +} + +uint8_t W5500Class::getRetransmissionCount() { + return readRCR(); +} + +void W5500Class::setPHYCFGR(uint8_t _val) { + writePHYCFGR(_val); +} + +uint8_t W5500Class::getPHYCFGR() { + return readPHYCFGR(); +} + +#endif diff --git a/libraries/LiquidCrystal/README.adoc b/libraries/LiquidCrystal/README.adoc new file mode 100644 index 0000000..7ec3219 --- /dev/null +++ b/libraries/LiquidCrystal/README.adoc @@ -0,0 +1,25 @@ += Liquid Crystal Library for Arduino = + +This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. + +For more information about this library please visit us at +http://www.arduino.cc/en/Reference/LiquidCrystal + +== License == + +Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved. +Copyright (c) 2010 Arduino LLC. All right reserved. + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/libraries/LiquidCrystal/examples/Autoscroll/Autoscroll.ino b/libraries/LiquidCrystal/examples/Autoscroll/Autoscroll.ino new file mode 100644 index 0000000..697c222 --- /dev/null +++ b/libraries/LiquidCrystal/examples/Autoscroll/Autoscroll.ino @@ -0,0 +1,78 @@ +/* + LiquidCrystal Library - Autoscroll + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch demonstrates the use of the autoscroll() + and noAutoscroll() functions to make new text scroll or not. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + modified 7 Nov 2016 + by Arturo Guadalupi + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/LiquidCrystalAutoscroll + +*/ + +// include the library code: +#include + +// initialize the library by associating any needed LCD interface pin +// with the arduino pin number it is connected to +const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; +LiquidCrystal lcd(rs, en, d4, d5, d6, d7); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); +} + +void loop() { + // set the cursor to (0,0): + lcd.setCursor(0, 0); + // print from 0 to 9: + for (int thisChar = 0; thisChar < 10; thisChar++) { + lcd.print(thisChar); + delay(500); + } + + // set the cursor to (16,1): + lcd.setCursor(16, 1); + // set the display to automatically scroll: + lcd.autoscroll(); + // print from 0 to 9: + for (int thisChar = 0; thisChar < 10; thisChar++) { + lcd.print(thisChar); + delay(500); + } + // turn off automatic scrolling + lcd.noAutoscroll(); + + // clear screen for the next loop: + lcd.clear(); +} + diff --git a/libraries/LiquidCrystal/examples/Blink/Blink.ino b/libraries/LiquidCrystal/examples/Blink/Blink.ino new file mode 100644 index 0000000..d7c1444 --- /dev/null +++ b/libraries/LiquidCrystal/examples/Blink/Blink.ino @@ -0,0 +1,65 @@ +/* + LiquidCrystal Library - Blink + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints "Hello World!" to the LCD and makes the + cursor block blink. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + modified 7 Nov 2016 + by Arturo Guadalupi + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/LiquidCrystalBlink + +*/ + +// include the library code: +#include + +// initialize the library by associating any needed LCD interface pin +// with the arduino pin number it is connected to +const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; +LiquidCrystal lcd(rs, en, d4, d5, d6, d7); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // Print a message to the LCD. + lcd.print("hello, world!"); +} + +void loop() { + // Turn off the blinking cursor: + lcd.noBlink(); + delay(3000); + // Turn on the blinking cursor: + lcd.blink(); + delay(3000); +} + + diff --git a/libraries/LiquidCrystal/examples/Cursor/Cursor.ino b/libraries/LiquidCrystal/examples/Cursor/Cursor.ino new file mode 100644 index 0000000..acbc8d9 --- /dev/null +++ b/libraries/LiquidCrystal/examples/Cursor/Cursor.ino @@ -0,0 +1,65 @@ +/* + LiquidCrystal Library - Cursor + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints "Hello World!" to the LCD and + uses the cursor() and noCursor() methods to turn + on and off the cursor. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + modified 7 Nov 2016 + by Arturo Guadalupi + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/LiquidCrystalCursor + +*/ + +// include the library code: +#include + +// initialize the library by associating any needed LCD interface pin +// with the arduino pin number it is connected to +const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; +LiquidCrystal lcd(rs, en, d4, d5, d6, d7); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // Print a message to the LCD. + lcd.print("hello, world!"); +} + +void loop() { + // Turn off the cursor: + lcd.noCursor(); + delay(500); + // Turn on the cursor: + lcd.cursor(); + delay(500); +} + diff --git a/libraries/LiquidCrystal/examples/CustomCharacter/CustomCharacter.ino b/libraries/LiquidCrystal/examples/CustomCharacter/CustomCharacter.ino new file mode 100644 index 0000000..c78abb9 --- /dev/null +++ b/libraries/LiquidCrystal/examples/CustomCharacter/CustomCharacter.ino @@ -0,0 +1,147 @@ +/* + LiquidCrystal Library - Custom Characters + + Demonstrates how to add custom characters on an LCD display. + The LiquidCrystal library works with all LCD displays that are + compatible with the Hitachi HD44780 driver. There are many of + them out there, and you can usually tell them by the 16-pin interface. + + This sketch prints "I Arduino!" and a little dancing man + to the LCD. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K potentiometer: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + * 10K poterntiometer on pin A0 + + created 21 Mar 2011 + by Tom Igoe + modified 11 Nov 2013 + by Scott Fitzgerald + modified 7 Nov 2016 + by Arturo Guadalupi + + Based on Adafruit's example at + https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde + + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/LiquidCrystalCustomCharacter + + Also useful: + http://icontexto.com/charactercreator/ + +*/ + +// include the library code: +#include + +// initialize the library by associating any needed LCD interface pin +// with the arduino pin number it is connected to +const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; +LiquidCrystal lcd(rs, en, d4, d5, d6, d7); + +// make some custom characters: +byte heart[8] = { + 0b00000, + 0b01010, + 0b11111, + 0b11111, + 0b11111, + 0b01110, + 0b00100, + 0b00000 +}; + +byte smiley[8] = { + 0b00000, + 0b00000, + 0b01010, + 0b00000, + 0b00000, + 0b10001, + 0b01110, + 0b00000 +}; + +byte frownie[8] = { + 0b00000, + 0b00000, + 0b01010, + 0b00000, + 0b00000, + 0b00000, + 0b01110, + 0b10001 +}; + +byte armsDown[8] = { + 0b00100, + 0b01010, + 0b00100, + 0b00100, + 0b01110, + 0b10101, + 0b00100, + 0b01010 +}; + +byte armsUp[8] = { + 0b00100, + 0b01010, + 0b00100, + 0b10101, + 0b01110, + 0b00100, + 0b00100, + 0b01010 +}; + +void setup() { + // initialize LCD and set up the number of columns and rows: + lcd.begin(16, 2); + + // create a new character + lcd.createChar(0, heart); + // create a new character + lcd.createChar(1, smiley); + // create a new character + lcd.createChar(2, frownie); + // create a new character + lcd.createChar(3, armsDown); + // create a new character + lcd.createChar(4, armsUp); + + // set the cursor to the top left + lcd.setCursor(0, 0); + + // Print a message to the lcd. + lcd.print("I "); + lcd.write(byte(0)); // when calling lcd.write() '0' must be cast as a byte + lcd.print(" Arduino! "); + lcd.write((byte)1); + +} + +void loop() { + // read the potentiometer on A0: + int sensorReading = analogRead(A0); + // map the result to 200 - 1000: + int delayTime = map(sensorReading, 0, 1023, 200, 1000); + // set the cursor to the bottom row, 5th position: + lcd.setCursor(4, 1); + // draw the little man, arms down: + lcd.write(3); + delay(delayTime); + lcd.setCursor(4, 1); + // draw him arms up: + lcd.write(4); + delay(delayTime); +} diff --git a/libraries/LiquidCrystal/examples/Display/Display.ino b/libraries/LiquidCrystal/examples/Display/Display.ino new file mode 100644 index 0000000..6ceee50 --- /dev/null +++ b/libraries/LiquidCrystal/examples/Display/Display.ino @@ -0,0 +1,65 @@ +/* + LiquidCrystal Library - display() and noDisplay() + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints "Hello World!" to the LCD and uses the + display() and noDisplay() functions to turn on and off + the display. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + modified 7 Nov 2016 + by Arturo Guadalupi + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/LiquidCrystalDisplay + +*/ + +// include the library code: +#include + +// initialize the library by associating any needed LCD interface pin +// with the arduino pin number it is connected to +const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; +LiquidCrystal lcd(rs, en, d4, d5, d6, d7); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // Print a message to the LCD. + lcd.print("hello, world!"); +} + +void loop() { + // Turn off the display: + lcd.noDisplay(); + delay(500); + // Turn on the display: + lcd.display(); + delay(500); +} + diff --git a/libraries/LiquidCrystal/examples/HelloWorld/HelloWorld.ino b/libraries/LiquidCrystal/examples/HelloWorld/HelloWorld.ino new file mode 100644 index 0000000..0543740 --- /dev/null +++ b/libraries/LiquidCrystal/examples/HelloWorld/HelloWorld.ino @@ -0,0 +1,65 @@ +/* + LiquidCrystal Library - Hello World + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints "Hello World!" to the LCD + and shows the time. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * LCD VSS pin to ground + * LCD VCC pin to 5V + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + modified 7 Nov 2016 + by Arturo Guadalupi + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/LiquidCrystalHelloWorld + +*/ + +// include the library code: +#include + +// initialize the library by associating any needed LCD interface pin +// with the arduino pin number it is connected to +const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; +LiquidCrystal lcd(rs, en, d4, d5, d6, d7); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // Print a message to the LCD. + lcd.print("hello, world!"); +} + +void loop() { + // set the cursor to column 0, line 1 + // (note: line 1 is the second row, since counting begins with 0): + lcd.setCursor(0, 1); + // print the number of seconds since reset: + lcd.print(millis() / 1000); +} + diff --git a/libraries/LiquidCrystal/examples/Scroll/Scroll.ino b/libraries/LiquidCrystal/examples/Scroll/Scroll.ino new file mode 100644 index 0000000..7533047 --- /dev/null +++ b/libraries/LiquidCrystal/examples/Scroll/Scroll.ino @@ -0,0 +1,90 @@ +/* + LiquidCrystal Library - scrollDisplayLeft() and scrollDisplayRight() + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints "Hello World!" to the LCD and uses the + scrollDisplayLeft() and scrollDisplayRight() methods to scroll + the text. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + modified 7 Nov 2016 + by Arturo Guadalupi + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/LiquidCrystalScroll + +*/ + +// include the library code: +#include + +// initialize the library by associating any needed LCD interface pin +// with the arduino pin number it is connected to +const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; +LiquidCrystal lcd(rs, en, d4, d5, d6, d7); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // Print a message to the LCD. + lcd.print("hello, world!"); + delay(1000); +} + +void loop() { + // scroll 13 positions (string length) to the left + // to move it offscreen left: + for (int positionCounter = 0; positionCounter < 13; positionCounter++) { + // scroll one position left: + lcd.scrollDisplayLeft(); + // wait a bit: + delay(150); + } + + // scroll 29 positions (string length + display length) to the right + // to move it offscreen right: + for (int positionCounter = 0; positionCounter < 29; positionCounter++) { + // scroll one position right: + lcd.scrollDisplayRight(); + // wait a bit: + delay(150); + } + + // scroll 16 positions (display length + string length) to the left + // to move it back to center: + for (int positionCounter = 0; positionCounter < 16; positionCounter++) { + // scroll one position left: + lcd.scrollDisplayLeft(); + // wait a bit: + delay(150); + } + + // delay at the end of the full loop: + delay(1000); + +} + diff --git a/libraries/LiquidCrystal/examples/SerialDisplay/SerialDisplay.ino b/libraries/LiquidCrystal/examples/SerialDisplay/SerialDisplay.ino new file mode 100644 index 0000000..4307fa6 --- /dev/null +++ b/libraries/LiquidCrystal/examples/SerialDisplay/SerialDisplay.ino @@ -0,0 +1,69 @@ +/* + LiquidCrystal Library - Serial Input + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch displays text sent over the serial port + (e.g. from the Serial Monitor) on an attached LCD. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + modified 7 Nov 2016 + by Arturo Guadalupi + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/LiquidCrystalSerialDisplay + +*/ + +// include the library code: +#include + +// initialize the library by associating any needed LCD interface pin +// with the arduino pin number it is connected to +const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; +LiquidCrystal lcd(rs, en, d4, d5, d6, d7); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // initialize the serial communications: + Serial.begin(9600); +} + +void loop() { + // when characters arrive over the serial port... + if (Serial.available()) { + // wait a bit for the entire message to arrive + delay(100); + // clear the screen + lcd.clear(); + // read all the available characters + while (Serial.available() > 0) { + // display each character to the LCD + lcd.write(Serial.read()); + } + } +} diff --git a/libraries/LiquidCrystal/examples/TextDirection/TextDirection.ino b/libraries/LiquidCrystal/examples/TextDirection/TextDirection.ino new file mode 100644 index 0000000..28c80ad --- /dev/null +++ b/libraries/LiquidCrystal/examples/TextDirection/TextDirection.ino @@ -0,0 +1,90 @@ +/* + LiquidCrystal Library - TextDirection + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch demonstrates how to use leftToRight() and rightToLeft() + to move the cursor. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + modified 7 Nov 2016 + by Arturo Guadalupi + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/LiquidCrystalTextDirection + +*/ + +// include the library code: +#include + +// initialize the library by associating any needed LCD interface pin +// with the arduino pin number it is connected to +const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; +LiquidCrystal lcd(rs, en, d4, d5, d6, d7); + +int thisChar = 'a'; + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // turn on the cursor: + lcd.cursor(); +} + +void loop() { + // reverse directions at 'm': + if (thisChar == 'm') { + // go right for the next letter + lcd.rightToLeft(); + } + // reverse again at 's': + if (thisChar == 's') { + // go left for the next letter + lcd.leftToRight(); + } + // reset at 'z': + if (thisChar > 'z') { + // go to (0,0): + lcd.home(); + // start again at 0 + thisChar = 'a'; + } + // print the character + lcd.write(thisChar); + // wait a second: + delay(1000); + // increment the letter: + thisChar++; +} + + + + + + + + diff --git a/libraries/LiquidCrystal/examples/setCursor/setCursor.ino b/libraries/LiquidCrystal/examples/setCursor/setCursor.ino new file mode 100644 index 0000000..869b5c8 --- /dev/null +++ b/libraries/LiquidCrystal/examples/setCursor/setCursor.ino @@ -0,0 +1,76 @@ +/* + LiquidCrystal Library - setCursor + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints to all the positions of the LCD using the + setCursor() method: + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + modified 7 Nov 2016 + by Arturo Guadalupi + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/LiquidCrystalSetCursor + +*/ + +// include the library code: +#include + +// initialize the library by associating any needed LCD interface pin +// with the arduino pin number it is connected to +const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; +LiquidCrystal lcd(rs, en, d4, d5, d6, d7); + +// these constants won't change. But you can change the size of +// your LCD using them: +const int numRows = 2; +const int numCols = 16; + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(numCols, numRows); +} + +void loop() { + // loop from ASCII 'a' to ASCII 'z': + for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) { + // loop over the columns: + for (int thisRow = 0; thisRow < numRows; thisRow++) { + // loop over the rows: + for (int thisCol = 0; thisCol < numCols; thisCol++) { + // set the cursor position: + lcd.setCursor(thisCol, thisRow); + // print the letter: + lcd.write(thisLetter); + delay(200); + } + } + } +} + + diff --git a/libraries/LiquidCrystal/keywords.txt b/libraries/LiquidCrystal/keywords.txt new file mode 100644 index 0000000..b6aa7fd --- /dev/null +++ b/libraries/LiquidCrystal/keywords.txt @@ -0,0 +1,38 @@ +####################################### +# Syntax Coloring Map For LiquidCrystal +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +LiquidCrystal KEYWORD1 LiquidCrystal + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +begin KEYWORD2 +clear KEYWORD2 +home KEYWORD2 +print KEYWORD2 +setCursor KEYWORD2 +cursor KEYWORD2 +noCursor KEYWORD2 +blink KEYWORD2 +noBlink KEYWORD2 +display KEYWORD2 +noDisplay KEYWORD2 +autoscroll KEYWORD2 +noAutoscroll KEYWORD2 +leftToRight KEYWORD2 +rightToLeft KEYWORD2 +scrollDisplayLeft KEYWORD2 +scrollDisplayRight KEYWORD2 +createChar KEYWORD2 +setRowOffsets KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### + diff --git a/libraries/LiquidCrystal/library.properties b/libraries/LiquidCrystal/library.properties new file mode 100644 index 0000000..097624d --- /dev/null +++ b/libraries/LiquidCrystal/library.properties @@ -0,0 +1,9 @@ +name=LiquidCrystal +version=1.0.7 +author=Arduino, Adafruit +maintainer=Renesas Electronics Corporation +sentence=Allows communication with alphanumerical liquid crystal displays (LCDs). +paragraph=This library allows an Arduino/Genuino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. The library works with in either 4 or 8 bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines). +category=Display +url=http://www.arduino.cc/en/Reference/LiquidCrystal +architectures=rl78g22_fpb diff --git a/libraries/LiquidCrystal/src/LiquidCrystal.cpp b/libraries/LiquidCrystal/src/LiquidCrystal.cpp new file mode 100644 index 0000000..39d278f --- /dev/null +++ b/libraries/LiquidCrystal/src/LiquidCrystal.cpp @@ -0,0 +1,326 @@ +#include "LiquidCrystal.h" + +#include +#include +#include +#include "Arduino.h" + +// When the display powers up, it is configured as follows: +// +// 1. Display clear +// 2. Function set: +// DL = 1; 8-bit interface data +// N = 0; 1-line display +// F = 0; 5x8 dot character font +// 3. Display on/off control: +// D = 0; Display off +// C = 0; Cursor off +// B = 0; Blinking off +// 4. Entry mode set: +// I/D = 1; Increment by 1 +// S = 0; No shift +// +// Note, however, that resetting the Arduino doesn't reset the LCD, so we +// can't assume that its in that state when a sketch starts (and the +// LiquidCrystal constructor is called). + +LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, + uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, + uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7) +{ + init(0, rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7); +} + +LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t enable, + uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, + uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7) +{ + init(0, rs, 255, enable, d0, d1, d2, d3, d4, d5, d6, d7); +} + +LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, + uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3) +{ + init(1, rs, rw, enable, d0, d1, d2, d3, 0, 0, 0, 0); +} + +LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t enable, + uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3) +{ + init(1, rs, 255, enable, d0, d1, d2, d3, 0, 0, 0, 0); +} + +void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable, + uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, + uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7) +{ + _rs_pin = rs; + _rw_pin = rw; + _enable_pin = enable; + + _data_pins[0] = d0; + _data_pins[1] = d1; + _data_pins[2] = d2; + _data_pins[3] = d3; + _data_pins[4] = d4; + _data_pins[5] = d5; + _data_pins[6] = d6; + _data_pins[7] = d7; + + if (fourbitmode) + _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; + else + _displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS; + +//RL78 begin(16, 1); +} + +void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { + if (lines > 1) { + _displayfunction |= LCD_2LINE; + } + _numlines = lines; + + setRowOffsets(0x00, 0x40, 0x00 + cols, 0x40 + cols); + + // for some 1 line displays you can select a 10 pixel high font + if ((dotsize != LCD_5x8DOTS) && (lines == 1)) { + _displayfunction |= LCD_5x10DOTS; + } + + pinMode(_rs_pin, OUTPUT); + // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin# + if (_rw_pin != 255) { + pinMode(_rw_pin, OUTPUT); + } + pinMode(_enable_pin, OUTPUT); + + // Do these once, instead of every time a character is drawn for speed reasons. + for (int i=0; i<((_displayfunction & LCD_8BITMODE) ? 8 : 4); ++i) + { + pinMode(_data_pins[i], OUTPUT); + } + + // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! + // according to datasheet, we need at least 40ms after power rises above 2.7V + // before sending commands. Arduino can turn on way before 4.5V so we'll wait 50 + delayMicroseconds(50000); + // Now we pull both RS and R/W low to begin commands + digitalWrite(_rs_pin, LOW); + digitalWrite(_enable_pin, LOW); + if (_rw_pin != 255) { + digitalWrite(_rw_pin, LOW); + } + + //put the LCD into 4 bit or 8 bit mode + if (! (_displayfunction & LCD_8BITMODE)) { + // this is according to the hitachi HD44780 datasheet + // figure 24, pg 46 + + // we start in 8bit mode, try to set 4 bit mode + write4bits(0x03); + delayMicroseconds(4500); // wait min 4.1ms + + // second try + write4bits(0x03); + delayMicroseconds(4500); // wait min 4.1ms + + // third go! + write4bits(0x03); + delayMicroseconds(150); + + // finally, set to 4-bit interface + write4bits(0x02); + } else { + // this is according to the hitachi HD44780 datasheet + // page 45 figure 23 + + // Send function set command sequence + command(LCD_FUNCTIONSET | _displayfunction); + delayMicroseconds(4500); // wait more than 4.1ms + + // second try + command(LCD_FUNCTIONSET | _displayfunction); + delayMicroseconds(150); + + // third go + command(LCD_FUNCTIONSET | _displayfunction); + } + + // finally, set # lines, font size, etc. + command(LCD_FUNCTIONSET | _displayfunction); + + // turn the display on with no cursor or blinking default + _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; + display(); + + // clear it off + clear(); + + // Initialize to default text direction (for romance languages) + _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT; + // set the entry mode + command(LCD_ENTRYMODESET | _displaymode); + +} + +void LiquidCrystal::setRowOffsets(int row0, int row1, int row2, int row3) +{ + _row_offsets[0] = row0; + _row_offsets[1] = row1; + _row_offsets[2] = row2; + _row_offsets[3] = row3; +} + +/********** high level commands, for the user! */ +void LiquidCrystal::clear() +{ + command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero + delayMicroseconds(2000); // this command takes a long time! +} + +void LiquidCrystal::home() +{ + command(LCD_RETURNHOME); // set cursor position to zero + delayMicroseconds(2000); // this command takes a long time! +} + +void LiquidCrystal::setCursor(uint8_t col, uint8_t row) +{ + const size_t max_lines = sizeof(_row_offsets) / sizeof(*_row_offsets); + if ( row >= max_lines ) { + row = max_lines - 1; // we count rows starting w/0 + } + if ( row >= _numlines ) { + row = _numlines - 1; // we count rows starting w/0 + } + + command(LCD_SETDDRAMADDR | (col + _row_offsets[row])); +} + +// Turn the display on/off (quickly) +void LiquidCrystal::noDisplay() { + _displaycontrol &= ~LCD_DISPLAYON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} +void LiquidCrystal::display() { + _displaycontrol |= LCD_DISPLAYON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} + +// Turns the underline cursor on/off +void LiquidCrystal::noCursor() { + _displaycontrol &= ~LCD_CURSORON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} +void LiquidCrystal::cursor() { + _displaycontrol |= LCD_CURSORON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} + +// Turn on and off the blinking cursor +void LiquidCrystal::noBlink() { + _displaycontrol &= ~LCD_BLINKON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} +void LiquidCrystal::blink() { + _displaycontrol |= LCD_BLINKON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} + +// These commands scroll the display without changing the RAM +void LiquidCrystal::scrollDisplayLeft(void) { + command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT); +} +void LiquidCrystal::scrollDisplayRight(void) { + command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT); +} + +// This is for text that flows Left to Right +void LiquidCrystal::leftToRight(void) { + _displaymode |= LCD_ENTRYLEFT; + command(LCD_ENTRYMODESET | _displaymode); +} + +// This is for text that flows Right to Left +void LiquidCrystal::rightToLeft(void) { + _displaymode &= ~LCD_ENTRYLEFT; + command(LCD_ENTRYMODESET | _displaymode); +} + +// This will 'right justify' text from the cursor +void LiquidCrystal::autoscroll(void) { + _displaymode |= LCD_ENTRYSHIFTINCREMENT; + command(LCD_ENTRYMODESET | _displaymode); +} + +// This will 'left justify' text from the cursor +void LiquidCrystal::noAutoscroll(void) { + _displaymode &= ~LCD_ENTRYSHIFTINCREMENT; + command(LCD_ENTRYMODESET | _displaymode); +} + +// Allows us to fill the first 8 CGRAM locations +// with custom characters +void LiquidCrystal::createChar(uint8_t location, uint8_t charmap[]) { + location &= 0x7; // we only have 8 locations 0-7 + command(LCD_SETCGRAMADDR | (location << 3)); + for (int i=0; i<8; i++) { + write(charmap[i]); + } +} + +/*********** mid level commands, for sending data/cmds */ + +inline void LiquidCrystal::command(uint8_t value) { + send(value, LOW); +} + +inline size_t LiquidCrystal::write(uint8_t value) { + send(value, HIGH); + return 1; // assume sucess +} + +/************ low level data pushing commands **********/ + +// write either command or data, with automatic 4/8-bit selection +void LiquidCrystal::send(uint8_t value, uint8_t mode) { + digitalWrite(_rs_pin, mode); + + // if there is a RW pin indicated, set it low to Write + if (_rw_pin != 255) { + digitalWrite(_rw_pin, LOW); + } + + if (_displayfunction & LCD_8BITMODE) { + write8bits(value); + } else { + write4bits(value>>4); + write4bits(value); + } +} + +void LiquidCrystal::pulseEnable(void) { + digitalWrite(_enable_pin, LOW); + delayMicroseconds(1); + digitalWrite(_enable_pin, HIGH); + delayMicroseconds(1); // enable pulse must be >450ns + digitalWrite(_enable_pin, LOW); + delayMicroseconds(100); // commands need > 37us to settle +} + +void LiquidCrystal::write4bits(uint8_t value) { + for (int i = 0; i < 4; i++) { + digitalWrite(_data_pins[i], (value >> i) & 0x01); + } + + pulseEnable(); +} + +void LiquidCrystal::write8bits(uint8_t value) { + for (int i = 0; i < 8; i++) { + digitalWrite(_data_pins[i], (value >> i) & 0x01); + } + + pulseEnable(); +} diff --git a/libraries/LiquidCrystal/src/LiquidCrystal.h b/libraries/LiquidCrystal/src/LiquidCrystal.h new file mode 100644 index 0000000..af34724 --- /dev/null +++ b/libraries/LiquidCrystal/src/LiquidCrystal.h @@ -0,0 +1,108 @@ +#ifndef LiquidCrystal_h +#define LiquidCrystal_h + +#include +#include "api/Print.h" + +// commands +#define LCD_CLEARDISPLAY 0x01 +#define LCD_RETURNHOME 0x02 +#define LCD_ENTRYMODESET 0x04 +#define LCD_DISPLAYCONTROL 0x08 +#define LCD_CURSORSHIFT 0x10 +#define LCD_FUNCTIONSET 0x20 +#define LCD_SETCGRAMADDR 0x40 +#define LCD_SETDDRAMADDR 0x80 + +// flags for display entry mode +#define LCD_ENTRYRIGHT 0x00 +#define LCD_ENTRYLEFT 0x02 +#define LCD_ENTRYSHIFTINCREMENT 0x01 +#define LCD_ENTRYSHIFTDECREMENT 0x00 + +// flags for display on/off control +#define LCD_DISPLAYON 0x04 +#define LCD_DISPLAYOFF 0x00 +#define LCD_CURSORON 0x02 +#define LCD_CURSOROFF 0x00 +#define LCD_BLINKON 0x01 +#define LCD_BLINKOFF 0x00 + +// flags for display/cursor shift +#define LCD_DISPLAYMOVE 0x08 +#define LCD_CURSORMOVE 0x00 +#define LCD_MOVERIGHT 0x04 +#define LCD_MOVELEFT 0x00 + +// flags for function set +#define LCD_8BITMODE 0x10 +#define LCD_4BITMODE 0x00 +#define LCD_2LINE 0x08 +#define LCD_1LINE 0x00 +#define LCD_5x10DOTS 0x04 +#define LCD_5x8DOTS 0x00 + +class LiquidCrystal : public Print { +public: + LiquidCrystal(uint8_t rs, uint8_t enable, + uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, + uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); + LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, + uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, + uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); + LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, + uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3); + LiquidCrystal(uint8_t rs, uint8_t enable, + uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3); + + void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable, + uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, + uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); + + void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); + + void clear(); + void home(); + + void noDisplay(); + void display(); + void noBlink(); + void blink(); + void noCursor(); + void cursor(); + void scrollDisplayLeft(); + void scrollDisplayRight(); + void leftToRight(); + void rightToLeft(); + void autoscroll(); + void noAutoscroll(); + + void setRowOffsets(int row1, int row2, int row3, int row4); + void createChar(uint8_t, uint8_t[]); + void setCursor(uint8_t, uint8_t); + virtual size_t write(uint8_t); + void command(uint8_t); + + using Print::write; +private: + void send(uint8_t, uint8_t); + void write4bits(uint8_t); + void write8bits(uint8_t); + void pulseEnable(); + + uint8_t _rs_pin; // LOW: command. HIGH: character. + uint8_t _rw_pin; // LOW: write to LCD. HIGH: read from LCD. + uint8_t _enable_pin; // activated by a HIGH pulse. + uint8_t _data_pins[8]; + + uint8_t _displayfunction; + uint8_t _displaycontrol; + uint8_t _displaymode; + + uint8_t _initialized; + + uint8_t _numlines; + uint8_t _row_offsets[4]; +}; + +#endif diff --git a/libraries/MsTimer2/MsTimer2.cpp b/libraries/MsTimer2/MsTimer2.cpp new file mode 100644 index 0000000..7e41040 --- /dev/null +++ b/libraries/MsTimer2/MsTimer2.cpp @@ -0,0 +1,60 @@ +#include "Arduino.h" +// #include +#include "MsTimer2.h" + +//extern "C" { +//#include "Config_ITL013.h" +//} + +static void (*millisIntervalFunc)() = NULL; +static unsigned long millisIntervalTime; +static unsigned long millisIntervalCount; + +static void (*intervalFunc)() = NULL; +extern void (*INT_TM_HOOK)(); + +extern "C" { +void MillisIntervalFunc(void) +{ + if (++millisIntervalCount >= millisIntervalTime) { + if (millisIntervalFunc) { + millisIntervalFunc(); + } + millisIntervalCount = 0; + } +} +} + +void MsTimer2::set(unsigned long ms, void (*f)()) +{ +#if 0 + attachMicroIntervalTimerHandler(NULL, 1000); +#endif + millisIntervalCount = 0; + millisIntervalTime = ms; + millisIntervalFunc = f; + intervalFunc = MillisIntervalFunc; +} +#if 0 +void MsTimer2::setMicros(unsigned short us, void (*f)()) +{ + attachMicroIntervalTimerHandler(NULL, us); + intervalFunc = f; +} +#endif + +void MsTimer2::setClock(unsigned short fclk, void (*f)()) +{ + attachClockIntervalTimerHandler(NULL, fclk); + intervalFunc = f; +} + +void MsTimer2::start() +{ + INT_TM_HOOK = intervalFunc; +} + +void MsTimer2::stop() +{ + INT_TM_HOOK = NULL; +} diff --git a/libraries/MsTimer2/MsTimer2.h b/libraries/MsTimer2/MsTimer2.h new file mode 100644 index 0000000..bf113f4 --- /dev/null +++ b/libraries/MsTimer2/MsTimer2.h @@ -0,0 +1,15 @@ +#ifndef _MSTIMER2_H_ +#define _MSTIMER2_H_ + +namespace MsTimer2 +{ + void set(unsigned long ms, void (*f)()); +#if 0 + void setMicros(unsigned short us, void (*f)()); +#endif + void setClock(unsigned short fclk, void (*f)()); + void start(); + void stop(); +} + +#endif/*_MSTIMER2_H_*/ diff --git a/libraries/MsTimer2/README.md b/libraries/MsTimer2/README.md new file mode 100644 index 0000000..c674ca4 --- /dev/null +++ b/libraries/MsTimer2/README.md @@ -0,0 +1,7 @@ +#MsTimer2 Library# + +Run a function every millisecond. + +http://www.pjrc.com/teensy/td_libs_MsTimer2.html + +Originally written by Javier Valencia diff --git a/libraries/MsTimer2/examples/FlashLed/FlashLed.ino b/libraries/MsTimer2/examples/FlashLed/FlashLed.ino new file mode 100644 index 0000000..162e5db --- /dev/null +++ b/libraries/MsTimer2/examples/FlashLed/FlashLed.ino @@ -0,0 +1,32 @@ +/* + MsTimer2 is a small and very easy to use library to interface Timer2 with + humans. It's called MsTimer2 because it "hardcodes" a resolution of 1 + millisecond on timer2 + For Details see: http://www.arduino.cc/playground/Main/MsTimer2 +*/ +#include + +// Switch on LED on and off each half second + +const int led_pin = BUILTIN_LED1; // 1.0 built in LED pin var + + +void flash() +{ + static boolean output = HIGH; + + digitalWrite(led_pin, output); + output = !output; +} + +void setup() +{ + pinMode(led_pin, OUTPUT); + + MsTimer2::set(500, flash); // 500ms period + MsTimer2::start(); +} + +void loop() +{ +} diff --git a/libraries/MsTimer2/keywords.txt b/libraries/MsTimer2/keywords.txt new file mode 100644 index 0000000..8b4fff7 --- /dev/null +++ b/libraries/MsTimer2/keywords.txt @@ -0,0 +1,4 @@ +MsTimer2 KEYWORD1 +set KEYWORD2 +start KEYWORD2 +stop KEYWORD2 diff --git a/libraries/MsTimer2/library.properties b/libraries/MsTimer2/library.properties new file mode 100644 index 0000000..727c9f5 --- /dev/null +++ b/libraries/MsTimer2/library.properties @@ -0,0 +1,9 @@ +name=MsTimer2 +version=1.1 +author=Javier Valencia +maintainer=Renesas Electronics Corporation +sentence=Run an interrupt function using Timer2 +paragraph= +category=Timing +url=https://github.com/renesas/Arduino +architectures=rl78g22_fpb diff --git a/libraries/SPI/SPI.cpp b/libraries/SPI/SPI.cpp new file mode 100644 index 0000000..371d358 --- /dev/null +++ b/libraries/SPI/SPI.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2010 by Cristian Maglie + * SPI Master library for arduino. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of either the GNU General Public License version 2 + * or the GNU Lesser General Public License version 2.1, both as + * published by the Free Software Foundation. + * + * Modified 28 February 2013 by masahiko.nagata.cj@renesas.com + */ + +#include "pins_arduino.h" +#include "r_cg_macrodriver.h" +#include "r_cg_sau.h" +#include "SPI.h" + +#if defined(CSI_CHANNEL0) && CSI_CHANNEL0 == 0 +SPIClass SPI(0); +#endif +#if defined(CSI_CHANNEL1) && CSI_CHANNEL1 == 1 +SPIClass SPI1(1); +#endif +#if defined(CSI_CHANNEL2) && CSI_CHANNEL2 == 2 +SPIClass SPI2(2); +#endif +#if defined(CSI_CHANNEL3) && CSI_CHANNEL3 == 3 +SPIClass SPI(3); +#endif +#if defined(CSI_CHANNEL4) && CSI_CHANNEL4 == 4 +SPIClass SPI(4); +#endif +#if defined(CSI_CHANNEL5) && CSI_CHANNEL5 == 5 +SPIClass SPI5(5); +#endif +#if defined(CSI_CHANNEL6) && CSI_CHANNEL6 == 6 +SPIClass SPI6(6); +#endif +#if defined(CSI_CHANNEL7) && CSI_CHANNEL7 == 7 +SPIClass SPI7(7); +#endif + +// Constructors //////////////////////////////////////////////////////////////// + +/********************************************************************************************************************** + * Function Name: SPIClass::SPIClass + * Description : Constructor + * Arguments : ch - SPI channel no. + * Return Value : - + *********************************************************************************************************************/ +SPIClass::SPIClass(uint8_t ch) : + csi (ch) +, channel(ch) +{ + initializeProps(); +}; + +// Public Methods ////////////////////////////////////////////////////////////// + +/********************************************************************************************************************** + * Function Name: SPIClass::begin + * Description : Initiate the SPI bus. + * Arguments : - + * Return Value : - + *********************************************************************************************************************/ +void SPIClass::begin(void) { + csi.Master_Create(); + csi.Master_Start(); +} + +/********************************************************************************************************************** + * Function Name: SPIClass::end + * Description : Disable the SPI bus. + * Arguments : - + * Return Value : - + *********************************************************************************************************************/ +void SPIClass::end() { + csi.Master_Stop(); +} + +// Private Methods ///////////////////////////////////////////////////////////// + +/********************************************************************************************************************** + * Function Name: SPIClass::initializeProps + * Description : Initialize instance properties. + * Arguments : - + * Return Value : - + *********************************************************************************************************************/ +void SPIClass::initializeProps(void) { + initialized = 0; + interruptMode = 0; + interruptMask = 0; + interruptSave = 0; +#ifdef SPI_TRANSACTION_MISMATCH_LED + inTransactionFlag = 0; +#endif +} diff --git a/libraries/SPI/SPI.h b/libraries/SPI/SPI.h new file mode 100644 index 0000000..c112b49 --- /dev/null +++ b/libraries/SPI/SPI.h @@ -0,0 +1,279 @@ +/* + * Copyright (c) 2010 by Cristian Maglie + * SPI Master library for arduino. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of either the GNU General Public License version 2 + * or the GNU Lesser General Public License version 2.1, both as + * published by the Free Software Foundation. + * + * Modified 28 February 2013 by masahiko.nagata.cj@renesas.com + */ + +#ifndef _SPI_H_INCLUDED +#define _SPI_H_INCLUDED + +#include +#include +#include +// #include + +#include "SPI_CSI.h" + +// SPI_HAS_TRANSACTION means SPI has beginTransaction(), endTransaction(), +// usingInterrupt(), and SPISetting(clock, bitOrder, dataMode) +#define SPI_HAS_TRANSACTION 1 + +// SPI_HAS_NOTUSINGINTERRUPT means that SPI has notUsingInterrupt() method +#define SPI_HAS_NOTUSINGINTERRUPT 1 + +// SPI_ATOMIC_VERSION means that SPI has atomicity fixes and what version. +// This way when there is a bug fix you can check this define to alert users +// of your code if it uses better version of this library. +// This also implies everything that SPI_HAS_TRANSACTION as documented above is +// available too. +#define SPI_ATOMIC_VERSION 1 + +// Uncomment this line to add detection of mismatched begin/end transactions. +// A mismatch occurs if other libraries fail to use SPI.endTransaction() for +// each SPI.beginTransaction(). Connect an LED to this pin. The LED will turn +// on if any mismatch is ever detected. +//#define SPI_TRANSACTION_MISMATCH_LED 5 + +class SPISettings { +public: + SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) : + clock (clock) + , bitOrder(bitOrder) + , dataMode(dataMode) + { } + + SPISettings() : SPISettings(4000000, MSBFIRST, SPI_MODE0) { } + +private: + uint32_t clock; + uint8_t bitOrder; + uint8_t dataMode; + + friend class SPIClass; +}; + + +class SPIClass { +public: + SPIClass(uint8_t ch = 3); + + void Set_SPIPort(uint8_t sck_pin,uint8_t si_pin,uint8_t so_pin); + + // Initialize the SPI library + void begin(); + + // If SPI is used from within an interrupt, this function registers + // that interrupt with the SPI library, so beginTransaction() can + // prevent conflicts. The input interruptNumber is the number used + // with attachInterrupt. If SPI is used from a different interrupt + // (eg, a timer), interruptNumber should be 255. + void usingInterrupt(uint8_t interruptNumber); + // And this does the opposite. + void notUsingInterrupt(uint8_t interruptNumber); + // Note: the usingInterrupt and notUsingInterrupt functions should + // not to be called from ISR context or inside a transaction. + // For details see: + // https://github.com/arduino/Arduino/pull/2381 + // https://github.com/arduino/Arduino/pull/2449 + + // Before using SPI.transfer() or asserting chip select pins, + // this function is used to gain exclusive access to the SPI bus + // and configure the correct settings. + void beginTransaction(SPISettings settings) { + if (interruptMode > 0) { + noInterrupts(); + } + + #ifdef SPI_TRANSACTION_MISMATCH_LED + if (inTransactionFlag) { + pinMode(SPI_TRANSACTION_MISMATCH_LED, OUTPUT); + digitalWrite(SPI_TRANSACTION_MISMATCH_LED, HIGH); + } + inTransactionFlag = 1; + #endif + + csi.Master_SetBitOrder(settings.bitOrder); + csi.Master_SetDataMode(settings.dataMode); + csi.Master_SetClock(settings.clock); + } + + // Write to the SPI bus (MOSI pin) and also receive (MISO pin) + uint8_t transfer(uint8_t data) { + memset(rx_buf, 0x00, sizeof(rx_buf)); + memset(tx_buf, 0x00, sizeof(tx_buf)); + tx_buf[0] = data; + + /* XXX: It returns error status, though, there's no way to tell the error. */ + MD_STATUS ret = csi.Master_Send_Receive(tx_buf, sizeof(data), rx_buf); + (void)ret; //Warning measures + + return rx_buf[0]; + } + + uint16_t transfer16(uint16_t data) { + memset(rx_buf, 0x00, sizeof(rx_buf)); + memset(tx_buf, 0x00, sizeof(tx_buf)); + + const uint8_t bitOrder = csi.Master_GetBitOrder(); + if (bitOrder == LSBFIRST) { + tx_buf[0] = (data >> 0) & 0xFF; + tx_buf[1] = (data >> 8) & 0xFF; + } else { + tx_buf[1] = (data >> 0) & 0xFF; + tx_buf[0] = (data >> 8) & 0xFF; + } + + /* XXX: It returns error status, though, there's no way to tell the error. */ + MD_STATUS ret = csi.Master_Send_Receive(tx_buf, sizeof(data), rx_buf); + (void)ret; //Warning measures + + return bitOrder == LSBFIRST + + ? (static_cast(rx_buf[0]) << 0) + | (static_cast(rx_buf[1]) << 8) + + : (static_cast(rx_buf[1]) << 0) + | (static_cast(rx_buf[0]) << 8); + } + + void transfer(void *buf, size_t count) { + MD_STATUS ret; + + while (count > 0) { + size_t sendSize = min(sizeof(tx_buf), count); + + memset(rx_buf, 0x00, sizeof(rx_buf)); + memset(tx_buf, 0x00, sizeof(tx_buf)); + + /* XXX: Instead of unfound `memcpy()`, copy the buffer by hand. */ + for (size_t i = 0; i < sendSize; i++) { + tx_buf[i] = reinterpret_cast(buf)[i]; + } + + /* XXX: It returns error status, though, there's no way to tell the error. */ + ret = csi.Master_Send_Receive(tx_buf, sendSize, rx_buf); + (void)ret; //Warning measures + + /* XXX: Instead of unfound `memcpy()`, copy the buffer by hand. */ + for (size_t i = 0; i < sendSize; i++) { + reinterpret_cast(buf)[i] = rx_buf[i]; + } + + count -= sendSize; + buf = reinterpret_cast(buf) + sendSize; + } + } + + // After performing a group of transfers and releasing the chip select + // signal, this function allows others to access the SPI bus + void endTransaction(void) { + #ifdef SPI_TRANSACTION_MISMATCH_LED + if (!inTransactionFlag) { + pinMode(SPI_TRANSACTION_MISMATCH_LED, OUTPUT); + digitalWrite(SPI_TRANSACTION_MISMATCH_LED, HIGH); + } + inTransactionFlag = 0; + #endif + + if (interruptMode > 0) { + noInterrupts(); + if (!interruptSave) { + interrupts(); + } + } + } + + // Disable the SPI bus + void end(); + + // This function is deprecated. New applications should use + // beginTransaction() to configure SPI settings. + inline void setBitOrder(uint8_t bitOrder) { + csi.Master_SetBitOrder(bitOrder); + } + + // This function is deprecated. New applications should use + // beginTransaction() to configure SPI settings. + inline void setDataMode(uint8_t dataMode) { + csi.Master_SetDataMode(dataMode); + } + + // This function is deprecated. New applications should use + // beginTransaction() to configure SPI settings. + // The frequency divider can only be set to the following values. + // SPI_CLOCK_DIV{ 2, 4, 8, 16, 32, 64, 128 } + inline void setClockDivider(uint16_t clockDiv) { + csi.Master_SetClockDivider(clockDiv); + } + + // These undocumented functions should not be used. SPI.transfer() + // polls the hardware flag which is automatically cleared as the + // AVR responds to SPI's interrupt + +#ifndef __RL78__ +inline static void attachInterrupt() {SPCR |= _BV(SPIE);} +inline static void detachInterrupt() {SPCR &= ~_BV(SPIE);} +#endif + +/* + * XXX: + * Dummy definition. + * Called from `main.cpp`, though, + * SPI channel setting is already done in the constructor. + */ +inline void set_channel(uint8_t ch) { (void)ch; } + +private: +uint8_t channel; + +CSI_Impl csi; + +static const size_t BUFSIZE = 32; + +uint8_t tx_buf[BUFSIZE]; +uint8_t rx_buf[BUFSIZE]; + +uint8_t initialized; +uint8_t interruptMode; // 0=none, 1=mask, 2=global +uint8_t interruptMask;// which interrupts to mask +uint8_t interruptSave;// temp storage, to restore state + +#ifdef SPI_TRANSACTION_MISMATCH_LED +uint8_t inTransactionFlag; +#endif + +void initializeProps(void); +}; + +#if defined(CSI_CHANNEL0) && CSI_CHANNEL0 == 0 +extern SPIClass SPI; +#endif +#if defined(CSI_CHANNEL1) && CSI_CHANNEL1 == 1 +extern SPIClass SPI1; +#endif +#if defined(CSI_CHANNEL2) && CSI_CHANNEL2 == 2 +extern SPIClass SPI2; +#endif +#if defined(CSI_CHANNEL3) && CSI_CHANNEL3 == 3 +extern SPIClass SPI; +#endif +#if defined(CSI_CHANNEL4) && CSI_CHANNEL4 == 4 +extern SPIClass SPI; +#endif +#if defined(CSI_CHANNEL5) && CSI_CHANNEL5 == 5 +extern SPIClass SPI5; +#endif +#if defined(CSI_CHANNEL6) && CSI_CHANNEL6 == 6 +extern SPIClass SPI6; +#endif +#if defined(CSI_CHANNEL7) && CSI_CHANNEL7 == 7 +extern SPIClass SPI7; +#endif + +#endif diff --git a/libraries/SPI/SPI_CSI.cpp b/libraries/SPI/SPI_CSI.cpp new file mode 100644 index 0000000..906c0ca --- /dev/null +++ b/libraries/SPI/SPI_CSI.cpp @@ -0,0 +1,341 @@ +#include "SPI_CSI.h" + +#include "r_cg_macrodriver.h" +#include "pins_variant.h" + +extern "C" { + +#if defined(CSI_CHANNEL3) && CSI_CHANNEL3 == 3 + #include "Config_CSI11.h" + extern volatile uint16_t g_csi11_tx_count; + extern volatile uint16_t g_csi11_status_flag; +#endif + +#if defined(CSI_CHANNEL4) && CSI_CHANNEL4 == 4 + #include "Config_CSI20.h" + extern volatile uint16_t g_csi20_tx_count; + extern volatile uint16_t g_csi20_status_flag; +#endif + +} + +#define DELAY_MS(x) delay(x) + +// Constructors //////////////////////////////////////////////////////////////// + +/********************************************************************************************************************** + * Function Name: CSI_Impl::CSI_Impl + * Description : Constructor + * Arguments : ch - SPI channel no. + * Return Value : - + *********************************************************************************************************************/ +CSI_Impl::CSI_Impl(uint8_t ch) { + switch (ch) { + +#if defined(CSI_CHANNEL3) && CSI_CHANNEL3 == 3 + case 3: + Master_Create_ = R_Config_CSI11_Create; + Master_Start_ = R_Config_CSI11_Start; + Master_Stop_ = R_Config_CSI11_Stop; + Master_Create_UserInit_ = R_Config_CSI11_Create_UserInit; + Master_ClearStatus_ = R_Config_CSI11_ClearStatus; + Master_Send_Receive_ = R_Config_CSI11_Send_Receive; + Master_SetBitOrder_ = R_Config_CSI11_SetBitOrder; + Master_SetDataMode_ = R_Config_CSI11_SetDataMode; + Master_SetClockDivider_ = R_Config_CSI11_SetClockDivider; + Master_SetClock_ = R_Config_CSI11_SetClock; + Master_GetBitOrder_ = R_Config_CSI11_GetBitOrder; + master_tx_count = &g_csi11_tx_count; + master_status_flag = &g_csi11_status_flag; + break; +#endif /* defined(CSI_CHANNEL3) && CSI_CHANNEL3 == 3 */ + +#if defined(CSI_CHANNEL4) && CSI_CHANNEL4 == 4 + case 4: + Master_Create_ = R_Config_CSI20_Create; + Master_Start_ = R_Config_CSI20_Start; + Master_Stop_ = R_Config_CSI20_Stop; + Master_Create_UserInit_ = R_Config_CSI20_Create_UserInit; + Master_ClearStatus_ = R_Config_CSI20_ClearStatus; + Master_Send_Receive_ = R_Config_CSI20_Send_Receive; + Master_SetBitOrder_ = R_Config_CSI20_SetBitOrder; + Master_SetDataMode_ = R_Config_CSI20_SetDataMode; + Master_SetClockDivider_ = R_Config_CSI20_SetClockDivider; + Master_SetClock_ = R_Config_CSI20_SetClock; + Master_GetBitOrder_ = R_Config_CSI20_GetBitOrder; + master_tx_count = &g_csi20_tx_count; + master_status_flag = &g_csi20_status_flag; + break; +#endif /* defined(CSI_CHANNEL4) && CSI_CHANNEL4 == 4 */ + default: + Master_Create_ = + Master_Start_ = + Master_Stop_ = + Master_Create_UserInit_ = + Master_ClearStatus_ = nullptr; + Master_Send_Receive_ = nullptr; + Master_SetBitOrder_ = + Master_SetDataMode_ = nullptr; + Master_SetClockDivider_ = nullptr; + Master_SetClock_ = nullptr; + Master_GetBitOrder_ = nullptr; + master_tx_count = + master_status_flag = nullptr; + break; + + } +} + +// Private Methods ///////////////////////////////////////////////////////////// + +/********************************************************************************************************************** + * Function Name: CSI_Impl::Master_ClearStatus + * Description : Clear the CSI module's status. + * Arguments : - + * Return Value : - + *********************************************************************************************************************/ +void CSI_Impl::Master_ClearStatus(void) const { + if (Master_ClearStatus_ != nullptr) { + Master_ClearStatus_(); + } +} + +/********************************************************************************************************************** + * Function Name: CSI_Impl::Master_StatusFlagWait + * Description : Wait for CSI interruption to know the operation exit status or error. + * Arguments : - + * Return Value : status of the operation + * : Upper 8 bits (0xFF00U) is assigned to CSI status bits (e.g. operation completion) + * : Lower 8 bits (0x00FFU) is assigned to CSI errors + *********************************************************************************************************************/ +uint16_t CSI_Impl::Master_StatusFlagWait(void) const { + uint16_t ret = 0x0000U; + + uint16_t wait = 0; + while (true) { + uint16_t stat = *master_status_flag; + if((stat & 0x7F) == 0x10) + { + return 0; + } + else if ((stat & _00FF_SPI_STATUS_ERROR_MASK) != 0x0000U) { + ret = stat; + break; + } + else if ( + (stat & _8000_SPI_STATUS_SENDEND ) != 0x0000U + && (stat & _4000_SPI_STATUS_RECEIVEEND) != 0x0000U + ) + { + ret = stat; + break; + } + + if (wait > STATUS_WAIT_TIMEOUT) { + ret = (stat & ~_00FF_SPI_STATUS_ERROR_MASK) + | (_0080_SPI_STATUS_ERROR_TIMEOUT & _00FF_SPI_STATUS_ERROR_MASK); + break; + } + + wait += STATUS_WAIT_INTERVAL; + } + + return ret; +} + +/* +uint16_t CSI_Impl::Master_StatusFlagWait(void) const { + uint16_t ret = 0x0000U; + + uint16_t wait = 0; + while (true) { + auto stat = getMasterStatusFlag(); + if ((stat & _00FF_SPI_STATUS_ERROR_MASK) != 0x0000U) { + ret = stat; + break; + } + + if ( + (stat & _8000_SPI_STATUS_SENDEND ) != 0x0000U + && (stat & _4000_SPI_STATUS_RECEIVEEND) != 0x0000U + ) { + ret = stat; + break; + } + + if (wait > STATUS_WAIT_TIMEOUT) { + ret = (stat & ~_00FF_SPI_STATUS_ERROR_MASK) + | (_0080_SPI_STATUS_ERROR_TIMEOUT & _00FF_SPI_STATUS_ERROR_MASK); + break; + } + + wait += STATUS_WAIT_INTERVAL; + } + + return ret; +} + */ + + + +// Public Methods ////////////////////////////////////////////////////////////// + +/********************************************************************************************************************** + * Function Name: CSI_Impl::Master_Create + * Description : Initialize the CSI module. + * Arguments : - + * Return Value : - + *********************************************************************************************************************/ +void CSI_Impl::Master_Create (void) const { + if (Master_Create_ != nullptr) { + Master_Create_(); + } +} + +/********************************************************************************************************************** + * Function Name: CSI_Impl::Master_Start + * Description : Start the CSI module operation. + * Arguments : - + * Return Value : - + *********************************************************************************************************************/ +void CSI_Impl::Master_Start (void) const { + if (Master_Start_ != nullptr) { + Master_Start_(); + } +} + +/********************************************************************************************************************** + * Function Name: CSI_Impl::Master_Stop + * Description : Stop the CSI module operation. + * Arguments : - + * Return Value : - + *********************************************************************************************************************/ +void CSI_Impl::Master_Stop (void) const { + if (Master_Stop_ != nullptr) { + Master_Stop_(); + } +} + +/********************************************************************************************************************** + * Function Name: CSI_Impl::Master_Send_Receive + * Description : send and receive CSI data. + * Arguments : tx_buf - transfer buffer pointer + * tx_num - buffer size + * rx_buf - receive buffer pointer + * Return Value : error status + * : MD_OK + * : MD_ARGERROR + * : MD_ERROR + *********************************************************************************************************************/ +MD_STATUS CSI_Impl::Master_Send_Receive (uint8_t * const tx_buf, uint16_t tx_num, uint8_t * const rx_buf) const { + MD_STATUS ret; + uint16_t status = 0x0000U; + + if (Master_Send_Receive_ == nullptr) { + ret = MD_ERROR; + } else { + Master_ClearStatus(); + ret = Master_Send_Receive_(tx_buf, tx_num, rx_buf); + if (ret == MD_OK) { + status = Master_StatusFlagWait(); + if ((status & _00FF_SPI_STATUS_ERROR_MASK) != 0x0000u) { + ret = (status & _0080_SPI_STATUS_ERROR_TIMEOUT) != 0x0000u ? MD_BUSY2 + : (status & _0001_SPI_STATUS_ERROR_OVERRUN) != 0x0000u ? MD_OVERRUN + : MD_ERROR; + } + } + } + + return ret; +} + +/********************************************************************************************************************** + * Function Name: CSI_Impl::Master_Create_UserInit + * Description : Call the user code for the CSI initialization. + * Arguments : - + * Return Value : - + *********************************************************************************************************************/ +void CSI_Impl::Master_Create_UserInit(void) const { + if (Master_Create_UserInit_ != nullptr) { + Master_Create_UserInit_(); + } +} + +/********************************************************************************************************************** + * Function Name: CSI_Impl::Master_GetBitOrder + * Description : Get the order of the bits shifted out of and into the SPI bus. + * Arguments : - + * Return Value : Current bit order setting + * : LSBFIRST + * : MSBFIRST + *********************************************************************************************************************/ +uint8_t CSI_Impl::Master_GetBitOrder (void) const { + if (Master_GetBitOrder_ != nullptr) { + return Master_GetBitOrder_(); + } else { + /* XXX: If SMC function is not set, return device endian by default. */ + const uint16_t TESTVAL = 0x1234U; + return reinterpret_cast(&TESTVAL)[0] == 0x12U ? MSBFIRST : LSBFIRST; + } +} + +/********************************************************************************************************************** + * Function Name: CSI_Impl::Master_SetBitOrder + * Description : Set the order of the bits shifted out of and into the SPI bus. + * Arguments : bitOrder - Bit order setting + * : LSBFIRST + * : MSBFIRST + * Return Value : - + *********************************************************************************************************************/ +void CSI_Impl::Master_SetBitOrder (uint8_t bitOrder) const { + if (Master_SetBitOrder_ != nullptr) { + Master_SetBitOrder_(bitOrder); + } +} + +/********************************************************************************************************************** + * Function Name: CSI_Impl::Master_SetDataMode + * Description : Set the SPI data mode (clock polarity and phase). + * Arguments : dataMode - SPI data mode + * : SPI_MODE0 + * : SPI_MODE1 + * : SPI_MODE2 + * : SPI_MODE3 + * Return Value : - + *********************************************************************************************************************/ +void CSI_Impl::Master_SetDataMode (uint8_t dataMode) const { + if (Master_SetDataMode_ != nullptr) { + Master_SetDataMode_(dataMode); + } +} + +/********************************************************************************************************************** + * Function Name: CSI_Impl::Master_SetClockDivider + * Description : Set the SPI clock divider relative to the system clock. + * Arguments : clockDiv - SPI clock divider + * : SPI_CLOCK_DIV2 + * : SPI_CLOCK_DIV4 + * : SPI_CLOCK_DIV8 + * : SPI_CLOCK_DIV16 + * : SPI_CLOCK_DIV32 + * : SPI_CLOCK_DIV64 + * : SPI_CLOCK_DIV128 + * Return Value : - + *********************************************************************************************************************/ +void CSI_Impl::Master_SetClockDivider(uint16_t clockDiv) const { + if (Master_SetClockDivider_ != nullptr) { + Master_SetClockDivider_(clockDiv); + } +} + +/********************************************************************************************************************** + * Function Name: CSI_Impl::Master_SetClock + * Description : Set the SPI maximum speed of communication. + * Arguments : clock - SPI clock speed + * Return Value : - + *********************************************************************************************************************/ +void CSI_Impl::Master_SetClock (uint32_t clock) const { + if (Master_SetClock_ != nullptr) { + Master_SetClock_(clock); + } +} diff --git a/libraries/SPI/SPI_CSI.h b/libraries/SPI/SPI_CSI.h new file mode 100644 index 0000000..9684d26 --- /dev/null +++ b/libraries/SPI/SPI_CSI.h @@ -0,0 +1,53 @@ +#ifndef SPI_CSI_h +#define SPI_CSI_h + +#include "Arduino.h" + +extern "C" { +#include "r_cg_macrodriver.h" +#include "r_cg_sau.h" +} + +class CSI_Impl { +public: + CSI_Impl(uint8_t ch); + + void Master_Create (void) const; + void Master_Start (void) const; + void Master_Stop (void) const; + MD_STATUS Master_Send_Receive (uint8_t * const tx_buf, uint16_t tx_num, uint8_t * const rx_buf) const; + void Master_Create_UserInit(void) const; + uint8_t Master_GetBitOrder (void) const; + void Master_SetBitOrder (uint8_t bitOrder) const; + void Master_SetDataMode (uint8_t dataMode) const; + void Master_SetClockDivider(uint16_t clockDiv) const; + void Master_SetClock (uint32_t clock) const; + + inline uint16_t getMasterTxCount (void) const { return master_tx_count == nullptr ? 0U : *master_tx_count ; } + inline uint16_t getMasterStatusFlag(void) const { return master_status_flag == nullptr ? 0x0000U : *master_status_flag; }; + +private: + void (*Master_Create_ )(void); + void (*Master_Start_ )(void); + void (*Master_Stop_ )(void); + MD_STATUS (*Master_Send_Receive_ )(uint8_t * const tx_buf, uint16_t tx_num, uint8_t * const rx_buf); + void (*Master_Create_UserInit_)(void); + void (*Master_ClearStatus_ )(void); + uint8_t (*Master_GetBitOrder_ )(void); + void (*Master_SetBitOrder_ )(uint8_t bitOrder); + void (*Master_SetDataMode_ )(uint8_t dataMode); + void (*Master_SetClockDivider_)(uint16_t clockDiv); + void (*Master_SetClock_ )(uint32_t clock); + + const volatile uint16_t *master_tx_count; + const volatile uint16_t *master_status_flag; + + const unsigned int STATUS_WAIT_TIMEOUT = 1000; + // const unsigned long STATUS_WAIT_INTERVAL = 10; + const unsigned int STATUS_WAIT_INTERVAL = 1; + + void Master_ClearStatus (void) const; + uint16_t Master_StatusFlagWait (void) const; +}; + +#endif diff --git a/libraries/SPI/library.properties b/libraries/SPI/library.properties new file mode 100644 index 0000000..b083abc --- /dev/null +++ b/libraries/SPI/library.properties @@ -0,0 +1,9 @@ +name=SPI +version=1.0 +author=Renesas Electronics Corporation +maintainer=Renesas Electronics Corporation +sentence=Enables the communication with devices that use the Serial Peripheral Interface (SPI) Bus. +paragraph=SPI is a synchronous serial data protocol used by microcontrollers for communicating with one or more peripheral devices quickly over short distances. It uses three lines common to all devices (MISO, MOSI and SCK) and one specific for each device. +category=Communication +url=https://github.com/renesas/Arduino +architectures=rl78g22_fpb diff --git a/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino b/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino new file mode 100644 index 0000000..3256077 --- /dev/null +++ b/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino @@ -0,0 +1,54 @@ +/* + Software serial multple serial test + + Receives from the hardware serial, sends to software serial. + Receives from software serial, sends to hardware serial. + + The circuit: + * RX is digital pin 10 (connect to TX of other device) + * TX is digital pin 11 (connect to RX of other device) + + Note: + Not all pins on the Mega and Mega 2560 support change interrupts, + so only the following can be used for RX: + 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69 + + Not all pins on the Leonardo and Micro support change interrupts, + so only the following can be used for RX: + 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI). + + created back in the mists of time + modified 25 May 2012 + by Tom Igoe + based on Mikal Hart's example + + This example code is in the public domain. + + */ +#include + +SoftwareSerial mySerial(11, 10); // RX, TX + +void setup() { + // Open serial communications and wait for port to open: + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + + + Serial.println("Goodnight moon!"); + + // set the data rate for the SoftwareSerial port + mySerial.begin(9600); + mySerial.println("Hello, world?"); +} + +void loop() { // run over and over + if (mySerial.available()) { + Serial.write(mySerial.read()); + } + if (Serial.available()) { + mySerial.write(Serial.read()); + } +} diff --git a/libraries/SoftwareSerial/keywords.txt b/libraries/SoftwareSerial/keywords.txt new file mode 100644 index 0000000..aaea17c --- /dev/null +++ b/libraries/SoftwareSerial/keywords.txt @@ -0,0 +1,30 @@ +####################################### +# Syntax Coloring Map for SoftwareSerial +# (formerly NewSoftSerial) +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +SoftwareSerial KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +begin KEYWORD2 +end KEYWORD2 +read KEYWORD2 +write KEYWORD2 +available KEYWORD2 +isListening KEYWORD2 +overflow KEYWORD2 +flush KEYWORD2 +listen KEYWORD2 +peek KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### + diff --git a/libraries/SoftwareSerial/library.properties b/libraries/SoftwareSerial/library.properties new file mode 100644 index 0000000..05c3735 --- /dev/null +++ b/libraries/SoftwareSerial/library.properties @@ -0,0 +1,9 @@ +name=SoftwareSerial +version=1.0 +author=Arduino +maintainer=Renesas Electronics Corporation +sentence=Enables serial communication on any digital pin. +paragraph=The SoftwareSerial library has been developed to allow serial communication on any digital pin of the board, using software to replicate the functionality of the hardware UART. It is possible to have multiple software serial ports with speeds up to 115200 bps. +category=Communication +url=http://www.arduino.cc/en/Reference/SoftwareSerial +architectures=rl78g22_fpb \ No newline at end of file diff --git a/libraries/SoftwareSerial/src/SoftwareSerial.cpp b/libraries/SoftwareSerial/src/SoftwareSerial.cpp new file mode 100644 index 0000000..4c456b5 --- /dev/null +++ b/libraries/SoftwareSerial/src/SoftwareSerial.cpp @@ -0,0 +1,572 @@ +/* +SoftwareSerial.cpp (formerly NewSoftSerial.cpp) - +Multi-instance software serial library for Arduino/Wiring +-- Interrupt-driven receive and other improvements by ladyada + (http://ladyada.net) +-- Tuning, circular buffer, derivation from class Print/Stream, + multi-instance support, porting to 8MHz processors, + various optimizations, PROGMEM delay tables, inverse logic and + direct port writing by Mikal Hart (http://www.arduiniana.org) +-- Pin change interrupt macros by Paul Stoffregen (http://www.pjrc.com) +-- 20MHz processor support by Garrett Mace (http://www.macetech.com) +-- ATmega1280/2560 support by Brett Hagman (http://www.roguerobotics.com/) + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +The latest version of this library can always be found at +http://arduiniana.org. +*/ +/* Aug 25th 2017: Modified by Yuuki Okamiya for RL78 */ + +// When set, _DEBUG co-opts pins 11 and 13 for debugging with an +// oscilloscope or logic analyzer. Beware: it also slightly modifies +// the bit times, so don't rely on it too much at high baud rates +#define _DEBUG 0 +#define _DEBUG_PIN1 11 +#define _DEBUG_PIN2 13 +// +// Includes +// + +#include +#include "SoftwareSerial.h" + +extern "C" { + #include "pintable.h" + extern const PinTableType * pinTablelist[NUM_DIGITAL_PINS]; +} + +volatile int tempAXvalue=0; +#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) ) +const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = { + DIGITAL_PIN_MASK_0, + DIGITAL_PIN_MASK_1, + DIGITAL_PIN_MASK_2, + DIGITAL_PIN_MASK_3, + DIGITAL_PIN_MASK_4, + DIGITAL_PIN_MASK_5, + DIGITAL_PIN_MASK_6, + DIGITAL_PIN_MASK_7, + DIGITAL_PIN_MASK_8, + DIGITAL_PIN_MASK_9, + DIGITAL_PIN_MASK_10, + DIGITAL_PIN_MASK_11, + DIGITAL_PIN_MASK_12, + DIGITAL_PIN_MASK_13, + DIGITAL_PIN_MASK_14, + DIGITAL_PIN_MASK_15, + DIGITAL_PIN_MASK_16, + DIGITAL_PIN_MASK_17, + DIGITAL_PIN_MASK_18, + DIGITAL_PIN_MASK_19, + DIGITAL_PIN_MASK_20, + DIGITAL_PIN_MASK_21, + DIGITAL_PIN_MASK_22, + DIGITAL_PIN_MASK_23, + DIGITAL_PIN_MASK_24, + DIGITAL_PIN_MASK_25, + DIGITAL_PIN_MASK_26, + DIGITAL_PIN_MASK_27, + DIGITAL_PIN_MASK_28, + DIGITAL_PIN_MASK_29, + DIGITAL_PIN_MASK_30 +}; +// +// Statics +// +SoftwareSerial *SoftwareSerial::active_object = 0; +uint8_t SoftwareSerial::_receive_buffer[_SS_MAX_RX_BUFF]; +volatile uint8_t SoftwareSerial::_receive_buffer_tail = 0; +volatile uint8_t SoftwareSerial::_receive_buffer_head = 0; + +// +// Debugging +// +// This function generates a brief pulse +// for debugging or measuring on an oscilloscope. + +inline void DebugPulse(uint8_t, uint8_t) {} + +// +// Private methods +// + +/* static */ +inline void SoftwareSerial::tunedDelay(uint16_t delay_cnt){ + tempAXvalue = delay_cnt; + asm("movw bc, ax"); + asm("movw de, #0"); + asm("movw ax, bc"); + asm("cmpw ax, #0"); + asm("bz $1f"); + asm("2:"); + asm("incw de"); + asm("movw ax, de"); + asm("cmpw ax, bc"); + asm("bnz $2b"); + asm("1:"); + return; +} + + +// This function sets the current object as the "listening" +// one and returns true if it replaces another +bool SoftwareSerial::listen() +{ + if (!_rx_delay_stopbit) + return false; + + if (active_object != this) + { + if (active_object) + active_object->stopListening(); + + _buffer_overflow = false; + _receive_buffer_head = _receive_buffer_tail = 0; + active_object = this; + setRxIntMsk(true); + return true; + } + + return false; +} + +// Stop listening. Returns true if we were actually listening. +bool SoftwareSerial::stopListening() +{ + if (active_object == this) + { + setRxIntMsk(false); + active_object = NULL; + return true; + } + return false; +} + +uint8_t tempLEDBlink = 0; + +void DebugPulse2(void){ + if(tempLEDBlink == 0) + { + digitalWrite(BUILTIN_LED2, HIGH); + tempLEDBlink = 1; + } + else + { + digitalWrite(BUILTIN_LED2, LOW); + tempLEDBlink = 0; + } +} + +// +// The receive routine called by the interrupt handler +// +void SoftwareSerial::recv() +{ + uint8_t d = 0; + // If RX line is high, then we don't see any start bit + // so interrupt is probably not for us + if (_inverse_logic ? rx_pin_read() : !rx_pin_read()) + { + // Disable further interrupts during reception, this prevents + // triggering another interrupt directly after we return, which can + // cause problems at higher baudrates. + setRxIntMsk(false); + + // Wait approximately 1/2 of a bit width to "center" the sample + if(_rx_delay_centering>0) tunedDelay(_rx_delay_centering); + + if(_rx_delay_firstbit>0) tunedDelay(_rx_delay_firstbit); + // Read each of the 8 bits + for (uint8_t i=8; i > 0; --i) + { + if(i<8) tunedDelay(_rx_delay_intrabit); + d >>= 1; +// DebugPulse2(); + if (rx_pin_read()) + d |= 0x80; + } + + if (_inverse_logic) + d = ~d; + + // if buffer full, set the overflow flag and return + uint8_t next = (_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF; + if (next != _receive_buffer_head) + { + // save new data in buffer: tail points to where byte goes + _receive_buffer[_receive_buffer_tail] = d; // save new byte + _receive_buffer_tail = next; + } + else + { + _buffer_overflow = true; + } + + // skip the stop bit + tunedDelay(_rx_delay_stopbit); + + // Re-enable interrupts when we're sure to be inside the stop bit + setRxIntMsk(true); + } +} + + +uint8_t SoftwareSerial::rx_pin_read() +{ + return *_receivePortRegister & _receiveBitMask; +} + +// +// Interrupt handling +// + +/* static */ +inline void SoftwareSerial::handle_interrupt() +{ + if (active_object) + { + active_object->recv(); + } +} + +static void softwareserial_interrupt(){ + SoftwareSerial::handle_interrupt(); +} + +// +// Constructor +// +SoftwareSerial::SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic /* = false */) : + _rx_delay_centering(0), + _rx_delay_firstbit(0), + _rx_delay_intrabit(0), + _rx_delay_stopbit(0), + _tx_delay(0), + _buffer_overflow(false), + _inverse_logic(inverse_logic) +{ + _transmitPin = transmitPin; + _receivePin = receivePin; + _transmitBitMask = digitalPinToBitMask(transmitPin); + _receiveBitMask = digitalPinToBitMask(receivePin); + PinTableType* p; + PinTableType pin_tbl; + p =(PinTableType*)&pin_tbl; + const PinTableType ** pp; + pp = &pinTablelist[transmitPin]; + p = (PinTableType *)*pp; + _transmitPortRegister = p->portRegisterAddr; + pp = &pinTablelist[receivePin]; + p = (PinTableType *)*pp; + _receiveBitMask = p->mask; + _receivePortRegister = p->portRegisterAddr; + _interrupt_num = digitalPinToInterrupt(_receivePin); + _pcint_maskreg_p = 0; + _pcint_maskreg_n = 0; + _pcint_maskvalue_p = 0; + _pcint_maskvalue_n = 0; +} + +// +// Destructor +// +SoftwareSerial::~SoftwareSerial() +{ + end(); +} + +uint16_t SoftwareSerial::subtract_cap(uint16_t num, uint16_t sub) { + if (num > sub) + return num - sub; + else + return 1; +} + +// +// Public methods +// + +void SoftwareSerial::begin(long speed) +{ + _rx_delay_centering = _rx_delay_intrabit = _rx_delay_stopbit = _tx_delay = _rx_delay_firstbit = 0; + + uint16_t bit_delay = (F_CPU / speed) / 5 - 5; + + // 12 (gcc 4.8.2) or 13 (gcc 4.3.2) cycles from start bit to first bit, + // 15 (gcc 4.8.2) or 16 (gcc 4.3.2) cycles between bits, + // 12 (gcc 4.8.2) or 14 (gcc 4.3.2) cycles from last bit to stop bit + // These are all close enough to just use 15 cycles, since the inter-bit + // timings are the most critical (deviations stack 8 times) + _tx_delay = subtract_cap(bit_delay, 15 / 4); + + attachInterrupt(_interrupt_num, softwareserial_interrupt, CHANGE); + + if (115200L == speed) + { + _rx_delay_centering = 0; + _rx_delay_firstbit = 30; + _rx_delay_intrabit = 30; + _rx_delay_stopbit = 30; + _tx_delay = 30; + } + else if (57600L == speed) + { + _rx_delay_centering = 25; + _rx_delay_firstbit = 69; + _rx_delay_intrabit = 69; + _rx_delay_stopbit = 69; + _tx_delay = 69; + } + else if (38400L == speed) + { + _rx_delay_centering = 45; + _rx_delay_firstbit = 108; + _rx_delay_intrabit = 108; + _rx_delay_stopbit = 108; + _tx_delay = 108; + } + else if (19200L == speed) + { + _rx_delay_centering = 110; + _rx_delay_firstbit = 227; + _rx_delay_intrabit = 227; + _rx_delay_stopbit = 227; + _tx_delay = 227; + } + else if (9600L == speed) + { + _rx_delay_centering = 227; + _rx_delay_firstbit = 463; + _rx_delay_intrabit = 463; + _rx_delay_stopbit = 463; + _tx_delay = 463; + } + else if (4800L == speed) + { + _rx_delay_centering = 467; + _rx_delay_firstbit = 935; + _rx_delay_intrabit = 935; + _rx_delay_stopbit = 935; + _tx_delay = 935; + } + + Set_SerialPort(_transmitPin,_receivePin); + + listen(); +} +// param : true means enable the interruption +void SoftwareSerial::setRxIntMsk(bool enable) +{ + if (enable) + { + _pcint_maskreg_p |= _pcint_maskvalue_p; + _pcint_maskreg_n |= _pcint_maskvalue_p; + } + else{ + _pcint_maskreg_p &= ~_pcint_maskvalue_p; + _pcint_maskreg_n &= ~_pcint_maskvalue_p; + } +} + +void SoftwareSerial::tx_pin_write(uint8_t pin_state) +{ + if (pin_state == LOW) + *_transmitPortRegister &= ~_transmitBitMask; + else + *_transmitPortRegister |= _transmitBitMask; +} + +void SoftwareSerial::end() +{ + stopListening(); +} + + +// Read data from buffer +int SoftwareSerial::read() +{ + if (!isListening()) + return -1; + + // Empty buffer? + if (_receive_buffer_head == _receive_buffer_tail) + return -1; + + // Read from "head" + uint8_t d = _receive_buffer[_receive_buffer_head]; // grab next byte + _receive_buffer_head = (_receive_buffer_head + 1) % _SS_MAX_RX_BUFF; + return d; +} + +int SoftwareSerial::available() +{ + if (!isListening()) + return 0; + + return (_receive_buffer_tail + _SS_MAX_RX_BUFF - _receive_buffer_head) % _SS_MAX_RX_BUFF; +} + +// modified from 6->4 +const int XMIT_START_ADJUSTMENT = 4; + +size_t SoftwareSerial::write(uint8_t b) +{ + if (_tx_delay == 0) + return 0; + + noInterrupts(); + + // Write the start bit + tempAXvalue = _inverse_logic ? HIGH : LOW; + tx_pin_write(tempAXvalue); + tempAXvalue = _tx_delay + XMIT_START_ADJUSTMENT; + tunedDelay(tempAXvalue); + + // Write each of the 8 bits + if (_inverse_logic) + { + for (uint8_t mask = 0x01; mask; mask <<= 1) + { + if (b & mask) // choose bit + tx_pin_write(LOW); // send 1 + else + tx_pin_write(HIGH); // send 0 + + tunedDelay(_tx_delay); + } + tx_pin_write(LOW); // restore pin to natural state + } + else + { + for (uint8_t mask = 0x01; mask; mask <<= 1) + { + if (b & mask) // choose bit + tx_pin_write(HIGH); // send 1 + else + tx_pin_write(LOW); // send 0 + + tunedDelay(_tx_delay); + } + + tx_pin_write(HIGH); // restore pin to natural state + } + tunedDelay(_tx_delay); + interrupts(); + + return 1; +} + +void SoftwareSerial::flush() +{ + // There is no tx buffering, simply return +} + +int SoftwareSerial::peek() +{ + if (!isListening()) + return -1; + + // Empty buffer? + if (_receive_buffer_head == _receive_buffer_tail) + return -1; + + // Read from "head" + return _receive_buffer[_receive_buffer_head]; +} + +void SoftwareSerial::Set_SerialPort(uint8_t txd_pin,uint8_t rxd_pin) +{ + const PinTableType ** pp; + PinTableType * p; + + /* Set RxD pin */ + //getPinTable(rxd_pin,p); + pp = &pinTablelist[rxd_pin]; + p = (PinTableType *)*pp; + /* Set PM Register for Input */ + *p->portModeRegisterAddr |= (unsigned long)(0x1 << p->bit); + + /* Set PMCA Register */ + if (0!=p->pmca){ + *p->portModeControlARegisterAddr &= (unsigned long)~(p->pmca); + } + + /* Set PMCT Register */ + if (0!=p->pmct){ + *p->portModeControlTRegisterAddr &= (unsigned long)~(p->pmct); + } +#if defined(G23_FPB) + /* Set PMCE Register for Output */ + if (0!=p->pmce){ + *p->portModeControlERegisterAddr &= (unsigned long)~(p->pmce); + } +#endif // G23_FPB + /* Set CCDE Register for Digital InOut */ +#if defined(G23_FPB) + if (0!=p->ccde){ + CCDE &= (uint8_t)~(p->ccde); + } +#endif // G23_FPB + + /* Set TxD pin */ + pp = &pinTablelist[txd_pin]; + p = (PinTableType *)*pp; + /* Set PMCE Register t */ +#if defined(G23_FPB) + if (0!=p->pmce){ + *p->portModeControlERegisterAddr &= (unsigned long)~(p->pmce); + } +#endif // G23_FPB + + if(true == _inverse_logic) + { + /* Set P Register for Set "L" Output Port*/ + *p->portRegisterAddr &= (uint8_t)~(0x1 << p->bit); + } + else + { + /* Set P Register for Set "H" Output Port*/ + *p->portRegisterAddr |= (uint8_t)(0x1 << p->bit); + } + + /* Set PM Register for Output */ + *p->portModeRegisterAddr &= (unsigned long)~(0x1 << p->bit); + + /* Set PMCA Register */ + if (0!=p->pmca){ + *p->portModeControlARegisterAddr &= (unsigned long)~(p->pmca); + } + + /* Set PMCT Register */ + if (0!=p->pmct){ + *p->portModeControlTRegisterAddr &= (unsigned long)~(p->pmct); + } + + /* Set PMCE Register t */ +#if defined(G23_FPB) + if (0!=p->pmce){ + *p->portModeControlERegisterAddr &= (unsigned long)~(p->pmce); + } +#endif // G23_FPB + + /* Set CCDE Register for Digital InOut */ +#if defined(G23_FPB) + if (0!=p->ccde){ + CCDE &= (uint8_t)~(p->ccde); + } +#endif // G23_FPB + +} diff --git a/libraries/SoftwareSerial/src/SoftwareSerial.h b/libraries/SoftwareSerial/src/SoftwareSerial.h new file mode 100644 index 0000000..83027eb --- /dev/null +++ b/libraries/SoftwareSerial/src/SoftwareSerial.h @@ -0,0 +1,129 @@ +/* +SoftwareSerial.h (formerly NewSoftSerial.h) - +Multi-instance software serial library for Arduino/Wiring +-- Interrupt-driven receive and other improvements by ladyada + (http://ladyada.net) +-- Tuning, circular buffer, derivation from class Print/Stream, + multi-instance support, porting to 8MHz processors, + various optimizations, PROGMEM delay tables, inverse logic and + direct port writing by Mikal Hart (http://www.arduiniana.org) +-- Pin change interrupt macros by Paul Stoffregen (http://www.pjrc.com) +-- 20MHz processor support by Garrett Mace (http://www.macetech.com) +-- ATmega1280/2560 support by Brett Hagman (http://www.roguerobotics.com/) + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +The latest version of this library can always be found at +http://arduiniana.org. +*/ +/* Aug 25th 2017: Modified by Yuuki Okamiya for RL78 */ + +#ifndef SoftwareSerial_h +#define SoftwareSerial_h + +#include +#include "api/Stream.h" + +/****************************************************************************** +* Definitions +******************************************************************************/ + +#ifndef _SS_MAX_RX_BUFF +#define _SS_MAX_RX_BUFF 256 // RX buffer size +#endif + +#ifndef GCC_VERSION +#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +#endif + +class SoftwareSerial : public Stream +{ +private: +// per object data + uint8_t _receivePin; + uint8_t _receiveBitMask; + volatile uint8_t *_receivePortRegister; + uint8_t _transmitBitMask; + volatile uint8_t *_transmitPortRegister; + uint8_t _transmitPin; + uint8_t _interrupt_num; + volatile uint8_t _pcint_maskreg_p; + volatile uint8_t _pcint_maskreg_n; + uint8_t _pcint_maskvalue_p; + uint8_t _pcint_maskvalue_n; + +// Expressed as 4-cycle delays (must never be 0!) + uint16_t _rx_delay_centering; + uint16_t _rx_delay_firstbit; + uint16_t _rx_delay_intrabit; + uint16_t _rx_delay_stopbit; + uint16_t _tx_delay; + + uint16_t _buffer_overflow:1; + uint16_t _inverse_logic:1; + +// static data + static uint8_t _receive_buffer[_SS_MAX_RX_BUFF]; + static volatile uint8_t _receive_buffer_tail; + static volatile uint8_t _receive_buffer_head; + static SoftwareSerial *active_object; + +// private methods + inline void recv() __attribute__((__always_inline__)); + uint8_t rx_pin_read(); + void tx_pin_write(uint8_t pin_state); + + inline void setRxIntMsk(bool enable) __attribute__((__always_inline__)); + +// Return num - sub, or 1 if the result would be < 1 + static uint16_t subtract_cap(uint16_t num, uint16_t sub); + +// private static method for timing + static inline void tunedDelay(uint16_t delay); + void Set_SerialPort(uint8_t txd_pin,uint8_t rxd_pin); +public: + // public methods + SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic = false); + ~SoftwareSerial(); + void begin(long speed); + bool listen(); + void end(); + bool isListening() { return this == active_object; } + bool stopListening(); + bool overflow() { bool ret = _buffer_overflow; if (ret) _buffer_overflow = false; return ret; } + int peek(); + + virtual size_t write(uint8_t byte); + virtual int read(); + virtual int available(); + virtual void flush(); + operator bool() { return true; } + + using Print::write; + + // public only for easy access by interrupt handlers + static inline void handle_interrupt() __attribute__((__always_inline__)); +}; + +// Arduino 0012 workaround +#undef int +#undef char +#undef long +#undef byte +#undef float +#undef abs +#undef round + +#endif diff --git a/libraries/Wire/examples/i2c-lcd/i2c-lcd.ino b/libraries/Wire/examples/i2c-lcd/i2c-lcd.ino new file mode 100644 index 0000000..ba5cadd --- /dev/null +++ b/libraries/Wire/examples/i2c-lcd/i2c-lcd.ino @@ -0,0 +1,123 @@ + + +#include + +#define SLAVE_ADDRESS_LCD 0x27 // change this according to ur setup + +void lcd_send_cmd (char cmd); +void lcd_send_data (char data); +void lcd_clear (void); +void lcd_init (void); +void lcd_put_cur(int row, int col); +void lcd_send_string (char *str); + + +void lcd_send_cmd (char cmd) +{ + char data_u, data_l; + uint8_t DATA; + data_u = (cmd&0xf0); + data_l = ((cmd<<4)&0xf0); + Wire.beginTransmission(SLAVE_ADDRESS_LCD); + DATA = data_u|0x0C; //en=1, rs=0 + Wire.write(DATA); + DATA = data_u|0x08; //en=0, rs=0 + Wire.write(DATA); + DATA = data_l|0x0C; //en=1, rs=0 + Wire.write(DATA); + DATA = data_l|0x08; //en=0, rs=0 + Wire.write(DATA); + Wire.endTransmission(); + delay(50); +} + +void lcd_send_data (char data) +{ + char data_u, data_l; + uint8_t DATA; + data_u = (data&0xf0); + data_l = ((data<<4)&0xf0); + Wire.beginTransmission(SLAVE_ADDRESS_LCD); + DATA = data_u|0x0D; //en=1, rs=0 + Wire.write(DATA); + DATA = data_u|0x09; //en=0, rs=0 + Wire.write(DATA); + DATA = data_l|0x0D; //en=1, rs=0 + Wire.write(DATA); + DATA = data_l|0x09; //en=0, rs=0 + Wire.write(DATA); + Wire.write(DATA); + Wire.endTransmission(); + delay(50); +} + +void lcd_clear (void) +{ + lcd_send_cmd (0x80); + for (int i=0; i<70; i++) + { + lcd_send_data (' '); + } +} + +void lcd_init (void) +{ + // 4 bit initialisation + delay(100); // wait for >40ms + lcd_send_cmd (0x30); + delay(50); // wait for >4.1ms + lcd_send_cmd (0x30); + delay(50); // wait for >100us + lcd_send_cmd (0x30); + delay(50); + lcd_send_cmd (0x20); // 4bit mode + delay(50); + + // dislay initialisation + lcd_send_cmd (0x28); // Function set --> DL=0 (4 bit mode), N = 1 (2 line display) F = 0 (5x8 characters) + delay(50); + lcd_send_cmd (0x08); //Display on/off control --> D=0,C=0, B=0 ---> display off + delay(50); + lcd_send_cmd (0x01); // clear display + delay(50); + delay(50); + lcd_send_cmd (0x06); //Entry mode set --> I/D = 1 (increment cursor) & S = 0 (no shift) + delay(50); + lcd_send_cmd (0x0C); //Display on/off control --> D = 1, C and B = 0. (Cursor and blink, last two bits) +} + +void lcd_put_cur(int row, int col) +{ + switch (row) + { + case 0: + col |= 0x80; + break; + case 1: + col |= 0xC0; + break; + } + lcd_send_cmd (col); +} + + +void lcd_send_string (char *str) +{ + while (*str) lcd_send_data (*str++); +} + + +void setup() { + char character_1[12]="Hello RL78!"; + + pinMode(7, OUTPUT); + + Wire.begin(); // join i2c bus (address optional for master) + + lcd_init(); + lcd_send_string(character_1); +} + +void loop() { + delay(1000); // wait for a second +} diff --git a/libraries/Wire/library.properties b/libraries/Wire/library.properties index a34200d..f206045 100644 --- a/libraries/Wire/library.properties +++ b/libraries/Wire/library.properties @@ -6,5 +6,5 @@ sentence=This library allows you to communicate with I2C and Two Wire Interface paragraph=It allows the communication with I2C devices like temperature sensors, realtime clocks and many others using SDA (Data Line) and SCL (Clock Line). category=Communication url=https://github.com/renesas/Arduino -architectures=rl78g22 +architectures=rl78g22_fpb diff --git a/libraries/Wire/src/Wire.h b/libraries/Wire/src/Wire.h index eebceeb..e429e3a 100644 --- a/libraries/Wire/src/Wire.h +++ b/libraries/Wire/src/Wire.h @@ -33,8 +33,6 @@ namespace arduino { -// 2023/02/15 -//class TwoWire : public Stream class TwoWire : public HardwareI2C { private: @@ -73,10 +71,13 @@ class TwoWire : public HardwareI2C void setClock(uint32_t) override; void beginTransmission(uint8_t) override; +// void beginTransmission(int); uint8_t endTransmission(void) override; uint8_t endTransmission(bool) override; size_t requestFrom(uint8_t, size_t) override; size_t requestFrom(uint8_t, size_t, bool) override; +// size_t requestFrom(int, int); +// size_t requestFrom(int, int, int); virtual size_t write(uint8_t) override; virtual size_t write(const uint8_t *, size_t) override; virtual int available(void) override; diff --git a/libraries/Wire/src/Wire_IICA.cpp b/libraries/Wire/src/Wire_IICA.cpp index e0ad6c0..c85c600 100644 --- a/libraries/Wire/src/Wire_IICA.cpp +++ b/libraries/Wire/src/Wire_IICA.cpp @@ -22,7 +22,6 @@ extern "C" { } -// 2023/02/15 using namespace arduino; /* Constructors ***************************************************************/ diff --git a/platform.txt b/platform.txt index 3c22d86..1423708 100644 --- a/platform.txt +++ b/platform.txt @@ -4,7 +4,7 @@ # For more info: # LLVM Prototype Package for Tools Test name=Renesas RL78/G22 -version=2.0.0 +version=2.1.0 # --------------------- # Compile variables @@ -73,47 +73,32 @@ inc5 ="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_ITL000" inc6 ="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_ITL001" inc7 ="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_ITL012" inc8 ="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_ITL013" -inc9 ="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_0_Measure_Signal" -inc10="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_01_PWM" -inc11="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_1_Measure_Signal" -inc12="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_1_Servo" -inc13="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_1_Square_Wave" -inc14="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_2_Measure_Signal" -inc15="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_2_Servo" -inc16="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_2_Square_Wave" -inc17="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_23_PWM" -inc18="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_3_Measure_Signal" -inc19="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_3_Servo" -inc20="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_3_Square_Wave" -inc21="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_4_Servo" -inc22="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_5_Servo" -inc23="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_6_Micros" -inc24="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_6_Servo" -inc25="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_67_PWM" -inc26="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_7_Measure_Signal" -inc27="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_7_MsTimer2" -inc28="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_7_Servo" -inc29="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_7_Square_Wave" -inc30="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_RTC" -inc31="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_UART0" -inc32="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_UART1" -inc33="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_UART2" -inc34="-I{runtime.platform.path}/cores/rl78g22/smc_gen/general" -inc35="-I{runtime.platform.path}/cores/rl78g22/smc_gen/r_bsp" -inc36="-I{runtime.platform.path}/cores/rl78g22/smc_gen/r_bsp/board" -inc37="-I{runtime.platform.path}/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22" -inc38="-I{runtime.platform.path}/cores/rl78g22/smc_gen/r_bsp/mcu/all" -inc39="-I{runtime.platform.path}/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22" -inc40="-I{runtime.platform.path}/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/register_access" -inc41="-I{runtime.platform.path}/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/register_access/llvm" -inc42="-I{runtime.platform.path}/cores/rl78g22/smc_gen/r_config" -inc43="-I{runtime.platform.path}/variants/g22-fpb-48p" +inc9 ="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_0_PWM" +inc10="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_1_Square_Wave" +inc11="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_2_Square_Wave" +inc12="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_3_Square_Wave" +inc13="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_6_Micros" +inc14="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_TAU0_7_Square_Wave" +inc15="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_RTC" +inc16="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_UART0" +inc17="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_UART1" +inc18="-I{runtime.platform.path}/cores/rl78g22/smc_gen/Config_UART2" +inc19="-I{runtime.platform.path}/cores/rl78g22/smc_gen/general" +inc20="-I{runtime.platform.path}/cores/rl78g22/smc_gen/r_bsp" +inc21="-I{runtime.platform.path}/cores/rl78g22/smc_gen/r_bsp/board" +inc22="-I{runtime.platform.path}/cores/rl78g22/smc_gen/r_bsp/board/generic_rl78_g22" +inc23="-I{runtime.platform.path}/cores/rl78g22/smc_gen/r_bsp/mcu/all" +inc24="-I{runtime.platform.path}/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22" +inc25="-I{runtime.platform.path}/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/register_access" +inc26="-I{runtime.platform.path}/cores/rl78g22/smc_gen/r_bsp/mcu/rl78_g22/register_access/llvm" +inc27="-I{runtime.platform.path}/cores/rl78g22/smc_gen/r_config" +inc28="-I{runtime.platform.path}/variants/g22-fpb-48p" incA={inc0} {inc1} {inc2} {inc3} {inc4} {inc5} {inc6} {inc7} {inc8} {inc9} incB={inc10} {inc11} {inc12} {inc13} {inc14} {inc15} {inc16} {inc17} {inc18} {inc19} -incC={inc20} {inc21} {inc22} {inc23} {inc24} {inc25} {inc26} {inc27} {inc28} {inc29} -incD={inc30} {inc31} {inc32} {inc33} {inc34} {inc35} {inc36} {inc37} {inc38} {inc39} -incE={inc40} {inc41} {inc42} {inc43} +incC={inc20} {inc21} {inc22} {inc23} {inc24} {inc25} {inc26} {inc27} {inc28} +incD= +incE= compiler.includes={incA} {incB} {incC} {incD} {incE} @@ -142,7 +127,7 @@ recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {includes} {compiler.includ # -------------------- # Create archives # -------------------- -compiler.ar.cmd=llvm-ar.exe +compiler.ar.cmd=llvm-ar compiler.ar.flags=rcs recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} "{archive_file_path}" "{object_file}" @@ -152,9 +137,6 @@ recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} "{archi #Core-SourceCode edition recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {object_files} "-L{build.path}" "{build.path}/{archive_file}" "-T{runtime.platform.path}/{build.ldscript}" -Wl,-Map={build.path}/{build.project_name}.map -Wl,--start-group -Wl,--end-group -nostartfiles -Wl,-e_PowerON_Reset -Wl,--gc-sections -Wl,--icf=none -o {build.path}/{build.project_name}.elf -#Core-StaticLibrary edition -#recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {object_files} "-L{build.path}" "{build.path}/{archive_file}" "{runtime.platform.path}\cores\core_rl78g22_48p_fpb_arduino.a" "-T{runtime.platform.path}/{build.ldscript}" -Wl,-Map={build.path}/{build.project_name}.map -Wl,--start-group -Wl,--end-group -nostartfiles -Wl,-e_PowerON_Reset -Wl,--gc-sections -Wl,--icf=none -o {build.path}/{build.project_name}.elf - # -------------------- # Create eeprom # -------------------- diff --git a/variants/g22-fpb-48p/linker_scripts/gcc/linker_script.ld b/variants/g22-fpb-48p/linker_scripts/gcc/linker_script.ld index f743c2e..7674f11 100644 --- a/variants/g22-fpb-48p/linker_scripts/gcc/linker_script.ld +++ b/variants/g22-fpb-48p/linker_scripts/gcc/linker_script.ld @@ -1,249 +1,248 @@ -MEMORY -{ - VEC : ORIGIN = 0x0, LENGTH = 4 - IVEC : ORIGIN = 0x4, LENGTH = 188 - CALLT0 : ORIGIN = 0x80, LENGTH = 0x40 - OPT : ORIGIN = 0xC0, LENGTH = 4 - SEC_ID : ORIGIN = 0xC4, LENGTH = 10 - OCDSTAD : ORIGIN = 0xCE, LENGTH = 10 - OCDROM : ORIGIN = 0xFE00, LENGTH = 512 - ROM : ORIGIN = 0xD8, LENGTH = 64808 - MIRROR : ORIGIN = 0xF2000, LENGTH = 52992 - SADDR : ORIGIN = 0xffe20, LENGTH = 0x000a0 - RAM : ORIGIN = 0xFEF00, LENGTH = 4096 -} - -EXTERN(vec vects callt0 option_bytes security_id init fini preinit_array init_array fini_array eh_frame_hdr eh_frame) - -SECTIONS -{ - .vec 0x0: AT(0x0) - { - KEEP(*(.vec)) - } > VEC - .vects 0x4: AT(0x4) - { - KEEP(*(.vects)) - } > IVEC - - .callt0 0x80 : AT(0x80) - { - . = ALIGN(2); - KEEP(*(.callt0)) - } >CALLT0 - - .option_byte 0xc0 : AT(0xc0) - { - KEEP(*(.option_bytes)) - } > OPT - .security_id 0xc4 : AT(0xc4) - { - KEEP(*(.security_id)) - } > SEC_ID - .lowtext 0xD8: AT(0xD8) - { - *(.plt) - *(.lowtext) - } > ROM - - __mdata = .; - - .text (. + __romdatacopysize): - { - *(.text) - *(.text.*) - /*INPUT_SECTION_FLAGS(SHF_EXECINSTR) *(*_n)*/ - } >ROM AT>ROM - - .init : - { - KEEP(*(.init)) - } >ROM - - .fini : - { - KEEP(*(.fini)) - } >ROM - - PROVIDE(__rodata_limit = CONSTANT(MIRRORAREASTART)+ 0x2000 + LENGTH(MIRROR)); - - .rodata MAX(., (CONSTANT(MIRRORAREASTART)+ 0x2000)): - { - . = ALIGN(2); - __rodata = .; - *(.rodata) - *(.rodata.*) - . = ALIGN(2); - *(.const) - *(.const.*) - - . = ALIGN(2); - PROVIDE(__preinit_array_end = .); - KEEP(*(.preinit_array)) - PROVIDE(__preinit_array_start = .); - PROVIDE(__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE(__init_array_end = .); - PROVIDE(__fini_array_start = .); - KEEP(*(.fini_array)) - KEEP(*(SORT(.fini_array.*))) - PROVIDE(__fini_array_end = .); - __erodata = .; - /*The rodata section is copied into the MIRROR area, that is why we check if the start and end addresses for rodata are less then _rodata_limit*/ - ASSERT((SIZEOF (.rodata) == 0) || (__rodata < __rodata_limit), "Error: rodata section start address is too large. Move the text section after the rodata section to ensure that correct data is added to the MIRROR area."); - ASSERT((SIZEOF (.rodata) == 0) || (__erodata <= __rodata_limit), "Error: rodata section size exceeds length of the MIRROR area."); - - }>ROM - - - .textf : - { - *(.textf) - *(.textf.*) - /*INPUT_SECTION_FLAGS(SHF_EXECINSTR) *(*_f)*/ - }>ROM - - .frodata : - { - . = ALIGN(2); - __frodata = .; - *(.frodata) - *(.frodata.*) - __efrodata = .; - - . = ALIGN(2); - __constf = .; - *(.constf) - *(.constf.*) - __econstf = .; - } >ROM - - .eh_frame_hdr : - { - KEEP(*(.eh_frame_hdr)) - } > ROM - .eh_frame : - { - KEEP(*(.eh_frame)) - } > ROM - - .data 0xFEF00 : AT(__mdata) - { - . = ALIGN(2); - PROVIDE (__datastart = .); - __data = .; - *(.data) - *(.data.*) - . = ALIGN(2); - /*INPUT_SECTION_FLAGS(!SHF_EXECINSTR, SHF_WRITE, SHF_ALLOC) *(*_n)*/ - __edata = .; - } >RAM - - - PROVIDE(__romdatastart = LOADADDR(.data)); - PROVIDE (__romdatacopysize = SIZEOF(.data)); - - - .dataf : { - . = ALIGN(2); - PROVIDE (__datafstart = .); - . = ALIGN(2); - *(.dataf) - *(.dataf.*) - /*INPUT_SECTION_FLAGS(!SHF_EXECINSTR, SHF_WRITE, SHF_ALLOC) *(*_f)*/ - . = ALIGN(2); - PROVIDE (__datafend = .); - } > RAM AT> ROM - PROVIDE(__romdatafstart = LOADADDR(.dataf)); - PROVIDE (__romdatafcopysize = SIZEOF(.dataf)); - - - .sdata : { - . = ALIGN(2); - PROVIDE (__sdatastart = .); - *(.sdata) - *(.sdata.*) - . = ALIGN(2); - PROVIDE (__sdataend = .); - } > SADDR AT> ROM - - /* Note that crt0 assumes this is a multiple of two; all the - start/stop symbols are also assumed word-aligned. */ - PROVIDE(__romsdatastart = LOADADDR(.sdata)); - PROVIDE (__romsdatacopysize = SIZEOF(.sdata)); - - - .saddr : { - - . = ALIGN(2); - PROVIDE (__saddrstart = .); - *(.saddr) - . = ALIGN(2); - - } >SADDR AT>ROM - PROVIDE(__romsaddrstart = LOADADDR(.saddr)); - PROVIDE (__romsaddrcopysize = SIZEOF(.saddr)); - - - - .sbss : - { - PROVIDE(__sbssstart = .); - . = ALIGN(2); - __sbss = .; - *(.sbss) - *(.sbss.*) - /*INPUT_SECTION_FLAGS(!SHF_EXECINSTR, SHF_WRITE, SHF_ALLOC) *(*_s)*/ - . = ALIGN(2); - *(.sbss_bit) - . = ALIGN(2); - __esbss = .; - - } >SADDR AT>RAM - PROVIDE(__sbsssize = SIZEOF(.sbss)); - - .bss : - { - PROVIDE(__bssstart = .); - . = ALIGN(2); - __bss = .; - *(.bss) - *(.bss.*) - . = ALIGN(2); - *(.bss_bit) - . = ALIGN(2); - *(COMMON) - . = ALIGN(2); - __ebss = .; - } >RAM AT>RAM - PROVIDE(__bsssize = SIZEOF(.bss)); - - - .bssf (NOLOAD): - { - PROVIDE(__bssfstart = .); - . = ALIGN(2); - *(.bssf) - *(.bssf.*) - /*INPUT_SECTION_FLAGS(!SHF_EXECINSTR, SHF_WRITE, SHF_ALLOC) *(*_f)*/ - . = ALIGN(128); - __end = .; - } >RAM AT>RAM - PROVIDE(__bssfsize = SIZEOF(.bssf)); - - PROVIDE(__stack_size = 0x100); - .stack 0xFFEDC (NOLOAD) : AT(0xFFEDC) - { - - PROVIDE(__stack = .); - ASSERT((__stack > (__end + __stack_size)), "Error: Too much data - no room left for the stack"); - } >RAM - - /DISCARD/ : - { - *(.note) - *(.note.*) - *(.gnu.warning*) - } -} +MEMORY +{ + VEC : ORIGIN = 0x0, LENGTH = 4 + IVEC : ORIGIN = 0x4, LENGTH = 188 + CALLT0 : ORIGIN = 0x80, LENGTH = 0x40 + OPT : ORIGIN = 0xC0, LENGTH = 4 + SEC_ID : ORIGIN = 0xC4, LENGTH = 10 + OCDSTAD : ORIGIN = 0xCE, LENGTH = 10 + OCDROM : ORIGIN = 0xFE00, LENGTH = 512 + ROM : ORIGIN = 0xD8, LENGTH = 64808 + MIRROR : ORIGIN = 0xF2000, LENGTH = 52992 + SADDR : ORIGIN = 0xffe20, LENGTH = 0x000a0 + RAM : ORIGIN = 0xFEF00, LENGTH = 4096 +} + +EXTERN(vec vects callt0 option_bytes security_id init fini preinit_array init_array fini_array eh_frame_hdr eh_frame) + +SECTIONS +{ + .vec 0x0: AT(0x0) + { + KEEP(*(.vec)) + } > VEC + .vects 0x4: AT(0x4) + { + KEEP(*(.vects)) + } > IVEC + + .callt0 0x80 : AT(0x80) + { + . = ALIGN(2); + KEEP(*(.callt0)) + } >CALLT0 + + .option_byte 0xc0 : AT(0xc0) + { + KEEP(*(.option_bytes)) + } > OPT + .security_id 0xc4 : AT(0xc4) + { + KEEP(*(.security_id)) + } > SEC_ID + .lowtext 0xD8: AT(0xD8) + { + *(.plt) + *(.lowtext) + } > ROM + + __mdata = .; + + .text (. + __romdatacopysize): + { + *(.text) + *(.text.*) + /*INPUT_SECTION_FLAGS(SHF_EXECINSTR) *(*_n)*/ + } >ROM AT>ROM + + .init : + { + KEEP(*(.init)) + } >ROM + + .fini : + { + KEEP(*(.fini)) + } >ROM + + PROVIDE(__rodata_limit = CONSTANT(MIRRORAREASTART)+ 0x2000 + LENGTH(MIRROR)); + + .rodata MAX(., (CONSTANT(MIRRORAREASTART)+ 0x2000)): + { + . = ALIGN(2); + __rodata = .; + *(.rodata) + *(.rodata.*) + . = ALIGN(2); + *(.const) + *(.const.*) + + . = ALIGN(2); + PROVIDE(__preinit_array_end = .); + KEEP(*(.preinit_array)) + PROVIDE(__preinit_array_start = .); + PROVIDE(__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE(__init_array_end = .); + PROVIDE(__fini_array_start = .); + KEEP(*(.fini_array)) + KEEP(*(SORT(.fini_array.*))) + PROVIDE(__fini_array_end = .); + __erodata = .; + /*The rodata section is copied into the MIRROR area, that is why we check if the start and end addresses for rodata are less then _rodata_limit*/ + ASSERT((SIZEOF (.rodata) == 0) || (__rodata < __rodata_limit), "Error: rodata section start address is too large. Move the text section after the rodata section to ensure that correct data is added to the MIRROR area."); + ASSERT((SIZEOF (.rodata) == 0) || (__erodata <= __rodata_limit), "Error: rodata section size exceeds length of the MIRROR area."); + }>ROM + + + .textf : + { + *(.textf) + *(.textf.*) + /*INPUT_SECTION_FLAGS(SHF_EXECINSTR) *(*_f)*/ + }>ROM + + .frodata : + { + . = ALIGN(2); + __frodata = .; + *(.frodata) + *(.frodata.*) + __efrodata = .; + + . = ALIGN(2); + __constf = .; + *(.constf) + *(.constf.*) + __econstf = .; + } >ROM + + .eh_frame_hdr : + { + KEEP(*(.eh_frame_hdr)) + } > ROM + .eh_frame : + { + KEEP(*(.eh_frame)) + } > ROM + + .data 0xFEF00 : AT(__mdata) + { + . = ALIGN(2); + PROVIDE (__datastart = .); + __data = .; + *(.data) + *(.data.*) + . = ALIGN(2); + /*INPUT_SECTION_FLAGS(!SHF_EXECINSTR, SHF_WRITE, SHF_ALLOC) *(*_n)*/ + __edata = .; + } >RAM + + + PROVIDE(__romdatastart = LOADADDR(.data)); + PROVIDE (__romdatacopysize = SIZEOF(.data)); + + + .dataf : { + . = ALIGN(2); + PROVIDE (__datafstart = .); + . = ALIGN(2); + *(.dataf) + *(.dataf.*) + /*INPUT_SECTION_FLAGS(!SHF_EXECINSTR, SHF_WRITE, SHF_ALLOC) *(*_f)*/ + . = ALIGN(2); + PROVIDE (__datafend = .); + } > RAM AT> ROM + PROVIDE(__romdatafstart = LOADADDR(.dataf)); + PROVIDE (__romdatafcopysize = SIZEOF(.dataf)); + + + .sdata : { + . = ALIGN(2); + PROVIDE (__sdatastart = .); + *(.sdata) + *(.sdata.*) + . = ALIGN(2); + PROVIDE (__sdataend = .); + } > SADDR AT> ROM + + /* Note that crt0 assumes this is a multiple of two; all the + start/stop symbols are also assumed word-aligned. */ + PROVIDE(__romsdatastart = LOADADDR(.sdata)); + PROVIDE (__romsdatacopysize = SIZEOF(.sdata)); + + + .saddr : { + + . = ALIGN(2); + PROVIDE (__saddrstart = .); + *(.saddr) + . = ALIGN(2); + + } >SADDR AT>ROM + PROVIDE(__romsaddrstart = LOADADDR(.saddr)); + PROVIDE (__romsaddrcopysize = SIZEOF(.saddr)); + + + + .sbss : + { + PROVIDE(__sbssstart = .); + . = ALIGN(2); + __sbss = .; + *(.sbss) + *(.sbss.*) + /*INPUT_SECTION_FLAGS(!SHF_EXECINSTR, SHF_WRITE, SHF_ALLOC) *(*_s)*/ + . = ALIGN(2); + *(.sbss_bit) + . = ALIGN(2); + __esbss = .; + + } >SADDR AT>RAM + PROVIDE(__sbsssize = SIZEOF(.sbss)); + + .bss : + { + PROVIDE(__bssstart = .); + . = ALIGN(2); + __bss = .; + *(.bss) + *(.bss.*) + . = ALIGN(2); + *(.bss_bit) + . = ALIGN(2); + *(COMMON) + . = ALIGN(2); + __ebss = .; + } >RAM AT>RAM + PROVIDE(__bsssize = SIZEOF(.bss)); + + + .bssf (NOLOAD): + { + PROVIDE(__bssfstart = .); + . = ALIGN(2); + *(.bssf) + *(.bssf.*) + /*INPUT_SECTION_FLAGS(!SHF_EXECINSTR, SHF_WRITE, SHF_ALLOC) *(*_f)*/ + . = ALIGN(128); + __end = .; + } >RAM AT>RAM + PROVIDE(__bssfsize = SIZEOF(.bssf)); + + PROVIDE(__stack_size = 0x100); + .stack 0xFFEDC (NOLOAD) : AT(0xFFEDC) + { + + PROVIDE(__stack = .); + ASSERT((__stack > (__end + __stack_size)), "Error: Too much data - no room left for the stack"); + } >RAM + + /DISCARD/ : + { + *(.note) + *(.note.*) + *(.gnu.warning*) + } +} diff --git a/variants/g22-fpb-48p/pins_variant.h b/variants/g22-fpb-48p/pins_variant.h index e70aa96..4ec0574 100644 --- a/variants/g22-fpb-48p/pins_variant.h +++ b/variants/g22-fpb-48p/pins_variant.h @@ -29,20 +29,21 @@ #include #include -// 2023/03/02 moved from Arduino.h -// Arduino.h should not be board specific #ifndef configCPU_CLOCK_HZ #define configCPU_CLOCK_HZ (32000000) //!< CPU�̓�����g���iRTOS���g�p���ɒ�`�j #endif #define F_CPU (32 * 1000 * 1000L) +// G22:1 , G23 :2 , G16:1, G24:3 +#define MICROS_TIMER_DIVIDE_FACTOR ((uint32_t)1) + #define UART_CHANNEL 0 // UART0(Serial0) #define UART1_CHANNEL 1 // UART1(Serial1) #define UART2_CHANNEL 2 // UART2(Serial2) /* SPI(CSI) Definition */ -#define USE_CSI (0) // Set to '1' when Use SPI Hardware. +#define USE_CSI (1) // Set to '1' when Use SPI Hardware. #if defined(USE_CSI) && USE_CSI @@ -50,7 +51,7 @@ // #define CSI_CHANNEL1 (1) // USE CSI01 for SPI // #define CSI_CHANNEL2 (2) // USE CSI10 for SPI // #define CSI_CHANNEL3 (3) // USE CSI11 for SPI - #define CSI_CHANNEL4 (4) // USE CSI20 for SPI +#define CSI_CHANNEL4 (4) // USE CSI20 for SPI // #define CSI_CHANNEL5 (5) // USE CSI21 for SPI // #define CSI_CHANNEL6 (6) // USE CSI30 for SPI // #define CSI_CHANNEL7 (7) // USE CSI31 for SPI @@ -102,7 +103,6 @@ extern "C" // tone_func -#define PULSE_IN_CH_NUM (4) int8_t get_tone_channel(uint8_t tone_num); typedef struct { @@ -643,7 +643,7 @@ extern const uint8_t A9; #define PWM_PIN_23 0xE2 // Software PWM2 #define SWPWM_PIN 0xE0 -#define PWM_PIN_3 3 // TO4 +#define PWM_PIN_3 3 // TO3 #define PWM_PIN_6 6 // TO7 #define PWM_PIN_12 12 // TO3 #define PWM_PIN_25 25 // TO6 diff --git a/variants/g22-fpb-48p/pintable.c b/variants/g22-fpb-48p/pintable.c index ac1af80..aaf0038 100644 --- a/variants/g22-fpb-48p/pintable.c +++ b/variants/g22-fpb-48p/pintable.c @@ -1,975 +1,975 @@ -#include -#include - -const PinTableType pinTable_0 = -{ - DIGITAL_PIN_MASK_0, //uint8_t mask; - DIGITAL_PIN_BIT_0, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_0,//uint8_t pmca; - DIGITAL_PIN_PMCT_0,//uint8_t pmct; - DIGITAL_PIN_PM_0,//uint8_t pm; - DIGITAL_PIN_PU_0,//uint8_t pu; - DIGITAL_PIN_PIM_0,//uint8_t pim; - DIGITAL_PIN_POM_0,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_0),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_0),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_0),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_0),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_0),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_0),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_0),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_1 = -{ - DIGITAL_PIN_MASK_1, //uint8_t mask; - DIGITAL_PIN_BIT_1, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_1,//uint8_t pmca; - DIGITAL_PIN_PMCT_1,//uint8_t pmct; - DIGITAL_PIN_PM_1,//uint8_t pm; - DIGITAL_PIN_PU_1,//uint8_t pu; - DIGITAL_PIN_PIM_1,//uint8_t pim; - DIGITAL_PIN_POM_1,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_1),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_1),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_1),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_1),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_1),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_1),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_1),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_2 = -{ - DIGITAL_PIN_MASK_2, //uint8_t mask; - DIGITAL_PIN_BIT_2, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_2,//uint8_t pmca; - DIGITAL_PIN_PMCT_2,//uint8_t pmct; - DIGITAL_PIN_PM_2,//uint8_t pm; - DIGITAL_PIN_PU_2,//uint8_t pu; - DIGITAL_PIN_PIM_2,//uint8_t pim; - DIGITAL_PIN_POM_2,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_2),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_2),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_2),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_2),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_2),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_2),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_2),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_3 = -{ - DIGITAL_PIN_MASK_3, //uint8_t mask; - DIGITAL_PIN_BIT_3, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_3,//uint8_t pmca; - DIGITAL_PIN_PMCT_3,//uint8_t pmct; - DIGITAL_PIN_PM_3,//uint8_t pm; - DIGITAL_PIN_PU_3,//uint8_t pu; - DIGITAL_PIN_PIM_3,//uint8_t pim; - DIGITAL_PIN_POM_3,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_3),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_3),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_3),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_3),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_3),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_3),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_3),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_4 = -{ - DIGITAL_PIN_MASK_4, //uint8_t mask; - DIGITAL_PIN_BIT_4, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_4,//uint8_t pmca; - DIGITAL_PIN_PMCT_4,//uint8_t pmct; - DIGITAL_PIN_PM_4,//uint8_t pm; - DIGITAL_PIN_PU_4,//uint8_t pu; - DIGITAL_PIN_PIM_4,//uint8_t pim; - DIGITAL_PIN_POM_4,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_4),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_4),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_4),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_4),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_4),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_4),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_4),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_5 = -{ - DIGITAL_PIN_MASK_5, //uint8_t mask; - DIGITAL_PIN_BIT_5, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_5,//uint8_t pmca; - DIGITAL_PIN_PMCT_5,//uint8_t pmct; - DIGITAL_PIN_PM_5,//uint8_t pm; - DIGITAL_PIN_PU_5,//uint8_t pu; - DIGITAL_PIN_PIM_5,//uint8_t pim; - DIGITAL_PIN_POM_5,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_5),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_5),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_5),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_5),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_5),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_5),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_5),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_6 = -{ - DIGITAL_PIN_MASK_6, //uint8_t mask; - DIGITAL_PIN_BIT_6, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_6,//uint8_t pmca; - DIGITAL_PIN_PMCT_6,//uint8_t pmct; - DIGITAL_PIN_PM_6,//uint8_t pm; - DIGITAL_PIN_PU_6,//uint8_t pu; - DIGITAL_PIN_PIM_6,//uint8_t pim; - DIGITAL_PIN_POM_6,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_6),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_6),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_6),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_6),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_6),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_6),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_6),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_7 = -{ - DIGITAL_PIN_MASK_7, //uint8_t mask; - DIGITAL_PIN_BIT_7, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_7,//uint8_t pmca; - DIGITAL_PIN_PMCT_7,//uint8_t pmct; - DIGITAL_PIN_PM_7,//uint8_t pm; - DIGITAL_PIN_PU_7,//uint8_t pu; - DIGITAL_PIN_PIM_7,//uint8_t pim; - DIGITAL_PIN_POM_7,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_7),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_7),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_7),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_7),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_7),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_7),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_7),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_8 = -{ - DIGITAL_PIN_MASK_8, //uint8_t mask; - DIGITAL_PIN_BIT_8, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_8,//uint8_t pmca; - DIGITAL_PIN_PMCT_8,//uint8_t pmct; - DIGITAL_PIN_PM_8,//uint8_t pm; - DIGITAL_PIN_PU_8,//uint8_t pu; - DIGITAL_PIN_PIM_8,//uint8_t pim; - DIGITAL_PIN_POM_8,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_8),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_8),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_8),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_8),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_8),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_8),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_8),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_9 = -{ - DIGITAL_PIN_MASK_9, //uint8_t mask; - DIGITAL_PIN_BIT_9, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_9,//uint8_t pmca; - DIGITAL_PIN_PMCT_9,//uint8_t pmct; - DIGITAL_PIN_PM_9,//uint8_t pm; - DIGITAL_PIN_PU_9,//uint8_t pu; - DIGITAL_PIN_PIM_9,//uint8_t pim; - DIGITAL_PIN_POM_9,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_9),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_9),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_9),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_9),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_9),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_9),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_9),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_10 = -{ - DIGITAL_PIN_MASK_10, //uint8_t mask; - DIGITAL_PIN_BIT_10, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_10,//uint8_t pmca; - DIGITAL_PIN_PMCT_10,//uint8_t pmct; - DIGITAL_PIN_PM_10,//uint8_t pm; - DIGITAL_PIN_PU_10,//uint8_t pu; - DIGITAL_PIN_PIM_10,//uint8_t pim; - DIGITAL_PIN_POM_10,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_10),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_10),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_10),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_10),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_10),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_10),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_10),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_11 = -{ - DIGITAL_PIN_MASK_11, //uint8_t mask; - DIGITAL_PIN_BIT_11, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_11,//uint8_t pmca; - DIGITAL_PIN_PMCT_11,//uint8_t pmct; - DIGITAL_PIN_PM_11,//uint8_t pm; - DIGITAL_PIN_PU_11,//uint8_t pu; - DIGITAL_PIN_PIM_11,//uint8_t pim; - DIGITAL_PIN_POM_11,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_11),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_11),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_11),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_11),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_11),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_11),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_11),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_12 = -{ - DIGITAL_PIN_MASK_12, //uint8_t mask; - DIGITAL_PIN_BIT_12, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_12,//uint8_t pmca; - DIGITAL_PIN_PMCT_12,//uint8_t pmct; - DIGITAL_PIN_PM_12,//uint8_t pm; - DIGITAL_PIN_PU_12,//uint8_t pu; - DIGITAL_PIN_PIM_12,//uint8_t pim; - DIGITAL_PIN_POM_12,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_12),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_12),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_12),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_12),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_12),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_12),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_12),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_13 = -{ - DIGITAL_PIN_MASK_13, //uint8_t mask; - DIGITAL_PIN_BIT_13, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_13,//uint8_t pmca; - DIGITAL_PIN_PMCT_13,//uint8_t pmct; - DIGITAL_PIN_PM_13,//uint8_t pm; - DIGITAL_PIN_PU_13,//uint8_t pu; - DIGITAL_PIN_PIM_13,//uint8_t pim; - DIGITAL_PIN_POM_13,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_13),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_13),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_13),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_13),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_13),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_13),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_13),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_14 = -{ - DIGITAL_PIN_MASK_14, //uint8_t mask; - DIGITAL_PIN_BIT_14, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_14,//uint8_t pmca; - DIGITAL_PIN_PMCT_14,//uint8_t pmct; - DIGITAL_PIN_PM_14,//uint8_t pm; - DIGITAL_PIN_PU_14,//uint8_t pu; - DIGITAL_PIN_PIM_14,//uint8_t pim; - DIGITAL_PIN_POM_14,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_14),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_14),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_14),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_14),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_14),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_14),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_14),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_15 = -{ - DIGITAL_PIN_MASK_15, //uint8_t mask; - DIGITAL_PIN_BIT_15, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_15,//uint8_t pmca; - DIGITAL_PIN_PMCT_15,//uint8_t pmct; - DIGITAL_PIN_PM_15,//uint8_t pm; - DIGITAL_PIN_PU_15,//uint8_t pu; - DIGITAL_PIN_PIM_15,//uint8_t pim; - DIGITAL_PIN_POM_15,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_15),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_15),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_15),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_15),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_15),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_15),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_15),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_16 = -{ - DIGITAL_PIN_MASK_16, //uint8_t mask; - DIGITAL_PIN_BIT_16, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_16,//uint8_t pmca; - DIGITAL_PIN_PMCT_16,//uint8_t pmct; - DIGITAL_PIN_PM_16,//uint8_t pm; - DIGITAL_PIN_PU_16,//uint8_t pu; - DIGITAL_PIN_PIM_16,//uint8_t pim; - DIGITAL_PIN_POM_16,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_16),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_16),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_16),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_16),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_16),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_16),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_16),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_17 = -{ - DIGITAL_PIN_MASK_17, //uint8_t mask; - DIGITAL_PIN_BIT_17, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_17,//uint8_t pmca; - DIGITAL_PIN_PMCT_17,//uint8_t pmct; - DIGITAL_PIN_PM_17,//uint8_t pm; - DIGITAL_PIN_PU_17,//uint8_t pu; - DIGITAL_PIN_PIM_17,//uint8_t pim; - DIGITAL_PIN_POM_17,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_17),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_17),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_17),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_17),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_17),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_17),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_17),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_18 = -{ - DIGITAL_PIN_MASK_18, //uint8_t mask; - DIGITAL_PIN_BIT_18, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_18,//uint8_t pmca; - DIGITAL_PIN_PMCT_18,//uint8_t pmct; - DIGITAL_PIN_PM_18,//uint8_t pm; - DIGITAL_PIN_PU_18,//uint8_t pu; - DIGITAL_PIN_PIM_18,//uint8_t pim; - DIGITAL_PIN_POM_18,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_18),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_18),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_18),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_18),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_18),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_18),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_18),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_19 = -{ - DIGITAL_PIN_MASK_19, //uint8_t mask; - DIGITAL_PIN_BIT_19, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_19,//uint8_t pmca; - DIGITAL_PIN_PMCT_19,//uint8_t pmct; - DIGITAL_PIN_PM_19,//uint8_t pm; - DIGITAL_PIN_PU_19,//uint8_t pu; - DIGITAL_PIN_PIM_19,//uint8_t pim; - DIGITAL_PIN_POM_19,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_19),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_19),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_19),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_19),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_19),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_19),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_19),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_20 = -{ - DIGITAL_PIN_MASK_20, //uint8_t mask; - DIGITAL_PIN_BIT_20, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_20,//uint8_t pmca; - DIGITAL_PIN_PMCT_20,//uint8_t pmct; - DIGITAL_PIN_PM_20,//uint8_t pm; - DIGITAL_PIN_PU_20,//uint8_t pu; - DIGITAL_PIN_PIM_20,//uint8_t pim; - DIGITAL_PIN_POM_20,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_20),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_20),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_20),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_20),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_20),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_20),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_20),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_21 = -{ - DIGITAL_PIN_MASK_21, //uint8_t mask; - DIGITAL_PIN_BIT_21, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_21,//uint8_t pmca; - DIGITAL_PIN_PMCT_21,//uint8_t pmct; - DIGITAL_PIN_PM_21,//uint8_t pm; - DIGITAL_PIN_PU_21,//uint8_t pu; - DIGITAL_PIN_PIM_21,//uint8_t pim; - DIGITAL_PIN_POM_21,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_21),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_21),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_21),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_21),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_21),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_21),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_21),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_22 = -{ - DIGITAL_PIN_MASK_22, //uint8_t mask; - DIGITAL_PIN_BIT_22, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_22,//uint8_t pmca; - DIGITAL_PIN_PMCT_22,//uint8_t pmct; - DIGITAL_PIN_PM_22,//uint8_t pm; - DIGITAL_PIN_PU_22,//uint8_t pu; - DIGITAL_PIN_PIM_22,//uint8_t pim; - DIGITAL_PIN_POM_22,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_22),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_22),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_22),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_22),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_22),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_22),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_22),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_23 = -{ - DIGITAL_PIN_MASK_23, //uint8_t mask; - DIGITAL_PIN_BIT_23, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_23,//uint8_t pmca; - DIGITAL_PIN_PMCT_23,//uint8_t pmct; - DIGITAL_PIN_PM_23,//uint8_t pm; - DIGITAL_PIN_PU_23,//uint8_t pu; - DIGITAL_PIN_PIM_23,//uint8_t pim; - DIGITAL_PIN_POM_23,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_23),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_23),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_23),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_23),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_23),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_23),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_23),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_24 = -{ - DIGITAL_PIN_MASK_24, //uint8_t mask; - DIGITAL_PIN_BIT_24, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_24,//uint8_t pmca; - DIGITAL_PIN_PMCT_24,//uint8_t pmct; - DIGITAL_PIN_PM_24,//uint8_t pm; - DIGITAL_PIN_PU_24,//uint8_t pu; - DIGITAL_PIN_PIM_24,//uint8_t pim; - DIGITAL_PIN_POM_24,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_24),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_24),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_24),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_24),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_24),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_24),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_24),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_25 = -{ - DIGITAL_PIN_MASK_25, //uint8_t mask; - DIGITAL_PIN_BIT_25, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_25,//uint8_t pmca; - DIGITAL_PIN_PMCT_25,//uint8_t pmct; - DIGITAL_PIN_PM_25,//uint8_t pm; - DIGITAL_PIN_PU_25,//uint8_t pu; - DIGITAL_PIN_PIM_25,//uint8_t pim; - DIGITAL_PIN_POM_25,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_25),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_25),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_25),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_25),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_25),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_25),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_25),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_26 = -{ - DIGITAL_PIN_MASK_26, //uint8_t mask; - DIGITAL_PIN_BIT_26, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_26,//uint8_t pmca; - DIGITAL_PIN_PMCT_26,//uint8_t pmct; - DIGITAL_PIN_PM_26,//uint8_t pm; - DIGITAL_PIN_PU_26,//uint8_t pu; - DIGITAL_PIN_PIM_26,//uint8_t pim; - DIGITAL_PIN_POM_26,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_26),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_26),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_26),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_26),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_26),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_26),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_26),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_27 = -{ - DIGITAL_PIN_MASK_27, //uint8_t mask; - DIGITAL_PIN_BIT_27, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_27,//uint8_t pmca; - DIGITAL_PIN_PMCT_27,//uint8_t pmct; - DIGITAL_PIN_PM_27,//uint8_t pm; - DIGITAL_PIN_PU_27,//uint8_t pu; - DIGITAL_PIN_PIM_27,//uint8_t pim; - DIGITAL_PIN_POM_27,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_27),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_27),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_27),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_27),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_27),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_27),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_27),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_28 = -{ - DIGITAL_PIN_MASK_28, //uint8_t mask; - DIGITAL_PIN_BIT_28, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_28,//uint8_t pmca; - DIGITAL_PIN_PMCT_28,//uint8_t pmct; - DIGITAL_PIN_PM_28,//uint8_t pm; - DIGITAL_PIN_PU_28,//uint8_t pu; - DIGITAL_PIN_PIM_28,//uint8_t pim; - DIGITAL_PIN_POM_28,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_28),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_28),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_28),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_28),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_28),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_28),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_28),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_29 = -{ - DIGITAL_PIN_MASK_29, //uint8_t mask; - DIGITAL_PIN_BIT_29, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_29,//uint8_t pmca; - DIGITAL_PIN_PMCT_29,//uint8_t pmct; - DIGITAL_PIN_PM_29,//uint8_t pm; - DIGITAL_PIN_PU_29,//uint8_t pu; - DIGITAL_PIN_PIM_29,//uint8_t pim; - DIGITAL_PIN_POM_29,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_29),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_29),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_29),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_29),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_29),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_29),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_29),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_30 = -{ - DIGITAL_PIN_MASK_30, //uint8_t mask; - DIGITAL_PIN_BIT_30, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_30,//uint8_t pmca; - DIGITAL_PIN_PMCT_30,//uint8_t pmct; - DIGITAL_PIN_PM_30,//uint8_t pm; - DIGITAL_PIN_PU_30,//uint8_t pu; - DIGITAL_PIN_PIM_30,//uint8_t pim; - DIGITAL_PIN_POM_30,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_30),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_30),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_30),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_30),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_30),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_30),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_30),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_31 = -{ - DIGITAL_PIN_MASK_31, //uint8_t mask; - DIGITAL_PIN_BIT_31, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_31,//uint8_t pmca; - DIGITAL_PIN_PMCT_31,//uint8_t pmct; - DIGITAL_PIN_PM_31,//uint8_t pm; - DIGITAL_PIN_PU_31,//uint8_t pu; - DIGITAL_PIN_PIM_31,//uint8_t pim; - DIGITAL_PIN_POM_31,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_31),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_31),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_31),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_31),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_31),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_31),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_31),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_32 = -{ - DIGITAL_PIN_MASK_32, //uint8_t mask; - DIGITAL_PIN_BIT_32, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_32,//uint8_t pmca; - DIGITAL_PIN_PMCT_32,//uint8_t pmct; - DIGITAL_PIN_PM_32,//uint8_t pm; - DIGITAL_PIN_PU_32,//uint8_t pu; - DIGITAL_PIN_PIM_32,//uint8_t pim; - DIGITAL_PIN_POM_32,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_32),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_32),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_32),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_32),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_32),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_32),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_32),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_33 = -{ - DIGITAL_PIN_MASK_33, //uint8_t mask; - DIGITAL_PIN_BIT_33, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_33,//uint8_t pmca; - DIGITAL_PIN_PMCT_33,//uint8_t pmct; - DIGITAL_PIN_PM_33,//uint8_t pm; - DIGITAL_PIN_PU_33,//uint8_t pu; - DIGITAL_PIN_PIM_33,//uint8_t pim; - DIGITAL_PIN_POM_33,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_33),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_33),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_33),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_33),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_33),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_33),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_33),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_34 = -{ - DIGITAL_PIN_MASK_34, //uint8_t mask; - DIGITAL_PIN_BIT_34, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_34,//uint8_t pmca; - DIGITAL_PIN_PMCT_34,//uint8_t pmct; - DIGITAL_PIN_PM_34,//uint8_t pm; - DIGITAL_PIN_PU_34,//uint8_t pu; - DIGITAL_PIN_PIM_34,//uint8_t pim; - DIGITAL_PIN_POM_34,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_34),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_34),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_34),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_34),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_34),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_34),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_34),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_35 = -{ - DIGITAL_PIN_MASK_35, //uint8_t mask; - DIGITAL_PIN_BIT_35, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_35,//uint8_t pmca; - DIGITAL_PIN_PMCT_35,//uint8_t pmct; - DIGITAL_PIN_PM_35,//uint8_t pm; - DIGITAL_PIN_PU_35,//uint8_t pu; - DIGITAL_PIN_PIM_35,//uint8_t pim; - DIGITAL_PIN_POM_35,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_35),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_35),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_35),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_35),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_35),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_35),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_35),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_36 = -{ - DIGITAL_PIN_MASK_36, //uint8_t mask; - DIGITAL_PIN_BIT_36, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_36,//uint8_t pmca; - DIGITAL_PIN_PMCT_36,//uint8_t pmct; - DIGITAL_PIN_PM_36,//uint8_t pm; - DIGITAL_PIN_PU_36,//uint8_t pu; - DIGITAL_PIN_PIM_36,//uint8_t pim; - DIGITAL_PIN_POM_36,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_36),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_36),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_36),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_36),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_36),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_36),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_36),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_37 = -{ - DIGITAL_PIN_MASK_37, //uint8_t mask; - DIGITAL_PIN_BIT_37, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_37,//uint8_t pmca; - DIGITAL_PIN_PMCT_37,//uint8_t pmct; - DIGITAL_PIN_PM_37,//uint8_t pm; - DIGITAL_PIN_PU_37,//uint8_t pu; - DIGITAL_PIN_PIM_37,//uint8_t pim; - DIGITAL_PIN_POM_37,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_37),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_37),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_37),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_37),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_37),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_37),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_37),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_38 = -{ - DIGITAL_PIN_MASK_38, //uint8_t mask; - DIGITAL_PIN_BIT_38, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_38,//uint8_t pmca; - DIGITAL_PIN_PMCT_38,//uint8_t pmct; - DIGITAL_PIN_PM_38,//uint8_t pm; - DIGITAL_PIN_PU_38,//uint8_t pu; - DIGITAL_PIN_PIM_38,//uint8_t pim; - DIGITAL_PIN_POM_38,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_38),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_38),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_38),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_38),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_38),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_38),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_38),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_39 = -{ - DIGITAL_PIN_MASK_39, //uint8_t mask; - DIGITAL_PIN_BIT_39, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_39,//uint8_t pmca; - DIGITAL_PIN_PMCT_39,//uint8_t pmct; - DIGITAL_PIN_PM_39,//uint8_t pm; - DIGITAL_PIN_PU_39,//uint8_t pu; - DIGITAL_PIN_PIM_39,//uint8_t pim; - DIGITAL_PIN_POM_39,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_39),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_39),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_39),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_39),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_39),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_39),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_39),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_40 = -{ - DIGITAL_PIN_MASK_40, //uint8_t mask; - DIGITAL_PIN_BIT_40, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_40,//uint8_t pmca; - DIGITAL_PIN_PMCT_40,//uint8_t pmct; - DIGITAL_PIN_PM_40,//uint8_t pm; - DIGITAL_PIN_PU_40,//uint8_t pu; - DIGITAL_PIN_PIM_40,//uint8_t pim; - DIGITAL_PIN_POM_40,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_40),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_40),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_40),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_40),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_40),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_40),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_40),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_41 = -{ - DIGITAL_PIN_MASK_41, //uint8_t mask; - DIGITAL_PIN_BIT_41, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_41,//uint8_t pmca; - DIGITAL_PIN_PMCT_41,//uint8_t pmct; - DIGITAL_PIN_PM_41,//uint8_t pm; - DIGITAL_PIN_PU_41,//uint8_t pu; - DIGITAL_PIN_PIM_41,//uint8_t pim; - DIGITAL_PIN_POM_41,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_41),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_41),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_41),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_41),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_41),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_41),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_41),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_42 = -{ - DIGITAL_PIN_MASK_42, //uint8_t mask; - DIGITAL_PIN_BIT_42, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_42,//uint8_t pmca; - DIGITAL_PIN_PMCT_42,//uint8_t pmct; - DIGITAL_PIN_PM_42,//uint8_t pm; - DIGITAL_PIN_PU_42,//uint8_t pu; - DIGITAL_PIN_PIM_42,//uint8_t pim; - DIGITAL_PIN_POM_42,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_42),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_42),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_42),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_42),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_42),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_42),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_42),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_43 = -{ - DIGITAL_PIN_MASK_43, //uint8_t mask; - DIGITAL_PIN_BIT_43, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_43,//uint8_t pmca; - DIGITAL_PIN_PMCT_43,//uint8_t pmct; - DIGITAL_PIN_PM_43,//uint8_t pm; - DIGITAL_PIN_PU_43,//uint8_t pu; - DIGITAL_PIN_PIM_43,//uint8_t pim; - DIGITAL_PIN_POM_43,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_43),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_43),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_43),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_43),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_43),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_43),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_43),//volatile uint8_t* portModeControlTRegisterAddr; -}; -/* -const PinTableType pinTable_44 = -{ - DIGITAL_PIN_MASK_44, //uint8_t mask; - DIGITAL_PIN_BIT_44, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_44,//uint8_t pmca; - DIGITAL_PIN_PMCT_44,//uint8_t pmct; - DIGITAL_PIN_PM_44,//uint8_t pm; - DIGITAL_PIN_PU_44,//uint8_t pu; - DIGITAL_PIN_PIM_44,//uint8_t pim; - DIGITAL_PIN_POM_44,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_44),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_44),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_44),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_44),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_44),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_44),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_44),//volatile uint8_t* portModeControlTRegisterAddr; -}; - -const PinTableType pinTable_45 = -{ - DIGITAL_PIN_MASK_45, //uint8_t mask; - DIGITAL_PIN_BIT_45, //uint8_t bit; - 0,//uint8_t timer; - DIGITAL_PIN_PMCA_45,//uint8_t pmca; - DIGITAL_PIN_PMCT_45,//uint8_t pmct; - DIGITAL_PIN_PM_45,//uint8_t pm; - DIGITAL_PIN_PU_45,//uint8_t pu; - DIGITAL_PIN_PIM_45,//uint8_t pim; - DIGITAL_PIN_POM_45,//uint8_t pom; - getPortModeRegisterAddr(DIGITAL_PIN_45),//volatile uint8_t* portModeRegisterAddr; - getPortPullUpRegisterAddr(DIGITAL_PIN_45),//volatile uint8_t* portPullUpRegisterAddr; - getPortInputModeRegisterAddr(DIGITAL_PIN_45),//volatile uint8_t* portInputModeRegisterAddr; - getPortOutputModeRegisterAddr(DIGITAL_PIN_45),//volatile uint8_t* portOutputModeRegisterAddr; - getPortRegisterAddr(DIGITAL_PIN_45),//volatile uint8_t* portRegisterAddr; - getPortModeControlARegisterAddr(DIGITAL_PIN_45),//volatile uint8_t* portModeControlARegisterAddr; - getPortModeControlTRegisterAddr(DIGITAL_PIN_45),//volatile uint8_t* portModeControlTRegisterAddr; -}; -*/ - - -const PinTableType * const pinTablelist[NUM_DIGITAL_PINS] = -{ - &pinTable_0, - &pinTable_1, - &pinTable_2, - &pinTable_3, - &pinTable_4, - &pinTable_5, - &pinTable_6, - &pinTable_7, - &pinTable_8, - &pinTable_9, - &pinTable_10, - &pinTable_11, - &pinTable_12, - &pinTable_13, - &pinTable_14, - &pinTable_15, - &pinTable_16, - &pinTable_17, - &pinTable_18, - &pinTable_19, - &pinTable_20, - &pinTable_21, - &pinTable_22, - &pinTable_23, - &pinTable_24, - &pinTable_25, - &pinTable_26, - &pinTable_27, - &pinTable_28, - &pinTable_29, - &pinTable_30, - &pinTable_31, - &pinTable_32, - &pinTable_33, - &pinTable_34, - &pinTable_35, - &pinTable_36, - &pinTable_37, - &pinTable_38, - &pinTable_39, - &pinTable_40, - &pinTable_41, - &pinTable_42, - &pinTable_43, -// &pinTable_44, -// &pinTable_45, -}; - +#include +#include + +const PinTableType pinTable_0 = +{ + DIGITAL_PIN_MASK_0, //uint8_t mask; + DIGITAL_PIN_BIT_0, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_0,//uint8_t pmca; + DIGITAL_PIN_PMCT_0,//uint8_t pmct; + DIGITAL_PIN_PM_0,//uint8_t pm; + DIGITAL_PIN_PU_0,//uint8_t pu; + DIGITAL_PIN_PIM_0,//uint8_t pim; + DIGITAL_PIN_POM_0,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_0),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_0),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_0),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_0),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_0),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_0),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_0),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_1 = +{ + DIGITAL_PIN_MASK_1, //uint8_t mask; + DIGITAL_PIN_BIT_1, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_1,//uint8_t pmca; + DIGITAL_PIN_PMCT_1,//uint8_t pmct; + DIGITAL_PIN_PM_1,//uint8_t pm; + DIGITAL_PIN_PU_1,//uint8_t pu; + DIGITAL_PIN_PIM_1,//uint8_t pim; + DIGITAL_PIN_POM_1,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_1),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_1),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_1),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_1),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_1),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_1),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_1),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_2 = +{ + DIGITAL_PIN_MASK_2, //uint8_t mask; + DIGITAL_PIN_BIT_2, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_2,//uint8_t pmca; + DIGITAL_PIN_PMCT_2,//uint8_t pmct; + DIGITAL_PIN_PM_2,//uint8_t pm; + DIGITAL_PIN_PU_2,//uint8_t pu; + DIGITAL_PIN_PIM_2,//uint8_t pim; + DIGITAL_PIN_POM_2,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_2),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_2),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_2),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_2),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_2),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_2),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_2),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_3 = +{ + DIGITAL_PIN_MASK_3, //uint8_t mask; + DIGITAL_PIN_BIT_3, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_3,//uint8_t pmca; + DIGITAL_PIN_PMCT_3,//uint8_t pmct; + DIGITAL_PIN_PM_3,//uint8_t pm; + DIGITAL_PIN_PU_3,//uint8_t pu; + DIGITAL_PIN_PIM_3,//uint8_t pim; + DIGITAL_PIN_POM_3,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_3),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_3),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_3),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_3),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_3),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_3),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_3),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_4 = +{ + DIGITAL_PIN_MASK_4, //uint8_t mask; + DIGITAL_PIN_BIT_4, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_4,//uint8_t pmca; + DIGITAL_PIN_PMCT_4,//uint8_t pmct; + DIGITAL_PIN_PM_4,//uint8_t pm; + DIGITAL_PIN_PU_4,//uint8_t pu; + DIGITAL_PIN_PIM_4,//uint8_t pim; + DIGITAL_PIN_POM_4,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_4),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_4),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_4),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_4),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_4),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_4),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_4),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_5 = +{ + DIGITAL_PIN_MASK_5, //uint8_t mask; + DIGITAL_PIN_BIT_5, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_5,//uint8_t pmca; + DIGITAL_PIN_PMCT_5,//uint8_t pmct; + DIGITAL_PIN_PM_5,//uint8_t pm; + DIGITAL_PIN_PU_5,//uint8_t pu; + DIGITAL_PIN_PIM_5,//uint8_t pim; + DIGITAL_PIN_POM_5,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_5),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_5),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_5),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_5),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_5),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_5),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_5),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_6 = +{ + DIGITAL_PIN_MASK_6, //uint8_t mask; + DIGITAL_PIN_BIT_6, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_6,//uint8_t pmca; + DIGITAL_PIN_PMCT_6,//uint8_t pmct; + DIGITAL_PIN_PM_6,//uint8_t pm; + DIGITAL_PIN_PU_6,//uint8_t pu; + DIGITAL_PIN_PIM_6,//uint8_t pim; + DIGITAL_PIN_POM_6,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_6),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_6),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_6),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_6),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_6),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_6),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_6),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_7 = +{ + DIGITAL_PIN_MASK_7, //uint8_t mask; + DIGITAL_PIN_BIT_7, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_7,//uint8_t pmca; + DIGITAL_PIN_PMCT_7,//uint8_t pmct; + DIGITAL_PIN_PM_7,//uint8_t pm; + DIGITAL_PIN_PU_7,//uint8_t pu; + DIGITAL_PIN_PIM_7,//uint8_t pim; + DIGITAL_PIN_POM_7,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_7),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_7),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_7),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_7),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_7),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_7),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_7),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_8 = +{ + DIGITAL_PIN_MASK_8, //uint8_t mask; + DIGITAL_PIN_BIT_8, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_8,//uint8_t pmca; + DIGITAL_PIN_PMCT_8,//uint8_t pmct; + DIGITAL_PIN_PM_8,//uint8_t pm; + DIGITAL_PIN_PU_8,//uint8_t pu; + DIGITAL_PIN_PIM_8,//uint8_t pim; + DIGITAL_PIN_POM_8,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_8),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_8),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_8),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_8),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_8),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_8),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_8),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_9 = +{ + DIGITAL_PIN_MASK_9, //uint8_t mask; + DIGITAL_PIN_BIT_9, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_9,//uint8_t pmca; + DIGITAL_PIN_PMCT_9,//uint8_t pmct; + DIGITAL_PIN_PM_9,//uint8_t pm; + DIGITAL_PIN_PU_9,//uint8_t pu; + DIGITAL_PIN_PIM_9,//uint8_t pim; + DIGITAL_PIN_POM_9,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_9),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_9),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_9),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_9),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_9),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_9),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_9),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_10 = +{ + DIGITAL_PIN_MASK_10, //uint8_t mask; + DIGITAL_PIN_BIT_10, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_10,//uint8_t pmca; + DIGITAL_PIN_PMCT_10,//uint8_t pmct; + DIGITAL_PIN_PM_10,//uint8_t pm; + DIGITAL_PIN_PU_10,//uint8_t pu; + DIGITAL_PIN_PIM_10,//uint8_t pim; + DIGITAL_PIN_POM_10,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_10),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_10),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_10),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_10),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_10),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_10),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_10),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_11 = +{ + DIGITAL_PIN_MASK_11, //uint8_t mask; + DIGITAL_PIN_BIT_11, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_11,//uint8_t pmca; + DIGITAL_PIN_PMCT_11,//uint8_t pmct; + DIGITAL_PIN_PM_11,//uint8_t pm; + DIGITAL_PIN_PU_11,//uint8_t pu; + DIGITAL_PIN_PIM_11,//uint8_t pim; + DIGITAL_PIN_POM_11,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_11),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_11),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_11),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_11),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_11),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_11),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_11),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_12 = +{ + DIGITAL_PIN_MASK_12, //uint8_t mask; + DIGITAL_PIN_BIT_12, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_12,//uint8_t pmca; + DIGITAL_PIN_PMCT_12,//uint8_t pmct; + DIGITAL_PIN_PM_12,//uint8_t pm; + DIGITAL_PIN_PU_12,//uint8_t pu; + DIGITAL_PIN_PIM_12,//uint8_t pim; + DIGITAL_PIN_POM_12,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_12),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_12),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_12),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_12),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_12),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_12),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_12),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_13 = +{ + DIGITAL_PIN_MASK_13, //uint8_t mask; + DIGITAL_PIN_BIT_13, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_13,//uint8_t pmca; + DIGITAL_PIN_PMCT_13,//uint8_t pmct; + DIGITAL_PIN_PM_13,//uint8_t pm; + DIGITAL_PIN_PU_13,//uint8_t pu; + DIGITAL_PIN_PIM_13,//uint8_t pim; + DIGITAL_PIN_POM_13,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_13),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_13),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_13),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_13),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_13),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_13),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_13),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_14 = +{ + DIGITAL_PIN_MASK_14, //uint8_t mask; + DIGITAL_PIN_BIT_14, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_14,//uint8_t pmca; + DIGITAL_PIN_PMCT_14,//uint8_t pmct; + DIGITAL_PIN_PM_14,//uint8_t pm; + DIGITAL_PIN_PU_14,//uint8_t pu; + DIGITAL_PIN_PIM_14,//uint8_t pim; + DIGITAL_PIN_POM_14,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_14),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_14),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_14),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_14),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_14),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_14),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_14),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_15 = +{ + DIGITAL_PIN_MASK_15, //uint8_t mask; + DIGITAL_PIN_BIT_15, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_15,//uint8_t pmca; + DIGITAL_PIN_PMCT_15,//uint8_t pmct; + DIGITAL_PIN_PM_15,//uint8_t pm; + DIGITAL_PIN_PU_15,//uint8_t pu; + DIGITAL_PIN_PIM_15,//uint8_t pim; + DIGITAL_PIN_POM_15,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_15),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_15),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_15),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_15),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_15),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_15),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_15),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_16 = +{ + DIGITAL_PIN_MASK_16, //uint8_t mask; + DIGITAL_PIN_BIT_16, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_16,//uint8_t pmca; + DIGITAL_PIN_PMCT_16,//uint8_t pmct; + DIGITAL_PIN_PM_16,//uint8_t pm; + DIGITAL_PIN_PU_16,//uint8_t pu; + DIGITAL_PIN_PIM_16,//uint8_t pim; + DIGITAL_PIN_POM_16,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_16),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_16),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_16),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_16),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_16),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_16),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_16),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_17 = +{ + DIGITAL_PIN_MASK_17, //uint8_t mask; + DIGITAL_PIN_BIT_17, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_17,//uint8_t pmca; + DIGITAL_PIN_PMCT_17,//uint8_t pmct; + DIGITAL_PIN_PM_17,//uint8_t pm; + DIGITAL_PIN_PU_17,//uint8_t pu; + DIGITAL_PIN_PIM_17,//uint8_t pim; + DIGITAL_PIN_POM_17,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_17),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_17),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_17),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_17),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_17),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_17),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_17),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_18 = +{ + DIGITAL_PIN_MASK_18, //uint8_t mask; + DIGITAL_PIN_BIT_18, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_18,//uint8_t pmca; + DIGITAL_PIN_PMCT_18,//uint8_t pmct; + DIGITAL_PIN_PM_18,//uint8_t pm; + DIGITAL_PIN_PU_18,//uint8_t pu; + DIGITAL_PIN_PIM_18,//uint8_t pim; + DIGITAL_PIN_POM_18,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_18),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_18),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_18),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_18),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_18),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_18),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_18),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_19 = +{ + DIGITAL_PIN_MASK_19, //uint8_t mask; + DIGITAL_PIN_BIT_19, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_19,//uint8_t pmca; + DIGITAL_PIN_PMCT_19,//uint8_t pmct; + DIGITAL_PIN_PM_19,//uint8_t pm; + DIGITAL_PIN_PU_19,//uint8_t pu; + DIGITAL_PIN_PIM_19,//uint8_t pim; + DIGITAL_PIN_POM_19,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_19),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_19),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_19),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_19),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_19),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_19),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_19),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_20 = +{ + DIGITAL_PIN_MASK_20, //uint8_t mask; + DIGITAL_PIN_BIT_20, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_20,//uint8_t pmca; + DIGITAL_PIN_PMCT_20,//uint8_t pmct; + DIGITAL_PIN_PM_20,//uint8_t pm; + DIGITAL_PIN_PU_20,//uint8_t pu; + DIGITAL_PIN_PIM_20,//uint8_t pim; + DIGITAL_PIN_POM_20,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_20),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_20),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_20),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_20),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_20),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_20),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_20),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_21 = +{ + DIGITAL_PIN_MASK_21, //uint8_t mask; + DIGITAL_PIN_BIT_21, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_21,//uint8_t pmca; + DIGITAL_PIN_PMCT_21,//uint8_t pmct; + DIGITAL_PIN_PM_21,//uint8_t pm; + DIGITAL_PIN_PU_21,//uint8_t pu; + DIGITAL_PIN_PIM_21,//uint8_t pim; + DIGITAL_PIN_POM_21,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_21),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_21),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_21),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_21),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_21),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_21),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_21),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_22 = +{ + DIGITAL_PIN_MASK_22, //uint8_t mask; + DIGITAL_PIN_BIT_22, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_22,//uint8_t pmca; + DIGITAL_PIN_PMCT_22,//uint8_t pmct; + DIGITAL_PIN_PM_22,//uint8_t pm; + DIGITAL_PIN_PU_22,//uint8_t pu; + DIGITAL_PIN_PIM_22,//uint8_t pim; + DIGITAL_PIN_POM_22,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_22),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_22),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_22),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_22),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_22),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_22),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_22),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_23 = +{ + DIGITAL_PIN_MASK_23, //uint8_t mask; + DIGITAL_PIN_BIT_23, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_23,//uint8_t pmca; + DIGITAL_PIN_PMCT_23,//uint8_t pmct; + DIGITAL_PIN_PM_23,//uint8_t pm; + DIGITAL_PIN_PU_23,//uint8_t pu; + DIGITAL_PIN_PIM_23,//uint8_t pim; + DIGITAL_PIN_POM_23,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_23),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_23),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_23),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_23),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_23),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_23),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_23),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_24 = +{ + DIGITAL_PIN_MASK_24, //uint8_t mask; + DIGITAL_PIN_BIT_24, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_24,//uint8_t pmca; + DIGITAL_PIN_PMCT_24,//uint8_t pmct; + DIGITAL_PIN_PM_24,//uint8_t pm; + DIGITAL_PIN_PU_24,//uint8_t pu; + DIGITAL_PIN_PIM_24,//uint8_t pim; + DIGITAL_PIN_POM_24,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_24),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_24),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_24),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_24),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_24),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_24),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_24),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_25 = +{ + DIGITAL_PIN_MASK_25, //uint8_t mask; + DIGITAL_PIN_BIT_25, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_25,//uint8_t pmca; + DIGITAL_PIN_PMCT_25,//uint8_t pmct; + DIGITAL_PIN_PM_25,//uint8_t pm; + DIGITAL_PIN_PU_25,//uint8_t pu; + DIGITAL_PIN_PIM_25,//uint8_t pim; + DIGITAL_PIN_POM_25,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_25),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_25),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_25),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_25),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_25),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_25),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_25),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_26 = +{ + DIGITAL_PIN_MASK_26, //uint8_t mask; + DIGITAL_PIN_BIT_26, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_26,//uint8_t pmca; + DIGITAL_PIN_PMCT_26,//uint8_t pmct; + DIGITAL_PIN_PM_26,//uint8_t pm; + DIGITAL_PIN_PU_26,//uint8_t pu; + DIGITAL_PIN_PIM_26,//uint8_t pim; + DIGITAL_PIN_POM_26,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_26),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_26),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_26),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_26),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_26),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_26),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_26),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_27 = +{ + DIGITAL_PIN_MASK_27, //uint8_t mask; + DIGITAL_PIN_BIT_27, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_27,//uint8_t pmca; + DIGITAL_PIN_PMCT_27,//uint8_t pmct; + DIGITAL_PIN_PM_27,//uint8_t pm; + DIGITAL_PIN_PU_27,//uint8_t pu; + DIGITAL_PIN_PIM_27,//uint8_t pim; + DIGITAL_PIN_POM_27,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_27),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_27),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_27),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_27),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_27),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_27),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_27),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_28 = +{ + DIGITAL_PIN_MASK_28, //uint8_t mask; + DIGITAL_PIN_BIT_28, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_28,//uint8_t pmca; + DIGITAL_PIN_PMCT_28,//uint8_t pmct; + DIGITAL_PIN_PM_28,//uint8_t pm; + DIGITAL_PIN_PU_28,//uint8_t pu; + DIGITAL_PIN_PIM_28,//uint8_t pim; + DIGITAL_PIN_POM_28,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_28),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_28),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_28),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_28),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_28),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_28),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_28),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_29 = +{ + DIGITAL_PIN_MASK_29, //uint8_t mask; + DIGITAL_PIN_BIT_29, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_29,//uint8_t pmca; + DIGITAL_PIN_PMCT_29,//uint8_t pmct; + DIGITAL_PIN_PM_29,//uint8_t pm; + DIGITAL_PIN_PU_29,//uint8_t pu; + DIGITAL_PIN_PIM_29,//uint8_t pim; + DIGITAL_PIN_POM_29,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_29),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_29),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_29),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_29),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_29),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_29),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_29),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_30 = +{ + DIGITAL_PIN_MASK_30, //uint8_t mask; + DIGITAL_PIN_BIT_30, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_30,//uint8_t pmca; + DIGITAL_PIN_PMCT_30,//uint8_t pmct; + DIGITAL_PIN_PM_30,//uint8_t pm; + DIGITAL_PIN_PU_30,//uint8_t pu; + DIGITAL_PIN_PIM_30,//uint8_t pim; + DIGITAL_PIN_POM_30,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_30),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_30),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_30),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_30),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_30),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_30),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_30),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_31 = +{ + DIGITAL_PIN_MASK_31, //uint8_t mask; + DIGITAL_PIN_BIT_31, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_31,//uint8_t pmca; + DIGITAL_PIN_PMCT_31,//uint8_t pmct; + DIGITAL_PIN_PM_31,//uint8_t pm; + DIGITAL_PIN_PU_31,//uint8_t pu; + DIGITAL_PIN_PIM_31,//uint8_t pim; + DIGITAL_PIN_POM_31,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_31),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_31),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_31),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_31),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_31),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_31),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_31),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_32 = +{ + DIGITAL_PIN_MASK_32, //uint8_t mask; + DIGITAL_PIN_BIT_32, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_32,//uint8_t pmca; + DIGITAL_PIN_PMCT_32,//uint8_t pmct; + DIGITAL_PIN_PM_32,//uint8_t pm; + DIGITAL_PIN_PU_32,//uint8_t pu; + DIGITAL_PIN_PIM_32,//uint8_t pim; + DIGITAL_PIN_POM_32,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_32),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_32),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_32),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_32),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_32),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_32),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_32),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_33 = +{ + DIGITAL_PIN_MASK_33, //uint8_t mask; + DIGITAL_PIN_BIT_33, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_33,//uint8_t pmca; + DIGITAL_PIN_PMCT_33,//uint8_t pmct; + DIGITAL_PIN_PM_33,//uint8_t pm; + DIGITAL_PIN_PU_33,//uint8_t pu; + DIGITAL_PIN_PIM_33,//uint8_t pim; + DIGITAL_PIN_POM_33,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_33),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_33),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_33),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_33),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_33),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_33),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_33),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_34 = +{ + DIGITAL_PIN_MASK_34, //uint8_t mask; + DIGITAL_PIN_BIT_34, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_34,//uint8_t pmca; + DIGITAL_PIN_PMCT_34,//uint8_t pmct; + DIGITAL_PIN_PM_34,//uint8_t pm; + DIGITAL_PIN_PU_34,//uint8_t pu; + DIGITAL_PIN_PIM_34,//uint8_t pim; + DIGITAL_PIN_POM_34,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_34),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_34),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_34),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_34),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_34),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_34),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_34),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_35 = +{ + DIGITAL_PIN_MASK_35, //uint8_t mask; + DIGITAL_PIN_BIT_35, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_35,//uint8_t pmca; + DIGITAL_PIN_PMCT_35,//uint8_t pmct; + DIGITAL_PIN_PM_35,//uint8_t pm; + DIGITAL_PIN_PU_35,//uint8_t pu; + DIGITAL_PIN_PIM_35,//uint8_t pim; + DIGITAL_PIN_POM_35,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_35),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_35),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_35),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_35),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_35),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_35),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_35),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_36 = +{ + DIGITAL_PIN_MASK_36, //uint8_t mask; + DIGITAL_PIN_BIT_36, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_36,//uint8_t pmca; + DIGITAL_PIN_PMCT_36,//uint8_t pmct; + DIGITAL_PIN_PM_36,//uint8_t pm; + DIGITAL_PIN_PU_36,//uint8_t pu; + DIGITAL_PIN_PIM_36,//uint8_t pim; + DIGITAL_PIN_POM_36,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_36),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_36),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_36),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_36),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_36),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_36),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_36),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_37 = +{ + DIGITAL_PIN_MASK_37, //uint8_t mask; + DIGITAL_PIN_BIT_37, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_37,//uint8_t pmca; + DIGITAL_PIN_PMCT_37,//uint8_t pmct; + DIGITAL_PIN_PM_37,//uint8_t pm; + DIGITAL_PIN_PU_37,//uint8_t pu; + DIGITAL_PIN_PIM_37,//uint8_t pim; + DIGITAL_PIN_POM_37,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_37),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_37),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_37),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_37),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_37),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_37),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_37),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_38 = +{ + DIGITAL_PIN_MASK_38, //uint8_t mask; + DIGITAL_PIN_BIT_38, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_38,//uint8_t pmca; + DIGITAL_PIN_PMCT_38,//uint8_t pmct; + DIGITAL_PIN_PM_38,//uint8_t pm; + DIGITAL_PIN_PU_38,//uint8_t pu; + DIGITAL_PIN_PIM_38,//uint8_t pim; + DIGITAL_PIN_POM_38,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_38),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_38),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_38),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_38),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_38),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_38),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_38),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_39 = +{ + DIGITAL_PIN_MASK_39, //uint8_t mask; + DIGITAL_PIN_BIT_39, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_39,//uint8_t pmca; + DIGITAL_PIN_PMCT_39,//uint8_t pmct; + DIGITAL_PIN_PM_39,//uint8_t pm; + DIGITAL_PIN_PU_39,//uint8_t pu; + DIGITAL_PIN_PIM_39,//uint8_t pim; + DIGITAL_PIN_POM_39,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_39),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_39),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_39),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_39),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_39),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_39),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_39),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_40 = +{ + DIGITAL_PIN_MASK_40, //uint8_t mask; + DIGITAL_PIN_BIT_40, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_40,//uint8_t pmca; + DIGITAL_PIN_PMCT_40,//uint8_t pmct; + DIGITAL_PIN_PM_40,//uint8_t pm; + DIGITAL_PIN_PU_40,//uint8_t pu; + DIGITAL_PIN_PIM_40,//uint8_t pim; + DIGITAL_PIN_POM_40,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_40),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_40),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_40),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_40),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_40),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_40),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_40),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_41 = +{ + DIGITAL_PIN_MASK_41, //uint8_t mask; + DIGITAL_PIN_BIT_41, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_41,//uint8_t pmca; + DIGITAL_PIN_PMCT_41,//uint8_t pmct; + DIGITAL_PIN_PM_41,//uint8_t pm; + DIGITAL_PIN_PU_41,//uint8_t pu; + DIGITAL_PIN_PIM_41,//uint8_t pim; + DIGITAL_PIN_POM_41,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_41),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_41),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_41),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_41),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_41),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_41),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_41),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_42 = +{ + DIGITAL_PIN_MASK_42, //uint8_t mask; + DIGITAL_PIN_BIT_42, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_42,//uint8_t pmca; + DIGITAL_PIN_PMCT_42,//uint8_t pmct; + DIGITAL_PIN_PM_42,//uint8_t pm; + DIGITAL_PIN_PU_42,//uint8_t pu; + DIGITAL_PIN_PIM_42,//uint8_t pim; + DIGITAL_PIN_POM_42,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_42),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_42),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_42),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_42),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_42),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_42),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_42),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_43 = +{ + DIGITAL_PIN_MASK_43, //uint8_t mask; + DIGITAL_PIN_BIT_43, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_43,//uint8_t pmca; + DIGITAL_PIN_PMCT_43,//uint8_t pmct; + DIGITAL_PIN_PM_43,//uint8_t pm; + DIGITAL_PIN_PU_43,//uint8_t pu; + DIGITAL_PIN_PIM_43,//uint8_t pim; + DIGITAL_PIN_POM_43,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_43),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_43),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_43),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_43),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_43),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_43),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_43),//volatile uint8_t* portModeControlTRegisterAddr; +}; +/* +const PinTableType pinTable_44 = +{ + DIGITAL_PIN_MASK_44, //uint8_t mask; + DIGITAL_PIN_BIT_44, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_44,//uint8_t pmca; + DIGITAL_PIN_PMCT_44,//uint8_t pmct; + DIGITAL_PIN_PM_44,//uint8_t pm; + DIGITAL_PIN_PU_44,//uint8_t pu; + DIGITAL_PIN_PIM_44,//uint8_t pim; + DIGITAL_PIN_POM_44,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_44),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_44),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_44),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_44),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_44),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_44),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_44),//volatile uint8_t* portModeControlTRegisterAddr; +}; + +const PinTableType pinTable_45 = +{ + DIGITAL_PIN_MASK_45, //uint8_t mask; + DIGITAL_PIN_BIT_45, //uint8_t bit; + 0,//uint8_t timer; + DIGITAL_PIN_PMCA_45,//uint8_t pmca; + DIGITAL_PIN_PMCT_45,//uint8_t pmct; + DIGITAL_PIN_PM_45,//uint8_t pm; + DIGITAL_PIN_PU_45,//uint8_t pu; + DIGITAL_PIN_PIM_45,//uint8_t pim; + DIGITAL_PIN_POM_45,//uint8_t pom; + getPortModeRegisterAddr(DIGITAL_PIN_45),//volatile uint8_t* portModeRegisterAddr; + getPortPullUpRegisterAddr(DIGITAL_PIN_45),//volatile uint8_t* portPullUpRegisterAddr; + getPortInputModeRegisterAddr(DIGITAL_PIN_45),//volatile uint8_t* portInputModeRegisterAddr; + getPortOutputModeRegisterAddr(DIGITAL_PIN_45),//volatile uint8_t* portOutputModeRegisterAddr; + getPortRegisterAddr(DIGITAL_PIN_45),//volatile uint8_t* portRegisterAddr; + getPortModeControlARegisterAddr(DIGITAL_PIN_45),//volatile uint8_t* portModeControlARegisterAddr; + getPortModeControlTRegisterAddr(DIGITAL_PIN_45),//volatile uint8_t* portModeControlTRegisterAddr; +}; +*/ + + +const PinTableType * const pinTablelist[NUM_DIGITAL_PINS] = +{ + &pinTable_0, + &pinTable_1, + &pinTable_2, + &pinTable_3, + &pinTable_4, + &pinTable_5, + &pinTable_6, + &pinTable_7, + &pinTable_8, + &pinTable_9, + &pinTable_10, + &pinTable_11, + &pinTable_12, + &pinTable_13, + &pinTable_14, + &pinTable_15, + &pinTable_16, + &pinTable_17, + &pinTable_18, + &pinTable_19, + &pinTable_20, + &pinTable_21, + &pinTable_22, + &pinTable_23, + &pinTable_24, + &pinTable_25, + &pinTable_26, + &pinTable_27, + &pinTable_28, + &pinTable_29, + &pinTable_30, + &pinTable_31, + &pinTable_32, + &pinTable_33, + &pinTable_34, + &pinTable_35, + &pinTable_36, + &pinTable_37, + &pinTable_38, + &pinTable_39, + &pinTable_40, + &pinTable_41, + &pinTable_42, + &pinTable_43, +// &pinTable_44, +// &pinTable_45, +}; + diff --git a/variants/g22-fpb-48p/pintable.h b/variants/g22-fpb-48p/pintable.h index 6c32c3a..02b3532 100644 --- a/variants/g22-fpb-48p/pintable.h +++ b/variants/g22-fpb-48p/pintable.h @@ -1,62 +1,62 @@ -/* - pintable.h - Copyright (c) 2015 Nozomu Fujita. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ -#ifndef _PINTABLE_H_ -#define _PINTABLE_H_ - -// #include -#include -#include -// #include - -#ifdef __cplusplus -extern "C" { -#endif - -#define getPortModeRegisterAddr(port) ((volatile uint8_t*)(ADDR_PORT_MODE_REG + port)) /*!< Base Address of Port Mode Register */ -#define getPortPullUpRegisterAddr(port) ((volatile uint8_t*)(ADDR_PORT_PULL_UP_REG + port)) /*!< Base Address of Port Pull-up Register */ -#define getPortInputModeRegisterAddr(port) ((volatile uint8_t*)(ADDR_PORT_IN_MODE_REG + port)) /*!< Base Address of Port Input Mode Register */ -#define getPortOutputModeRegisterAddr(port) ((volatile uint8_t*)(ADDR_PORT_OUT_MODE_REG + port)) /*!< Base Address of Port Output Mode Register */ -#define getPortRegisterAddr(port) ((volatile uint8_t*)(ADDR_PORT_REG + port)) /*!< Base Address of Port Register */ -#define getPortModeControlARegisterAddr(port) ((volatile uint8_t*)(ADDR_PORT_MODE_CONTROL_A_REG + port)) /*!< Base Address of Port Mode Control-A Register */ -#define getPortModeControlTRegisterAddr(port) ((volatile uint8_t*)(ADDR_PORT_MODE_CONTROL_T_REG + port)) /*!< Base Address of Port Mode Control-T Register */ - -typedef struct { - uint8_t mask; - uint8_t bit; - uint8_t timer; - uint8_t pmca; - uint8_t pmct; - uint8_t pm; - uint8_t pu; - uint8_t pim; - uint8_t pom; - volatile uint8_t* portModeRegisterAddr; - volatile uint8_t* portPullUpRegisterAddr; - volatile uint8_t* portInputModeRegisterAddr; - volatile uint8_t* portOutputModeRegisterAddr; - volatile uint8_t* portRegisterAddr; - volatile uint8_t* portModeControlARegisterAddr; - volatile uint8_t* portModeControlTRegisterAddr; -} PinTableType; - -#ifdef __cplusplus -}; -#endif - -#endif/*_PINTABLE_H_*/ +/* + pintable.h + Copyright (c) 2015 Nozomu Fujita. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#ifndef _PINTABLE_H_ +#define _PINTABLE_H_ + +// #include +#include +#include +// #include + +#ifdef __cplusplus +extern "C" { +#endif + +#define getPortModeRegisterAddr(port) ((volatile uint8_t*)(ADDR_PORT_MODE_REG + port)) /*!< Base Address of Port Mode Register */ +#define getPortPullUpRegisterAddr(port) ((volatile uint8_t*)(ADDR_PORT_PULL_UP_REG + port)) /*!< Base Address of Port Pull-up Register */ +#define getPortInputModeRegisterAddr(port) ((volatile uint8_t*)(ADDR_PORT_IN_MODE_REG + port)) /*!< Base Address of Port Input Mode Register */ +#define getPortOutputModeRegisterAddr(port) ((volatile uint8_t*)(ADDR_PORT_OUT_MODE_REG + port)) /*!< Base Address of Port Output Mode Register */ +#define getPortRegisterAddr(port) ((volatile uint8_t*)(ADDR_PORT_REG + port)) /*!< Base Address of Port Register */ +#define getPortModeControlARegisterAddr(port) ((volatile uint8_t*)(ADDR_PORT_MODE_CONTROL_A_REG + port)) /*!< Base Address of Port Mode Control-A Register */ +#define getPortModeControlTRegisterAddr(port) ((volatile uint8_t*)(ADDR_PORT_MODE_CONTROL_T_REG + port)) /*!< Base Address of Port Mode Control-T Register */ + +typedef struct { + uint8_t mask; + uint8_t bit; + uint8_t timer; + uint8_t pmca; + uint8_t pmct; + uint8_t pm; + uint8_t pu; + uint8_t pim; + uint8_t pom; + volatile uint8_t* portModeRegisterAddr; + volatile uint8_t* portPullUpRegisterAddr; + volatile uint8_t* portInputModeRegisterAddr; + volatile uint8_t* portOutputModeRegisterAddr; + volatile uint8_t* portRegisterAddr; + volatile uint8_t* portModeControlARegisterAddr; + volatile uint8_t* portModeControlTRegisterAddr; +} PinTableType; + +#ifdef __cplusplus +}; +#endif + +#endif/*_PINTABLE_H_*/ diff --git a/variants/g22-fpb-48p/r_mmc_sfr.h b/variants/g22-fpb-48p/r_mmc_sfr.h index ee964c4..3dace7e 100644 --- a/variants/g22-fpb-48p/r_mmc_sfr.h +++ b/variants/g22-fpb-48p/r_mmc_sfr.h @@ -1,1901 +1,1901 @@ -/*""FILE COMMENT""******************************************************************* -* File Name : r_mmc_sfr.h -* Version : 1.00 -* Device(s) : RL78/G23 -* compiler : CC-RL -* H/W Platform : R7F100Gxx -* Description : MMC driver SFR common definitions -************************************************************************************* -* History : DD.MM.YYYY Version Description -* : 04.06.2021 Ver1.00 -*""FILE COMMENT END""***************************************************************/ -#ifndef __MMC_SFR_H__ -#define __MMC_SFR_H__ -#include "r_mmc_user_config.h" -#include "r_cg_macrodriver.h" - -/************************************************************************************************/ -/* Definitions */ -/************************************************************************************************/ -/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ -/* Do not change the following data. */ -/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ -#define _MMC_DRIVER_CPU_MODULE_NAME_ "RL78G23_CSI" - -//#define CAT_2(a,b) a##b -//#define CAT(a,b) CAT_2(a,b) - -/*----------------------------------------------------------------------------------------------*/ -/* Define the control port. */ -/*----------------------------------------------------------------------------------------------*/ - -#if (MMC_SAU_UNIT == 0) -#if (MMC_SAU_CHANNEL == 0) -#define MMC_CSI_UNIT 0 -#define MMC_CSI_CHANNEL 0 - -#if (MMC_CSI_PIN == 'A') -#define MMC_DATAI_PORTNO 1 /* MMC DataIn Port No. */ -#define MMC_DATAI_BITNO 1 /* MMC DataIn Bit No. */ -#define MMC_CLK_PORTNO 1 /* MMC CLK Port No. */ -#define MMC_CLK_BITNO 0 /* MMC CLK Bit No. */ -#define MMC_DATAO_PORTNO 1 /* MMC DataOut Port No. */ -#define MMC_DATAO_BITNO 2 /* MMC DataOut Bit No. */ - -/*----------- PMCEmn register value -----------*/ -#define MMC_PMCE1_TBL (uint8_t)0xF8 -/* 11111000B */ /* PMCEmn setting */ -/* |||||||+-------- PMCE10 : Set to 0 */ -/* ||||||+--------- PMCE11 : Set to 0 */ -/* |||||+---------- PMCE12 : Set to 0 */ -/* +++++----------- Reserved : Set to 1 */ - -/*----------- PFOE1n register value -----------*/ -#define MMC_PFOE1_TBL (uint8_t)0x05 -/* 00000101B */ /* PFOE1n setting */ -/* |||||||+-------- PFOE10 (P12) : Set to 0 */ -/* ||||||+--------- Reserved : Set to 1 */ -/* |||||+---------- PFOE12 (P10) : Set to 0 */ -/* +++++----------- Reserved : Set to 1 */ - -#elif (MMC_CSI_PIN == 'B') -#define MMC_DATAI_PORTNO 1 /* MMC DataIn Port No. */ -#define MMC_DATAI_BITNO 6 /* MMC DataIn Bit No. */ -#define MMC_CLK_PORTNO 5 /* MMC CLK Port No. */ -#define MMC_CLK_BITNO 5 /* MMC CLK Bit No. */ -#define MMC_DATAO_PORTNO 1 /* MMC DataOut Port No. */ -#define MMC_DATAO_BITNO 7 /* MMC DataOut Bit No. */ - -/*----------- PMCEmn register value -----------*/ -#define MMC_PMCE1_TBL (uint8_t)0x3F -/* 00111111B */ /* PMCEmn setting */ -/* ||++++++-------- Reserved : Set to 1 */ -/* |+-------------- PMCE16 : Set to 0 */ -/* +--------------- PMCE17 : Set to 0 */ - -/*----------- CCDE register value -----------*/ -#define MMC_CCDE_TBL (uint8_t)0xFC -/* 11111100B */ /* CCDE setting */ -/* |||||||+-------- CCDE00 (P16) : Set to 0 */ -/* ||||||+--------- CCDE01 (P17) : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ - -/*----------- PFOE1n register value -----------*/ -#define MMC_PFOE1_TBL (uint8_t)0x05 -/* 00000101B */ /* PFOE1n setting */ -/* |||||||+-------- PFOE10 (P17) : Set to 1 */ -/* ||||||+--------- Reserved : Set to 0 */ -/* |||||+---------- PFOE12 (P55) : Set to 1 */ -/* +++++----------- Reserved : Set to 0 */ - -#endif /* MMC_CSI_PIN */ - -#define MMC_CSI_SIR_CLEAR (uint8_t)0x03 -/* 00000011B */ /* SIRms setting */ -/* |||||||+-------- OVCTmn : Clear */ -/* ||||||+--------- PECTmn : Clear */ -/* ++++++---------- Reserved : Set to 0 */ - -#define MMC_CLK_SO_BITNO 8 -#define MMC_DATAO_SO_BITNO 0 - -#elif (MMC_SAU_CHANNEL == 1) -#define MMC_CSI_UNIT 0 -#define MMC_CSI_CHANNEL 1 - -#define MMC_DATAI_PORTNO 7 /* MMC DataIn Port No. */ -#define MMC_DATAI_BITNO 4 /* MMC DataIn Bit No. */ -#define MMC_CLK_PORTNO 7 /* MMC CLK Port No. */ -#define MMC_CLK_BITNO 5 /* MMC CLK Bit No. */ -#define MMC_DATAO_PORTNO 7 /* MMC DataOut Port No. */ -#define MMC_DATAO_BITNO 3 /* MMC DataOut Bit No. */ - -#define MMC_CSI_SIR_CLEAR (uint8_t)0x07 -/* 00000111B */ /* SIRms setting */ -/* |||||||+-------- OVCTmn : Clear */ -/* ||||||+--------- PECTmn : Clear */ -/* |||||+---------- FECTmn : Clear */ -/* +++++----------- Reserved : Set to 0 */ - -/*----------- PMCTxx register value -----------*/ -#define MMC_PMCT7_TBL (uint8_t)0xC7 -/* 11000111B */ /* PMCTmn setting */ -/* |||||+++-------- Reserved : Set to 1 */ -/* ||||+----------- PMCT73 : Set to 0 */ -/* |||+------------ PMCT74 : Set to 0 */ -/* ||+------------- PMCT75 : Set to 0 */ -/* +++++----------- Reserved : Set to 1 */ - -#define MMC_CLK_SO_BITNO 9 -#define MMC_DATAO_SO_BITNO 1 - -#elif (MMC_SAU_CHANNEL == 2) -#define MMC_CSI_UNIT 1 -#define MMC_CSI_CHANNEL 0 - -#define MMC_DATAI_PORTNO 0 /* MMC DataIn Port No. */ -#define MMC_DATAI_BITNO 3 /* MMC DataIn Bit No. */ -#define MMC_CLK_PORTNO 0 /* MMC CLK Port No. */ -#define MMC_CLK_BITNO 4 /* MMC CLK Bit No. */ -#define MMC_DATAO_PORTNO 0 /* MMC DataOut Port No. */ -#define MMC_DATAO_BITNO 2 /* MMC DataOut Bit No. */ - -/*----------- PMCAxx register value -----------*/ -#define MMC_PMCA0_TBL (uint8_t)0xF3 -/* 11110011B */ /* PMCAmn setting */ -/* ||||||++-------- Reserved : Set to 1 */ -/* |||||+---------- PMCA02 : Set to 0 */ -/* ||||++---------- PMCA03 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ - -/*----------- PMCTxx register value -----------*/ -#define MMC_PMCT0_TBL (uint8_t)0xF3 -/* 11110011B */ /* PMCTmn setting */ -/* ||||||++-------- Reserved : Set to 1 */ -/* |||||+---------- PMCT02 : Set to 0 */ -/* ||||++---------- PMCT03 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ - -#define MMC_CSI_SIR_CLEAR (uint8_t)0x03 -/* 00000011B */ /* SIRms setting */ -/* |||||||+-------- OVCTmn : Clear */ -/* ||||||+--------- PECTmn : Clear */ -/* ++++++---------- Reserved : Set to 0 */ - -#define MMC_CLK_SO_BITNO 10 -#define MMC_DATAO_SO_BITNO 2 - -#elif (MMC_SAU_CHANNEL == 3) -#define MMC_CSI_UNIT 1 -#define MMC_CSI_CHANNEL 1 - -#define MMC_DATAI_PORTNO 5 /* MMC DataIn Port No. */ -#define MMC_DATAI_BITNO 0 /* MMC DataIn Bit No. */ -#define MMC_CLK_PORTNO 3 /* MMC CLK Port No. */ -#define MMC_CLK_BITNO 0 /* MMC CLK Bit No. */ -#define MMC_DATAO_PORTNO 5 /* MMC DataOut Port No. */ -#define MMC_DATAO_BITNO 1 /* MMC DataOut Bit No. */ - -/*----------- PMCTxx register value -----------*/ -#define MMC_PMCT3_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCTmn setting */ -/* |||||||+-------- PMCT30 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ - -/*----------- PMCTxx register value -----------*/ -#define MMC_PMCT5_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCTmn setting */ -/* |||||||+-------- PMCT50 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ - -/*----------- PMCExx register value -----------*/ -#define MMC_PMCE5_TBL (uint8_t)0xFC -/* 11111100B */ /* PMCEmn setting */ -/* |||||||+-------- PMCE50 : Set to 0 */ -/* ||||||+--------- PMCE51 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ - -/*----------- CCDE register value -----------*/ -#define MMC_CCDE_TBL (uint8_t)0xF3 -/* 11110011B */ /* CCDE setting */ -/* ||||||++-------- Reserved : Set to 1 */ -/* |||||+---------- CCDE02 (P51) : Set to 0 */ -/* ||||+----------- CCDE03 (P50) : Set to 0 */ -/* ++++------------ Reserved : Set to 1 */ - -#define MMC_CSI_SIR_CLEAR (uint8_t)0x07 -/* 00000111B */ /* SIRms setting */ -/* |||||||+-------- OVCTmn : Clear */ -/* ||||||+--------- PECTmn : Clear */ -/* |||||+---------- FECTmn : Clear */ -/* +++++----------- Reserved : Set to 0 */ - -#define MMC_CLK_SO_BITNO 11 -#define MMC_DATAO_SO_BITNO 3 - -#endif /* #if (MMC_SAU_CHANNEL == x) */ - -#elif (MMC_SAU_UNIT == 1) -#if (MMC_SAU_CHANNEL == 0) -#define MMC_CSI_UNIT 2 -#define MMC_CSI_CHANNEL 0 - -#define MMC_DATAI_PORTNO 1 /* MMC DataIn Port No. */ -#define MMC_DATAI_BITNO 4 /* MMC DataIn Bit No. */ -#define MMC_CLK_PORTNO 1 /* MMC CLK Port No. */ -#define MMC_CLK_BITNO 5 /* MMC CLK Bit No. */ -#define MMC_DATAO_PORTNO 1 /* MMC DataOut Port No. */ -#define MMC_DATAO_BITNO 3 /* MMC DataOut Bit No. */ - -#define MMC_CSI_SIR_CLEAR (uint8_t)0x03 -/* 00000011B */ /* SIRms setting */ -/* |||||||+-------- OVCTmn : Clear */ -/* ||||||+--------- PECTmn : Clear */ -/* ++++++---------- Reserved : Set to 0 */ - -/*----------- PMCAmn register value -----------*/ -#define MMC_PMCA1_TBL (uint8_t)0xF7 -/* 11110111B */ /* PMCAmn setting */ -/* |||||+++-------- Reserved : Set to 1 */ -/* ||||+----------- PMCA13 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ - -/*----------- PMCExx register value -----------*/ -#define MMC_PMCE1_TBL (uint8_t)0xC7 -/* 11000111B */ /* PMCEmn setting */ -/* |||||+++-------- Reserved : Set to 1 */ -/* ||||+----------- PMCE13 : Set to 0 */ -/* |||+------------ PMCE14 : Set to 0 */ -/* ||+------------- PMCE15 : Set to 0 */ -/* ++-------------- Reserved : Set to 1 */ - -#define MMC_CLK_SO_BITNO 8 -#define MMC_DATAO_SO_BITNO 0 - -#elif (MMC_SAU_CHANNEL == 1) -#define MMC_CSI_UNIT 2 -#define MMC_CSI_CHANNEL 1 - -#define MMC_DATAI_PORTNO 7 /* MMC DataIn Port No. */ -#define MMC_DATAI_BITNO 1 /* MMC DataIn Bit No. */ -#define MMC_CLK_PORTNO 7 /* MMC CLK Port No. */ -#define MMC_CLK_BITNO 0 /* MMC CLK Bit No. */ -#define MMC_DATAO_PORTNO 7 /* MMC DataOut Port No. */ -#define MMC_DATAO_BITNO 2 /* MMC DataOut Bit No. */ - -#define MMC_CSI_SIR_CLEAR (uint8_t)0x07 -/* 00000111B */ /* SIRms setting */ -/* |||||||+-------- OVCTmn : Clear */ -/* ||||||+--------- PECTmn : Clear */ -/* |||||+---------- FECTmn : Clear */ -/* +++++----------- Reserved : Set to 0 */ - -/*----------- PMCTxx register value -----------*/ -#define MMC_PMCT7_TBL (uint8_t)0xF8 -/* 11111000B */ /* PMCTmn setting */ -/* |||||||+-------- PMCT70 : Set to 0 */ -/* ||||||+--------- PMCT71 : Set to 0 */ -/* |||||+---------- PMCT72 : Set to 0 */ -/* +++++----------- Reserved : Set to 1 */ - -#define MMC_CLK_SO_BITNO 9 -#define MMC_DATAO_SO_BITNO 1 - - -#endif /* MMC_SAU_CHANNEL */ -#endif /* MMC_SAU_UNIT */ - -/*----------- PMCAxx register value -----------*/ -#ifndef MMC_PMCA0_TBL -#define MMC_PMCA0_TBL (uint8_t)0xFF -#endif /* MMC_PMCA0_TBL */ - -#ifndef MMC_PMCA1_TBL -#define MMC_PMCA1_TBL (uint8_t)0xFF -#endif /* MMC_PMCA1_TBL */ - -#define MMC_PMCA2_TBL (uint8_t)0xFF -#define MMC_PMCA12_TBL (uint8_t)0xFF -#define MMC_PMCA14_TBL (uint8_t)0xFF - -/*----------- PMCTxx register value -----------*/ -#ifndef MMC_PMCT0_TBL -#define MMC_PMCT0_TBL (uint8_t)0xFF -#endif /* MMC_PMCT0_TBL */ -#ifndef MMC_PMCT3_TBL -#define MMC_PMCT3_TBL (uint8_t)0xFF -#endif /* MMC_PMCT3_TBL */ -#ifndef MMC_PMCT5_TBL -#define MMC_PMCT5_TBL (uint8_t)0xFF -#endif /* MMC_PMCT5_TBL */ -#ifndef MMC_PMCT7_TBL -#define MMC_PMCT7_TBL (uint8_t)0xFF -#endif /* MMC_PMCT7_TBL */ -#define MMC_PMCT2_TBL (uint8_t)0xFF -#define MMC_PMCT6_TBL (uint8_t)0xFF - -/*----------- PMCExx register value -----------*/ -#ifndef MMC_PMCE1_TBL -#define MMC_PMCE1_TBL (uint8_t)0xFF -#endif /* MMC_PMCE1_TBL */ -#ifndef MMC_PMCE5_TBL -#define MMC_PMCE5_TBL (uint8_t)0xFF -#endif /* MMC_PMCE5_TBL */ -#define MMC_PMCE0_TBL (uint8_t)0xFF -#define MMC_PMCE6_TBL (uint8_t)0xFF - -/*----------- CCDE register value -----------*/ -#ifndef MMC_CCDE_TBL -#define MMC_CCDE_TBL (uint8_t)0xFF -#endif /* MMC_CCDE_TBL */ - -/*----------- PFOE1 register value -----------*/ -#ifndef MMC_PFOE1_TBL -#define MMC_PFOE1_TBL (uint8_t)0x00 -#endif /* MMC_PFOE1_TBL */ - -/*----------- ISC register value -----------*/ -#if (MMC_CSI_UNIT == 0) -#if (MMC_CSI_CHANNEL == 0) -#define MMC_ISC_TBL (uint8_t)0xE3 -/* 11100011B */ /* ISC setting */ -/* ||||||++-------- Reserved : Set to 1 */ -/* |||||+---------- ISC2 : Set to 0 */ -/* ||||+----------- ISC3 : Set to 0 */ -/* |||+------------ ISC4 : Set to 0 */ -/* +++------------- Reserved : Set to 1 */ -#elif (MMC_CSI_CHANNEL == 1) -#define MMC_ISC_TBL (uint8_t)0x1F -/* 00011111B */ /* ISC setting */ -/* |||+++++-------- Reserved : Set to 1 */ -/* ||+------------- ISC2 : Set to 0 */ -/* |+-------------- ISC3 : Set to 0 */ -/* +--------------- ISC4 : Set to 0 */ -#endif /* MMC_CSI_CHANNEL */ -#else -#define MMC_ISC_TBL (uint8_t)0xFF -#endif /* MMC_CSI_UNIT */ - -/*----------- PMCAxx (CS0) register value -----------*/ -#if (MMC_CS0_PORTNO == 0) -#if (MMC_CS0_BITNO == 0) -#define MMC_CS0_PMCA0_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCAmn setting */ -/* |||||||+-------- PMCA00 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 1) -#define MMC_CS0_PMCA0_TBL (uint8_t)0xFD -/* 11111101B */ /* PMCAmn setting */ -/* |||||||+-------- Reserved : Set to 1 */ -/* ||||||+--------- PMCA01 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 2) -#define MMC_CS0_PMCA0_TBL (uint8_t)0xFB -/* 11111011B */ /* PMCAmn setting */ -/* ||||||++-------- Reserved : Set to 1 */ -/* |||||+---------- PMCA02 : Set to 0 */ -/* +++++----------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 3) -#define MMC_CS0_PMCA0_TBL (uint8_t)0xF7 -/* 11110111B */ /* PMCAmn setting */ -/* |||||+++-------- Reserved : Set to 1 */ -/* ||||+----------- PMCA03 : Set to 0 */ -/* ++++------------ Reserved : Set to 1 */ -#endif /* MMC_CS0_BITNO */ - -#elif (MMC_CS0_PORTNO == 1) -#if (MMC_CS0_BITNO == 3) -#define MMC_CS0_PMCA1_TBL (uint8_t)0xF7 -/* 11110111B */ /* PMCAmn setting */ -/* |||||+++-------- Reserved : Set to 1 */ -/* ||||+----------- PMCA13 : Set to 0 */ -/* ++++------------ Reserved : Set to 1 */ -#endif /* MMC_CS0_BITNO */ - -#elif (MMC_CS0_PORTNO == 2) -#if (MMC_CS0_BITNO == 0) -#define MMC_CS0_PMCA2_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCAmn setting */ -/* |||||||+-------- PMCA00 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 1) -#define MMC_CS0_PMCA2_TBL (uint8_t)0xFD -/* 11111101B */ /* PMCAmn setting */ -/* |||||||+-------- Reserved : Set to 1 */ -/* ||||||+--------- PMCA21 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 2) -#define MMC_CS0_PMCA2_TBL (uint8_t)0xFB -/* 11111011B */ /* PMCAmn setting */ -/* ||||||++-------- Reserved : Set to 1 */ -/* |||||+---------- PMCA22 : Set to 0 */ -/* +++++----------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 3) -#define MMC_CS0_PMCA2_TBL (uint8_t)0xF7 -/* 11110111B */ /* PMCAmn setting */ -/* |||||+++-------- Reserved : Set to 1 */ -/* ||||+----------- PMCA23 : Set to 0 */ -/* ++++------------ Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 4) -#define MMC_CS0_PMCA2_TBL (uint8_t)0xEF -/* 11101111B */ /* PMCAmn setting */ -/* ||||++++-------- Reserved : Set to 1 */ -/* |||+------------ PMCA24 : Set to 0 */ -/* +++------------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 5) -#define MMC_CS0_PMCA2_TBL (uint8_t)0xDF -/* 11011111B */ /* PMCAmn setting */ -/* |||+++++-------- Reserved : Set to 1 */ -/* ||+------------- PMCA25 : Set to 0 */ -/* ++-------------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 6) -#define MMC_CS0_PMCA2_TBL (uint8_t)0xBF -/* 10111111B */ /* PMCAmn setting */ -/* ||++++++-------- Reserved : Set to 1 */ -/* |+-------------- PMCA26 : Set to 0 */ -/* +--------------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 7) -#define MMC_CS0_PMCA2_TBL (uint8_t)0x7F -/* 01111111B */ /* PMCAmn setting */ -/* |+++++++-------- Reserved : Set to 1 */ -/* +--------------- PMCA27 : Set to 0 */ -#endif /* MMC_CS0_BITNO */ - -#elif (MMC_CS0_PORTNO == 12) -#if (MMC_CS0_BITNO == 0) -#define MMC_CS0_PMCA12_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCAmn setting */ -/* |||||||+-------- PMCA120 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#endif /* MMC_CS0_BITNO */ - -#elif (MMC_CS0_PORTNO == 14) -#if (MMC_CS0_BITNO == 7) -#define MMC_CS0_PMCA14_TBL (uint8_t)0x7F -/* 01111111B */ /* PMCAmn setting */ -/* |+++++++-------- Reserved : Set to 1 */ -/* +--------------- PMCA147 : Set to 0 */ -#endif /* MMC_CS0_BITNO */ -#endif /* MMC_CS0_PORTNO */ - -#ifndef MMC_CS0_PMCA0_TBL -#define MMC_CS0_PMCA0_TBL (uint8_t)0xFF -#endif /* MMC_CS0_PMCA0_TBL */ -#ifndef MMC_CS0_PMCA1_TBL -#define MMC_CS0_PMCA1_TBL (uint8_t)0xFF -#endif /* MMC_CS0_PMCA1_TBL */ -#ifndef MMC_CS0_PMCA2_TBL -#define MMC_CS0_PMCA2_TBL (uint8_t)0xFF -#endif /* MMC_CS0_PMCA2_TBL */ -#ifndef MMC_CS0_PMCA12_TBL -#define MMC_CS0_PMCA12_TBL (uint8_t)0xFF -#endif /* MMC_CS0_PMCA12_TBL */ -#ifndef MMC_CS0_PMCA14_TBL -#define MMC_CS0_PMCA14_TBL (uint8_t)0xFF -#endif /* MMC_CS0_PMCA14_TBL */ - -/*----------- PMCTxx (CS0) register value -----------*/ -#if (MMC_CS0_PORTNO == 0) -#if (MMC_CS0_BITNO == 0) -#define MMC_CS0_PMCT0_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCTmn setting */ -/* |||||||+-------- PMCT00 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 1) -#define MMC_CS0_PMCT0_TBL (uint8_t)0xFD -/* 11111101B */ /* PMCTmn setting */ -/* |||||||+-------- Reserved : Set to 1 */ -/* ||||||+--------- PMCT01 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 2) -#define MMC_CS0_PMCT0_TBL (uint8_t)0xFB -/* 11111011B */ /* PMCTmn setting */ -/* ||||||++-------- Reserved : Set to 1 */ -/* |||||+---------- PMCT02 : Set to 0 */ -/* +++++----------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 3) -#define MMC_CS0_PMCT0_TBL (uint8_t)0xF7 -/* 11110111B */ /* PMCTmn setting */ -/* |||||+++-------- Reserved : Set to 1 */ -/* ||||+----------- PMCT03 : Set to 0 */ -/* ++++------------ Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 5) -#define MMC_CS0_PMCT0_TBL (uint8_t)0xDF -/* 11011111B */ /* PMCTmn setting */ -/* |||+++++-------- Reserved : Set to 1 */ -/* ||+------------- PMCT05 : Set to 0 */ -/* ++-------------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 6) -#define MMC_CS0_PMCT0_TBL (uint8_t)0xBF -/* 10111111B */ /* PMCTmn setting */ -/* ||++++++-------- Reserved : Set to 1 */ -/* |+-------------- PMCT06 : Set to 0 */ -/* +--------------- Reserved : Set to 1 */ -#endif /* MMC_CS0_BITNO */ - -#elif (MMC_CS0_PORTNO == 2) -#if (MMC_CS0_BITNO == 2) -#define MMC_CS0_PMCT2_TBL (uint8_t)0xFB -/* 11111011B */ /* PMCTmn setting */ -/* ||||||++-------- Reserved : Set to 1 */ -/* |||||+---------- PMCT22 : Set to 0 */ -/* +++++----------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 3) -#define MMC_CS0_PMCT2_TBL (uint8_t)0xF7 -/* 11110111B */ /* PMCTmn setting */ -/* |||||+++-------- Reserved : Set to 1 */ -/* ||||+----------- PMCT23 : Set to 0 */ -/* ++++------------ Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 4) -#define MMC_CS0_PMCT2_TBL (uint8_t)0xEF -/* 11101111B */ /* PMCTmn setting */ -/* ||||++++-------- Reserved : Set to 1 */ -/* |||+------------ PMCT24 : Set to 0 */ -/* +++------------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 5) -#define MMC_CS0_PMCT2_TBL (uint8_t)0xDF -/* 11011111B */ /* PMCTmn setting */ -/* |||+++++-------- Reserved : Set to 1 */ -/* ||+------------- PMCT25 : Set to 0 */ -/* ++-------------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 6) -#define MMC_CS0_PMCT2_TBL (uint8_t)0xBF -/* 10111111B */ /* PMCTmn setting */ -/* ||++++++-------- Reserved : Set to 1 */ -/* |+-------------- PMCT26 : Set to 0 */ -/* +--------------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 7) -#define MMC_CS0_PMCT2_TBL (uint8_t)0x7F -/* 01111111B */ /* PMCTmn setting */ -/* |+++++++-------- Reserved : Set to 1 */ -/* +--------------- PMCT27 : Set to 0 */ -#endif /* MMC_CS0_BITNO */ - -#elif (MMC_CS0_PORTNO == 3) -#if (MMC_CS0_BITNO == 0) -#define MMC_CS0_PMCT3_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCTmn setting */ -/* |||||||+-------- PMCT30 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 1) -#define MMC_CS0_PMCT3_TBL (uint8_t)0xFD -/* 11111101B */ /* PMCTmn setting */ -/* |||||||+-------- Reserved : Set to 1 */ -/* ||||||+--------- PMCT31 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ -#endif /* MMC_CS0_BITNO */ - -#elif (MMC_CS0_PORTNO == 5) -#if (MMC_CS0_BITNO == 0) -#define MMC_CS0_PMCT5_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCTmn setting */ -/* |||||||+-------- PMCT50 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#endif /* MMC_CS0_BITNO */ - -#elif (MMC_CS0_PORTNO == 6) -#if (MMC_CS0_BITNO == 4) -#define MMC_CS0_PMCT6_TBL (uint8_t)0xEF -/* 11101111B */ /* PMCTmn setting */ -/* ||||++++-------- Reserved : Set to 1 */ -/* |||+------------ PMCT64 : Set to 0 */ -/* +++------------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 5) -#define MMC_CS0_PMCT6_TBL (uint8_t)0xDF -/* 11011111B */ /* PMCTmn setting */ -/* |||+++++-------- Reserved : Set to 1 */ -/* ||+------------- PMCT65 : Set to 0 */ -/* ++-------------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 6) -#define MMC_CS0_PMCT6_TBL (uint8_t)0xBF -/* 10111111B */ /* PMCTmn setting */ -/* ||++++++-------- Reserved : Set to 1 */ -/* |+-------------- PMCT66 : Set to 0 */ -/* +--------------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 7) -#define MMC_CS0_PMCT6_TBL (uint8_t)0x7F -/* 01111111B */ /* PMCTmn setting */ -/* |+++++++-------- Reserved : Set to 1 */ -/* +--------------- PMCT67 : Set to 0 */ -#endif /* MMC_CS0_BITNO */ - -#elif (MMC_CS0_PORTNO == 7) -#if (MMC_CS0_BITNO == 0) -#define MMC_CS0_PMCT7_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCTmn setting */ -/* |||||||+-------- PMCT70 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 1) -#define MMC_CS0_PMCT7_TBL (uint8_t)0xFD -/* 11111101B */ /* PMCTmn setting */ -/* |||||||+-------- Reserved : Set to 1 */ -/* ||||||+--------- PMCT71 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 2) -#define MMC_CS0_PMCT7_TBL (uint8_t)0xFB -/* 11111011B */ /* PMCTmn setting */ -/* ||||||++-------- Reserved : Set to 1 */ -/* |||||+---------- PMCT72 : Set to 0 */ -/* +++++----------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 3) -#define MMC_CS0_PMCT7_TBL (uint8_t)0xF7 -/* 11110111B */ /* PMCTmn setting */ -/* |||||+++-------- Reserved : Set to 1 */ -/* ||||+----------- PMCT73 : Set to 0 */ -/* ++++------------ Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 4) -#define MMC_CS0_PMCT7_TBL (uint8_t)0xEF -/* 11101111B */ /* PMCTmn setting */ -/* ||||++++-------- Reserved : Set to 1 */ -/* |||+------------ PMCT74 : Set to 0 */ -/* +++------------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 5) -#define MMC_CS0_PMCT7_TBL (uint8_t)0xDF -/* 11011111B */ /* PMCTmn setting */ -/* |||+++++-------- Reserved : Set to 1 */ -/* ||+------------- PMCT75 : Set to 0 */ -/* ++-------------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 6) -#define MMC_CS0_PMCT7_TBL (uint8_t)0xBF -/* 10111111B */ /* PMCTmn setting */ -/* ||++++++-------- Reserved : Set to 1 */ -/* |+-------------- PMCT76 : Set to 0 */ -/* +--------------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 7) -#define MMC_CS0_PMCT7_TBL (uint8_t)0x7F -/* 01111111B */ /* PMCTmn setting */ -/* |+++++++-------- Reserved : Set to 1 */ -/* +--------------- PMCT77 : Set to 0 */ -#endif /* MMC_CS0_BITNO */ -#endif /* MMC_CS0_PORTNO */ - -#ifndef MMC_CS0_PMCT0_TBL -#define MMC_CS0_PMCT0_TBL (uint8_t)0xFF -#endif /* MMC_CS0_PMCT0_TBL */ -#ifndef MMC_CS0_PMCT2_TBL -#define MMC_CS0_PMCT2_TBL (uint8_t)0xFF -#endif /* MMC_CS0_PMCT2_TBL */ -#ifndef MMC_CS0_PMCT3_TBL -#define MMC_CS0_PMCT3_TBL (uint8_t)0xFF -#endif /* MMC_CS0_PMCT3_TBL */ -#ifndef MMC_CS0_PMCT5_TBL -#define MMC_CS0_PMCT5_TBL (uint8_t)0xFF -#endif /* MMC_CS0_PMCT5_TBL */ -#ifndef MMC_CS0_PMCT6_TBL -#define MMC_CS0_PMCT6_TBL (uint8_t)0xFF -#endif /* MMC_CS0_PMCT6_TBL */ -#ifndef MMC_CS0_PMCT7_TBL -#define MMC_CS0_PMCT7_TBL (uint8_t)0xFF -#endif /* MMC_CS0_PMCT7_TBL */ - -/*----------- PMCExx (CS0) register value -----------*/ -#if (MMC_CS0_PORTNO == 0) -#if (MMC_CS0_BITNO == 1) -#define MMC_CS0_PMCE0_TBL (uint8_t)0xFD -/* 11111101B */ /* PMCEmn setting */ -/* |||||||+-------- Reserved : Set to 1 */ -/* ||||||+--------- PMCE01 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ -#endif /* MMC_CS0_BITNO */ - -#elif (MMC_CS0_PORTNO == 1) -#if (MMC_CS0_BITNO == 0) -#define MMC_CS0_PMCE1_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCEmn setting */ -/* |||||||+-------- PMCE10 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 1) -#define MMC_CS0_PMCE1_TBL (uint8_t)0xFD -/* 11111101B */ /* PMCEmn setting */ -/* |||||||+-------- Reserved : Set to 1 */ -/* ||||||+--------- PMCE11 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 2) -#define MMC_CS0_PMCE1_TBL (uint8_t)0xFB -/* 11111011B */ /* PMCEmn setting */ -/* ||||||++-------- Reserved : Set to 1 */ -/* |||||+---------- PMCE12 : Set to 0 */ -/* +++++----------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 3) -#define MMC_CS0_PMCE1_TBL (uint8_t)0xF7 -/* 11110111B */ /* PMCEmn setting */ -/* |||||+++-------- Reserved : Set to 1 */ -/* ||||+----------- PMCE13 : Set to 0 */ -/* ++++------------ Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 4) -#define MMC_CS0_PMCE1_TBL (uint8_t)0xEF -/* 11101111B */ /* PMCEmn setting */ -/* ||||++++-------- Reserved : Set to 1 */ -/* |||+------------ PMCE14 : Set to 0 */ -/* +++------------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 5) -#define MMC_CS0_PMCE1_TBL (uint8_t)0xDF -/* 11011111B */ /* PMCEmn setting */ -/* |||+++++-------- Reserved : Set to 1 */ -/* ||+------------- PMCE15 : Set to 0 */ -/* ++-------------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 6) -#define MMC_CS0_PMCE1_TBL (uint8_t)0xBF -/* 10111111B */ /* PMCEmn setting */ -/* ||++++++-------- Reserved : Set to 1 */ -/* |+-------------- PMCE16 : Set to 0 */ -/* +--------------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 7) -#define MMC_CS0_PMCE1_TBL (uint8_t)0x7F -/* 01111111B */ /* PMCEmn setting */ -/* |+++++++-------- Reserved : Set to 1 */ -/* +--------------- PMCE17 : Set to 0 */ -#endif /* MMC_CS0_BITNO */ - -#elif (MMC_CS0_PORTNO == 5) -#if (MMC_CS0_BITNO == 0) -#define MMC_CS0_PMCE5_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCEmn setting */ -/* |||||||+-------- PMCE50 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 1) -#define MMC_CS0_PMCE5_TBL (uint8_t)0xFD -/* 11111101B */ /* PMCEmn setting */ -/* |||||||+-------- Reserved : Set to 1 */ -/* ||||||+--------- PMCE51 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ -#endif /* MMC_CS0_BITNO */ - -#elif (MMC_CS0_PORTNO == 6) -#if (MMC_CS0_BITNO == 0) -#define MMC_CS0_PMCE6_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCEmn setting */ -/* |||||||+-------- PMCE60 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 1) -#define MMC_CS0_PMCE6_TBL (uint8_t)0xFD -/* 11111101B */ /* PMCEmn setting */ -/* |||||||+-------- Reserved : Set to 1 */ -/* ||||||+--------- PMCE61 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ -#endif /* MMC_CS0_BITNO */ -#endif /* MMC_CS0_PORTNO */ - -#ifndef MMC_CS0_PMCE0_TBL -#define MMC_CS0_PMCE0_TBL (uint8_t)0xFF -#endif /* MMC_CS0_PMCE0_TBL */ -#ifndef MMC_CS0_PMCE1_TBL -#define MMC_CS0_PMCE1_TBL (uint8_t)0xFF -#endif /* MMC_CS0_PMCE1_TBL */ -#ifndef MMC_CS0_PMCE5_TBL -#define MMC_CS0_PMCE5_TBL (uint8_t)0xFF -#endif /* MMC_CS0_PMCE5_TBL */ -#ifndef MMC_CS0_PMCE6_TBL -#define MMC_CS0_PMCE6_TBL (uint8_t)0xFF -#endif /* MMC_CS0_PMCE6_TBL */ - -/*----------- CCDE (CS0) register value -----------*/ -#if (MMC_CS0_PORTNO == 1) -#if (MMC_CS0_BITNO == 6) -#define MMC_CS0_CCDE_TBL (uint8_t)0xFE -/* 11111110B */ /* CCDE setting */ -/* |||||||+-------- CCDE00 (P16) : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#elif (MMC_CS0_BITNO == 7) -#define MMC_CS0_CCDE_TBL (uint8_t)0xFD -/* 11111101B */ /* CCDE setting */ -/* |||||||+-------- Reserved : Set to 1 */ -/* ||||||+--------- CCDE01 (P17) : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ -#endif /* MMC_CS0_BITNO */ -#endif /* MMC_CS0_PORTNO */ - -#ifndef MMC_CS0_CCDE_TBL -#define MMC_CS0_CCDE_TBL (uint8_t)0xFF -#endif /* MMC_CS0_CCDE_TBL */ - - -/*----------- PMCAxx (DETECT0) register value -----------*/ -#if (MMC_DETECT0_PORTNO == 0) -#if (MMC_DETECT0_BITNO == 0) -#define MMC_DETECT0_PMCA0_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCAmn setting */ -/* |||||||+-------- PMCA00 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 1) -#define MMC_DETECT0_PMCA0_TBL (uint8_t)0xFD -/* 11111101B */ /* PMCAmn setting */ -/* |||||||+-------- Reserved : Set to 1 */ -/* ||||||+--------- PMCA01 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 2) -#define MMC_DETECT0_PMCA0_TBL (uint8_t)0xFB -/* 11111011B */ /* PMCAmn setting */ -/* ||||||++-------- Reserved : Set to 1 */ -/* |||||+---------- PMCA02 : Set to 0 */ -/* +++++----------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 3) -#define MMC_DETECT0_PMCA0_TBL (uint8_t)0xF7 -/* 11110111B */ /* PMCAmn setting */ -/* |||||+++-------- Reserved : Set to 1 */ -/* ||||+----------- PMCA03 : Set to 0 */ -/* ++++------------ Reserved : Set to 1 */ -#endif /* MMC_DETECT0_BITNO */ - -#elif (MMC_DETECT0_PORTNO == 1) -#if (MMC_DETECT0_BITNO == 3) -#define MMC_DETECT0_PMCA1_TBL (uint8_t)0xF7 -/* 11110111B */ /* PMCAmn setting */ -/* |||||+++-------- Reserved : Set to 1 */ -/* ||||+----------- PMCA13 : Set to 0 */ -/* ++++------------ Reserved : Set to 1 */ -#endif /* MMC_DETECT0_BITNO */ - -#elif (MMC_DETECT0_PORTNO == 2) -#if (MMC_DETECT0_BITNO == 0) -#define MMC_DETECT0_PMCA2_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCAmn setting */ -/* |||||||+-------- PMCA00 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 1) -#define MMC_DETECT0_PMCA2_TBL (uint8_t)0xFD -/* 11111101B */ /* PMCAmn setting */ -/* |||||||+-------- Reserved : Set to 1 */ -/* ||||||+--------- PMCA21 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 2) -#define MMC_DETECT0_PMCA2_TBL (uint8_t)0xFB -/* 11111011B */ /* PMCAmn setting */ -/* ||||||++-------- Reserved : Set to 1 */ -/* |||||+---------- PMCA22 : Set to 0 */ -/* +++++----------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 3) -#define MMC_DETECT0_PMCA2_TBL (uint8_t)0xF7 -/* 11110111B */ /* PMCAmn setting */ -/* |||||+++-------- Reserved : Set to 1 */ -/* ||||+----------- PMCA23 : Set to 0 */ -/* ++++------------ Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 4) -#define MMC_DETECT0_PMCA2_TBL (uint8_t)0xEF -/* 11101111B */ /* PMCAmn setting */ -/* ||||++++-------- Reserved : Set to 1 */ -/* |||+------------ PMCA24 : Set to 0 */ -/* +++------------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 5) -#define MMC_DETECT0_PMCA2_TBL (uint8_t)0xDF -/* 11011111B */ /* PMCAmn setting */ -/* |||+++++-------- Reserved : Set to 1 */ -/* ||+------------- PMCA25 : Set to 0 */ -/* ++-------------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 6) -#define MMC_DETECT0_PMCA2_TBL (uint8_t)0xBF -/* 10111111B */ /* PMCAmn setting */ -/* ||++++++-------- Reserved : Set to 1 */ -/* |+-------------- PMCA26 : Set to 0 */ -/* +--------------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 7) -#define MMC_DETECT0_PMCA2_TBL (uint8_t)0x7F -/* 10111111B */ /* PMCAmn setting */ -/* |+++++++-------- Reserved : Set to 1 */ -/* +--------------- PMCA27 : Set to 0 */ -#endif /* MMC_DETECT0_BITNO */ - -#elif (MMC_DETECT0_PORTNO == 12) -#if (MMC_DETECT0_BITNO == 0) -#define MMC_DETECT0_PMCA12_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCAmn setting */ -/* |||||||+-------- PMCA120 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#endif /* MMC_DETECT0_BITNO */ - -#elif (MMC_DETECT0_PORTNO == 14) -#if (MMC_DETECT0_BITNO == 7) -#define MMC_DETECT0_PMCA14_TBL (uint8_t)0x7F -/* 01111111B */ /* PMCAmn setting */ -/* |+++++++-------- Reserved : Set to 1 */ -/* +--------------- PMCA147 : Set to 0 */ -#endif /* MMC_DETECT0_BITNO */ -#endif /* MMC_DETECT0_PORTNO */ - -#ifndef MMC_DETECT0_PMCA0_TBL -#define MMC_DETECT0_PMCA0_TBL (uint8_t)0xFF -#endif /* MMC_DETECT0_PMCA0_TBL */ -#ifndef MMC_DETECT0_PMCA1_TBL -#define MMC_DETECT0_PMCA1_TBL (uint8_t)0xFF -#endif /* MMC_DETECT0_PMCA1_TBL */ -#ifndef MMC_DETECT0_PMCA2_TBL -#define MMC_DETECT0_PMCA2_TBL (uint8_t)0xFF -#endif /* MMC_DETECT0_PMCA2_TBL */ -#ifndef MMC_DETECT0_PMCA12_TBL -#define MMC_DETECT0_PMCA12_TBL (uint8_t)0xFF -#endif /* MMC_DETECT0_PMCA12_TBL */ -#ifndef MMC_DETECT0_PMCA14_TBL -#define MMC_DETECT0_PMCA14_TBL (uint8_t)0xFF -#endif /* MMC_DETECT0_PMCA14_TBL */ - -/*----------- PMCTxx (DETECT0) register value -----------*/ -#if (MMC_DETECT0_PORTNO == 0) -#if (MMC_DETECT0_BITNO == 0) -#define MMC_DETECT0_PMCT0_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCTmn setting */ -/* |||||||+-------- PMCT00 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 1) -#define MMC_DETECT0_PMCT0_TBL (uint8_t)0xFD -/* 11111101B */ /* PMCTmn setting */ -/* |||||||+-------- Reserved : Set to 1 */ -/* ||||||+--------- PMCT01 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 2) -#define MMC_DETECT0_PMCT0_TBL (uint8_t)0xFB -/* 11111011B */ /* PMCTmn setting */ -/* ||||||++-------- Reserved : Set to 1 */ -/* |||||+---------- PMCT02 : Set to 0 */ -/* +++++----------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 3) -#define MMC_DETECT0_PMCT0_TBL (uint8_t)0xF7 -/* 11110111B */ /* PMCTmn setting */ -/* |||||+++-------- Reserved : Set to 1 */ -/* ||||+----------- PMCT03 : Set to 0 */ -/* ++++------------ Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 5) -#define MMC_DETECT0_PMCT0_TBL (uint8_t)0xDF -/* 11011111B */ /* PMCTmn setting */ -/* |||+++++-------- Reserved : Set to 1 */ -/* ||+------------- PMCT05 : Set to 0 */ -/* ++-------------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 6) -#define MMC_DETECT0_PMCT0_TBL (uint8_t)0xBF -/* 10111111B */ /* PMCTmn setting */ -/* ||++++++-------- Reserved : Set to 1 */ -/* |+-------------- PMCT06 : Set to 0 */ -/* +--------------- Reserved : Set to 1 */ -#endif /* MMC_DETECT0_BITNO */ - -#elif (MMC_DETECT0_PORTNO == 2) -#if (MMC_DETECT0_BITNO == 2) -#define MMC_DETECT0_PMCT2_TBL (uint8_t)0xFB -/* 11111011B */ /* PMCTmn setting */ -/* ||||||++-------- Reserved : Set to 1 */ -/* |||||+---------- PMCT22 : Set to 0 */ -/* +++++----------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 3) -#define MMC_DETECT0_PMCT2_TBL (uint8_t)0xF7 -/* 11110111B */ /* PMCTmn setting */ -/* |||||+++-------- Reserved : Set to 1 */ -/* ||||+----------- PMCT23 : Set to 0 */ -/* ++++------------ Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 4) -#define MMC_DETECT0_PMCT2_TBL (uint8_t)0xEF -/* 11101111B */ /* PMCTmn setting */ -/* ||||++++-------- Reserved : Set to 1 */ -/* |||+------------ PMCT24 : Set to 0 */ -/* +++------------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 5) -#define MMC_DETECT0_PMCT2_TBL (uint8_t)0xDF -/* 11011111B */ /* PMCTmn setting */ -/* |||+++++-------- Reserved : Set to 1 */ -/* ||+------------- PMCT25 : Set to 0 */ -/* ++-------------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 6) -#define MMC_DETECT0_PMCT2_TBL (uint8_t)0xBF -/* 10111111B */ /* PMCTmn setting */ -/* ||++++++-------- Reserved : Set to 1 */ -/* |+-------------- PMCT26 : Set to 0 */ -/* +--------------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 7) -#define MMC_DETECT0_PMCT2_TBL (uint8_t)0x7F -/* 10111111B */ /* PMCTmn setting */ -/* |+++++++-------- Reserved : Set to 1 */ -/* +--------------- PMCT27 : Set to 0 */ -#endif /* MMC_DETECT0_BITNO */ - -#elif (MMC_DETECT0_PORTNO == 3) -#if (MMC_DETECT0_BITNO == 0) -#define MMC_DETECT0_PMCT3_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCTmn setting */ -/* |||||||+-------- PMCT30 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 1) -#define MMC_DETECT0_PMCT3_TBL (uint8_t)0xFD -/* 11111101B */ /* PMCTmn setting */ -/* |||||||+-------- Reserved : Set to 1 */ -/* ||||||+--------- PMCT31 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ -#endif /* MMC_DETECT0_BITNO */ - -#elif (MMC_DETECT0_PORTNO == 5) -#if (MMC_DETECT0_BITNO == 0) -#define MMC_DETECT0_PMCT5_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCTmn setting */ -/* |||||||+-------- PMCT50 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#endif /* MMC_DETECT0_BITNO */ - -#elif (MMC_DETECT0_PORTNO == 6) -#if (MMC_DETECT0_BITNO == 4) -#define MMC_DETECT0_PMCT6_TBL (uint8_t)0xEF -/* 11101111B */ /* PMCTmn setting */ -/* ||||++++-------- Reserved : Set to 1 */ -/* |||+------------ PMCT64 : Set to 0 */ -/* +++------------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 5) -#define MMC_DETECT0_PMCT6_TBL (uint8_t)0xDF -/* 11011111B */ /* PMCTmn setting */ -/* |||+++++-------- Reserved : Set to 1 */ -/* ||+------------- PMCT65 : Set to 0 */ -/* ++-------------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 6) -#define MMC_DETECT0_PMCT6_TBL (uint8_t)0xBF -/* 10111111B */ /* PMCTmn setting */ -/* ||++++++-------- Reserved : Set to 1 */ -/* |+-------------- PMCT66 : Set to 0 */ -/* +--------------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 7) -#define MMC_DETECT0_PMCT6_TBL (uint8_t)0x7F -/* 10111111B */ /* PMCTmn setting */ -/* |+++++++-------- Reserved : Set to 1 */ -/* +--------------- PMCT67 : Set to 0 */ -#endif /* MMC_DETECT0_BITNO */ - -#elif (MMC_DETECT0_PORTNO == 7) -#if (MMC_DETECT0_BITNO == 0) -#define MMC_DETECT0_PMCT7_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCTmn setting */ -/* |||||||+-------- PMCT70 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 1) -#define MMC_DETECT0_PMCT7_TBL (uint8_t)0xFD -/* 11111101B */ /* PMCTmn setting */ -/* |||||||+-------- Reserved : Set to 1 */ -/* ||||||+--------- PMCT71 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 2) -#define MMC_DETECT0_PMCT7_TBL (uint8_t)0xFB -/* 11111011B */ /* PMCTmn setting */ -/* ||||||++-------- Reserved : Set to 1 */ -/* |||||+---------- PMCT72 : Set to 0 */ -/* +++++----------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 3) -#define MMC_DETECT0_PMCT7_TBL (uint8_t)0xF7 -/* 11110111B */ /* PMCTmn setting */ -/* |||||+++-------- Reserved : Set to 1 */ -/* ||||+----------- PMCT73 : Set to 0 */ -/* ++++------------ Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 4) -#define MMC_DETECT0_PMCT7_TBL (uint8_t)0xEF -/* 11101111B */ /* PMCTmn setting */ -/* ||||++++-------- Reserved : Set to 1 */ -/* |||+------------ PMCT74 : Set to 0 */ -/* +++------------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 5) -#define MMC_DETECT0_PMCT7_TBL (uint8_t)0xDF -/* 11011111B */ /* PMCTmn setting */ -/* |||+++++-------- Reserved : Set to 1 */ -/* ||+------------- PMCT75 : Set to 0 */ -/* ++-------------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 6) -#define MMC_DETECT0_PMCT7_TBL (uint8_t)0xBF -/* 10111111B */ /* PMCTmn setting */ -/* ||++++++-------- Reserved : Set to 1 */ -/* |+-------------- PMCT76 : Set to 0 */ -/* +--------------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 7) -#define MMC_DETECT0_PMCT7_TBL (uint8_t)0x7F -/* 10111111B */ /* PMCTmn setting */ -/* |+++++++-------- Reserved : Set to 1 */ -/* +--------------- PMCT77 : Set to 0 */ -#endif /* MMC_DETECT0_BITNO */ -#endif /* MMC_DETECT0_PORTNO */ - -#ifndef MMC_DETECT0_PMCT0_TBL -#define MMC_DETECT0_PMCT0_TBL (uint8_t)0xFF -#endif /* MMC_DETECT0_PMCT0_TBL */ -#ifndef MMC_DETECT0_PMCT2_TBL -#define MMC_DETECT0_PMCT2_TBL (uint8_t)0xFF -#endif /* MMC_DETECT0_PMCT2_TBL */ -#ifndef MMC_DETECT0_PMCT3_TBL -#define MMC_DETECT0_PMCT3_TBL (uint8_t)0xFF -#endif /* MMC_DETECT0_PMCT3_TBL */ -#ifndef MMC_DETECT0_PMCT5_TBL -#define MMC_DETECT0_PMCT5_TBL (uint8_t)0xFF -#endif /* MMC_DETECT0_PMCT5_TBL */ -#ifndef MMC_DETECT0_PMCT6_TBL -#define MMC_DETECT0_PMCT6_TBL (uint8_t)0xFF -#endif /* MMC_DETECT0_PMCT6_TBL */ -#ifndef MMC_DETECT0_PMCT7_TBL -#define MMC_DETECT0_PMCT7_TBL (uint8_t)0xFF -#endif /* MMC_DETECT0_PMCT7_TBL */ - -/*----------- PMCExx (DETECT0) register value -----------*/ -#if (MMC_DETECT0_PORTNO == 0) -#if (MMC_DETECT0_BITNO == 1) -#define MMC_DETECT0_PMCE0_TBL (uint8_t)0xFD -/* 11111101B */ /* PMCEmn setting */ -/* |||||||+-------- Reserved : Set to 1 */ -/* ||||||+--------- PMCE01 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ -#endif /* MMC_DETECT0_BITNO */ - -#elif (MMC_DETECT0_PORTNO == 1) -#if (MMC_DETECT0_BITNO == 0) -#define MMC_DETECT0_PMCE1_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCEmn setting */ -/* |||||||+-------- PMCE10 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 1) -#define MMC_DETECT0_PMCE1_TBL (uint8_t)0xFD -/* 11111101B */ /* PMCEmn setting */ -/* |||||||+-------- Reserved : Set to 1 */ -/* ||||||+--------- PMCE11 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 2) -#define MMC_DETECT0_PMCE1_TBL (uint8_t)0xFB -/* 11111011B */ /* PMCEmn setting */ -/* ||||||++-------- Reserved : Set to 1 */ -/* |||||+---------- PMCE12 : Set to 0 */ -/* +++++----------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 3) -#define MMC_DETECT0_PMCE1_TBL (uint8_t)0xF7 -/* 11110111B */ /* PMCEmn setting */ -/* |||||+++-------- Reserved : Set to 1 */ -/* ||||+----------- PMCE13 : Set to 0 */ -/* ++++------------ Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 4) -#define MMC_DETECT0_PMCE1_TBL (uint8_t)0xEF -/* 11101111B */ /* PMCEmn setting */ -/* ||||++++-------- Reserved : Set to 1 */ -/* |||+------------ PMCE14 : Set to 0 */ -/* +++------------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 5) -#define MMC_DETECT0_PMCE1_TBL (uint8_t)0xDF -/* 11011111B */ /* PMCEmn setting */ -/* |||+++++-------- Reserved : Set to 1 */ -/* ||+------------- PMCE15 : Set to 0 */ -/* ++-------------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 6) -#define MMC_DETECT0_PMCE1_TBL (uint8_t)0xBF -/* 10111111B */ /* PMCEmn setting */ -/* ||++++++-------- Reserved : Set to 1 */ -/* |+-------------- PMCE16 : Set to 0 */ -/* +--------------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 7) -#define MMC_DETECT0_PMCE1_TBL (uint8_t)0x7F -/* 01111111B */ /* PMCEmn setting */ -/* |+++++++-------- Reserved : Set to 1 */ -/* +--------------- PMCE17 : Set to 0 */ -#endif /* MMC_DETECT0_BITNO */ - -#elif (MMC_DETECT0_PORTNO == 5) -#if (MMC_DETECT0_BITNO == 0) -#define MMC_DETECT0_PMCE5_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCEmn setting */ -/* |||||||+-------- PMCE50 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 1) -#define MMC_DETECT0_PMCE5_TBL (uint8_t)0xFD -/* 11111101B */ /* PMCEmn setting */ -/* |||||||+-------- Reserved : Set to 1 */ -/* ||||||+--------- PMCE51 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ -#endif /* MMC_DETECT0_BITNO */ - -#elif (MMC_DETECT0_PORTNO == 6) -#if (MMC_DETECT0_BITNO == 0) -#define MMC_DETECT0_PMCE6_TBL (uint8_t)0xFE -/* 11111110B */ /* PMCEmn setting */ -/* |||||||+-------- PMCE60 : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 1) -#define MMC_DETECT0_PMCE6_TBL (uint8_t)0xFD -/* 11111101B */ /* PMCEmn setting */ -/* |||||||+-------- Reserved : Set to 1 */ -/* ||||||+--------- PMCE61 : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ -#endif /* MMC_DETECT0_BITNO */ -#endif /* MMC_DETECT0_PORTNO */ - -#ifndef MMC_DETECT0_PMCE0_TBL -#define MMC_DETECT0_PMCE0_TBL (uint8_t)0xFF -#endif /* MMC_DETECT0_PMCE0_TBL */ -#ifndef MMC_DETECT0_PMCE1_TBL -#define MMC_DETECT0_PMCE1_TBL (uint8_t)0xFF -#endif /* MMC_DETECT0_PMCE1_TBL */ -#ifndef MMC_DETECT0_PMCE5_TBL -#define MMC_DETECT0_PMCE5_TBL (uint8_t)0xFF -#endif /* MMC_DETECT0_PMCE5_TBL */ -#ifndef MMC_DETECT0_PMCE6_TBL -#define MMC_DETECT0_PMCE6_TBL (uint8_t)0xFF -#endif /* MMC_DETECT0_PMCE6_TBL */ - -/*----------- CCDE (DETECT0) register value -----------*/ -#if (MMC_DETECT0_PORTNO == 1) -#if (MMC_DETECT0_BITNO == 6) -#define MMC_DETECT0_CCDE_TBL (uint8_t)0xFE -/* 11111110B */ /* CCDE setting */ -/* |||||||+-------- CCDE00 (P16) : Set to 0 */ -/* +++++++--------- Reserved : Set to 1 */ -#elif (MMC_DETECT0_BITNO == 7) -#define MMC_DETECT0_CCDE_TBL (uint8_t)0xFD -/* 11111101B */ /* CCDE setting */ -/* |||||||+-------- Reserved : Set to 1 */ -/* ||||||+--------- CCDE01 (P17) : Set to 0 */ -/* ++++++---------- Reserved : Set to 1 */ -#endif /* MMC_DETECT0_BITNO */ -#endif /* MMC_DETECT0_PORTNO */ - -#ifndef MMC_DETECT0_CCDE_TBL -#define MMC_DETECT0_CCDE_TBL (uint8_t)0xFF -#endif /* MMC_DETECT0_CCDE_TBL */ - - - -#define __PM( x,y ) PM ## x ##_bit.no ## y -#define _PM( x,y ) __PM( x , y ) -#define __POM( x,y ) POM ## x ##_bit.no ## y -#define _POM( x,y ) __POM( x , y ) -#define __PIM( x,y ) PIM ## x ##_bit.no ## y -#define _PIM( x,y ) __PIM( x , y ) -#define __P( x,y ) P ## x ##_bit.no ## y -#define _P( x,y ) __P( x , y ) -#define __PMC( x,y ) PMC ## x ##_bit.no ## y -#define _PMC( x,y ) __PMC( x , y ) - -#define __SPS( x ) SPS ## x -#define _SPS( x ) __SPS( x ) -#define __SPSL( x ) SPS ## x ## L -#define _SPSL( x ) __SPSL( x ) - -#define __SMR( x,y ) SMR ## x ## y -#define _SMR( x,y ) __SMR( x , y ) - -#define __SCR( x,y ) SCR ## x ## y -#define _SCR( x,y ) __SCR( x , y ) - -#define __SDR( x,y ) SDR ## x ## y -#define _SDR( x,y ) __SDR( x , y ) -#define __SIO( x,y ) SIO ## x ## y -#define _SIO( x,y ) __SIO( x , y ) - -#define __SIR( x,y ) SIR ## x ## y -#define _SIR( x,y ) __SIR( x , y ) -#define __SIRL( x,y ) SIR ## x ## y ## L -#define _SIRL( x,y ) __SIRL( x , y ) - -#define __SSR( x,y ) SSR ## x ## y -#define _SSR( x,y ) __SSR( x , y ) -#define __SSRL( x,y ) SSR ## x ## y ## L -#define _SSRL( x,y ) __SSRL( x , y ) - -#define __SS( x ) SS ## x -#define _SS( x ) __SS( x ) -#define __SSL( x ) SS ## x ## L -#define _SSL( x ) __SSL( x ) -#define __SSLB( x,y ) SS ## x ## L_bit.no ## y -#define _SSLB( x,y ) __SSLB( x,y ) - -#define __ST( x ) ST ## x -#define _ST( x ) __ST( x ) -#define __STL( x ) ST ## x ## L -#define _STL( x ) __STL( x ) -#define __STLB( x,y ) ST ## x ## L_bit.no ## y -#define _STLB( x,y ) __STLB( x,y ) - -#define __SE( x ) SE ## x -#define _SE( x ) __SE( x ) -#define __SEL( x ) SE ## x ## L -#define _SEL( x ) __SEL( x ) -#define __SELB( x,y ) SE ## x ## L_bit.no ## y -#define _SELB( x,y ) __SELB( x,y ) - -#define __SOE( x ) SOE ## x -#define _SOE( x ) __SOE( x ) -#define __SOEL( x ) SOE ## x ## L -#define _SOEL( x ) __SOEL( x ) -#define __SOELB( x,y ) SOE ## x ## L_bit.no ## y -#define _SOELB( x,y ) __SOELB( x,y ) - -#define __SO( x ) SO ## x -#define _SO( x ) __SO( x ) - -#define __CSIIF( x,y ) CSIIF ## x ## y -#define _CSIIF( x,y ) __CSIIF( x , y ) -#define __CSIMK( x,y ) CSIMK ## x ## y -#define _CSIMK( x,y ) __CSIMK( x , y ) -#define __SAUEN( x ) SAU ## x ## EN -#define _SAUEN( x ) __SAUEN( x ) -#define __SAURES( x ) SAU ## x ## RES -#define _SAURES( x ) __SAURES( x ) - -#define MMC_PM_DATAI _PM( MMC_DATAI_PORTNO , MMC_DATAI_BITNO ) /* MMC DataIn */ -#define MMC_PORT_DATAI _P( MMC_DATAI_PORTNO , MMC_DATAI_BITNO ) /* MMC DataIn */ -#define MMC_PIM_DATAI _PIM( MMC_DATAI_PORTNO , MMC_DATAI_BITNO ) /* MMC DataIn */ -#define MMC_POM_DATAI _POM( MMC_DATAI_PORTNO , MMC_DATAI_BITNO ) /* MMC DataIn */ -#define MMC_PMC_DATAI _PMC( MMC_DATAI_PORTNO , MMC_DATAI_BITNO ) /* MMC DataIn */ -#define MMC_PM_CLK _PM( MMC_CLK_PORTNO , MMC_CLK_BITNO ) /* MMC CLK */ -#define MMC_PORT_CLK _P( MMC_CLK_PORTNO , MMC_CLK_BITNO ) /* MMC CLK */ -#define MMC_PIM_CLK _PIM( MMC_CLK_PORTNO , MMC_CLK_BITNO ) /* MMC CLK */ -#define MMC_POM_CLK _POM( MMC_CLK_PORTNO , MMC_CLK_BITNO ) /* MMC CLK */ -#define MMC_PMC_CLK _PMC( MMC_CLK_PORTNO , MMC_CLK_BITNO ) /* MMC CLK */ -#define MMC_PM_DATAO _PM( MMC_DATAO_PORTNO , MMC_DATAO_BITNO ) /* MMC DataOut */ -#define MMC_PORT_DATAO _P( MMC_DATAO_PORTNO , MMC_DATAO_BITNO ) /* MMC DataOut */ -#define MMC_PIM_DATAO _PIM( MMC_DATAO_PORTNO , MMC_DATAO_BITNO ) /* MMC DataOut */ -#define MMC_POM_DATAO _POM( MMC_DATAO_PORTNO , MMC_DATAO_BITNO ) /* MMC DataOut */ -#define MMC_PMC_DATAO _PMC( MMC_DATAO_PORTNO , MMC_DATAO_BITNO ) /* MMC DataOut */ - -#define MMC_PM_CS0 _PM( MMC_CS0_PORTNO , MMC_CS0_BITNO ) /* MMC CS0 (Negative-true logic) */ -#define MMC_PORT_CS0 _P( MMC_CS0_PORTNO , MMC_CS0_BITNO ) /* MMC CS0 (Negative-true logic) */ -#define MMC_PIM_CS0 _PIM( MMC_CS0_PORTNO , MMC_CS0_BITNO ) /* MMC CS0 (Negative-true logic) */ -#define MMC_POM_CS0 _POM( MMC_CS0_PORTNO , MMC_CS0_BITNO ) /* MMC CS0 (Negative-true logic) */ - -#if defined(MMC_DETECT0_CONNECTION) -#define MMC_PM_DETECT0 _PM( MMC_DETECT0_PORTNO , MMC_DETECT0_BITNO ) /* MMC Detect0 (Negative-true logic) */ -#define MMC_PORT_DETECT0 _P( MMC_DETECT0_PORTNO , MMC_DETECT0_BITNO ) /* MMC Detect0 (Negative-true logic) */ -#define MMC_PIM_DETECT0 _PIM( MMC_DETECT0_PORTNO , MMC_DETECT0_BITNO ) /* MMC Detect0 (Negative-true logic) */ -#define MMC_POM_DETECT0 _POM( MMC_DETECT0_PORTNO , MMC_DETECT0_BITNO ) /* MMC Detect0 (Negative-true logic) */ -#endif /* #if defined(MMC_DETECT0_CONNECTION) */ - -#if (MMC_SLOT_NUM > 1) -#define MMC_PM_CS1 _PM( MMC_CS1_PORTNO , MMC_CS1_BITNO ) /* MMC CS1 (Negative-true logic) */ -#define MMC_PORT_CS1 _P( MMC_CS1_PORTNO , MMC_CS1_BITNO ) /* MMC CS1 (Negative-true logic) */ -#define MMC_PIM_CS1 _PIM( MMC_CS1_PORTNO , MMC_CS1_BITNO ) /* MMC CS1 (Negative-true logic) */ -#define MMC_POM_CS1 _POM( MMC_CS1_PORTNO , MMC_CS1_BITNO ) /* MMC CS1 (Negative-true logic) */ - -#if defined(MMC_DETECT1_CONNECTION) -#define MMC_PM_DETECT1 _PM( MMC_DETECT1_PORTNO , MMC_DETECT1_BITNO ) /* MMC Detect1 (Negative-true logic) */ -#define MMC_PORT_DETECT1 _P( MMC_DETECT1_PORTNO , MMC_DETECT1_BITNO ) /* MMC Detect1 (Negative-true logic) */ -#define MMC_PIM_DETECT1 _PIM( MMC_DETECT1_PORTNO , MMC_DETECT1_BITNO ) /* MMC Detect1 (Negative-true logic) */ -#define MMC_POM_DETECT1 _POM( MMC_DETECT1_PORTNO , MMC_DETECT1_BITNO ) /* MMC Detect1 (Negative-true logic) */ -#endif /* #if defined(MMC_DETECT1_CONNECTION) */ - -#endif /* #if (MMC_SLOT_NUM > 1) */ - - -/*----------- Definitions of resource used -----------*/ -#define MMC_CSI_USED /* CSI used */ -#define MMC_SYNC_MSBF /* CSI MSB first */ - -#ifdef MMC_OPTION_1 -#define MMC_CRC_SOFT /* Encode by soft CRC (ROM table used) */ -#endif /* #ifdef MMC_OPTION_1 */ - -#ifdef MMC_OPTION_2 -#define MMC_CRC_HARD /* Encode by hard CRC */ -#define MMC_CRC_LSBF -#endif /* #ifdef MMC_OPTION_2 */ - - -/*----------------- CSI definitions -----------------*/ - -/* 16bits 8bits */ -#define MMC_CSI_SPSmL _SPSL( MMC_SAU_UNIT ) /* SPSmL register : 8bits */ -#define MMC_CSI_SMRmn _SMR( MMC_SAU_UNIT ,MMC_SAU_CHANNEL ) /* SMRmn register : 16bits */ -#define MMC_CSI_SCRmn _SCR( MMC_SAU_UNIT ,MMC_SAU_CHANNEL ) /* SCRmn register : 16bits */ -#define MMC_CSI_SDRmn _SDR( MMC_SAU_UNIT ,MMC_SAU_CHANNEL ) /* SDRmn register : 16bits */ -#define MMC_CSI_SIOmn _SIO( MMC_CSI_UNIT ,MMC_CSI_CHANNEL ) /* SIOmn register : 8bits */ -#define MMC_CSI_SIRmnL _SIRL( MMC_SAU_UNIT ,MMC_SAU_CHANNEL ) /* SIRmnL register : 8bits */ -#define MMC_CSI_SSRmnL _SSRL( MMC_SAU_UNIT ,MMC_SAU_CHANNEL ) /* SSRmnL register : 8bits */ - -#define MMC_CSI_SSmn _SSLB( MMC_SAU_UNIT ,MMC_SAU_CHANNEL ) /* SSm register Bit n : 1bit */ -#define MMC_CSI_STmn _STLB( MMC_SAU_UNIT ,MMC_SAU_CHANNEL ) /* STm register Bit n : 1bit */ -#define MMC_CSI_SEmn _SELB( MMC_SAU_UNIT ,MMC_SAU_CHANNEL ) /* SEm register Bit n : 1bit */ -#define MMC_CSI_SOEmn _SOELB( MMC_SAU_UNIT ,MMC_SAU_CHANNEL ) /* SOEm register Bit n : 1bit */ -#define MMC_CSI_SOm _SO( MMC_SAU_UNIT ) /* SOm register : 16bits */ -#define MMC_CSI_ISC ISC /* ISC register : 8bits */ -#define MMC_CSI_IFmn _CSIIF( MMC_CSI_UNIT , MMC_CSI_CHANNEL) /* CSI Interrupt flag : 1bit */ -#define MMC_CSI_MKmn _CSIMK( MMC_CSI_UNIT , MMC_CSI_CHANNEL) /* CSI Interrupt enable flag : 1bit */ -#define MMC_SAUmEN _SAUEN( MMC_SAU_UNIT ) /* SAU enable flag : 1bit */ -#define MMC_SAUmRES _SAURES( MMC_SAU_UNIT ) /* SAU reset flag : 1bit */ - -#define MMC_CSI_TXBUF MMC_CSI_SIOmn -#define MMC_CSI_RXBUF MMC_CSI_SIOmn - -#if (MMC_OPERATION_CLK_SELECT == 0) -#define MMC_SPS_MASK (uint8_t)0xF0 -/* xxxx0000B */ /* SPSmnL setting */ -/* ||||++++-------- PRSm[03:00] : CKm0 = fCLK */ -/* ++++------------ PRSm[07:04] : CKm1 = No change */ -#define MMC_SPS_SET (uint8_t)(MMC_FCLK_PRESCALER_SELECT) -/* xxxx****B */ /* SPSmnL setting */ -/* ||||++++-------- PRSm[03:00] : CKm0 set */ -/* ++++------------ PRSm[07:04] : CKm1 = No change */ -#elif (MMC_OPERATION_CLK_SELECT == 1) -#define MMC_SPS_MASK (uint8_t)0x0F -/* 0000xxxxB */ /* SPSmnL setting */ -/* ||||++++-------- PRSm[03:00] : CKm0 = No change */ -/* ++++------------ PRSm[07:04] : CKm1 = fCLK */ - -#define MMC_SPS_SET (uint8_t)(MMC_FCLK_PRESCALER_SELECT << 4) -/* ****xxxxB */ /* SPSmnL setting */ -/* ||||++++-------- PRSm[03:00] : CKm0 = No change */ -/* ++++------------ PRSm[07:04] : CKm1 set */ -#endif - -/* CSI setting */ -#define MMC_SMR_TX (uint16_t)0x0021 | ((uint16_t)MMC_OPERATION_CLK_SELECT << 15) -/* 00000000 00100001B */ /* SMRmn setting */ -/* |||||||| |||||||+-------- MDmn0 : Buffer empty interrupt */ -/* |||||||| |||||++--------- MDmn[2-1] : CSI mode */ -/* |||||||| |||++----------- Reserved : Set to 0 */ -/* |||||||| ||+------------- Reserved : Set to 1 */ -/* |||||||| |+-------------- SISmn : Read by failing edge */ -/* |||||||| +--------------- Reserved : Set to 0 */ -/* |||||||+ ---------------- STSmn : Software trigger is valid */ -/* ||+++++- ---------------- Reserved : Set to 0 */ -/* |+------ ---------------- CCSmn : Clock fMCK specified by the CKSmn bit */ -/* +------- ---------------- CKSmn : Operation clock CKmX set by the SPSm */ - -#define MMC_SMR_RX (uint16_t)0x0020 | ((uint16_t)MMC_OPERATION_CLK_SELECT << 15) -/* x0000000 00100000B */ /* SMRmn setting */ -/* |||||||| |||||||+-------- MDmn0 : Transfer end interrupt */ -/* |||||||| |||||++--------- MDmn[2-1] : CSI mode */ -/* |||||||| |||++----------- Reserved : Set to 0 */ -/* |||||||| ||+------------- Reserved : Set to 1 */ -/* |||||||| |+-------------- SISmn : Read by failing edge */ -/* |||||||| +--------------- Reserved : Set to 0 */ -/* |||||||+ ---------------- STSmn : Software trigger is valid */ -/* ||+++++- ---------------- Reserved : Set to 0 */ -/* |+------ ---------------- CCSmn : Clock fMCK specified by the CKSmn bit */ -/* +------- ---------------- CKSmn : Operation clock CKmX set by user */ - -#define MMC_SCR_INIT (uint16_t)0x0007 -/* 00000000 00000111B */ /* SCRmn setting */ -/* |||||||| ||||||++-------- DLSmn[1:0] : 8-bit data length */ -/* |||||||| |||||+---------- Reserved : Set to 1 */ -/* |||||||| ||||+----------- Reserved : Set to 0 */ -/* |||||||| ||++------------ SLCmn[1:0] : No stop bit */ -/* |||||||| |+-------------- Reserved : Set to 0 */ -/* |||||||| +--------------- DIRmn : MSB first */ -/* ||||||++ ---------------- PTCmn[1:0] : Receives without parity */ -/* |||||+-- ---------------- EOCmn : Masks error interrupt */ -/* ||||+--- ---------------- Reserved : Set to 0 */ -/* |||+---- ---------------- CKPmn : Select type 1 */ -/* ||+----- ---------------- DAPmn : Select type 1 */ -/* |+------ ---------------- RXEmn : Disable Reception */ -/* +------- ---------------- TXEmn : Disable Transmission */ - -#define MMC_SCR_TX (uint16_t)0x8007 -/* 10000000 00000111B */ /* SCRmn setting */ -/* |||||||| ||||||++-------- DLSmn[1:0] : 8-bit data length */ -/* |||||||| |||||+---------- Reserved : Set to 1 */ -/* |||||||| ||||+----------- Reserved : Set to 0 */ -/* |||||||| ||++------------ SLCmn[1:0] : No stop bit */ -/* |||||||| |+-------------- Reserved : Set to 0 */ -/* |||||||| +--------------- DIRmn : MSB first */ -/* ||||||++ ---------------- PTCmn[1:0] : Receives without parity */ -/* |||||+-- ---------------- EOCmn : Masks error interrupt */ -/* ||||+--- ---------------- Reserved : Set to 0 */ -/* |||+---- ---------------- CKPmn : Select type 1 */ -/* ||+----- ---------------- DAPmn : Select type 1 */ -/* |+------ ---------------- RXEmn : Disable Reception */ -/* +------- ---------------- TXEmn : Enable Transmission */ - -#define MMC_SCR_RX (uint16_t)0x4007 -/* 10000000 00000111B */ /* SCRmn setting */ -/* |||||||| ||||||++-------- DLSmn[1:0] : 8-bit data length */ -/* |||||||| |||||+---------- Reserved : Set to 1 */ -/* |||||||| ||||+----------- Reserved : Set to 0 */ -/* |||||||| ||++------------ SLCmn[1:0] : No stop bit */ -/* |||||||| |+-------------- Reserved : Set to 0 */ -/* |||||||| +--------------- DIRmn : MSB first */ -/* ||||||++ ---------------- PTCmn[1:0] : Receives without parity */ -/* |||||+-- ---------------- EOCmn : Masks error interrupt */ -/* ||||+--- ---------------- Reserved : Set to 0 */ -/* |||+---- ---------------- CKPmn : Select type 1 */ -/* ||+----- ---------------- DAPmn : Select type 1 */ -/* |+------ ---------------- RXEmn : Enable Reception */ -/* +------- ---------------- TXEmn : Disable Transmission */ - -#define MMC_CLKOUT_BIT (uint16_t)(0x0001 << (8 + MMC_SAU_CHANNEL)) -/* 0000xxxx 00000000B */ /* SOmn setting */ -/* |||||||| ++++++++-------- Reserved : Set to 0 */ -/* |||||||+ ---------------- CKOm0 : CKOm0 Output level */ -/* ||||||+- ---------------- CKOm1 : CKOm1 Output level */ -/* |||||+-- ---------------- CKOm2 : CKOm2 Output level */ -/* ||||+--- ---------------- CKOm3 : CKOm3 Output level */ -/* ++++---- ---------------- Reserved : Set to 0 */ - -#define MMC_SOOUT_BIT (uint16_t)(0x0001 << (MMC_SAU_CHANNEL)) -/* 00000000 0000xxxxB */ /* SOmn setting */ -/* |||||||| |||||||+-------- SOm0 : SOm0 Output level */ -/* |||||||| ||||||+--------- SOm1 : SOm1 Output level */ -/* |||||||| |||||+---------- SOm2 : SOm2 Output level */ -/* |||||||| ||||+----------- SOm3 : SOm3 Output level */ -/* ++++++++ ++++------------ Reserved : Set to 0 */ - -#define MMC_TXNEXT_MASK (uint8_t)(0x20) -/* 00100000B */ /* SSRmn reading */ -/* |||||||+-------- OVFmn : Not Check */ -/* ||||||+--------- PEFmn : Not Check */ -/* |||||+---------- FEFmn : Not Check */ -/* |||++----------- Reserved : Not Check */ -/* ||+------------- BFFmn : Check */ -/* |+-------------- TSFmn : Not Check */ -/* +--------------- Reserved : Not Check */ - -#define MMC_TXEND_MASK (uint8_t)(0x40) -/* 01000000B */ /* SSRmn reading */ -/* |||||||+-------- OVFmn : Not Check */ -/* ||||||+--------- PEFmn : Not Check */ -/* |||||+---------- FEFmn : Not Check */ -/* |||++----------- Reserved : Not Check */ -/* ||+------------- BFFmn : Not Check */ -/* |+-------------- TSFmn : Check */ -/* +--------------- Reserved : Not Check */ - -#define MMC_RX_COMPLETE_MASK (uint8_t)(0x20) -/* 01000000B */ /* SSRmn reading */ -/* |||||||+-------- OVFmn : Not Check */ -/* ||||||+--------- PEFmn : Not Check */ -/* |||||+---------- FEFmn : Not Check */ -/* |||++----------- Reserved : Not Check */ -/* ||+------------- BFFmn : Check */ -/* |+-------------- TSFmn : Not Check */ -/* +--------------- Reserved : Not Check */ - -#define MMC_OVF_MASK (uint8_t)(0x01) -/* 00000001B */ /* SSRmn reading */ -/* |||||||+-------- OVFmn : Not Check */ -/* ||||||+--------- PEFmn : Not Check */ -/* |||||+---------- FEFmn : Not Check */ -/* |||++----------- Reserved : Not Check */ -/* ||+------------- BFFmn : Not Check */ -/* |+-------------- TSFmn : Check */ -/* +--------------- Reserved : Not Check */ - - -#define MMC_DUMMY_DATA (uint8_t)0xFF /* MMC dummy data for some command */ - -/*----------------- CRC definitions ------------------*/ -#ifdef MMC_CRC_HARD -#define MMC_CRCIN CRCIN /* CRC input register */ -#define MMC_CRCD CRCD /* CRC data register */ - -#endif /* #ifdef MMC_CRC_HARD */ - - -/************************************************************************************************/ -/* Unions */ -/************************************************************************************************/ - -/************************************************************************************************/ -/* Structs */ -/************************************************************************************************/ - -/************************************************************************************************/ -/* Externs */ -/************************************************************************************************/ - -/************************************************************************************************/ -/* Macros */ -/************************************************************************************************/ - -/*------------- Driver use port control --------------*/ -#if (MMC_SLOT_NUM == 1) -/* !!!! The other Ports are set to input mode. !!!! */ -#define MMC_IO_INIT() do /* Driver use terminal initial setting */ \ - { \ - PMCA0 &= (MMC_PMCA0_TBL & MMC_CS0_PMCA0_TBL & MMC_DETECT0_PMCA0_TBL); \ - PMCA1 &= (MMC_PMCA1_TBL & MMC_CS0_PMCA1_TBL & MMC_DETECT0_PMCA1_TBL); \ - PMCA2 &= (MMC_PMCA2_TBL & MMC_CS0_PMCA2_TBL & MMC_DETECT0_PMCA2_TBL); \ - PMCA12 &= (MMC_PMCA12_TBL & MMC_CS0_PMCA12_TBL & MMC_DETECT0_PMCA12_TBL); \ - PMCA14 &= (MMC_PMCA14_TBL & MMC_CS0_PMCA14_TBL & MMC_DETECT0_PMCA14_TBL); \ - PMCT0 &= (MMC_PMCT0_TBL & MMC_CS0_PMCT0_TBL & MMC_DETECT0_PMCT0_TBL); \ - PMCT2 &= (MMC_PMCT2_TBL & MMC_CS0_PMCT2_TBL & MMC_DETECT0_PMCT2_TBL); \ - PMCT3 &= (MMC_PMCT3_TBL & MMC_CS0_PMCT3_TBL & MMC_DETECT0_PMCT3_TBL); \ - PMCT5 &= (MMC_PMCT5_TBL & MMC_CS0_PMCT5_TBL & MMC_DETECT0_PMCT5_TBL); \ - PMCT6 &= (MMC_PMCT6_TBL & MMC_CS0_PMCT6_TBL & MMC_DETECT0_PMCT6_TBL); \ - PMCT7 &= (MMC_PMCT7_TBL & MMC_CS0_PMCT7_TBL & MMC_DETECT0_PMCT7_TBL); \ - PMCE0 &= (MMC_PMCE0_TBL & MMC_CS0_PMCE0_TBL & MMC_DETECT0_PMCE0_TBL); \ - PMCE1 &= (MMC_PMCE1_TBL & MMC_CS0_PMCE1_TBL & MMC_DETECT0_PMCE1_TBL); \ - PMCE5 &= (MMC_PMCE5_TBL & MMC_CS0_PMCE5_TBL & MMC_DETECT0_PMCE5_TBL); \ - PMCE6 &= (MMC_PMCE6_TBL & MMC_CS0_PMCE6_TBL & MMC_DETECT0_PMCE6_TBL); \ - CCDE &= (MMC_CCDE_TBL & MMC_CS0_CCDE_TBL & MMC_DETECT0_CCDE_TBL); \ - PFOE1 |= MMC_PFOE1_TBL; \ - MMC_PORT_DATAO = MMC_TRUE; /* DataOut "H" */ \ - MMC_PM_DATAO = MMC_FALSE; /* DataOut Output */ \ - MMC_PORT_CLK = MMC_TRUE; /* CLK "H" */ \ - MMC_PM_CLK = MMC_FALSE; /* CLK Output */ \ - MMC_PM_DATAI = MMC_TRUE; /* DataIn Input */ \ - MMC_PORT_CS0 = MMC_TRUE; /* CS0 "H" */ \ - MMC_PM_CS0 = MMC_FALSE; /* CS0 Output */ \ - MMC_DETECT0_INIT(); /* DETECT0 Input */ \ - } while (0) -#endif /* #if (MMC_SLOT_NUM == 1) */ - -#if (MMC_SLOT_NUM > 1) -/* !!!! The other Ports are set to input mode. !!!! */ -#define MMC_IO_INIT() do /* Driver use terminal initial setting */ \ - { \ - PMCA0 &= (MMC_PMCA0_TBL & MMC_CS0_PMCA0_TBL & MMC_DETECT0_PMCA0_TBL); \ - PMCA1 &= (MMC_PMCA1_TBL & MMC_CS0_PMCA1_TBL & MMC_DETECT0_PMCA1_TBL); \ - PMCA2 &= (MMC_PMCA2_TBL & MMC_CS0_PMCA2_TBL & MMC_DETECT0_PMCA2_TBL); \ - PMCA12 &= (MMC_PMCA12_TBL & MMC_CS0_PMCA12_TBL & MMC_DETECT0_PMCA12_TBL); \ - PMCA14 &= (MMC_PMCA14_TBL & MMC_CS0_PMCA14_TBL & MMC_DETECT0_PMCA14_TBL); \ - PMCT0 &= (MMC_PMCT0_TBL & MMC_CS0_PMCT0_TBL & MMC_DETECT0_PMCT0_TBL); \ - PMCT2 &= (MMC_PMCT2_TBL & MMC_CS0_PMCT2_TBL & MMC_DETECT0_PMCT2_TBL); \ - PMCT3 &= (MMC_PMCT3_TBL & MMC_CS0_PMCT3_TBL & MMC_DETECT0_PMCT3_TBL); \ - PMCT5 &= (MMC_PMCT5_TBL & MMC_CS0_PMCT5_TBL & MMC_DETECT0_PMCT5_TBL); \ - PMCT6 &= (MMC_PMCT6_TBL & MMC_CS0_PMCT6_TBL & MMC_DETECT0_PMCT6_TBL); \ - PMCT7 &= (MMC_PMCT7_TBL & MMC_CS0_PMCT7_TBL & MMC_DETECT0_PMCT7_TBL); \ - PMCE0 &= (MMC_PMCE0_TBL & MMC_CS0_PMCE0_TBL & MMC_DETECT0_PMCE0_TBL); \ - PMCE1 &= (MMC_PMCE1_TBL & MMC_CS0_PMCE1_TBL & MMC_DETECT0_PMCE1_TBL); \ - PMCE5 &= (MMC_PMCE5_TBL & MMC_CS0_PMCE5_TBL & MMC_DETECT0_PMCE5_TBL); \ - PMCE6 &= (MMC_PMCE6_TBL & MMC_CS0_PMCE6_TBL & MMC_DETECT0_PMCE6_TBL); \ - CCDE &= (MMC_CCDE_TBL & MMC_CS0_CCDE_TBL & MMC_DETECT0_CCDE_TBL); \ - PFOE1 |= MMC_PFOE1_TBL; \ - MMC_PORT_DATAO = MMC_TRUE; /* DataOut "H" */ \ - MMC_PM_DATAO = MMC_FALSE; /* DataOut Output */ \ - MMC_PORT_CLK = MMC_TRUE; /* CLK "H" */ \ - MMC_PM_CLK = MMC_FALSE; /* CLK Output */ \ - MMC_PM_DATAI = MMC_TRUE; /* DataIn Input */ \ - MMC_PORT_CS0 = MMC_TRUE; /* CS0 "H" */ \ - MMC_PM_CS0 = MMC_FALSE; /* CS0 Output */ \ - MMC_DETECT0_INIT(); /* DETECT0 Input */ \ - MMC_PORT_CS1 = MMC_TRUE; /* CS1 "H" */ \ - MMC_PM_CS1 = MMC_FALSE; /* CS1 Output */ \ - MMC_DETECT1_INIT(); /* DETECT1 Input */ \ - } while (0) -#endif /* #if (MMC_SLOT_NUM > 1) */ - -/*------------------ DataIn control ------------------*/ -#define MMC_DATAI_INIT() do /* DataIn initial setting */ \ - { \ - } while (0) - -/*----------------- DataOut control ------------------*/ -#define MMC_DATAO_INIT() do /* DataOut initial setting */ \ - { \ - } while (0) - -#define MMC_DATAO_OPEN() do /* DataOut open setting */ \ - { \ - } while (0) - -/*------------------- CLK control --------------------*/ -#define MMC_CLK_INIT() do /* CLK initial setting */ \ - { \ - } while (0) - -#define MMC_CLK_OPEN() do /* CLK open setting */ \ - { \ - } while (0) - -/*------------------ DETECT control ------------------*/ -#if defined(MMC_DETECT0_CONNECTION) -#define MMC_DETECT0_INIT() do /* DETECT initial setting */ \ - { \ - MMC_PM_DETECT0 = MMC_TRUE; /* DETECT Input */ \ - } while (0) - -#define MMC_GET_DETECT0(Lv) do /* DETECT input control */ \ - { \ - Lv = MMC_PORT_DETECT0; \ - } while (0) -#else /* #if defined(MMC_DETECT0_CONNECTION) */ -#define MMC_DETECT0_INIT() /* DETECT initial setting */ -#define MMC_GET_DETECT0(Lv) /* DETECT input control */ -#endif /* #if defined(MMC_DETECT0_CONNECTION) */ - - -#if (MMC_SLOT_NUM > 1) -#if defined(MMC_DETECT1_CONNECTION) -#define MMC_DETECT1_INIT() do /* DETECT initial setting */ \ - { \ - MMC_PM_DETECT1 = MMC_TRUE; /* DETECT Input */ \ - } while (0) - -#define MMC_GET_DETECT1(Lv) do /* DETECT input control */ \ - { \ - Lv = MMC_PORT_DETECT1; \ - } while (0) -#else /* #if defined(MMC_DETECT0_CONNECTION) */ -#define MMC_DETECT1_INIT() /* DETECT initial setting */ -#define MMC_GET_DETECT1(Lv) /* DETECT input control */ -#endif /* #if defined(MMC_DETECT1_CONNECTION) */ -#endif /* #if (MMC_SLOT_NUM > 1) */ - -#if (MMC_SLOT_NUM == 1) -#define MMC_DETECT_INIT(SlotNo) do /* DETECT initial setting */ \ - { \ - MMC_DETECT0_INIT(); \ - } while (0) -#define MMC_GET_DETECT(SlotNo, Lv) do /* DETECT input control */ \ - { \ - Lv = MMC_NOT_CONNECT; /* Initialize by non-detection */ \ - MMC_GET_DETECT0(Lv); \ - } while (0) -#endif /* #if (MMC_SLOT_NUM > 1) */ - -#if (MMC_SLOT_NUM > 1) -#define MMC_DETECT_INIT(SlotNo) do /* DETECT initial setting */ \ - { \ - switch (SlotNo) { \ - case MMC_SLOT0: MMC_DETECT0_INIT(); break; \ - case MMC_SLOT1: MMC_DETECT1_INIT(); break; \ - default: break; \ - } \ - } while (0) -#define MMC_GET_DETECT(SlotNo, Lv) do /* DETECT input control */ \ - { \ - Lv = MMC_NOT_CONNECT; /* Initialize by non-detection */ \ - switch (SlotNo) \ - { \ - case MMC_SLOT0: MMC_GET_DETECT0(Lv); break; \ - case MMC_SLOT1: MMC_GET_DETECT1(Lv); break; \ - default: break; \ - } \ - } while (0) -#endif /* #if (MMC_SLOT_NUM > 1) */ - -/*-------------------- CS control --------------------*/ -#if (MMC_SLOT_NUM == 1) -#define MMC_CS_INIT(SlotNo) do /* CS initial setting */ \ - { \ - MMC_PORT_CS0 = MMC_HI; /* CS0 "H" */ \ - MMC_PM_CS0 = MMC_FALSE; /* CS0 Output */ \ - } while (0) - -#define MMC_CS_OPEN(SlotNo) do /* CS open setting */ \ - { \ - MMC_PM_CS0 = MMC_TRUE; /* CS0 Input */ \ - } while (0) - -#define MMC_SET_CS(SlotNo, Lv) do /* CS output control */ \ - { \ - MMC_PORT_CS0 = Lv; \ - } while (0) -#endif /* #if (MMC_SLOT_NUM == 1) */ - -#if (MMC_SLOT_NUM > 1) -#define MMC_CS_INIT(SlotNo) do /* CS initial setting */ \ - { \ - switch (SlotNo) \ - { \ - case MMC_SLOT0: \ - MMC_PORT_CS0 = MMC_HI; /* CS0 Output */ \ - MMC_PM_CS0 = MMC_FALSE; /* CS0 "H" */ \ - break; \ - case MMC_SLOT1: \ - MMC_PORT_CS1 = MMC_HI; /* CS1 Output */ \ - MMC_PM_CS1 = MMC_FALSE; /* CS1 "H" */ \ - break; \ - default: \ - break; \ - } \ - } while (0) - -#define MMC_CS_OPEN(SlotNo) do /* CS open setting */ \ - { \ - switch (SlotNo) \ - { \ - case MMC_SLOT0: MMC_PM_CS0 = MMC_TRUE; break; /* CS0 Input */ \ - case MMC_SLOT1: MMC_PM_CS1 = MMC_TRUE; break; /* CS1 Input */ \ - default: break; \ - } \ - } while (0) - -#define MMC_SET_CS(SlotNo, Lv) do /* CS output control */ \ - { \ - switch (SlotNo) \ - { \ - case MMC_SLOT0: MMC_PORT_CS0 = Lv; break; \ - case MMC_SLOT1: MMC_PORT_CS1 = Lv; break; \ - default: break; \ - } \ - } while (0) - -#endif /* #if (MMC_SLOT_NUM > 1) */ - -/*------------------- CSI control -------------------*/ -#define MMC_CSI_ERR_CLEAR() do /* CSI enable setting */ \ - { \ - MMC_CSI_SIRmnL = MMC_CSI_SIR_CLEAR; /* clear error flag */ \ - } while (0) - - -#define MMC_CSI_EI() do /* CSI enable setting */ \ - { \ - MMC_SAUmRES = MMC_FALSE; /* SAUm reset control */ \ - MMC_SAUmEN = MMC_TRUE; /* supply SAUm clock */ \ - __nop(); /* wait 4 clocks */ \ - __nop(); \ - __nop(); \ - __nop(); \ - MMC_CSI_SPSmL = (MMC_CSI_SPSmL & MMC_SPS_MASK | MMC_SPS_SET); /* Serial clock setting */ \ - MMC_CSI_STmn = MMC_TRUE; /* clear error flag */ \ - MMC_CSI_MKmn = MMC_TRUE; /* disable INTCSImn interrupt */ \ - MMC_CSI_IFmn = MMC_FALSE; /* clear INTCSImn interrupt flag */ \ - MMC_CSI_SIRmnL = MMC_CSI_SIR_CLEAR; /* clear error flag */ \ - MMC_CSI_SCRmn = MMC_SCR_INIT; /* init SCR setting */ \ - MMC_CSI_SOm |= MMC_CLKOUT_BIT; \ - MMC_CSI_SOm |= MMC_SOOUT_BIT; \ - MMC_CSI_SOEmn = MMC_TRUE; \ - MMC_CSI_ISC &= MMC_ISC_TBL; \ - } while (0) - -#define MMC_CSI_DI() do /* CSI disable setting */ \ - { \ - MMC_CSI_SCRmn = MMC_SCR_INIT; /* init SCR setting */ \ - } while (0) - -#define MMC_CSI_BRG_SET(BR_DATA) do /* CSI bit rate setting */ \ - { \ - MMC_CSI_SDRmn = ((uint16_t)BR_DATA << 9); /* Clock setting */ \ - } while (0) - -#define MMC_CSI_TX_EI() do /* CSI transmit enable setting */ \ - { \ - MMC_CSI_SMRmn = MMC_SMR_TX; /* Transmission mode setting */ \ - MMC_CSI_SCRmn = MMC_SCR_TX; /* Transmission mode setting */ \ - MMC_CSI_SOEmn = MMC_TRUE; \ - MMC_CSI_IFmn = MMC_FALSE; /* clear INTCSImn interrupt flag */ \ - MMC_CSI_SSmn = MMC_TRUE; /* enable CSIxy */ \ - } while (0) - -#define MMC_CSI_TRX_EI() do /* CSI transmit&receive enable setting */ \ - { \ - MMC_CSI_SMRmn = MMC_SMR_RX; /* Transmission mode setting */ \ - MMC_CSI_SCRmn = MMC_SCR_RX; /* Transmission mode setting */ \ - MMC_CSI_SOEmn = MMC_TRUE; /* enable CSI */ \ - MMC_CSI_IFmn = MMC_FALSE; /* clear INTCSImn interrupt flag */ \ - MMC_CSI_SSmn = MMC_TRUE; /* start CSI */ \ - } while (0) - -#define MMC_CSI_TX_DI() do /* CSI transmit disable setting */ \ - { \ - MMC_CSI_STmn = MMC_TRUE; /* stop CSI */ \ - MMC_CSI_SOEmn = MMC_FALSE; /* disable CSI output */ \ - MMC_CSI_IFmn = MMC_FALSE; /* clear INTCSImn interrupt flag */ \ - MMC_CSI_SOm |= ((uint16_t)1 << MMC_CLK_SO_BITNO) | ((uint16_t)1 << MMC_DATAO_SO_BITNO); /* Port init */ \ - } while (0) - -#define MMC_CSI_TRX_DI() do /* CSI transmit&receive disable setting */ \ - { \ - MMC_CSI_STmn = MMC_TRUE; /* stop CSI */ \ - MMC_CSI_SOEmn = MMC_FALSE; /* disable CSI output */ \ - MMC_CSI_IFmn = MMC_FALSE; /* clear INTCSImn interrupt flag */ \ - MMC_CSI_SOm |= ((uint16_t)1 << MMC_CLK_SO_BITNO) | ((uint16_t)1 << MMC_DATAO_SO_BITNO); /* Port init */ \ - } while (0) - -#define MMC_TXNEXT_CHECK() ((MMC_CSI_SSRmnL & MMC_TXNEXT_MASK) != 0) -#define MMC_TXNEXT_CLR() do \ - { \ - MMC_CSI_IFmn = MMC_FALSE; \ - } while (0) - -#define MMC_TXEND_CHECK() ((MMC_CSI_SSRmnL & MMC_TXEND_MASK) != 0) - - -#define MMC_CSI_ORER_CHECK() ((MMC_CSI_SSRmnL & MMC_OVF_MASK) != 0) - -#define MMC_RX_COMPLETE_CHECK() ((MMC_CSI_SSRmnL & MMC_RX_COMPLETE_MASK) == 0) -#define MMC_RXNEXT_CLR() - -/*----------------- CRC calculation ------------------*/ -#ifdef MMC_CRC_HARD -#define MMC_CRC_CLR() MMC_CRCD = 0x0000 -#define MMC_CRC_SET(Data) do \ - { \ - MMC_CRCIN = T_ExchgBit[Data]; \ - }while(0); - -#define MMC_CRC_GET(Data) Data = MMC_CRCD -#else /* #ifdef MMC_CRC_HARD */ -#define MMC_CRC_CLR() gMmc_CrcData.us = 0x0000 -#ifdef MTL_MCU_LITTLE -#define MMC_CRC_SET(Data) do \ - { \ - uint8_t ucTmp; \ - ucTmp = gMmc_CrcData.uc[0]; \ - gMmc_CrcData.us = T_Crc_Ccitt[gMmc_CrcData.uc[1] ^ Data]; \ - gMmc_CrcData.uc[1] = gMmc_CrcData.uc[1] ^ ucTmp; \ - } while (0) -#else /* #ifdef MTL_MCU_LITTLE */ -#define MMC_CRC_SET(Data) do \ - { \ - uint8_t ucTmp; \ - ucTmp = gMmc_CrcData.uc[1]; \ - gMmc_CrcData.us = T_Crc_Ccitt[gMmc_CrcData.uc[0] ^ Data]; \ - gMmc_CrcData.uc[0] = gMmc_CrcData.uc[0] ^ ucTmp; \ - } while (0) -#endif /* #ifdef MTL_MCU_LITTLE */ -#define MMC_CRC_GET(Data) Data = gMmc_CrcData.us -#endif /* #ifdef MMC_CRC_HARD */ - -#endif /* __MMC_SFR_H__ */ +/*""FILE COMMENT""******************************************************************* +* File Name : r_mmc_sfr.h +* Version : 1.00 +* Device(s) : RL78/G23 +* compiler : CC-RL +* H/W Platform : R7F100Gxx +* Description : MMC driver SFR common definitions +************************************************************************************* +* History : DD.MM.YYYY Version Description +* : 04.06.2021 Ver1.00 +*""FILE COMMENT END""***************************************************************/ +#ifndef __MMC_SFR_H__ +#define __MMC_SFR_H__ +#include "r_mmc_user_config.h" +#include "r_cg_macrodriver.h" + +/************************************************************************************************/ +/* Definitions */ +/************************************************************************************************/ +/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ +/* Do not change the following data. */ +/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ +#define _MMC_DRIVER_CPU_MODULE_NAME_ "RL78G23_CSI" + +//#define CAT_2(a,b) a##b +//#define CAT(a,b) CAT_2(a,b) + +/*----------------------------------------------------------------------------------------------*/ +/* Define the control port. */ +/*----------------------------------------------------------------------------------------------*/ + +#if (MMC_SAU_UNIT == 0) +#if (MMC_SAU_CHANNEL == 0) +#define MMC_CSI_UNIT 0 +#define MMC_CSI_CHANNEL 0 + +#if (MMC_CSI_PIN == 'A') +#define MMC_DATAI_PORTNO 1 /* MMC DataIn Port No. */ +#define MMC_DATAI_BITNO 1 /* MMC DataIn Bit No. */ +#define MMC_CLK_PORTNO 1 /* MMC CLK Port No. */ +#define MMC_CLK_BITNO 0 /* MMC CLK Bit No. */ +#define MMC_DATAO_PORTNO 1 /* MMC DataOut Port No. */ +#define MMC_DATAO_BITNO 2 /* MMC DataOut Bit No. */ + +/*----------- PMCEmn register value -----------*/ +#define MMC_PMCE1_TBL (uint8_t)0xF8 +/* 11111000B */ /* PMCEmn setting */ +/* |||||||+-------- PMCE10 : Set to 0 */ +/* ||||||+--------- PMCE11 : Set to 0 */ +/* |||||+---------- PMCE12 : Set to 0 */ +/* +++++----------- Reserved : Set to 1 */ + +/*----------- PFOE1n register value -----------*/ +#define MMC_PFOE1_TBL (uint8_t)0x05 +/* 00000101B */ /* PFOE1n setting */ +/* |||||||+-------- PFOE10 (P12) : Set to 0 */ +/* ||||||+--------- Reserved : Set to 1 */ +/* |||||+---------- PFOE12 (P10) : Set to 0 */ +/* +++++----------- Reserved : Set to 1 */ + +#elif (MMC_CSI_PIN == 'B') +#define MMC_DATAI_PORTNO 1 /* MMC DataIn Port No. */ +#define MMC_DATAI_BITNO 6 /* MMC DataIn Bit No. */ +#define MMC_CLK_PORTNO 5 /* MMC CLK Port No. */ +#define MMC_CLK_BITNO 5 /* MMC CLK Bit No. */ +#define MMC_DATAO_PORTNO 1 /* MMC DataOut Port No. */ +#define MMC_DATAO_BITNO 7 /* MMC DataOut Bit No. */ + +/*----------- PMCEmn register value -----------*/ +#define MMC_PMCE1_TBL (uint8_t)0x3F +/* 00111111B */ /* PMCEmn setting */ +/* ||++++++-------- Reserved : Set to 1 */ +/* |+-------------- PMCE16 : Set to 0 */ +/* +--------------- PMCE17 : Set to 0 */ + +/*----------- CCDE register value -----------*/ +#define MMC_CCDE_TBL (uint8_t)0xFC +/* 11111100B */ /* CCDE setting */ +/* |||||||+-------- CCDE00 (P16) : Set to 0 */ +/* ||||||+--------- CCDE01 (P17) : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ + +/*----------- PFOE1n register value -----------*/ +#define MMC_PFOE1_TBL (uint8_t)0x05 +/* 00000101B */ /* PFOE1n setting */ +/* |||||||+-------- PFOE10 (P17) : Set to 1 */ +/* ||||||+--------- Reserved : Set to 0 */ +/* |||||+---------- PFOE12 (P55) : Set to 1 */ +/* +++++----------- Reserved : Set to 0 */ + +#endif /* MMC_CSI_PIN */ + +#define MMC_CSI_SIR_CLEAR (uint8_t)0x03 +/* 00000011B */ /* SIRms setting */ +/* |||||||+-------- OVCTmn : Clear */ +/* ||||||+--------- PECTmn : Clear */ +/* ++++++---------- Reserved : Set to 0 */ + +#define MMC_CLK_SO_BITNO 8 +#define MMC_DATAO_SO_BITNO 0 + +#elif (MMC_SAU_CHANNEL == 1) +#define MMC_CSI_UNIT 0 +#define MMC_CSI_CHANNEL 1 + +#define MMC_DATAI_PORTNO 7 /* MMC DataIn Port No. */ +#define MMC_DATAI_BITNO 4 /* MMC DataIn Bit No. */ +#define MMC_CLK_PORTNO 7 /* MMC CLK Port No. */ +#define MMC_CLK_BITNO 5 /* MMC CLK Bit No. */ +#define MMC_DATAO_PORTNO 7 /* MMC DataOut Port No. */ +#define MMC_DATAO_BITNO 3 /* MMC DataOut Bit No. */ + +#define MMC_CSI_SIR_CLEAR (uint8_t)0x07 +/* 00000111B */ /* SIRms setting */ +/* |||||||+-------- OVCTmn : Clear */ +/* ||||||+--------- PECTmn : Clear */ +/* |||||+---------- FECTmn : Clear */ +/* +++++----------- Reserved : Set to 0 */ + +/*----------- PMCTxx register value -----------*/ +#define MMC_PMCT7_TBL (uint8_t)0xC7 +/* 11000111B */ /* PMCTmn setting */ +/* |||||+++-------- Reserved : Set to 1 */ +/* ||||+----------- PMCT73 : Set to 0 */ +/* |||+------------ PMCT74 : Set to 0 */ +/* ||+------------- PMCT75 : Set to 0 */ +/* +++++----------- Reserved : Set to 1 */ + +#define MMC_CLK_SO_BITNO 9 +#define MMC_DATAO_SO_BITNO 1 + +#elif (MMC_SAU_CHANNEL == 2) +#define MMC_CSI_UNIT 1 +#define MMC_CSI_CHANNEL 0 + +#define MMC_DATAI_PORTNO 0 /* MMC DataIn Port No. */ +#define MMC_DATAI_BITNO 3 /* MMC DataIn Bit No. */ +#define MMC_CLK_PORTNO 0 /* MMC CLK Port No. */ +#define MMC_CLK_BITNO 4 /* MMC CLK Bit No. */ +#define MMC_DATAO_PORTNO 0 /* MMC DataOut Port No. */ +#define MMC_DATAO_BITNO 2 /* MMC DataOut Bit No. */ + +/*----------- PMCAxx register value -----------*/ +#define MMC_PMCA0_TBL (uint8_t)0xF3 +/* 11110011B */ /* PMCAmn setting */ +/* ||||||++-------- Reserved : Set to 1 */ +/* |||||+---------- PMCA02 : Set to 0 */ +/* ||||++---------- PMCA03 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ + +/*----------- PMCTxx register value -----------*/ +#define MMC_PMCT0_TBL (uint8_t)0xF3 +/* 11110011B */ /* PMCTmn setting */ +/* ||||||++-------- Reserved : Set to 1 */ +/* |||||+---------- PMCT02 : Set to 0 */ +/* ||||++---------- PMCT03 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ + +#define MMC_CSI_SIR_CLEAR (uint8_t)0x03 +/* 00000011B */ /* SIRms setting */ +/* |||||||+-------- OVCTmn : Clear */ +/* ||||||+--------- PECTmn : Clear */ +/* ++++++---------- Reserved : Set to 0 */ + +#define MMC_CLK_SO_BITNO 10 +#define MMC_DATAO_SO_BITNO 2 + +#elif (MMC_SAU_CHANNEL == 3) +#define MMC_CSI_UNIT 1 +#define MMC_CSI_CHANNEL 1 + +#define MMC_DATAI_PORTNO 5 /* MMC DataIn Port No. */ +#define MMC_DATAI_BITNO 0 /* MMC DataIn Bit No. */ +#define MMC_CLK_PORTNO 3 /* MMC CLK Port No. */ +#define MMC_CLK_BITNO 0 /* MMC CLK Bit No. */ +#define MMC_DATAO_PORTNO 5 /* MMC DataOut Port No. */ +#define MMC_DATAO_BITNO 1 /* MMC DataOut Bit No. */ + +/*----------- PMCTxx register value -----------*/ +#define MMC_PMCT3_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCTmn setting */ +/* |||||||+-------- PMCT30 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ + +/*----------- PMCTxx register value -----------*/ +#define MMC_PMCT5_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCTmn setting */ +/* |||||||+-------- PMCT50 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ + +/*----------- PMCExx register value -----------*/ +#define MMC_PMCE5_TBL (uint8_t)0xFC +/* 11111100B */ /* PMCEmn setting */ +/* |||||||+-------- PMCE50 : Set to 0 */ +/* ||||||+--------- PMCE51 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ + +/*----------- CCDE register value -----------*/ +#define MMC_CCDE_TBL (uint8_t)0xF3 +/* 11110011B */ /* CCDE setting */ +/* ||||||++-------- Reserved : Set to 1 */ +/* |||||+---------- CCDE02 (P51) : Set to 0 */ +/* ||||+----------- CCDE03 (P50) : Set to 0 */ +/* ++++------------ Reserved : Set to 1 */ + +#define MMC_CSI_SIR_CLEAR (uint8_t)0x07 +/* 00000111B */ /* SIRms setting */ +/* |||||||+-------- OVCTmn : Clear */ +/* ||||||+--------- PECTmn : Clear */ +/* |||||+---------- FECTmn : Clear */ +/* +++++----------- Reserved : Set to 0 */ + +#define MMC_CLK_SO_BITNO 11 +#define MMC_DATAO_SO_BITNO 3 + +#endif /* #if (MMC_SAU_CHANNEL == x) */ + +#elif (MMC_SAU_UNIT == 1) +#if (MMC_SAU_CHANNEL == 0) +#define MMC_CSI_UNIT 2 +#define MMC_CSI_CHANNEL 0 + +#define MMC_DATAI_PORTNO 1 /* MMC DataIn Port No. */ +#define MMC_DATAI_BITNO 4 /* MMC DataIn Bit No. */ +#define MMC_CLK_PORTNO 1 /* MMC CLK Port No. */ +#define MMC_CLK_BITNO 5 /* MMC CLK Bit No. */ +#define MMC_DATAO_PORTNO 1 /* MMC DataOut Port No. */ +#define MMC_DATAO_BITNO 3 /* MMC DataOut Bit No. */ + +#define MMC_CSI_SIR_CLEAR (uint8_t)0x03 +/* 00000011B */ /* SIRms setting */ +/* |||||||+-------- OVCTmn : Clear */ +/* ||||||+--------- PECTmn : Clear */ +/* ++++++---------- Reserved : Set to 0 */ + +/*----------- PMCAmn register value -----------*/ +#define MMC_PMCA1_TBL (uint8_t)0xF7 +/* 11110111B */ /* PMCAmn setting */ +/* |||||+++-------- Reserved : Set to 1 */ +/* ||||+----------- PMCA13 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ + +/*----------- PMCExx register value -----------*/ +#define MMC_PMCE1_TBL (uint8_t)0xC7 +/* 11000111B */ /* PMCEmn setting */ +/* |||||+++-------- Reserved : Set to 1 */ +/* ||||+----------- PMCE13 : Set to 0 */ +/* |||+------------ PMCE14 : Set to 0 */ +/* ||+------------- PMCE15 : Set to 0 */ +/* ++-------------- Reserved : Set to 1 */ + +#define MMC_CLK_SO_BITNO 8 +#define MMC_DATAO_SO_BITNO 0 + +#elif (MMC_SAU_CHANNEL == 1) +#define MMC_CSI_UNIT 2 +#define MMC_CSI_CHANNEL 1 + +#define MMC_DATAI_PORTNO 7 /* MMC DataIn Port No. */ +#define MMC_DATAI_BITNO 1 /* MMC DataIn Bit No. */ +#define MMC_CLK_PORTNO 7 /* MMC CLK Port No. */ +#define MMC_CLK_BITNO 0 /* MMC CLK Bit No. */ +#define MMC_DATAO_PORTNO 7 /* MMC DataOut Port No. */ +#define MMC_DATAO_BITNO 2 /* MMC DataOut Bit No. */ + +#define MMC_CSI_SIR_CLEAR (uint8_t)0x07 +/* 00000111B */ /* SIRms setting */ +/* |||||||+-------- OVCTmn : Clear */ +/* ||||||+--------- PECTmn : Clear */ +/* |||||+---------- FECTmn : Clear */ +/* +++++----------- Reserved : Set to 0 */ + +/*----------- PMCTxx register value -----------*/ +#define MMC_PMCT7_TBL (uint8_t)0xF8 +/* 11111000B */ /* PMCTmn setting */ +/* |||||||+-------- PMCT70 : Set to 0 */ +/* ||||||+--------- PMCT71 : Set to 0 */ +/* |||||+---------- PMCT72 : Set to 0 */ +/* +++++----------- Reserved : Set to 1 */ + +#define MMC_CLK_SO_BITNO 9 +#define MMC_DATAO_SO_BITNO 1 + + +#endif /* MMC_SAU_CHANNEL */ +#endif /* MMC_SAU_UNIT */ + +/*----------- PMCAxx register value -----------*/ +#ifndef MMC_PMCA0_TBL +#define MMC_PMCA0_TBL (uint8_t)0xFF +#endif /* MMC_PMCA0_TBL */ + +#ifndef MMC_PMCA1_TBL +#define MMC_PMCA1_TBL (uint8_t)0xFF +#endif /* MMC_PMCA1_TBL */ + +#define MMC_PMCA2_TBL (uint8_t)0xFF +#define MMC_PMCA12_TBL (uint8_t)0xFF +#define MMC_PMCA14_TBL (uint8_t)0xFF + +/*----------- PMCTxx register value -----------*/ +#ifndef MMC_PMCT0_TBL +#define MMC_PMCT0_TBL (uint8_t)0xFF +#endif /* MMC_PMCT0_TBL */ +#ifndef MMC_PMCT3_TBL +#define MMC_PMCT3_TBL (uint8_t)0xFF +#endif /* MMC_PMCT3_TBL */ +#ifndef MMC_PMCT5_TBL +#define MMC_PMCT5_TBL (uint8_t)0xFF +#endif /* MMC_PMCT5_TBL */ +#ifndef MMC_PMCT7_TBL +#define MMC_PMCT7_TBL (uint8_t)0xFF +#endif /* MMC_PMCT7_TBL */ +#define MMC_PMCT2_TBL (uint8_t)0xFF +#define MMC_PMCT6_TBL (uint8_t)0xFF + +/*----------- PMCExx register value -----------*/ +#ifndef MMC_PMCE1_TBL +#define MMC_PMCE1_TBL (uint8_t)0xFF +#endif /* MMC_PMCE1_TBL */ +#ifndef MMC_PMCE5_TBL +#define MMC_PMCE5_TBL (uint8_t)0xFF +#endif /* MMC_PMCE5_TBL */ +#define MMC_PMCE0_TBL (uint8_t)0xFF +#define MMC_PMCE6_TBL (uint8_t)0xFF + +/*----------- CCDE register value -----------*/ +#ifndef MMC_CCDE_TBL +#define MMC_CCDE_TBL (uint8_t)0xFF +#endif /* MMC_CCDE_TBL */ + +/*----------- PFOE1 register value -----------*/ +#ifndef MMC_PFOE1_TBL +#define MMC_PFOE1_TBL (uint8_t)0x00 +#endif /* MMC_PFOE1_TBL */ + +/*----------- ISC register value -----------*/ +#if (MMC_CSI_UNIT == 0) +#if (MMC_CSI_CHANNEL == 0) +#define MMC_ISC_TBL (uint8_t)0xE3 +/* 11100011B */ /* ISC setting */ +/* ||||||++-------- Reserved : Set to 1 */ +/* |||||+---------- ISC2 : Set to 0 */ +/* ||||+----------- ISC3 : Set to 0 */ +/* |||+------------ ISC4 : Set to 0 */ +/* +++------------- Reserved : Set to 1 */ +#elif (MMC_CSI_CHANNEL == 1) +#define MMC_ISC_TBL (uint8_t)0x1F +/* 00011111B */ /* ISC setting */ +/* |||+++++-------- Reserved : Set to 1 */ +/* ||+------------- ISC2 : Set to 0 */ +/* |+-------------- ISC3 : Set to 0 */ +/* +--------------- ISC4 : Set to 0 */ +#endif /* MMC_CSI_CHANNEL */ +#else +#define MMC_ISC_TBL (uint8_t)0xFF +#endif /* MMC_CSI_UNIT */ + +/*----------- PMCAxx (CS0) register value -----------*/ +#if (MMC_CS0_PORTNO == 0) +#if (MMC_CS0_BITNO == 0) +#define MMC_CS0_PMCA0_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCAmn setting */ +/* |||||||+-------- PMCA00 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 1) +#define MMC_CS0_PMCA0_TBL (uint8_t)0xFD +/* 11111101B */ /* PMCAmn setting */ +/* |||||||+-------- Reserved : Set to 1 */ +/* ||||||+--------- PMCA01 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 2) +#define MMC_CS0_PMCA0_TBL (uint8_t)0xFB +/* 11111011B */ /* PMCAmn setting */ +/* ||||||++-------- Reserved : Set to 1 */ +/* |||||+---------- PMCA02 : Set to 0 */ +/* +++++----------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 3) +#define MMC_CS0_PMCA0_TBL (uint8_t)0xF7 +/* 11110111B */ /* PMCAmn setting */ +/* |||||+++-------- Reserved : Set to 1 */ +/* ||||+----------- PMCA03 : Set to 0 */ +/* ++++------------ Reserved : Set to 1 */ +#endif /* MMC_CS0_BITNO */ + +#elif (MMC_CS0_PORTNO == 1) +#if (MMC_CS0_BITNO == 3) +#define MMC_CS0_PMCA1_TBL (uint8_t)0xF7 +/* 11110111B */ /* PMCAmn setting */ +/* |||||+++-------- Reserved : Set to 1 */ +/* ||||+----------- PMCA13 : Set to 0 */ +/* ++++------------ Reserved : Set to 1 */ +#endif /* MMC_CS0_BITNO */ + +#elif (MMC_CS0_PORTNO == 2) +#if (MMC_CS0_BITNO == 0) +#define MMC_CS0_PMCA2_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCAmn setting */ +/* |||||||+-------- PMCA00 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 1) +#define MMC_CS0_PMCA2_TBL (uint8_t)0xFD +/* 11111101B */ /* PMCAmn setting */ +/* |||||||+-------- Reserved : Set to 1 */ +/* ||||||+--------- PMCA21 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 2) +#define MMC_CS0_PMCA2_TBL (uint8_t)0xFB +/* 11111011B */ /* PMCAmn setting */ +/* ||||||++-------- Reserved : Set to 1 */ +/* |||||+---------- PMCA22 : Set to 0 */ +/* +++++----------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 3) +#define MMC_CS0_PMCA2_TBL (uint8_t)0xF7 +/* 11110111B */ /* PMCAmn setting */ +/* |||||+++-------- Reserved : Set to 1 */ +/* ||||+----------- PMCA23 : Set to 0 */ +/* ++++------------ Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 4) +#define MMC_CS0_PMCA2_TBL (uint8_t)0xEF +/* 11101111B */ /* PMCAmn setting */ +/* ||||++++-------- Reserved : Set to 1 */ +/* |||+------------ PMCA24 : Set to 0 */ +/* +++------------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 5) +#define MMC_CS0_PMCA2_TBL (uint8_t)0xDF +/* 11011111B */ /* PMCAmn setting */ +/* |||+++++-------- Reserved : Set to 1 */ +/* ||+------------- PMCA25 : Set to 0 */ +/* ++-------------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 6) +#define MMC_CS0_PMCA2_TBL (uint8_t)0xBF +/* 10111111B */ /* PMCAmn setting */ +/* ||++++++-------- Reserved : Set to 1 */ +/* |+-------------- PMCA26 : Set to 0 */ +/* +--------------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 7) +#define MMC_CS0_PMCA2_TBL (uint8_t)0x7F +/* 01111111B */ /* PMCAmn setting */ +/* |+++++++-------- Reserved : Set to 1 */ +/* +--------------- PMCA27 : Set to 0 */ +#endif /* MMC_CS0_BITNO */ + +#elif (MMC_CS0_PORTNO == 12) +#if (MMC_CS0_BITNO == 0) +#define MMC_CS0_PMCA12_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCAmn setting */ +/* |||||||+-------- PMCA120 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#endif /* MMC_CS0_BITNO */ + +#elif (MMC_CS0_PORTNO == 14) +#if (MMC_CS0_BITNO == 7) +#define MMC_CS0_PMCA14_TBL (uint8_t)0x7F +/* 01111111B */ /* PMCAmn setting */ +/* |+++++++-------- Reserved : Set to 1 */ +/* +--------------- PMCA147 : Set to 0 */ +#endif /* MMC_CS0_BITNO */ +#endif /* MMC_CS0_PORTNO */ + +#ifndef MMC_CS0_PMCA0_TBL +#define MMC_CS0_PMCA0_TBL (uint8_t)0xFF +#endif /* MMC_CS0_PMCA0_TBL */ +#ifndef MMC_CS0_PMCA1_TBL +#define MMC_CS0_PMCA1_TBL (uint8_t)0xFF +#endif /* MMC_CS0_PMCA1_TBL */ +#ifndef MMC_CS0_PMCA2_TBL +#define MMC_CS0_PMCA2_TBL (uint8_t)0xFF +#endif /* MMC_CS0_PMCA2_TBL */ +#ifndef MMC_CS0_PMCA12_TBL +#define MMC_CS0_PMCA12_TBL (uint8_t)0xFF +#endif /* MMC_CS0_PMCA12_TBL */ +#ifndef MMC_CS0_PMCA14_TBL +#define MMC_CS0_PMCA14_TBL (uint8_t)0xFF +#endif /* MMC_CS0_PMCA14_TBL */ + +/*----------- PMCTxx (CS0) register value -----------*/ +#if (MMC_CS0_PORTNO == 0) +#if (MMC_CS0_BITNO == 0) +#define MMC_CS0_PMCT0_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCTmn setting */ +/* |||||||+-------- PMCT00 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 1) +#define MMC_CS0_PMCT0_TBL (uint8_t)0xFD +/* 11111101B */ /* PMCTmn setting */ +/* |||||||+-------- Reserved : Set to 1 */ +/* ||||||+--------- PMCT01 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 2) +#define MMC_CS0_PMCT0_TBL (uint8_t)0xFB +/* 11111011B */ /* PMCTmn setting */ +/* ||||||++-------- Reserved : Set to 1 */ +/* |||||+---------- PMCT02 : Set to 0 */ +/* +++++----------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 3) +#define MMC_CS0_PMCT0_TBL (uint8_t)0xF7 +/* 11110111B */ /* PMCTmn setting */ +/* |||||+++-------- Reserved : Set to 1 */ +/* ||||+----------- PMCT03 : Set to 0 */ +/* ++++------------ Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 5) +#define MMC_CS0_PMCT0_TBL (uint8_t)0xDF +/* 11011111B */ /* PMCTmn setting */ +/* |||+++++-------- Reserved : Set to 1 */ +/* ||+------------- PMCT05 : Set to 0 */ +/* ++-------------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 6) +#define MMC_CS0_PMCT0_TBL (uint8_t)0xBF +/* 10111111B */ /* PMCTmn setting */ +/* ||++++++-------- Reserved : Set to 1 */ +/* |+-------------- PMCT06 : Set to 0 */ +/* +--------------- Reserved : Set to 1 */ +#endif /* MMC_CS0_BITNO */ + +#elif (MMC_CS0_PORTNO == 2) +#if (MMC_CS0_BITNO == 2) +#define MMC_CS0_PMCT2_TBL (uint8_t)0xFB +/* 11111011B */ /* PMCTmn setting */ +/* ||||||++-------- Reserved : Set to 1 */ +/* |||||+---------- PMCT22 : Set to 0 */ +/* +++++----------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 3) +#define MMC_CS0_PMCT2_TBL (uint8_t)0xF7 +/* 11110111B */ /* PMCTmn setting */ +/* |||||+++-------- Reserved : Set to 1 */ +/* ||||+----------- PMCT23 : Set to 0 */ +/* ++++------------ Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 4) +#define MMC_CS0_PMCT2_TBL (uint8_t)0xEF +/* 11101111B */ /* PMCTmn setting */ +/* ||||++++-------- Reserved : Set to 1 */ +/* |||+------------ PMCT24 : Set to 0 */ +/* +++------------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 5) +#define MMC_CS0_PMCT2_TBL (uint8_t)0xDF +/* 11011111B */ /* PMCTmn setting */ +/* |||+++++-------- Reserved : Set to 1 */ +/* ||+------------- PMCT25 : Set to 0 */ +/* ++-------------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 6) +#define MMC_CS0_PMCT2_TBL (uint8_t)0xBF +/* 10111111B */ /* PMCTmn setting */ +/* ||++++++-------- Reserved : Set to 1 */ +/* |+-------------- PMCT26 : Set to 0 */ +/* +--------------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 7) +#define MMC_CS0_PMCT2_TBL (uint8_t)0x7F +/* 01111111B */ /* PMCTmn setting */ +/* |+++++++-------- Reserved : Set to 1 */ +/* +--------------- PMCT27 : Set to 0 */ +#endif /* MMC_CS0_BITNO */ + +#elif (MMC_CS0_PORTNO == 3) +#if (MMC_CS0_BITNO == 0) +#define MMC_CS0_PMCT3_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCTmn setting */ +/* |||||||+-------- PMCT30 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 1) +#define MMC_CS0_PMCT3_TBL (uint8_t)0xFD +/* 11111101B */ /* PMCTmn setting */ +/* |||||||+-------- Reserved : Set to 1 */ +/* ||||||+--------- PMCT31 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ +#endif /* MMC_CS0_BITNO */ + +#elif (MMC_CS0_PORTNO == 5) +#if (MMC_CS0_BITNO == 0) +#define MMC_CS0_PMCT5_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCTmn setting */ +/* |||||||+-------- PMCT50 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#endif /* MMC_CS0_BITNO */ + +#elif (MMC_CS0_PORTNO == 6) +#if (MMC_CS0_BITNO == 4) +#define MMC_CS0_PMCT6_TBL (uint8_t)0xEF +/* 11101111B */ /* PMCTmn setting */ +/* ||||++++-------- Reserved : Set to 1 */ +/* |||+------------ PMCT64 : Set to 0 */ +/* +++------------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 5) +#define MMC_CS0_PMCT6_TBL (uint8_t)0xDF +/* 11011111B */ /* PMCTmn setting */ +/* |||+++++-------- Reserved : Set to 1 */ +/* ||+------------- PMCT65 : Set to 0 */ +/* ++-------------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 6) +#define MMC_CS0_PMCT6_TBL (uint8_t)0xBF +/* 10111111B */ /* PMCTmn setting */ +/* ||++++++-------- Reserved : Set to 1 */ +/* |+-------------- PMCT66 : Set to 0 */ +/* +--------------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 7) +#define MMC_CS0_PMCT6_TBL (uint8_t)0x7F +/* 01111111B */ /* PMCTmn setting */ +/* |+++++++-------- Reserved : Set to 1 */ +/* +--------------- PMCT67 : Set to 0 */ +#endif /* MMC_CS0_BITNO */ + +#elif (MMC_CS0_PORTNO == 7) +#if (MMC_CS0_BITNO == 0) +#define MMC_CS0_PMCT7_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCTmn setting */ +/* |||||||+-------- PMCT70 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 1) +#define MMC_CS0_PMCT7_TBL (uint8_t)0xFD +/* 11111101B */ /* PMCTmn setting */ +/* |||||||+-------- Reserved : Set to 1 */ +/* ||||||+--------- PMCT71 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 2) +#define MMC_CS0_PMCT7_TBL (uint8_t)0xFB +/* 11111011B */ /* PMCTmn setting */ +/* ||||||++-------- Reserved : Set to 1 */ +/* |||||+---------- PMCT72 : Set to 0 */ +/* +++++----------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 3) +#define MMC_CS0_PMCT7_TBL (uint8_t)0xF7 +/* 11110111B */ /* PMCTmn setting */ +/* |||||+++-------- Reserved : Set to 1 */ +/* ||||+----------- PMCT73 : Set to 0 */ +/* ++++------------ Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 4) +#define MMC_CS0_PMCT7_TBL (uint8_t)0xEF +/* 11101111B */ /* PMCTmn setting */ +/* ||||++++-------- Reserved : Set to 1 */ +/* |||+------------ PMCT74 : Set to 0 */ +/* +++------------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 5) +#define MMC_CS0_PMCT7_TBL (uint8_t)0xDF +/* 11011111B */ /* PMCTmn setting */ +/* |||+++++-------- Reserved : Set to 1 */ +/* ||+------------- PMCT75 : Set to 0 */ +/* ++-------------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 6) +#define MMC_CS0_PMCT7_TBL (uint8_t)0xBF +/* 10111111B */ /* PMCTmn setting */ +/* ||++++++-------- Reserved : Set to 1 */ +/* |+-------------- PMCT76 : Set to 0 */ +/* +--------------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 7) +#define MMC_CS0_PMCT7_TBL (uint8_t)0x7F +/* 01111111B */ /* PMCTmn setting */ +/* |+++++++-------- Reserved : Set to 1 */ +/* +--------------- PMCT77 : Set to 0 */ +#endif /* MMC_CS0_BITNO */ +#endif /* MMC_CS0_PORTNO */ + +#ifndef MMC_CS0_PMCT0_TBL +#define MMC_CS0_PMCT0_TBL (uint8_t)0xFF +#endif /* MMC_CS0_PMCT0_TBL */ +#ifndef MMC_CS0_PMCT2_TBL +#define MMC_CS0_PMCT2_TBL (uint8_t)0xFF +#endif /* MMC_CS0_PMCT2_TBL */ +#ifndef MMC_CS0_PMCT3_TBL +#define MMC_CS0_PMCT3_TBL (uint8_t)0xFF +#endif /* MMC_CS0_PMCT3_TBL */ +#ifndef MMC_CS0_PMCT5_TBL +#define MMC_CS0_PMCT5_TBL (uint8_t)0xFF +#endif /* MMC_CS0_PMCT5_TBL */ +#ifndef MMC_CS0_PMCT6_TBL +#define MMC_CS0_PMCT6_TBL (uint8_t)0xFF +#endif /* MMC_CS0_PMCT6_TBL */ +#ifndef MMC_CS0_PMCT7_TBL +#define MMC_CS0_PMCT7_TBL (uint8_t)0xFF +#endif /* MMC_CS0_PMCT7_TBL */ + +/*----------- PMCExx (CS0) register value -----------*/ +#if (MMC_CS0_PORTNO == 0) +#if (MMC_CS0_BITNO == 1) +#define MMC_CS0_PMCE0_TBL (uint8_t)0xFD +/* 11111101B */ /* PMCEmn setting */ +/* |||||||+-------- Reserved : Set to 1 */ +/* ||||||+--------- PMCE01 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ +#endif /* MMC_CS0_BITNO */ + +#elif (MMC_CS0_PORTNO == 1) +#if (MMC_CS0_BITNO == 0) +#define MMC_CS0_PMCE1_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCEmn setting */ +/* |||||||+-------- PMCE10 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 1) +#define MMC_CS0_PMCE1_TBL (uint8_t)0xFD +/* 11111101B */ /* PMCEmn setting */ +/* |||||||+-------- Reserved : Set to 1 */ +/* ||||||+--------- PMCE11 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 2) +#define MMC_CS0_PMCE1_TBL (uint8_t)0xFB +/* 11111011B */ /* PMCEmn setting */ +/* ||||||++-------- Reserved : Set to 1 */ +/* |||||+---------- PMCE12 : Set to 0 */ +/* +++++----------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 3) +#define MMC_CS0_PMCE1_TBL (uint8_t)0xF7 +/* 11110111B */ /* PMCEmn setting */ +/* |||||+++-------- Reserved : Set to 1 */ +/* ||||+----------- PMCE13 : Set to 0 */ +/* ++++------------ Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 4) +#define MMC_CS0_PMCE1_TBL (uint8_t)0xEF +/* 11101111B */ /* PMCEmn setting */ +/* ||||++++-------- Reserved : Set to 1 */ +/* |||+------------ PMCE14 : Set to 0 */ +/* +++------------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 5) +#define MMC_CS0_PMCE1_TBL (uint8_t)0xDF +/* 11011111B */ /* PMCEmn setting */ +/* |||+++++-------- Reserved : Set to 1 */ +/* ||+------------- PMCE15 : Set to 0 */ +/* ++-------------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 6) +#define MMC_CS0_PMCE1_TBL (uint8_t)0xBF +/* 10111111B */ /* PMCEmn setting */ +/* ||++++++-------- Reserved : Set to 1 */ +/* |+-------------- PMCE16 : Set to 0 */ +/* +--------------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 7) +#define MMC_CS0_PMCE1_TBL (uint8_t)0x7F +/* 01111111B */ /* PMCEmn setting */ +/* |+++++++-------- Reserved : Set to 1 */ +/* +--------------- PMCE17 : Set to 0 */ +#endif /* MMC_CS0_BITNO */ + +#elif (MMC_CS0_PORTNO == 5) +#if (MMC_CS0_BITNO == 0) +#define MMC_CS0_PMCE5_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCEmn setting */ +/* |||||||+-------- PMCE50 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 1) +#define MMC_CS0_PMCE5_TBL (uint8_t)0xFD +/* 11111101B */ /* PMCEmn setting */ +/* |||||||+-------- Reserved : Set to 1 */ +/* ||||||+--------- PMCE51 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ +#endif /* MMC_CS0_BITNO */ + +#elif (MMC_CS0_PORTNO == 6) +#if (MMC_CS0_BITNO == 0) +#define MMC_CS0_PMCE6_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCEmn setting */ +/* |||||||+-------- PMCE60 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 1) +#define MMC_CS0_PMCE6_TBL (uint8_t)0xFD +/* 11111101B */ /* PMCEmn setting */ +/* |||||||+-------- Reserved : Set to 1 */ +/* ||||||+--------- PMCE61 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ +#endif /* MMC_CS0_BITNO */ +#endif /* MMC_CS0_PORTNO */ + +#ifndef MMC_CS0_PMCE0_TBL +#define MMC_CS0_PMCE0_TBL (uint8_t)0xFF +#endif /* MMC_CS0_PMCE0_TBL */ +#ifndef MMC_CS0_PMCE1_TBL +#define MMC_CS0_PMCE1_TBL (uint8_t)0xFF +#endif /* MMC_CS0_PMCE1_TBL */ +#ifndef MMC_CS0_PMCE5_TBL +#define MMC_CS0_PMCE5_TBL (uint8_t)0xFF +#endif /* MMC_CS0_PMCE5_TBL */ +#ifndef MMC_CS0_PMCE6_TBL +#define MMC_CS0_PMCE6_TBL (uint8_t)0xFF +#endif /* MMC_CS0_PMCE6_TBL */ + +/*----------- CCDE (CS0) register value -----------*/ +#if (MMC_CS0_PORTNO == 1) +#if (MMC_CS0_BITNO == 6) +#define MMC_CS0_CCDE_TBL (uint8_t)0xFE +/* 11111110B */ /* CCDE setting */ +/* |||||||+-------- CCDE00 (P16) : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#elif (MMC_CS0_BITNO == 7) +#define MMC_CS0_CCDE_TBL (uint8_t)0xFD +/* 11111101B */ /* CCDE setting */ +/* |||||||+-------- Reserved : Set to 1 */ +/* ||||||+--------- CCDE01 (P17) : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ +#endif /* MMC_CS0_BITNO */ +#endif /* MMC_CS0_PORTNO */ + +#ifndef MMC_CS0_CCDE_TBL +#define MMC_CS0_CCDE_TBL (uint8_t)0xFF +#endif /* MMC_CS0_CCDE_TBL */ + + +/*----------- PMCAxx (DETECT0) register value -----------*/ +#if (MMC_DETECT0_PORTNO == 0) +#if (MMC_DETECT0_BITNO == 0) +#define MMC_DETECT0_PMCA0_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCAmn setting */ +/* |||||||+-------- PMCA00 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 1) +#define MMC_DETECT0_PMCA0_TBL (uint8_t)0xFD +/* 11111101B */ /* PMCAmn setting */ +/* |||||||+-------- Reserved : Set to 1 */ +/* ||||||+--------- PMCA01 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 2) +#define MMC_DETECT0_PMCA0_TBL (uint8_t)0xFB +/* 11111011B */ /* PMCAmn setting */ +/* ||||||++-------- Reserved : Set to 1 */ +/* |||||+---------- PMCA02 : Set to 0 */ +/* +++++----------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 3) +#define MMC_DETECT0_PMCA0_TBL (uint8_t)0xF7 +/* 11110111B */ /* PMCAmn setting */ +/* |||||+++-------- Reserved : Set to 1 */ +/* ||||+----------- PMCA03 : Set to 0 */ +/* ++++------------ Reserved : Set to 1 */ +#endif /* MMC_DETECT0_BITNO */ + +#elif (MMC_DETECT0_PORTNO == 1) +#if (MMC_DETECT0_BITNO == 3) +#define MMC_DETECT0_PMCA1_TBL (uint8_t)0xF7 +/* 11110111B */ /* PMCAmn setting */ +/* |||||+++-------- Reserved : Set to 1 */ +/* ||||+----------- PMCA13 : Set to 0 */ +/* ++++------------ Reserved : Set to 1 */ +#endif /* MMC_DETECT0_BITNO */ + +#elif (MMC_DETECT0_PORTNO == 2) +#if (MMC_DETECT0_BITNO == 0) +#define MMC_DETECT0_PMCA2_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCAmn setting */ +/* |||||||+-------- PMCA00 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 1) +#define MMC_DETECT0_PMCA2_TBL (uint8_t)0xFD +/* 11111101B */ /* PMCAmn setting */ +/* |||||||+-------- Reserved : Set to 1 */ +/* ||||||+--------- PMCA21 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 2) +#define MMC_DETECT0_PMCA2_TBL (uint8_t)0xFB +/* 11111011B */ /* PMCAmn setting */ +/* ||||||++-------- Reserved : Set to 1 */ +/* |||||+---------- PMCA22 : Set to 0 */ +/* +++++----------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 3) +#define MMC_DETECT0_PMCA2_TBL (uint8_t)0xF7 +/* 11110111B */ /* PMCAmn setting */ +/* |||||+++-------- Reserved : Set to 1 */ +/* ||||+----------- PMCA23 : Set to 0 */ +/* ++++------------ Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 4) +#define MMC_DETECT0_PMCA2_TBL (uint8_t)0xEF +/* 11101111B */ /* PMCAmn setting */ +/* ||||++++-------- Reserved : Set to 1 */ +/* |||+------------ PMCA24 : Set to 0 */ +/* +++------------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 5) +#define MMC_DETECT0_PMCA2_TBL (uint8_t)0xDF +/* 11011111B */ /* PMCAmn setting */ +/* |||+++++-------- Reserved : Set to 1 */ +/* ||+------------- PMCA25 : Set to 0 */ +/* ++-------------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 6) +#define MMC_DETECT0_PMCA2_TBL (uint8_t)0xBF +/* 10111111B */ /* PMCAmn setting */ +/* ||++++++-------- Reserved : Set to 1 */ +/* |+-------------- PMCA26 : Set to 0 */ +/* +--------------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 7) +#define MMC_DETECT0_PMCA2_TBL (uint8_t)0x7F +/* 10111111B */ /* PMCAmn setting */ +/* |+++++++-------- Reserved : Set to 1 */ +/* +--------------- PMCA27 : Set to 0 */ +#endif /* MMC_DETECT0_BITNO */ + +#elif (MMC_DETECT0_PORTNO == 12) +#if (MMC_DETECT0_BITNO == 0) +#define MMC_DETECT0_PMCA12_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCAmn setting */ +/* |||||||+-------- PMCA120 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#endif /* MMC_DETECT0_BITNO */ + +#elif (MMC_DETECT0_PORTNO == 14) +#if (MMC_DETECT0_BITNO == 7) +#define MMC_DETECT0_PMCA14_TBL (uint8_t)0x7F +/* 01111111B */ /* PMCAmn setting */ +/* |+++++++-------- Reserved : Set to 1 */ +/* +--------------- PMCA147 : Set to 0 */ +#endif /* MMC_DETECT0_BITNO */ +#endif /* MMC_DETECT0_PORTNO */ + +#ifndef MMC_DETECT0_PMCA0_TBL +#define MMC_DETECT0_PMCA0_TBL (uint8_t)0xFF +#endif /* MMC_DETECT0_PMCA0_TBL */ +#ifndef MMC_DETECT0_PMCA1_TBL +#define MMC_DETECT0_PMCA1_TBL (uint8_t)0xFF +#endif /* MMC_DETECT0_PMCA1_TBL */ +#ifndef MMC_DETECT0_PMCA2_TBL +#define MMC_DETECT0_PMCA2_TBL (uint8_t)0xFF +#endif /* MMC_DETECT0_PMCA2_TBL */ +#ifndef MMC_DETECT0_PMCA12_TBL +#define MMC_DETECT0_PMCA12_TBL (uint8_t)0xFF +#endif /* MMC_DETECT0_PMCA12_TBL */ +#ifndef MMC_DETECT0_PMCA14_TBL +#define MMC_DETECT0_PMCA14_TBL (uint8_t)0xFF +#endif /* MMC_DETECT0_PMCA14_TBL */ + +/*----------- PMCTxx (DETECT0) register value -----------*/ +#if (MMC_DETECT0_PORTNO == 0) +#if (MMC_DETECT0_BITNO == 0) +#define MMC_DETECT0_PMCT0_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCTmn setting */ +/* |||||||+-------- PMCT00 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 1) +#define MMC_DETECT0_PMCT0_TBL (uint8_t)0xFD +/* 11111101B */ /* PMCTmn setting */ +/* |||||||+-------- Reserved : Set to 1 */ +/* ||||||+--------- PMCT01 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 2) +#define MMC_DETECT0_PMCT0_TBL (uint8_t)0xFB +/* 11111011B */ /* PMCTmn setting */ +/* ||||||++-------- Reserved : Set to 1 */ +/* |||||+---------- PMCT02 : Set to 0 */ +/* +++++----------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 3) +#define MMC_DETECT0_PMCT0_TBL (uint8_t)0xF7 +/* 11110111B */ /* PMCTmn setting */ +/* |||||+++-------- Reserved : Set to 1 */ +/* ||||+----------- PMCT03 : Set to 0 */ +/* ++++------------ Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 5) +#define MMC_DETECT0_PMCT0_TBL (uint8_t)0xDF +/* 11011111B */ /* PMCTmn setting */ +/* |||+++++-------- Reserved : Set to 1 */ +/* ||+------------- PMCT05 : Set to 0 */ +/* ++-------------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 6) +#define MMC_DETECT0_PMCT0_TBL (uint8_t)0xBF +/* 10111111B */ /* PMCTmn setting */ +/* ||++++++-------- Reserved : Set to 1 */ +/* |+-------------- PMCT06 : Set to 0 */ +/* +--------------- Reserved : Set to 1 */ +#endif /* MMC_DETECT0_BITNO */ + +#elif (MMC_DETECT0_PORTNO == 2) +#if (MMC_DETECT0_BITNO == 2) +#define MMC_DETECT0_PMCT2_TBL (uint8_t)0xFB +/* 11111011B */ /* PMCTmn setting */ +/* ||||||++-------- Reserved : Set to 1 */ +/* |||||+---------- PMCT22 : Set to 0 */ +/* +++++----------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 3) +#define MMC_DETECT0_PMCT2_TBL (uint8_t)0xF7 +/* 11110111B */ /* PMCTmn setting */ +/* |||||+++-------- Reserved : Set to 1 */ +/* ||||+----------- PMCT23 : Set to 0 */ +/* ++++------------ Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 4) +#define MMC_DETECT0_PMCT2_TBL (uint8_t)0xEF +/* 11101111B */ /* PMCTmn setting */ +/* ||||++++-------- Reserved : Set to 1 */ +/* |||+------------ PMCT24 : Set to 0 */ +/* +++------------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 5) +#define MMC_DETECT0_PMCT2_TBL (uint8_t)0xDF +/* 11011111B */ /* PMCTmn setting */ +/* |||+++++-------- Reserved : Set to 1 */ +/* ||+------------- PMCT25 : Set to 0 */ +/* ++-------------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 6) +#define MMC_DETECT0_PMCT2_TBL (uint8_t)0xBF +/* 10111111B */ /* PMCTmn setting */ +/* ||++++++-------- Reserved : Set to 1 */ +/* |+-------------- PMCT26 : Set to 0 */ +/* +--------------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 7) +#define MMC_DETECT0_PMCT2_TBL (uint8_t)0x7F +/* 10111111B */ /* PMCTmn setting */ +/* |+++++++-------- Reserved : Set to 1 */ +/* +--------------- PMCT27 : Set to 0 */ +#endif /* MMC_DETECT0_BITNO */ + +#elif (MMC_DETECT0_PORTNO == 3) +#if (MMC_DETECT0_BITNO == 0) +#define MMC_DETECT0_PMCT3_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCTmn setting */ +/* |||||||+-------- PMCT30 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 1) +#define MMC_DETECT0_PMCT3_TBL (uint8_t)0xFD +/* 11111101B */ /* PMCTmn setting */ +/* |||||||+-------- Reserved : Set to 1 */ +/* ||||||+--------- PMCT31 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ +#endif /* MMC_DETECT0_BITNO */ + +#elif (MMC_DETECT0_PORTNO == 5) +#if (MMC_DETECT0_BITNO == 0) +#define MMC_DETECT0_PMCT5_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCTmn setting */ +/* |||||||+-------- PMCT50 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#endif /* MMC_DETECT0_BITNO */ + +#elif (MMC_DETECT0_PORTNO == 6) +#if (MMC_DETECT0_BITNO == 4) +#define MMC_DETECT0_PMCT6_TBL (uint8_t)0xEF +/* 11101111B */ /* PMCTmn setting */ +/* ||||++++-------- Reserved : Set to 1 */ +/* |||+------------ PMCT64 : Set to 0 */ +/* +++------------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 5) +#define MMC_DETECT0_PMCT6_TBL (uint8_t)0xDF +/* 11011111B */ /* PMCTmn setting */ +/* |||+++++-------- Reserved : Set to 1 */ +/* ||+------------- PMCT65 : Set to 0 */ +/* ++-------------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 6) +#define MMC_DETECT0_PMCT6_TBL (uint8_t)0xBF +/* 10111111B */ /* PMCTmn setting */ +/* ||++++++-------- Reserved : Set to 1 */ +/* |+-------------- PMCT66 : Set to 0 */ +/* +--------------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 7) +#define MMC_DETECT0_PMCT6_TBL (uint8_t)0x7F +/* 10111111B */ /* PMCTmn setting */ +/* |+++++++-------- Reserved : Set to 1 */ +/* +--------------- PMCT67 : Set to 0 */ +#endif /* MMC_DETECT0_BITNO */ + +#elif (MMC_DETECT0_PORTNO == 7) +#if (MMC_DETECT0_BITNO == 0) +#define MMC_DETECT0_PMCT7_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCTmn setting */ +/* |||||||+-------- PMCT70 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 1) +#define MMC_DETECT0_PMCT7_TBL (uint8_t)0xFD +/* 11111101B */ /* PMCTmn setting */ +/* |||||||+-------- Reserved : Set to 1 */ +/* ||||||+--------- PMCT71 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 2) +#define MMC_DETECT0_PMCT7_TBL (uint8_t)0xFB +/* 11111011B */ /* PMCTmn setting */ +/* ||||||++-------- Reserved : Set to 1 */ +/* |||||+---------- PMCT72 : Set to 0 */ +/* +++++----------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 3) +#define MMC_DETECT0_PMCT7_TBL (uint8_t)0xF7 +/* 11110111B */ /* PMCTmn setting */ +/* |||||+++-------- Reserved : Set to 1 */ +/* ||||+----------- PMCT73 : Set to 0 */ +/* ++++------------ Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 4) +#define MMC_DETECT0_PMCT7_TBL (uint8_t)0xEF +/* 11101111B */ /* PMCTmn setting */ +/* ||||++++-------- Reserved : Set to 1 */ +/* |||+------------ PMCT74 : Set to 0 */ +/* +++------------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 5) +#define MMC_DETECT0_PMCT7_TBL (uint8_t)0xDF +/* 11011111B */ /* PMCTmn setting */ +/* |||+++++-------- Reserved : Set to 1 */ +/* ||+------------- PMCT75 : Set to 0 */ +/* ++-------------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 6) +#define MMC_DETECT0_PMCT7_TBL (uint8_t)0xBF +/* 10111111B */ /* PMCTmn setting */ +/* ||++++++-------- Reserved : Set to 1 */ +/* |+-------------- PMCT76 : Set to 0 */ +/* +--------------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 7) +#define MMC_DETECT0_PMCT7_TBL (uint8_t)0x7F +/* 10111111B */ /* PMCTmn setting */ +/* |+++++++-------- Reserved : Set to 1 */ +/* +--------------- PMCT77 : Set to 0 */ +#endif /* MMC_DETECT0_BITNO */ +#endif /* MMC_DETECT0_PORTNO */ + +#ifndef MMC_DETECT0_PMCT0_TBL +#define MMC_DETECT0_PMCT0_TBL (uint8_t)0xFF +#endif /* MMC_DETECT0_PMCT0_TBL */ +#ifndef MMC_DETECT0_PMCT2_TBL +#define MMC_DETECT0_PMCT2_TBL (uint8_t)0xFF +#endif /* MMC_DETECT0_PMCT2_TBL */ +#ifndef MMC_DETECT0_PMCT3_TBL +#define MMC_DETECT0_PMCT3_TBL (uint8_t)0xFF +#endif /* MMC_DETECT0_PMCT3_TBL */ +#ifndef MMC_DETECT0_PMCT5_TBL +#define MMC_DETECT0_PMCT5_TBL (uint8_t)0xFF +#endif /* MMC_DETECT0_PMCT5_TBL */ +#ifndef MMC_DETECT0_PMCT6_TBL +#define MMC_DETECT0_PMCT6_TBL (uint8_t)0xFF +#endif /* MMC_DETECT0_PMCT6_TBL */ +#ifndef MMC_DETECT0_PMCT7_TBL +#define MMC_DETECT0_PMCT7_TBL (uint8_t)0xFF +#endif /* MMC_DETECT0_PMCT7_TBL */ + +/*----------- PMCExx (DETECT0) register value -----------*/ +#if (MMC_DETECT0_PORTNO == 0) +#if (MMC_DETECT0_BITNO == 1) +#define MMC_DETECT0_PMCE0_TBL (uint8_t)0xFD +/* 11111101B */ /* PMCEmn setting */ +/* |||||||+-------- Reserved : Set to 1 */ +/* ||||||+--------- PMCE01 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ +#endif /* MMC_DETECT0_BITNO */ + +#elif (MMC_DETECT0_PORTNO == 1) +#if (MMC_DETECT0_BITNO == 0) +#define MMC_DETECT0_PMCE1_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCEmn setting */ +/* |||||||+-------- PMCE10 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 1) +#define MMC_DETECT0_PMCE1_TBL (uint8_t)0xFD +/* 11111101B */ /* PMCEmn setting */ +/* |||||||+-------- Reserved : Set to 1 */ +/* ||||||+--------- PMCE11 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 2) +#define MMC_DETECT0_PMCE1_TBL (uint8_t)0xFB +/* 11111011B */ /* PMCEmn setting */ +/* ||||||++-------- Reserved : Set to 1 */ +/* |||||+---------- PMCE12 : Set to 0 */ +/* +++++----------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 3) +#define MMC_DETECT0_PMCE1_TBL (uint8_t)0xF7 +/* 11110111B */ /* PMCEmn setting */ +/* |||||+++-------- Reserved : Set to 1 */ +/* ||||+----------- PMCE13 : Set to 0 */ +/* ++++------------ Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 4) +#define MMC_DETECT0_PMCE1_TBL (uint8_t)0xEF +/* 11101111B */ /* PMCEmn setting */ +/* ||||++++-------- Reserved : Set to 1 */ +/* |||+------------ PMCE14 : Set to 0 */ +/* +++------------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 5) +#define MMC_DETECT0_PMCE1_TBL (uint8_t)0xDF +/* 11011111B */ /* PMCEmn setting */ +/* |||+++++-------- Reserved : Set to 1 */ +/* ||+------------- PMCE15 : Set to 0 */ +/* ++-------------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 6) +#define MMC_DETECT0_PMCE1_TBL (uint8_t)0xBF +/* 10111111B */ /* PMCEmn setting */ +/* ||++++++-------- Reserved : Set to 1 */ +/* |+-------------- PMCE16 : Set to 0 */ +/* +--------------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 7) +#define MMC_DETECT0_PMCE1_TBL (uint8_t)0x7F +/* 01111111B */ /* PMCEmn setting */ +/* |+++++++-------- Reserved : Set to 1 */ +/* +--------------- PMCE17 : Set to 0 */ +#endif /* MMC_DETECT0_BITNO */ + +#elif (MMC_DETECT0_PORTNO == 5) +#if (MMC_DETECT0_BITNO == 0) +#define MMC_DETECT0_PMCE5_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCEmn setting */ +/* |||||||+-------- PMCE50 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 1) +#define MMC_DETECT0_PMCE5_TBL (uint8_t)0xFD +/* 11111101B */ /* PMCEmn setting */ +/* |||||||+-------- Reserved : Set to 1 */ +/* ||||||+--------- PMCE51 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ +#endif /* MMC_DETECT0_BITNO */ + +#elif (MMC_DETECT0_PORTNO == 6) +#if (MMC_DETECT0_BITNO == 0) +#define MMC_DETECT0_PMCE6_TBL (uint8_t)0xFE +/* 11111110B */ /* PMCEmn setting */ +/* |||||||+-------- PMCE60 : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 1) +#define MMC_DETECT0_PMCE6_TBL (uint8_t)0xFD +/* 11111101B */ /* PMCEmn setting */ +/* |||||||+-------- Reserved : Set to 1 */ +/* ||||||+--------- PMCE61 : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ +#endif /* MMC_DETECT0_BITNO */ +#endif /* MMC_DETECT0_PORTNO */ + +#ifndef MMC_DETECT0_PMCE0_TBL +#define MMC_DETECT0_PMCE0_TBL (uint8_t)0xFF +#endif /* MMC_DETECT0_PMCE0_TBL */ +#ifndef MMC_DETECT0_PMCE1_TBL +#define MMC_DETECT0_PMCE1_TBL (uint8_t)0xFF +#endif /* MMC_DETECT0_PMCE1_TBL */ +#ifndef MMC_DETECT0_PMCE5_TBL +#define MMC_DETECT0_PMCE5_TBL (uint8_t)0xFF +#endif /* MMC_DETECT0_PMCE5_TBL */ +#ifndef MMC_DETECT0_PMCE6_TBL +#define MMC_DETECT0_PMCE6_TBL (uint8_t)0xFF +#endif /* MMC_DETECT0_PMCE6_TBL */ + +/*----------- CCDE (DETECT0) register value -----------*/ +#if (MMC_DETECT0_PORTNO == 1) +#if (MMC_DETECT0_BITNO == 6) +#define MMC_DETECT0_CCDE_TBL (uint8_t)0xFE +/* 11111110B */ /* CCDE setting */ +/* |||||||+-------- CCDE00 (P16) : Set to 0 */ +/* +++++++--------- Reserved : Set to 1 */ +#elif (MMC_DETECT0_BITNO == 7) +#define MMC_DETECT0_CCDE_TBL (uint8_t)0xFD +/* 11111101B */ /* CCDE setting */ +/* |||||||+-------- Reserved : Set to 1 */ +/* ||||||+--------- CCDE01 (P17) : Set to 0 */ +/* ++++++---------- Reserved : Set to 1 */ +#endif /* MMC_DETECT0_BITNO */ +#endif /* MMC_DETECT0_PORTNO */ + +#ifndef MMC_DETECT0_CCDE_TBL +#define MMC_DETECT0_CCDE_TBL (uint8_t)0xFF +#endif /* MMC_DETECT0_CCDE_TBL */ + + + +#define __PM( x,y ) PM ## x ##_bit.no ## y +#define _PM( x,y ) __PM( x , y ) +#define __POM( x,y ) POM ## x ##_bit.no ## y +#define _POM( x,y ) __POM( x , y ) +#define __PIM( x,y ) PIM ## x ##_bit.no ## y +#define _PIM( x,y ) __PIM( x , y ) +#define __P( x,y ) P ## x ##_bit.no ## y +#define _P( x,y ) __P( x , y ) +#define __PMC( x,y ) PMC ## x ##_bit.no ## y +#define _PMC( x,y ) __PMC( x , y ) + +#define __SPS( x ) SPS ## x +#define _SPS( x ) __SPS( x ) +#define __SPSL( x ) SPS ## x ## L +#define _SPSL( x ) __SPSL( x ) + +#define __SMR( x,y ) SMR ## x ## y +#define _SMR( x,y ) __SMR( x , y ) + +#define __SCR( x,y ) SCR ## x ## y +#define _SCR( x,y ) __SCR( x , y ) + +#define __SDR( x,y ) SDR ## x ## y +#define _SDR( x,y ) __SDR( x , y ) +#define __SIO( x,y ) SIO ## x ## y +#define _SIO( x,y ) __SIO( x , y ) + +#define __SIR( x,y ) SIR ## x ## y +#define _SIR( x,y ) __SIR( x , y ) +#define __SIRL( x,y ) SIR ## x ## y ## L +#define _SIRL( x,y ) __SIRL( x , y ) + +#define __SSR( x,y ) SSR ## x ## y +#define _SSR( x,y ) __SSR( x , y ) +#define __SSRL( x,y ) SSR ## x ## y ## L +#define _SSRL( x,y ) __SSRL( x , y ) + +#define __SS( x ) SS ## x +#define _SS( x ) __SS( x ) +#define __SSL( x ) SS ## x ## L +#define _SSL( x ) __SSL( x ) +#define __SSLB( x,y ) SS ## x ## L_bit.no ## y +#define _SSLB( x,y ) __SSLB( x,y ) + +#define __ST( x ) ST ## x +#define _ST( x ) __ST( x ) +#define __STL( x ) ST ## x ## L +#define _STL( x ) __STL( x ) +#define __STLB( x,y ) ST ## x ## L_bit.no ## y +#define _STLB( x,y ) __STLB( x,y ) + +#define __SE( x ) SE ## x +#define _SE( x ) __SE( x ) +#define __SEL( x ) SE ## x ## L +#define _SEL( x ) __SEL( x ) +#define __SELB( x,y ) SE ## x ## L_bit.no ## y +#define _SELB( x,y ) __SELB( x,y ) + +#define __SOE( x ) SOE ## x +#define _SOE( x ) __SOE( x ) +#define __SOEL( x ) SOE ## x ## L +#define _SOEL( x ) __SOEL( x ) +#define __SOELB( x,y ) SOE ## x ## L_bit.no ## y +#define _SOELB( x,y ) __SOELB( x,y ) + +#define __SO( x ) SO ## x +#define _SO( x ) __SO( x ) + +#define __CSIIF( x,y ) CSIIF ## x ## y +#define _CSIIF( x,y ) __CSIIF( x , y ) +#define __CSIMK( x,y ) CSIMK ## x ## y +#define _CSIMK( x,y ) __CSIMK( x , y ) +#define __SAUEN( x ) SAU ## x ## EN +#define _SAUEN( x ) __SAUEN( x ) +#define __SAURES( x ) SAU ## x ## RES +#define _SAURES( x ) __SAURES( x ) + +#define MMC_PM_DATAI _PM( MMC_DATAI_PORTNO , MMC_DATAI_BITNO ) /* MMC DataIn */ +#define MMC_PORT_DATAI _P( MMC_DATAI_PORTNO , MMC_DATAI_BITNO ) /* MMC DataIn */ +#define MMC_PIM_DATAI _PIM( MMC_DATAI_PORTNO , MMC_DATAI_BITNO ) /* MMC DataIn */ +#define MMC_POM_DATAI _POM( MMC_DATAI_PORTNO , MMC_DATAI_BITNO ) /* MMC DataIn */ +#define MMC_PMC_DATAI _PMC( MMC_DATAI_PORTNO , MMC_DATAI_BITNO ) /* MMC DataIn */ +#define MMC_PM_CLK _PM( MMC_CLK_PORTNO , MMC_CLK_BITNO ) /* MMC CLK */ +#define MMC_PORT_CLK _P( MMC_CLK_PORTNO , MMC_CLK_BITNO ) /* MMC CLK */ +#define MMC_PIM_CLK _PIM( MMC_CLK_PORTNO , MMC_CLK_BITNO ) /* MMC CLK */ +#define MMC_POM_CLK _POM( MMC_CLK_PORTNO , MMC_CLK_BITNO ) /* MMC CLK */ +#define MMC_PMC_CLK _PMC( MMC_CLK_PORTNO , MMC_CLK_BITNO ) /* MMC CLK */ +#define MMC_PM_DATAO _PM( MMC_DATAO_PORTNO , MMC_DATAO_BITNO ) /* MMC DataOut */ +#define MMC_PORT_DATAO _P( MMC_DATAO_PORTNO , MMC_DATAO_BITNO ) /* MMC DataOut */ +#define MMC_PIM_DATAO _PIM( MMC_DATAO_PORTNO , MMC_DATAO_BITNO ) /* MMC DataOut */ +#define MMC_POM_DATAO _POM( MMC_DATAO_PORTNO , MMC_DATAO_BITNO ) /* MMC DataOut */ +#define MMC_PMC_DATAO _PMC( MMC_DATAO_PORTNO , MMC_DATAO_BITNO ) /* MMC DataOut */ + +#define MMC_PM_CS0 _PM( MMC_CS0_PORTNO , MMC_CS0_BITNO ) /* MMC CS0 (Negative-true logic) */ +#define MMC_PORT_CS0 _P( MMC_CS0_PORTNO , MMC_CS0_BITNO ) /* MMC CS0 (Negative-true logic) */ +#define MMC_PIM_CS0 _PIM( MMC_CS0_PORTNO , MMC_CS0_BITNO ) /* MMC CS0 (Negative-true logic) */ +#define MMC_POM_CS0 _POM( MMC_CS0_PORTNO , MMC_CS0_BITNO ) /* MMC CS0 (Negative-true logic) */ + +#if defined(MMC_DETECT0_CONNECTION) +#define MMC_PM_DETECT0 _PM( MMC_DETECT0_PORTNO , MMC_DETECT0_BITNO ) /* MMC Detect0 (Negative-true logic) */ +#define MMC_PORT_DETECT0 _P( MMC_DETECT0_PORTNO , MMC_DETECT0_BITNO ) /* MMC Detect0 (Negative-true logic) */ +#define MMC_PIM_DETECT0 _PIM( MMC_DETECT0_PORTNO , MMC_DETECT0_BITNO ) /* MMC Detect0 (Negative-true logic) */ +#define MMC_POM_DETECT0 _POM( MMC_DETECT0_PORTNO , MMC_DETECT0_BITNO ) /* MMC Detect0 (Negative-true logic) */ +#endif /* #if defined(MMC_DETECT0_CONNECTION) */ + +#if (MMC_SLOT_NUM > 1) +#define MMC_PM_CS1 _PM( MMC_CS1_PORTNO , MMC_CS1_BITNO ) /* MMC CS1 (Negative-true logic) */ +#define MMC_PORT_CS1 _P( MMC_CS1_PORTNO , MMC_CS1_BITNO ) /* MMC CS1 (Negative-true logic) */ +#define MMC_PIM_CS1 _PIM( MMC_CS1_PORTNO , MMC_CS1_BITNO ) /* MMC CS1 (Negative-true logic) */ +#define MMC_POM_CS1 _POM( MMC_CS1_PORTNO , MMC_CS1_BITNO ) /* MMC CS1 (Negative-true logic) */ + +#if defined(MMC_DETECT1_CONNECTION) +#define MMC_PM_DETECT1 _PM( MMC_DETECT1_PORTNO , MMC_DETECT1_BITNO ) /* MMC Detect1 (Negative-true logic) */ +#define MMC_PORT_DETECT1 _P( MMC_DETECT1_PORTNO , MMC_DETECT1_BITNO ) /* MMC Detect1 (Negative-true logic) */ +#define MMC_PIM_DETECT1 _PIM( MMC_DETECT1_PORTNO , MMC_DETECT1_BITNO ) /* MMC Detect1 (Negative-true logic) */ +#define MMC_POM_DETECT1 _POM( MMC_DETECT1_PORTNO , MMC_DETECT1_BITNO ) /* MMC Detect1 (Negative-true logic) */ +#endif /* #if defined(MMC_DETECT1_CONNECTION) */ + +#endif /* #if (MMC_SLOT_NUM > 1) */ + + +/*----------- Definitions of resource used -----------*/ +#define MMC_CSI_USED /* CSI used */ +#define MMC_SYNC_MSBF /* CSI MSB first */ + +#ifdef MMC_OPTION_1 +#define MMC_CRC_SOFT /* Encode by soft CRC (ROM table used) */ +#endif /* #ifdef MMC_OPTION_1 */ + +#ifdef MMC_OPTION_2 +#define MMC_CRC_HARD /* Encode by hard CRC */ +#define MMC_CRC_LSBF +#endif /* #ifdef MMC_OPTION_2 */ + + +/*----------------- CSI definitions -----------------*/ + +/* 16bits 8bits */ +#define MMC_CSI_SPSmL _SPSL( MMC_SAU_UNIT ) /* SPSmL register : 8bits */ +#define MMC_CSI_SMRmn _SMR( MMC_SAU_UNIT ,MMC_SAU_CHANNEL ) /* SMRmn register : 16bits */ +#define MMC_CSI_SCRmn _SCR( MMC_SAU_UNIT ,MMC_SAU_CHANNEL ) /* SCRmn register : 16bits */ +#define MMC_CSI_SDRmn _SDR( MMC_SAU_UNIT ,MMC_SAU_CHANNEL ) /* SDRmn register : 16bits */ +#define MMC_CSI_SIOmn _SIO( MMC_CSI_UNIT ,MMC_CSI_CHANNEL ) /* SIOmn register : 8bits */ +#define MMC_CSI_SIRmnL _SIRL( MMC_SAU_UNIT ,MMC_SAU_CHANNEL ) /* SIRmnL register : 8bits */ +#define MMC_CSI_SSRmnL _SSRL( MMC_SAU_UNIT ,MMC_SAU_CHANNEL ) /* SSRmnL register : 8bits */ + +#define MMC_CSI_SSmn _SSLB( MMC_SAU_UNIT ,MMC_SAU_CHANNEL ) /* SSm register Bit n : 1bit */ +#define MMC_CSI_STmn _STLB( MMC_SAU_UNIT ,MMC_SAU_CHANNEL ) /* STm register Bit n : 1bit */ +#define MMC_CSI_SEmn _SELB( MMC_SAU_UNIT ,MMC_SAU_CHANNEL ) /* SEm register Bit n : 1bit */ +#define MMC_CSI_SOEmn _SOELB( MMC_SAU_UNIT ,MMC_SAU_CHANNEL ) /* SOEm register Bit n : 1bit */ +#define MMC_CSI_SOm _SO( MMC_SAU_UNIT ) /* SOm register : 16bits */ +#define MMC_CSI_ISC ISC /* ISC register : 8bits */ +#define MMC_CSI_IFmn _CSIIF( MMC_CSI_UNIT , MMC_CSI_CHANNEL) /* CSI Interrupt flag : 1bit */ +#define MMC_CSI_MKmn _CSIMK( MMC_CSI_UNIT , MMC_CSI_CHANNEL) /* CSI Interrupt enable flag : 1bit */ +#define MMC_SAUmEN _SAUEN( MMC_SAU_UNIT ) /* SAU enable flag : 1bit */ +#define MMC_SAUmRES _SAURES( MMC_SAU_UNIT ) /* SAU reset flag : 1bit */ + +#define MMC_CSI_TXBUF MMC_CSI_SIOmn +#define MMC_CSI_RXBUF MMC_CSI_SIOmn + +#if (MMC_OPERATION_CLK_SELECT == 0) +#define MMC_SPS_MASK (uint8_t)0xF0 +/* xxxx0000B */ /* SPSmnL setting */ +/* ||||++++-------- PRSm[03:00] : CKm0 = fCLK */ +/* ++++------------ PRSm[07:04] : CKm1 = No change */ +#define MMC_SPS_SET (uint8_t)(MMC_FCLK_PRESCALER_SELECT) +/* xxxx****B */ /* SPSmnL setting */ +/* ||||++++-------- PRSm[03:00] : CKm0 set */ +/* ++++------------ PRSm[07:04] : CKm1 = No change */ +#elif (MMC_OPERATION_CLK_SELECT == 1) +#define MMC_SPS_MASK (uint8_t)0x0F +/* 0000xxxxB */ /* SPSmnL setting */ +/* ||||++++-------- PRSm[03:00] : CKm0 = No change */ +/* ++++------------ PRSm[07:04] : CKm1 = fCLK */ + +#define MMC_SPS_SET (uint8_t)(MMC_FCLK_PRESCALER_SELECT << 4) +/* ****xxxxB */ /* SPSmnL setting */ +/* ||||++++-------- PRSm[03:00] : CKm0 = No change */ +/* ++++------------ PRSm[07:04] : CKm1 set */ +#endif + +/* CSI setting */ +#define MMC_SMR_TX (uint16_t)0x0021 | ((uint16_t)MMC_OPERATION_CLK_SELECT << 15) +/* 00000000 00100001B */ /* SMRmn setting */ +/* |||||||| |||||||+-------- MDmn0 : Buffer empty interrupt */ +/* |||||||| |||||++--------- MDmn[2-1] : CSI mode */ +/* |||||||| |||++----------- Reserved : Set to 0 */ +/* |||||||| ||+------------- Reserved : Set to 1 */ +/* |||||||| |+-------------- SISmn : Read by failing edge */ +/* |||||||| +--------------- Reserved : Set to 0 */ +/* |||||||+ ---------------- STSmn : Software trigger is valid */ +/* ||+++++- ---------------- Reserved : Set to 0 */ +/* |+------ ---------------- CCSmn : Clock fMCK specified by the CKSmn bit */ +/* +------- ---------------- CKSmn : Operation clock CKmX set by the SPSm */ + +#define MMC_SMR_RX (uint16_t)0x0020 | ((uint16_t)MMC_OPERATION_CLK_SELECT << 15) +/* x0000000 00100000B */ /* SMRmn setting */ +/* |||||||| |||||||+-------- MDmn0 : Transfer end interrupt */ +/* |||||||| |||||++--------- MDmn[2-1] : CSI mode */ +/* |||||||| |||++----------- Reserved : Set to 0 */ +/* |||||||| ||+------------- Reserved : Set to 1 */ +/* |||||||| |+-------------- SISmn : Read by failing edge */ +/* |||||||| +--------------- Reserved : Set to 0 */ +/* |||||||+ ---------------- STSmn : Software trigger is valid */ +/* ||+++++- ---------------- Reserved : Set to 0 */ +/* |+------ ---------------- CCSmn : Clock fMCK specified by the CKSmn bit */ +/* +------- ---------------- CKSmn : Operation clock CKmX set by user */ + +#define MMC_SCR_INIT (uint16_t)0x0007 +/* 00000000 00000111B */ /* SCRmn setting */ +/* |||||||| ||||||++-------- DLSmn[1:0] : 8-bit data length */ +/* |||||||| |||||+---------- Reserved : Set to 1 */ +/* |||||||| ||||+----------- Reserved : Set to 0 */ +/* |||||||| ||++------------ SLCmn[1:0] : No stop bit */ +/* |||||||| |+-------------- Reserved : Set to 0 */ +/* |||||||| +--------------- DIRmn : MSB first */ +/* ||||||++ ---------------- PTCmn[1:0] : Receives without parity */ +/* |||||+-- ---------------- EOCmn : Masks error interrupt */ +/* ||||+--- ---------------- Reserved : Set to 0 */ +/* |||+---- ---------------- CKPmn : Select type 1 */ +/* ||+----- ---------------- DAPmn : Select type 1 */ +/* |+------ ---------------- RXEmn : Disable Reception */ +/* +------- ---------------- TXEmn : Disable Transmission */ + +#define MMC_SCR_TX (uint16_t)0x8007 +/* 10000000 00000111B */ /* SCRmn setting */ +/* |||||||| ||||||++-------- DLSmn[1:0] : 8-bit data length */ +/* |||||||| |||||+---------- Reserved : Set to 1 */ +/* |||||||| ||||+----------- Reserved : Set to 0 */ +/* |||||||| ||++------------ SLCmn[1:0] : No stop bit */ +/* |||||||| |+-------------- Reserved : Set to 0 */ +/* |||||||| +--------------- DIRmn : MSB first */ +/* ||||||++ ---------------- PTCmn[1:0] : Receives without parity */ +/* |||||+-- ---------------- EOCmn : Masks error interrupt */ +/* ||||+--- ---------------- Reserved : Set to 0 */ +/* |||+---- ---------------- CKPmn : Select type 1 */ +/* ||+----- ---------------- DAPmn : Select type 1 */ +/* |+------ ---------------- RXEmn : Disable Reception */ +/* +------- ---------------- TXEmn : Enable Transmission */ + +#define MMC_SCR_RX (uint16_t)0x4007 +/* 10000000 00000111B */ /* SCRmn setting */ +/* |||||||| ||||||++-------- DLSmn[1:0] : 8-bit data length */ +/* |||||||| |||||+---------- Reserved : Set to 1 */ +/* |||||||| ||||+----------- Reserved : Set to 0 */ +/* |||||||| ||++------------ SLCmn[1:0] : No stop bit */ +/* |||||||| |+-------------- Reserved : Set to 0 */ +/* |||||||| +--------------- DIRmn : MSB first */ +/* ||||||++ ---------------- PTCmn[1:0] : Receives without parity */ +/* |||||+-- ---------------- EOCmn : Masks error interrupt */ +/* ||||+--- ---------------- Reserved : Set to 0 */ +/* |||+---- ---------------- CKPmn : Select type 1 */ +/* ||+----- ---------------- DAPmn : Select type 1 */ +/* |+------ ---------------- RXEmn : Enable Reception */ +/* +------- ---------------- TXEmn : Disable Transmission */ + +#define MMC_CLKOUT_BIT (uint16_t)(0x0001 << (8 + MMC_SAU_CHANNEL)) +/* 0000xxxx 00000000B */ /* SOmn setting */ +/* |||||||| ++++++++-------- Reserved : Set to 0 */ +/* |||||||+ ---------------- CKOm0 : CKOm0 Output level */ +/* ||||||+- ---------------- CKOm1 : CKOm1 Output level */ +/* |||||+-- ---------------- CKOm2 : CKOm2 Output level */ +/* ||||+--- ---------------- CKOm3 : CKOm3 Output level */ +/* ++++---- ---------------- Reserved : Set to 0 */ + +#define MMC_SOOUT_BIT (uint16_t)(0x0001 << (MMC_SAU_CHANNEL)) +/* 00000000 0000xxxxB */ /* SOmn setting */ +/* |||||||| |||||||+-------- SOm0 : SOm0 Output level */ +/* |||||||| ||||||+--------- SOm1 : SOm1 Output level */ +/* |||||||| |||||+---------- SOm2 : SOm2 Output level */ +/* |||||||| ||||+----------- SOm3 : SOm3 Output level */ +/* ++++++++ ++++------------ Reserved : Set to 0 */ + +#define MMC_TXNEXT_MASK (uint8_t)(0x20) +/* 00100000B */ /* SSRmn reading */ +/* |||||||+-------- OVFmn : Not Check */ +/* ||||||+--------- PEFmn : Not Check */ +/* |||||+---------- FEFmn : Not Check */ +/* |||++----------- Reserved : Not Check */ +/* ||+------------- BFFmn : Check */ +/* |+-------------- TSFmn : Not Check */ +/* +--------------- Reserved : Not Check */ + +#define MMC_TXEND_MASK (uint8_t)(0x40) +/* 01000000B */ /* SSRmn reading */ +/* |||||||+-------- OVFmn : Not Check */ +/* ||||||+--------- PEFmn : Not Check */ +/* |||||+---------- FEFmn : Not Check */ +/* |||++----------- Reserved : Not Check */ +/* ||+------------- BFFmn : Not Check */ +/* |+-------------- TSFmn : Check */ +/* +--------------- Reserved : Not Check */ + +#define MMC_RX_COMPLETE_MASK (uint8_t)(0x20) +/* 01000000B */ /* SSRmn reading */ +/* |||||||+-------- OVFmn : Not Check */ +/* ||||||+--------- PEFmn : Not Check */ +/* |||||+---------- FEFmn : Not Check */ +/* |||++----------- Reserved : Not Check */ +/* ||+------------- BFFmn : Check */ +/* |+-------------- TSFmn : Not Check */ +/* +--------------- Reserved : Not Check */ + +#define MMC_OVF_MASK (uint8_t)(0x01) +/* 00000001B */ /* SSRmn reading */ +/* |||||||+-------- OVFmn : Not Check */ +/* ||||||+--------- PEFmn : Not Check */ +/* |||||+---------- FEFmn : Not Check */ +/* |||++----------- Reserved : Not Check */ +/* ||+------------- BFFmn : Not Check */ +/* |+-------------- TSFmn : Check */ +/* +--------------- Reserved : Not Check */ + + +#define MMC_DUMMY_DATA (uint8_t)0xFF /* MMC dummy data for some command */ + +/*----------------- CRC definitions ------------------*/ +#ifdef MMC_CRC_HARD +#define MMC_CRCIN CRCIN /* CRC input register */ +#define MMC_CRCD CRCD /* CRC data register */ + +#endif /* #ifdef MMC_CRC_HARD */ + + +/************************************************************************************************/ +/* Unions */ +/************************************************************************************************/ + +/************************************************************************************************/ +/* Structs */ +/************************************************************************************************/ + +/************************************************************************************************/ +/* Externs */ +/************************************************************************************************/ + +/************************************************************************************************/ +/* Macros */ +/************************************************************************************************/ + +/*------------- Driver use port control --------------*/ +#if (MMC_SLOT_NUM == 1) +/* !!!! The other Ports are set to input mode. !!!! */ +#define MMC_IO_INIT() do /* Driver use terminal initial setting */ \ + { \ + PMCA0 &= (MMC_PMCA0_TBL & MMC_CS0_PMCA0_TBL & MMC_DETECT0_PMCA0_TBL); \ + PMCA1 &= (MMC_PMCA1_TBL & MMC_CS0_PMCA1_TBL & MMC_DETECT0_PMCA1_TBL); \ + PMCA2 &= (MMC_PMCA2_TBL & MMC_CS0_PMCA2_TBL & MMC_DETECT0_PMCA2_TBL); \ + PMCA12 &= (MMC_PMCA12_TBL & MMC_CS0_PMCA12_TBL & MMC_DETECT0_PMCA12_TBL); \ + PMCA14 &= (MMC_PMCA14_TBL & MMC_CS0_PMCA14_TBL & MMC_DETECT0_PMCA14_TBL); \ + PMCT0 &= (MMC_PMCT0_TBL & MMC_CS0_PMCT0_TBL & MMC_DETECT0_PMCT0_TBL); \ + PMCT2 &= (MMC_PMCT2_TBL & MMC_CS0_PMCT2_TBL & MMC_DETECT0_PMCT2_TBL); \ + PMCT3 &= (MMC_PMCT3_TBL & MMC_CS0_PMCT3_TBL & MMC_DETECT0_PMCT3_TBL); \ + PMCT5 &= (MMC_PMCT5_TBL & MMC_CS0_PMCT5_TBL & MMC_DETECT0_PMCT5_TBL); \ + PMCT6 &= (MMC_PMCT6_TBL & MMC_CS0_PMCT6_TBL & MMC_DETECT0_PMCT6_TBL); \ + PMCT7 &= (MMC_PMCT7_TBL & MMC_CS0_PMCT7_TBL & MMC_DETECT0_PMCT7_TBL); \ + PMCE0 &= (MMC_PMCE0_TBL & MMC_CS0_PMCE0_TBL & MMC_DETECT0_PMCE0_TBL); \ + PMCE1 &= (MMC_PMCE1_TBL & MMC_CS0_PMCE1_TBL & MMC_DETECT0_PMCE1_TBL); \ + PMCE5 &= (MMC_PMCE5_TBL & MMC_CS0_PMCE5_TBL & MMC_DETECT0_PMCE5_TBL); \ + PMCE6 &= (MMC_PMCE6_TBL & MMC_CS0_PMCE6_TBL & MMC_DETECT0_PMCE6_TBL); \ + CCDE &= (MMC_CCDE_TBL & MMC_CS0_CCDE_TBL & MMC_DETECT0_CCDE_TBL); \ + PFOE1 |= MMC_PFOE1_TBL; \ + MMC_PORT_DATAO = MMC_TRUE; /* DataOut "H" */ \ + MMC_PM_DATAO = MMC_FALSE; /* DataOut Output */ \ + MMC_PORT_CLK = MMC_TRUE; /* CLK "H" */ \ + MMC_PM_CLK = MMC_FALSE; /* CLK Output */ \ + MMC_PM_DATAI = MMC_TRUE; /* DataIn Input */ \ + MMC_PORT_CS0 = MMC_TRUE; /* CS0 "H" */ \ + MMC_PM_CS0 = MMC_FALSE; /* CS0 Output */ \ + MMC_DETECT0_INIT(); /* DETECT0 Input */ \ + } while (0) +#endif /* #if (MMC_SLOT_NUM == 1) */ + +#if (MMC_SLOT_NUM > 1) +/* !!!! The other Ports are set to input mode. !!!! */ +#define MMC_IO_INIT() do /* Driver use terminal initial setting */ \ + { \ + PMCA0 &= (MMC_PMCA0_TBL & MMC_CS0_PMCA0_TBL & MMC_DETECT0_PMCA0_TBL); \ + PMCA1 &= (MMC_PMCA1_TBL & MMC_CS0_PMCA1_TBL & MMC_DETECT0_PMCA1_TBL); \ + PMCA2 &= (MMC_PMCA2_TBL & MMC_CS0_PMCA2_TBL & MMC_DETECT0_PMCA2_TBL); \ + PMCA12 &= (MMC_PMCA12_TBL & MMC_CS0_PMCA12_TBL & MMC_DETECT0_PMCA12_TBL); \ + PMCA14 &= (MMC_PMCA14_TBL & MMC_CS0_PMCA14_TBL & MMC_DETECT0_PMCA14_TBL); \ + PMCT0 &= (MMC_PMCT0_TBL & MMC_CS0_PMCT0_TBL & MMC_DETECT0_PMCT0_TBL); \ + PMCT2 &= (MMC_PMCT2_TBL & MMC_CS0_PMCT2_TBL & MMC_DETECT0_PMCT2_TBL); \ + PMCT3 &= (MMC_PMCT3_TBL & MMC_CS0_PMCT3_TBL & MMC_DETECT0_PMCT3_TBL); \ + PMCT5 &= (MMC_PMCT5_TBL & MMC_CS0_PMCT5_TBL & MMC_DETECT0_PMCT5_TBL); \ + PMCT6 &= (MMC_PMCT6_TBL & MMC_CS0_PMCT6_TBL & MMC_DETECT0_PMCT6_TBL); \ + PMCT7 &= (MMC_PMCT7_TBL & MMC_CS0_PMCT7_TBL & MMC_DETECT0_PMCT7_TBL); \ + PMCE0 &= (MMC_PMCE0_TBL & MMC_CS0_PMCE0_TBL & MMC_DETECT0_PMCE0_TBL); \ + PMCE1 &= (MMC_PMCE1_TBL & MMC_CS0_PMCE1_TBL & MMC_DETECT0_PMCE1_TBL); \ + PMCE5 &= (MMC_PMCE5_TBL & MMC_CS0_PMCE5_TBL & MMC_DETECT0_PMCE5_TBL); \ + PMCE6 &= (MMC_PMCE6_TBL & MMC_CS0_PMCE6_TBL & MMC_DETECT0_PMCE6_TBL); \ + CCDE &= (MMC_CCDE_TBL & MMC_CS0_CCDE_TBL & MMC_DETECT0_CCDE_TBL); \ + PFOE1 |= MMC_PFOE1_TBL; \ + MMC_PORT_DATAO = MMC_TRUE; /* DataOut "H" */ \ + MMC_PM_DATAO = MMC_FALSE; /* DataOut Output */ \ + MMC_PORT_CLK = MMC_TRUE; /* CLK "H" */ \ + MMC_PM_CLK = MMC_FALSE; /* CLK Output */ \ + MMC_PM_DATAI = MMC_TRUE; /* DataIn Input */ \ + MMC_PORT_CS0 = MMC_TRUE; /* CS0 "H" */ \ + MMC_PM_CS0 = MMC_FALSE; /* CS0 Output */ \ + MMC_DETECT0_INIT(); /* DETECT0 Input */ \ + MMC_PORT_CS1 = MMC_TRUE; /* CS1 "H" */ \ + MMC_PM_CS1 = MMC_FALSE; /* CS1 Output */ \ + MMC_DETECT1_INIT(); /* DETECT1 Input */ \ + } while (0) +#endif /* #if (MMC_SLOT_NUM > 1) */ + +/*------------------ DataIn control ------------------*/ +#define MMC_DATAI_INIT() do /* DataIn initial setting */ \ + { \ + } while (0) + +/*----------------- DataOut control ------------------*/ +#define MMC_DATAO_INIT() do /* DataOut initial setting */ \ + { \ + } while (0) + +#define MMC_DATAO_OPEN() do /* DataOut open setting */ \ + { \ + } while (0) + +/*------------------- CLK control --------------------*/ +#define MMC_CLK_INIT() do /* CLK initial setting */ \ + { \ + } while (0) + +#define MMC_CLK_OPEN() do /* CLK open setting */ \ + { \ + } while (0) + +/*------------------ DETECT control ------------------*/ +#if defined(MMC_DETECT0_CONNECTION) +#define MMC_DETECT0_INIT() do /* DETECT initial setting */ \ + { \ + MMC_PM_DETECT0 = MMC_TRUE; /* DETECT Input */ \ + } while (0) + +#define MMC_GET_DETECT0(Lv) do /* DETECT input control */ \ + { \ + Lv = MMC_PORT_DETECT0; \ + } while (0) +#else /* #if defined(MMC_DETECT0_CONNECTION) */ +#define MMC_DETECT0_INIT() /* DETECT initial setting */ +#define MMC_GET_DETECT0(Lv) /* DETECT input control */ +#endif /* #if defined(MMC_DETECT0_CONNECTION) */ + + +#if (MMC_SLOT_NUM > 1) +#if defined(MMC_DETECT1_CONNECTION) +#define MMC_DETECT1_INIT() do /* DETECT initial setting */ \ + { \ + MMC_PM_DETECT1 = MMC_TRUE; /* DETECT Input */ \ + } while (0) + +#define MMC_GET_DETECT1(Lv) do /* DETECT input control */ \ + { \ + Lv = MMC_PORT_DETECT1; \ + } while (0) +#else /* #if defined(MMC_DETECT0_CONNECTION) */ +#define MMC_DETECT1_INIT() /* DETECT initial setting */ +#define MMC_GET_DETECT1(Lv) /* DETECT input control */ +#endif /* #if defined(MMC_DETECT1_CONNECTION) */ +#endif /* #if (MMC_SLOT_NUM > 1) */ + +#if (MMC_SLOT_NUM == 1) +#define MMC_DETECT_INIT(SlotNo) do /* DETECT initial setting */ \ + { \ + MMC_DETECT0_INIT(); \ + } while (0) +#define MMC_GET_DETECT(SlotNo, Lv) do /* DETECT input control */ \ + { \ + Lv = MMC_NOT_CONNECT; /* Initialize by non-detection */ \ + MMC_GET_DETECT0(Lv); \ + } while (0) +#endif /* #if (MMC_SLOT_NUM > 1) */ + +#if (MMC_SLOT_NUM > 1) +#define MMC_DETECT_INIT(SlotNo) do /* DETECT initial setting */ \ + { \ + switch (SlotNo) { \ + case MMC_SLOT0: MMC_DETECT0_INIT(); break; \ + case MMC_SLOT1: MMC_DETECT1_INIT(); break; \ + default: break; \ + } \ + } while (0) +#define MMC_GET_DETECT(SlotNo, Lv) do /* DETECT input control */ \ + { \ + Lv = MMC_NOT_CONNECT; /* Initialize by non-detection */ \ + switch (SlotNo) \ + { \ + case MMC_SLOT0: MMC_GET_DETECT0(Lv); break; \ + case MMC_SLOT1: MMC_GET_DETECT1(Lv); break; \ + default: break; \ + } \ + } while (0) +#endif /* #if (MMC_SLOT_NUM > 1) */ + +/*-------------------- CS control --------------------*/ +#if (MMC_SLOT_NUM == 1) +#define MMC_CS_INIT(SlotNo) do /* CS initial setting */ \ + { \ + MMC_PORT_CS0 = MMC_HI; /* CS0 "H" */ \ + MMC_PM_CS0 = MMC_FALSE; /* CS0 Output */ \ + } while (0) + +#define MMC_CS_OPEN(SlotNo) do /* CS open setting */ \ + { \ + MMC_PM_CS0 = MMC_TRUE; /* CS0 Input */ \ + } while (0) + +#define MMC_SET_CS(SlotNo, Lv) do /* CS output control */ \ + { \ + MMC_PORT_CS0 = Lv; \ + } while (0) +#endif /* #if (MMC_SLOT_NUM == 1) */ + +#if (MMC_SLOT_NUM > 1) +#define MMC_CS_INIT(SlotNo) do /* CS initial setting */ \ + { \ + switch (SlotNo) \ + { \ + case MMC_SLOT0: \ + MMC_PORT_CS0 = MMC_HI; /* CS0 Output */ \ + MMC_PM_CS0 = MMC_FALSE; /* CS0 "H" */ \ + break; \ + case MMC_SLOT1: \ + MMC_PORT_CS1 = MMC_HI; /* CS1 Output */ \ + MMC_PM_CS1 = MMC_FALSE; /* CS1 "H" */ \ + break; \ + default: \ + break; \ + } \ + } while (0) + +#define MMC_CS_OPEN(SlotNo) do /* CS open setting */ \ + { \ + switch (SlotNo) \ + { \ + case MMC_SLOT0: MMC_PM_CS0 = MMC_TRUE; break; /* CS0 Input */ \ + case MMC_SLOT1: MMC_PM_CS1 = MMC_TRUE; break; /* CS1 Input */ \ + default: break; \ + } \ + } while (0) + +#define MMC_SET_CS(SlotNo, Lv) do /* CS output control */ \ + { \ + switch (SlotNo) \ + { \ + case MMC_SLOT0: MMC_PORT_CS0 = Lv; break; \ + case MMC_SLOT1: MMC_PORT_CS1 = Lv; break; \ + default: break; \ + } \ + } while (0) + +#endif /* #if (MMC_SLOT_NUM > 1) */ + +/*------------------- CSI control -------------------*/ +#define MMC_CSI_ERR_CLEAR() do /* CSI enable setting */ \ + { \ + MMC_CSI_SIRmnL = MMC_CSI_SIR_CLEAR; /* clear error flag */ \ + } while (0) + + +#define MMC_CSI_EI() do /* CSI enable setting */ \ + { \ + MMC_SAUmRES = MMC_FALSE; /* SAUm reset control */ \ + MMC_SAUmEN = MMC_TRUE; /* supply SAUm clock */ \ + __nop(); /* wait 4 clocks */ \ + __nop(); \ + __nop(); \ + __nop(); \ + MMC_CSI_SPSmL = (MMC_CSI_SPSmL & MMC_SPS_MASK | MMC_SPS_SET); /* Serial clock setting */ \ + MMC_CSI_STmn = MMC_TRUE; /* clear error flag */ \ + MMC_CSI_MKmn = MMC_TRUE; /* disable INTCSImn interrupt */ \ + MMC_CSI_IFmn = MMC_FALSE; /* clear INTCSImn interrupt flag */ \ + MMC_CSI_SIRmnL = MMC_CSI_SIR_CLEAR; /* clear error flag */ \ + MMC_CSI_SCRmn = MMC_SCR_INIT; /* init SCR setting */ \ + MMC_CSI_SOm |= MMC_CLKOUT_BIT; \ + MMC_CSI_SOm |= MMC_SOOUT_BIT; \ + MMC_CSI_SOEmn = MMC_TRUE; \ + MMC_CSI_ISC &= MMC_ISC_TBL; \ + } while (0) + +#define MMC_CSI_DI() do /* CSI disable setting */ \ + { \ + MMC_CSI_SCRmn = MMC_SCR_INIT; /* init SCR setting */ \ + } while (0) + +#define MMC_CSI_BRG_SET(BR_DATA) do /* CSI bit rate setting */ \ + { \ + MMC_CSI_SDRmn = ((uint16_t)BR_DATA << 9); /* Clock setting */ \ + } while (0) + +#define MMC_CSI_TX_EI() do /* CSI transmit enable setting */ \ + { \ + MMC_CSI_SMRmn = MMC_SMR_TX; /* Transmission mode setting */ \ + MMC_CSI_SCRmn = MMC_SCR_TX; /* Transmission mode setting */ \ + MMC_CSI_SOEmn = MMC_TRUE; \ + MMC_CSI_IFmn = MMC_FALSE; /* clear INTCSImn interrupt flag */ \ + MMC_CSI_SSmn = MMC_TRUE; /* enable CSIxy */ \ + } while (0) + +#define MMC_CSI_TRX_EI() do /* CSI transmit&receive enable setting */ \ + { \ + MMC_CSI_SMRmn = MMC_SMR_RX; /* Transmission mode setting */ \ + MMC_CSI_SCRmn = MMC_SCR_RX; /* Transmission mode setting */ \ + MMC_CSI_SOEmn = MMC_TRUE; /* enable CSI */ \ + MMC_CSI_IFmn = MMC_FALSE; /* clear INTCSImn interrupt flag */ \ + MMC_CSI_SSmn = MMC_TRUE; /* start CSI */ \ + } while (0) + +#define MMC_CSI_TX_DI() do /* CSI transmit disable setting */ \ + { \ + MMC_CSI_STmn = MMC_TRUE; /* stop CSI */ \ + MMC_CSI_SOEmn = MMC_FALSE; /* disable CSI output */ \ + MMC_CSI_IFmn = MMC_FALSE; /* clear INTCSImn interrupt flag */ \ + MMC_CSI_SOm |= ((uint16_t)1 << MMC_CLK_SO_BITNO) | ((uint16_t)1 << MMC_DATAO_SO_BITNO); /* Port init */ \ + } while (0) + +#define MMC_CSI_TRX_DI() do /* CSI transmit&receive disable setting */ \ + { \ + MMC_CSI_STmn = MMC_TRUE; /* stop CSI */ \ + MMC_CSI_SOEmn = MMC_FALSE; /* disable CSI output */ \ + MMC_CSI_IFmn = MMC_FALSE; /* clear INTCSImn interrupt flag */ \ + MMC_CSI_SOm |= ((uint16_t)1 << MMC_CLK_SO_BITNO) | ((uint16_t)1 << MMC_DATAO_SO_BITNO); /* Port init */ \ + } while (0) + +#define MMC_TXNEXT_CHECK() ((MMC_CSI_SSRmnL & MMC_TXNEXT_MASK) != 0) +#define MMC_TXNEXT_CLR() do \ + { \ + MMC_CSI_IFmn = MMC_FALSE; \ + } while (0) + +#define MMC_TXEND_CHECK() ((MMC_CSI_SSRmnL & MMC_TXEND_MASK) != 0) + + +#define MMC_CSI_ORER_CHECK() ((MMC_CSI_SSRmnL & MMC_OVF_MASK) != 0) + +#define MMC_RX_COMPLETE_CHECK() ((MMC_CSI_SSRmnL & MMC_RX_COMPLETE_MASK) == 0) +#define MMC_RXNEXT_CLR() + +/*----------------- CRC calculation ------------------*/ +#ifdef MMC_CRC_HARD +#define MMC_CRC_CLR() MMC_CRCD = 0x0000 +#define MMC_CRC_SET(Data) do \ + { \ + MMC_CRCIN = T_ExchgBit[Data]; \ + }while(0); + +#define MMC_CRC_GET(Data) Data = MMC_CRCD +#else /* #ifdef MMC_CRC_HARD */ +#define MMC_CRC_CLR() gMmc_CrcData.us = 0x0000 +#ifdef MTL_MCU_LITTLE +#define MMC_CRC_SET(Data) do \ + { \ + uint8_t ucTmp; \ + ucTmp = gMmc_CrcData.uc[0]; \ + gMmc_CrcData.us = T_Crc_Ccitt[gMmc_CrcData.uc[1] ^ Data]; \ + gMmc_CrcData.uc[1] = gMmc_CrcData.uc[1] ^ ucTmp; \ + } while (0) +#else /* #ifdef MTL_MCU_LITTLE */ +#define MMC_CRC_SET(Data) do \ + { \ + uint8_t ucTmp; \ + ucTmp = gMmc_CrcData.uc[1]; \ + gMmc_CrcData.us = T_Crc_Ccitt[gMmc_CrcData.uc[0] ^ Data]; \ + gMmc_CrcData.uc[0] = gMmc_CrcData.uc[0] ^ ucTmp; \ + } while (0) +#endif /* #ifdef MTL_MCU_LITTLE */ +#define MMC_CRC_GET(Data) Data = gMmc_CrcData.us +#endif /* #ifdef MMC_CRC_HARD */ + +#endif /* __MMC_SFR_H__ */ diff --git a/variants/g22-fpb-48p/r_mmc_user_config.h b/variants/g22-fpb-48p/r_mmc_user_config.h index a497239..9efe4aa 100644 --- a/variants/g22-fpb-48p/r_mmc_user_config.h +++ b/variants/g22-fpb-48p/r_mmc_user_config.h @@ -1,144 +1,144 @@ -/*""FILE COMMENT""******************************************************************* -* File Name : r_mmc_user_config.h -* Version : 1.00 -* Device(s) : RL78/G23 -* compiler : CC-RL -* H/W Platform : R7F100Gxx -* Description : MMC driver SFR for RL78/G23-CSI user configuration definitions -************************************************************************************* -* History : DD.MM.YYYY Version Description -* : 04.06.2021 Ver1.00 -*""FILE COMMENT END""***************************************************************/ -#ifndef __R_MMC_USER_CONFIG_H__ -#define __R_MMC_USER_CONFIG_H__ - -/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ -/* Please define resources of each user system. */ -/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ - -/* Serial Array Unit(SAU) Select ( 0 or 1 )*/ -#define MMC_SAU_UNIT 0 /** SET **/ -/* SAU Channel Select ( 0 or 1 or 2 or 3 ) */ -#define MMC_SAU_CHANNEL 3 /** SET **/ -/* CSI PIN select ( 'A' or 'B' ) */ -#define MMC_CSI_PIN 'A' /** SET **/ - -/* - || Select Port | -------------+------------+-----------++--------------------------------+ - MMC_SAU_ | MMC_SAU_ | MMC_CSI_ || SI | SCK | SO | - UNIT | CHANNEL | PIN || Select | Select | Select | - Value | Value | Value || port | port | port | -============+============+===========++==========+==========+==========+ - 0 | 0 | 'A' || P11 | P10 | P12 | -(=Use SAU0) | |-----------++----------+----------+----------+ - |(=Use CSI00)| 'B' || P16 | P55 | P17 | - +------------+-----------++----------+----------+----------+ - | 1 | (invalid) || P74 | P75 | P73 | - |(=Use CSI01)| || | | | - +------------+-----------++----------+----------+----------+ - | 2 | (invalid) || P03 | P04 | P02 | - |(=Use CSI10)| || | | | - -+------------+-----------++----------+----------+----------+ - | 3 | (invalid) || P50 | P30 | P51 | - |(=Use CSI11)| || | | | -------------+------------+-----------++----------+----------+----------+ - 1 | 0 | (invalid) || P14 | P15 | P13 | -(=Use SAU1) |(=Use CSI20)| || | | | - +------------+-----------++----------+----------+----------+ - | 1 | (invalid) || P71 | P70 | P72 | - |(=Use CSI21)| || | | | -------------+------------+-----------++----------+----------+----------+*/ - -/*----------------------------------------------------------------------------------------------*/ -/* Define the control port. */ -/*----------------------------------------------------------------------------------------------*/ -#define MMC_CS0_PORTNO 0 /* CS0 Port No. */ /** SET **/ -#define MMC_CS0_BITNO 5 /* CS0 Bit No. */ /** SET **/ - -/* Please define the MMC_DETECT0_CONNECTION macro when the MMC slot Card detect pin connect to MCU. */ -//#define MMC_DETECT0_CONNECTION /* DETECT0 Port Connection */ /** SET **/ - -#if defined(MMC_DETECT0_CONNECTION) -#define MMC_DETECT0_PORTNO 0 /* DETECT0 Port No. */ /** SET **/ -#define MMC_DETECT0_BITNO 6 /* DETECT0 Bit No. */ /** SET **/ -#endif /* #if defined(MMC_DETECT0_CONNECTION) */ - - -#if (MMC_SLOT_NUM > 1) - -#define MMC_CS1_PORTNO /* CS1 Port No. */ /** SET **/ -#define MMC_CS1_BITNO /* CS1 Bit No. */ /** SET **/ - - -#define MMC_DETECT1_CONNECTION /* DETECT1 Port Connection */ /** SET **/ - -#if defined(MMC_DETECT1_CONNECTION) -#define MMC_DETECT1_PORTNO /* DETECT1 Port No. */ /** SET **/ -#define MMC_DETECT1_BITNO /* DETECT1 Bit No. */ /** SET **/ -#endif /* #if defined(MMC_DETECT0_CONNECTION) */ - -#endif /* #if (MMC_SLOT_NUM > 1) */ - - -/*----------------------------------------------------------------------------------------------*/ -/* Macro "MMC_NOCHK_TIMEOUT" omits detecting timeout during communication. */ -/* If user omits detecting timeout, please define this macro. */ -/* If this macro is defined, processing speed would be increased. */ -/*----------------------------------------------------------------------------------------------*/ -#define MMC_NOCHK_TIMEOUT /* No Check Communication Timeout */ /** SET **/ - -/*----------------------------------------------------------------------------------------------*/ -/* If MMC_NOCHK_TIMEOUT would be not defined, please set timeout time. */ -/* MMC_T_CSI_WAIT is unit of measuring timeout. */ -/* Please select value from "r_mtl_tim.h" */ -/* Please set value of (timeout time/unit) to MMC_CSI_TX_WAIT(transmitting) */ -/* and MMC_CSI_RX_WAIT(receiving). */ -/*----------------------------------------------------------------------------------------------*/ -/* CSI transmit&receive completion waiting polling time */ -#define MMC_T_CSI_WAIT (natural_uint_t)MTL_T_1US /** SET **/ - -/* CSI transmission completion waiting time 50000 * 1us = 50ms */ -#define MMC_CSI_TX_WAIT (natural_uint_t)50000 /** SET **/ -/* CSI receive completion waiting time 50000 * 1us = 50ms */ -#define MMC_CSI_RX_WAIT (natural_uint_t)50000 /** SET **/ - - -/*----------------------------------------------------------------------------------------------*/ -/* Define the combination of the MCU's resources. */ -/*----------------------------------------------------------------------------------------------*/ -//#define MMC_OPTION_1 /* CSI */ /** SET **/ -#define MMC_OPTION_2 /* CSI + CRC calculation circuit */ /** SET **/ - - -/*----------------------------------------------------------------------------------------------*/ -/* Define the value of the bit rate register according to a communication baud rate. */ -/* Set the frequency of CLK to 12MHz or less. */ -/* The possible maximum transfer frequency of CLK is depends on hardware circuit */ -/* and MCU conditions. */ -/* Refer to MCU hardware manual/memory card specifications and specify the buad rate. */ -/* When operating card with SPI mode, */ -/* specify the following two definitions of Identification mode and Data Transfer mode. */ -/* Specify the definition to meet tODLY of both Identification mode and Data Transfer mode. */ -/* In addition, meet tOD (100KHz <= tOD <= 400KHz) at Identification mode */ -/* and tPP (0.1MHz <= tPP <= 20MHz ) at Data Transfer mode. */ -/* The maximum frequency depends on MCU type. */ -/* */ -/* Transfer clock frequency(fTCLK) = (fMCK) / (SDRmn[15:9] + 1) / 2 [Hz] */ -/* fMCK: Operation clock */ -/* fMCK is determined by serial clock select register m (SPSm) */ -/* and bit 15 (CKSmn) of serial mode register mn (SMRmn). */ -/*----------------------------------------------------------------------------------------------*/ -/* fCLK = 32MHz , fMCK = 16MHz , fTCLK = 8MHz */ -#define MMC_FCLK_PRESCALER_SELECT 1 /* SPSm.PRSmk[3:0] */ /** SET **/ - -//#define MMC_OPERATION_CLK_SELECT 0 /* select SMRm.CKmX 0:CKm0 1:CKm1 */ /** SET **/ -#define MMC_OPERATION_CLK_SELECT 1 /* select SMRm.CKmX 0:CKm0 1:CKm1 */ /** SET **/ - -#define MMC_UBRG_IDENTIFICATION (uint8_t)19 /* BRR identification mode setting */ /** SET **/ -/* ++---------------- 400KHz */ -#define MMC_UBRG_D_TRANSFER (uint8_t)0 /* BRR data Transfer mode setting */ /** SET **/ -/* ++---------------- 8.0MHz */ -#define MMC_CLK_D_TRANSFER (uint32_t)8000000 /* Data Transfer mode clock frequency */ /** SET **/ - -#endif /* #ifndef __R_MMC_USER_CONFIG_H__ */ +/*""FILE COMMENT""******************************************************************* +* File Name : r_mmc_user_config.h +* Version : 1.00 +* Device(s) : RL78/G23 +* compiler : CC-RL +* H/W Platform : R7F100Gxx +* Description : MMC driver SFR for RL78/G23-CSI user configuration definitions +************************************************************************************* +* History : DD.MM.YYYY Version Description +* : 04.06.2021 Ver1.00 +*""FILE COMMENT END""***************************************************************/ +#ifndef __R_MMC_USER_CONFIG_H__ +#define __R_MMC_USER_CONFIG_H__ + +/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ +/* Please define resources of each user system. */ +/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ + +/* Serial Array Unit(SAU) Select ( 0 or 1 )*/ +#define MMC_SAU_UNIT 0 /** SET **/ +/* SAU Channel Select ( 0 or 1 or 2 or 3 ) */ +#define MMC_SAU_CHANNEL 3 /** SET **/ +/* CSI PIN select ( 'A' or 'B' ) */ +#define MMC_CSI_PIN 'A' /** SET **/ + +/* + || Select Port | +------------+------------+-----------++--------------------------------+ + MMC_SAU_ | MMC_SAU_ | MMC_CSI_ || SI | SCK | SO | + UNIT | CHANNEL | PIN || Select | Select | Select | + Value | Value | Value || port | port | port | +============+============+===========++==========+==========+==========+ + 0 | 0 | 'A' || P11 | P10 | P12 | +(=Use SAU0) | |-----------++----------+----------+----------+ + |(=Use CSI00)| 'B' || P16 | P55 | P17 | + +------------+-----------++----------+----------+----------+ + | 1 | (invalid) || P74 | P75 | P73 | + |(=Use CSI01)| || | | | + +------------+-----------++----------+----------+----------+ + | 2 | (invalid) || P03 | P04 | P02 | + |(=Use CSI10)| || | | | + -+------------+-----------++----------+----------+----------+ + | 3 | (invalid) || P50 | P30 | P51 | + |(=Use CSI11)| || | | | +------------+------------+-----------++----------+----------+----------+ + 1 | 0 | (invalid) || P14 | P15 | P13 | +(=Use SAU1) |(=Use CSI20)| || | | | + +------------+-----------++----------+----------+----------+ + | 1 | (invalid) || P71 | P70 | P72 | + |(=Use CSI21)| || | | | +------------+------------+-----------++----------+----------+----------+*/ + +/*----------------------------------------------------------------------------------------------*/ +/* Define the control port. */ +/*----------------------------------------------------------------------------------------------*/ +#define MMC_CS0_PORTNO 0 /* CS0 Port No. */ /** SET **/ +#define MMC_CS0_BITNO 5 /* CS0 Bit No. */ /** SET **/ + +/* Please define the MMC_DETECT0_CONNECTION macro when the MMC slot Card detect pin connect to MCU. */ +//#define MMC_DETECT0_CONNECTION /* DETECT0 Port Connection */ /** SET **/ + +#if defined(MMC_DETECT0_CONNECTION) +#define MMC_DETECT0_PORTNO 0 /* DETECT0 Port No. */ /** SET **/ +#define MMC_DETECT0_BITNO 6 /* DETECT0 Bit No. */ /** SET **/ +#endif /* #if defined(MMC_DETECT0_CONNECTION) */ + + +#if (MMC_SLOT_NUM > 1) + +#define MMC_CS1_PORTNO /* CS1 Port No. */ /** SET **/ +#define MMC_CS1_BITNO /* CS1 Bit No. */ /** SET **/ + + +#define MMC_DETECT1_CONNECTION /* DETECT1 Port Connection */ /** SET **/ + +#if defined(MMC_DETECT1_CONNECTION) +#define MMC_DETECT1_PORTNO /* DETECT1 Port No. */ /** SET **/ +#define MMC_DETECT1_BITNO /* DETECT1 Bit No. */ /** SET **/ +#endif /* #if defined(MMC_DETECT0_CONNECTION) */ + +#endif /* #if (MMC_SLOT_NUM > 1) */ + + +/*----------------------------------------------------------------------------------------------*/ +/* Macro "MMC_NOCHK_TIMEOUT" omits detecting timeout during communication. */ +/* If user omits detecting timeout, please define this macro. */ +/* If this macro is defined, processing speed would be increased. */ +/*----------------------------------------------------------------------------------------------*/ +#define MMC_NOCHK_TIMEOUT /* No Check Communication Timeout */ /** SET **/ + +/*----------------------------------------------------------------------------------------------*/ +/* If MMC_NOCHK_TIMEOUT would be not defined, please set timeout time. */ +/* MMC_T_CSI_WAIT is unit of measuring timeout. */ +/* Please select value from "r_mtl_tim.h" */ +/* Please set value of (timeout time/unit) to MMC_CSI_TX_WAIT(transmitting) */ +/* and MMC_CSI_RX_WAIT(receiving). */ +/*----------------------------------------------------------------------------------------------*/ +/* CSI transmit&receive completion waiting polling time */ +#define MMC_T_CSI_WAIT (natural_uint_t)MTL_T_1US /** SET **/ + +/* CSI transmission completion waiting time 50000 * 1us = 50ms */ +#define MMC_CSI_TX_WAIT (natural_uint_t)50000 /** SET **/ +/* CSI receive completion waiting time 50000 * 1us = 50ms */ +#define MMC_CSI_RX_WAIT (natural_uint_t)50000 /** SET **/ + + +/*----------------------------------------------------------------------------------------------*/ +/* Define the combination of the MCU's resources. */ +/*----------------------------------------------------------------------------------------------*/ +//#define MMC_OPTION_1 /* CSI */ /** SET **/ +#define MMC_OPTION_2 /* CSI + CRC calculation circuit */ /** SET **/ + + +/*----------------------------------------------------------------------------------------------*/ +/* Define the value of the bit rate register according to a communication baud rate. */ +/* Set the frequency of CLK to 12MHz or less. */ +/* The possible maximum transfer frequency of CLK is depends on hardware circuit */ +/* and MCU conditions. */ +/* Refer to MCU hardware manual/memory card specifications and specify the buad rate. */ +/* When operating card with SPI mode, */ +/* specify the following two definitions of Identification mode and Data Transfer mode. */ +/* Specify the definition to meet tODLY of both Identification mode and Data Transfer mode. */ +/* In addition, meet tOD (100KHz <= tOD <= 400KHz) at Identification mode */ +/* and tPP (0.1MHz <= tPP <= 20MHz ) at Data Transfer mode. */ +/* The maximum frequency depends on MCU type. */ +/* */ +/* Transfer clock frequency(fTCLK) = (fMCK) / (SDRmn[15:9] + 1) / 2 [Hz] */ +/* fMCK: Operation clock */ +/* fMCK is determined by serial clock select register m (SPSm) */ +/* and bit 15 (CKSmn) of serial mode register mn (SMRmn). */ +/*----------------------------------------------------------------------------------------------*/ +/* fCLK = 32MHz , fMCK = 16MHz , fTCLK = 8MHz */ +#define MMC_FCLK_PRESCALER_SELECT 1 /* SPSm.PRSmk[3:0] */ /** SET **/ + +//#define MMC_OPERATION_CLK_SELECT 0 /* select SMRm.CKmX 0:CKm0 1:CKm1 */ /** SET **/ +#define MMC_OPERATION_CLK_SELECT 1 /* select SMRm.CKmX 0:CKm0 1:CKm1 */ /** SET **/ + +#define MMC_UBRG_IDENTIFICATION (uint8_t)19 /* BRR identification mode setting */ /** SET **/ +/* ++---------------- 400KHz */ +#define MMC_UBRG_D_TRANSFER (uint8_t)0 /* BRR data Transfer mode setting */ /** SET **/ +/* ++---------------- 8.0MHz */ +#define MMC_CLK_D_TRANSFER (uint32_t)8000000 /* Data Transfer mode clock frequency */ /** SET **/ + +#endif /* #ifndef __R_MMC_USER_CONFIG_H__ */ diff --git a/variants/g22-fpb-48p/wiring_private_tone.h b/variants/g22-fpb-48p/wiring_private_tone.h index 136c6aa..cd449e5 100644 --- a/variants/g22-fpb-48p/wiring_private_tone.h +++ b/variants/g22-fpb-48p/wiring_private_tone.h @@ -1,105 +1,105 @@ -/* - wiring_private.h - Internal header file. - Part of Arduino - http://www.arduino.cc/ - - Copyright (c) 2005-2006 David A. Mellis - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - $Id: wiring.h 239 2007-01-12 17:58:39Z mellis $ -*/ -/* - Modified 13 July 2014 by Nozomu Fujita for GR-SAKURA - Modified 1 Mar 2017 by Yuuki Okamiya for RL78/G13 -*/ - -#ifndef WiringPrivateTone_h -#define WiringPrivateTone_h - -#ifdef __cplusplus -extern "C"{ -#endif - -#define FREQUENCY_MIN_VAL (500) -#define FREQUENCY_MAX_VAL (8000000) - -#define TONE_CH_NUM (7) - -#define TAU_OPERATION_CLOCK (0xC000U) /* operation clock set by PRS register */ -#define CK00_CK01_OPERATION (0x000F) /* Selection of operation clock CK00, CK01 */ -#define CK02_OPERATION (0x0300) /* Selection of operation clock CK02 */ -#define CK03_OPERATION (0x3000) /* Selection of operation clock CK03 */ -#define TIMEOUT_MAX_VAL (65535) -#define PULSE_INTERUPT (1) - -#define _4000_TAU_CLOCK_SELECT_CKM2 (0x4000U) /* operation clock CK2 set by PRS register */ -#define _0000_TAU_CKM2_FCLK_1 (0x0000U) /* ckm2 - fCLK/2^1 */ -#define _C000_TAU_CLOCK_SELECT_CKM3 (0xC000U) /* operation clock CK3 set by PRS register */ - -typedef struct { - void (*open)(); - void (*start)(); - void (*stop)(); -} tone_func; - - - -#ifdef __cplusplus -} // extern "C" -#endif - - -/* tone pin set */ -extern volatile unsigned short *g_tone_period_reg[TONE_CH_NUM]; -extern volatile unsigned short *g_timer_tone_mode_reg[TONE_CH_NUM]; -extern volatile unsigned short *g_timer_tone_clock_select_reg; -extern const uint8_t tone_channel_table[TONE_CH_NUM]; - -//#include "Config_TAU0_1_Square_Wave.h" -extern "C"{ -void R_Config_TAU0_1_Square_Wave_Create(void); -void R_Config_TAU0_1_Square_Wave_Start(void); -void R_Config_TAU0_1_Square_Wave_Stop(void); -void R_Config_TAU0_1_Square_Wave_Create_UserInit(void); -void R_Config_TAU0_2_Square_Wave_Create(void); -void R_Config_TAU0_2_Square_Wave_Start(void); -void R_Config_TAU0_2_Square_Wave_Stop(void); -void R_Config_TAU0_2_Square_Wave_Create_UserInit(void); -void R_Config_TAU0_3_Square_Wave_Create(void); -void R_Config_TAU0_3_Square_Wave_Start(void); -void R_Config_TAU0_3_Square_Wave_Stop(void); -void R_Config_TAU0_3_Square_Wave_Create_UserInit(void); -void R_Config_TAU0_4_Square_Wave_Create(void); -void R_Config_TAU0_4_Square_Wave_Start(void); -void R_Config_TAU0_4_Square_Wave_Stop(void); -void R_Config_TAU0_4_Square_Wave_Create_UserInit(void); -void R_Config_TAU0_5_Square_Wave_Create(void); -void R_Config_TAU0_5_Square_Wave_Start(void); -void R_Config_TAU0_5_Square_Wave_Stop(void); -void R_Config_TAU0_5_Square_Wave_Create_UserInit(void); -void R_Config_TAU0_6_Square_Wave_Create(void); -void R_Config_TAU0_6_Square_Wave_Start(void); -void R_Config_TAU0_6_Square_Wave_Stop(void); -void R_Config_TAU0_6_Square_Wave_Create_UserInit(void); -void R_Config_TAU0_7_Square_Wave_Create(void); -void R_Config_TAU0_7_Square_Wave_Start(void); -void R_Config_TAU0_7_Square_Wave_Stop(void); -void R_Config_TAU0_7_Square_Wave_Create_UserInit(void); -} - -extern tone_func tone_ch[TONE_CH_NUM]; - -#endif +/* + wiring_private.h - Internal header file. + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2005-2006 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + $Id: wiring.h 239 2007-01-12 17:58:39Z mellis $ +*/ +/* + Modified 13 July 2014 by Nozomu Fujita for GR-SAKURA + Modified 1 Mar 2017 by Yuuki Okamiya for RL78/G13 +*/ + +#ifndef WiringPrivateTone_h +#define WiringPrivateTone_h + +#ifdef __cplusplus +extern "C"{ +#endif + +#define FREQUENCY_MIN_VAL (500) +#define FREQUENCY_MAX_VAL (8000000) + +#define TONE_CH_NUM (7) + +#define TAU_OPERATION_CLOCK (0xC000U) /* operation clock set by PRS register */ +#define CK00_CK01_OPERATION (0x000F) /* Selection of operation clock CK00, CK01 */ +#define CK02_OPERATION (0x0300) /* Selection of operation clock CK02 */ +#define CK03_OPERATION (0x3000) /* Selection of operation clock CK03 */ +#define TIMEOUT_MAX_VAL (65535) +#define PULSE_INTERUPT (1) + +#define _4000_TAU_CLOCK_SELECT_CKM2 (0x4000U) /* operation clock CK2 set by PRS register */ +#define _0000_TAU_CKM2_FCLK_1 (0x0000U) /* ckm2 - fCLK/2^1 */ +#define _C000_TAU_CLOCK_SELECT_CKM3 (0xC000U) /* operation clock CK3 set by PRS register */ + +typedef struct { + void (*open)(); + void (*start)(); + void (*stop)(); +} tone_func; + + + +#ifdef __cplusplus +} // extern "C" +#endif + + +/* tone pin set */ +extern volatile unsigned short *g_tone_period_reg[TONE_CH_NUM]; +extern volatile unsigned short *g_timer_tone_mode_reg[TONE_CH_NUM]; +extern volatile unsigned short *g_timer_tone_clock_select_reg; +extern const uint8_t tone_channel_table[TONE_CH_NUM]; + +//#include "Config_TAU0_1_Square_Wave.h" +extern "C"{ +void R_Config_TAU0_1_Square_Wave_Create(void); +void R_Config_TAU0_1_Square_Wave_Start(void); +void R_Config_TAU0_1_Square_Wave_Stop(void); +void R_Config_TAU0_1_Square_Wave_Create_UserInit(void); +void R_Config_TAU0_2_Square_Wave_Create(void); +void R_Config_TAU0_2_Square_Wave_Start(void); +void R_Config_TAU0_2_Square_Wave_Stop(void); +void R_Config_TAU0_2_Square_Wave_Create_UserInit(void); +void R_Config_TAU0_3_Square_Wave_Create(void); +void R_Config_TAU0_3_Square_Wave_Start(void); +void R_Config_TAU0_3_Square_Wave_Stop(void); +void R_Config_TAU0_3_Square_Wave_Create_UserInit(void); +void R_Config_TAU0_4_Square_Wave_Create(void); +void R_Config_TAU0_4_Square_Wave_Start(void); +void R_Config_TAU0_4_Square_Wave_Stop(void); +void R_Config_TAU0_4_Square_Wave_Create_UserInit(void); +void R_Config_TAU0_5_Square_Wave_Create(void); +void R_Config_TAU0_5_Square_Wave_Start(void); +void R_Config_TAU0_5_Square_Wave_Stop(void); +void R_Config_TAU0_5_Square_Wave_Create_UserInit(void); +void R_Config_TAU0_6_Square_Wave_Create(void); +void R_Config_TAU0_6_Square_Wave_Start(void); +void R_Config_TAU0_6_Square_Wave_Stop(void); +void R_Config_TAU0_6_Square_Wave_Create_UserInit(void); +void R_Config_TAU0_7_Square_Wave_Create(void); +void R_Config_TAU0_7_Square_Wave_Start(void); +void R_Config_TAU0_7_Square_Wave_Stop(void); +void R_Config_TAU0_7_Square_Wave_Create_UserInit(void); +} + +extern tone_func tone_ch[TONE_CH_NUM]; + +#endif diff --git a/variants/g22-fpb-48p/wiring_variant.h b/variants/g22-fpb-48p/wiring_variant.h index 2fe7459..6ed5524 100644 --- a/variants/g22-fpb-48p/wiring_variant.h +++ b/variants/g22-fpb-48p/wiring_variant.h @@ -1,83 +1,70 @@ -/* - wiring_variant.h - Internal header file. - Part of Arduino - http://www.arduino.cc/ - - Copyright (c) 2005-2006 David A. Mellis - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - $Id: wiring.h 239 2007-01-12 17:58:39Z mellis $ -*/ -/* - Modified 13 July 2014 by Nozomu Fujita for GR-SAKURA - Modified 1 Mar 2017 by Yuuki Okamiya for RL78/G13 -*/ - -#ifndef WiringVariante_h -#define WiringVariante_h - -#include -#include -#include "Arduino.h" -#include "utilities.h" - -#ifdef __cplusplus -extern "C"{ -#endif - -#define ANALOG_ADPC_OFFSET 4 -#define ANALOG_PIN_START_NUMBER (38) -#define MAX_CYCLIC_HANDLER (8) -#define EXTERNAL_NUM_INTERRUPTS (7) - -/* PWM defines. */ -#define PWM_MIN 0 -#define PWM_MAX 255 - -/* External interrupt define. */ -#define EXTERNAL_INTERRUPT_0 2 -#define EXTERNAL_INTERRUPT_1 3 -#define EXTERNAL_INTERRUPT_2 10 -#define EXTERNAL_INTERRUPT_3 32 -#define PWM_CH_NUM (4) - -#define FREQUENCY_MIN_VAL (500) -#define FREQUENCY_MAX_VAL (8000000) - -#ifdef __cplusplus -} // extern "C" -#endif - -extern volatile uint8_t g_tau0_ch0_interrupt_flag; -extern volatile uint8_t g_tau0_ch1_interrupt_flag; -extern volatile uint8_t g_tau0_ch2_interrupt_flag; -extern volatile uint8_t g_tau0_ch3_interrupt_flag; -extern volatile uint8_t g_tau0_ch4_interrupt_flag; -extern volatile uint8_t g_tau0_ch5_interrupt_flag; -extern volatile uint8_t g_tau0_ch6_interrupt_flag; -extern volatile uint8_t g_tau0_ch7_interrupt_flag; -extern uint32_t R_BSP_GetFclkFreqHz(void); - -extern volatile uint8_t g_pulse_enable_interrupt_flag; -extern volatile unsigned short *g_timer_pulse_mode_reg[PULSE_IN_CH_NUM]; -extern volatile unsigned short *g_timer_pulse_clock_select_reg; -extern volatile unsigned short *g_timer_timeout_data_reg; -extern volatile unsigned short *g_timer_timeout_mode_reg; -extern const uint8_t pulse_in_channel_table[PULSE_IN_CH_NUM]; -extern pulse_in_func pulse_in_ch[PULSE_IN_CH_NUM]; - -#endif /* WiringVariante_h */ - +/* + wiring_variant.h - Internal header file. + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2005-2006 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + $Id: wiring.h 239 2007-01-12 17:58:39Z mellis $ +*/ +/* + Modified 13 July 2014 by Nozomu Fujita for GR-SAKURA + Modified 1 Mar 2017 by Yuuki Okamiya for RL78/G13 +*/ + +#ifndef WiringVariante_h +#define WiringVariante_h + +#include +#include +#include "Arduino.h" +#include "utilities.h" + +#ifdef __cplusplus +extern "C"{ +#endif + +#define ANALOG_ADPC_OFFSET 4 +#define ANALOG_PIN_START_NUMBER (38) +#define MAX_CYCLIC_HANDLER (8) +#define EXTERNAL_NUM_INTERRUPTS (7) + +/* PWM defines. */ +#define PWM_MIN 0 +#define PWM_MAX 255 + +/* External interrupt define. */ +#define EXTERNAL_INTERRUPT_0 2 +#define EXTERNAL_INTERRUPT_1 3 +#define EXTERNAL_INTERRUPT_2 10 +#define EXTERNAL_INTERRUPT_3 32 +#define PWM_CH_NUM (4) + +#define FREQUENCY_MIN_VAL (500) +#define FREQUENCY_MAX_VAL (8000000) + +/* pulseIn define. */ +#define PULSEIN_CLOCK_CYCLE 41 + +#ifdef __cplusplus +} // extern "C" +#endif + + +//extern uint32_t R_BSP_GetFclkFreqHz(void); +#endif /* WiringVariante_h */ + diff --git a/variants/g22-fpb-48p/wiring_variant_pwm.c b/variants/g22-fpb-48p/wiring_variant_pwm.c index 913084b..202d1f6 100644 --- a/variants/g22-fpb-48p/wiring_variant_pwm.c +++ b/variants/g22-fpb-48p/wiring_variant_pwm.c @@ -22,11 +22,11 @@ #include "r_smc_entry.h" // 2023/02/22 moved from wiring_analog.c -volatile unsigned short *g_timer_period_reg[PWM_CH_NUM] = {&TDR00,&TDR02,&TDR06}; -volatile unsigned short *g_timer_duty_reg[PWM_CH_NUM] = {&TDR01,&TDR03,&TDR07}; -volatile unsigned short *g_timer_analog_mode_reg[PWM_CH_NUM] = {&TMR01,&TMR03,&TMR07}; +volatile unsigned short *g_timer_period_reg[PWM_CH_NUM] = {&TDR00,&TDR00,&TDR00,&TDR00}; +volatile unsigned short *g_timer_duty_reg[PWM_CH_NUM] = {&TDR01,&TDR02,&TDR03,&TDR07}; +volatile unsigned short *g_timer_analog_mode_reg[PWM_CH_NUM] = {&TMR01,&TMR02,&TMR03,&TMR07}; volatile unsigned short *g_timer_analog_clock_select_reg = &TPS0; -const uint8_t pwm_channel_table[PWM_CH_NUM] = {PWM_PIN_10,PWM_PIN_3,PWM_PIN_5}; +const uint8_t pwm_channel_table[PWM_CH_NUM] = {PWM_PIN_10,PWM_PIN_9,PWM_PIN_3,PWM_PIN_5}; const uint8_t g_au8AnalogPinTable[NUM_ANALOG_INPUTS] = { ANALOG_PIN_0, ANALOG_PIN_1, ANALOG_PIN_2, ANALOG_PIN_3, @@ -36,59 +36,39 @@ const uint8_t g_analog_pin_input[NUM_ANALOG_INPUTS] = {PIN_A0, PIN_A1, PIN_A2, P Pwm_func pwm_ch[PWM_CH_NUM] = { { - .open = R_Config_TAU0_01_PWM_Create, - .start = R_Config_TAU0_01_PWM_Start, - .cycle = CYCLE_VALUE, + .open = (void*)R_Config_TAU0_0_PWM_Create, + .open_slave = (void*)R_Config_TAU0_1_PWM_Create, + .start = (void*)R_Config_TAU0_0_PWM_Start, + .start_slave = (void*)R_Config_TAU0_01_PWM_Start, + .stop_slave = (void*)R_Config_TAU0_01_PWM_Stop, + .enable_interrupt = (void*)R_Config_TAU0_0_PWM_Enable_IRQ, + .cycle = CYCLE_VALUE, }, { - .open = R_Config_TAU0_23_PWM_Create, - .start = R_Config_TAU0_23_PWM_Start, - .cycle = CYCLE_VALUE, - }, - { - .open = R_Config_TAU0_67_PWM_Create, - .start = R_Config_TAU0_67_PWM_Start, - .cycle = CYCLE_VALUE, - } -}; - -// 2023/02/22 end of moved from wiring_analog.c - -// 2023/02/23 moved from wiring_pulse.c - -volatile uint8_t g_pulse_enable_interrupt_flag = 0; -volatile unsigned short *g_timer_pulse_mode_reg[PULSE_IN_CH_NUM] = {&TMR01,&TMR02,&TMR03,&TMR07}; -volatile unsigned short *g_timer_pulse_clock_select_reg = &TPS0; -volatile unsigned short *g_timer_timeout_data_reg = &TDR00; -volatile unsigned short *g_timer_timeout_mode_reg = &TMR00; -const uint8_t pulse_in_channel_table[PULSE_IN_CH_NUM] = {PWM_PIN_10,PWM_PIN_9,PWM_PIN_3,PWM_PIN_5}; - - -pulse_in_func pulse_in_ch[PULSE_IN_CH_NUM] = -{ - { - .open = (void*)R_Config_TAU0_0_1_Measure_Signal_Create, - .start = (void*)R_Config_TAU0_0_1_Measure_Signal_Start, - .stop = (void*)R_Config_TAU0_0_1_Measure_Signal_Stop, - .get_width = (void*)R_Config_TAU0_1_Measure_Signal_Get_PulseWidth, - }, - { - .open = (void*)R_Config_TAU0_0_2_Measure_Signal_Create, - .start = (void*)R_Config_TAU0_0_2_Measure_Signal_Start, - .stop = (void*)R_Config_TAU0_0_2_Measure_Signal_Stop, - .get_width = (void*)R_Config_TAU0_2_Measure_Signal_Get_PulseWidth, + .open = (void*)R_Config_TAU0_0_PWM_Create, + .open_slave = (void*)R_Config_TAU0_2_PWM_Create, + .start = (void*)R_Config_TAU0_0_PWM_Start, + .start_slave = (void*)R_Config_TAU0_02_PWM_Start, + .stop_slave = (void*)R_Config_TAU0_02_PWM_Stop, + .enable_interrupt = (void*)R_Config_TAU0_0_PWM_Enable_IRQ, + .cycle = CYCLE_VALUE, }, { - .open = (void*)R_Config_TAU0_0_3_Measure_Signal_Create, - .start = (void*)R_Config_TAU0_0_3_Measure_Signal_Start, - .stop = (void*)R_Config_TAU0_0_3_Measure_Signal_Stop, - .get_width = (void*)R_Config_TAU0_3_Measure_Signal_Get_PulseWidth, + .open = (void*)R_Config_TAU0_0_PWM_Create, + .open_slave = (void*)R_Config_TAU0_3_PWM_Create, + .start = (void*)R_Config_TAU0_0_PWM_Start, + .start_slave = (void*)R_Config_TAU0_03_PWM_Start, + .stop_slave = (void*)R_Config_TAU0_03_PWM_Stop, + .enable_interrupt = (void*)R_Config_TAU0_0_PWM_Enable_IRQ, + .cycle = CYCLE_VALUE, }, - { - .open = (void*)R_Config_TAU0_0_7_Measure_Signal_Create, - .start = (void*)R_Config_TAU0_0_7_Measure_Signal_Start, - .stop = (void*)R_Config_TAU0_0_7_Measure_Signal_Stop, - .get_width = (void*)R_Config_TAU0_7_Measure_Signal_Get_PulseWidth, + { + .open = (void*)R_Config_TAU0_0_PWM_Create, + .open_slave = (void*)R_Config_TAU0_7_PWM_Create, + .start = (void*)R_Config_TAU0_0_PWM_Start, + .start_slave = (void*)R_Config_TAU0_07_PWM_Start, + .stop_slave = (void*)R_Config_TAU0_07_PWM_Stop, + .enable_interrupt = (void*)R_Config_TAU0_0_PWM_Enable_IRQ, + .cycle = CYCLE_VALUE, } }; -