initial commit

This commit is contained in:
shell committed 2026-10-11 21:48:59 +08:00
commit b44ce7bd77
2716 files changed
+559005

No files matched your search

@@ -0,0 +1,19 @@
set(MCU_VARIANT rx63n)
set(MCU_FAMILY RX63X)
set(CMAKE_SYSTEM_CPU rx610 CACHE INTERNAL "System Processor")
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/r5f5631fd.ld)
set(JLINK_DEVICE R5F5631F)
set(JLINK_IF JTAG)
set(BOARD_SOURCES
${CMAKE_CURRENT_LIST_DIR}/gr_citrus.c
)
function(update_board TARGET)
target_include_directories(${TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
)
endfunction()
+64
View File
@@ -0,0 +1,64 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2020, Ha Thach (tinyusb.org)
*
* 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.
*
* This file is part of the TinyUSB stack.
*/
/* metadata:
name: GR Citrus
url: https://www.renesas.com/en/products/gadget-renesas/boards/gr-citrus
*/
#ifndef BOARD_H_
#define BOARD_H_
#include "iodefine.h"
#ifdef __cplusplus
extern "C" {
#endif
// LED: PA0, active high
#define BOARD_LED_WRITE(state) (PORTA.PODR.BIT.B0 = (state) ? 1 : 0)
// No user button
#define BOARD_BUTTON_READ() 0
// UART: SCI0
#define BOARD_UART_SCI SCI0
#define BOARD_SCI_TXI_HANDLER INT_Excep_SCI0_TXI0
#define BOARD_SCI_TEI_HANDLER INT_Excep_SCI0_TEI0
#define BOARD_SCI_RXI_HANDLER INT_Excep_SCI0_RXI0
// USB interrupt handler
#define BOARD_USB_IRQ_HANDLER INT_Excep_USB0_USBI0
// Clocks
#define BOARD_PCLK 48000000
#define BOARD_CPUCLK 96000000
#ifdef __cplusplus
}
#endif
#endif /* BOARD_H_ */
+22
View File
@@ -0,0 +1,22 @@
CFLAGS += \
-mcpu=rx610 \
-misa=v1 \
-DCFG_TUSB_MCU=OPT_MCU_RX63X
MCU_DIR = hw/mcu/renesas/rx/rx63n
# All source paths should be relative to the top level.
LD_FILE = $(BOARD_PATH)/r5f5631fd.ld
# For freeRTOS port source
FREERTOS_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/RX600
# For flash-jlink target
JLINK_DEVICE = R5F5631F
JLINK_IF = JTAG
# For flash-pyocd target
PYOCD_TARGET =
# flash using jlink
flash: flash-jlink
@@ -0,0 +1,126 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2021, Koji Kitayama
*
* 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.
*
* This file is part of the TinyUSB stack.
*/
/* How to connect JLink and GR-CITRUS
*
* GR-CITRUS needs to solder some pads to enable JTAG interface.
* - Short the following pads individually with solder.
* - J4
* - J5
* - Short EMLE pad and 3.3V(GR-CITRUS pin name) with a wire.
*
* The pads are [the back side of GR-CITRUS](https://www.slideshare.net/MinaoYamamoto/grcitrusrx631/2).
*
* Connect the pins between GR-CITRUS and JLink as follows.
*
* | Function | GR-CITRUS pin | JLink pin No.| note |
* |:---------:|:-------------:|:------------:|:--------:|
* | VTref | 3.3V | 1 | |
* | TRST | 5 | 3 | |
* | GND | GND | 4 | |
* | TDI | 3 | 5 | |
* | TMS | 2 | 7 | |
* | TCK/FINEC | 14 | 9 | short J4 |
* | TDO | 9 | 13 | short J5 |
* | nRES | RST | 15 | |
*
* JLink firmware needs to update to V6.96 or newer version to avoid
* [a bug](https://forum.segger.com/index.php/Thread/7758-SOLVED-Bug-in-JLink-from-V6-88b-regarding-RX65N)
* regarding downloading.
*/
#include "iodefine.h"
#include "board.h"
#define SYSTEM_PRCR_PRC1 (1<<1)
#define SYSTEM_PRCR_PRKEY (0xA5u<<8)
#define MPC_PFS_ISEL (1<<6)
#define IRQ_PRIORITY_SCI0 5
#define SCI_PCLK 48000000
void HardwareSetup(void)
{
SYSTEM.PRCR.WORD = 0xA503u;
SYSTEM.SOSCCR.BYTE = 0x01u;
SYSTEM.MOSCWTCR.BYTE = 0x0Du;
SYSTEM.PLLWTCR.BYTE = 0x0Eu;
SYSTEM.PLLCR.WORD = 0x0F00u;
SYSTEM.MOSCCR.BYTE = 0x00u;
SYSTEM.PLLCR2.BYTE = 0x00u;
for (unsigned i = 0; i < 2075u; ++i) __asm("nop");
SYSTEM.SCKCR.LONG = 0x21021211u;
SYSTEM.SCKCR2.WORD = 0x0033u;
SYSTEM.SCKCR3.WORD = 0x0400u;
SYSTEM.SYSCR0.WORD = 0x5A01;
SYSTEM.MSTPCRB.BIT.MSTPB15 = 0;
SYSTEM.PRCR.WORD = 0xA500u;
}
void board_pin_init(void)
{
/* Unlock MPC registers */
MPC.PWPR.BIT.B0WI = 0;
MPC.PWPR.BIT.PFSWE = 1;
/* LED PA0 */
PORTA.PMR.BIT.B0 = 0U;
PORTA.PODR.BIT.B0 = 0U;
PORTA.PDR.BIT.B0 = 1U;
/* UART TXD0 => P20, RXD0 => P21 */
PORT2.PMR.BIT.B0 = 1U;
PORT2.PCR.BIT.B0 = 1U;
MPC.P20PFS.BYTE = 0b01010;
PORT2.PMR.BIT.B1 = 1U;
MPC.P21PFS.BYTE = 0b01010;
/* USB VBUS -> P16 DPUPE -> P14 */
PORT1.PMR.BIT.B4 = 1U;
PORT1.PMR.BIT.B6 = 1U;
MPC.P14PFS.BYTE = 0b10001;
MPC.P16PFS.BYTE = MPC_PFS_ISEL | 0b10001;
MPC.PFUSB0.BIT.PUPHZS = 1;
/* Lock MPC registers */
MPC.PWPR.BIT.PFSWE = 0;
MPC.PWPR.BIT.B0WI = 1;
/* Enable SCI0 */
SYSTEM.PRCR.WORD = SYSTEM_PRCR_PRKEY | SYSTEM_PRCR_PRC1;
MSTP(SCI0) = 0;
SYSTEM.PRCR.WORD = SYSTEM_PRCR_PRKEY;
SCI0.BRR = (SCI_PCLK / (32 * 115200)) - 1;
IR(SCI0, RXI0) = 0;
IR(SCI0, TXI0) = 0;
IR(SCI0, TEI0) = 0;
IPR(SCI0, RXI0) = IRQ_PRIORITY_SCI0;
IPR(SCI0, TXI0) = IRQ_PRIORITY_SCI0;
IPR(SCI0, TEI0) = IRQ_PRIORITY_SCI0;
IEN(SCI0, RXI0) = 1;
IEN(SCI0, TXI0) = 1;
IEN(SCI0, TEI0) = 1;
}
@@ -0,0 +1,127 @@
__USTACK_SIZE = 0x00000400;
__ISTACK_SIZE = 0x00000400;
MEMORY
{
RAM : ORIGIN = 0x4, LENGTH = 0x3fffc
ROM : ORIGIN = 0xFFE00000, LENGTH = 0x200000
}
SECTIONS
{
.fvectors 0xFFFFFF80: AT(0xFFFFFF80)
{
KEEP(*(.fvectors))
} > ROM
.text 0xFFE00000: AT(0xFFE00000)
{
*(.text)
*(.text.*)
*(P)
etext = .;
} > ROM
.rvectors ALIGN(4):
{
_rvectors_start = .;
KEEP(*(.rvectors))
_rvectors_end = .;
} > ROM
.init :
{
KEEP(*(.init))
__preinit_array_start = .;
KEEP(*(.preinit_array))
__preinit_array_end = .;
__init_array_start = (. + 3) & ~ 3;
KEEP(*(.init_array))
KEEP(*(SORT(.init_array.*)))
__init_array_end = .;
__fini_array_start = .;
KEEP(*(.fini_array))
KEEP(*(SORT(.fini_array.*)))
__fini_array_end = .;
} > ROM
.fini :
{
KEEP(*(.fini))
} > ROM
.got :
{
*(.got)
*(.got.plt)
} > ROM
.rodata :
{
*(.rodata)
*(.rodata.*)
*(C_1)
*(C_2)
*(C)
_erodata = .;
} > ROM
.eh_frame_hdr :
{
*(.eh_frame_hdr)
} > ROM
.eh_frame :
{
*(.eh_frame)
} > ROM
.jcr :
{
*(.jcr)
} > ROM
.tors :
{
__CTOR_LIST__ = .;
. = ALIGN(2);
___ctors = .;
*(.ctors)
___ctors_end = .;
__CTOR_END__ = .;
__DTOR_LIST__ = .;
___dtors = .;
*(.dtors)
___dtors_end = .;
__DTOR_END__ = .;
. = ALIGN(2);
_mdata = .;
} > ROM
.data : AT(_mdata)
{
_data = .;
*(.data)
*(.data.*)
*(D)
*(D_1)
*(D_2)
_edata = .;
} > RAM
.gcc_exc :
{
*(.gcc_exc)
} > RAM
.bss :
{
_bss = .;
*(.bss)
*(.bss.**)
*(COMMON)
*(B)
*(B_1)
*(B_2)
_ebss = .;
_end = .;
} > RAM
.ustack :
{
. = ALIGN(8);
. = . + __USTACK_SIZE;
PROVIDE(_ustack = .);
} > RAM
.istack :
{
. = ALIGN(8);
. = . + __ISTACK_SIZE;
PROVIDE(_istack = .);
} > RAM
}