Skip to content

Commit d365dd8

Browse files
committed
refactored to Speaker_Toggle inline function
1 parent e977ea8 commit d365dd8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

atmegaClock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ ISR( TIMER2_OVF_vect ) //wakes up each second
150150

151151
ISR( TIMER0_COMPA_vect ) //notes driver (second octave)
152152
{
153-
PINC = _BV(SPEAKER_N) | _BV(SPEAKER_P); //toggle outputs
153+
Speaker_Toggle();
154154
}
155155

156156
ISR( TIMER0_COMPB_vect ) //notes driver (second octave)
157157
{
158-
PINC = _BV(SPEAKER_N) | _BV(SPEAKER_P); //toggle outputs
158+
Speaker_Toggle();
159159
}
160160

161161
// ADC interrupt service routine

atmegaClock.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ inline void Speaker_Off()
234234
PORTC &= ~(_BV(SPEAKER_N) | _BV(SPEAKER_P));
235235
}
236236

237+
inline void Speaker_Toggle()
238+
{
239+
PINC = _BV(SPEAKER_N) | _BV(SPEAKER_P); //toggle outputs
240+
}
241+
237242
inline void Speaker_Freq(uint8_t note)
238243
{
239244
OCR0A = note;

0 commit comments

Comments
 (0)