HAL_PX4: implement AP_HAL::Util perf calls for PX4

This commit is contained in:
Andrew Tridgell 2015-10-20 16:42:18 +11:00
parent 28fa05c965
commit 8dbb51c64e
2 changed files with 42 additions and 1 deletions

View File

@ -134,4 +134,41 @@ uint16_t PX4Util::available_memory(void)
return mem.fordblks; return mem.fordblks;
} }
/*
AP_HAL wrapper around PX4 perf counters
*/
PX4Util::perf_counter_t PX4Util::perf_alloc(PX4Util::perf_counter_type t, const char *name)
{
::perf_counter_type px4_t;
switch (t) {
case PX4Util::PC_COUNT:
px4_t = ::PC_COUNT;
break;
case PX4Util::PC_ELAPSED:
px4_t = ::PC_ELAPSED;
break;
case PX4Util::PC_INTERVAL:
px4_t = ::PC_INTERVAL;
break;
default:
return NULL;
}
return (perf_counter_t)::perf_alloc(px4_t, name);
}
void PX4Util::perf_begin(perf_counter_t h)
{
::perf_begin((::perf_counter_t)h);
}
void PX4Util::perf_end(perf_counter_t h)
{
::perf_end((::perf_counter_t)h);
}
void PX4Util::perf_count(perf_counter_t h)
{
::perf_count((::perf_counter_t)h);
}
#endif // CONFIG_HAL_BOARD == HAL_BOARD_PX4 #endif // CONFIG_HAL_BOARD == HAL_BOARD_PX4

View File

@ -51,7 +51,11 @@ public:
return a stream for access to nsh shell return a stream for access to nsh shell
*/ */
AP_HAL::Stream *get_shell_stream() { return &_shell_stream; } AP_HAL::Stream *get_shell_stream() { return &_shell_stream; }
perf_counter_t perf_alloc(perf_counter_type t, const char *name) override;
void perf_begin(perf_counter_t ) override;
void perf_end(perf_counter_t) override;
void perf_count(perf_counter_t) override;
private: private:
int _safety_handle; int _safety_handle;
PX4::NSHShellStream _shell_stream; PX4::NSHShellStream _shell_stream;