@@ -78,11 +78,6 @@ void tone(uint8_t pin, unsigned int frequency, unsigned long duration)
78
78
no_stop = true ;
79
79
}
80
80
81
- // PWM configuration depends on the following:
82
- // [ ] time_per
83
- // [ ] duty ( via seq )
84
- // [ ] pin ( via pins[0] )
85
-
86
81
// Configure PWM
87
82
static uint16_t seq_values[]={0 };
88
83
// In each value, the most significant bit (15) determines the polarity of the output
@@ -95,35 +90,12 @@ void tone(uint8_t pin, unsigned int frequency, unsigned long duration)
95
90
0
96
91
};
97
92
98
- #if 0
99
- //assign pin to pwm channel - look at WVariant.h for details about ulPWMChannel attribute
100
- uint8_t pwm_type=g_APinDescription[pin].ulPWMChannel;
101
- if(pwm_type == NOT_ON_PWM)
102
- return;
103
-
104
- uint32_t pins[NRF_PWM_CHANNEL_COUNT]={NRF_PWM_PIN_NOT_CONNECTED, NRF_PWM_PIN_NOT_CONNECTED, NRF_PWM_PIN_NOT_CONNECTED, NRF_PWM_PIN_NOT_CONNECTED};
105
- pins[pwm_type & 0x0F]=g_APinDescription[pin].ulPin;
106
- IRQn_Type IntNo = PWM0_IRQn;
107
- NRF_PWM_Type * PWMInstance = NRF_PWM0;
108
- switch(pwm_type &0xF0){
109
- case 16://0x10
110
- PWMInstance = NRF_PWM1;
111
- IntNo = PWM1_IRQn;
112
- break;
113
- case 32://0x20
114
- PWMInstance = NRF_PWM2;
115
- IntNo = PWM2_IRQn;
116
- break;
117
- }
118
- #else
119
-
120
93
// Use fixed PWM2, TODO could conflict with other usage
121
94
uint32_t pins[NRF_PWM_CHANNEL_COUNT]={NRF_PWM_PIN_NOT_CONNECTED, NRF_PWM_PIN_NOT_CONNECTED, NRF_PWM_PIN_NOT_CONNECTED, NRF_PWM_PIN_NOT_CONNECTED};
122
95
pins[0 ] = g_ADigitalPinMap[pin];
123
96
124
97
IRQn_Type IntNo = PWM2_IRQn;
125
98
NRF_PWM_Type * PWMInstance = NRF_PWM2;
126
- #endif
127
99
128
100
nrf_pwm_pins_set (PWMInstance, pins);
129
101
nrf_pwm_enable (PWMInstance);
@@ -150,21 +122,7 @@ void noTone(uint8_t pin)
150
122
return ;
151
123
}
152
124
153
- #if 0
154
- uint8_t pwm_type=g_APinDescription[pin].ulPWMChannel;
155
- NRF_PWM_Type * PWMInstance = NRF_PWM0;
156
- switch(pwm_type &0xF0){
157
- case 16://0x10
158
- PWMInstance = NRF_PWM1;
159
- break;
160
- case 32://0x20
161
- PWMInstance = NRF_PWM2;
162
- break;
163
- }
164
- #else
165
125
NRF_PWM_Type * PWMInstance = NRF_PWM2;
166
- #endif
167
-
168
126
nrf_pwm_task_trigger (PWMInstance, NRF_PWM_TASK_STOP);
169
127
nrf_pwm_disable (PWMInstance);
170
128
}
@@ -173,34 +131,6 @@ void noTone(uint8_t pin)
173
131
extern " C" {
174
132
#endif
175
133
176
- #if 0
177
- void PWM0_IRQHandler(void){
178
- nrf_pwm_event_clear(NRF_PWM0, NRF_PWM_EVENT_PWMPERIODEND);
179
- if(!no_stop){
180
- count_duration--;
181
- if(count_duration == 0)
182
- noTone(pin_sound);
183
- else
184
- nrf_pwm_task_trigger(NRF_PWM0, NRF_PWM_TASK_SEQSTART0);
185
- }
186
- else
187
- nrf_pwm_task_trigger(NRF_PWM0, NRF_PWM_TASK_SEQSTART0);
188
- }
189
-
190
- void PWM1_IRQHandler(void){
191
- nrf_pwm_event_clear(NRF_PWM1, NRF_PWM_EVENT_PWMPERIODEND);
192
- if(!no_stop){
193
- count_duration--;
194
- if(count_duration == 0)
195
- noTone(pin_sound);
196
- else
197
- nrf_pwm_task_trigger(NRF_PWM1, NRF_PWM_TASK_SEQSTART0);
198
- }
199
- else
200
- nrf_pwm_task_trigger(NRF_PWM1, NRF_PWM_TASK_SEQSTART0);
201
- }
202
- #endif
203
-
204
134
void PWM2_IRQHandler (void ){
205
135
nrf_pwm_event_clear (NRF_PWM2, NRF_PWM_EVENT_PWMPERIODEND);
206
136
if (!no_stop){
0 commit comments