4008-04-07 Release
[avr_bc100.git] / BaseTinyFirmware / GCC / PWM.c
index 9d205fc2703410e731abe05f92d8ef3d4186d3db..a84a357ab35baa538e515335c4eb7b6f41737a71 100644 (file)
  *      AVR463: Charging NiMH Batteries with BC100\r
  *\r
  * \par Documentation\r
- *      For comprehensive code documentation, supported compilers, compiler \r
+ *      For comprehensive code documentation, supported compilers, compiler\r
  *      settings and supported devices see readme.html\r
  *\r
  * \author\r
  *      Atmel Corporation: http://www.atmel.com \n\r
  *      Support email: avr@atmel.com\r
  *\r
- * \r
+ *\r
  * $Name$\r
  * $Revision: 2299 $\r
  * $RCSfile$\r
@@ -67,52 +67,52 @@ void PWM_Start(void)
 {\r
        // Clear OC1B on compare match, enable PWM on comparator OCR1B.\r
        TCCR1A = (1<<COM1B1)|(0<<COM1B0)|(1<<PWM1B);\r
-       \r
+\r
        // Non-inverted PWM, T/C stopped.\r
        TCCR1B = 0;\r
-       \r
+\r
        // Copy shadow bits, disconnect OC1D.\r
        TCCR1C = (TCCR1A & 0xF0);\r
-       \r
+\r
        // No fault protection, use phase & frequency correct PWM.\r
        TCCR1D = (0<<WGM11)|(1<WGM10);\r
-       \r
+\r
        // Does not matter -- PWM6 mode not used.\r
        TCCR1E = 0;\r
-       \r
+\r
        // Does not matter -- OC1A is disabled.\r
        OCR1A = 0;\r
-       \r
+\r
        // Set reset compare level. (Offset is used, or JumperCheck() will fail.)\r
        OCR1B = PWM_OFFSET;\r
-       \r
+\r
        // TOP value for PWM, f(PWM) = 64MHz / 255 = 251kHz.\r
        OCR1C = 0xFF;\r
-       \r
+\r
        // Does not matter -- OC1D is disabled.\r
        OCR1D = 0;\r
-       \r
+\r
        // No dead time values.\r
        DT1 = 0;\r
-       \r
+\r
        // Set PWM port pin to output.\r
        DDRB |= (1<<PB3);\r
-       \r
+\r
        // Enable PLL, use full speed mode.\r
        PLLCSR = (0<<LSM) | (1<<PLLE);\r
-       \r
+\r
        // Use general timer and wait 1 ms for PLL lock to settle.\r
        Time_Set(TIMER_GEN,0,0,1);\r
-       do{ \r
+       do{\r
        }while(Time_Left(TIMER_GEN));\r
-       \r
+\r
        // Now wait for PLL to lock.\r
-       do{ \r
+       do{\r
        }while((PLLCSR & (1<<PLOCK)) == 0);\r
 \r
        // Use PLL as clock source.\r
        PLLCSR |= (1<<PCKE);\r
-       \r
+\r
        // CLK PCK = 64MHz / 1 = 64MHz.\r
        TCCR1B |= (0<<CS13)|(0<<CS12)|(0<<CS11)|(1<<CS10);\r
 }\r
@@ -139,9 +139,9 @@ unsigned char PWM_IncrementDutyCycle(void){
  * \retval TRUE Success, duty cycle could be decremented.\r
  * \retval FALSE Failure, duty cycle already at zero.\r
  */\r
-unsigned char PWM_DecrementDutyCycle(void){\r
-       \r
-       if (OCR1B > 0)  {\r
+unsigned char PWM_DecrementDutyCycle(void) {\r
+\r
+       if (OCR1B > 0) {\r
                OCR1B -= 1;\r
                return(TRUE);\r
        } else {\r