Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

v13: temp can read below 0 degrees F

  • Loading branch information...
commit 4accd6a2ff11210beee2246fadea68258085ae9b 0 parents
Aaron Weiss authored
555 IR_eval/Makefile
@@ -0,0 +1,555 @@
+# Hey Emacs, this is a -*- makefile -*-
+#----------------------------------------------------------------------------
+# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
+#
+# Released to the Public Domain
+#
+# Additional material for this makefile was written by:
+# Peter Fleury
+# Tim Henigan
+# Colin O'Flynn
+# Reiner Patommel
+# Markus Pfaff
+# Sander Pool
+# Frederik Rouleau
+#
+#----------------------------------------------------------------------------
+# On command line:
+#
+# make all = Make software.
+#
+# make clean = Clean out built project files.
+#
+# make coff = Convert ELF to AVR COFF.
+#
+# make extcoff = Convert ELF to AVR Extended COFF.
+#
+# make program = Download the hex file to the device, using avrdude.
+# Please customize the avrdude settings below first!
+#
+# make debug = Start either simulavr or avarice as specified for debugging,
+# with avr-gdb or avr-insight as the front end for debugging.
+#
+# make filename.s = Just compile filename.c into the assembler code only.
+#
+# make filename.i = Create a preprocessed source file for use in submitting
+# bug reports to the GCC project.
+#
+# To rebuild project do "make clean" then "make all".
+#----------------------------------------------------------------------------
+
+
+
+# MCU name
+MCU = atmega328p
+
+
+# Processor frequency.
+# This will define a symbol, F_CPU, in all source code files equal to the
+# processor frequency. You can then use this symbol in your source code to
+# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+# automatically to create a 32-bit value in your source code.
+F_CPU = 8000000
+
+
+# Output format. (can be srec, ihex, binary)
+FORMAT = ihex
+
+
+# Target file name (without extension).
+TARGET = main
+
+
+# List C source files here. (C dependencies are automatically generated.)
+SRC = $(TARGET).c
+
+
+# List Assembler source files here.
+# Make them always end in a capital .S. Files ending in a lowercase .s
+# will not be considered source files but generated files (assembler
+# output from the compiler), and will be deleted upon "make clean"!
+# Even though the DOS/Win* filesystem matches both .s and .S the same,
+# it will preserve the spelling of the filenames, and gcc itself does
+# care about how the name is spelled on its command-line.
+ASRC =
+
+
+# Optimization level, can be [0, 1, 2, 3, s].
+# 0 = turn off optimization. s = optimize for size.
+# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
+OPT = s
+
+
+# Debugging format.
+# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
+# AVR Studio 4.10 requires dwarf-2.
+# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
+DEBUG = dwarf-2
+
+
+# List any extra directories to look for include files here.
+# Each directory must be seperated by a space.
+# Use forward slashes for directory separators.
+# For a directory that has spaces, enclose it in quotes.
+EXTRAINCDIRS =
+
+
+# Compiler flag to set the C Standard level.
+# c89 = "ANSI" C
+# gnu89 = c89 plus GCC extensions
+# c99 = ISO C99 standard (not yet fully implemented)
+# gnu99 = c99 plus GCC extensions
+CSTANDARD = -std=gnu99
+
+
+# Place -D or -U options here
+CDEFS = -DF_CPU=$(F_CPU)UL
+
+
+# Place -I options here
+CINCS =
+
+
+
+#---------------- Compiler Options ----------------
+# -g*: generate debugging information
+# -O*: optimization level
+# -f...: tuning, see GCC manual and avr-libc documentation
+# -Wall...: warning level
+# -Wa,...: tell GCC to pass this to the assembler.
+# -adhlns...: create assembler listing
+CFLAGS = -g$(DEBUG)
+CFLAGS += $(CDEFS) $(CINCS)
+CFLAGS += -O$(OPT)
+CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
+CFLAGS += -Wall -Wstrict-prototypes
+CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
+CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
+CFLAGS += $(CSTANDARD)
+
+
+#---------------- Assembler Options ----------------
+# -Wa,...: tell GCC to pass this to the assembler.
+# -ahlms: create listing
+# -gstabs: have the assembler create line number information; note that
+# for use in COFF files, additional information about filenames
+# and function names needs to be present in the assembler source
+# files -- see avr-libc docs [FIXME: not yet described there]
+ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
+
+
+#---------------- Library Options ----------------
+# Minimalistic printf version
+PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires MATH_LIB = -lm below)
+PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
+
+# If this is left blank, then it will use the Standard printf version.
+PRINTF_LIB =
+#PRINTF_LIB = $(PRINTF_LIB_MIN)
+#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
+
+
+# Minimalistic scanf version
+SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
+
+# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
+SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
+
+# If this is left blank, then it will use the Standard scanf version.
+SCANF_LIB =
+#SCANF_LIB = $(SCANF_LIB_MIN)
+#SCANF_LIB = $(SCANF_LIB_FLOAT)
+
+
+MATH_LIB = -lm
+
+
+
+#---------------- External Memory Options ----------------
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# used for variables (.data/.bss) and heap (malloc()).
+#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# only used for heap (malloc()).
+#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
+
+EXTMEMOPTS =
+
+
+
+#---------------- Linker Options ----------------
+# -Wl,...: tell GCC to pass this to linker.
+# -Map: create map file
+# --cref: add cross reference to map file
+LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
+LDFLAGS += $(EXTMEMOPTS)
+LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
+
+
+
+#---------------- Programming Options (avrdude serial bootloader) ----------------
+
+#"C:\arduino\hardware\tools\avr\bin\avrdude" -PCOM3 -c stk500v1 -patmega168 -b19200 -Uflash:w:Simon-PTH-v1.hex -V -F -C"C:\arduino\hardware\tools\avr\etc\avrdude.conf"
+SERIAL_AVRDUDE = C:\WinAVR-20100110\bin\avrdude
+SERIAL_AVRDUDE_CONFIG = C:\WinAVR-20100110\bin\avrdude.conf
+SERIAL_AVRDUDE_PORT = COM7
+SERIAL_AVRDUDE_SPEED = 57600
+SERIAL_AVRDUDE_PROGRAMMER = stk500v1
+
+SERIAL_AVRDUDE_FLAGS = -p $(MCU) -P $(SERIAL_AVRDUDE_PORT) -c $(SERIAL_AVRDUDE_PROGRAMMER) -b $(SERIAL_AVRDUDE_SPEED)
+SERIAL_AVRDUDE_FLAGS += -C$(SERIAL_AVRDUDE_CONFIG)
+SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
+SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
+SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+
+
+#---------------- Programming Options (avrdude) ----------------
+
+# Programming hardware: alf avr910 avrisp bascom bsd
+# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
+#
+# Type: avrdude -c ?
+# to get a full listing.
+AVRDUDE_PROGRAMMER = stk500v1
+#AVRDUDE_PROGRAMMER = ponyser
+
+# com1 = serial port. Use lpt1 to connect to parallel port.
+#AVRDUDE_PORT = lpt1
+AVRDUDE_PORT = COM5
+
+AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE_COUNTER = -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_NO_VERIFY = -V
+
+# Increase verbosity level. Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
+# to submit bug reports.
+#AVRDUDE_VERBOSE = -v -v
+
+AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
+AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
+AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+
+#---------------- Programming Options (STK500) ----------------
+# Programming hardware: stk500 (the AVR MKII ISP version)
+
+STK500 = stk500
+
+# Location of STK500.exe - no trailing '\'
+STK500_PATH = C:\Program Files\Atmel\AVR Tools\STK500
+
+# The STK500 AVR ISP MKII is USB. The USB drivers must already be installed.
+# Do this normally by installing AVR Studio.
+STK500_PORT = USB
+
+#-erase chip -Program Flash -Verify Flash -File name -Serial programing(ISP)
+STK500_WRITE_FLASH = -e -pf -vf -if$(TARGET).hex -ms
+
+STK500_FLAGS = -d$(MCU) -c$(STK500_PORT)
+
+#-Set ISP frequency to 250kHz. Limit is 1/4 of internal osc which is default 1MHz
+#Reduce this to 100kHz if you run into flash verification problems in low-voltage systems
+STK500_FLAGS += -I250kHz
+
+#---------------- Debugging Options ----------------
+
+# For simulavr only - target MCU frequency.
+DEBUG_MFREQ = $(F_CPU)
+
+# Set the DEBUG_UI to either gdb or insight.
+# DEBUG_UI = gdb
+DEBUG_UI = insight
+
+# Set the debugging back-end to either avarice, simulavr.
+DEBUG_BACKEND = avarice
+#DEBUG_BACKEND = simulavr
+
+# GDB Init Filename.
+GDBINIT_FILE = __avr_gdbinit
+
+# When using avarice settings for the JTAG
+JTAG_DEV = /dev/com1
+
+# Debugging port used to communicate between GDB / avarice / simulavr.
+DEBUG_PORT = 4242
+
+# Debugging host used to communicate between GDB / avarice / simulavr, normally
+# just set to localhost unless doing some sort of crazy debugging when
+# avarice is running on a different computer.
+DEBUG_HOST = localhost
+
+
+
+#============================================================================
+
+
+# Define programs and commands.
+SHELL = sh
+CC = avr-gcc
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+NM = avr-nm
+AVRDUDE = avrdude
+REMOVE = rm -f
+COPY = cp
+WINSHELL = cmd
+
+
+# Define Messages
+# English
+MSG_ERRORS_NONE = Errors: none
+MSG_BEGIN = -------- begin --------
+MSG_END = -------- end --------
+MSG_SIZE_BEFORE = Size before:
+MSG_SIZE_AFTER = Size after:
+MSG_COFF = Converting to AVR COFF:
+MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
+MSG_FLASH = Creating load file for Flash:
+MSG_EEPROM = Creating load file for EEPROM:
+MSG_EXTENDED_LISTING = Creating Extended Listing:
+MSG_SYMBOL_TABLE = Creating Symbol Table:
+MSG_LINKING = Linking:
+MSG_COMPILING = Compiling:
+MSG_ASSEMBLING = Assembling:
+MSG_CLEANING = Cleaning project:
+
+
+
+
+# Define all object files.
+OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
+
+# Define all listing files.
+LST = $(SRC:.c=.lst) $(ASRC:.S=.lst)
+
+
+# Compiler flags to generate dependency files.
+GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
+
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+
+
+
+# Default target.
+all: begin gccversion sizebefore build sizeafter end
+
+build: elf hex eep lss sym
+
+elf: $(TARGET).elf
+hex: $(TARGET).hex
+eep: $(TARGET).eep
+lss: $(TARGET).lss
+sym: $(TARGET).sym
+
+
+
+# Eye candy.
+# AVR Studio 3.x does not check make's exit code but relies on
+# the following magic strings to be generated by the compile job.
+begin:
+ @echo
+ @echo $(MSG_BEGIN)
+
+end:
+ @echo $(MSG_END)
+ @echo
+
+
+# Display size of file.
+HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
+#New
+ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf
+#Old
+#ELFSIZE = $(SIZE) -A $(TARGET).elf
+
+AVRMEM = avr-mem.sh $(TARGET).elf $(MCU)
+
+sizebefore:
+ @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
+ $(AVRMEM) 2>/dev/null; echo; fi
+
+sizeafter:
+ @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
+ $(AVRMEM) 2>/dev/null; echo; fi
+
+
+
+# Display compiler version information.
+gccversion :
+ @$(CC) --version
+
+
+
+# Program the device.
+program: $(TARGET).hex $(TARGET).eep
+ $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+program_stk500: $(TARGET).hex $(TARGET).eep
+ $(STK500_PATH)\$(STK500) $(STK500_FLAGS) $(STK500_WRITE_FLASH)
+
+program_serial: $(TARGET).hex $(TARGET).eep
+ $(SERIAL_AVRDUDE) $(SERIAL_AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
+
+# Generate avr-gdb config/init file which does the following:
+# define the reset signal, load the target file, connect to target, and set
+# a breakpoint at main().
+gdb-config:
+ @$(REMOVE) $(GDBINIT_FILE)
+ @echo define reset >> $(GDBINIT_FILE)
+ @echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
+ @echo end >> $(GDBINIT_FILE)
+ @echo file $(TARGET).elf >> $(GDBINIT_FILE)
+ @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE)
+ifeq ($(DEBUG_BACKEND),simulavr)
+ @echo load >> $(GDBINIT_FILE)
+endif
+ @echo break main >> $(GDBINIT_FILE)
+
+debug: gdb-config $(TARGET).elf
+ifeq ($(DEBUG_BACKEND), avarice)
+ @echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
+ @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
+ $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
+ @$(WINSHELL) /c pause
+
+else
+ @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
+ $(DEBUG_MFREQ) --port $(DEBUG_PORT)
+endif
+ @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
+
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
+COFFCONVERT=$(OBJCOPY) --debugging \
+--change-section-address .data-0x800000 \
+--change-section-address .bss-0x800000 \
+--change-section-address .noinit-0x800000 \
+--change-section-address .eeprom-0x810000
+
+
+coff: $(TARGET).elf
+ @echo
+ @echo $(MSG_COFF) $(TARGET).cof
+ $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+ @echo
+ @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
+ $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
+
+
+
+# Create final output files (.hex, .eep) from ELF output file.
+%.hex: %.elf
+ @echo
+ @echo $(MSG_FLASH) $@
+ $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+%.eep: %.elf
+ @echo
+ @echo $(MSG_EEPROM) $@
+ -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+ --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+%.lss: %.elf
+ @echo
+ @echo $(MSG_EXTENDED_LISTING) $@
+ $(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+%.sym: %.elf
+ @echo
+ @echo $(MSG_SYMBOL_TABLE) $@
+ $(NM) -n $< > $@
+
+
+
+# Link: create ELF output file from object files.
+.SECONDARY : $(TARGET).elf
+.PRECIOUS : $(OBJ)
+%.elf: $(OBJ)
+ @echo
+ @echo $(MSG_LINKING) $@
+ $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
+
+
+# Compile: create object files from C source files.
+%.o : %.c
+ @echo
+ @echo $(MSG_COMPILING) $<
+ $(CC) -c $(ALL_CFLAGS) $< -o $@
+
+
+# Compile: create assembler files from C source files.
+%.s : %.c
+ $(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+%.o : %.S
+ @echo
+ @echo $(MSG_ASSEMBLING) $<
+ $(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+# Create preprocessed source for use in sending a bug report.
+%.i : %.c
+ $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
+
+
+# Target: clean project.
+clean: begin clean_list end
+
+clean_list :
+ @echo
+ @echo $(MSG_CLEANING)
+ $(REMOVE) $(TARGET).hex
+ $(REMOVE) $(TARGET).eep
+ $(REMOVE) $(TARGET).cof
+ $(REMOVE) $(TARGET).elf
+ $(REMOVE) $(TARGET).map
+ $(REMOVE) $(TARGET).sym
+ $(REMOVE) $(TARGET).lss
+ $(REMOVE) $(OBJ)
+ $(REMOVE) $(LST)
+ $(REMOVE) $(SRC:.c=.s)
+ $(REMOVE) $(SRC:.c=.d)
+ $(REMOVE) .dep/*
+
+
+
+# Include the dependency files.
+-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
+
+
+# Listing of phony targets.
+.PHONY : all begin finish end sizebefore sizeafter gccversion \
+build elf hex eep lss sym coff extcoff \
+clean clean_list program debug gdb-config
+
+
+
86 IR_eval/defs.h
@@ -0,0 +1,86 @@
+/*! \file avrlibdefs.h \brief AVRlib global defines and macros. */
+//*****************************************************************************
+//
+// File Name : 'avrlibdefs.h'
+// Title : AVRlib global defines and macros include file
+// Author : Pascal Stang
+// Created : 7/12/2001
+// Revised : 9/30/2002
+// Version : 1.1
+// Target MCU : Atmel AVR series
+// Editor Tabs : 4
+//
+// Description : This include file is designed to contain items useful to all
+// code files and projects, regardless of specific implementation.
+//
+// This code is distributed under the GNU Public License
+// which can be found at http://www.gnu.org/licenses/gpl.txt
+//
+//*****************************************************************************
+
+
+#ifndef AVRLIBDEFS_H
+#define AVRLIBDEFS_H
+
+//#define F_CPU 4000000
+#define MEM_TYPE 1
+
+// Code compatibility to new AVR-libc
+// outb(), inb(), inw(), outw(), BV(), sbi(), cbi(), sei(), cli()
+#ifndef outb
+ #define outb(addr, data) addr = (data)
+#endif
+#ifndef inb
+ #define inb(addr) (addr)
+#endif
+#ifndef outw
+ #define outw(addr, data) addr = (data)
+#endif
+#ifndef inw
+ #define inw(addr) (addr)
+#endif
+#ifndef BV
+ #define BV(bit) (1<<(bit))
+#endif
+//#ifndef cbi
+// #define cbi(reg,bit) reg &= ~(BV(bit))
+//#endif
+//#ifndef sbi
+// #define sbi(reg,bit) reg |= (BV(bit))
+//#endif
+#ifndef cli
+ #define cli() __asm__ __volatile__ ("cli" ::)
+#endif
+#ifndef sei
+ #define sei() __asm__ __volatile__ ("sei" ::)
+#endif
+
+// support for individual port pin naming in the mega128
+// see port128.h for details
+#ifdef __AVR_ATmega128__
+// not currently necessary due to inclusion
+// of these defines in newest AVR-GCC
+// do a quick test to see if include is needed
+#ifndef PD0
+ //#include "port128.h"
+#endif
+#endif
+
+// use this for packed structures
+// (this is seldom necessary on an 8-bit architecture like AVR,
+// but can assist in code portability to AVR)
+#define GNUC_PACKED __attribute__((packed))
+
+// port address helpers
+#define DDR(x) ((x)-1) // address of data direction register of port x
+#define PIN(x) ((x)-2) // address of input register of port x
+
+// MIN/MAX/ABS macros
+#define MIN(a,b) ((a<b)?(a):(b))
+#define MAX(a,b) ((a>b)?(a):(b))
+#define ABS(x) ((x>0)?(x):(-x))
+
+// constants
+#define PI 3.14159265359
+
+#endif
84 IR_eval/i2c.h
@@ -0,0 +1,84 @@
+// This library provides the high-level functions needed to use the I2C
+// serial interface supported by the hardware of several AVR processors.
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include "types.h"
+#include "defs.h"
+
+// TWSR values (not bits)
+// (taken from avr-libc twi.h - thank you Marek Michalkiewicz)
+// Master
+#define TW_START 0x08
+#define TW_REP_START 0x10
+// Master Transmitter
+#define TW_MT_SLA_ACK 0x18
+#define TW_MT_SLA_NACK 0x20
+#define TW_MT_DATA_ACK 0x28
+#define TW_MT_DATA_NACK 0x30
+#define TW_MT_ARB_LOST 0x38
+// Master Receiver
+#define TW_MR_ARB_LOST 0x38
+#define TW_MR_SLA_ACK 0x40
+#define TW_MR_SLA_NACK 0x48
+#define TW_MR_DATA_ACK 0x50
+#define TW_MR_DATA_NACK 0x58
+// Slave Transmitter
+#define TW_ST_SLA_ACK 0xA8
+#define TW_ST_ARB_LOST_SLA_ACK 0xB0
+#define TW_ST_DATA_ACK 0xB8
+#define TW_ST_DATA_NACK 0xC0
+#define TW_ST_LAST_DATA 0xC8
+// Slave Receiver
+#define TW_SR_SLA_ACK 0x60
+#define TW_SR_ARB_LOST_SLA_ACK 0x68
+#define TW_SR_GCALL_ACK 0x70
+#define TW_SR_ARB_LOST_GCALL_ACK 0x78
+#define TW_SR_DATA_ACK 0x80
+#define TW_SR_DATA_NACK 0x88
+#define TW_SR_GCALL_DATA_ACK 0x90
+#define TW_SR_GCALL_DATA_NACK 0x98
+#define TW_SR_STOP 0xA0
+// Misc
+#define TW_NO_INFO 0xF8
+#define TW_BUS_ERROR 0x00
+
+// defines and constants
+#define TWCR_CMD_MASK 0x0F
+#define TWSR_STATUS_MASK 0xF8
+
+// return values
+#define I2C_OK 0x00
+#define I2C_ERROR_NODEV 0x01
+
+// functions
+
+//! Initialize I2C (TWI) interface
+void i2cInit(void);
+
+//! Set the I2C transaction bitrate (in KHz)
+void i2cSetBitrate(unsigned short bitrateKHz);
+
+// Low-level I2C transaction commands
+//! Send an I2C start condition in Master mode
+void i2cSendStart(void);
+//! Send an I2C stop condition in Master mode
+void i2cSendStop(void);
+//! Wait for current I2C operation to complete
+void i2cWaitForComplete(void);
+//! Send an (address|R/W) combination or a data byte over I2C
+void i2cSendByte(unsigned char data);
+//! Receive a data byte over I2C
+// ackFlag = TRUE if recevied data should be ACK'ed
+// ackFlag = FALSE if recevied data should be NACK'ed
+void i2cReceiveByte(unsigned char ackFlag);
+//! Pick up the data that was received with i2cReceiveByte()
+unsigned char i2cGetReceivedByte(void);
+//! Get current I2c bus status from TWSR
+unsigned char i2cGetStatus(void);
+
+// high-level I2C transaction commands
+
+//! send I2C data to a device on the bus (non-interrupt based)
+unsigned char i2cMasterSendNI(unsigned char deviceAddr, unsigned char length, unsigned char* data);
+//! receive I2C data from a device on the bus (non-interrupt based)
+unsigned char i2cMasterReceiveNI(unsigned char deviceAddr, unsigned char length, unsigned char *data);
276 IR_eval/main.c
@@ -0,0 +1,276 @@
+/*
+ 12-6-10
+ Copyright Spark Fun Electronics© 2010
+ Aaron Weiss
+ aaron at sparkfun.com
+
+ firmware v13
+
+ MLX90614 IR Temperature Sensor
+
+ ATMega328 w/ external 8MHz resonator
+ High Fuse D9
+ Low Fuse E2
+
+ Baud = 38400bps
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <avr/io.h>
+#include <avr/pgmspace.h>
+#include <avr/interrupt.h>
+#include "types.h"
+#include "defs.h"
+#include "i2c.h"
+
+#define FOSC 8000000
+#define BAUD 38400
+
+#define sbi(var, mask) ((var) |= (uint8_t)(1 << mask))
+#define cbi(var, mask) ((var) &= (uint8_t)~(1 << mask))
+
+#define WRITE_sda() DDRC = DDRC | 0b00010000 //SDA must be output when writing
+#define READ_sda() DDRC = DDRC & 0b11101111 //SDA must be input when reading
+
+///============Function Prototypes=========/////////////////
+void MLX(void);
+
+///============I2C Prototypes=============//////////////////
+void i2cSendStart(void);
+void i2cSendStop(void);
+void i2cWaitForComplete(void);
+void i2cSendByte(unsigned char data);
+void i2cInit(void);
+void i2cHz(long uP_F, long scl_F);
+void i2c_receive_pec(void);
+
+///============Initialize Prototypes=====//////////////////
+void ioinit(void);
+void UART_Init(unsigned int ubrr);
+static int uart_putchar(char c, FILE *stream);
+void put_char(unsigned char byte);
+static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE);
+void delay_ms(uint16_t x);
+
+long Tfr;
+int16_t Tf;
+
+/////===================================////////////////////
+
+int main(void)
+{
+ ioinit();
+ i2cInit();
+ delay_ms(100);
+
+ while(1)
+ {
+ cbi(PORTB, 0);
+ delay_ms(400);
+ MLX();
+ printf("%d.", Tf);
+ printf("%lu\n", Tfr);
+ sbi(PORTB, 0);
+ delay_ms(400);
+ }
+}
+
+void MLX(void)
+{
+ long xh, xl;
+ uint16_t Toreg;
+
+ i2cSendStart();
+ i2cWaitForComplete();
+ i2cSendByte(0x00); //read from slave
+ i2cWaitForComplete();
+ i2cSendByte(0x07); //object temperature 1
+ i2cWaitForComplete();
+ i2cSendStop();
+
+ i2cSendStart();
+ i2cWaitForComplete();
+ i2cSendByte(0x01); //write to slave
+ i2cWaitForComplete();
+ i2cReceiveByte(TRUE);
+ i2cWaitForComplete();
+ xl = i2cGetReceivedByte(); //low byte
+ i2cWaitForComplete();
+
+ i2cReceiveByte(TRUE);
+ i2cWaitForComplete();
+ xh = i2cGetReceivedByte(); //high byte
+ i2cWaitForComplete();
+ i2c_receive_pec() ;
+ i2cSendStop();
+
+ Toreg = (xh << 8)|xl; //concatinate MSB and LSB
+
+ if(Toreg & 0x8000) //if MSbit is 1 there is an error
+ {
+ printf("error\n");
+ }
+
+ //Tk = Toreg / 200;
+ Tf = ((256* xh + xl)*18/5 - 45967)/100;
+ Tfr = ((256* xh + xl)*18/5 - 45967)%100;
+}
+
+/*********************
+ ****Initialize****
+ *********************/
+
+void ioinit (void)
+{
+ //1 = output, 0 = input
+ DDRB = 0b01100001; //PORTB4, B5 output
+ DDRC = 0b00010000; //PORTC4 (SDA), PORTC5 (SCL), PORTC all others are inputs
+ DDRD = 0b11111110; //PORTD (RX on PD0), PD2 is status output
+ PORTC = 0b00110000; //pullups on the I2C bus
+
+ //UART_Init((unsigned int)(FOSC/16/(BAUD*2)-1)); // ocillator fq/16/baud rate -1
+ UART_Init(12);//38400
+}
+
+void UART_Init( unsigned int ubrr)
+{
+ // Set baud rate
+ UBRR0H = ubrr>>8;
+ UBRR0L = ubrr;
+
+ // Enable receiver and transmitter
+ UCSR0A = (0<<U2X0);
+ UCSR0B = (1<<RXEN0)|(1<<TXEN0);
+
+ // Set frame format: 8 bit, no parity, 1 stop bit,
+ UCSR0C = (1<<UCSZ00)|(1<<UCSZ01);
+
+ stdout = &mystdout; //Required for printf init
+}
+
+static int uart_putchar(char c, FILE *stream)
+{
+ if (c == '\n') uart_putchar('\r', stream);
+
+ loop_until_bit_is_set(UCSR0A, UDRE0);
+ UDR0 = c;
+
+ return 0;
+}
+
+void put_char(unsigned char byte)
+{
+ /* Wait for empty transmit buffer */
+ while ( !( UCSR0A & (1<<UDRE0)) );
+ /* Put data into buffer, sends the data */
+ UDR0 = byte;
+}
+
+void delay_ms(uint16_t x)
+{
+ uint8_t y, z;
+ for ( ; x > 0 ; x--){
+ for ( y = 0 ; y < 90 ; y++){
+ for ( z = 0 ; z < 6 ; z++){
+ asm volatile ("nop");
+ }
+ }
+ }
+}
+
+/*********************
+ ****I2C Functions****
+ *********************/
+
+void i2cInit(void)
+{
+ // set i2c bit rate to 80KHz, for some reason much less than this will not work??
+ i2cSetBitrate(30);
+ // enable TWI (two-wire interface)
+ //sbi(TWCR, TWEN);
+}
+
+void i2cSetBitrate(unsigned short bitrateKHz)
+{
+ unsigned char bitrate_div;
+ // set i2c bitrate
+ // SCL freq = F_CPU/(16+2*TWBR))
+ //#ifdef TWPS0
+ // for processors with additional bitrate division (mega128)
+ // SCL freq = F_CPU/(16+2*TWBR*4^TWPS)
+ // set TWPS to zero
+ cbi(TWSR, TWPS0);
+ cbi(TWSR, TWPS1);
+ //#endif
+ // calculate bitrate division
+ bitrate_div = ((F_CPU/4000l)/bitrateKHz);
+ if(bitrate_div >= 16)
+ bitrate_div = (bitrate_div-16)/2;
+ outb(TWBR, bitrate_div);
+}
+
+void i2cSendStart(void)
+{
+ WRITE_sda();
+ // send start condition
+ TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN);
+}
+
+void i2cSendStop(void)
+{
+ // transmit stop condition
+ TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWSTO);
+}
+
+void i2cWaitForComplete(void)
+{
+ int i = 0; //time out variable
+
+ // wait for i2c interface to complete operation
+ while ((!(TWCR & (1<<TWINT))) && (i < 150)) //90
+ i++;
+}
+
+void i2cSendByte(unsigned char data)
+{
+
+ WRITE_sda();
+ // save data to the TWDR
+ TWDR = data;
+ // begin send
+ TWCR = (1<<TWINT)|(1<<TWEN);
+}
+
+void i2cReceiveByte(unsigned char ackFlag)
+{
+ // begin receive over i2c
+ if( ackFlag )
+ {
+ // ackFlag = TRUE: ACK the recevied data
+ outb(TWCR, (inb(TWCR)&TWCR_CMD_MASK)|BV(TWINT)|BV(TWEA));
+ }
+ else
+ {
+ // ackFlag = FALSE: NACK the recevied data
+ outb(TWCR, (inb(TWCR)&TWCR_CMD_MASK)|BV(TWINT));
+ }
+}
+
+unsigned char i2cGetReceivedByte(void)
+{
+ // retieve received data byte from i2c TWDR
+ return( inb(TWDR) );
+}
+
+unsigned char i2cGetStatus(void)
+{
+ // retieve current i2c status from i2c TWSR
+ return( inb(TWSR) );
+}
+
+void i2c_receive_pec(void)
+{
+ TWCR = (1 << TWINT)|(1 << TWEN); // start PEC reception, transmit NACK
+ while (!(TWCR & (1 << TWINT)));
+}
195 IR_eval/main.hex
@@ -0,0 +1,195 @@
+:100000000C9434000C9451000C9451000C94510049
+:100010000C9451000C9451000C9451000C9451001C
+:100020000C9451000C9451000C9451000C9451000C
+:100030000C9451000C9451000C9451000C945100FC
+:100040000C9451000C9451000C9451000C945100EC
+:100050000C9451000C9451000C9451000C945100DC
+:100060000C9451000C94510011241FBECFEFD8E026
+:10007000DEBFCDBF11E0A0E0B1E0E4EFFBE002C0E5
+:1000800005900D92AE31B107D9F711E0AEE1B1E0C4
+:1000900001C01D92AA32B107E1F70E9406020C943A
+:1000A000F8050C94000081E684B980E187B98EEFF1
+:1000B0008AB980E388B91092C5008CE08093C400AF
+:1000C0001092C00088E18093C10086E08093C20056
+:1000D0008FE091E0909327018093260108959093FB
+:1000E000C5008093C4001092C00088E18093C100D5
+:1000F00086E08093C2008FE091E090932701809387
+:10010000260108951F93182F8A3019F48DE00E945C
+:1001100082008091C00085FFFCCF1093C60080E074
+:1001200090E01F910895982F8091C00085FFFCCF2B
+:100130009093C60008950BC020E00000000000006E
+:100140000000000000002F5F2A35B9F701970097E3
+:1001500099F70895BC018091B9008E7F8093B90012
+:100160008091B9008D7F8093B90080ED97E00E9467
+:100170007005603130F0862F90E040979595879517
+:10018000682F6093B80008958EE190E00E94AA0065
+:1001900008953C9A84EA8093BC00089584E9809392
+:1001A000BC00089520E030E002C02F5F3F4F8091F7
+:1001B000BC0087FD03C026393105B9F708953C9A84
+:1001C0008093BB0084E88093BC000895882329F0C5
+:1001D0008091BC008F70806C04C08091BC008F70D7
+:1001E00080688093BC0008958091BB000895809141
+:1001F000B900089584E88093BC008091BC0087FF1B
+:10020000FCCF0895AF92BF92CF92DF92EF92FF9210
+:100210000F931F933C9A84EA8093BC0020E030E067
+:1002200002C02F5F3F4F8091BC0087FD03C026397D
+:100230003105B9F73C9A1092BB0084E88093BC006A
+:1002400020E030E002C02F5F3F4F8091BC0087FD6F
+:1002500003C026393105B9F73C9A87E08093BB008B
+:1002600084E88093BC0020E030E002C02F5F3F4F65
+:100270008091BC0087FD03C026393105B9F784E9B8
+:100280008093BC003C9A84EA8093BC0020E030E07C
+:1002900002C02F5F3F4F8091BC0087FD03C026390D
+:1002A0003105B9F73C9A81E08093BB0084E88093E4
+:1002B000BC0020E030E002C02F5F3F4F8091BC00C7
+:1002C00087FD03C026393105B9F78091BC008F70D6
+:1002D000806C8093BC0020E030E002C02F5F3F4F75
+:1002E0008091BC0087FD03C026393105B9F78091A4
+:1002F000BB00A82EBB24CC24DD2420E030E002C0CB
+:100300002F5F3F4F8091BC0087FD03C02639310528
+:10031000B9F78091BC008F70806C8093BC0020E0A6
+:1003200030E002C02F5F3F4F8091BC0087FD03C0CB
+:1003300026393105B9F78091BB00E82EFF2400E093
+:1003400010E020E030E002C02F5F3F4F8091BC0002
+:1003500087FD03C026393105B9F784E88093BC00D6
+:100360008091BC0087FFFCCF84E98093BC00B02F54
+:10037000AF2D9E2D88278A299B2997FF04C080E0F6
+:1003800091E00E949F02902F8F2D7E2D66276A0D8F
+:100390007B1D8C1D9D1D22E130E040E050E00E945D
+:1003A000510525E030E040E050E00E9484057901ED
+:1003B0008A0181E79CE4AFEFBFEFE80EF91E0A1F48
+:1003C0001B1FC801B70124E630E040E050E00E9466
+:1003D00084053093230120932201C801B70124E64C
+:1003E00030E040E050E00E94840560931E0170936D
+:1003F0001F0180932001909321011F910F91FF9085
+:10040000EF90DF90CF90BF90AF9008950F931F9320
+:10041000CF93DF9381E684B980E187B98EEF8AB903
+:1004200080E388B91092C5008CE08093C4001092DC
+:10043000C00088E18093C10086E08093C2008FE015
+:1004400091E090932701809326010E94C40084E6E6
+:1004500090E00BC000000000000000000000000061
+:100460002F5F2A35B9F7019711F020E0F3CF06E0AE
+:1004700011E0CAE0D1E0289880E991E00BC00000CB
+:10048000000000000000000000002F5F2A35B9F7CF
+:10049000019711F020E0F3CF0E94020100D000D0BC
+:1004A000EDB7FEB712830183809122019091230161
+:1004B000948383830E948A0200D0EDB7FEB7D28373
+:1004C000C18380911E0190911F01A0912001B091E4
+:1004D000210183839483A583B6830E948A02289A8C
+:1004E00080E991E02DB73EB72A5F3F4F0FB6F894F1
+:1004F0003EBF0FBE2DBF0CC000000000000000007A
+:10050000000000002F5F2A35B9F7019709F4B3CF37
+:1005100020E0F2CFA0E0B0E0E0E9F2E00C94D105F9
+:10052000FE0135966191719180912601909127018C
+:10053000AF010E94D4022096E2E00C94ED050F93E7
+:100540001F93CF93DF938C01E0912601F091270157
+:10055000838181FF21C0C0E0D0E00DC0E091260181
+:10056000F091270120853185BF01F9010995892B7B
+:1005700011F0CFEFDFEFF80181918F01882371F740
+:10058000E0912601F0912701208531858AE0BF01A5
+:10059000F9010995892B11F0CFEFDFEFCE01DF9143
+:1005A000CF911F910F910895ABE0B0E0EAEDF2E03A
+:1005B0000C94C1053C012B015A01FC0117821682E3
+:1005C000838181FD03C06FEF7FEFC6C19AE0892E62
+:1005D0001E010894211C311CF3012381F20123FD2B
+:1005E000859123FF81912F01882309F4B2C18532BF
+:1005F00039F423FD859123FF81912F01853229F460
+:1006000090E0B3010E94C704E7CF982FFF24EE24A7
+:100610009924FFE1FF15D0F09B3269F09C3228F459
+:10062000903259F0933291F40EC09D3249F09033DC
+:1006300069F441E024C052E0F52A84E0F82A28C099
+:1006400098E0F92A25C0E0E1FE2A22C0F7FC29C083
+:10065000892F80538A3070F4F6FE05C0989C902C48
+:100660001124980E15C0E89CE02C1124E80EF0E24D
+:10067000FF2A0EC09E3229F4F6FC6BC140E4F42A36
+:1006800007C09C3619F450E8F52A02C0983649F4A0
+:10069000F20123FD959123FF91912F01992309F0F8
+:1006A000B8CF892F8554833018F08052833038F4C6
+:1006B00044E050E0A40EB51E5FE359830FC09336AB
+:1006C00031F0933779F0933509F056C020C0F50129
+:1006D0008081898342E050E0A40EB51E610101E0F3
+:1006E00010E012C0F501C080D180F6FC03C06FEFAE
+:1006F0007FEF02C0692D70E042E050E0A40EB51E0D
+:10070000C6010E94BC048C015FE7F52214C0F5010C
+:10071000C080D180F6FC03C06FEF7FEF02C0692D6F
+:1007200070E042E050E0A40EB51EC6010E94B10484
+:100730008C0150E8F52AF3FE07C01AC080E290E071
+:10074000B3010E94C704EA948E2D90E008171907A0
+:10075000A8F30EC0F601F7FC8591F7FE81916F01B9
+:1007600090E0B3010E94C704E110EA9401501040E8
+:100770000115110579F7EAC0943611F0993669F53B
+:10078000F7FE08C0F501208131814281538184E068
+:1007900090E00AC0F501808191819C01442737FDDA
+:1007A0004095542F82E090E0A80EB91E9FE6F922F2
+:1007B00057FF09C050954095309521953F4F4F4FB9
+:1007C0005F4FE0E8FE2ACA01B901A1012AE030E04A
+:1007D0000E94F304D82ED21840C0953729F41F2D5B
+:1007E0001F7E2AE030E01DC01F2D197F9F3661F06B
+:1007F000903720F4983509F0ACC00FC0903739F02D
+:10080000983709F0A6C004C028E030E00AC01061A3
+:1008100014FD146020E130E004C014FD166020E1F6
+:1008200032E017FF08C0F5016081718182819381F8
+:1008300044E050E008C0F50180819181BC0180E076
+:1008400090E042E050E0A40EB51EA1010E94F30426
+:10085000D82ED2188FE7F82EF122F6FE0BC05EEFED
+:10086000F522D91438F4F4FE07C0F2FC05C08FEE6F
+:10087000F82202C01D2D01C0192DF4FE0DC0FE018D
+:10088000ED0DF11D8081803319F499EEF92208C035
+:100890001F5FF2FE05C003C08F2D867809F01F5F31
+:1008A0000F2DF3FC14C0F0FE0FC01E1510F09D2C90
+:1008B0000BC09D2C9E0C911A1E2D06C080E290E06C
+:1008C000B3010E94C7041F5F1E15C0F304C01E15AC
+:1008D00010F4E11A01C0EE2404FF0FC080E390E0A1
+:1008E000B3010E94C70402FF1DC001FD03C088E7D9
+:1008F00090E00EC088E590E00BC0802F867891F0E4
+:1009000001FF02C08BE201C080E2F7FC8DE290E0C3
+:10091000B3010E94C70406C080E390E0B3010E94C7
+:10092000C7049A94D914C0F3DA94F101ED0DF11DC6
+:10093000808190E0B3010E94C704DD20A9F706C0C2
+:1009400080E290E0B3010E94C704EA94EE20C1F770
+:1009500043CEF30166817781CB012B96E2E10C94C3
+:10096000DD05FC010590615070400110D8F78095BD
+:1009700090958E0F9F1F0895FC016150704001906B
+:100980000110D8F7809590958E0F9F1F08950F93B3
+:100990001F93CF93DF938C01EB018B8181FF1BC0F1
+:1009A00082FF0DC02E813F818C819D8128173907E0
+:1009B00064F4E881F9810193F983E88306C0E8854E
+:1009C000F985802F0995892B31F48E819F810196BD
+:1009D0009F838E8302C00FEF1FEFC801DF91CF917D
+:1009E0001F910F910895FA01AA27283051F1203163
+:1009F00081F1E8946F936E7F6E5F7F4F8F4F9F4FB3
+:100A0000AF4FB1E03ED0B4E03CD0670F781F891FF4
+:100A10009A1FA11D680F791F8A1F911DA11D6A0FC2
+:100A2000711D811D911DA11D20D009F468943F9175
+:100A30002AE0269F11243019305D3193DEF6CF0174
+:100A40000895462F4770405D4193B3E00FD0C9F73A
+:100A5000F6CF462F4F70405D4A3318F0495D31FDA7
+:100A60004052419302D0A9F7EACFB4E0A6959795FA
+:100A7000879577956795BA95C9F7009761057105D0
+:100A800008959B01AC010A2E06945795479537951A
+:100A90002795BA95C9F7620F731F841F951FA01D74
+:100AA0000895629FD001739FF001829FE00DF11DB8
+:100AB000649FE00DF11D929FF00D839FF00D749FD8
+:100AC000F00D659FF00D9927729FB00DE11DF91F84
+:100AD000639FB00DE11DF91FBD01CF0111240895E1
+:100AE000AA1BBB1B51E107C0AA1FBB1FA617B70754
+:100AF00010F0A61BB70B881F991F5A95A9F7809570
+:100B00009095BC01CD01089597FB092E05260ED0C6
+:100B100057FD04D014D00AD0001C38F450954095ED
+:100B2000309521953F4F4F4F5F4F0895F6F79095C1
+:100B30008095709561957F4F8F4F9F4F0895A1E2EB
+:100B40001A2EAA1BBB1BFD010DC0AA1FBB1FEE1F47
+:100B5000FF1FA217B307E407F50720F0A21BB30B92
+:100B6000E40BF50B661F771F881F991F1A9469F70E
+:100B700060957095809590959B01AC01BD01CF016A
+:100B800008952F923F924F925F926F927F928F9231
+:100B90009F92AF92BF92CF92DF92EF92FF920F930C
+:100BA0001F93CF93DF93CDB7DEB7CA1BDB0B0FB616
+:100BB000F894DEBF0FBECDBF09942A8839884888D3
+:100BC0005F846E847D848C849B84AA84B984C88469
+:100BD000DF80EE80FD800C811B81AA81B981CE0F60
+:100BE000D11D0FB6F894DEBF0FBECDBFED01089545
+:040BF000F894FFCFA7
+:100BF4006572726F720025642E00256C750A000000
+:0E0C040000000200000000820000000000005E
+:00000001FF
65 IR_eval/types.h
@@ -0,0 +1,65 @@
+//useful things to include in code
+
+#ifndef TYPES_H
+#define TYPES_H
+
+#ifndef WIN32
+ // true/false defines
+ #define FALSE 0
+ #define TRUE -1
+#endif
+
+// datatype definitions macros
+typedef unsigned char u08;
+typedef signed char s08;
+typedef unsigned short u16;
+typedef signed short s16;
+typedef unsigned long u32;
+typedef signed long s32;
+typedef unsigned long long u64;
+typedef signed long long s64;
+
+/* use inttypes.h instead
+// C99 standard integer type definitions
+typedef unsigned char uint8_t;
+typedef signed char int8_t;
+typedef unsigned short uint16_t;
+typedef signed short int16_t;
+typedef unsigned long uint32_t;
+typedef signed long int32_t;
+typedef unsigned long uint64_t;
+typedef signed long int64_t;
+*/
+// maximum value that can be held
+// by unsigned data types (8,16,32bits)
+#define MAX_U08 255
+#define MAX_U16 65535
+#define MAX_U32 4294967295
+
+// maximum values that can be held
+// by signed data types (8,16,32bits)
+#define MIN_S08 -128
+#define MAX_S08 127
+#define MIN_S16 -32768
+#define MAX_S16 32767
+#define MIN_S32 -2147483648
+#define MAX_S32 2147483647
+
+#ifndef WIN32
+ // more type redefinitions
+ typedef unsigned char BOOL;
+ typedef unsigned char BYTE;
+ typedef unsigned int WORD;
+ typedef unsigned long DWORD;
+
+ typedef unsigned char UCHAR;
+ typedef unsigned int UINT;
+ typedef unsigned short USHORT;
+ typedef unsigned long ULONG;
+
+ typedef char CHAR;
+ typedef int INT;
+ typedef long LONG;
+#endif
+
+#endif
2  README.txt
@@ -0,0 +1,2 @@
+All files are released under Creative Commons Attribution:
+http://creativecommons.org/licenses/by/3.0/
Please sign in to comment.
Something went wrong with that request. Please try again.