Skip to content

Add RMC-RA4M1(rev.2.0) #421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
49 changes: 49 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,52 @@ muxto.upload.maximum_size=262144
muxto.upload.maximum_data_size=32768

##############################################################

rmc_ra4m1_20.name=Arduino RMC-RA4M1(rev.2.0)
rmc_ra4m1_20.build.core=arduino
rmc_ra4m1_20.build.crossprefix=arm-none-eabi-
rmc_ra4m1_20.build.compiler_path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/

rmc_ra4m1_20.build.variant=rmc_ra4m1_20
rmc_ra4m1_20.build.mcu=cortex-m4
rmc_ra4m1_20.build.architecture=cortex-m4
rmc_ra4m1_20.build.fpu=-mfpu=fpv4-sp-d16
rmc_ra4m1_20.build.float-abi=-mfloat-abi=hard

rmc_ra4m1_20.build.board=rmc_ra4m1_20
rmc_ra4m1_20.build.defines=-DF_CPU=48000000 -DARDUINO_UNOR4_MINIMA
rmc_ra4m1_20.vid.0=0x2341
rmc_ra4m1_20.pid.0=0x0069
rmc_ra4m1_20.vid.1=0x2341
rmc_ra4m1_20.pid.1=0x0369
rmc_ra4m1_20.upload_port.0.vid=0x2341
rmc_ra4m1_20.upload_port.0.pid=0x0069
rmc_ra4m1_20.upload_port.1.vid=0x2341
rmc_ra4m1_20.upload_port.1.pid=0x0369

rmc_ra4m1_20.compiler.fsp.defines={build.variant.path}/defines.txt
rmc_ra4m1_20.compiler.fsp.ldflags={build.variant.path}/ldflags.txt
rmc_ra4m1_20.compiler.fsp.cflags=-mthumb "@{compiler.fsp.defines}"
rmc_ra4m1_20.compiler.fsp.cxxflags=-mthumb "@{compiler.fsp.defines}"
rmc_ra4m1_20.compiler.tinyusb.cflags=-DCFG_TUSB_MCU=OPT_MCU_RAXXX
rmc_ra4m1_20.compiler.tinyusb.cxxflags=-DCFG_TUSB_MCU=OPT_MCU_RAXXX
rmc_ra4m1_20.compiler.fsp.includes={build.variant.path}/includes.txt
rmc_ra4m1_20.compiler.fsp.extra_ldflags=--specs=nano.specs -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
rmc_ra4m1_20.compiler.fsp="{build.variant.path}/libs/libfsp.a"

rmc_ra4m1_20.upload.tool=dfu-util
rmc_ra4m1_20.upload.tool.default=dfu-util
rmc_ra4m1_20.upload.protocol=
rmc_ra4m1_20.upload.transport=
rmc_ra4m1_20.upload.vid=0x2341
rmc_ra4m1_20.upload.pid=0x0369
rmc_ra4m1_20.upload.address=0x00010000
rmc_ra4m1_20.upload.interface=0
rmc_ra4m1_20.upload.use_1200bps_touch=false
rmc_ra4m1_20.upload.wait_for_upload_port=false
rmc_ra4m1_20.upload.native_usb=true
rmc_ra4m1_20.upload.maximum_size=262144
rmc_ra4m1_20.upload.maximum_data_size=32768

##############################################################

4 changes: 4 additions & 0 deletions cores/arduino/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ float analogReference();
#define IOPORT_PRV_PORT_OFFSET (8U)
#define BSP_IO_PRV_8BIT_MASK (0xFF)

#ifndef SDCARD_SPI
#define SDCARD_SPI SPI
#endif

#include "pins_arduino.h"
#include "usb/USB.h"

Expand Down
50 changes: 8 additions & 42 deletions cores/arduino/FspTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ bool FspTimer::force_pwm_reserved = false;
TimerAvail_t FspTimer::gpt_used_channel[GPT_HOWMANY] = { TIMER_FREE };
TimerAvail_t FspTimer::agt_used_channel[AGT_HOWMANY] = { TIMER_FREE };

