mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 00:43:34 +08:00
module_base: remove CRTP template pattern to reduce flash bloat (#26476)
* module_base: claude rewrite to remove CRTP bloat * module_base: apply to all drivers/modules * format * fix build errors * fix missing syntax * remove reference to module.h in files that need module_base.h * remove old ModuleBase<T> * add module_base.cpp to px4_protected_layers.cmake * fix IridiumSBD can_stop() * fix IridiumSBD.cpp * clang-tidy: downcast static cast * get_instance() template accessor, revert clang-tidy global * rename module_base.h to module.h * revert changes in zenoh/Kconfig.topics
This commit is contained in:
@@ -34,6 +34,8 @@
|
||||
#include "pwm_input.h"
|
||||
#include <px4_arch/io_timer.h>
|
||||
|
||||
ModuleBase::Descriptor PWMIN::desc{task_spawn, custom_command, print_usage};
|
||||
|
||||
int
|
||||
PWMIN::task_spawn(int argc, char *argv[])
|
||||
{
|
||||
@@ -44,8 +46,8 @@ PWMIN::task_spawn(int argc, char *argv[])
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
_object.store(pwmin);
|
||||
_task_id = task_id_is_work_queue;
|
||||
desc.object.store(pwmin);
|
||||
desc.task_id = task_id_is_work_queue;
|
||||
|
||||
pwmin->start();
|
||||
|
||||
@@ -148,7 +150,7 @@ PWMIN::pwmin_tim_isr(int irq, void *context, void *arg)
|
||||
/* ack the interrupts we just read */
|
||||
rSR = 0;
|
||||
|
||||
auto obj = get_instance();
|
||||
auto obj = get_instance<PWMIN>(desc);
|
||||
|
||||
if (obj != nullptr) {
|
||||
obj->publish(status, period, pulse_width);
|
||||
@@ -218,5 +220,5 @@ PWMIN::custom_command(int argc, char *argv[])
|
||||
|
||||
extern "C" __EXPORT int pwm_input_main(int argc, char *argv[])
|
||||
{
|
||||
return PWMIN::main(argc, argv);
|
||||
return ModuleBase::main(PWMIN::desc, argc, argv);
|
||||
}
|
||||
|
||||
@@ -120,9 +120,11 @@
|
||||
#error PWMIN_TIMER_CHANNEL must be either 1 and 2.
|
||||
#endif
|
||||
|
||||
class PWMIN : public ModuleBase<PWMIN>
|
||||
class PWMIN : public ModuleBase
|
||||
{
|
||||
public:
|
||||
static Descriptor desc;
|
||||
|
||||
void start();
|
||||
void publish(uint16_t status, uint32_t period, uint32_t pulse_width);
|
||||
int print_status() override;
|
||||
|
||||
Reference in New Issue
Block a user