/* Writes the set and clear values on a pin of the port when an ELC event occurs. This allows accurate timing of pin output level. */
static void r_ioport_hw_pin_event_output_data_write(bsp_io_port_t port, ioport_size_t set_value, ioport_size_t reset_value, bsp_io_level_t pin_level)
/* Writes the set and clear values on a pin of the port when an ELC event occurs. This allows accurate timing of pin output level. */
static void r_ioport_hw_pin_event_output_data_write(bsp_io_port_t port, ioport_size_t set_value, ioport_size_t reset_value, bsp_io_level_t pin_level)
{
    uint32_t port_value = 0;
    R_PORT0_Type * p_ioport_regs = IOPORT_PRV_PORT_ADDRESS((port >> IOPORT_PRV_PORT_OFFSET) & IOPORT_PRV_8BIT_MASK);
    port_value = p_ioport_regs->PCNTR4;
    if (BSP_IO_LEVEL_HIGH == pin_level)
    {
        port_value |= (uint32_t) (set_value);
        port_value &= (((uint32_t) reset_value << 16) | IOPORT_PRV_16BIT_MASK);
    }
    else
    {
        port_value |= (uint32_t) reset_value << 16;
        port_value &= (uint32_t) ((set_value | IOPORT_PRV_UPPER_16BIT_MASK));
    }
    p_ioport_regs->PCNTR4 = port_value;
}