示例#1
0
int main(void) {
    uint16_t flash;
 
    DDRB = _BV(LED) | _BV(IRLED);    //set the visible and IR LED pins to outputs
    PORTB = _BV(LED) | _BV(IRLED);   //LEDs are off when pins are high
    OCR0A = (uint8_t)freq_to_timerval(38000); //value for 38kHz
    TCCR0A = 0;   //stop timer0
    TCCR0B = 0;
 
    flash = 0;
    while(1) {
        flash++;
        if (flash == 2000)
          PORTB &= ~_BV(LED);      //turn on visible LED at PB0 by pulling pin to ground
        //measured AIM beacon pattern [inverted by PNA4602M]:
        //high 6ms/low 624us/high 1.2ms/low 624us/high 1.2ms/low 624us [repeat]
        //Alternative Private Beacon Code:
        //300us ON / 1200us OFF / 300us ON / 1200us OFF / 300us ON / 6000us OFF
        //900us ON/9300us = 9.7% duty time
        xmitCodeElement(622, 1195);  //timing tweaked via AVR Studio Stopwatch
        xmitCodeElement(622, 1195);
        xmitCodeElement(622, 5994);  //IRLED on 1.872ms/off 8.4ms = 18.2% on time
        if (flash == 2005) {
          PORTB |= _BV(LED);       //turn off visible LED
          flash = 0;
        }
    }
}
示例#2
0
文件: main.c 项目: sk1p/TV-B-Gone-kit
int main(void) {
  uint8_t i;
  
  TCCR1 = 0;		   // Turn off PWM/freq gen, should be off already
  TCCR0A = 0;
  TCCR0B = 0;

  i = MCUSR;                     // Save reset reason
  MCUSR = 0;                     // clear watchdog flag
  WDTCR = _BV(WDCE) | _BV(WDE);  // enable WDT disable

  WDTCR = 0;                     // disable WDT while we setup

  DDRB = _BV(LED) | _BV(IRLED);   // set the visible and IR LED pins to outputs
  PORTB = _BV(LED) |              //  visible LED is off when pin is high
          _BV(IRLED) |            // IR LED is off when pin is high
          _BV(REGIONSWITCH);     // Turn on pullup on region switch pin

  // check the reset flags
  if (i & _BV(BORF)) {    // Brownout
    // Flash out an error and go to sleep
    flashslowLEDx(2);	
    tvbgone_sleep();  
  }

  delay_ten_us(5000);            // Let everything settle for a bit

  // Starting execution loop
  delay_ten_us(25000);
  
  // turn on watchdog timer immediately, this protects against
  // a 'stuck' system by resetting it
  wdt_enable(WDTO_8S); // 1 second long timeout

  wdt_reset();

  // set OCR for Timer1 to output this POWER code's carrier frequency
  // XXX we need to set the carrier frequency to 32700 Hz, I think
  OCR0A = freq_to_timerval(32700);

  // XXX change 733 to 536 to change mode?
  // XXX emit burst...
  xmitCodeElement(45, 733, 1);
  // XXX emit second burst
  xmitCodeElement(45, 733, 1);
  
  // We are done, no need for a watchdog timer anymore
  wdt_disable();

  // flash the visible LED on PB0  4 times to indicate that we're done
  delay_ten_us(65500); // wait maxtime 
  delay_ten_us(65500); // wait maxtime 
  quickflashLEDx(4);

  tvbgone_sleep();
}
示例#3
0
void sendCode(struct IrCode code, const uint16_t* times, const uint8_t* codes) {

    uint16_t ontime, offtime;

    // Read the carrier frequency from the first byte of code structure
    const uint8_t freq = (code.freq == 0) ? 0 : freq_to_timerval(code.freq);
    // set OCR for Timer1 to output this POWER code's carrier frequency
    OCR0A = freq;
    // OCR0B = freq / 3; // 33% duty cycle


    // Get the number of pairs, the second byte from the code struct
    const uint8_t numpairs = code.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 = code.bitcompression;
    
    // Print out the frequency of the carrier and the PWM settings
#if DEBUG
    DEBUGP(putstring("\n\rOCR1: ");
    putnum_ud(freq);
    );
示例#4
0
* "The tricky part of TV-B-Gone was collecting all of the POWER codes, and 
* getting rid of the duplicates and near-duplicates (because if there is a 
* duplicate, then one POWER code will turn a TV off, and the duplicate will 
* turn it on again (which we certainly do not want)."
*
* Thanks to Albert Yarusso (http://www.atariage.com) for helping with porting
* and debugging.
*
*******************************************************************************/
#include "FslTypes.h"
#include "DC16.h"


// Code 420 -- macs lol
static powercode appleCode  = {
  freq_to_timerval(37470), // 37.47 KHz  
{{907,453},
{70,70  },
{70,177 },
{70,177 },
{70,177 },
{70,70  },
{70,177 },
{70,177 },
{70,177 },
{70,177 },
{70,177 },
{70,177 },
{70,70  },
{70,70  },
{70,70  },
示例#5
0
*/
const uint8_t code_ACCodes[] PROGMEM = {
0x04,
0x94,
0x49,
0x28,
0xA2,
0x92,
0x48,
0x92,
0x89,
0x25,
0x24,
0x52,
0x4E,
0x30
};
const struct IrCode code_ACCode PROGMEM = {
  freq_to_timerval(38462),
  36,		// # of pairs
  3,		// # of bits per index
  code_ACTimes,
  code_ACCodes
};


const struct IrCode *ACpowerCodes[] PROGMEM = {
&code_ACCode };

uint8_t num_ACcodes = NUM_ELEM(ACpowerCodes);
示例#6
0
#include <avr/io.h>             // this contains all the IO port definitions
#include <avr/pgmspace.h>       // definitions or keeping constants in program memory
#include "main.h"

// table of POWER codes

#define freq_to_timerval(x) ((F_CPU / x - 1 )/ 2)

  
// Code 000 -- Sony, Baur, Neckermann, Otto Versand, Palladium, Quelle, SEI, Sinudyne, Sonolor, Universum
const struct powercode sonyCode PROGMEM = {
  freq_to_timerval(37470), // 37.47 KHz  
  {{245, 60},
   {123, 60},
   {61 , 60},
   {123, 60},
   {61 , 60},
   {123, 60},
   {61 , 60},
   {61 , 60},
   {123, 60},
   {61 , 60},
   {61 , 60},
   {61 , 60},
   {61 , 2759},
   {245, 60},
   {123, 60},
   {61 , 60},
   {123, 60},
   {61 , 60},
   {123, 60},
示例#7
0
#include <avr/io.h>             // this contains all the IO port definitions
#include <avr/pgmspace.h>       // definitions or keeping constants in program memory
#include "main.h"

// table of POWER codes

#define freq_to_timerval(x) ((F_CPU / x - 1 )/ 2)

const struct powercode sony PROGMEM = {
 freq_to_timerval(37520.0),   // Code 000 -- Sony, Baur and a few others
 {{ 245,    60 },
  { 123,    60 },
  {  61,    60 },
  { 123,    60 },
  {  61,    60 },
  { 123,    60 },
  {  61,    60 },
  {  61,    60 },
  { 123,    60 },
  {  61,    60 },
  {  61,    60 },
  {  61,    60 },
  {  61,  2758 },
  { 246,    60 },
  { 123,    60 },
  {  61,    60 },
  { 123,    60 },
  {  61,    60 },
  { 123,    60 },
  {  61,    60 },
  {  61,    60 },