Community-PIO-CH32V / platform-ch32v

PlatformIO platform for CH32V RISC-V chips (CH32V003, CH32V103, CH32V20x, CH32V30x, CH32X035) and CH56x, CH57x, CH58x, CH59x
Apache License 2.0
203 stars 34 forks source link

Can make custom template noneos-sdk on new project ? #42

Closed Witawat closed 2 months ago

Witawat commented 10 months ago

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 ?

maxgerhardt commented 10 months ago

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)
    {
    }
}