Hardware Definition C++ Framework for Renesas RX Series
- Hardware definitions provided by Renesas are highly environment-dependent
- Implemented for the C language, using it with C++ has many negative effects
- Many implementations violate language conventions and are not recommended.
- Very verbose and poorly readable
- It is generated by another tool and is inconsistent.
- Not available without a separate tool.
- Generic keywords are defined in “#define” and contaminate keywords of the same name in the namespace
- Cannot be shared because of partial differences between RX microcontrollers.
Hardware definitions using C++ templates can be compiled error-free with C++17 or later compilers.
The hardware definitions utilizing C++ templates can be compiled without errors with C++17 or later compilers, and use formal names that conform to the register descriptions in the hardware manuals.
The hardware definitions using the C++ template can be compiled without error on C++17 or later compilers.
In “iodefine.h”, due to the structure of bit field definitions, it is necessary to add different instances for bit access and word access.
The “iodefine.h” is redundant because it is necessary to add different instances for bit access and word access due to the structure of the bit field definitions.
The source code is divided by module according to the hardware manual.
Since it is a template class, optimization can be maximized, and if necessary, there is room for further implementation for optimization.
It uses C++ functionality to absorb the subtle differences between different hardware through structural access, reference access, etc.
Each device module is referred to in this framework as a “peripheral.”
- To identify each device module, a peripheral name is defined
- Peripheral names are defined in the RXxxx/peripheral.hpp file.
- Peripheral names are defined in the RXxxx/peripheral.hpp file.
- These names are used as identifiers in various situations, such as power-saving switching, port control, interrupt control, etc.
- The names are used to automate the detailed configuration required throughout the framework.
- Note that the name of a peripheral may be the same as the name of the class that defines the peripheral.
- Peripheral names are defined as scoped enums in the “peripheral” space.
- There are several clocks generated by each microcontroller and they differ from module to module
- There are several clocks generated by each microcontroller and they differ from module to module: BASE, PLL_BASE, PCLKA, PCLKB, PCLKC, PCLKD, FCLK, BCLK, etc.
- It is defined in the file RXxxx/clock_profile.hpp
- This clock frequency is referenced, if needed, and is defined for each module class.
- Each module, and the driver that controls it, refers to this clock frequency to determine its period.
- The frequency is defined as an integer (if it is not divisible, be careful to handle errors)
- Defined in the file RXxxx/power_mgr.hpp
- Performs power control using peripheral names as keys.
- Defined in RXxxx/icu.hpp file
- Interrupt vectors handled by each device are also defined for abstraction
- Interrupt vectors have specific types, such as normal vectors, group vectors, and selective vectors.
- The different types are used to ensure that the configuration method is consistent, even when different configuration methods are used.
- Each device module of RX microcontroller uses I/O ports as input/output.
- Since these ports are used exclusively, it is necessary to set which input/output is assigned to which port.
- Port assignment is limited and there are several candidates
- The port map class implements a mechanism that allows specification by candidate and by group
- The RXxxx/port_map.hpp file defines the basic port candidates.
- Using this mechanism, each driver class can select and switch to a specified port.
- The candidate ports can be selected with the simplest possible specification.
- The “candidates” are based on the “List of Assigned Multifunction Pins” of the MPC (Multi-function Pin Controller) in the Hardware Manual.
- Each device class has various mechanisms to handle operations from driver and service classes in a more abstract way
- Each device class may have functions that allow operations to be performed in a concise manner
- We use “device” as the namespace for devices.
- For each microcontroller, a file that consolidates hardware-dependent definitions is provided.
- The definitions are in the file RXxxx/board_profile.hpp
- This file contains commonly used definitions such as LED ports, SCI ports, CMT channels, etc.
- Many of the sample application programs refer to and use these definitions.
- Therefore, the sample applications do not need to be aware of the settings specific to each microcontroller.
- There are cases where you want to use the sample programs and drivers provided by Renesas in conjunction with iodefine.h.
- In such a case, you may need to use “iodefine.h” together with C++ classes.
- In such cases, a generic name will be used (e.g., “USB”).
- In such cases, the generic name will be used (e.g. “USB”) because it may be defined by “#define” in “iodefine.h
- In this case, you need to change “iodefine.h” to a name that does not hit the target, and modify the source code provided by Renesas.
- C++ template classes are pushed into the namespace and usually do not hit, but if “#define” is used, there is nothing that can be done.
- Changing the “hit” names in the C++ template classes would be a major modification and is not recommended.
- The other way is to completely separate the source code that uses “idodefine.h” from the source code that uses the C++ framework
- When calling a C++ function from a C source, use “extern ‘C’” to define the function in C++, in which case the prototype should be C compliant
RX Microcontroller | operation verification |
---|---|
RX13T | - |
RX23T | - |
RX24T | 〇 |
RX24U | - |
RX26T | 〇 |
RX26x (RX260/RX261) | - |
RX62x (RX621/RX62N) | 〇 |
RX63T | 〇 |
RX63x (RX631/RX63N) | 〇 |
RX64M | 〇 |
RX65x (RX651/RX65N) | 〇 |
RX66N | - |
RX66T | 〇 |
RX71M | 〇 |
RX72M | - |
RX72N | 〇 |
RX72T | 〇 |
RX110 | - |
RX111 | - |
RX113 | - |
RX130 | - |
RX140 | 〇 |
RX220 | 〇 |
RX231 | 〇 |
RX660 | - |
RX671 | - |
File | Functions | Class |
---|---|---|
bus.hpp | Buses | BUS |
cac.hpp | Clock Frequency Accuracy Measurement Circuit | CAC |
can.hpp | CAN Module | CAN |
canfd.hpp | CAN FD Module | CANFD |
cmpc.hpp | Comparator C | CMPC |
cmt.hpp | Compare Match Timer | CMT |
cmtw.hpp | Compare Match Timer W | CMTW |
crc.hpp | CRC Calculator | CRC |
crca.hpp | CRC Calculator A | CRCA |
ctsu.hpp | Capacitive Touch Sensing Unit | CTSU |
ctsu2.hpp | Capacitive Touch Sensing Unit 2 | CTSU2 |
dmac.hpp | DMA Controller | DMAC |
doc.hpp | Data Operation Circuit | DOC |
doca.hpp | Data Operation Circuit A | DOCA |
drw2d.hpp | 2D Drawing Engine | DRW2D |
dsmif.hpp | Delta-Sigma Modulator Interface | DSMIF |
dtc.hpp | Data Transfer Controller | DTC |
edmac.hpp | DMA Controller for the Ethernet Controller | EDMAC |
elc.hpp | Event Link Controller | ELC |
eptpc.hpp | PTP Module for the Ethernet Controller | EPTPC |
esc.hpp | EtherCAT Slave Controller | ESC |
etherc.hpp | Ethernet Controller | ETHERC |
exdmac.hpp | EXDMA Controller | EXDMAC |
flash.hpp | Flash Memory | FLASH |
glcdc.hpp | Graphic LCD Controller | GLCDC |
gpt.hpp | General PWM Timer | GPT |
gptw.hpp | General PWM Timer W | GPTW |
hrpwm.hpp | High Resolution PWM Waveform Generation Circuit | HRPWM |
iwdt.hpp | Independent Watchdog Timer | IWDT |
lcdc.hpp | LCD Controller / Driver | LCDC |
lpt.hpp | Low-Power Timer | LPT |
lvda.hpp | Voltage Detection Circuit | LVDA |
mmcif.hpp | MultiMediaCard Interface | MMCIF |
mpu.hpp | Memory-Protection Unit | MPU |
mtu3.hpp | Multi-Function Timer Pulse Unit 3 | MTU3 |
pdc.hpp | Parallel Data Capture Unit | PDC |
pmgi.hpp | PHY Management Interface | PMGI |
poe3d.hpp | Port Output Enable 3 | POE3 |
poeg.hpp | Port Output Enable for GPTW | POEG |
ppg.hpp | Programmable Pulse Generator | PPG |
qspi.hpp | Quad Serial Peripheral Interface | QSPI |
qspix.hpp | Quad-SPI Memory Interface | QSPIX |
r12da.hpp | 12-Bit D/A Converter | R12DA |
remc.hpp | Remote Control Signal Receiver | REMC |
ri3c.hpp | I3C-bus Interface | RI3C |
riic.hpp | I2C-bus Interface | RIIC |
riichs.hpp | High-speed I2C-bus Interface | RIICHS |
rscan.hpp | RSCAN Module | RSCAN |
rsci.hpp | Serial Communications Interface | RSCI |
rspi.hpp | Serial Peripheral Interface | RSPI |
rspia.hpp | Serial Peripheral Interface A | RSPIA |
rtc.hpp | Realtime Clock | RTC |
s12adf.hpp | 12-Bit A/D Converter | S12ADC |
sci_a.hpp | Serial Communications Interface a | SCIa |
sci_c.hpp | Serial Communications Interface c | SCIc |
sci_d.hpp | Serial Communications Interface d | SCId |
sci_e.hpp | Serial Communications Interface e | SCIe |
sci_f.hpp | Serial Communications Interface f | SCIf |
sci_g.hpp | Serial Communications Interface g | SCIg |
sci_h.hpp | Serial Communications Interface h | SCIh |
sci_i.hpp | Serial Communications Interface i | SCIi |
sci_j.hpp | Serial Communications Interface j | SCIj |
sci_k.hpp | Serial Communications Interface k | SCIk |
sci_m.hpp | Serial Communications Interface m | SCIm |
scif.hpp | Serial Communications Interface with FIFO | SCIF |
sdhi.hpp | SD Host interface | SDHI |
sdsi.hpp | SD Slave interface | SDSI |
src.hpp | Sampling Rate Converter | SRC |
ssi.hpp | Serial Sound Interface | SSI |
ssie.hpp | Extension Serial Sound Interface | SSIE |
system.hpp | Clock Generation Circuit/etc. | SYSTEM |
tfu.hpp | Trigonometrical function calculator | TFU |
tmr.hpp | 8-Bit Timer | TMR |
tpu.hpp | 16-Bit Timer plus unit | TPU |
usb.hpp | USB 2.0 FS Host/Function Module | USB |
usba.hpp | USB 2.0 Full-Speed Host/Function Module | USBA |
vbatt.hpp | Battery Backup Function | VBATT |
wdta.hpp | Watchdog Timer | WDT |
File | Functions |
---|---|
ad_utils.hpp | A/D Conversion Utility |
adc_in.hpp | A/D Input |
adc_in_base.hpp | A/D A/D Conversion Base |
bus_mgr.hpp | Bus Manager |
can_frame.hpp | CAN frame definition |
canfd_frame.hpp | CAN FD frame definition |
dac_out.hpp | D/A Output |
dmac_mgr.hpp | DMAC Manager |
drw2d_mgr.hpp | DRW2D Manager |
ether_io.hpp | イーサーネット入出力 |
flash_io.hpp | Flash memory input/output |
flash_io_base.hpp | Flash memory input/output base |
glcdc_def.hpp | GLCDC basic definition |
glcdc_mgr.hpp | GLCDC Manager |
icu_base.hpp | 割り込み制御ベース |
icu_utils.hpp | 割り込み制御ユーティリティ |
mtu_base.hpp | MTU base |
port_base.hpp | PORT base |
port_map_irq.hpp | IRQ port map |
port_map_order.hpp | port map order |
rtc_io.hpp | RTC Input/Output |
sci_base.hpp | SCI base |
sdram.hpp | SDRAM Setting |
ssi_io.hpp | SSI Input/Output |
ssie_io.hpp | SSIE Input/Output |
standby_ram.hpp | Standby RAM Controle |
system_io.hpp | クロック制御など |
Special thanks:
Translated with DeepL.com (free version)
License
MIT