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 )
9192 uint8_t do_init = 0 ;
93+ #endif
9294 PinName p = digitalPinToPinName (ulPin );
9395 if (p != NC ) {
9496#ifdef HAL_DAC_MODULE_ENABLED
@@ -101,6 +103,7 @@ void analogWrite(uint32_t ulPin, uint32_t ulValue)
101103 dac_write_value (p , ulValue , do_init );
102104 } else
103105#endif //HAL_DAC_MODULE_ENABLED
106+ #ifdef HAL_TIM_MODULE_ENABLED
104107 if (pin_in_pinmap (p , PinMap_PWM )) {
105108 if (is_pin_configured (p , g_anOutputPinConfigured ) == false) {
106109 do_init = 1 ;
@@ -110,7 +113,10 @@ void analogWrite(uint32_t ulPin, uint32_t ulValue)
110113 pwm_start (p , _writeFreq * PWM_MAX_DUTY_CYCLE ,
111114 PWM_MAX_DUTY_CYCLE ,
112115 ulValue , 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
115121 pinMode (ulPin , OUTPUT );
116122 ulValue = mapResolution (ulValue , _writeResolution , 8 );
0 commit comments