First you'll need to add ATiny13 support to your Arduino IDE. See:
https://github.com/MCUdude/MicroCore and jump down to 'Boards Manager Installation'. Once installed read the page I linked *properly*!
You can force the Arduino IDE's code munger (that's supposed to make it easy to use by auto-generating function prototypes) to *NOT* parse your C/C++ source during build and ruin it!
Here's what should be in your sketch:
/**
* Dummy .ino file for C/C++ compatibility.
* See: http://www.gammon.com.au/forum/?id=12625
*
* N.B. DO *NOT* call any file in the project 'main.cpp' - it clashes with an
* Arduino one. Also, no .c or .cpp file can have the same name as the sketch.
*
* This file should be empty apart from documentation comments and a list of
* *LIBRARY* headers (i.e. extra Arduino libraries #included as <...>, not part
* of the core) to tell IDE what to build with. eg:
*
* #include <Servo.h> // Arduino Servo library
*
*/
/**
* Copyright (c) 2016, Łukasz Marcin Podkalicki <lpodkalicki@gmail.com>
* ATtiny13/013
* NEC proto analyzer. Example of monblocking IR signal reader (38kHz, TSOPxxx) and NEC protocol decoder.
* Settings:
* FUSE_L=0x7A
* FUSE_H=0xFF
* F_CPU=9600000
*/
I suggest saving the sketch as
IRtiny13. You *MUST* then close it.
You'll need to copy all the source files and headers from Łukasz's Github repository:
ir.h,
uart.h,
ir.c,
main.c,
uart.cto your sketch folder. You can now reopen the sketch.
You'll need somewhere to put global #defines as the Arduino IDE doesn't let you set them to be passed to GCC on a per-sketch basis, so add a new tab (file) to the sketch called
IRtiny13.h and paste the following into it:
/**
* Project global #defines
*
* The Arduino IDE desn't let you pass global defines to GCC so we
* must #include them in *all* .c and .cpp files in the project as:
*
* #include "IRtiny13.h" // Project global #defines
*
*/
#define F_CPU (9600000UL) // 9.6MHz internal oscillator
#define UART_BAUDRATE (115200UL) // Min. baud rate at this F_CPU is 57600
Finally, go to each .c tab and add the line:
#include "IRtiny13.h" // Project global #defines
before any other #include lines.
It should now build cleanly. Its up to you to figure out how the fuses need to be set (See:
https://www.engbedded.com/fusecalc ) and how to program an ATtiny13 from the Arduino IDE.