Skip to content

Commit 232898f

Browse files
committed
ports/renesas-ra/boards/VK-RA6M3: New Board.
ports/renesas-ra/boards: New processor RA6M3. ports/renesas-ra: Integration to the existing RA family. Signed-off-by: mbedNoobNinja <[email protected]>
1 parent 05cb140 commit 232898f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+6125
-22
lines changed

ports/renesas-ra/Makefile

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ include $(BOARD_DIR)/mpconfigboard.mk
2525

2626
USE_FSP_LPM ?= 1
2727
USE_FSP_QSPI ?= 0
28+
USE_FSP_SDHI ?= 0
29+
USE_FSP_ETH ?= 0
30+
USE_FSP_LCD ?= 0
31+
USE_FSP_CAM ?= 0
2832
FSP_BOARD_NAME ?= $(shell echo $(BOARD) | tr '[:upper:]' '[:lower:]')
2933

3034
# Files that are generated and needed before the QSTR build.
@@ -73,7 +77,7 @@ INC += -I$(TOP)/lib/tinyusb/hw
7377
INC += -I$(TOP)/lib/tinyusb/src
7478
INC += -I$(TOP)/shared/tinyusb
7579
INC += -Ilwip_inc
76-
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),RA4M1 RA4W1 RA6M1 RA6M2 RA6M5))
80+
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),RA4M1 RA4W1 RA6M1 RA6M2 RA6M3 RA6M5))
7781
INC += -Ira
7882
endif
7983
INC += -I$(BOARD_DIR)/ra_gen
@@ -108,6 +112,7 @@ CFLAGS_MCU_RA4M1 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4
108112
CFLAGS_MCU_RA4W1 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4
109113
CFLAGS_MCU_RA6M1 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4
110114
CFLAGS_MCU_RA6M2 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4
115+
CFLAGS_MCU_RA6M3 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4
111116
CFLAGS_MCU_RA6M5 = $(CFLAGS_CORTEX_M) -mtune=cortex-m33 -mcpu=cortex-m33
112117

113118
ASFLAGS += $(CFLAGS_CORTEX_M) -mcpu=cortex-$(MCU_SERIES)
@@ -327,7 +332,11 @@ SRC_C += \
327332
machine_pin.c \
328333
machine_rtc.c \
329334
machine_sdcard.c \
335+
machine_lcd.c \
336+
machine_cam.c \
330337
modmachine.c \
338+
network_lan.c \
339+
eth.c \
331340
extint.c \
332341
usrsw.c \
333342
flash.c \
@@ -396,6 +405,26 @@ HAL_SRC_C += $(HAL_DIR)/ra/fsp/src/r_sdhi/r_sdhi.c \
396405
$(HAL_DIR)/ra/fsp/src/r_dtc/r_dtc.c
397406
endif
398407

408+
ifeq ($(USE_FSP_ETH), 1)
409+
CFLAGS += -DUSE_FSP_ETH
410+
HAL_SRC_C += $(HAL_DIR)/ra/fsp/src/r_ether_phy/targets/ICS1894/r_ether_phy_target_ics1894.c \
411+
$(HAL_DIR)/ra/fsp/src/r_ether_phy/r_ether_phy.c \
412+
$(HAL_DIR)/ra/fsp/src/r_ether/r_ether.c
413+
endif
414+
415+
ifeq ($(USE_FSP_LCD), 1)
416+
CFLAGS += -DUSE_FSP_LCD
417+
HAL_SRC_C += $(HAL_DIR)/ra/fsp/src/r_glcdc/r_glcdc.c \
418+
$(HAL_DIR)/ra/fsp/src/r_sci_i2c/r_sci_i2c.c \
419+
$(HAL_DIR)/ra/fsp/src/r_icu/r_icu.c
420+
endif
421+
422+
ifeq ($(USE_FSP_CAM), 1)
423+
CFLAGS += -DUSE_FSP_CAM
424+
HAL_SRC_C += $(HAL_DIR)/ra/fsp/src/r_pdc/r_pdc.c \
425+
$(HAL_DIR)/ra/fsp/src/r_jpeg/r_jpeg.c
426+
endif
427+
399428
ifeq ($(USE_FSP_LPM), 1)
400429
CFLAGS += -DUSE_FSP_LPM
401430
HAL_SRC_C += $(HAL_DIR)/ra/fsp/src/r_lpm/r_lpm.c
@@ -408,14 +437,14 @@ HAL_SRC_C += $(HAL_DIR)/ra/fsp/src/r_flash_lp/r_flash_lp.c
408437
endif
409438
endif
410439

