Closed lefebvresam closed 4 months ago
To make it more flexible I do the following in the initialization step:
uint32_t peripheral = pinmap_find_peripheral(_buzzerpin, PinMap_PWM);
if (peripheral == (uint32_t)NC) { // no mapping available
WARNING("Haptic pin not assigned to a PWM output");
} else {
INFO("Setup buzzer for PWM peripheral at address 0x%X", peripheral);
_buzzer = new PwmOut(_buzzerpin);
}
And later test if _buzzer == nullptr to perform the necessary actions.
Ok, I do not know how, but place bad link, this is correct one and this call https://github.com/mbed-ce/mbed-os/blob/031d274c62cc71b4c5a24fd66d3a9e164bb07f1c/hal/source/mbed_pinmap_common.c#L68-L80
So when you put a pin what is not in the pinmap then you should see "pinmap not found for peripheral" your serial terminal.
The output where I want PWM in line with my HW is not listed in the pinmap 'PWM'. Probably because it is not one of the timer outputs. If I configure PwmOut with that pin there is no warning or error, and the PWM output is not working as expected. So two questions:
1/ Why there is no warning/error? 2/ Is there an easy alternative? (By overwriting PwmOut by an own function that puts a pin high and low?) Or can this alternative be automatically provided by the mbed lib?