AP_IRLock: auto-start batt_smbus driver if enabled

This commit is contained in:
Andrew Tridgell 2016-08-03 14:44:53 +10:00
parent d05a08ff4d
commit e24cebec33
1 changed files with 9 additions and 0 deletions

View File

@ -20,6 +20,7 @@
* Author: MLandes
*/
#include <AP_HAL/AP_HAL.h>
#include <AP_BoardConfig/AP_BoardConfig.h>
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4 || CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
#include "AP_IRLock_PX4.h"
@ -34,8 +35,16 @@ AP_IRLock_PX4::AP_IRLock_PX4() :
_fd(0)
{}
extern "C" int irlock_main(int, char **);
void AP_IRLock_PX4::init()
{
if (!AP_BoardConfig::px4_start_driver(irlock_main, "irlock", "start")) {
hal.console->printf("irlock driver start failed\n");
} else {
// give it time to initialise
hal.scheduler->delay(500);
}
_fd = open(IRLOCK0_DEVICE_PATH, O_RDONLY);
if (_fd < 0) {
hal.console->printf("Unable to open " IRLOCK0_DEVICE_PATH "\n");