411-
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),RA6M1 RA6M2 RA6M5))
440+
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),RA6M1 RA6M2 RA6M3 RA6M5))
412441
ifeq ($(USE_FSP_FLASH), 1)
413442
CFLAGS += -DUSE_FSP_FLASH
414443
HAL_SRC_C += $(HAL_DIR)/ra/fsp/src/r_flash_hp/r_flash_hp.c
415444
endif
416445
endif
417446

418-
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),RA4M1 RA4W1 RA6M1 RA6M2 RA6M5))
447+
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),RA4M1 RA4W1 RA6M1 RA6M2 RA6M3 RA6M5))
419448
HAL_SRC_C += $(addprefix ra/,\
420449
ra_adc.c \
421450
ra_dac.c \
@@ -432,10 +461,43 @@ HAL_SRC_C += $(addprefix ra/,\
432461
ra_gpt.c \
433462
ra_utils.c \
434463
)
464+
endif
435465

466+
ifeq ($(MICROPY_SSL_MBEDTLS),1)
467+
LIB_SRC_C += mbedtls/mbedtls_port.c
436468
endif
437469

438470
ifeq ($(MICROPY_HW_ENABLE_RNG),1)
471+
ifeq ($(CMSIS_MCU),RA6M3)
472+
CRYPTO_DIR = ra/fsp/src/r_sce/crypto_procedures/src/sce7/plainkey/
473+
474+
INC += -I$(TOP)/$(HAL_DIR)/$(CRYPTO_DIR)/private/inc
475+
INC += -I$(TOP)/$(HAL_DIR)/$(CRYPTO_DIR)/public/inc
476+
INC += -I$(TOP)/$(HAL_DIR)/$(CRYPTO_DIR)/primitive
477+
INC += -I$(TOP)/$(HAL_DIR)/ra/fsp/src/r_sce/common
478+
INC += -I$(TOP)/$(HAL_DIR)/ra/fsp/src/r_sce
479+
480+
# The following FSP files are required for the random number generator.
481+
HAL_SRC_C += $(addprefix $(HAL_DIR)/$(CRYPTO_DIR)/,\
482+
adaptors/r_sce_adapt.c \
483+
primitive/hw_sce_p_p00.c \
484+
primitive/hw_sce_p_p01.c \
485+
primitive/hw_sce_p_p02.c \
486+
primitive/hw_sce_p_p20.c \
487+
primitive/hw_sce_p_func050.c \
488+
primitive/hw_sce_p_func051.c \
489+
primitive/hw_sce_p_func052.c \
490+
primitive/hw_sce_p_func053.c \
491+
primitive/hw_sce_p_func054.c \
492+
primitive/hw_sce_p_func100.c \
493+
primitive/hw_sce_p_func101.c \
494+
primitive/hw_sce_p_func102.c \
495+
primitive/hw_sce_p_func103.c \
496+
primitive/hw_sce_p_subprc01.c \
497+
primitive/hw_sce_p_subprc02.c \
498+
)
499+
endif
500+
ifeq ($(CMSIS_MCU),RA6M5)
439501
CRYPTO_DIR = ra/fsp/src/r_sce_protected/crypto_procedures_protected/src/sce9/
440502

441503
INC += -I$(TOP)/$(HAL_DIR)/$(CRYPTO_DIR)/inc
@@ -471,6 +533,7 @@ HAL_SRC_C += $(addprefix $(HAL_DIR)/$(CRYPTO_DIR)/,\
471533
primitive/r_sce_subprc01.c\
472534
)
473535
endif
536+
endif
474537

475538
OBJ += $(PY_O)
476539
OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
@@ -554,6 +617,9 @@ endif
554617
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),RA6M2))
555618
AF_FILE = boards/ra6m2_af.csv
556619
endif
620+
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),RA6M3))
621+
AF_FILE = boards/ra6m3_af.csv
622+
endif
557623
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),RA6M5))
558624
AF_FILE = boards/ra6m5_af.csv
559625
endif

