diff --git a/libraries/AP_HAL/AP_HAL_Boards.h b/libraries/AP_HAL/AP_HAL_Boards.h index a1973ad7ce..9d140044b4 100644 --- a/libraries/AP_HAL/AP_HAL_Boards.h +++ b/libraries/AP_HAL/AP_HAL_Boards.h @@ -92,13 +92,27 @@ /* CPU classes, used to select if CPU intensive algorithms should be used * Note that these are only approximate, not exact CPU speeds. */ -/* 150Mhz: PX4 or similar. Assumes: +/* 150Mhz: STM32F4 or similar. Assumes: * - hardware floating point - * - tens of kilobytes of memory available */ + * - tens of kilobytes of memory available +*/ #define HAL_CPU_CLASS_150 3 + /* GigaHz class: SITL, BeagleBone etc. Assumes megabytes of memory available. */ #define HAL_CPU_CLASS_1000 4 + +/* + memory classes, in kbytes. Board must have at least the given amount + of memory +*/ +#define HAL_MEM_CLASS_20 1 +#define HAL_MEM_CLASS_64 2 +#define HAL_MEM_CLASS_192 3 +#define HAL_MEM_CLASS_300 4 +#define HAL_MEM_CLASS_500 5 +#define HAL_MEM_CLASS_1000 6 + /* Operating system features * * HAL implementations may define the following extra feature defines to 1 if diff --git a/libraries/AP_HAL/board/chibios.h b/libraries/AP_HAL/board/chibios.h index ab6cbce84c..305da45355 100644 --- a/libraries/AP_HAL/board/chibios.h +++ b/libraries/AP_HAL/board/chibios.h @@ -4,7 +4,20 @@ #include #define HAL_BOARD_NAME "ChibiOS" -#define HAL_CPU_CLASS HAL_CPU_CLASS_150 + +#if HAL_MEMORY_TOTAL_KB >= 1000 +#define HAL_MEM_CLASS HAL_MEM_CLASS_1000 +#elif HAL_MEMORY_TOTAL_KB >= 500 +#define HAL_MEM_CLASS HAL_MEM_CLASS_500 +#elif HAL_MEMORY_TOTAL_KB >= 300 +#define HAL_MEM_CLASS HAL_MEM_CLASS_300 +#elif HAL_MEMORY_TOTAL_KB >= 192 +#define HAL_MEM_CLASS HAL_MEM_CLASS_192 +#elif HAL_MEMORY_TOTAL_KB >= 64 +#define HAL_MEM_CLASS HAL_MEM_CLASS_64 +#else +#define HAL_MEM_CLASS HAL_MEM_CLASS_20 +#endif #ifndef HAL_GPIO_LED_ON #define HAL_GPIO_LED_ON 0 diff --git a/libraries/AP_HAL/board/empty.h b/libraries/AP_HAL/board/empty.h index c2d9c3d370..bc2b680d3e 100644 --- a/libraries/AP_HAL/board/empty.h +++ b/libraries/AP_HAL/board/empty.h @@ -2,6 +2,7 @@ #define HAL_BOARD_NAME "EMPTY" #define HAL_CPU_CLASS HAL_CPU_CLASS_150 +#define HAL_MEM_CLASS HAL_MEM_CLASS_192 #define HAL_STORAGE_SIZE 16384 #define HAL_STORAGE_SIZE_AVAILABLE HAL_STORAGE_SIZE #define HAL_INS_DEFAULT HAL_INS_HIL diff --git a/libraries/AP_HAL/board/linux.h b/libraries/AP_HAL/board/linux.h index e4a8b87bc2..0f25f9a333 100644 --- a/libraries/AP_HAL/board/linux.h +++ b/libraries/AP_HAL/board/linux.h @@ -2,6 +2,7 @@ #define HAL_BOARD_NAME "Linux" #define HAL_CPU_CLASS HAL_CPU_CLASS_1000 +#define HAL_MEM_CLASS HAL_MEM_CLASS_1000 #define HAL_OS_POSIX_IO 1 #define HAL_OS_SOCKETS 1 #define HAL_STORAGE_SIZE 16384 diff --git a/libraries/AP_HAL/board/sitl.h b/libraries/AP_HAL/board/sitl.h index 04014851e9..39f873668d 100644 --- a/libraries/AP_HAL/board/sitl.h +++ b/libraries/AP_HAL/board/sitl.h @@ -2,6 +2,7 @@ #define HAL_BOARD_NAME "SITL" #define HAL_CPU_CLASS HAL_CPU_CLASS_1000 +#define HAL_MEM_CLASS HAL_MEM_CLASS_1000 #define HAL_OS_POSIX_IO 1 #define HAL_OS_SOCKETS 1 #define HAL_STORAGE_SIZE 16384