Hi,
I'm curious to know about the design pattern used in the Kinetis SDK examples so that I can customize the code easily. For example in the bootloader code, all the interfaces defined by structures, implementations are mapped in various .c files (memory.c, bl_tree_root.c, property_kinetis.c) and then called in bl_main.c
Where can I find more information about design patterns used in Kinetis SDK examples and any best practices for NXP Kinetis MCUs?
example -
In bl_context.c
bootloader_context_t g_bootloaderContext = {.memoryInterface = &g_memoryInterface,
.memoryMap = g_memoryMap,
#if BL_FEATURE_EXPAND_MEMORY
.externalMemoryMap = g_externalMemoryMap,
#endif // BL_FEATURE_EXPAND_MEMORY
.allPeripherals = g_peripherals,
.activePeripheral = NULL, // Filled in at run time.
.propertyInterface = &g_propertyInterface,
.commandInterface = &g_commandInterface,
#if !BL_FEATURE_HAS_NO_INTERNAL_FLASH
.flashDriverInterface = &g_flashDriverInterface,
#if !BL_DEVICE_IS_LPC_SERIES
.allFlashState = &g_flashState,
.allFlashCacheState = &g_flashcacheState,
#if BL_FEATURE_SUPPORT_DFLASH
.dflashDriverInterface = &g_dflashDriverInterface,
.dFlashState = &g_dflashState,
#endif // BL_FEATURE_SUPPORT_DFLASH
#else
.allFlashState = g_flashState,
#endif // !BL_DEVICE_IS_LPC_SERIES
#endif // #if !BL_FEATURE_HAS_NO_INTERNAL_FLASH
#if AES_SECURITY_SUPPORTED
.aesInterface = &g_aesInterface,
#endif
};
In bl_main.c
// Init the active peripheral.
if (g_bootloaderContext.activePeripheral->byteInterface &&
g_bootloaderContext.activePeripheral->byteInterface->init)
{
g_bootloaderContext.activePeripheral->byteInterface->init(g_bootloaderContext.activePeripheral);
}
if (g_bootloaderContext.activePeripheral->packetInterface &&
g_bootloaderContext.activePeripheral->packetInterface->init)
{
g_bootloaderContext.activePeripheral->packetInterface->init(g_bootloaderContext.activePeripheral);
}
Thank you in advance.
Hello
This information can be found on the SDK documentation. You can download this at this page: https://mcuxpresso.nxp.com/en/welcome.
Let me know if this is helpful, if you have more questions do not hesitate to ask me.
Best regards,
Omar