ports/renesas-ra/RA6M3_hal.h

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2021 Renesas Electronics Corporation
5+
* Copyright (c) 2023 Vekatech Ltd.
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
26+
#ifndef PORTS_RA_RA6M3_HAL_H_
27+
#define PORTS_RA_RA6M3_HAL_H_
28+
29+
#include <stdio.h>
30+
#include <stdint.h>
31+
#include <stdbool.h>
32+
// #include "hal_data.h"
33+
#include "bsp_api.h"
34+
#include "common_data.h"
35+
#if defined(USE_DBG_PRINT)
36+
#include RA_CFG_H
37+
#endif
38+
39+
#define SCI_CH DEFAULT_DBG_CH
40+
#define SCI_BAUD 115200
41+
#define UART_CH SCI_CH
42+
#define UART_TxStr sci_tx_str
43+
#define PCLK 120000000
44+
45+
#define RA_PRI_SYSTICK (0)
46+
#define RA_PRI_UART (1)
47+
#define RA_PRI_SDIO (4)
48+
#define RA_PRI_DMA (5)
49+
#define RA_PRI_FLASH (6)
50+
#define RA_PRI_OTG_FS (6)
51+
#define RA_PRI_OTG_HS (6)
52+
#define RA_PRI_TIM5 (6)
53+
#define RA_PRI_CAN (7)
54+
#define RA_PRI_SPI (8)
55+
#define RA_PRI_I2C (8)
56+
#define RA_PRI_TIMX (13)
57+
#define RA_PRI_EXTINT (14)
58+
#define RA_PRI_PENDSV (15)
59+
#define RA_PRI_RTC_WKUP (15)
60+
61+
#include "ra_config.h"
62+
#include "ra_adc.h"
63+
#include "ra_dac.h"
64+
#include "ra_flash.h"
65+
#include "ra_gpio.h"
66+
#include "ra_gpt.h"
67+
#include "ra_i2c.h"
68+
#include "ra_icu.h"
69+
#include "ra_init.h"
70+
#include "ra_int.h"
71+
#include "ra_rtc.h"
72+
#include "ra_sci.h"
73+
#include "ra_spi.h"
74+
#include "ra_timer.h"
75+
#include "ra_utils.h"
76+
77+
typedef enum {
78+
HAL_OK = 0x00,
79+
HAL_ERROR = 0x01,
80+
HAL_BUSY = 0x02,
81+
HAL_TIMEOUT = 0x03
82+
} HAL_StatusTypeDef;
83+
84+
#define __IO volatile
85+
86+
#if defined(USE_DBG_PRINT)
87+
#if !defined(DEBUG_CH)
88+
#define DEBUG_CH SCI_CH
89+
#endif
90+
#if (DEBUG_CH == 7)
91+
#define DEBUG_TX_PIN P613
92+
#define DEBUG_RX_PIN P614
93+
#endif
94+
#if (DEBUG_CH == 8)
95+
#define DEBUG_TX_PIN P105
96+
#define DEBUG_RX_PIN P104
97+
#endif
98+
#if (DEBUG_CH == 9)
99+
#define DEBUG_TX_PIN P109
100+
#define DEBUG_RX_PIN P110
101+
#endif
102+
#define DEBUG_TXSTR(s) ra_sci_tx_str(DEBUG_CH, (unsigned char *)s)
103+
#define DEBUG_TXCH(c) ra_sci_tx_ch(DEBUG_CH, c)
104+
#else
105+
#define DEBUG_TXSTR(s)
106+
#define DEBUG_TXCH(c)
107+
#endif
108+
109+
#endif /* PORTS_RA_RA6M3_HAL_H_ */
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
In case you need to debug something in `VK_RA6M3` board, make sure the contents of
2+
[project repo](https://github.com/Vekatech/VK_RA6M3) is cloned in to **this** directory.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"deploy": [
3+
"../deploy.md"
4+
],
5+
"docs": "https://vekatech.com/VK-RA6M3_docs/brochures/VK-RA6M3%20Flyer%20R2.pdf",
6+
"features": [
7+
"DAC",
8+
"USB",
9+
"microSD",
10+
"Ethernet",
11+
"Camera",
12+
"Display",
13+
"External Flash"
14+
],
15+
"images": [
16+
"VK-RA6M3.jpg"
17+
],
18+
"mcu": "ra6m3",
19+
"product": "VK-RA6M3",
20+
"thumbnail": "",
21+
"url": "https://vekatech.com",
22+
"vendor": "Vekatech"
23+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include("$(PORT_DIR)/boards/manifest.py")
2+
# Networking
3+
require("bundle-networking")
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// MCU config
2+
#define MICROPY_HW_BOARD_NAME "VK-RA6M3"
3+
#define MICROPY_HW_MCU_NAME "RA6M3"
4+
#define MICROPY_HW_MCU_SYSCLK 120000000
5+
#define MICROPY_HW_MCU_PCLK 120000000
6+
7+
// module config
8+
#define MICROPY_EMIT_THUMB (1)
9+
#define MICROPY_EMIT_INLINE_THUMB (1)
10+
#define MICROPY_PY_BUILTINS_COMPLEX (1)
11+
#define MICROPY_PY_GENERATOR_PEND_THROW (1)
12+
#define MICROPY_PY_MATH (1)
13+
#define MICROPY_PY_HEAPQ (1)
14+
#define MICROPY_PY_THREAD (0) // disable ARM_THUMB_FP using vldr due to RA has single float only
15+
#define MICROPY_HW_ETH_MDC (1)
16+
#define MICROPY_PY_NETWORK (1)
17+
#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT MICROPY_HW_BOARD_NAME
18+
19+
#define MODULE_LCD_ENABLED (1)
20+
#define MODULE_CAM_ENABLED (1)
21+
22+
// peripheral config
23+
#define MICROPY_HW_ENABLE_RNG (1)
24+
#define MICROPY_HW_ENABLE_RTC (1)
25+
#define MICROPY_HW_RTC_SOURCE (1) // 0: subclock
26+
#define MICROPY_HW_ENABLE_ADC (1)
27+
#define MICROPY_HW_HAS_FLASH (1)
28+
#define MICROPY_HW_ENABLE_USBDEV (1)
29+
#define MICROPY_HW_ENABLE_UART_REPL (1)
30+
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (1)
31+
#define MICROPY_HW_HAS_QSPI_FLASH (1)
32+
#define MICROPY_HW_HAS_SDHI_CARD (1)
33+
34+
// board config
35+
36+
// UART
37+
#define MICROPY_HW_UART7_TX (pin_P613) // D1
38+
#define MICROPY_HW_UART7_RX (pin_P614) // D0
39+
#define MICROPY_HW_UART8_TX (pin_P105) // Modbus (RS485)
40+
#define MICROPY_HW_UART8_RX (pin_P104) // Modbus (RS485)
41+
#define MICROPY_HW_UART9_TX (pin_P109) // REPL
42+
#define MICROPY_HW_UART9_RX (pin_P110) // REPL
43+
#define MICROPY_HW_UART_REPL HW_UART_9
44+
#define MICROPY_HW_UART_REPL_BAUD 115200
45+
46+
// I2C
47+
#define MICROPY_HW_I2C1_SCL (pin_P205)
48+
#define MICROPY_HW_I2C1_SDA (pin_P206)
49+
50+
// SPI
51+
#define MICROPY_HW_SPI1_SSL (pin_P301) // D10
52+
#define MICROPY_HW_SPI1_RSPCK (pin_P204) // D13
53+
#define MICROPY_HW_SPI1_MISO (pin_P202) // D12
54+
#define MICROPY_HW_SPI1_MOSI (pin_P203) // D11
55+
56+
// PWM
57+
// #define MICROPY_HW_PWM_8A (pin_P107) // D7
58+
#define MICROPY_HW_PWM_8A (pin_P605) // LED_B
59+
#define MICROPY_HW_PWM_2A (pin_P113) // D4
60+
#define MICROPY_HW_PWM_2B (pin_P114) // D5
61+
#define MICROPY_HW_PWM_4A (pin_P115) // D6
62+
// #define MICROPY_HW_PWM_4A (pin_P302) // D9
63+
#define MICROPY_HW_PWM_5B (pin_P202) // D12
64+
#define MICROPY_HW_PWM_5A (pin_P203) // D11
65+
// #define MICROPY_HW_PWM_4B (pin_P204) // D13
66+
// #define MICROPY_HW_PWM_4B (pin_P301) // D10
67+
#define MICROPY_HW_PWM_4B (pin_P608) // LED_Y
68+
#define MICROPY_HW_PWM_7B (pin_P303) // D8
69+
// #define MICROPY_HW_PWM_7B (pin_P602) // PN4_3
70+
// #define MICROPY_HW_PWM_7A (pin_P304) // PN4_8
71+
#define MICROPY_HW_PWM_7A (pin_P603) // LED_R
72+
#define MICROPY_HW_PWM_6B (pin_P600) // PN4_4
73+
#define MICROPY_HW_PWM_6A (pin_P601) // LED_G
74+
#define MICROPY_HW_PWM_8B (pin_P604) // PN4_2
75+
76+
// DAC
77+
#define MICROPY_HW_DAC0 (pin_P014) // A4
78+
#define MICROPY_HW_DAC1 (pin_P015) // A5
79+
80+
// Switch
81+
#define MICROPY_HW_HAS_SWITCH (1)
82+
#define MICROPY_HW_USRSW_PIN (pin_P008)
83+
// #define MICROPY_HW_USRSW_PIN (pin_P009)
84+
#define MICROPY_HW_USRSW_PULL (MP_HAL_PIN_PULL_NONE)
85+
#define MICROPY_HW_USRSW_EXTI_MODE (MP_HAL_PIN_TRIGGER_FALLING)
86+
#define MICROPY_HW_USRSW_PRESSED (0)
87+
88+
// LEDs
89+
#define MICROPY_HW_LED1 (pin_P603)
90+
#define MICROPY_HW_LED2 (pin_P601)
91+
#define MICROPY_HW_LED3 (pin_P605)
92+
#define MICROPY_HW_LED4 (pin_P608)
93+
#define MICROPY_HW_LED_ON(pin) mp_hal_pin_high(pin)
94+
#define MICROPY_HW_LED_OFF(pin) mp_hal_pin_low(pin)
95+
#define MICROPY_HW_LED_TOGGLE(pin) mp_hal_pin_toggle(pin)

0 commit comments

Comments
 (0)