@@ -151,7 +151,9 @@ void SerialBase::_init()
151151{
152152 serial_init (&_serial, _tx_pin, _rx_pin);
153153#if DEVICE_SERIAL_FC
154- set_flow_control (_flow_type, _flow1, _flow2);
154+ if (_set_flow_control_dp_func) {
155+ (this ->*_set_flow_control_dp_func)(_flow_type, _flow1, _flow2);
156+ }
155157#endif
156158 serial_baud (&_serial, _baud);
157159 serial_irq_handler (&_serial, SerialBase::_irq_handler, (uint32_t )this );
@@ -161,8 +163,8 @@ void SerialBase::_init_direct()
161163{
162164 serial_init_direct (&_serial, _static_pinmap);
163165#if DEVICE_SERIAL_FC
164- if (_static_pinmap_fc) {
165- set_flow_control (_flow_type, *_static_pinmap_fc);
166+ if (_static_pinmap_fc && _set_flow_control_dp_func ) {
167+ ( this ->*_set_flow_control_sp_func) (_flow_type, *_static_pinmap_fc);
166168 }
167169#endif
168170 serial_baud (&_serial, _baud);
@@ -303,6 +305,7 @@ SerialBase::~SerialBase()
303305void SerialBase::set_flow_control (Flow type, PinName flow1, PinName flow2)
304306{
305307 MBED_ASSERT (_static_pinmap == NULL ); // this function must be used when serial object has been created using dynamic pin-map constructor
308+ _set_flow_control_dp_func = &SerialBase::set_flow_control;
306309 lock ();
307310
308311 _flow_type = type;
@@ -333,6 +336,7 @@ void SerialBase::set_flow_control(Flow type, PinName flow1, PinName flow2)
333336void SerialBase::set_flow_control (Flow type, const serial_fc_pinmap_t &static_pinmap)
334337{
335338 MBED_ASSERT (_static_pinmap != NULL ); // this function must be used when serial object has been created using static pin-map constructor
339+ _set_flow_control_sp_func = &SerialBase::set_flow_control;
336340 lock ();
337341 _static_pinmap_fc = &static_pinmap;
338342 _flow_type = type;
0 commit comments