23
23
extern "C" {
24
24
#endif
25
25
26
-
26
+ #if defined( HAL_DAC_MODULE_ENABLED ) || defined( HAL_TIM_MODULE_ENABLED )
27
27
//This is the list of the IOs configured
28
28
uint32_t g_anOutputPinConfigured [MAX_NB_PORT ] = {0 };
29
+ #endif
29
30
30
31
static int _readResolution = 10 ;
31
32
static int _writeResolution = 8 ;
@@ -87,8 +88,9 @@ void analogOutputInit(void)
87
88
// to digital output.
88
89
void analogWrite (uint32_t ulPin , uint32_t ulValue )
89
90
{
90
-
91
+ #if defined( HAL_DAC_MODULE_ENABLED ) || defined( HAL_TIM_MODULE_ENABLED )
91
92
uint8_t do_init = 0 ;
93
+ #endif
92
94
PinName p = digitalPinToPinName (ulPin );
93
95
if (p != NC ) {
94
96
#ifdef HAL_DAC_MODULE_ENABLED
@@ -101,6 +103,7 @@ void analogWrite(uint32_t ulPin, uint32_t ulValue)
101
103
dac_write_value (p , ulValue , do_init );
102
104
} else
103
105
#endif //HAL_DAC_MODULE_ENABLED
106
+ #ifdef HAL_TIM_MODULE_ENABLED
104
107
if (pin_in_pinmap (p , PinMap_PWM )) {
105
108
if (is_pin_configured (p , g_anOutputPinConfigured ) == false) {
106
109
do_init = 1 ;
@@ -110,7 +113,10 @@ void analogWrite(uint32_t ulPin, uint32_t ulValue)
110
113
pwm_start (p , _writeFreq * PWM_MAX_DUTY_CYCLE ,
111
114
PWM_MAX_DUTY_CYCLE ,
112
115
ulValue , do_init );
113
- } else { //DIGITAL PIN ONLY
116
+ } else
117
+ #endif /* HAL_TIM_MODULE_ENABLED */
118
+ {
119
+ //DIGITAL PIN ONLY
114
120
// Defaults to digital write
115
121
pinMode (ulPin , OUTPUT );
116
122
ulValue = mapResolution (ulValue , _writeResolution , 8 );
0 commit comments