C
Qt Quick Ultralite multitask Example
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
#include <stdint.h>
#include "bsp_exceptions.h"
#include "R7FA8D1BH.h"
#include "platforminterface/log.h"
#define IO_PORT_04_PIN_14 (0x040E)
#define IO_PRV_PFS_PSEL_OFFSET (24)
#define IO_PRV_8BIT_MASK (0xFF)
#define IO_PWPR_B0WI_OFFSET (7U)
#define IO_PWPR_PFSWE_OFFSET (6U)
#define IO_PFS_PDR_OUTPUT (4U)
#define IO_PRV_PIN_WRITE_MASK (0xFFFE3FFE)
namespace BoardUtils {
void initLED()
{
//USER_LED3-Green is initialised by platform
}
void toggleLED()
{
// Enable PinAccess
R_PMISC->PWPRS = 0; ///< Clear BOWI bit - writing to PFSWE bit enabled
R_PMISC->PWPRS = 1U << IO_PWPR_PFSWE_OFFSET; ///< Set PFSWE bit - writing to PFS register enabled
static uint8_t level = 1;
/* Clear PMR, ASEL, ISEL and PODR bits. */
uint32_t pfs_bits = R_PFS->PORT[IO_PORT_04_PIN_14 >> 8].PIN[IO_PORT_04_PIN_14 & IO_PRV_8BIT_MASK].PmnPFS;
pfs_bits &= IO_PRV_PIN_WRITE_MASK;
/* Set output level and pin direction to output. */
uint32_t lvl = ((uint32_t) level | pfs_bits);
R_PFS->PORT[IO_PORT_04_PIN_14 >> 8].PIN[IO_PORT_04_PIN_14 & IO_PRV_8BIT_MASK].PmnPFS = (IO_PFS_PDR_OUTPUT | lvl);
// Disable PinAccess
R_PMISC->PWPRS = 0; ///< Clear PFSWE bit - writing to PFS register disabled
R_PMISC->PWPRS = 1U << IO_PWPR_B0WI_OFFSET; ///< Set BOWI bit - writing to PFSWE bit disabled
level = 1 - level;
}
} // namespace BoardUtils