Hi My friends
I'm trying to make IR remote control receiver using atmega8 u controller, using atmel studio 7,
I've created the main file main.c and included the library header file, but when compiling the project I've get
punch of errors and after googling i found some one recommend changing the main file name from main.c to main.cpp ,and re compile, after doing this really it solve many many issues (and i don't know why ? !),
but i stuck with two errors
1- ID returned 1 Exit Status
2- recipe for target IRRemote.elf failed
so please if any one can help to get the hex file ?
main.cpp
#define recvPin 0
#define outPutPin1 1
#define outPutOin2 2
#include <avr/io.h>
#include "IRremote.h"
int main(void)
{
IRrecv irRecv(recvPin);
decode_results results;
irRecv.enableIRIn();
DDRC=(1<<2|1<<1|0<<0);
while (1)
{
if(irRecv.decode(&results))
{
switch(results.value)
{
case 0xFD00FF:
PORTC=(1<<1);
break;
case 0xFD807F:
PORTC=(1<<2);
break;
}
}
}
}
IRremot.h
#ifndef IRremote_h
#define IRremote_h
//------------------------------------------------------------------------------
// The ISR header contains several useful macros the user may wish to use
//
#include "IRremoteInt.h"
//------------------------------------------------------------------------------
// Supported IR protocols
// Each protocol you include costs memory and, during decode, costs time
// Disable (set to 0) all the protocols you do not need/want!
//
#define DECODE_NEC 1
#define SEND_NEC 1
//------------------------------------------------------------------------------
// When sending a Pronto code we request to send either the "once" code
// or the "repeat" code
// If the code requested does not exist we can request to fallback on the
// other code (the one we did not explicitly request)
//
// I would suggest that "fallback" will be the standard calling method
// The last paragraph on this page discusses the rationale of this idea:
// http://www.remotecentral.com/features/irdisp2.htm
//
#define PRONTO_ONCE false
#define PRONTO_REPEAT true
#define PRONTO_FALLBACK true
#define PRONTO_NOFALLBACK false
//------------------------------------------------------------------------------
// An enumerated list of all supported formats
// You do NOT need to remove entries from this list when disabling protocols!
//
typedef
enum {
UNKNOWN = -1,
UNUSED = 0,
RC5,
RC6,
NEC,
SONY,
PANASONIC,
JVC,
SAMSUNG,
WHYNTER,
AIWA_RC_T501,
LG,
SANYO,
MITSUBISHI,
DISH,
SHARP,
DENON,
PRONTO,
LEGO_PF,
}
decode_type_t;
//------------------------------------------------------------------------------
// Set DEBUG to 1 for lots of lovely debug output
//
#define DEBUG 0
//------------------------------------------------------------------------------
// Debug directives
//
#if DEBUG
define DBG_PRINT(...) Serial.print(VA_ARGS)
define DBG_PRINTLN(...) Serial.println(VA_ARGS)
#else
define DBG_PRINT(...)
define DBG_PRINTLN(...)
#endif
//------------------------------------------------------------------------------
// Mark & Space matching functions
//
int MATCH (int measured, int desired) ;
int MATCH_MARK (int measured_ticks, int desired_us) ;
int MATCH_SPACE (int measured_ticks, int desired_us) ;
//------------------------------------------------------------------------------
// Results returned from the decoder
//
class decode_results
{
public:
decode_type_t decode_type; // UNKNOWN, NEC, SONY, RC5, ...
unsigned int address; // Used by Panasonic & Sharp [16-bits]
unsigned long value; // Decoded value [max 32-bits]
int bits; // Number of bits in decoded value
volatile unsigned int *rawbuf; // Raw intervals in 50uS ticks
int rawlen; // Number of records in rawbuf
int overflow; // true iff IR raw code too long
};
//------------------------------------------------------------------------------
// Decoded value for NEC when a repeat code is received
//
#define REPEAT 0xFFFFFFFF
//------------------------------------------------------------------------------
// Main class for receiving IR
//
class IRrecv
{
public:
IRrecv (int recvpin) ;
IRrecv (int recvpin, int blinkpin);
void blink13 (int blinkflag) ;
int decode (decode_results *results) ;
void enableIRIn ( ) ;
bool isIdle ( ) ;
void resume ( ) ;
private:
long decodeHash (decode_results *results) ;
int compare (unsigned int oldval, unsigned int newval) ;
//......................................................................
//......................................................................
if DECODE_NEC
bool decodeNEC (decode_results *results) ;
endif
} ;
//------------------------------------------------------------------------------
// Main class for sending IR
//
class IRsend
{
public:
#ifdef USE_SOFT_CARRIER
IRsend(int pin = SEND_PIN)
{
sendPin = pin;
}
#else
IRsend()
{
}
#endif
void custom_delay_usec (unsigned long uSecs);
void enableIROut (int khz) ;
void mark (unsigned int usec) ;
void space (unsigned int usec) ;
void sendRaw (const unsigned int buf[], unsigned int len, unsigned int hz) ;
//......................................................................
//......................................................................
if SEND_NEC
void sendNEC (unsigned long data, int nbits) ;
endif
//......................................................................
#ifdef USE_SOFT_CARRIER
private:
int sendPin;
unsigned int periodTime;
unsigned int periodOnTime;
void sleepMicros(unsigned long us);
void sleepUntilMicros(unsigned long targetTime);
#else
const int sendPin = SEND_PIN;
#endif
} ;
#endif