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 || \
|
2015-11-28 05:38:56 -04:00
|
|
|
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_RASPILOT || \
|
|
|
|
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 || \
|
|
|
|
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) {
|
|
|
|
printf("Raspberry Pi 2 with BCM2709!\n");
|
|
|
|
_rpi_version = 2;
|
|
|
|
} else if (hw == UTIL_HARDWARE_RPI1) {
|
|
|
|
printf("Raspberry Pi 1 with BCM2708!\n");
|
|
|
|
_rpi_version = 1;
|
|
|
|
} else {
|
|
|
|
/* defaults to 1 */
|
|
|
|
fprintf(stderr, "Could not detect RPi version, defaulting to 1\n");
|
|
|
|
_rpi_version = 1;
|
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
|