#include #include CMSIS_device_header #include "Driver_GPIO.h" #include "sram_vtor.h" #include "cmsis_dv.h" #include "cmsis_os2.h" // CMSIS RTOS2 error handler void osRtxErrorNotify(uint32_t code) { (void)code; // Handle RTOS errors while(1); } void cmsis_validate_task(void *args) { (void)args; cmsis_dv(NULL); // Exit task when done osThreadExit(); } int main(void) { NVIC_Relocate_VTOR(); SystemCoreClockUpdate(); // Enable GPIO clocks RCC->AHB1ENR |= RCC_AHB1ENR_GPIOBEN; // Enable GPIOB for PB4/PB5 (void)RCC->AHB1ENR; (void)RCC->AHB1ENR; // Enable SYSCFG clock (required for EXTI interrupt routing) RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN; (void)RCC->APB2ENR; osKernelInitialize(); const osThreadAttr_t thread_attr = { .name = "CMSIS Validate", .stack_size = 1024 // 1024 words = 4096 bytes }; osThreadNew(cmsis_validate_task, NULL, &thread_attr); osKernelStart(); // Should never reach here while(1); }