Skip to content

Commit

Permalink
[nxp][examples][mcxw71_k32w1] Add platform/CHIPDeviceBuildConfig.h (#…
Browse files Browse the repository at this point in the history
…36482)

* [nxp][examples][mcxw71_k32w1] Include platform/CHIPDeviceConfig.h in FreeRtosHooks.cpp

 * this will include the CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR macro allowing	OTAIdleActivities
   to be called during ota.
 * Switch FreeRtosHooks.c to FreeRtosHooks.cpp
 * Add extern to functions

Signed-off-by: Andrei Menzopol <[email protected]>

* Restyled by whitespace

* Restyled by clang-format

* Restyled by gn

---------

Signed-off-by: Andrei Menzopol <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
andrei-menzopol and restyled-commits authored Nov 14, 2024
1 parent dac4a53 commit 9a68d62
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
13 changes: 9 additions & 4 deletions examples/platform/nxp/mcxw71_k32w1/app/support/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ config("support_config") {

source_set("freertos_memory_utils") {
sources = [
"FreeRtosHooks.c",
"FreeRtosHooks.h",
"FreeRtosHooks.cpp",
"Memconfig.cpp",
]

deps = [ "${chip_root}/src/lib/support" ]
deps = [
"${chip_root}/src/lib/support",
"${chip_root}/src/platform:platform_config_header",
]

cflags = [ "-Wconversion" ]

Expand All @@ -57,5 +59,8 @@ source_set("freertos_memory_utils") {
defines = [ "CHIP_PLAT_NVM_SUPPORT=3" ]
}

public_configs = [ ":support_config" ]
public_configs = [
":support_config",
"${chip_root}/src:includes",
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#include <stdio.h>
#include <string.h>

/* Include CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR */
#include <platform/CHIPDeviceConfig.h>

#if (CHIP_PLAT_NVM_SUPPORT == 1)
#include "NVM_Interface.h"
#elif (CHIP_PLAT_NVM_SUPPORT == 3)
Expand Down Expand Up @@ -55,6 +58,8 @@
#define APP_DBG_LOG(...)
#endif

extern "C" {

static inline void mutex_init(mbedtls_threading_mutex_t * p_mutex)
{
assert(p_mutex != NULL);
Expand All @@ -73,7 +78,7 @@ static inline int mutex_lock(mbedtls_threading_mutex_t * p_mutex)
{
assert(p_mutex != NULL);
assert(*p_mutex != NULL);
return xSemaphoreTake(*p_mutex, portMAX_DELAY) != pdTRUE;
return xSemaphoreTake((SemaphoreHandle_t) (*p_mutex), portMAX_DELAY) != pdTRUE;
}

static inline int mutex_unlock(mbedtls_threading_mutex_t * p_mutex)
Expand Down Expand Up @@ -153,3 +158,5 @@ void vApplicationIdleHook(void)
OTAIdleActivities();
#endif
}

} // extern "C"
12 changes: 5 additions & 7 deletions examples/platform/nxp/mcxw71_k32w1/app/support/FreeRtosHooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@

typedef void * mbedtls_threading_mutex_t;

extern void mbedtls_threading_set_alt(void (*mutex_init)(mbedtls_threading_mutex_t *),
void (*mutex_free)(mbedtls_threading_mutex_t *),
int (*mutex_lock)(mbedtls_threading_mutex_t *),
int (*mutex_unlock)(mbedtls_threading_mutex_t *));

extern void mbedtls_threading_free_alt(void);

#ifdef __cplusplus
extern "C" {
#endif

void mbedtls_threading_set_alt(void (*mutex_init)(mbedtls_threading_mutex_t *), void (*mutex_free)(mbedtls_threading_mutex_t *),
int (*mutex_lock)(mbedtls_threading_mutex_t *), int (*mutex_unlock)(mbedtls_threading_mutex_t *));

void mbedtls_threading_free_alt(void);

/**@brief Function for initializing alternative MbedTLS mutexes to enable the usage of the FreeRTOS implementation. */
void freertos_mbedtls_mutex_init(void);

Expand Down

0 comments on commit 9a68d62

Please sign in to comment.