APIs like digitalWrite who use g_pinc_cfg should do bounds checking

There are several of the top level APIs, like digitalWrite, which index this array without checking anything, which if the value passed in, is out of range, will produce unpredictable results, ranging from faulting to randomly acting on different pin.

Example:

void digitalWrite(pin_size_t pin, PinStatus val) {
	R_IOPORT_PinWrite(NULL, g_pin_cfg[pin].pin, val == LOW ? BSP_IO_LEVEL_LOW : BSP_IO_LEVEL_HIGH);
}

I am assuming, that the UNOR4 boards are not EXTENDED_PIN_MODE so

typedef uint8_t pin_size_t;

A quick check I believe, that some of the APIs include:

analogWrite
pinMode
digitalWrite
digitalRead

Note: I see a few places that actually checks:

static int pin2IrqChannel(int pin) {
/* -------------------------------------------------------------------------- */  
  /* verify index are good */
  if(pin < 0 || pin >= (int)(g_pin_cfg_size / sizeof(g_pin_cfg[0]))) {
    return -1;
  }

Likewise PwmOut

There are probably others in both check and don't check, as I have not gone through every reference.

Some related discussion here:

https://github.com/arduino/ArduinoCore-renesas/issues/58#issuecomment-1668688405

I really hate the "cluttering" of digitalWrite() with checks for whether an analogWrite() is in effect, whether the pin is in INPUT mode (and therefore should have a pullup enabled) (which the R4 code also doesn't do) and so on. Some of this is painful preservation of AVR behavior, and some is just things that ought to be the programmer's responsibility.