AP_HAL: added HAL_MEM_CLASS for amount of memory

This commit is contained in:
Andrew Tridgell 2019-09-23 08:51:30 +10:00
parent 47f2f1764d
commit 2d00298070
5 changed files with 33 additions and 3 deletions

View File

@ -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

View File

@ -4,7 +4,20 @@
#include <hal.h>
#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

View File

@ -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

View File

@ -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

View File

@ -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