From 947edbf9d4ab1f78654c24376fb364f661670695 Mon Sep 17 00:00:00 2001
From: cnlohr <lohr85@gmail.com>
Date: Wed, 2 Aug 2023 12:05:19 -0700
Subject: [PATCH] Update with nulled printf (to prevent warnings on non-printf
 projects) and undestructively add interrupt nesting to WS2812B driver.

---
 ch32v003fun/ch32v003fun.c              | 6 +++---
 ch32v003fun/ch32v003fun.h              | 1 +
 extralibs/ws2812b_dma_spi_led_driver.h | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/ch32v003fun/ch32v003fun.c b/ch32v003fun/ch32v003fun.c
index 235f20f..f7f86c5 100644
--- a/ch32v003fun/ch32v003fun.c
+++ b/ch32v003fun/ch32v003fun.c
@@ -1004,9 +1004,9 @@ void WaitForDebuggerToAttach()
 #endif
 
 #if (defined( FUNCONF_USE_DEBUGPRINTF ) && !FUNCONF_USE_DEBUGPRINTF) && \
-((defined( FUNCONF_USE_UARTPRINTF ) && !FUNCONF_USE_UARTPRINTF) || \
-!defined( FUNCONF_USE_UARTPRINTF ))
-#warning( DEBUG Print Disabled)
+    (defined( FUNCONF_USE_UARTPRINTF ) && !FUNCONF_USE_UARTPRINTF) && \
+    (defined( FUNCONF_NULL_PRINTF ) && FUNCONF_NULL_PRINTF)
+
 int _write(int fd, const char *buf, int size)
 {
 	return size;
diff --git a/ch32v003fun/ch32v003fun.h b/ch32v003fun/ch32v003fun.h
index 74c6118..f80ea16 100644
--- a/ch32v003fun/ch32v003fun.h
+++ b/ch32v003fun/ch32v003fun.h
@@ -17,6 +17,7 @@
 #define FUNCONF_USE_CLK_SEC	1			// Use clock security system, enabled by default
 #define FUNCONF_USE_DEBUGPRINTF 1
 #define FUNCONF_USE_UARTPRINTF  0
+#define FUNCONF_NULL_PRINTF 0           // Have printf but direct it "nowhere"
 #define FUNCONF_SYSTICK_USE_HCLK 0      // Should systick be at 48 MHz or 6MHz?
 #define FUNCONF_TINYVECTOR 0            // If enabled, Does not allow normal interrupts.
 #define FUNCONF_UART_PRINTF_BAUD 115200 // Only used if FUNCONF_USE_UARTPRINTF is set.
diff --git a/extralibs/ws2812b_dma_spi_led_driver.h b/extralibs/ws2812b_dma_spi_led_driver.h
index 9d8433a..f076d21 100644
--- a/extralibs/ws2812b_dma_spi_led_driver.h
+++ b/extralibs/ws2812b_dma_spi_led_driver.h
@@ -264,7 +264,7 @@ void WS2812BDMAInit( )
 	DMA1_Channel3->CFGR |= DMA_CFGR1_EN;
 
 #ifdef WS2812B_ALLOW_INTERRUPT_NESTING
-	__set_INTSYSCR( 2 ); // Enable interrupt nesting.
+	__set_INTSYSCR( __get_INTSYSCR() | 2 ); // Enable interrupt nesting.
 	PFIC->IPRIOR[24] = 0b10000000; // Turn on preemption for DMA1Ch3
 #endif
 }
-- 
GitLab