summaryrefslogtreecommitdiff
path: root/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities
diff options
context:
space:
mode:
Diffstat (limited to 'FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities')
-rw-r--r--FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_assert.c27
-rw-r--r--FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_debug_console.c491
-rw-r--r--FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_debug_console.h60
-rw-r--r--FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_debug_console_conf.h105
-rw-r--r--FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_str.c94
5 files changed, 540 insertions, 237 deletions
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_assert.c b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_assert.c
index 275960b56..db65df030 100644
--- a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_assert.c
+++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_assert.c
@@ -1,11 +1,11 @@
/*
-* Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
-* Copyright 2016-2017 NXP
-* All rights reserved.
-*
-*
-* SPDX-License-Identifier: BSD-3-Clause
-*/
+ * Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
+ * Copyright 2016-2017 NXP
+ * All rights reserved.
+ *
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
#include "fsl_common.h"
#include "fsl_debug_console.h"
@@ -20,7 +20,17 @@ void __aeabi_assert(const char *failedExpr, const char *file, int line)
__BKPT(0);
}
}
-#elif(defined(__GNUC__))
+#elif (defined(__GNUC__))
+#if defined(__REDLIB__)
+void __assertion_failed(char *failedExpr)
+{
+ PRINTF("ASSERT ERROR \" %s \n", failedExpr);
+ for (;;)
+ {
+ __BKPT(0);
+ }
+}
+#else
void __assert_func(const char *file, int line, const char *func, const char *failedExpr)
{
PRINTF("ASSERT ERROR \" %s \": file \"%s\" Line \"%d\" function name \"%s\" \n", failedExpr, file, line, func);
@@ -29,5 +39,6 @@ void __assert_func(const char *file, int line, const char *func, const char *fai
__BKPT(0);
}
}
+#endif /* defined(__REDLIB__) */
#endif /* (defined(__CC_ARM) || (defined(__ICCARM__)) || (defined(__ARMCC_VERSION)) */
#endif /* NDEBUG */
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_debug_console.c b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_debug_console.c
index a79e7af34..76aee9c2a 100644
--- a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_debug_console.c
+++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_debug_console.c
@@ -30,7 +30,7 @@
* of this software
* Copyright (c) 2015, Freescale Semiconductor, Inc.
- * Copyright 2016-2018 NXP
+ * Copyright 2016-2019 NXP
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -43,8 +43,8 @@
#ifdef FSL_RTOS_FREE_RTOS
#include "FreeRTOS.h"
-#include "task.h"
#include "semphr.h"
+#include "task.h"
#endif
#include "fsl_debug_console_conf.h"
@@ -65,18 +65,28 @@
#endif
#endif
+#if SDK_DEBUGCONSOLE
+#define DEBUG_CONSOLE_FUNCTION_PREFIX
+#else
+#define DEBUG_CONSOLE_FUNCTION_PREFIX static
+#endif
+
/*! @brief character backspace ASCII value */
-#define DEBUG_CONSOLE_BACKSPACE 127
+#define DEBUG_CONSOLE_BACKSPACE 127U
/* lock definition */
#if (DEBUG_CONSOLE_SYNCHRONIZATION_MODE == DEBUG_CONSOLE_SYNCHRONIZATION_FREERTOS)
static SemaphoreHandle_t s_debugConsoleReadSemaphore;
+#if (defined(DEBUG_CONSOLE_RX_ENABLE) && (DEBUG_CONSOLE_RX_ENABLE > 0U))
static SemaphoreHandle_t s_debugConsoleReadWaitSemaphore;
+#endif
-#elif(DEBUG_CONSOLE_SYNCHRONIZATION_MODE == DDEBUG_CONSOLE_SYNCHRONIZATION_BM)
+#elif (DEBUG_CONSOLE_SYNCHRONIZATION_MODE == DEBUG_CONSOLE_SYNCHRONIZATION_BM)
+#if (defined(DEBUG_CONSOLE_RX_ENABLE) && (DEBUG_CONSOLE_RX_ENABLE > 0U))
static volatile uint8_t s_debugConsoleReadWaitSemaphore;
+#endif
#else
@@ -93,14 +103,23 @@ static volatile uint8_t s_debugConsoleReadWaitSemaphore;
#if (DEBUG_CONSOLE_SYNCHRONIZATION_MODE == DEBUG_CONSOLE_SYNCHRONIZATION_FREERTOS)
/* mutex semaphore */
-#define DEBUG_CONSOLE_CREATE_MUTEX_SEMAPHORE(mutex) (mutex = xSemaphoreCreateMutex())
-
/* clang-format off */
+#define DEBUG_CONSOLE_CREATE_MUTEX_SEMAPHORE(mutex) ((mutex) = xSemaphoreCreateMutex())
+#define DEBUG_CONSOLE_DESTROY_MUTEX_SEMAPHORE(mutex) \
+ do \
+ { \
+ if(NULL != mutex) \
+ { \
+ vSemaphoreDelete(mutex); \
+ mutex = NULL; \
+ } \
+ } while(0)
+
#define DEBUG_CONSOLE_GIVE_MUTEX_SEMAPHORE(mutex) \
{ \
if (IS_RUNNING_IN_ISR() == 0U) \
{ \
- xSemaphoreGive(mutex); \
+ (void)xSemaphoreGive(mutex); \
} \
}
@@ -108,7 +127,7 @@ static volatile uint8_t s_debugConsoleReadWaitSemaphore;
{ \
if (IS_RUNNING_IN_ISR() == 0U) \
{ \
- xSemaphoreTake(mutex, portMAX_DELAY); \
+ (void)xSemaphoreTake(mutex, portMAX_DELAY); \
} \
}
@@ -123,21 +142,31 @@ static volatile uint8_t s_debugConsoleReadWaitSemaphore;
result = 1U; \
} \
}
-/* clang-format on */
/* Binary semaphore */
-#define DEBUG_CONSOLE_CREATE_BINARY_SEMAPHORE(binary) (binary = xSemaphoreCreateBinary())
-#define DEBUG_CONSOLE_TAKE_BINARY_SEMAPHORE_BLOCKING(binary) (xSemaphoreTake(binary, portMAX_DELAY))
-#define DEBUG_CONSOLE_GIVE_BINARY_SEMAPHORE_FROM_ISR(binary) (xSemaphoreGiveFromISR(binary, NULL))
-
-#elif(DEBUG_CONSOLE_SYNCHRONIZATION_BM == DEBUG_CONSOLE_SYNCHRONIZATION_MODE)
+#define DEBUG_CONSOLE_CREATE_BINARY_SEMAPHORE(binary) ((binary) = xSemaphoreCreateBinary())
+#define DEBUG_CONSOLE_DESTROY_BINARY_SEMAPHORE(binary) \
+ do \
+ { \
+ if(NULL != binary) \
+ { \
+ vSemaphoreDelete(binary); \
+ binary = NULL; \
+ } \
+ } while(0)
+#define DEBUG_CONSOLE_TAKE_BINARY_SEMAPHORE_BLOCKING(binary) ((void)xSemaphoreTake(binary, portMAX_DELAY))
+#define DEBUG_CONSOLE_GIVE_BINARY_SEMAPHORE_FROM_ISR(binary) ((void)xSemaphoreGiveFromISR(binary, NULL))
+
+#elif (DEBUG_CONSOLE_SYNCHRONIZATION_BM == DEBUG_CONSOLE_SYNCHRONIZATION_MODE)
#define DEBUG_CONSOLE_CREATE_MUTEX_SEMAPHORE(mutex)
+#define DEBUG_CONSOLE_DESTROY_MUTEX_SEMAPHORE(mutex)
#define DEBUG_CONSOLE_TAKE_MUTEX_SEMAPHORE_BLOCKING(mutex)
#define DEBUG_CONSOLE_GIVE_MUTEX_SEMAPHORE(mutex)
#define DEBUG_CONSOLE_TAKE_MUTEX_SEMAPHORE_NONBLOCKING(mutex, result) (result = 1U)
#define DEBUG_CONSOLE_CREATE_BINARY_SEMAPHORE(binary)
+#define DEBUG_CONSOLE_DESTROY_BINARY_SEMAPHORE(binary)
#ifdef DEBUG_CONSOLE_TRANSFER_NON_BLOCKING
#define DEBUG_CONSOLE_TAKE_BINARY_SEMAPHORE_BLOCKING(binary) \
{ \
@@ -151,11 +180,12 @@ static volatile uint8_t s_debugConsoleReadWaitSemaphore;
#define DEBUG_CONSOLE_TAKE_BINARY_SEMAPHORE_BLOCKING(binary)
#define DEBUG_CONSOLE_GIVE_BINARY_SEMAPHORE_FROM_ISR(binary)
#endif /* DEBUG_CONSOLE_TRANSFER_NON_BLOCKING */
+/* clang-format on */
/* add other implementation here
-*such as :
-* #elif(DEBUG_CONSOLE_SYNCHRONIZATION_MODE == DDEBUG_CONSOLE_SYNCHRONIZATION_xxx)
-*/
+ *such as :
+ * #elif(DEBUG_CONSOLE_SYNCHRONIZATION_MODE == DDEBUG_CONSOLE_SYNCHRONIZATION_xxx)
+ */
#else
@@ -191,7 +221,11 @@ typedef struct _debug_console_state_struct
******************************************************************************/
/*! @brief Debug console state information. */
+#if (defined(DATA_SECTION_IS_CACHEABLE) && (DATA_SECTION_IS_CACHEABLE > 0))
+AT_NONCACHEABLE_SECTION(static debug_console_state_struct_t s_debugConsoleState);
+#else
static debug_console_state_struct_t s_debugConsoleState;
+#endif
serial_handle_t g_serialHandle; /*!< serial manager handle */
/*******************************************************************************
@@ -208,11 +242,20 @@ serial_handle_t g_serialHandle; /*!< serial manager handle */
*
*/
#if SDK_DEBUGCONSOLE
-static void DbgConsole_PrintCallback(char *buf, int32_t *indicator, char val, int len);
+static void DbgConsole_PrintCallback(char *buf, int32_t *indicator, char dbgVal, int len);
#endif
+status_t DbgConsole_ReadOneCharacter(uint8_t *ch);
int DbgConsole_SendData(uint8_t *ch, size_t size);
-
+int DbgConsole_SendDataReliable(uint8_t *ch, size_t size);
+int DbgConsole_ReadLine(uint8_t *buf, size_t size);
+int DbgConsole_ReadCharacter(uint8_t *ch);
+
+#if ((SDK_DEBUGCONSOLE > 0U) || \
+ ((SDK_DEBUGCONSOLE == 0U) && defined(DEBUG_CONSOLE_TRANSFER_NON_BLOCKING) && \
+ (defined(DEBUG_CONSOLE_TX_RELIABLE_ENABLE) && (DEBUG_CONSOLE_TX_RELIABLE_ENABLE > 0U))))
+DEBUG_CONSOLE_FUNCTION_PREFIX status_t DbgConsole_Flush(void);
+#endif
/*******************************************************************************
* Code
******************************************************************************/
@@ -252,13 +295,19 @@ static void DbgConsole_SerialManagerTxCallback(void *callbackParam,
sendDataLength = ioState->writeRingBuffer.ringBufferSize - ioState->writeRingBuffer.ringTail;
}
- SerialManager_WriteNonBlocking(((serial_write_handle_t)&ioState->serialWriteHandleBuffer[0]),
- &ioState->writeRingBuffer.ringBuffer[ioState->writeRingBuffer.ringTail],
- sendDataLength);
+ (void)SerialManager_WriteNonBlocking(
+ ((serial_write_handle_t)&ioState->serialWriteHandleBuffer[0]),
+ &ioState->writeRingBuffer.ringBuffer[ioState->writeRingBuffer.ringTail], sendDataLength);
}
}
+ else if (kStatus_SerialManager_Canceled == status)
+ {
+ ioState->writeRingBuffer.ringTail = 0U;
+ ioState->writeRingBuffer.ringHead = 0U;
+ }
else
{
+ /*MISRA rule 16.4*/
}
}
@@ -283,6 +332,7 @@ static void DbgConsole_SerialManagerRxCallback(void *callbackParam,
}
else
{
+ /*MISRA rule 16.4*/
}
}
#endif
@@ -294,31 +344,32 @@ status_t DbgConsole_ReadOneCharacter(uint8_t *ch)
#if (defined(DEBUG_CONSOLE_RX_ENABLE) && (DEBUG_CONSOLE_RX_ENABLE > 0U))
#if defined(DEBUG_CONSOLE_TRANSFER_NON_BLOCKING) && \
- (DEBUG_CONSOLE_SYNCHRONIZATION_MODE == DDEBUG_CONSOLE_SYNCHRONIZATION_BM) && defined(OSA_USED)
+ (DEBUG_CONSOLE_SYNCHRONIZATION_MODE == DEBUG_CONSOLE_SYNCHRONIZATION_BM) && defined(OSA_USED)
return kStatus_Fail;
#else
- status_t status = kStatus_SerialManager_Error;
+ status_t status = (status_t)kStatus_SerialManager_Error;
/* recieve one char every time */
#if defined(DEBUG_CONSOLE_TRANSFER_NON_BLOCKING)
- status =
- SerialManager_ReadNonBlocking(((serial_read_handle_t)&s_debugConsoleState.serialReadHandleBuffer[0]), ch, 1);
+ status = (status_t)SerialManager_ReadNonBlocking(
+ ((serial_read_handle_t)&s_debugConsoleState.serialReadHandleBuffer[0]), ch, 1);
#else
- status = SerialManager_ReadBlocking(((serial_read_handle_t)&s_debugConsoleState.serialReadHandleBuffer[0]), ch, 1);
+ status = (status_t)SerialManager_ReadBlocking(
+ ((serial_read_handle_t)&s_debugConsoleState.serialReadHandleBuffer[0]), ch, 1);
#endif
- if (kStatus_SerialManager_Success != status)
+ if ((status_t)kStatus_SerialManager_Success != status)
{
- return kStatus_Fail;
+ return (status_t)kStatus_Fail;
}
/* wait s_debugConsoleReadWaitSemaphore from RX callback */
DEBUG_CONSOLE_TAKE_BINARY_SEMAPHORE_BLOCKING(s_debugConsoleReadWaitSemaphore);
- return kStatus_Success;
+ return (status_t)kStatus_Success;
#endif
#else
- return kStatus_Fail;
+ return (status_t)kStatus_Fail;
#endif
}
@@ -327,16 +378,16 @@ status_t DbgConsole_ReadOneCharacter(uint8_t *ch)
static status_t DbgConsole_EchoCharacter(uint8_t *ch, bool isGetChar, int *index)
{
/* Due to scanf take \n and \r as end of string,should not echo */
- if (((*ch != '\r') && (*ch != '\n')) || (isGetChar))
+ if (((*ch != (uint8_t)'\r') && (*ch != (uint8_t)'\n')) || (isGetChar))
{
/* recieve one char every time */
- if (1 != DbgConsole_SendData(ch, 1U))
+ if (1 != DbgConsole_SendDataReliable(ch, 1U))
{
- return kStatus_Fail;
+ return (status_t)kStatus_Fail;
}
}
- if ((!isGetChar) && (index))
+ if ((!isGetChar) && (index != NULL))
{
if (DEBUG_CONSOLE_BACKSPACE == *ch)
{
@@ -351,13 +402,13 @@ static status_t DbgConsole_EchoCharacter(uint8_t *ch, bool isGetChar, int *index
}
}
- return kStatus_Success;
+ return (status_t)kStatus_Success;
}
#endif
int DbgConsole_SendData(uint8_t *ch, size_t size)
{
- status_t status = kStatus_SerialManager_Error;
+ status_t status = (status_t)kStatus_SerialManager_Error;
#if defined(DEBUG_CONSOLE_TRANSFER_NON_BLOCKING)
uint32_t sendDataLength;
int txBusy = 0;
@@ -379,13 +430,13 @@ int DbgConsole_SendData(uint8_t *ch, size_t size)
{
sendDataLength = 0U;
}
- sendDataLength = s_debugConsoleState.writeRingBuffer.ringBufferSize - sendDataLength;
- if (sendDataLength <= size)
+ sendDataLength = s_debugConsoleState.writeRingBuffer.ringBufferSize - sendDataLength - 1;
+ if (sendDataLength < size)
{
EnableGlobalIRQ(regPrimask);
return -1;
}
- for (int i = 0; i < size; i++)
+ for (int i = 0; i < (int)size; i++)
{
s_debugConsoleState.writeRingBuffer.ringBuffer[s_debugConsoleState.writeRingBuffer.ringHead++] = ch[i];
if (s_debugConsoleState.writeRingBuffer.ringHead >= s_debugConsoleState.writeRingBuffer.ringBufferSize)
@@ -394,9 +445,9 @@ int DbgConsole_SendData(uint8_t *ch, size_t size)
}
}
- status = kStatus_SerialManager_Success;
+ status = (status_t)kStatus_SerialManager_Success;
- if (!txBusy)
+ if (txBusy == 0)
{
if (s_debugConsoleState.writeRingBuffer.ringHead > s_debugConsoleState.writeRingBuffer.ringTail)
{
@@ -419,50 +470,143 @@ int DbgConsole_SendData(uint8_t *ch, size_t size)
status = (status_t)SerialManager_WriteBlocking(
((serial_write_handle_t)&s_debugConsoleState.serialWriteHandleBuffer[0]), ch, size);
#endif
- return ((kStatus_Success == status) ? (int)size : -1);
+ return (((status_t)kStatus_Success == status) ? (int)size : -1);
+}
+
+int DbgConsole_SendDataReliable(uint8_t *ch, size_t size)
+{
+#if defined(DEBUG_CONSOLE_TRANSFER_NON_BLOCKING)
+#if (defined(DEBUG_CONSOLE_TX_RELIABLE_ENABLE) && (DEBUG_CONSOLE_TX_RELIABLE_ENABLE > 0U))
+ status_t status = kStatus_SerialManager_Error;
+ uint32_t sendDataLength;
+ uint32_t totalLength = size;
+ int sentLength;
+#endif /* DEBUG_CONSOLE_TX_RELIABLE_ENABLE */
+#else
+ status_t status = kStatus_SerialManager_Error;
+#endif /* DEBUG_CONSOLE_TRANSFER_NON_BLOCKING */
+
+ assert(NULL != ch);
+ assert(0 != size);
+
+ if (NULL == g_serialHandle)
+ {
+ return 0;
+ }
+
+#if defined(DEBUG_CONSOLE_TRANSFER_NON_BLOCKING)
+
+#if (defined(DEBUG_CONSOLE_TX_RELIABLE_ENABLE) && (DEBUG_CONSOLE_TX_RELIABLE_ENABLE > 0U))
+ do
+ {
+ uint32_t regPrimask = DisableGlobalIRQ();
+ if (s_debugConsoleState.writeRingBuffer.ringHead != s_debugConsoleState.writeRingBuffer.ringTail)
+ {
+ sendDataLength =
+ (s_debugConsoleState.writeRingBuffer.ringHead + s_debugConsoleState.writeRingBuffer.ringBufferSize -
+ s_debugConsoleState.writeRingBuffer.ringTail) %
+ s_debugConsoleState.writeRingBuffer.ringBufferSize;
+ }
+ else
+ {
+ sendDataLength = 0U;
+ }
+ sendDataLength = s_debugConsoleState.writeRingBuffer.ringBufferSize - sendDataLength - 1U;
+
+ if (sendDataLength > 0U)
+ {
+ if (sendDataLength > totalLength)
+ {
+ sendDataLength = totalLength;
+ }
+
+ sentLength = DbgConsole_SendData(&ch[size - totalLength], sendDataLength);
+ if (sentLength > 0)
+ {
+ totalLength = totalLength - (uint32_t)sentLength;
+ }
+ }
+ EnableGlobalIRQ(regPrimask);
+
+ if (totalLength != 0U)
+ {
+ status = DbgConsole_Flush();
+ if ((status_t)kStatus_Success != status)
+ {
+ break;
+ }
+ }
+ } while (totalLength != 0U);
+ return (status_t)(uint32_t)((uint32_t)size - totalLength);
+#else
+ return DbgConsole_SendData(ch, size);
+#endif /* DEBUG_CONSOLE_TX_RELIABLE_ENABLE */
+
+#else
+ status = (status_t)SerialManager_WriteBlocking(
+ ((serial_write_handle_t)&s_debugConsoleState.serialWriteHandleBuffer[0]), ch, size);
+ return (((status_t)kStatus_Success == status) ? (int)size : -1);
+#endif /* DEBUG_CONSOLE_TRANSFER_NON_BLOCKING */
}
int DbgConsole_ReadLine(uint8_t *buf, size_t size)
{
- int i;
+ int i = 0;
assert(buf != NULL);
+ if (NULL == g_serialHandle)
+ {
+ return -1;
+ }
+
/* take mutex lock function */
DEBUG_CONSOLE_TAKE_MUTEX_SEMAPHORE_BLOCKING(s_debugConsoleReadSemaphore);
- for (i = 0; i < size; i++)
+ do
{
/* recieve one char every time */
- if (kStatus_Success != DbgConsole_ReadOneCharacter(&buf[i]))
+ if ((status_t)kStatus_Success != DbgConsole_ReadOneCharacter(&buf[i]))
{
/* release mutex lock function */
DEBUG_CONSOLE_GIVE_MUTEX_SEMAPHORE(s_debugConsoleReadSemaphore);
- return -1;
+ i = -1;
+ break;
}
#if DEBUG_CONSOLE_ENABLE_ECHO_FUNCTION
- DbgConsole_EchoCharacter(&buf[i], false, &i);
+ (void)DbgConsole_EchoCharacter(&buf[i], false, &i);
#endif
/* analysis data */
- if (('\r' == buf[i]) || ('\n' == buf[i]))
+ if (((uint8_t)'\r' == buf[i]) || ((uint8_t)'\n' == buf[i]))
{
/* End of Line. */
if (0 == i)
{
- buf[i] = '\0';
- i = -1;
+ buf[i] = (uint8_t)'\0';
+ continue;
}
else
{
break;
}
}
+ i++;
+ } while (i < (int)size);
+
+ /* get char should not add '\0'*/
+ if (i == (int)size)
+ {
+ buf[i] = (uint8_t)'\0';
+ }
+ else
+ {
+ buf[i + 1] = (uint8_t)'\0';
}
/* release mutex lock function */
DEBUG_CONSOLE_GIVE_MUTEX_SEMAPHORE(s_debugConsoleReadSemaphore);
- return i + 1;
+ return i;
}
int DbgConsole_ReadCharacter(uint8_t *ch)
@@ -471,14 +615,19 @@ int DbgConsole_ReadCharacter(uint8_t *ch)
assert(ch);
+ if (NULL == g_serialHandle)
+ {
+ return -1;
+ }
+
/* take mutex lock function */
DEBUG_CONSOLE_TAKE_MUTEX_SEMAPHORE_BLOCKING(s_debugConsoleReadSemaphore);
/* read one character */
- if (kStatus_Success == DbgConsole_ReadOneCharacter(ch))
+ if ((status_t)kStatus_Success == DbgConsole_ReadOneCharacter(ch))
{
ret = 1;
#if DEBUG_CONSOLE_ENABLE_ECHO_FUNCTION
- DbgConsole_EchoCharacter(ch, true, NULL);
+ (void)DbgConsole_EchoCharacter(ch, true, NULL);
#endif
}
else
@@ -493,19 +642,19 @@ int DbgConsole_ReadCharacter(uint8_t *ch)
}
#if SDK_DEBUGCONSOLE
-static void DbgConsole_PrintCallback(char *buf, int32_t *indicator, char val, int len)
+static void DbgConsole_PrintCallback(char *buf, int32_t *indicator, char dbgVal, int len)
{
int i = 0;
for (i = 0; i < len; i++)
{
- if ((*indicator + 1) >= DEBUG_CONSOLE_PRINTF_MAX_LOG_LEN)
+ if (((uint32_t)*indicator + 1UL) >= DEBUG_CONSOLE_PRINTF_MAX_LOG_LEN)
{
- DbgConsole_SendData((uint8_t *)buf, *indicator);
- *indicator = 0U;
+ (void)DbgConsole_SendDataReliable((uint8_t *)buf, (uint32_t)(*indicator));
+ *indicator = 0;
}
- buf[*indicator] = val;
+ buf[*indicator] = dbgVal;
(*indicator)++;
}
}
@@ -513,21 +662,22 @@ static void DbgConsole_PrintCallback(char *buf, int32_t *indicator, char val, in
/*************Code for DbgConsole Init, Deinit, Printf, Scanf *******************************/
+#if ((SDK_DEBUGCONSOLE == DEBUGCONSOLE_REDIRECT_TO_SDK) || defined(SDK_DEBUGCONSOLE_UART))
/* See fsl_debug_console.h for documentation of this function. */
status_t DbgConsole_Init(uint8_t instance, uint32_t baudRate, serial_port_type_t device, uint32_t clkSrcFreq)
{
serial_manager_config_t serialConfig;
- status_t status = kStatus_SerialManager_Error;
+ status_t status = (status_t)kStatus_SerialManager_Error;
#if (defined(SERIAL_PORT_TYPE_UART) && (SERIAL_PORT_TYPE_UART > 0U))
serial_port_uart_config_t uartConfig = {
- .instance = instance,
- .clockRate = clkSrcFreq,
- .baudRate = baudRate,
- .parityMode = kSerialManager_UartParityDisabled,
+ .instance = instance,
+ .clockRate = clkSrcFreq,
+ .baudRate = baudRate,
+ .parityMode = kSerialManager_UartParityDisabled,
.stopBitCount = kSerialManager_UartOneStopBit,
- .enableRx = 1,
- .enableTx = 1,
+ .enableRx = 1,
+ .enableTx = 1,
};
#endif
@@ -539,13 +689,21 @@ status_t DbgConsole_Init(uint8_t instance, uint32_t baudRate, serial_port_type_t
#if (defined(SERIAL_PORT_TYPE_SWO) && (SERIAL_PORT_TYPE_SWO > 0U))
serial_port_swo_config_t swoConfig = {
- .clockRate = clkSrcFreq, .baudRate = baudRate, .port = instance, .protocol = kSerialManager_SwoProtocolNrz,
+ .clockRate = clkSrcFreq,
+ .baudRate = baudRate,
+ .port = instance,
+ .protocol = kSerialManager_SwoProtocolNrz,
};
#endif
+#if (defined(SERIAL_PORT_TYPE_USBCDC_VIRTUAL) && (SERIAL_PORT_TYPE_USBCDC_VIRTUAL > 0U))
+ serial_port_usb_cdc_virtual_config_t usbCdcVirtualConfig = {
+ .controllerIndex = (serial_port_usb_cdc_virtual_controller_index_t)instance,
+ };
+#endif
serialConfig.type = device;
#if defined(DEBUG_CONSOLE_TRANSFER_NON_BLOCKING)
- serialConfig.ringBuffer = &s_debugConsoleState.readRingBuffer[0];
+ serialConfig.ringBuffer = &s_debugConsoleState.readRingBuffer[0];
serialConfig.ringBufferSize = DEBUG_CONSOLE_RECEIVE_BUFFER_LEN;
#endif
@@ -573,47 +731,59 @@ status_t DbgConsole_Init(uint8_t instance, uint32_t baudRate, serial_port_type_t
return status;
#endif
}
+ else if (kSerialPort_UsbCdcVirtual == device)
+ {
+#if (defined(SERIAL_PORT_TYPE_USBCDC_VIRTUAL) && (SERIAL_PORT_TYPE_USBCDC_VIRTUAL > 0U))
+ serialConfig.portConfig = &usbCdcVirtualConfig;
+#else
+ return status;
+#endif
+ }
else
{
return status;
}
- memset(&s_debugConsoleState, 0U, sizeof(s_debugConsoleState));
+ (void)memset(&s_debugConsoleState, 0, sizeof(s_debugConsoleState));
+
+#if defined(DEBUG_CONSOLE_TRANSFER_NON_BLOCKING)
+ s_debugConsoleState.writeRingBuffer.ringBufferSize = DEBUG_CONSOLE_TRANSMIT_BUFFER_LEN;
+#endif
s_debugConsoleState.serialHandle = (serial_handle_t)&s_debugConsoleState.serialHandleBuffer[0];
- g_serialHandle = s_debugConsoleState.serialHandle;
- status = SerialManager_Init(s_debugConsoleState.serialHandle, &serialConfig);
+ status = (status_t)SerialManager_Init(s_debugConsoleState.serialHandle, &serialConfig);
assert(kStatus_SerialManager_Success == status);
DEBUG_CONSOLE_CREATE_MUTEX_SEMAPHORE(s_debugConsoleReadSemaphore);
+#if (defined(DEBUG_CONSOLE_RX_ENABLE) && (DEBUG_CONSOLE_RX_ENABLE > 0U))
DEBUG_CONSOLE_CREATE_BINARY_SEMAPHORE(s_debugConsoleReadWaitSemaphore);
-
-#if defined(DEBUG_CONSOLE_TRANSFER_NON_BLOCKING)
- s_debugConsoleState.writeRingBuffer.ringBufferSize = DEBUG_CONSOLE_TRANSMIT_BUFFER_LEN;
#endif
{
- status = SerialManager_OpenWriteHandle(
+ status = (status_t)SerialManager_OpenWriteHandle(
s_debugConsoleState.serialHandle, ((serial_write_handle_t)&s_debugConsoleState.serialWriteHandleBuffer[0]));
assert(kStatus_SerialManager_Success == status);
#if defined(DEBUG_CONSOLE_TRANSFER_NON_BLOCKING)
- SerialManager_InstallTxCallback(((serial_write_handle_t)&s_debugConsoleState.serialWriteHandleBuffer[0]),
- DbgConsole_SerialManagerTxCallback, &s_debugConsoleState);
+ (void)SerialManager_InstallTxCallback(((serial_write_handle_t)&s_debugConsoleState.serialWriteHandleBuffer[0]),
+ DbgConsole_SerialManagerTxCallback, &s_debugConsoleState);
#endif
}
#if (defined(DEBUG_CONSOLE_RX_ENABLE) && (DEBUG_CONSOLE_RX_ENABLE > 0U))
{
- status = SerialManager_OpenReadHandle(s_debugConsoleState.serialHandle,
- ((serial_read_handle_t)&s_debugConsoleState.serialReadHandleBuffer[0]));
+ status = (status_t)SerialManager_OpenReadHandle(
+ s_debugConsoleState.serialHandle, ((serial_read_handle_t)&s_debugConsoleState.serialReadHandleBuffer[0]));
assert(kStatus_SerialManager_Success == status);
#if defined(DEBUG_CONSOLE_TRANSFER_NON_BLOCKING)
- SerialManager_InstallRxCallback(((serial_read_handle_t)&s_debugConsoleState.serialReadHandleBuffer[0]),
- DbgConsole_SerialManagerRxCallback, &s_debugConsoleState);
+ (void)SerialManager_InstallRxCallback(((serial_read_handle_t)&s_debugConsoleState.serialReadHandleBuffer[0]),
+ DbgConsole_SerialManagerRxCallback, &s_debugConsoleState);
#endif
}
#endif
+
+ g_serialHandle = s_debugConsoleState.serialHandle;
+
return kStatus_Success;
}
@@ -621,26 +791,49 @@ status_t DbgConsole_Init(uint8_t instance, uint32_t baudRate, serial_port_type_t
status_t DbgConsole_Deinit(void)
{
{
- SerialManager_CloseWriteHandle(((serial_write_handle_t)&s_debugConsoleState.serialWriteHandleBuffer[0]));
+ if (s_debugConsoleState.serialHandle != NULL)
+ {
+ (void)SerialManager_CloseWriteHandle(
+ ((serial_write_handle_t)&s_debugConsoleState.serialWriteHandleBuffer[0]));
+ }
}
#if (defined(DEBUG_CONSOLE_RX_ENABLE) && (DEBUG_CONSOLE_RX_ENABLE > 0U))
{
- SerialManager_CloseReadHandle(((serial_read_handle_t)&s_debugConsoleState.serialReadHandleBuffer[0]));
+ if (s_debugConsoleState.serialHandle != NULL)
+ {
+ (void)SerialManager_CloseReadHandle(((serial_read_handle_t)&s_debugConsoleState.serialReadHandleBuffer[0]));
+ }
+ }
+#endif
+ if (s_debugConsoleState.serialHandle)
+ {
+ if (kStatus_SerialManager_Success == SerialManager_Deinit(s_debugConsoleState.serialHandle))
+ {
+ s_debugConsoleState.serialHandle = NULL;
+ g_serialHandle = NULL;
+ }
}
+#if (defined(DEBUG_CONSOLE_RX_ENABLE) && (DEBUG_CONSOLE_RX_ENABLE > 0U))
+ DEBUG_CONSOLE_DESTROY_BINARY_SEMAPHORE(s_debugConsoleReadWaitSemaphore);
#endif
+ DEBUG_CONSOLE_DESTROY_MUTEX_SEMAPHORE(s_debugConsoleReadSemaphore);
- return kStatus_Success;
+ return (status_t)kStatus_Success;
}
+#endif /* ((SDK_DEBUGCONSOLE == DEBUGCONSOLE_REDIRECT_TO_SDK) || defined(SDK_DEBUGCONSOLE_UART)) */
-status_t DbgConsole_Flush(void)
+#if ((SDK_DEBUGCONSOLE > 0U) || \
+ ((SDK_DEBUGCONSOLE == 0U) && defined(DEBUG_CONSOLE_TRANSFER_NON_BLOCKING) && \
+ (defined(DEBUG_CONSOLE_TX_RELIABLE_ENABLE) && (DEBUG_CONSOLE_TX_RELIABLE_ENABLE > 0U))))
+DEBUG_CONSOLE_FUNCTION_PREFIX status_t DbgConsole_Flush(void)
{
#if defined(DEBUG_CONSOLE_TRANSFER_NON_BLOCKING)
-#if (DEBUG_CONSOLE_SYNCHRONIZATION_MODE == DDEBUG_CONSOLE_SYNCHRONIZATION_BM) && defined(OSA_USED)
+#if (DEBUG_CONSOLE_SYNCHRONIZATION_MODE == DEBUG_CONSOLE_SYNCHRONIZATION_BM) && defined(OSA_USED)
if (s_debugConsoleState.writeRingBuffer.ringHead != s_debugConsoleState.writeRingBuffer.ringTail)
{
- return kStatus_Fail;
+ return (status_t)kStatus_Fail;
}
#else
@@ -648,13 +841,16 @@ status_t DbgConsole_Flush(void)
while (s_debugConsoleState.writeRingBuffer.ringHead != s_debugConsoleState.writeRingBuffer.ringTail)
{
#if (DEBUG_CONSOLE_SYNCHRONIZATION_MODE == DEBUG_CONSOLE_SYNCHRONIZATION_FREERTOS)
- if (IS_RUNNING_IN_ISR() == 0U)
+ if (0U == IS_RUNNING_IN_ISR())
{
- vTaskDelay(1);
+ if (taskSCHEDULER_RUNNING == xTaskGetSchedulerState())
+ {
+ vTaskDelay(1);
+ }
}
else
{
- return kStatus_Fail;
+ return (status_t)kStatus_Fail;
}
#endif
}
@@ -662,16 +858,17 @@ status_t DbgConsole_Flush(void)
#endif
#endif
- return kStatus_Success;
+ return (status_t)kStatus_Success;
}
+#endif
#if SDK_DEBUGCONSOLE
/* See fsl_debug_console.h for documentation of this function. */
int DbgConsole_Printf(const char *formatString, ...)
{
va_list ap;
- int logLength = 0U, result = 0U;
- char printBuf[DEBUG_CONSOLE_PRINTF_MAX_LOG_LEN] = {0U};
+ int logLength = 0, dbgResult = 0;
+ char printBuf[DEBUG_CONSOLE_PRINTF_MAX_LOG_LEN] = {'\0'};
if (NULL == g_serialHandle)
{
@@ -682,37 +879,66 @@ int DbgConsole_Printf(const char *formatString, ...)
/* format print log first */
logLength = StrFormatPrintf(formatString, ap, printBuf, DbgConsole_PrintCallback);
/* print log */
- result = DbgConsole_SendData((uint8_t *)printBuf, logLength);
+ dbgResult = DbgConsole_SendDataReliable((uint8_t *)printBuf, (size_t)logLength);
va_end(ap);
- return result;
+ return dbgResult;
}
/* See fsl_debug_console.h for documentation of this function. */
int DbgConsole_Putchar(int ch)
{
/* print char */
- return DbgConsole_SendData((uint8_t *)&ch, 1U);
+ return DbgConsole_SendDataReliable((uint8_t *)&ch, 1U);
}
/* See fsl_debug_console.h for documentation of this function. */
int DbgConsole_Scanf(char *formatString, ...)
{
va_list ap;
- int result;
- char scanfBuf[DEBUG_CONSOLE_SCANF_MAX_LOG_LEN + 1U] = {0U};
+ int formatResult;
+ char scanfBuf[DEBUG_CONSOLE_SCANF_MAX_LOG_LEN + 1U] = {'\0'};
/* scanf log */
- DbgConsole_ReadLine((uint8_t *)scanfBuf, DEBUG_CONSOLE_SCANF_MAX_LOG_LEN);
+ (void)DbgConsole_ReadLine((uint8_t *)scanfBuf, DEBUG_CONSOLE_SCANF_MAX_LOG_LEN);
/* get va_list */
va_start(ap, formatString);
/* format scanf log */
- result = StrFormatScanf(scanfBuf, formatString, ap);
+ formatResult = StrFormatScanf(scanfBuf, formatString, ap);
+
+ va_end(ap);
+
+ return formatResult;
+}
+/* See fsl_debug_console.h for documentation of this function. */
+int DbgConsole_BlockingPrintf(const char *formatString, ...)
+{
+ va_list ap;
+ status_t status = (status_t)kStatus_SerialManager_Error;
+ int logLength = 0, dbgResult = 0;
+ char printBuf[DEBUG_CONSOLE_PRINTF_MAX_LOG_LEN] = {'\0'};
+
+ if (NULL == g_serialHandle)
+ {
+ return 0;
+ }
+
+ va_start(ap, formatString);
+ /* format print log first */
+ logLength = StrFormatPrintf(formatString, ap, printBuf, DbgConsole_PrintCallback);
+#if defined(DEBUG_CONSOLE_TRANSFER_NON_BLOCKING)
+ SerialManager_CancelWriting(((serial_write_handle_t)&s_debugConsoleState.serialWriteHandleBuffer[0]));
+#endif
+ /* print log */
+ status =
+ (status_t)SerialManager_WriteBlocking(((serial_write_handle_t)&s_debugConsoleState.serialWriteHandleBuffer[0]),
+ (uint8_t *)printBuf, (size_t)logLength);
+ dbgResult = (((status_t)kStatus_Success == status) ? (int)logLength : -1);
va_end(ap);
- return result;
+ return dbgResult;
}
#ifdef DEBUG_CONSOLE_TRANSFER_NON_BLOCKING
@@ -720,10 +946,15 @@ status_t DbgConsole_TryGetchar(char *ch)
{
#if (defined(DEBUG_CONSOLE_RX_ENABLE) && (DEBUG_CONSOLE_RX_ENABLE > 0U))
uint32_t length = 0;
- status_t status = kStatus_Fail;
+ status_t status = (status_t)kStatus_Fail;
assert(ch);
+ if (NULL == g_serialHandle)
+ {
+ return kStatus_Fail;
+ }
+
/* take mutex lock function */
DEBUG_CONSOLE_TAKE_MUTEX_SEMAPHORE_BLOCKING(s_debugConsoleReadSemaphore);
@@ -731,19 +962,19 @@ status_t DbgConsole_TryGetchar(char *ch)
SerialManager_TryRead(((serial_read_handle_t)&s_debugConsoleState.serialReadHandleBuffer[0]), (uint8_t *)ch, 1,
&length))
{
- if (length)
+ if (length != 0U)
{
#if DEBUG_CONSOLE_ENABLE_ECHO_FUNCTION
- DbgConsole_EchoCharacter(ch, true, NULL);
+ (void)DbgConsole_EchoCharacter((uint8_t *)ch, true, NULL);
#endif
- status = kStatus_Success;
+ status = (status_t)kStatus_Success;
}
}
/* release mutex lock function */
DEBUG_CONSOLE_GIVE_MUTEX_SEMAPHORE(s_debugConsoleReadSemaphore);
return status;
#else
- return kStatus_Fail;
+ return (status_t)kStatus_Fail;
#endif
}
#endif
@@ -754,7 +985,7 @@ int DbgConsole_Getchar(void)
uint8_t ch = 0U;
/* Get char */
- DbgConsole_ReadCharacter(&ch);
+ (void)DbgConsole_ReadCharacter(&ch);
return (int)ch;
}
@@ -784,7 +1015,7 @@ size_t __write(int handle, const unsigned char *buffer, size_t size)
}
/* Send data. */
- DbgConsole_SendData((uint8_t *)buffer, size);
+ DbgConsole_SendDataReliable((uint8_t *)buffer, size);
return size;
}
@@ -792,8 +1023,9 @@ size_t __write(int handle, const unsigned char *buffer, size_t size)
#pragma weak __read
size_t __read(int handle, unsigned char *buffer, size_t size)
{
- uint8_t ch = 0U;
- size_t actualSize = 0U;
+ uint8_t ch = 0U;
+ int actualSize = 0U;
+
/* This function only reads from "standard in", for all other file handles it returns failure. */
if (handle != 0)
{
@@ -818,9 +1050,9 @@ size_t __read(int handle, unsigned char *buffer, size_t size)
#endif /* SDK_DEBUGCONSOLE_UART */
/* support LPC Xpresso with RedLib */
-#elif(defined(__REDLIB__))
+#elif (defined(__REDLIB__))
-#if (!SDK_DEBUGCONSOLE) && (defined(SDK_DEBUGCONSOLE_UART))
+#if (defined(SDK_DEBUGCONSOLE_UART))
int __attribute__((weak)) __sys_write(int handle, char *buffer, int size)
{
if (buffer == 0)
@@ -836,7 +1068,7 @@ int __attribute__((weak)) __sys_write(int handle, char *buffer, int size)
}
/* Send data. */
- DbgConsole_SendData((uint8_t *)buffer, size);
+ DbgConsole_SendDataReliable((uint8_t *)buffer, size);
return 0;
}
@@ -876,7 +1108,7 @@ FILE __stdin;
int fputc(int ch, FILE *f)
{
/* Send data. */
- return DbgConsole_SendData((uint8_t *)(&ch), 1);
+ return DbgConsole_SendDataReliable((uint8_t *)(&ch), 1);
}
#pragma weak fgetc
@@ -908,7 +1140,7 @@ void _sys_exit(int returncode)
void _ttywrch(int ch)
{
char ench = ch;
- DbgConsole_SendData((uint8_t *)(&ench), 1);
+ DbgConsole_SendDataReliable((uint8_t *)(&ench), 1);
}
char *_sys_command_string(char *cmd, int len)
@@ -916,15 +1148,16 @@ char *_sys_command_string(char *cmd, int len)
return (cmd);
}
#endif /* SDK_DEBUGCONSOLE_UART */
+
/* These function __write and __read is used to support ARM_GCC, KDS, Atollic toolchains to printf and scanf*/
-#elif(defined(__GNUC__))
+#elif (defined(__GNUC__))
#if ((defined(__GNUC__) && (!defined(__MCUXPRESSO)) && (defined(SDK_DEBUGCONSOLE_UART))) || \
- (defined(__MCUXPRESSO) && (!SDK_DEBUGCONSOLE) && (defined(SDK_DEBUGCONSOLE_UART))))
-
+ (defined(__MCUXPRESSO) && (defined(SDK_DEBUGCONSOLE_UART))))
+int __attribute__((weak)) _write(int handle, char *buffer, int size);
int __attribute__((weak)) _write(int handle, char *buffer, int size)
{
- if (buffer == 0)
+ if (buffer == NULL)
{
/* return -1 if error. */
return -1;
@@ -937,15 +1170,16 @@ int __attribute__((weak)) _write(int handle, char *buffer, int size)
}
/* Send data. */
- DbgConsole_SendData((uint8_t *)buffer, size);
+ (void)DbgConsole_SendDataReliable((uint8_t *)buffer, (size_t)size);
return size;
}
+int __attribute__((weak)) _read(int handle, char *buffer, int size);
int __attribute__((weak)) _read(int handle, char *buffer, int size)
{
- uint8_t ch = 0U;
- int actualSize = 0U;
+ uint8_t ch = 0U;
+ int actualSize = 0;
/* This function only reads from "standard in", for all other file handles it returns failure. */
if (handle != 0)
@@ -953,20 +1187,25 @@ int __attribute__((weak)) _read(int handle, char *buffer, int size)
return -1;
}
+ /* Receive data. */
for (; size > 0; size--)
{
- DbgConsole_ReadCharacter(&ch);
+ if (DbgConsole_ReadCharacter(&ch) < 0)
+ {
+ break;
+ }
- *buffer++ = ch;
+ *buffer++ = (char)ch;
actualSize++;
- if ((ch == 0) || (ch == '\n') || (ch == '\r'))
+ if ((ch == 0U) || (ch == (uint8_t)'\n') || (ch == (uint8_t)'\r'))
{
break;
}
}
- return actualSize;
+ return (actualSize > 0) ? actualSize : -1;
}
#endif
+
#endif /* __ICCARM__ */
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_debug_console.h b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_debug_console.h
index 252834355..ec50606a5 100644
--- a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_debug_console.h
+++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_debug_console.h
@@ -34,24 +34,20 @@
* Definitions
******************************************************************************/
+extern serial_handle_t g_serialHandle; /*!< serial manager handle */
+
/*! @brief Definition select redirect toolchain printf, scanf to uart or not. */
#define DEBUGCONSOLE_REDIRECT_TO_TOOLCHAIN 0U /*!< Select toolchain printf and scanf. */
#define DEBUGCONSOLE_REDIRECT_TO_SDK 1U /*!< Select SDK version printf, scanf. */
#define DEBUGCONSOLE_DISABLE 2U /*!< Disable debugconsole function. */
-/*! @brief Definition to select sdk or toolchain printf, scanf. */
+/*! @brief Definition to select sdk or toolchain printf, scanf. The macro only support
+ * to be redefined in project setting.
+ */
#ifndef SDK_DEBUGCONSOLE
#define SDK_DEBUGCONSOLE 1U
#endif
-/*! @brief Definition to select redirect toolchain printf, scanf to uart or not. */
-#ifndef SDK_DEBUGCONSOLE_UART
-/* mcux will handle this macro, not define it here */
-#if (!defined(__MCUXPRESSO))
-#define SDK_DEBUGCONSOLE_UART
-#endif
-#endif
-
#if defined(SDK_DEBUGCONSOLE) && !(SDK_DEBUGCONSOLE)
#include <stdio.h>
#endif
@@ -61,7 +57,7 @@
* if SDK_DEBUGCONSOLE defined to 0,it represents select toolchain printf, scanf.
* if SDK_DEBUGCONSOLE defined to 1,it represents select SDK version printf, scanf.
* if SDK_DEBUGCONSOLE defined to 2,it represents disable debugconsole function.
-*/
+ */
#if SDK_DEBUGCONSOLE == DEBUGCONSOLE_DISABLE /* Disable debug console */
#define PRINTF
#define SCANF
@@ -73,7 +69,7 @@
#define PUTCHAR DbgConsole_Putchar
#define GETCHAR DbgConsole_Getchar
#elif SDK_DEBUGCONSOLE == DEBUGCONSOLE_REDIRECT_TO_TOOLCHAIN /* Select printf, scanf, putchar, getchar of toolchain. \ \
- */
+ */
#define PRINTF printf
#define SCANF scanf
#define PUTCHAR putchar
@@ -91,6 +87,7 @@ extern "C" {
/*! @name Initialization*/
/* @{ */
+#if ((SDK_DEBUGCONSOLE == DEBUGCONSOLE_REDIRECT_TO_SDK) || defined(SDK_DEBUGCONSOLE_UART))
/*!
* @brief Initializes the peripheral used for debug messages.
*
@@ -102,7 +99,8 @@ extern "C" {
* @param baudRate The desired baud rate in bits per second.
* @param device Low level device type for the debug console, can be one of the following.
* @arg kSerialPort_Uart,
- * @arg kSerialPort_UsbCdc.
+ * @arg kSerialPort_UsbCdc
+ * @arg kSerialPort_UsbCdcVirtual.
* @param clkSrcFreq Frequency of peripheral source clock.
*
* @return Indicates whether initialization was successful or not.
@@ -119,6 +117,31 @@ status_t DbgConsole_Init(uint8_t instance, uint32_t baudRate, serial_port_type_t
* @return Indicates whether de-initialization was successful or not.
*/
status_t DbgConsole_Deinit(void);
+#else
+/*!
+ * Use an error to replace the DbgConsole_Init when SDK_DEBUGCONSOLE is not DEBUGCONSOLE_REDIRECT_TO_SDK and
+ * SDK_DEBUGCONSOLE_UART is not defined.
+ */
+static inline status_t DbgConsole_Init(uint8_t instance,
+ uint32_t baudRate,
+ serial_port_type_t device,
+ uint32_t clkSrcFreq)
+{
+ (void)instance;
+ (void)baudRate;
+ (void)device;
+ (void)clkSrcFreq;
+ return (status_t)kStatus_Fail;
+}
+/*!
+ * Use an error to replace the DbgConsole_Deinit when SDK_DEBUGCONSOLE is not DEBUGCONSOLE_REDIRECT_TO_SDK and
+ * SDK_DEBUGCONSOLE_UART is not defined.
+ */
+static inline status_t DbgConsole_Deinit(void)
+{
+ return (status_t)kStatus_Fail;
+}
+#endif /* ((SDK_DEBUGCONSOLE == DEBUGCONSOLE_REDIRECT_TO_SDK) || defined(SDK_DEBUGCONSOLE_UART)) */
#if SDK_DEBUGCONSOLE
/*!
@@ -173,6 +196,19 @@ int DbgConsole_Scanf(char *formatString, ...);
int DbgConsole_Getchar(void);
/*!
+ * @brief Writes formatted output to the standard output stream with the blocking mode.
+ *
+ * Call this function to write a formatted output to the standard output stream with the blocking mode.
+ * The function will send data with blocking mode no matter the DEBUG_CONSOLE_TRANSFER_NON_BLOCKING set
+ * or not.
+ * The function could be used in system ISR mode with DEBUG_CONSOLE_TRANSFER_NON_BLOCKING set.
+ *
+ * @param formatString Format control string.
+ * @return Returns the number of characters printed or a negative value if an error occurs.
+ */
+int DbgConsole_BlockingPrintf(const char *formatString, ...);
+
+/*!
* @brief Debug console flush.
*
* Call this function to wait the tx buffer empty.
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_debug_console_conf.h b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_debug_console_conf.h
index fa6cdae82..4c36a7dd8 100644
--- a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_debug_console_conf.h
+++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_debug_console_conf.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 - 2018 NXP
+ * Copyright 2017 - 2019 NXP
* All rights reserved.
*
*
@@ -11,82 +11,99 @@
/****************Debug console configuration********************/
/*! @brief If Non-blocking mode is needed, please define it at project setting,
-* otherwise blocking mode is the default transfer mode.
-* Warning: If you want to use non-blocking transfer,please make sure the corresponding
-* IO interrupt is enable, otherwise there is no output.
-* And non-blocking is combine with buffer, no matter bare-metal or rtos.
-*/
+ * otherwise blocking mode is the default transfer mode.
+ * Warning: If you want to use non-blocking transfer,please make sure the corresponding
+ * IO interrupt is enable, otherwise there is no output.
+ * And non-blocking is combine with buffer, no matter bare-metal or rtos.
+ * Below shows how to configure in your project if you want to use non-blocking mode.
+ * For IAR, right click project and select "Options", define it in "C/C++ Compiler->Preprocessor->Defined symbols".
+ * For KEIL, click "Options for Target…", define it in "C/C++->Preprocessor Symbols->Define".
+ * For ARMGCC, open CmakeLists.txt and add the following lines,
+ * "SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG_CONSOLE_TRANSFER_NON_BLOCKING")" for debug target.
+ * "SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DDEBUG_CONSOLE_TRANSFER_NON_BLOCKING")" for release target.
+ * For MCUxpresso, right click project and select "Properties", define it in "C/C++ Build->Settings->MCU C
+ * Complier->Preprocessor".
+ *
+ */
#ifdef DEBUG_CONSOLE_TRANSFER_NON_BLOCKING
/*! @brief define the transmit buffer length which is used to store the multi task log, buffer is enabled automatically
-* when
-* non-blocking transfer is using,
-* This value will affect the RAM's ultilization, should be set per paltform's capability and software requirement.
-* If it is configured too small, log maybe missed , because the log will not be
-* buffered if the buffer is full, and the print will return immediately with -1.
-* And this value should be multiple of 4 to meet memory alignment.
-*
-*/
+ * when
+ * non-blocking transfer is using,
+ * This value will affect the RAM's ultilization, should be set per paltform's capability and software requirement.
+ * If it is configured too small, log maybe missed , because the log will not be
+ * buffered if the buffer is full, and the print will return immediately with -1.
+ * And this value should be multiple of 4 to meet memory alignment.
+ *
+ */
#ifndef DEBUG_CONSOLE_TRANSMIT_BUFFER_LEN
#define DEBUG_CONSOLE_TRANSMIT_BUFFER_LEN (512U)
#endif /* DEBUG_CONSOLE_TRANSMIT_BUFFER_LEN */
/*! @brief define the receive buffer length which is used to store the user input, buffer is enabled automatically when
-* non-blocking transfer is using,
-* This value will affect the RAM's ultilization, should be set per paltform's capability and software requirement.
-* If it is configured too small, log maybe missed, because buffer will be overwrited if buffer is too small.
-* And this value should be multiple of 4 to meet memory alignment.
-*
-*/
+ * non-blocking transfer is using,
+ * This value will affect the RAM's ultilization, should be set per paltform's capability and software requirement.
+ * If it is configured too small, log maybe missed, because buffer will be overwrited if buffer is too small.
+ * And this value should be multiple of 4 to meet memory alignment.
+ *
+ */
#ifndef DEBUG_CONSOLE_RECEIVE_BUFFER_LEN
-#define DEBUG_CONSOLE_RECEIVE_BUFFER_LEN (512U)
+#define DEBUG_CONSOLE_RECEIVE_BUFFER_LEN (1024U)
#endif /* DEBUG_CONSOLE_RECEIVE_BUFFER_LEN */
+/*!@ brief Whether enable the reliable TX function
+ * If the macro is zero, the reliable TX function of the debug console is disabled.
+ * When the macro is zero, the string of PRINTF will be thrown away after the transmit buffer is full.
+ */
+#ifndef DEBUG_CONSOLE_TX_RELIABLE_ENABLE
+#define DEBUG_CONSOLE_TX_RELIABLE_ENABLE (1U)
+#endif /* DEBUG_CONSOLE_RX_ENABLE */
+
#else
#define DEBUG_CONSOLE_TRANSFER_BLOCKING
#endif /* DEBUG_CONSOLE_TRANSFER_NON_BLOCKING */
/*!@ brief Whether enable the RX function
-* If the macro is zero, the receive function of the debug console is disabled.
-*/
+ * If the macro is zero, the receive function of the debug console is disabled.
+ */
#ifndef DEBUG_CONSOLE_RX_ENABLE
#define DEBUG_CONSOLE_RX_ENABLE (1U)
#endif /* DEBUG_CONSOLE_RX_ENABLE */
/*!@ brief define the MAX log length debug console support , that is when you call printf("log", x);, the log
-* length can not bigger than this value.
-* This macro decide the local log buffer length, the buffer locate at stack, the stack maybe overflow if
-* the buffer is too big and current task stack size not big enough.
-*/
+ * length can not bigger than this value.
+ * This macro decide the local log buffer length, the buffer locate at stack, the stack maybe overflow if
+ * the buffer is too big and current task stack size not big enough.
+ */
#ifndef DEBUG_CONSOLE_PRINTF_MAX_LOG_LEN
#define DEBUG_CONSOLE_PRINTF_MAX_LOG_LEN (128U)
#endif /* DEBUG_CONSOLE_PRINTF_MAX_LOG_LEN */
/*!@ brief define the buffer support buffer scanf log length, that is when you call scanf("log", &x);, the log
-* length can not bigger than this value.
-* As same as the DEBUG_CONSOLE_BUFFER_PRINTF_MAX_LOG_LEN.
-*/
+ * length can not bigger than this value.
+ * As same as the DEBUG_CONSOLE_BUFFER_PRINTF_MAX_LOG_LEN.
+ */
#ifndef DEBUG_CONSOLE_SCANF_MAX_LOG_LEN
#define DEBUG_CONSOLE_SCANF_MAX_LOG_LEN (20U)
#endif /* DEBUG_CONSOLE_SCANF_MAX_LOG_LEN */
/*! @brief Debug console synchronization
-* User should not change these macro for synchronization mode, but add the
-* corresponding synchronization mechanism per different software environment.
-* Such as, if another RTOS is used,
-* add:
-* #define DEBUG_CONSOLE_SYNCHRONIZATION_XXXX 3
-* in this configuration file and implement the synchronization in fsl.log.c.
-*/
+ * User should not change these macro for synchronization mode, but add the
+ * corresponding synchronization mechanism per different software environment.
+ * Such as, if another RTOS is used,
+ * add:
+ * #define DEBUG_CONSOLE_SYNCHRONIZATION_XXXX 3
+ * in this configuration file and implement the synchronization in fsl.log.c.
+ */
/*! @brief synchronization for baremetal software */
#define DEBUG_CONSOLE_SYNCHRONIZATION_BM 0
/*! @brief synchronization for freertos software */
#define DEBUG_CONSOLE_SYNCHRONIZATION_FREERTOS 1
/*! @brief RTOS synchronization mechanism disable
-* If not defined, default is enable, to avoid multitask log print mess.
-* If other RTOS is used, you can implement the RTOS's specific synchronization mechanism in fsl.log.c
-* If synchronization is disabled, log maybe messed on terminal.
-*/
+ * If not defined, default is enable, to avoid multitask log print mess.
+ * If other RTOS is used, you can implement the RTOS's specific synchronization mechanism in fsl.log.c
+ * If synchronization is disabled, log maybe messed on terminal.
+ */
#ifndef DEBUG_CONSOLE_DISABLE_RTOS_SYNCHRONIZATION
#ifdef DEBUG_CONSOLE_TRANSFER_NON_BLOCKING
#ifdef FSL_RTOS_FREE_RTOS
@@ -100,9 +117,9 @@
#endif /* DEBUG_CONSOLE_DISABLE_RTOS_SYNCHRONIZATION */
/*! @brief echo function support
-* If you want to use the echo function,please define DEBUG_CONSOLE_ENABLE_ECHO
-* at your project setting.
-*/
+ * If you want to use the echo function,please define DEBUG_CONSOLE_ENABLE_ECHO
+ * at your project setting.
+ */
#ifndef DEBUG_CONSOLE_ENABLE_ECHO
#define DEBUG_CONSOLE_ENABLE_ECHO_FUNCTION 0
#else
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_str.c b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_str.c
index 5d4831ed2..1a49a45e9 100644
--- a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_str.c
+++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/utilities/fsl_str.c
@@ -25,14 +25,14 @@
/*! @brief Specification modifier flags for printf. */
enum _debugconsole_printf_flag
{
- kPRINTF_Minus = 0x01U, /*!< Minus FLag. */
- kPRINTF_Plus = 0x02U, /*!< Plus Flag. */
- kPRINTF_Space = 0x04U, /*!< Space Flag. */
- kPRINTF_Zero = 0x08U, /*!< Zero Flag. */
- kPRINTF_Pound = 0x10U, /*!< Pound Flag. */
- kPRINTF_LengthChar = 0x20U, /*!< Length: Char Flag. */
- kPRINTF_LengthShortInt = 0x40U, /*!< Length: Short Int Flag. */
- kPRINTF_LengthLongInt = 0x80U, /*!< Length: Long Int Flag. */
+ kPRINTF_Minus = 0x01U, /*!< Minus FLag. */
+ kPRINTF_Plus = 0x02U, /*!< Plus Flag. */
+ kPRINTF_Space = 0x04U, /*!< Space Flag. */
+ kPRINTF_Zero = 0x08U, /*!< Zero Flag. */
+ kPRINTF_Pound = 0x10U, /*!< Pound Flag. */
+ kPRINTF_LengthChar = 0x20U, /*!< Length: Char Flag. */
+ kPRINTF_LengthShortInt = 0x40U, /*!< Length: Short Int Flag. */
+ kPRINTF_LengthLongInt = 0x80U, /*!< Length: Long Int Flag. */
kPRINTF_LengthLongLongInt = 0x100U, /*!< Length: Long Long Int Flag. */
};
#endif /* PRINTF_ADVANCED_ENABLE */
@@ -40,18 +40,18 @@ enum _debugconsole_printf_flag
/*! @brief Specification modifier flags for scanf. */
enum _debugconsole_scanf_flag
{
- kSCANF_Suppress = 0x2U, /*!< Suppress Flag. */
- kSCANF_DestMask = 0x7cU, /*!< Destination Mask. */
- kSCANF_DestChar = 0x4U, /*!< Destination Char Flag. */
+ kSCANF_Suppress = 0x2U, /*!< Suppress Flag. */
+ kSCANF_DestMask = 0x7cU, /*!< Destination Mask. */
+ kSCANF_DestChar = 0x4U, /*!< Destination Char Flag. */
kSCANF_DestString = 0x8U, /*!< Destination String FLag. */
- kSCANF_DestSet = 0x10U, /*!< Destination Set Flag. */
- kSCANF_DestInt = 0x20U, /*!< Destination Int Flag. */
- kSCANF_DestFloat = 0x30U, /*!< Destination Float Flag. */
+ kSCANF_DestSet = 0x10U, /*!< Destination Set Flag. */
+ kSCANF_DestInt = 0x20U, /*!< Destination Int Flag. */
+ kSCANF_DestFloat = 0x30U, /*!< Destination Float Flag. */
kSCANF_LengthMask = 0x1f00U, /*!< Length Mask Flag. */
#if SCANF_ADVANCED_ENABLE
- kSCANF_LengthChar = 0x100U, /*!< Length Char Flag. */
- kSCANF_LengthShortInt = 0x200U, /*!< Length ShortInt Flag. */
- kSCANF_LengthLongInt = 0x400U, /*!< Length LongInt Flag. */
+ kSCANF_LengthChar = 0x100U, /*!< Length Char Flag. */
+ kSCANF_LengthShortInt = 0x200U, /*!< Length ShortInt Flag. */
+ kSCANF_LengthLongInt = 0x400U, /*!< Length LongInt Flag. */
kSCANF_LengthLongLongInt = 0x800U, /*!< Length LongLongInt Flag. */
#endif /* SCANF_ADVANCED_ENABLE */
#if SCANF_FLOAT_ENABLE
@@ -104,7 +104,7 @@ static int32_t ConvertFloatRadixNumToString(char *numstr, void *nump, int32_t ra
#endif /* PRINTF_FLOAT_ENABLE */
/*!
-*
+ *
*/
double modf(double input_dbl, double *intpart_ptr);
@@ -148,8 +148,8 @@ static int32_t ConvertRadixNumToString(char *numstr, void *nump, int32_t neg, in
int32_t nlen;
char *nstrp;
- nlen = 0;
- nstrp = numstr;
+ nlen = 0;
+ nstrp = numstr;
*nstrp++ = '\0';
if (neg)
@@ -173,7 +173,7 @@ static int32_t ConvertRadixNumToString(char *numstr, void *nump, int32_t neg, in
if (c < 0)
{
uc = (uint64_t)c;
- c = (int64_t)(~uc) + 1 + '0';
+ c = (int64_t)(~uc) + 1 + '0';
}
#else
b = a / radix;
@@ -181,14 +181,14 @@ static int32_t ConvertRadixNumToString(char *numstr, void *nump, int32_t neg, in
if (c < 0)
{
uc = (uint32_t)c;
- c = (uint32_t)(~uc) + 1 + '0';
+ c = (uint32_t)(~uc) + 1 + '0';
}
#endif /* PRINTF_ADVANCED_ENABLE */
else
{
c = c + '0';
}
- a = b;
+ a = b;
*nstrp++ = (char)c;
++nlen;
}
@@ -224,7 +224,7 @@ static int32_t ConvertRadixNumToString(char *numstr, void *nump, int32_t neg, in
{
uc = uc - 10 + (use_caps ? 'A' : 'a');
}
- ua = ub;
+ ua = ub;
*nstrp++ = (char)uc;
++nlen;
}
@@ -249,10 +249,10 @@ static int32_t ConvertFloatRadixNumToString(char *numstr, void *nump, int32_t ra
int32_t nlen;
char *nstrp;
- nlen = 0;
- nstrp = numstr;
+ nlen = 0;
+ nstrp = numstr;
*nstrp++ = '\0';
- r = *(double *)nump;
+ r = *(double *)nump;
if (!r)
{
*nstrp = '0';
@@ -285,17 +285,17 @@ static int32_t ConvertFloatRadixNumToString(char *numstr, void *nump, int32_t ra
{
fb = fa / (int32_t)radix;
dc = (fa - (int64_t)fb * (int32_t)radix);
- c = (int32_t)dc;
+ c = (int32_t)dc;
if (c < 0)
{
uc = (uint32_t)c;
- c = (int32_t)(~uc) + 1 + '0';
+ c = (int32_t)(~uc) + 1 + '0';
}
else
{
c = c + '0';
}
- fa = fb;
+ fa = fb;
*nstrp++ = (char)c;
++nlen;
}
@@ -316,13 +316,13 @@ static int32_t ConvertFloatRadixNumToString(char *numstr, void *nump, int32_t ra
if (c < 0)
{
uc = (uint32_t)c;
- c = (int32_t)(~uc) + 1 + '0';
+ c = (int32_t)(~uc) + 1 + '0';
}
else
{
c = c + '0';
}
- a = b;
+ a = b;
*nstrp++ = (char)c;
++nlen;
}
@@ -351,7 +351,7 @@ int StrFormatPrintf(const char *fmt, va_list ap, char *buf, printfCb cb)
int32_t c;
char vstr[33];
- char *vstrp = NULL;
+ char *vstrp = NULL;
int32_t vlen = 0;
int32_t done;
@@ -400,7 +400,7 @@ int StrFormatPrintf(const char *fmt, va_list ap, char *buf, printfCb cb)
#if PRINTF_ADVANCED_ENABLE
/* First check for specification modifier flags. */
flags_used = 0;
- done = false;
+ done = false;
while (!done)
{
switch (*++p)
@@ -431,7 +431,7 @@ int StrFormatPrintf(const char *fmt, va_list ap, char *buf, printfCb cb)
/* Next check for minimum field width. */
field_width = 0;
- done = false;
+ done = false;
while (!done)
{
c = *++p;
@@ -461,7 +461,7 @@ int StrFormatPrintf(const char *fmt, va_list ap, char *buf, printfCb cb)
{
/* Must get precision field width, if present. */
precision_width = 0;
- done = false;
+ done = false;
while (!done)
{
c = *++p;
@@ -475,7 +475,7 @@ int StrFormatPrintf(const char *fmt, va_list ap, char *buf, printfCb cb)
#if PRINTF_ADVANCED_ENABLE
else if (c == '*')
{
- precision_width = (uint32_t)va_arg(ap, uint32_t);
+ precision_width = (uint32_t)va_arg(ap, uint32_t);
valid_precision_width = true;
}
#endif /* PRINTF_ADVANCED_ENABLE */
@@ -544,7 +544,7 @@ int StrFormatPrintf(const char *fmt, va_list ap, char *buf, printfCb cb)
{
ival = (int32_t)va_arg(ap, int32_t);
}
- vlen = ConvertRadixNumToString(vstr, &ival, true, 10, use_caps);
+ vlen = ConvertRadixNumToString(vstr, &ival, true, 10, use_caps);
vstrp = &vstr[vlen];
#if PRINTF_ADVANCED_ENABLE
if (ival < 0)
@@ -608,8 +608,8 @@ int StrFormatPrintf(const char *fmt, va_list ap, char *buf, printfCb cb)
#if PRINTF_FLOAT_ENABLE
if ((c == 'f') || (c == 'F'))
{
- fval = (double)va_arg(ap, double);
- vlen = ConvertFloatRadixNumToString(vstr, &fval, 10, precision_width);
+ fval = (double)va_arg(ap, double);
+ vlen = ConvertFloatRadixNumToString(vstr, &fval, 10, precision_width);
vstrp = &vstr[vlen];
#if PRINTF_ADVANCED_ENABLE
@@ -684,7 +684,7 @@ int StrFormatPrintf(const char *fmt, va_list ap, char *buf, printfCb cb)
{
uval = (uint32_t)va_arg(ap, uint32_t);
}
- vlen = ConvertRadixNumToString(vstr, &uval, false, 16, use_caps);
+ vlen = ConvertRadixNumToString(vstr, &uval, false, 16, use_caps);
vstrp = &vstr[vlen];
#if PRINTF_ADVANCED_ENABLE
@@ -756,7 +756,7 @@ int StrFormatPrintf(const char *fmt, va_list ap, char *buf, printfCb cb)
radix = 10;
}
- vlen = ConvertRadixNumToString(vstr, &uval, false, radix, use_caps);
+ vlen = ConvertRadixNumToString(vstr, &uval, false, radix, use_caps);
vstrp = &vstr[vlen];
#if PRINTF_ADVANCED_ENABLE
if (flags_used & kPRINTF_Zero)
@@ -932,9 +932,9 @@ int StrFormatScanf(const char *line_ptr, char *format, va_list args_ptr)
/* convernsion specification */
c++;
/* Reset. */
- flag = 0;
+ flag = 0;
field_width = 0;
- base = 0;
+ base = 0;
/* Loop to get full conversion specification. */
while ((*c) && (!(flag & kSCANF_DestMask)))
@@ -1093,7 +1093,7 @@ int StrFormatScanf(const char *line_ptr, char *format, va_list args_ptr)
switch (flag & kSCANF_DestMask)
{
case kSCANF_DestChar:
- s = (const char *)p;
+ s = (const char *)p;
buf = va_arg(args_ptr, char *);
while ((field_width--) && (*p))
{
@@ -1115,7 +1115,7 @@ int StrFormatScanf(const char *line_ptr, char *format, va_list args_ptr)
break;
case kSCANF_DestString:
n_decode += ScanIgnoreWhiteSpace(&p);
- s = p;
+ s = p;
buf = va_arg(args_ptr, char *);
while ((field_width--) && (*p != '\0') && (*p != ' ') && (*p != '\t') && (*p != '\n') &&
(*p != '\r') && (*p != '\v') && (*p != '\f'))
@@ -1140,7 +1140,7 @@ int StrFormatScanf(const char *line_ptr, char *format, va_list args_ptr)
break;
case kSCANF_DestInt:
n_decode += ScanIgnoreWhiteSpace(&p);
- s = p;
+ s = p;
val = 0;
if ((base == 0) || (base == 16))
{