platform-ch32v icon indicating copy to clipboard operation
platform-ch32v copied to clipboard

Can make custom template noneos-sdk on new project ?

Open Witawat opened this issue 2 years ago • 1 comments

Can make custom template noneos-sdk on new project ?

i need make custom template on new project have some file and function not have int main(){ } only ?

Witawat avatar Nov 04 '23 04:11 Witawat

The PlatformIO core does not directly support a platform providing a "new project" template: https://github.com/platformio/platformio-core/issues/446

The platform code (aka platform-ch32v) can work around this by checking if the e.g. src/main.c file does not exist (or the src/ folder is completely empty), then a file with a default template can be copied into that. Other platforms do such things.

What would a sensible template for framework = noneos-sdk be?

#if defined(CH32V00X)
#include <ch32v00x.h>
#elif defined(CH32V10X)
#include <ch32v10x.h>
#elif defined(CH32V20X)
#include <ch32v20x.h>
#elif defined(CH32V30X)
#include <ch32v30x.h>
#elif defined (CH32X035)
#include <ch32x035.h>
#endif
#include <debug.h>

void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));

int main(void)
{
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
	SystemCoreClockUpdate();
	Delay_Init();

	while (1)
	{
		Delay_Ms(1000);
	}
	return 0; // never reached
}

void NMI_Handler(void) {}
void HardFault_Handler(void)
{
	while (1)
	{
	}
}

maxgerhardt avatar Nov 04 '23 12:11 maxgerhardt