2323extern "C" {
2424#endif
2525
26-
26+ #if defined( HAL_DAC_MODULE_ENABLED ) || defined( HAL_TIM_MODULE_ENABLED )
2727//This is the list of the IOs configured
2828uint32_t g_anOutputPinConfigured [MAX_NB_PORT ]= {0 };
29+ #endif
2930
3031static int _readResolution = 10 ;
3132static int _writeResolution = 8 ;
@@ -87,8 +88,9 @@ void analogOutputInit(void)
8788// to digital output.
8889void analogWrite (uint32_t ulPin ,uint32_t ulValue )
8990{
90-
91+ #if defined( HAL_DAC_MODULE_ENABLED ) || defined( HAL_TIM_MODULE_ENABLED )
9192uint8_t do_init = 0 ;
93+ #endif
9294PinName p = digitalPinToPinName (ulPin );
9395if (p != NC ) {
9496#ifdef HAL_DAC_MODULE_ENABLED
@@ -101,6 +103,7 @@ void analogWrite(uint32_t ulPin, uint32_t ulValue)
101103dac_write_value (p ,ulValue ,do_init );
102104 }else
103105#endif //HAL_DAC_MODULE_ENABLED
106+ #ifdef HAL_TIM_MODULE_ENABLED
104107if (pin_in_pinmap (p ,PinMap_PWM )) {
105108if (is_pin_configured (p ,g_anOutputPinConfigured )== false) {
106109do_init = 1 ;
@@ -110,7 +113,10 @@ void analogWrite(uint32_t ulPin, uint32_t ulValue)
110113pwm_start (p ,_writeFreq * PWM_MAX_DUTY_CYCLE ,
111114PWM_MAX_DUTY_CYCLE ,
112115ulValue ,do_init );
113- }else {//DIGITAL PIN ONLY
116+ }else
117+ #endif /* HAL_TIM_MODULE_ENABLED */
118+ {
119+ //DIGITAL PIN ONLY
114120// Defaults to digital write
115121pinMode (ulPin ,OUTPUT );
116122ulValue = mapResolution (ulValue ,_writeResolution ,8 );