Skip to content

Commit

Permalink
Merge pull request #757 from kkitayam/add_support_for_gr_citrus
Browse files Browse the repository at this point in the history
Add support for GR-CITRUS
  • Loading branch information
hathach authored Mar 31, 2021
2 parents c5dfc54 + 1d8a79e commit 2f5dda9
Show file tree
Hide file tree
Showing 17 changed files with 1,354 additions and 4 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,73 @@ jobs:
asset_name: ${{ matrix.family }}-tinyusb-${{ github.event.release.tag_name }}-examples.zip
asset_content_type: application/zip

# ---------------------------------------
# Build Renesas family
# ---------------------------------------
build-renesas:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
family:
# Alphabetical order
- 'rx63n'
steps:
- name: Setup Python
uses: actions/setup-python@v2

- name: Checkout TinyUSB
uses: actions/checkout@v2

- name: Checkout common submodules in lib
run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip

- name: Set Toolchain URL
run: echo >> $GITHUB_ENV TOOLCHAIN_URL=http://gcc-renesas.com/downloads/get.php?f=rx/8.3.0.202004-gnurx/gcc-8.3.0.202004-GNURX-ELF.run

- name: Cache Toolchain
uses: actions/cache@v2
id: cache-toolchain
with:
path: ~/cache/
key: ${{ runner.os }}-21-03-30-${{ env.TOOLCHAIN_URL }}

