Corrected EOL style.

This commit is contained in:
skarg
2007-10-28 13:32:45 +00:00
parent f9586e3b44
commit 39f0a6f876
+108 -108
View File
@@ -1,108 +1,108 @@
/************************************************************************** /**************************************************************************
* *
* Copyright (C) 2007 Steve Karg <skarg@users.sourceforge.net> * Copyright (C) 2007 Steve Karg <skarg@users.sourceforge.net>
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including * "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, * without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to * distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to * permit persons to whom the Software is furnished to do so, subject to
* the following conditions: * the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
*********************************************************************/ *********************************************************************/
#include "hardware.h" #include "hardware.h"
/* This module is a 1 millisecond timer */ /* This module is a 1 millisecond timer */
/* Prescaling: 1, 8, 64, 256, 1024 */ /* Prescaling: 1, 8, 64, 256, 1024 */
#define TIMER_PRESCALER 64 #define TIMER_PRESCALER 64
/* Count: Timer0 counts up to 0xFF and then signals overflow */ /* Count: Timer0 counts up to 0xFF and then signals overflow */
#define TIMER_TICKS (F_CPU/TIMER_PRESCALER/1000) #define TIMER_TICKS (F_CPU/TIMER_PRESCALER/1000)
#if (TIMER_TICKS > 0xFF) #if (TIMER_TICKS > 0xFF)
#error Timer Prescaler value is too small #error Timer Prescaler value is too small
#endif #endif
#define TIMER_COUNT (0xFF-TIMER_TICKS) #define TIMER_COUNT (0xFF-TIMER_TICKS)
/* Global variable millisecond timer - used by main.c for timers task */ /* Global variable millisecond timer - used by main.c for timers task */
volatile uint8_t Timer_Milliseconds = 0; volatile uint8_t Timer_Milliseconds = 0;
/* MS/TP Silence Timer */ /* MS/TP Silence Timer */
static volatile uint16_t SilenceTime; static volatile uint16_t SilenceTime;
/* Configure the Timer */ /* Configure the Timer */
void Timer_Initialize(void) void Timer_Initialize(void)
{ {
/* Normal Operation */ /* Normal Operation */
TCCR1A = 0; TCCR1A = 0;
/* CSn2 CSn1 CSn0 Description /* CSn2 CSn1 CSn0 Description
---- ---- ---- ----------- ---- ---- ---- -----------
0 0 0 No Clock Source 0 0 0 No Clock Source
0 0 1 No prescaling 0 0 1 No prescaling
0 1 0 CLKio/8 0 1 0 CLKio/8
0 1 1 CLKio/64 0 1 1 CLKio/64
1 0 0 CLKio/256 1 0 0 CLKio/256
1 0 1 CLKio/1024 1 0 1 CLKio/1024
1 1 0 Falling Edge of T0 (external) 1 1 0 Falling Edge of T0 (external)
1 1 1 Rising Edge of T0 (external) 1 1 1 Rising Edge of T0 (external)
*/ */
TCCR0B = _BV(CS01) | _BV(CS00); TCCR0B = _BV(CS01) | _BV(CS00);
/* Clear any TOV1 Flag set when the timer overflowed */ /* Clear any TOV1 Flag set when the timer overflowed */
BIT_CLEAR(TIFR0,TOV0); BIT_CLEAR(TIFR0,TOV0);
/* Initial value */ /* Initial value */
TCNT0 = TIMER_COUNT; TCNT0 = TIMER_COUNT;
/* Enable the overflow interrupt */ /* Enable the overflow interrupt */
BIT_SET(TIMSK0,TOIE0); BIT_SET(TIMSK0,TOIE0);
/* Clear the Power Reduction Timer/Counter0 */ /* Clear the Power Reduction Timer/Counter0 */
BIT_CLEAR(PRR,PRTIM0); BIT_CLEAR(PRR,PRTIM0);
} }
/* Timer interupt */ /* Timer interupt */
/* note: Global interupts must be enabled - sei() */ /* note: Global interupts must be enabled - sei() */
/* Timer Overflowed! Increment the time. */ /* Timer Overflowed! Increment the time. */
ISR(TIMER0_OVF_vect) ISR(TIMER0_OVF_vect)
{ {
/* Set the counter for the next interrupt */ /* Set the counter for the next interrupt */
TCNT0 = TIMER_COUNT; TCNT0 = TIMER_COUNT;
/* Overflow Flag is automatically cleared */ /* Overflow Flag is automatically cleared */
/* Update the global timer */ /* Update the global timer */
if (Timer_Milliseconds < 0xFF) if (Timer_Milliseconds < 0xFF)
Timer_Milliseconds++; Timer_Milliseconds++;
if (SilenceTime < 0xFFFF) if (SilenceTime < 0xFFFF)
SilenceTime++; SilenceTime++;
} }
/* Public access to the Silence Timer */ /* Public access to the Silence Timer */
uint16_t Timer_Silence(void) uint16_t Timer_Silence(void)
{ {
uint16_t timer; uint16_t timer;
uint8_t sreg; uint8_t sreg;
sreg = SREG; sreg = SREG;
cli(); cli();
timer = SilenceTime; timer = SilenceTime;
SREG = sreg; SREG = sreg;
return timer; return timer;
} }
/* Public reset of the Silence Timer */ /* Public reset of the Silence Timer */
void Timer_Silence_Reset(void) void Timer_Silence_Reset(void)
{ {
uint8_t sreg; uint8_t sreg;
sreg = SREG; sreg = SREG;
cli(); cli();
SilenceTime = 0; SilenceTime = 0;
SREG = sreg; SREG = sreg;
} }