Permalink
Browse files

code clean up

getting rid of all the debug code as that should not be in production code

Signed-off-by: Scott Gustafson <scott@garlicsoftware.com>
  • Loading branch information...
scott-42 committed Feb 29, 2012
1 parent 7fc4877 commit cc0777bc59c944f0192e304fbac9b11b9e76e4e6
Showing with 1 addition and 160 deletions.
  1. +1 −1 firmware/Makefile
  2. +0 −35 firmware/main.c
  3. +0 −10 firmware/main.h
  4. +0 −91 firmware/util.c
  5. +0 −23 firmware/util.h
View
@@ -14,7 +14,7 @@ TARGET = tvbgone
OPT = s
# List C source files here. (C dependencies are automatically generated.)
-SRC = main.c WORLDcodes.c util.c
+SRC = main.c WORLDcodes.c
# List Assembler source files here.
# Make them always end in a capital .S. Files ending in a lowercase .s
View
@@ -19,7 +19,6 @@ depending on a pulldown resistor on pin B1 !
#include <avr/pgmspace.h> // definitions or keeping constants in program memory
#include <avr/wdt.h>
#include "main.h"
-#include "util.h"
/*
@@ -208,8 +207,6 @@ int main(void) {
_BV(IRLED) | // IR LED is off when pin is high
_BV(REGIONSWITCH); // Turn on pullup on region switch pin
- DEBUGP(putstring_nl("Hello!"));
-
// check the reset flags
if (i & _BV(BORF)) { // Brownout
// Flash out an error and go to sleep
@@ -222,10 +219,8 @@ int main(void) {
// determine region
if (PINB & _BV(REGIONSWITCH)) {
region = US; // US
- DEBUGP(putstring_nl("US"));
} else {
region = EU;
- DEBUGP(putstring_nl("EU"));
}
// Tell the user what region we're in - 3 is US 4 is EU
@@ -238,10 +233,6 @@ int main(void) {
// a 'stuck' system by resetting it
wdt_enable(WDTO_8S); // 1 second long timeout
- // Indicate how big our database is
- DEBUGP(putstring("\n\rNA Codesize: "); putnum_ud(num_NAcodes););
- DEBUGP(putstring("\n\rEU Codesize: "); putnum_ud(num_EUcodes););
-
do { //Execute the code at least once. If Loop is on, execute forever.
// We may have different number of codes in either database
@@ -253,10 +244,6 @@ int main(void) {
// for every POWER code in our collection
for(i=0 ; i < j; i++) {
-
- // print out the code # we are about to transmit
- DEBUGP(putstring("\n\r\n\rCode #: "); putnum_ud(i));
-
//To keep Watchdog from resetting in middle of code.
wdt_reset();
@@ -267,26 +254,17 @@ int main(void) {
code_ptr = (PGM_P)pgm_read_word(EUpowerCodes+i);
}
- // print out the address in ROM memory we're reading
- DEBUGP(putstring("\n\rAddr: "); putnum_uh(code_ptr));
-
// Read the carrier frequency from the first byte of code structure
const uint8_t freq = pgm_read_byte(code_ptr++);
// set OCR for Timer1 to output this POWER code's carrier frequency
OCR0A = freq;
- // Print out the frequency of the carrier and the PWM settings
- DEBUGP(putstring("\n\rOCR1: "); putnum_ud(freq););
- DEBUGP(uint16_t x = (freq+1) * 2; putstring("\n\rFreq: "); putnum_ud(F_CPU/x););
-
// Get the number of pairs, the second byte from the code struct
const uint8_t numpairs = pgm_read_byte(code_ptr++);
- DEBUGP(putstring("\n\rOn/off pairs: "); putnum_ud(numpairs));
// Get the number of bits we use to index into the timer table
// This is the third byte of the structure
const uint8_t bitcompression = pgm_read_byte(code_ptr++);
- DEBUGP(putstring("\n\rCompression: "); putnum_ud(bitcompression));
// Get pointer (address in memory) to pulse-times table
// The address is 16-bits (2 byte, 1 word)
@@ -300,19 +278,6 @@ int main(void) {
// transmitting offTime means no output from the IR emitters for the
// length of time specified in offTime
- /*
- // print out all of the pulse pairs
- for (uint8_t k=0; k<numpairs; k++) {
- uint8_t ti;
- ti = (read_bits(bitcompression)) * 4;
- // read the onTime and offTime from the program memory
- ontime = pgm_read_word(time_ptr+ti);
- offtime = pgm_read_word(time_ptr+ti+2);
- DEBUGP(putstring("\n\rti = "); putnum_ud(ti>>2); putstring("\tPair = "); putnum_ud(ontime));
- DEBUGP(putstring("\t"); putnum_ud(offtime));
- }
- */
-
// For EACH pair in this code....
for (uint8_t k=0; k<numpairs; k++) {
uint8_t ti;
View
@@ -7,14 +7,6 @@
#define US 0
#define EU 1
-// Lets us calculate the size of the NA/EU databases
-#define NUM_ELEM(x) (sizeof (x) / sizeof (*(x)));
-
-// set define to 0 to turn off debug output
-#define DEBUG 0
-#define DEBUGP(x) if (DEBUG == 1) { x ; }
-
-
// Shortcut to insert single, non-optimized-out nop
#define NOP __asm__ __volatile__ ("nop")
@@ -26,8 +18,6 @@
// is, the inverse!
#define freq_to_timerval(x) ((F_CPU / x - 1)/ 2)
-#define PULSE_CODE 0
-
// The structure of compressed code entries
struct IrCode {
uint8_t timer_val;
View
@@ -1,91 +0,0 @@
-#include <avr/io.h> // this contains all the IO port definitions
-#include <avr/interrupt.h> // definitions for interrupts
-#include "main.h"
-#include "util.h"
-
-#define TXPORT PORTB
-#define TX 2
-
-#if (DEBUG == 1)
-
-#define SERIALDELAY 57 // to make 19200 baud
-void serialdelay(void) {
- uint16_t timer;
- for (timer=0; timer <= SERIALDELAY; timer++) {
- NOP;
- }
-}
-
-
-void uart_putchar(char d) {
- int i;
- cli(); // turn off interrupts, make it nice & kleen
-
- TXPORT &= ~_BV(TX);
- serialdelay();
- for (i=0; i< 8; i++) {
- if (d & 0x1) {
- TXPORT |= _BV(TX);
- } else {
- TXPORT &= ~_BV(TX);
- }
- serialdelay();
- d >>= 1;
- }
- TXPORT |= _BV(TX);
- sei(); // turn on interrupts
- serialdelay();
-}
-
-void printhex(uint8_t hex) {
- hex &= 0xF;
- if (hex < 10)
- uart_putchar(hex + '0');
- else
- uart_putchar(hex + 'A' - 10);
-}
-
-void putnum_uh(uint16_t n) {
- if (n >> 12)
- printhex(n>>12);
- if (n >> 8)
- printhex(n >> 8);
- if (n >> 4)
- printhex(n >> 4);
- printhex(n);
-
- return;
-}
-
-
-void putnum_ud(uint16_t n) {
- uint8_t cnt=0, flag=0;
-
- while (n >= 10000UL) { flag = 1; cnt++; n -= 10000UL; }
- if (flag) uart_putchar('0'+cnt);
- cnt = 0;
- while (n >= 1000UL) { flag = 1; cnt++; n -= 1000UL; }
- if (flag) uart_putchar('0'+cnt);
- cnt = 0;
- while (n >= 100UL) { flag = 1; cnt++; n -= 100UL; }
- if (flag) uart_putchar('0'+cnt);
- cnt = 0;
- while (n >= 10UL) { flag = 1; cnt++; n -= 10UL; }
- if (flag) uart_putchar('0'+cnt);
- cnt = 0;
- uart_putchar('0'+n);
- return;
-}
-
-void ROM_putstring(const char *str, uint8_t nl) {
- uint8_t i;
-
- for (i=0; pgm_read_byte(&str[i]); i++) {
- uart_putchar(pgm_read_byte(&str[i]));
- }
- if (nl) {
- uart_putchar('\n'); uart_putchar('\r');
- }
-}
-
-#endif
View
@@ -1,23 +0,0 @@
-#include <avr/pgmspace.h>
-
-uint8_t internal_eeprom_read(uint16_t addr);
-void internal_eeprom_write(uint16_t addr, uint8_t data);
-void delay_ms(uint16_t ms);
-void uart_init(uint16_t baud);
-void uart_putchar(char c) ;
-char uart_getchar(void);
-char uart_getch(void);
-void putnum_ud(uint16_t n);
-void putnum_uh(uint16_t n);
-void printhex(uint8_t hex);
-void ROM_putstring(const char *str, uint8_t) ;
-void RAM_putstring(char *str, uint8_t) ;
-uint16_t uart_read16(void);
-void print_div(void);
-
-#define putstring(x) ROM_putstring(PSTR(x), 0)
-#define putstring_nl(x) ROM_putstring(PSTR(x), 1)
-//#define putstring(x) RAM_putstring(x)
-
-#define NOP __asm__ __volatile__ ("nop")
-

0 comments on commit cc0777b

Please sign in to comment.