2015-09-23 12:52:07 -03:00
|
|
|
#include <AP_HAL/AP_HAL.h>
|
|
|
|
|
2015-11-28 05:38:56 -04:00
|
|
|
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO || \
|
2016-01-20 09:27:43 -04:00
|
|
|
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO2 || \
|
2016-06-29 05:16:03 -03:00
|
|
|
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE || \
|
2015-11-28 05:38:56 -04:00
|
|
|
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \
|
2016-01-05 06:36:02 -04:00
|
|
|
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \
|
2016-10-17 15:02:48 -03:00
|
|
|
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK || \
|
2016-01-05 06:36:02 -04:00
|
|
|
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI
|
2015-09-23 12:52:07 -03:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2015-09-23 22:53:42 -03:00
|
|
|
#include "Util_RPI.h"
|
2015-12-22 09:49:12 -04:00
|
|
|
#include "Util.h"
|
2015-09-23 12:52:07 -03:00
|
|
|
|
|
|
|
extern const AP_HAL::HAL& hal;
|
|
|
|
|
|
|
|
using namespace Linux;
|
|
|
|
|
2015-10-20 18:13:25 -03:00
|
|
|
UtilRPI::UtilRPI()
|
2015-09-23 12:52:07 -03:00
|
|
|
{
|
|
|
|
_check_rpi_version();
|
|
|
|
}
|
|
|
|
|
2015-10-20 18:13:25 -03:00
|
|
|
int UtilRPI::_check_rpi_version()
|
2015-09-23 12:52:07 -03:00
|
|
|
{
|
2015-12-22 09:49:12 -04:00
|
|
|
int hw;
|
|
|
|
hw = Util::from(hal.util)->get_hw_arm32();
|
|
|
|
|
|
|
|
if (hw == UTIL_HARDWARE_RPI2) {
|
2016-06-06 11:38:51 -03:00
|
|
|
printf("Raspberry Pi 2/3 with BCM2709!\n");
|
2015-12-22 09:49:12 -04:00
|
|
|
_rpi_version = 2;
|
|
|
|
} else if (hw == UTIL_HARDWARE_RPI1) {
|
|
|
|
printf("Raspberry Pi 1 with BCM2708!\n");
|
|
|
|
_rpi_version = 1;
|
|
|
|
} else {
|
2016-06-06 11:38:51 -03:00
|
|
|
/* defaults to RPi version 2/3 */
|
|
|
|
fprintf(stderr, "Could not detect RPi version, defaulting to 2/3\n");
|
|
|
|
_rpi_version = 2;
|
2015-09-23 12:52:07 -03:00
|
|
|
}
|
|
|
|
return _rpi_version;
|
|
|
|
}
|
|
|
|
|
2015-10-20 18:13:25 -03:00
|
|
|
int UtilRPI::get_rpi_version() const
|
2015-09-23 12:52:07 -03:00
|
|
|
{
|
|
|
|
return _rpi_version;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|