mirror of https://github.com/ArduPilot/ardupilot
AP_IOCMU: added singleton in AP namespace
This commit is contained in:
parent
64aae4f67e
commit
a11f2b5cfb
|
@ -44,7 +44,9 @@ enum ioevents {
|
|||
|
||||
AP_IOMCU::AP_IOMCU(AP_HAL::UARTDriver &_uart) :
|
||||
uart(_uart)
|
||||
{}
|
||||
{
|
||||
singleton = this;
|
||||
}
|
||||
|
||||
#define IOMCU_DEBUG_ENABLE 0
|
||||
|
||||
|
@ -54,6 +56,8 @@ AP_IOMCU::AP_IOMCU(AP_HAL::UARTDriver &_uart) :
|
|||
#define debug(fmt, args ...)
|
||||
#endif
|
||||
|
||||
AP_IOMCU *AP_IOMCU::singleton;
|
||||
|
||||
/*
|
||||
initialise library, starting thread
|
||||
*/
|
||||
|
@ -999,4 +1003,11 @@ void AP_IOMCU::check_iomcu_reset(void)
|
|||
trigger_event(IOEVENT_SET_DEFAULT_RATE);
|
||||
}
|
||||
|
||||
|
||||
namespace AP {
|
||||
AP_IOMCU *iomcu(void) {
|
||||
return AP_IOMCU::get_singleton();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // HAL_WITH_IO_MCU
|
||||
|
|
|
@ -106,6 +106,10 @@ public:
|
|||
// channel group masks
|
||||
const uint8_t ch_masks[3] = { 0x03,0x0C,0xF0 };
|
||||
|
||||
static AP_IOMCU *get_singleton(void) {
|
||||
return singleton;
|
||||
}
|
||||
|
||||
private:
|
||||
AP_HAL::UARTDriver &uart;
|
||||
|
||||
|
@ -238,6 +242,8 @@ private:
|
|||
void handle_repeated_failures();
|
||||
void check_iomcu_reset();
|
||||
|
||||
static AP_IOMCU *singleton;
|
||||
|
||||
enum {
|
||||
PROTO_NOP = 0x00,
|
||||
PROTO_OK = 0x10,
|
||||
|
@ -270,4 +276,8 @@ private:
|
|||
};
|
||||
};
|
||||
|
||||
namespace AP {
|
||||
AP_IOMCU *iomcu(void);
|
||||
};
|
||||
|
||||
#endif // HAL_WITH_IO_MCU
|
||||
|
|
Loading…
Reference in New Issue