Skip to content

Commit

Permalink
Merge pull request #1580 from MatiMcFly/master
Browse files Browse the repository at this point in the history
Fixing Renesas register write protection and some compiler warnings in static code analysis
  • Loading branch information
hathach committed Apr 9, 2024
2 parents 1195fa8 + 6c2f71a commit a5b109b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 18 deletions.
26 changes: 13 additions & 13 deletions examples/build_system/make/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@
# ESP32-Sx and RP2040 has its own CMake build system
ifeq (,$(findstring $(FAMILY),espressif rp2040))

# ---------------------------------------
# Compiler Flags
# ---------------------------------------

CFLAGS += $(addprefix -I,$(INC))

# Verbose mode
ifeq ("$(V)","1")
$(info CFLAGS $(CFLAGS) ) $(info )
$(info LDFLAGS $(LDFLAGS)) $(info )
$(info ASFLAGS $(ASFLAGS)) $(info )
endif

# ---------------------------------------
# Rules
# ---------------------------------------
Expand All @@ -39,6 +26,19 @@ vpath %.S . $(TOP)

include ${TOP}/examples/build_system/make/toolchain/arm_$(TOOLCHAIN)_rules.mk

# ---------------------------------------
# Compiler Flags
# ---------------------------------------

CFLAGS += $(addprefix -I,$(INC))

# Verbose mode
ifeq ("$(V)","1")
$(info CFLAGS $(CFLAGS) ) $(info )
$(info LDFLAGS $(LDFLAGS)) $(info )
$(info ASFLAGS $(ASFLAGS)) $(info )
endif


OBJ_DIRS = $(sort $(dir $(OBJ)))
$(OBJ): | $(OBJ_DIRS)
Expand Down
3 changes: 2 additions & 1 deletion examples/device/cdc_msc_freertos/src/freertos_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, Stack
void vApplicationSetupTimerInterrupt(void)
{
/* Enable CMT0 */
unsigned short oldPRCR = SYSTEM.PRCR.WORD;
SYSTEM.PRCR.WORD = (0xA5u<<8) | TU_BIT(1);
MSTP(CMT0) = 0;
SYSTEM.PRCR.WORD = (0xA5u<<8);
SYSTEM.PRCR.WORD = (0xA5u<<8) | oldPRCR;

CMT0.CMCNT = 0;
CMT0.CMCOR = (unsigned short)(((configPERIPHERAL_CLOCK_HZ/configTICK_RATE_HZ)-1)/128);
Expand Down
3 changes: 2 additions & 1 deletion examples/device/hid_composite_freertos/src/freertos_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, Stack
void vApplicationSetupTimerInterrupt(void)
{
/* Enable CMT0 */
unsigned short oldPRCR = SYSTEM.PRCR.WORD;
SYSTEM.PRCR.WORD = (0xA5u<<8) | TU_BIT(1);
MSTP(CMT0) = 0;
SYSTEM.PRCR.WORD = (0xA5u<<8);
SYSTEM.PRCR.WORD = (0xA5u<<8) | oldPRCR;

CMT0.CMCNT = 0;
CMT0.CMCOR = (unsigned short)(((configPERIPHERAL_CLOCK_HZ/configTICK_RATE_HZ)-1)/128);
Expand Down
3 changes: 2 additions & 1 deletion hw/bsp/rx/boards/gr_citrus/gr_citrus.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,10 @@ void board_init(void)
IEN(SCI0, TEI0) = 1;

/* Enable USB0 */
unsigned short oldPRCR = SYSTEM.PRCR.WORD;
SYSTEM.PRCR.WORD = SYSTEM_PRCR_PRKEY | SYSTEM_PRCR_PRC1;
MSTP(USB0) = 0;
SYSTEM.PRCR.WORD = SYSTEM_PRCR_PRKEY;
SYSTEM.PRCR.WORD = SYSTEM_PRCR_PRKEY | oldPRCR;
}

//--------------------------------------------------------------------+
Expand Down
4 changes: 3 additions & 1 deletion hw/bsp/rx/boards/rx65n_target/rx65n_target.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,10 @@ void board_init(void)
EN(SCI5, TEI5) = 1;

/* Enable USB0 */
unsigned short oldPRCR = SYSTEM.PRCR.WORD;
SYSTEM.PRCR.WORD = SYSTEM_PRCR_PRKEY | SYSTEM_PRCR_PRC1;
MSTP(USB0) = 0;
SYSTEM.PRCR.WORD = SYSTEM_PRCR_PRKEY;
SYSTEM.PRCR.WORD = SYSTEM_PRCR_PRKEY | oldPRCR;

/* setup USBI0 interrupt. */
IR(USB0, USBI0) = 0;
Expand All @@ -277,6 +278,7 @@ int board_uart_read(uint8_t* buf, int len)
sci_buf[1].buf = buf;
sci_buf[1].cnt = len;
SCI5.SCR.BYTE |= SCI_SCR_RE | SCI_SCR_RIE;
// TODO change to non blocking, return -1 immediately if no data
while (SCI5.SCR.BIT.RE) ;
return len - sci_buf[1].cnt;
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/tusb_compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#define TU_VERIFY_STATIC _Static_assert
#elif defined(__CCRX__)
#define TU_VERIFY_STATIC(const_expr, _mess) typedef char TU_XSTRCAT(Line, __LINE__)[(const_expr) ? 1 : 0];
#define TU_VERIFY_STATIC(const_expr, _mess) typedef char TU_XSTRCAT(_verify_static_, _TU_COUNTER_)[(const_expr) ? 1 : 0];
#else
#define TU_VERIFY_STATIC(const_expr, _mess) enum { TU_XSTRCAT(_verify_static_, _TU_COUNTER_) = 1/(!!(const_expr)) }
#endif
Expand Down

0 comments on commit a5b109b

Please sign in to comment.