Skip to content

Commit

Permalink
[K32W] Improve debugging + CPU speed
Browse files Browse the repository at this point in the history
Add a timestamp for platform logging. Also increase the CPU speed
from 32Mhz to 48Mhz.

Signed-off-by: Doru Gucea <doru-cristian.gucea@nxp.com>
  • Loading branch information
doru91 committed Jun 17, 2021
1 parent 7b60dc2 commit f64ddd1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void GenericPlatformManagerImpl<ImplClass>::_DispatchEvent(const ChipDeviceEvent
uint32_t delta = (static_cast<uint32_t>(System::Layer::GetClock_MonotonicHiRes() - startUS)) / 1000;
if (delta > 100)
{
ChipLogError(DeviceLayer, "Long dispatch time: %" PRId32 " ms", delta);
ChipLogError(DeviceLayer, "Long dispatch time: %" PRId32 " ms, for event type %d", delta, event->Type);
}
#endif // CHIP_PROGRESS_LOGGING
}
Expand Down
17 changes: 10 additions & 7 deletions src/platform/K32W/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,29 @@
static bool isLogInitialized;
extern uint8_t gOtLogUartInstance;
extern "C" void K32WWriteBlocking(const uint8_t * aBuf, uint32_t len);
extern "C" uint32_t otPlatAlarmMilliGetNow(void);

namespace chip {
namespace Logging {
namespace Platform {

void GetMessageString(char * buf, uint8_t chipCategory, uint8_t otLevelLog)
{
sprintf(buf, "[%lu]", otPlatAlarmMilliGetNow());

if (chipCategory != kLogCategory_None)
{
switch (chipCategory)
{
case kLogCategory_Error:
memcpy(buf, "[Error]", 7);
memcpy(buf + strlen(buf), "[Error]", 7);
break;
case kLogCategory_Progress:
default:
memcpy(buf, "[Progress]", 10);
memcpy(buf + strlen(buf), "[Progress]", 10);
break;
case kLogCategory_Detail:
memcpy(buf, "[Debug]", 7);
memcpy(buf + strlen(buf), "[Debug]", 7);
break;
}
}
Expand All @@ -50,18 +53,18 @@ void GetMessageString(char * buf, uint8_t chipCategory, uint8_t otLevelLog)
switch (otLevelLog)
{
case OT_LOG_LEVEL_CRIT:
memcpy(buf, "[Error]", 7);
memcpy(buf + strlen(buf), "[Error]", 7);
break;
case OT_LOG_LEVEL_WARN:
memcpy(buf, "[Warn]", 6);
memcpy(buf + strlen(buf), "[Warn]", 6);
break;
case OT_LOG_LEVEL_NOTE:
case OT_LOG_LEVEL_INFO:
default:
memcpy(buf, "[Info]", 6);
memcpy(buf + strlen(buf), "[Info]", 6);
break;
case OT_LOG_LEVEL_DEBG:
memcpy(buf, "[Debug]", 7);
memcpy(buf + strlen(buf), "[Debug]", 7);
break;
}
}
Expand Down
1 change: 1 addition & 0 deletions third_party/k32w_sdk/k32w_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ template("k32w_sdk") {
]

defines = [
"gPWR_CpuClk_48MHz=1",
"gMainThreadPriority_c=6",
"CPU_K32W061HN",
"CPU_JN518X",
Expand Down

0 comments on commit f64ddd1

Please sign in to comment.