The input is _timer which is type uint8_t. There is no output value.
It branches according to the _timer. Currently it is 2 or -1. If the _timer is -1, it dose nothing and returns. If the _timer is 2, it sets TIMSK2, TCCR2A, TCCR2B and OCR2A to reset the timer/counter.
The TIMSK2 is a register to control interrupt mask. In the tone() it sets the OCIE2A bit to 1 to enable interrupt. Here it reset to 0 using bitWrite() to disable interrupt.
It sets the WGM20 bit of TCCR2A. In this case, timer/counter2 operates as Phase Correct PWM mode, which is used by analogWrite(). In the init(), dose the same.
The TCCR2B is set to bitwise AND of TCCR2B and 0b11111000, then set CS22 bit. This holds upper 5 bits and sets CS22 of lower 3 bits. This sets the division ratio of the clock to 64. In the init(), dose the same too.
/*
Copyright (c) 2019 garretlab.
Added source code explanation by garretlab.
*//* Tone.cpp
A Tone Generator Library
Written by Brett Hagman
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Version Modified By Date Comments
------- ----------- -------- --------
0001 B Hagman 09/08/02 Initial coding
0002 B Hagman 09/08/18 Multiple pins
0003 B Hagman 09/08/18 Moved initialization from constructor to begin()
0004 B Hagman 09/09/26 Fixed problems with ATmega8
0005 B Hagman 09/11/23 Scanned prescalars for best fit on 8 bit timers
09/11/25 Changed pin toggle method to XOR
09/11/25 Fixed timer0 from being excluded
0006 D Mellis 09/12/29 Replaced objects with functions
0007 M Sproul 10/08/29 Changed #ifdefs from cpu to register
0008 S Kanemoto 12/06/22 Fixed for Leonardo by @maris_HY
0009 J Reucker 15/04/10 Issue #292 Fixed problems with ATmega8 (thanks to Pete62)
0010 jipp 15/04/13 added additional define check #2923
*************************************************/