FspTimer::FspTimer(): init_ok(false), agt_timer(nullptr), gpt_timer(nullptr), type(GPT_TIMER), _period_buffer(true) {
FspTimer::FspTimer(): init_ok(false), agt_timer(nullptr), gpt_timer(nullptr), type(GPT_TIMER) {
// AGT0 is always used for timekeeping (millis() and micros())
// agt_used_channel[0] = TIMER_USED;
timer_cfg.cycle_end_irq = FSP_INVALID_VECTOR;
Expand Down Expand Up @@ -380,11 +380,13 @@ bool FspTimer::set_pulse_ms(double ms,TimerPWMChannel_t pwm_ch) {
freq_hz = R_FSP_SystemClockHzGet(FSP_PRIV_CLOCK_PCLKB) >> timer_cfg.source_div;
}

uint32_t pulse_counts_ms = (uint32_t) ((uint64_t) (freq_hz * ms)/1000);
uint32_t pulse_counts_ms = (uint32_t) ((uint64_t) freq_hz/1000 * ms);
if(!set_duty_cycle(pulse_counts_ms, pwm_ch)) {
return false;
}
return true;

return true;

}

/* -------------------------------------------------------------------------- */
Expand All @@ -397,11 +399,12 @@ bool FspTimer::set_pulse_us(double us,TimerPWMChannel_t pwm_ch) {
else if(type == AGT_TIMER){
freq_hz = R_FSP_SystemClockHzGet(FSP_PRIV_CLOCK_PCLKB) >> timer_cfg.source_div;
}

uint32_t pulse_counts_us = (uint32_t) ((uint64_t) (freq_hz * us)/1000000 );
uint32_t pulse_counts_us = (uint32_t) ((uint64_t) freq_hz/1000000 * us);
if(!set_duty_cycle(pulse_counts_us, pwm_ch)) {
return false;
}

return true;
}

Expand Down Expand Up @@ -450,15 +453,9 @@ bool FspTimer::set_period(uint32_t p) {
/* -------------------------------------------------------------------------- */

if(type == GPT_TIMER && gpt_timer != nullptr) {
if (_period_buffer) {
if (R_GPT_PeriodSet(&(gpt_timer->ctrl), p) != FSP_SUCCESS) {
return false;
}
}
else {
// Not buffered set it directly
gpt_timer->ctrl.p_reg->GTPR = p;
}
}
else if(type == AGT_TIMER && agt_timer != nullptr) {
if (R_AGT_PeriodSet(&(agt_timer->ctrl), p) != FSP_SUCCESS) {
Expand All @@ -473,37 +470,6 @@ bool FspTimer::set_period(uint32_t p) {



/* -------------------------------------------------------------------------- */
bool FspTimer::set_period_buffer(bool period_buffer) {
/* -------------------------------------------------------------------------- */

if (_period_buffer == (uint8_t)period_buffer) {
return true;
}

_period_buffer = (uint8_t)period_buffer;
if(type == GPT_TIMER && gpt_timer != nullptr) {

if (period_buffer) {
gpt_timer->ctrl.p_reg->GTBER_b.PR = 1;
gpt_timer->ctrl.p_reg->GTBER_b.BD1 = 0;
}
else {
gpt_timer->ctrl.p_reg->GTBER_b.PR = 0;
gpt_timer->ctrl.p_reg->GTBER_b.BD1 = 1;
}
}
else if(type == AGT_TIMER && agt_timer != nullptr) {
// not buffered..
}
else {
return false;
}
return true;
}



/* -------------------------------------------------------------------------- */
bool FspTimer::open() {
/* -------------------------------------------------------------------------- */
Expand Down
2 changes: 0 additions & 2 deletions cores/arduino/FspTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ class FspTimer {
uint32_t _duty_cycle_counts;
timer_source_div_t _sd;
uint8_t type;
uint8_t _period_buffer;
void set_period_counts(uint8_t tp, float period, uint32_t max);
TimerIrqCfg_t get_cfg_for_irq();
static bool force_pwm_reserved;
Expand All @@ -112,7 +111,6 @@ class FspTimer {
bool reset();
bool set_duty_cycle(uint32_t const duty_cycle_counts, TimerPWMChannel_t pwm_ch);
bool set_period(uint32_t p);
bool set_period_buffer(bool period_buffer);
bool close();
void enable_pwm_channel(TimerPWMChannel_t pwm_channel);
uint32_t get_counter();
Expand Down
Loading
Loading