- name: Install Toolchain
if: steps.cache-toolchain.outputs.cache-hit != 'true'
run: |
mkdir -p ~/cache/toolchain/gnurx
wget --progress=dot:mega $TOOLCHAIN_URL -O toolchain.run
chmod +x toolchain.run
./toolchain.run -p ~/cache/toolchain/gnurx -y
- name: Set Toolchain Path
run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin`

- name: Build
run: python3 tools/build_family.py ${{ matrix.family }}

- uses: actions/upload-artifact@v2
with:
name: ${{ matrix.family }}-tinyusb-examples
path: _bin/

- name: Create Release Asset
if: ${{ github.event_name == 'release' }}
run: |
cd _bin/
zip -r ../${{ matrix.family }}-tinyusb-${{ github.event.release.tag_name }}-examples.zip *
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ github.event_name == 'release' }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ matrix.family }}-tinyusb-${{ github.event.release.tag_name }}-examples.zip
asset_name: ${{ matrix.family }}-tinyusb-${{ github.event.release.tag_name }}-examples.zip
asset_content_type: application/zip

# ---------------------------------------
# Build all no-family (opharned) boards
# ---------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,6 @@
[submodule "hw/mcu/silabs/cmsis-dfp-efm32gg12b"]
path = hw/mcu/silabs/cmsis-dfp-efm32gg12b
url = https://github.com/cmsis-packs/cmsis-dfp-efm32gg12b
[submodule "hw/mcu/renesas/rx"]
path = hw/mcu/renesas/rx
url = https://github.com/kkitayam/rx_device.git
12 changes: 12 additions & 0 deletions examples/device/cdc_msc_freertos/src/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ extern uint32_t SystemCoreClock;
#define configASSERT( x )
#endif

#ifdef __RX__
/* Renesas RX series */
#define vSoftwareInterruptISR INT_Excep_ICU_SWINT
#define vTickISR INT_Excep_CMT0_CMI0
#define configPERIPHERAL_CLOCK_HZ (configCPU_CLOCK_HZ/2)
#define configKERNEL_INTERRUPT_PRIORITY 1
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 4

#else

/* FreeRTOS hooks to NVIC vectors */
#define xPortPendSVHandler PendSV_Handler
#define xPortSysTickHandler SysTick_Handler
Expand Down Expand Up @@ -164,4 +174,6 @@ to all Cortex-M ports, and do not rely on any particular library functions. */
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )

#endif

#endif /* __FREERTOS_CONFIG__H */
19 changes: 19 additions & 0 deletions examples/device/cdc_msc_freertos/src/freertos_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,22 @@ void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, Stack
configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
}

#if CFG_TUSB_MCU == OPT_MCU_RX63X
#include "iodefine.h"
void vApplicationSetupTimerInterrupt(void)
{
/* Enable CMT0 */
SYSTEM.PRCR.WORD = (0xA5u<<8) | TU_BIT(1);
MSTP(CMT0) = 0;
SYSTEM.PRCR.WORD = (0xA5u<<8);

CMT0.CMCNT = 0;
CMT0.CMCOR = (unsigned short)(((configPERIPHERAL_CLOCK_HZ/configTICK_RATE_HZ)-1)/128);
CMT0.CMCR.WORD = TU_BIT(6) | 2;
IR(CMT0, CMI0) = 0;
IPR(CMT0, CMI0) = configKERNEL_INTERRUPT_PRIORITY;
IEN(CMT0, CMI0) = 1;
CMT.CMSTR0.BIT.STR0 = 1;
}
#endif
4 changes: 2 additions & 2 deletions examples/device/cdc_msc_freertos/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ int main(void)
// skip starting scheduler (and return) for ESP32-S2
#if CFG_TUSB_MCU != OPT_MCU_ESP32S2
vTaskStartScheduler();
NVIC_SystemReset();
return 0;
#endif

return 0;
}

#if CFG_TUSB_MCU == OPT_MCU_ESP32S2
Expand Down
12 changes: 12 additions & 0 deletions examples/device/hid_composite_freertos/src/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ extern uint32_t SystemCoreClock;
#define configASSERT( x )
#endif

#ifdef __RX__
/* Renesas RX series */
#define vSoftwareInterruptISR INT_Excep_ICU_SWINT
#define vTickISR INT_Excep_CMT0_CMI0
#define configPERIPHERAL_CLOCK_HZ (configCPU_CLOCK_HZ/2)
#define configKERNEL_INTERRUPT_PRIORITY 1
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 4

#else

/* FreeRTOS hooks to NVIC vectors */
#define xPortPendSVHandler PendSV_Handler
#define xPortSysTickHandler SysTick_Handler
Expand Down Expand Up @@ -164,4 +174,6 @@ to all Cortex-M ports, and do not rely on any particular library functions. */
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )

#endif

#endif /* __FREERTOS_CONFIG__H */
19 changes: 19 additions & 0 deletions examples/device/hid_composite_freertos/src/freertos_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,22 @@ void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, Stack
configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
}

#if CFG_TUSB_MCU == OPT_MCU_RX63X
#include "iodefine.h"
void vApplicationSetupTimerInterrupt(void)
{
/* Enable CMT0 */
SYSTEM.PRCR.WORD = (0xA5u<<8) | TU_BIT(1);
MSTP(CMT0) = 0;
SYSTEM.PRCR.WORD = (0xA5u<<8);

CMT0.CMCNT = 0;
CMT0.CMCOR = (unsigned short)(((configPERIPHERAL_CLOCK_HZ/configTICK_RATE_HZ)-1)/128);
CMT0.CMCR.WORD = TU_BIT(6) | 2;
IR(CMT0, CMI0) = 0;
IPR(CMT0, CMI0) = configKERNEL_INTERRUPT_PRIORITY;
IEN(CMT0, CMI0) = 1;
CMT.CMSTR0.BIT.STR0 = 1;
}
#endif
4 changes: 2 additions & 2 deletions examples/device/hid_composite_freertos/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ int main(void)
// skip starting scheduler (and return) for ESP32-S2
#if CFG_TUSB_MCU != OPT_MCU_ESP32S2
vTaskStartScheduler();
NVIC_SystemReset();
return 0;
#endif

return 0;
}

#if CFG_TUSB_MCU == OPT_MCU_ESP32S2
Expand Down
3 changes: 3 additions & 0 deletions hw/bsp/board_mcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
#elif CFG_TUSB_MCU == OPT_MCU_EFM32GG || CFG_TUSB_MCU == OPT_MCU_EFM32GG11 || CFG_TUSB_MCU == OPT_MCU_EFM32GG12
#include "em_device.h"

#elif CFG_TUSB_MCU == OPT_MCU_RX63X
// no header needed

#else
#error "Missing MCU header"
#endif
Expand Down
61 changes: 61 additions & 0 deletions hw/bsp/rx63n/boards/gr_citrus/board.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
DEPS_SUBMODULES += hw/mcu/renesas/rx

CFLAGS += \
-nostartfiles \
-ffunction-sections \
-fdata-sections \
-fshort-enums \
-mcpu=rx610 \
-misa=v1 \
-mlittle-endian-data \
-DCFG_TUSB_MCU=OPT_MCU_RX63X

# Cross Compiler for RX
CROSS_COMPILE = rx-elf-

RX_NEWLIB ?= 1

ifeq ($(CMDEXE),1)
OPTLIBINC="$(shell for /F "usebackq delims=" %%i in (`where rx-elf-gcc`) do echo %%~dpi..\rx-elf\optlibinc)"
else
OPTLIBINC=$(shell dirname `which rx-elf-gcc`)../rx-elf/optlibinc
endif

ifeq ($(RX_NEWLIB),1)
CFLAGS += -DSSIZE_MAX=__INT_MAX__
else
# setup for optlib
CFLAGS += -nostdinc \
-isystem $(OPTLIBINC) \
-DLWIP_NO_INTTYPES_H

LIBS += -loptc -loptm
endif

MCU_DIR = hw/mcu/renesas/rx/rx63n

# All source paths should be relative to the top level.
LD_FILE = $(BOARD_PATH)/r5f5631fd.ld

SRC_C += \
src/portable/renesas/usba/dcd_usba.c \
$(MCU_DIR)/vects.c

INC += \
$(TOP)/$(BOARD_PATH) \
$(TOP)/$(MCU_DIR)

SRC_S += $(MCU_DIR)/start.S

# For freeRTOS port source
FREERTOS_PORT = RX600

# For flash-jlink target
JLINK_DEVICE = R5F5631F
JLINK_IF = JTAG

# For flash-pyocd target
PYOCD_TARGET =

# flash using jlink
flash: flash-jlink
Loading

0 comments on commit 2f5dda9

Please sign in to comment.