picoco/config/FreeRTOSConfig.h
2025-02-21 12:02:48 +01:00

117 lines
6.7 KiB
C

#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H
/*-----------------------------------------------------------
* Application specific definitions.
*
* These definitions should be adjusted for your particular hardware and
* application requirements.
*
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
*
* See http://www.freertos.org/a00110.html.
*----------------------------------------------------------*/
// Scheduler Configuration
#define configUSE_PREEMPTION 1 // 1: Preemptive scheduler, 0: Cooperative scheduler
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 // Use optimized task selection if available
#define configUSE_IDLE_HOOK 0 // 1: Use Idle hook function
#define configUSE_TICK_HOOK 0 // 1: Use Tick hook function
#define configIDLE_SHOULD_YIELD 1 // 1: Idle task yields to same priority tasks
#define configUSE_PASSIVE_IDLE_HOOK 0 // No passive idle hook (SMP-specific)
// System Clock Configuration
#define configCPU_CLOCK_HZ ((unsigned long)150000000) // CPU frequency: 150 MHz for RP2350
#define configTICK_RATE_HZ ((TickType_t)1000) // RTOS tick frequency (1000 Hz = 1ms tick)
// Task Configuration
#define configMAX_PRIORITIES 5 // Maximum number of priority levels
#define configMINIMAL_STACK_SIZE ((unsigned short)256) // Minimum stack size in words
#define configMAX_TASK_NAME_LEN (16) // Maximum length of task names
// Memory Configuration
#define configTOTAL_HEAP_SIZE ((size_t)(16 * 1024)) // Total RTOS heap size (16 KB)
#define configSUPPORT_DYNAMIC_ALLOCATION 1 // 1: Enable dynamic memory allocation
// Synchronization Primitives
#define configUSE_MUTEXES 1 // 1: Enable mutexes
#define configUSE_RECURSIVE_MUTEXES 1 // 1: Enable recursive mutexes
#define configUSE_COUNTING_SEMAPHORES 1 // 1: Enable counting semaphores
#define configQUEUE_REGISTRY_SIZE 8 // Number of queues/semaphores that can be registered
// Debugging and Diagnostics
#define configUSE_TRACE_FACILITIES 0 // 1: Enable trace/debug facilities
#define configCHECK_FOR_STACK_OVERFLOW 2 // Stack overflow checking method (0=off, 1=method1, 2=method2)
#define configUSE_MALLOC_FAILED_HOOK 0 // 1: Use memory allocation failure hook
#define configUSE_APPLICATION_TASK_TAG 0 // 1: Enable task tagging
#define configGENERATE_RUN_TIME_STATS 0 // 1: Generate run-time statistics
// Timer Configuration
#define configUSE_TIMERS 1 // 1: Enable software timers
#define configTIMER_TASK_PRIORITY (2) // Timer service task priority
#define configTIMER_QUEUE_LENGTH 10 // Timer command queue length
#define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 2) // Timer task stack size
// Co-routine Configuration
#define configUSE_CO_ROUTINES 0 // 1: Enable co-routines
#define configMAX_CO_ROUTINE_PRIORITIES (2) // Maximum co-routine priorities
// Hardware Specific Configuration
#define configENABLE_FPU 1 // 1: Enable Floating Point Unit
#define configUSE_TASK_FPU_SUPPORT 1 // Enable FPU context save/restore
#define configENABLE_TRUSTZONE 0 // 1: Enable TrustZone
#define configRUN_FREERTOS_SECURE_ONLY 0 // Non-secure mode to match port
#define configENABLE_MPU 0 // 1: Enable Memory Protection Unit (defined twice in original)
#define configRUN_FREERTOS_SECURE_ONLY 1 // 1: Run in secure mode only
#define configUSE_16_BIT_TICKS 0 // 0: Use 32-bit ticks, 1: Use 16-bit ticks
// SMP Configuration
#define configNUMBER_OF_CORES 2 // RP2350 has 2 cores
#if configNUMBER_OF_CORES > 1
#define configUSE_SMP 1 // Enable Symmetric Multiprocessing
#define configUSE_CORE_AFFINITY 1
#define configSMP_SPINLOCK_0 0 // Spinlock 0 for SMP synchronization
#define configSMP_SPINLOCK_1 1 // Spinlock 1 (optional, depending on port)
/* Fallback for missing portmacro.h definition */
#ifndef taskDISABLE_INTERRUPTS
#define taskDISABLE_INTERRUPTS() __asm volatile ("cpsid i" ::: "memory")
#endif
#endif
// API Inclusion Configuration
#define INCLUDE_vTaskPrioritySet 1 // Include task priority set API
#define INCLUDE_uxTaskPriorityGet 1 // Include task priority get API
#define INCLUDE_vTaskDelete 1 // Include task delete API
#define INCLUDE_vTaskCleanUpResources 0 // Include task cleanup API
#define INCLUDE_vTaskSuspend 1 // Include task suspend API
#define INCLUDE_vTaskDelayUntil 1 // Include delay until API
#define INCLUDE_vTaskDelay 1 // Include delay API
#define INCLUDE_xTaskGetSchedulerState 1 // Include scheduler state API
#define INCLUDE_xTaskGetCurrentTaskHandle 1 // Include current task handle API
#define INCLUDE_uxTaskGetStackHighWaterMark 0 // Include stack high water mark API
#define INCLUDE_xTaskGetIdleTaskHandle 0 // Include idle task handle API
#define INCLUDE_eTaskGetState 0 // Include task state API
#define INCLUDE_xSemaphoreGetMutexHolder 0 // Include mutex holder API
#define INCLUDE_xTimerPendFunctionCall 1 // Include timer pend function call API (defined twice in original)
#define INCLUDE_xQueueGetMutexHolder 0 // Include queue mutex holder API
#define INCLUDE_xEventGroupSetBitFromISR 1 // Include event group set bit from ISR API
// Cortex-M Interrupt Configuration
#ifdef __NVIC_PRIO_BITS
#define configPRIO_BITS __NVIC_PRIO_BITS // Use CMSIS defined priority bits
#else
#define configPRIO_BITS 3 // 7 priority levels (default)
#endif
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 0x7 // Lowest interrupt priority
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 // Highest priority for FreeRTOS API calls
#define configKERNEL_INTERRUPT_PRIORITY (configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS))
#define configMAX_SYSCALL_INTERRUPT_PRIORITY (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS))
// Assertion Definition
#define configASSERT(x) if((x) == 0) { taskDISABLE_INTERRUPTS(); for(;;); } // Basic assert implementation
#endif /* FREERTOS_CONFIG_H */