ardupilot/libraries/AP_HAL_PX4/system.cpp
Caio Marcelo de Oliveira Filho 8db8b9b355 AP_HAL_PX4: implement new AP_HAL functions
Implement the new AP_HAL functions and use them in the Scheduler when
possible.
2015-11-20 12:25:40 +09:00

54 lines
738 B
C++

#include <stdarg.h>
#include <stdio.h>
#include <drivers/drv_hrt.h>
#include <AP_HAL/AP_HAL.h>
#include <AP_HAL/system.h>
extern const AP_HAL::HAL& hal;
extern bool _px4_thread_should_exit;
namespace AP_HAL {
void init()
{
}
void panic(const char *errormsg, ...)
{
va_list ap;
va_start(ap, errormsg);
vdprintf(1, errormsg, ap);
va_end(ap);
write(1, "\n", 1);
hal.scheduler->delay_microseconds(10000);
_px4_thread_should_exit = true;
exit(1);
}
uint32_t micros()
{
return micros64() & 0xFFFFFFFF;
}
uint32_t millis()
{
return millis64() & 0xFFFFFFFF;
}
uint64_t micros64()
{
return hrt_absolute_time();
}
uint64_t millis64()
{
return micros64() / 1000;
}
} // namespace AP_HAL