Skip to content

Commit

Permalink
[update] RL78/G22_FPB related files for Arduino library.
Browse files Browse the repository at this point in the history
  • Loading branch information
SuguruHarada64 committed Oct 27, 2023
1 parent c027d3b commit 42e6162
Show file tree
Hide file tree
Showing 284 changed files with 37,504 additions and 29,603 deletions.
9 changes: 7 additions & 2 deletions cores/rl78g22/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@
#include "api/ArduinoAPI.h"
#include <stdbool.h>
#include "utilities.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "r_cg_macrodriver.h"
#ifdef __cplusplus
}
#endif
#include "pintable.h"
#include "pins_variant.h"

#define RLDUINO78_VERSION 0x0203
#define INTERRUPT
Expand Down Expand Up @@ -70,10 +77,8 @@ extern "C"{
#define INPUT_TTL 0x5
#define INPUT_TTL_PULLUP 0x6

// 2023/02/17 need confirm
/* PWM setting. */
#define PWM_MASTER_CLOCK (32000000)
//#define PWM_MASTER_CLOCK (1000000)
#if PWM_MASTER_CLOCK == 32000000
#define PWM_MASTER_MODE (0x0801) // CK0を選択
#define PWM_SLAVE_MODE (0x0409)
Expand Down
2,607 changes: 1,321 additions & 1,286 deletions cores/rl78g22/HardwareUart.cpp

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions cores/rl78g22/HardwareUart.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
#undef SERIAL_BUFFER_SIZE
#endif

#if defined(FEW_RAM_MODEL) && (FEW_RAM_MODEL == 1)
#define SERIAL_BUFFER_SIZE 32
#else
#define SERIAL_BUFFER_SIZE 256
#endif

class HardwareUart : public arduino::HardwareSerial
{
Expand Down Expand Up @@ -65,6 +69,11 @@ class HardwareUart : public arduino::HardwareSerial
unsigned char *_rx_buffer;
unsigned char *_tx_buffer;

#if defined(FEW_RAM_MODEL) && (FEW_RAM_MODEL == 1)
unsigned char base_rx_buffer[SERIAL_BUFFER_SIZE];
unsigned char base_tx_buffer[SERIAL_BUFFER_SIZE];
#endif //

uint8_t receive_buffer;
uint8_t _urt_channel;
bool transmitting;
Expand Down
224 changes: 112 additions & 112 deletions cores/rl78g22/WInterrupts.c
Original file line number Diff line number Diff line change
@@ -1,112 +1,112 @@
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */

/*
Part of the Wiring project - http://wiring.uniandes.edu.co
Copyright (c) 2004-05 Hernando Barragan
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
Modified 24 November 2006 by David A. Mellis
Modified 1 August 2010 by Mark Sproul
*/
/*
* Mar 1st 2017 : Modified for RL78/G13 by Yuuki Okamiya.
*/

#include <inttypes.h>
// #include <avr/pgmspace.h>
#include <stdio.h>

#include "utilities.h"
#include "wiring_private.h"
#include "api/Common.h"
#include "r_smc_entry.h"
#include "platform.h"



/* 1108 Ueeda add */

typedef struct {
void (*begin)();
void (*mode)(uint8_t interruptNum, PinStatus mode);
void (*start)();
void (*stop)(uint8_t interruptNum);
} Interrupts_func;

Interrupts_func Int_func =
{
.begin = (void*)R_Config_INTC_Create,
.mode = (void*)R_Config_INTC_Create_Mode,
.start = (void*)R_Config_INTC_INTP_Start,
.stop = (void*)R_Config_INTC_INTP_Stop
};

static bool IsFirst = true;

// void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode)

//void attachInterrupt(pin_size_t interruptNum, voidFuncPtr userFunc, int mode)

void attachInterrupt(pin_size_t interruptNum, voidFuncPtr userFunc, PinStatus p_mode)
{
uint8_t mode = (uint8_t)p_mode;
if (interruptNum < EXTERNAL_NUM_INTERRUPTS) {
g_afInterruptFuncTable[interruptNum] = userFunc;
if(IsFirst){
Int_func.begin();
IsFirst = false;
}
Int_func.mode(interruptNum, mode);
Int_func.start();
}
}

void detachInterrupt(uint8_t interruptNum) {

if (interruptNum < EXTERNAL_NUM_INTERRUPTS) {
Int_func.stop(interruptNum);
g_afInterruptFuncTable[interruptNum] = NULL;
}
}

// INTERRUPT HANDLERS *********************************************************/
// NMI and IRQ interrupt handlers. Note that all of these are declared in
// interrupts_handlers.h but defined here for clarity.

// ***************************************************************************/
INTERRUPT void external_interrupt_0(void)
{
if (g_afInterruptFuncTable[0] != NULL) {
(*g_afInterruptFuncTable[0])();
}
}

INTERRUPT void external_interrupt_1(void)
{
if (g_afInterruptFuncTable[1] != NULL) {
(*g_afInterruptFuncTable[1])();
}
}

INTERRUPT void external_interrupt_2(void)
{
if (g_afInterruptFuncTable[2] != NULL) {
(*g_afInterruptFuncTable[2])();
}
}

/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */

/*
Part of the Wiring project - http://wiring.uniandes.edu.co
Copyright (c) 2004-05 Hernando Barragan
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
Modified 24 November 2006 by David A. Mellis
Modified 1 August 2010 by Mark Sproul
*/
/*
* Mar 1st 2017 : Modified for RL78/G13 by Yuuki Okamiya.
*/

#include <inttypes.h>
// #include <avr/pgmspace.h>
#include <stdio.h>

#include "utilities.h"
#include "wiring_private.h"
#include "api/Common.h"
#include "r_smc_entry.h"
#include "platform.h"



/* 1108 Ueeda add */

typedef struct {
void (*begin)();
void (*mode)(uint8_t interruptNum, PinStatus mode);
void (*start)();
void (*stop)(uint8_t interruptNum);
} Interrupts_func;

Interrupts_func Int_func =
{
.begin = (void*)R_Config_INTC_Create,
.mode = (void*)R_Config_INTC_Create_Mode,
.start = (void*)R_Config_INTC_INTP_Start,
.stop = (void*)R_Config_INTC_INTP_Stop
};

static bool IsFirst = true;

// void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode)

//void attachInterrupt(pin_size_t interruptNum, voidFuncPtr userFunc, int mode)

void attachInterrupt(pin_size_t interruptNum, voidFuncPtr userFunc, PinStatus p_mode)
{
uint8_t mode = (uint8_t)p_mode;
if (interruptNum < EXTERNAL_NUM_INTERRUPTS) {
g_afInterruptFuncTable[interruptNum] = userFunc;
if(IsFirst){
Int_func.begin();
IsFirst = false;
}
Int_func.mode(interruptNum, mode);
Int_func.start();
}
}

void detachInterrupt(uint8_t interruptNum) {

if (interruptNum < EXTERNAL_NUM_INTERRUPTS) {
Int_func.stop(interruptNum);
g_afInterruptFuncTable[interruptNum] = NULL;
}
}

// INTERRUPT HANDLERS *********************************************************/
// NMI and IRQ interrupt handlers. Note that all of these are declared in
// interrupts_handlers.h but defined here for clarity.

// ***************************************************************************/
INTERRUPT void external_interrupt_0(void)
{
if (g_afInterruptFuncTable[0] != NULL) {
(*g_afInterruptFuncTable[0])();
}
}

INTERRUPT void external_interrupt_1(void)
{
if (g_afInterruptFuncTable[1] != NULL) {
(*g_afInterruptFuncTable[1])();
}
}

INTERRUPT void external_interrupt_2(void)
{
if (g_afInterruptFuncTable[2] != NULL) {
(*g_afInterruptFuncTable[2])();
}
}
Loading

0 comments on commit 42e6162

Please sign in to comment.