initial
This commit is contained in:
59
Makefile
Normal file
59
Makefile
Normal file
@@ -0,0 +1,59 @@
|
||||
TARGET = main
|
||||
SRCS := $(shell find -name '*.c')
|
||||
FILES = $(SRCS:%.c=%) #main uart avrIOhelper/io-helper #uart#hier alle c-Datein reinschreiben, trennung durch " " und ohne .c-Endung
|
||||
MCU = atmega16
|
||||
PROGC = m16
|
||||
CC = avr-gcc
|
||||
TOOL = stk500 -P /dev/ttyUSB0
|
||||
#TOOL = atmelice_isp
|
||||
#TOOL = avrispmkii
|
||||
#TOOL = usbasp-clone
|
||||
|
||||
BUILDDIR = Builds
|
||||
|
||||
DEFINES = -DF_CPU=8000000UL
|
||||
|
||||
CFLAGS =-mmcu=$(MCU) -O2 -Wall -Wpedantic $(DEFINES) -std=c99 -ffunction-sections -fdata-sections
|
||||
LDFLAGS =-mmcu=$(MCU) -Wl,--gc-sections
|
||||
|
||||
LDFILES = $(foreach FILE,$(FILES),$(BUILDDIR)/$(FILE).o)
|
||||
|
||||
all: clean $(BUILDDIR)/$(TARGET).elf
|
||||
|
||||
$(BUILDDIR)/%.o: %.c
|
||||
mkdir -p $(dir $@)
|
||||
$(CC) $(CFLAGS) -c $< -o $(BUILDDIR)/$*.o
|
||||
|
||||
$(BUILDDIR)/$(TARGET).elf: $(LDFILES)
|
||||
mkdir -p $(dir $@)
|
||||
$(CC) $(LDFLAGS) $(LDFILES) -o $(BUILDDIR)/$(TARGET).elf
|
||||
|
||||
$(BUILDDIR)/$(TARGET).hex : $(BUILDDIR)/$(TARGET).elf
|
||||
avr-objcopy -j .data -j .text -O ihex $< $@
|
||||
|
||||
fuse:
|
||||
avrdude -p $(PROGC) -c $(TOOL) -U lfuse:w:0xE8:m -U hfuse:w:0xD1:m
|
||||
|
||||
load: $(BUILDDIR)/$(TARGET).hex
|
||||
avrdude -p $(PROGC) -c $(TOOL) -U flash:w:$(BUILDDIR)/$(TARGET).hex -v -B 4MHz
|
||||
|
||||
program: clean load
|
||||
|
||||
reset:
|
||||
avrdude -p $(PROGC) -c $(TOOL)
|
||||
|
||||
size: $(BUILDDIR)/$(TARGET).elf
|
||||
avr-size -C --mcu=$(MCU) $(BUILDDIR)/$(TARGET).elf
|
||||
|
||||
.PHONY=clean
|
||||
clean:
|
||||
rm -rf $(BUILDDIR)
|
||||
|
||||
|
||||
#Fuse m1284p external Osz. Long startuptime
|
||||
# avrdude -c usbasp-clone -p m1284p -U lfuse:w:0xff:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m
|
||||
|
||||
#Fuse m1284p internal Osz. Long startuptime
|
||||
# avrdude -c usbasp-clone -p m1284p -U lfuse:w:0xe2:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m
|
||||
|
||||
|
||||
13
README.txt
Normal file
13
README.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
IRMP - Infrared Multi Protocol Decoder
|
||||
--------------------------------------
|
||||
|
||||
Version IRMP: 3.2.6 2021-01-27
|
||||
Version IRSND: 3.2.6 2021-01-27
|
||||
|
||||
Documentation:
|
||||
|
||||
http://www.mikrocontroller.net/articles/IRMP
|
||||
http://www.mikrocontroller.net/articles/IRMP_-_english
|
||||
|
||||
http://www.mikrocontroller.net/articles/IRSND
|
||||
http://www.mikrocontroller.net/articles/IRSND_-_english
|
||||
1140
irmpprotocols.h
Normal file
1140
irmpprotocols.h
Normal file
File diff suppressed because it is too large
Load Diff
218
irmpsystem.h
Normal file
218
irmpsystem.h
Normal file
@@ -0,0 +1,218 @@
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* irmpsystem.h - system specific includes and defines
|
||||
*
|
||||
* Copyright (c) 2009-2020 Frank Meyer - frank(at)fli4l.de
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _IRMPSYSTEM_H_
|
||||
#define _IRMPSYSTEM_H_
|
||||
|
||||
#if !defined(_IRMP_H_) && !defined(_IRSND_H_)
|
||||
# error please include only irmp.h or irsnd.h, not irmpsystem.h
|
||||
#endif
|
||||
|
||||
#if defined(__18CXX) // Microchip PIC C18 compiler
|
||||
# define PIC_C18
|
||||
#elif defined(__XC8) // PIC XC8 compiler
|
||||
# include <xc.h>
|
||||
# define PIC_C18
|
||||
#elif defined(__XC32) // XC32 or ChipKit compiler
|
||||
# define PIC_XC32
|
||||
#elif defined(__PCM__) || defined(__PCB__) || defined(__PCH__) // CCS PIC compiler
|
||||
# define PIC_CCS
|
||||
#elif defined(STM32L1XX_MD) || defined(STM32L1XX_MDP) || defined(STM32L1XX_HD) // ARM STM32
|
||||
# include <stm32l1xx.h>
|
||||
# define ARM_STM32
|
||||
# define ARM_STM32L1XX
|
||||
# define F_CPU (SysCtlClockGet())
|
||||
#elif defined(STM32F10X_LD) || defined(STM32F10X_LD_VL) \
|
||||
|| defined(STM32F10X_MD) || defined(STM32F10X_MD_VL) \
|
||||
|| defined(STM32F10X_HD) || defined(STM32F10X_HD_VL) \
|
||||
|| defined(STM32F10X_XL) || defined(STM32F10X_CL) // ARM STM32
|
||||
# include <stm32f10x.h>
|
||||
# define ARM_STM32
|
||||
# define ARM_STM32F10X
|
||||
# define F_CPU (SysCtlClockGet())
|
||||
#elif defined(STM32F30X) // ARM STM32
|
||||
# include <stm32f30x.h>
|
||||
# define ARM_STM32
|
||||
# define ARM_STM32F30X
|
||||
# define F_CPU (SysCtlClockGet())
|
||||
#elif defined(STM32F4XX) // ARM STM32
|
||||
# include <stm32f4xx.h>
|
||||
# define ARM_STM32
|
||||
# define ARM_STM32F4XX
|
||||
# define F_CPU (SysCtlClockGet())
|
||||
#elif defined(USE_HAL_DRIVER) // ARM STM32 with HAL Library
|
||||
# include "gpio.h"
|
||||
# if defined(_IRSND_H_)
|
||||
# include"tim.h"
|
||||
# endif
|
||||
# define ARM_STM32_HAL
|
||||
# define F_CPU SystemCoreClock
|
||||
#elif defined(__SDCC_stm8) // STM8
|
||||
# define SDCC_STM8
|
||||
#elif defined(TARGET_IS_BLIZZARD_RA2) // TI Stellaris (tested on Stellaris Launchpad with Code Composer Studio)
|
||||
# define STELLARIS_ARM_CORTEX_M4
|
||||
# define F_CPU (SysCtlClockGet())
|
||||
#elif defined(__xtensa__) // ESP8266 (Arduino)
|
||||
# include "Arduino.h"
|
||||
# include "ets_sys.h"
|
||||
# include "osapi.h"
|
||||
# include "gpio.h"
|
||||
# include "os_type.h"
|
||||
# include "c_types.h"
|
||||
# define uint_fast8_t uint8_t
|
||||
# define uint_fast16_t uint16_t
|
||||
#elif defined(TEENSYDUINO) && (defined(__MK20DX256__) || defined(__MK20DX128__)) // Teensy 3.x (tested on Teensy 3.1 in Arduino 1.6.5 / Teensyduino 1.2.5)
|
||||
# include <core_pins.h>
|
||||
# define TEENSY_ARM_CORTEX_M4
|
||||
#elif defined(unix) || defined(WIN32) || defined(__APPLE__) // Unix/Linux or Windows or Apple
|
||||
# define UNIX_OR_WINDOWS
|
||||
#elif defined(__MBED__) // mbed platform
|
||||
// #include "mbed.h" // if mbed.h is used, source must be compiled as cpp
|
||||
#include "gpio_api.h"
|
||||
#elif defined(IRMP_CHIBIOS_HAL) // ChibiOS HAL
|
||||
# include "hal.h"
|
||||
#else
|
||||
# define ATMEL_AVR // ATMEL AVR
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef UNIX_OR_WINDOWS // Analyze on Unix/Linux or Windows
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# define F_CPU 8000000L
|
||||
# define ANALYZE
|
||||
# include <stdint.h>
|
||||
# ifdef _MSC_VER
|
||||
# define IRMP_PACKED_STRUCT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(ATMEL_AVR)
|
||||
# include <stdint.h>
|
||||
# include <stdio.h>
|
||||
# include <avr/io.h>
|
||||
# include <util/delay.h>
|
||||
# include <avr/pgmspace.h>
|
||||
# include <avr/interrupt.h>
|
||||
# define IRSND_OC2 0 // OC2
|
||||
# define IRSND_OC2A 1 // OC2A
|
||||
# define IRSND_OC2B 2 // OC2B
|
||||
# define IRSND_OC0 3 // OC0
|
||||
# define IRSND_OC0A 4 // OC0A
|
||||
# define IRSND_OC0B 5 // OC0B
|
||||
|
||||
# define IRSND_XMEGA_OC0A 0 // OC0A
|
||||
# define IRSND_XMEGA_OC0B 1 // OC0B
|
||||
# define IRSND_XMEGA_OC0C 2 // OC0C
|
||||
# define IRSND_XMEGA_OC0D 3 // OC0D
|
||||
# define IRSND_XMEGA_OC1A 4 // OC1A
|
||||
# define IRSND_XMEGA_OC1B 5 // OC1B
|
||||
|
||||
#elif defined(STELLARIS_ARM_CORTEX_M4)
|
||||
|
||||
# include "inc/hw_ints.h"
|
||||
# include "inc/hw_memmap.h"
|
||||
# include "inc/hw_types.h"
|
||||
# include "inc/hw_gpio.h"
|
||||
# include "driverlib/fpu.h"
|
||||
# include "driverlib/sysctl.h"
|
||||
# include "driverlib/interrupt.h"
|
||||
# include "driverlib/gpio.h"
|
||||
# include "driverlib/rom.h"
|
||||
# include "driverlib/systick.h"
|
||||
# include "driverlib/pin_map.h"
|
||||
# include "driverlib/timer.h"
|
||||
# define PROGMEM
|
||||
# define memcpy_P memcpy
|
||||
# define APP_SYSTICKS_PER_SEC 32
|
||||
|
||||
#elif defined(ARM_STM32F10X)
|
||||
|
||||
# include "stm32f10x_gpio.h"
|
||||
# include "stm32f10x_rcc.h"
|
||||
# include "stm32f10x_tim.h"
|
||||
# include "misc.h"
|
||||
# define PROGMEM
|
||||
# define memcpy_P memcpy
|
||||
|
||||
#elif defined(SDCC_STM8)
|
||||
|
||||
# include "stm8s.h"
|
||||
# define PROGMEM
|
||||
# define memcpy_P memcpy
|
||||
# define __attribute__(x)
|
||||
# define uint_fast8_t uint8_t
|
||||
# define uint_fast16_t uint16_t
|
||||
|
||||
#elif defined(TEENSY_ARM_CORTEX_M4)
|
||||
# define PROGMEM
|
||||
# define memcpy_P memcpy
|
||||
|
||||
#elif defined(__xtensa__)
|
||||
# define PROGMEM
|
||||
# define memcpy_P memcpy
|
||||
|
||||
#elif defined(__MBED__)
|
||||
# define PROGMEM
|
||||
# define memcpy_P memcpy
|
||||
|
||||
#else
|
||||
# define PROGMEM
|
||||
# define memcpy_P memcpy
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(PIC_CCS) || defined(PIC_C18)
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned char uint_fast8_t;
|
||||
typedef unsigned short uint_fast16_t;
|
||||
#endif
|
||||
|
||||
#if defined (PIC_C18) // PIC C18 or XC8 compiler
|
||||
# include <p18cxxx.h> // main PIC18 h file
|
||||
#ifndef __XC8
|
||||
# include <timers.h> // timer lib
|
||||
# include <pwm.h> // pwm lib
|
||||
#endif
|
||||
# define IRSND_PIC_CCP1 1 // PIC C18 RC2 = PWM1 module
|
||||
# define IRSND_PIC_CCP2 2 // PIC C18 RC1 = PWM2 module
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
# define TRUE 1
|
||||
# define FALSE 0
|
||||
#endif
|
||||
|
||||
#if defined(PIC_XC32) // XC32 or ChipKit compiler
|
||||
# include <xc.h>
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
#if defined(PIC_C18)
|
||||
# define IRMP_PACKED_STRUCT
|
||||
#else
|
||||
# ifndef IRMP_PACKED_STRUCT
|
||||
# define IRMP_PACKED_STRUCT __attribute__ ((__packed__))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
typedef struct IRMP_PACKED_STRUCT
|
||||
{
|
||||
uint8_t protocol; // protocol, e.g. NEC_PROTOCOL
|
||||
uint16_t address; // address
|
||||
uint16_t command; // command
|
||||
uint8_t flags; // flags, e.g. repetition
|
||||
} IRMP_DATA;
|
||||
|
||||
#endif // _IRMPSYSTEM_H_
|
||||
156
irsnd-main-avr.c
Normal file
156
irsnd-main-avr.c
Normal file
@@ -0,0 +1,156 @@
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* irsnd-main-avr.c - demo main module to test IRSND encoder on AVRs
|
||||
*
|
||||
* Copyright (c) 2010-2020 Frank Meyer - frank(at)fli4l.de
|
||||
*
|
||||
* ATMEGA88 @ 8 MHz internal RC Osc with BODLEVEL 4.3V: lfuse: 0xE2 hfuse: 0xDC efuse: 0xF9
|
||||
* ATMEGA88 @ 8 MHz external Crystal Osc with BODLEVEL 4.3V: lfuse: 0xFF hfuse: 0xDC efuse: 0xF9
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
#include "irsnd.h"
|
||||
|
||||
#ifndef F_CPU
|
||||
# error F_CPU unknown
|
||||
#endif
|
||||
|
||||
void
|
||||
timer1_init (void)
|
||||
{
|
||||
#if defined (__AVR_ATtiny45__) || defined (__AVR_ATtiny85__) // ATtiny45 / ATtiny85:
|
||||
OCR1C = (F_CPU / F_INTERRUPTS / 4) - 1; // compare value: 1/15000 of CPU frequency, presc = 4
|
||||
TCCR1 = (1 << CTC1) | (1 << CS11) | (1 << CS10); // switch CTC Mode on, set prescaler to 4
|
||||
#else // ATmegaXX:
|
||||
OCR1A = (F_CPU / F_INTERRUPTS) - 1; // compare value: 1/15000 of CPU frequency
|
||||
TCCR1B = (1 << WGM12) | (1 << CS10); // switch CTC Mode on, set prescaler to 1
|
||||
#endif
|
||||
|
||||
#ifdef TIMSK1
|
||||
TIMSK1 = 1 << OCIE1A; // OCIE1A: Interrupt by timer compare
|
||||
#else
|
||||
TIMSK = 1 << OCIE1A; // OCIE1A: Interrupt by timer compare
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef TIM1_COMPA_vect // ATtiny84
|
||||
#define COMPA_VECT TIM1_COMPA_vect
|
||||
#else
|
||||
#define COMPA_VECT TIMER1_COMPA_vect // ATmega
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* timer 1 compare handler, called every 1/10000 sec
|
||||
*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
ISR(COMPA_VECT) // Timer1 output compare A interrupt service routine, called every 1/15000 sec
|
||||
{
|
||||
(void) irsnd_ISR(); // call irsnd ISR
|
||||
// call other timer interrupt routines here...
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* MAIN: main routine
|
||||
*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
IRMP_DATA irmp_data;
|
||||
|
||||
irsnd_init(); // initialize irsnd
|
||||
timer1_init(); // initialize timer
|
||||
sei (); // enable interrupts
|
||||
|
||||
|
||||
DDRA = 0x00;
|
||||
PORTA = 0xFF;
|
||||
|
||||
DDRB = 0xFF;
|
||||
PORTB = 0xFF;
|
||||
|
||||
irmp_data.protocol = IRMP_RC6_PROTOCOL; // use NEC protocol
|
||||
irmp_data.flags = 0; // don't repeat frame
|
||||
//
|
||||
for (;;)
|
||||
{
|
||||
//önöff
|
||||
if(~PINA & (1<<0)){
|
||||
PORTB &= ~0x01;
|
||||
irmp_data.address = 0x0000; // set address to 0x00FF
|
||||
irmp_data.command = 0x000C; // set command to 0x0001
|
||||
irsnd_send_data (&irmp_data, TRUE); // send frame, wait for completion
|
||||
_delay_ms (200);
|
||||
PORTB |= 0x01;
|
||||
}
|
||||
|
||||
//OK
|
||||
if(~PINA & (1<<1)){
|
||||
PORTB &= ~(1<<1);
|
||||
irmp_data.address = 0x0000; // set address to 0x00FF
|
||||
irmp_data.command = 0x005C; // set command to 0x0001
|
||||
irsnd_send_data (&irmp_data, TRUE); // send frame, wait for completion
|
||||
_delay_ms (200);
|
||||
PORTB |= 1<<1;
|
||||
}
|
||||
|
||||
//ambi
|
||||
if(~PINA & (1<<2)){
|
||||
PORTB &= ~(1<<2);
|
||||
irmp_data.address = 0x0000; // set address to 0x00FF
|
||||
irmp_data.command = 0x000A; // set command to 0x0001
|
||||
irsnd_send_data (&irmp_data, TRUE); // send frame, wait for completion
|
||||
_delay_ms (200);
|
||||
PORTB |= 1<<2;
|
||||
}
|
||||
|
||||
//rechts
|
||||
if(~PINA & (1<<3)){
|
||||
PORTB &= ~(1<<3);
|
||||
irmp_data.address = 0x0000; // set address to 0x00FF
|
||||
irmp_data.command = 0x005B; // set command to 0x0001
|
||||
irsnd_send_data (&irmp_data, TRUE); // send frame, wait for completion
|
||||
_delay_ms (200);
|
||||
PORTB |= 1<<3;
|
||||
}
|
||||
//links
|
||||
if(~PINA & (1<<4)){
|
||||
PORTB &= ~(1<<4);
|
||||
irmp_data.address = 0x0000; // set address to 0x00FF
|
||||
irmp_data.command = 0x005A; // set command to 0x0001
|
||||
irsnd_send_data (&irmp_data, TRUE); // send frame, wait for completion
|
||||
_delay_ms (200);
|
||||
PORTB |= 1<<4;
|
||||
}
|
||||
//runter
|
||||
if(~PINA & (1<<5)){
|
||||
PORTB &= ~(1<<5);
|
||||
irmp_data.address = 0x0000; // set address to 0x00FF
|
||||
irmp_data.command = 0x0059; // set command to 0x0001
|
||||
irsnd_send_data (&irmp_data, TRUE); // send frame, wait for completion
|
||||
_delay_ms (200);
|
||||
PORTB |= 1<<5;
|
||||
}
|
||||
//hoch
|
||||
if(~PINA & (1<<6)){
|
||||
PORTB &= ~(1<<6);
|
||||
irmp_data.address = 0x0000; // set address to 0x00FF
|
||||
irmp_data.command = 0x0058; // set command to 0x0001
|
||||
irsnd_send_data (&irmp_data, TRUE); // send frame, wait for completion
|
||||
_delay_ms (200);
|
||||
PORTB |= 1<<6;
|
||||
}
|
||||
//Menu
|
||||
if(~PINA & (1<<7)){
|
||||
PORTB &= ~(1<<7);
|
||||
irmp_data.address = 0x0000; // set address to 0x00FF
|
||||
irmp_data.command = 0x0057; // set command to 0x0001
|
||||
irsnd_send_data (&irmp_data, TRUE); // send frame, wait for completion
|
||||
_delay_ms (200);
|
||||
PORTB |= 1<<7;
|
||||
}
|
||||
}
|
||||
}
|
||||
158
irsnd.h
Normal file
158
irsnd.h
Normal file
@@ -0,0 +1,158 @@
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* irsnd.h
|
||||
*
|
||||
* Copyright (c) 2010-2020 Frank Meyer - frank(at)fli4l.de
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _IRSND_H_
|
||||
#define _IRSND_H_
|
||||
|
||||
#include "irmpsystem.h"
|
||||
#ifndef IRSND_USE_AS_LIB
|
||||
# include "irsndconfig.h"
|
||||
#endif
|
||||
|
||||
#ifdef ARDUINO
|
||||
# include "irsndArduinoExt.h"
|
||||
|
||||
#elif defined (ARM_STM32) // STM32
|
||||
# define _CONCAT(a,b) a##b
|
||||
# define CONCAT(a,b) _CONCAT(a,b)
|
||||
# define IRSND_PORT CONCAT(GPIO, IRSND_PORT_LETTER)
|
||||
# if defined (ARM_STM32L1XX)
|
||||
# define IRSND_PORT_RCC CONCAT(RCC_AHBPeriph_GPIO, IRSND_PORT_LETTER)
|
||||
# define IRSND_GPIO_AF CONCAT(GPIO_AF_TIM, IRSND_TIMER_NUMBER)
|
||||
# elif defined (ARM_STM32F10X)
|
||||
# define IRSND_PORT_RCC CONCAT(RCC_APB2Periph_GPIO, IRSND_PORT_LETTER)
|
||||
# elif defined (ARM_STM32F30X)
|
||||
# define IRSND_PORT_RCC CONCAT(RCC_AHBPeriph_GPIO, IRSND_PORT_LETTER)
|
||||
# elif defined (ARM_STM32F4XX)
|
||||
# define IRSND_PORT_RCC CONCAT(RCC_AHB1Periph_GPIO, IRSND_PORT_LETTER)
|
||||
# define IRSND_GPIO_AF CONCAT(GPIO_AF_TIM, IRSND_TIMER_NUMBER)
|
||||
# endif
|
||||
# define IRSND_BIT CONCAT(GPIO_Pin_, IRSND_BIT_NUMBER)
|
||||
# define IRSND_TIMER CONCAT(TIM, IRSND_TIMER_NUMBER)
|
||||
# define IRSND_TIMER_CHANNEL CONCAT(TIM_Channel_, IRSND_TIMER_CHANNEL_NUMBER)
|
||||
# if ((IRSND_TIMER_NUMBER >= 2) && (IRSND_TIMER_NUMBER <= 5)) || ((IRSND_TIMER_NUMBER >= 12) && (IRSND_TIMER_NUMBER <= 14))
|
||||
# define IRSND_TIMER_RCC CONCAT(RCC_APB1Periph_TIM, IRSND_TIMER_NUMBER)
|
||||
# elif (IRSND_TIMER_NUMBER == 1) || ((IRSND_TIMER_NUMBER >= 8) && (IRSND_TIMER_NUMBER <= 11))
|
||||
# define IRSND_TIMER_RCC CONCAT(RCC_APB2Periph_TIM, IRSND_TIMER_NUMBER)
|
||||
# else
|
||||
# error IRSND_TIMER_NUMBER not valid.
|
||||
# endif
|
||||
# ifndef USE_STDPERIPH_DRIVER
|
||||
# warning The STM32 port of IRSND uses the ST standard peripheral drivers which are not enabled in your build configuration.
|
||||
# endif
|
||||
|
||||
#elif defined(PIC_C18)
|
||||
|
||||
# if defined(__12F1840)
|
||||
// Do not change lines below unless you have a different HW. This example is for 12F1840
|
||||
// setup macro for PWM used PWM module
|
||||
|
||||
//~ # define PWMon() TMR2=0,IRSND_PIN=1
|
||||
//~ # define PWMoff() CCP1CON &=(~0b1100)
|
||||
//~ # define PWMon() TMR2ON=1
|
||||
//~ # define PWMoff() TMR2ON=0
|
||||
#if defined(IRSND_DEBUG)
|
||||
#define PWMon() LATA0=1
|
||||
#define PWMoff() LATA0=0
|
||||
#define IRSND_PIN LATA0
|
||||
#else
|
||||
# define PWMon() TMR2=0,CCP1CON |=0b1100
|
||||
# define PWMoff() CCP1CON &=(~0b1100)
|
||||
# define IRSND_PIN RA2
|
||||
#endif
|
||||
|
||||
#else
|
||||
// Do not change lines below until you have a different HW. Example is for 18F2550/18F4550
|
||||
// setup macro for PWM used PWM module
|
||||
# if IRSND_OCx == IRSND_PIC_CCP2
|
||||
# define PWMon() TMR2=0,CCP2CON |=0b1100
|
||||
# define PWMoff() CCP2CON &=(~0b1100)
|
||||
# define IRSND_PIN TRISCbits.TRISC1 // RC1 = PWM2
|
||||
# define SetDCPWM(x) SetDCPWM2(x)
|
||||
# define ClosePWM ClosePWM2
|
||||
# define OpenPWM(x) OpenPWM2(x)
|
||||
# endif
|
||||
# if IRSND_OCx == IRSND_PIC_CCP1
|
||||
# define PWMon() TMR2=0,CCP1CON |=0b1100
|
||||
# define PWMoff() CCP1CON &=(~0b1100)
|
||||
# define IRSND_PIN TRISCbits.TRISC2 // RC2 = PWM1
|
||||
# define SetDCPWM(x) SetDCPWM1(x)
|
||||
# define ClosePWM ClosePWM1
|
||||
# define OpenPWM(x) OpenPWM1(x)
|
||||
# endif
|
||||
# endif
|
||||
# endif // PIC_C18
|
||||
|
||||
#if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 && F_INTERRUPTS < 15000
|
||||
# warning F_INTERRUPTS too low, SIEMENS protocol disabled (should be at least 15000)
|
||||
# undef IRSND_SUPPORT_SIEMENS_PROTOCOL
|
||||
# define IRSND_SUPPORT_SIEMENS_PROTOCOL 0
|
||||
#endif
|
||||
|
||||
#if IRSND_SUPPORT_A1TVBOX_PROTOCOL == 1 && F_INTERRUPTS < 15000
|
||||
# warning F_INTERRUPTS too low, A1TVBOX protocol disabled (should be at least 15000)
|
||||
# undef IRSND_SUPPORT_A1TVBOX_PROTOCOL
|
||||
# define IRSND_SUPPORT_A1TVBOX_PROTOCOL 0
|
||||
#endif
|
||||
|
||||
#if IRSND_SUPPORT_RECS80_PROTOCOL == 1 && F_INTERRUPTS < 15000
|
||||
# warning F_INTERRUPTS too low, RECS80 protocol disabled (should be at least 15000)
|
||||
# undef IRSND_SUPPORT_RECS80_PROTOCOL
|
||||
# define IRSND_SUPPORT_RECS80_PROTOCOL 0
|
||||
#endif
|
||||
|
||||
#if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 && F_INTERRUPTS < 15000
|
||||
# warning F_INTERRUPTS too low, RECS80EXT protocol disabled (should be at least 15000)
|
||||
# undef IRSND_SUPPORT_RECS80EXT_PROTOCOL
|
||||
# define IRSND_SUPPORT_RECS80EXT_PROTOCOL 0
|
||||
#endif
|
||||
|
||||
#if IRSND_SUPPORT_LEGO_PROTOCOL == 1 && F_INTERRUPTS < 20000
|
||||
# warning F_INTERRUPTS too low, LEGO protocol disabled (should be at least 20000)
|
||||
# undef IRSND_SUPPORT_LEGO_PROTOCOL
|
||||
# define IRSND_SUPPORT_LEGO_PROTOCOL 0
|
||||
#endif
|
||||
|
||||
#include "irmpprotocols.h"
|
||||
|
||||
#define IRSND_NO_REPETITIONS 0 // no repetitions
|
||||
#define IRSND_MAX_REPETITIONS 14 // max # of repetitions
|
||||
#define IRSND_ENDLESS_REPETITION 15 // endless repetions
|
||||
#define IRSND_REPETITION_MASK 0x0F // lower nibble of flags
|
||||
#define IRSND_RAW_REPETITION_FRAME 0x10 // send one or more raw repetition frames, yet only used for NEC
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern void irsnd_init (void);
|
||||
# ifdef __cplusplus
|
||||
extern bool irsnd_is_busy (void);
|
||||
extern bool irsnd_send_data (IRMP_DATA *, uint8_t);
|
||||
extern bool irsnd_ISR (void);
|
||||
#else
|
||||
extern uint8_t irsnd_is_busy (void);
|
||||
extern uint8_t irsnd_send_data (IRMP_DATA *, uint8_t);
|
||||
extern uint8_t irsnd_ISR (void);
|
||||
#endif
|
||||
extern void irsnd_stop (void);
|
||||
|
||||
#if IRSND_USE_CALLBACK == 1
|
||||
extern void irsnd_set_callback_ptr (void (*cb)(uint8_t));
|
||||
#endif // IRSND_USE_CALLBACK == 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _IRSND_H_ */
|
||||
199
irsndconfig.h
Normal file
199
irsndconfig.h
Normal file
@@ -0,0 +1,199 @@
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* irsndconfig.h
|
||||
*
|
||||
* DO NOT INCLUDE THIS FILE, WILL BE INCLUDED BY IRSND.H!
|
||||
*
|
||||
* Copyright (c) 2010-2020 Frank Meyer - frank(at)fli4l.de
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _IRSNDCONFIG_H_
|
||||
#define _IRSNDCONFIG_H_
|
||||
|
||||
#if !defined(_IRSND_H_)
|
||||
# error please include only irsnd.h, not irsndconfig.h
|
||||
#endif
|
||||
|
||||
// #define IRSND_DEBUG 1 // activate debugging
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* F_INTERRUPTS: number of interrupts per second, should be in the range from 10000 to 20000, typically 15000
|
||||
*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef F_INTERRUPTS
|
||||
# define F_INTERRUPTS 15000 // interrupts per second
|
||||
#endif
|
||||
|
||||
#if ! defined(ARDUINO)
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* Change settings from 1 to 0 if you want to disable one or more encoders.
|
||||
* This saves program space.
|
||||
* 1 enable encoder
|
||||
* 0 disable encoder
|
||||
*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// typical protocols, disable here! Enable Remarks F_INTERRUPTS Program Space
|
||||
#define IRSND_SUPPORT_SIRCS_PROTOCOL 1 // Sony SIRCS >= 10000 ~200 bytes
|
||||
#define IRSND_SUPPORT_NEC_PROTOCOL 1 // NEC + APPLE >= 10000 ~100 bytes
|
||||
#define IRSND_SUPPORT_SAMSUNG_PROTOCOL 1 // Samsung + Samsung32 >= 10000 ~300 bytes
|
||||
#define IRSND_SUPPORT_MATSUSHITA_PROTOCOL 1 // Matsushita >= 10000 ~200 bytes
|
||||
#define IRSND_SUPPORT_KASEIKYO_PROTOCOL 1 // Kaseikyo >= 10000 ~300 bytes
|
||||
|
||||
// more protocols, enable here! Enable Remarks F_INTERRUPTS Program Space
|
||||
#define IRSND_SUPPORT_DENON_PROTOCOL 0 // DENON, Sharp >= 10000 ~200 bytes
|
||||
#define IRSND_SUPPORT_RC5_PROTOCOL 0 // RC5 >= 10000 ~150 bytes
|
||||
#define IRSND_SUPPORT_RC6_PROTOCOL 1 // RC6 >= 10000 ~250 bytes
|
||||
#define IRSND_SUPPORT_RC6A_PROTOCOL 1 // RC6A >= 10000 ~250 bytes
|
||||
#define IRSND_SUPPORT_JVC_PROTOCOL 0 // JVC >= 10000 ~150 bytes
|
||||
#define IRSND_SUPPORT_NEC16_PROTOCOL 0 // NEC16 >= 10000 ~150 bytes
|
||||
#define IRSND_SUPPORT_NEC42_PROTOCOL 0 // NEC42 >= 10000 ~150 bytes
|
||||
#define IRSND_SUPPORT_IR60_PROTOCOL 0 // IR60 (SDA2008) >= 10000 ~250 bytes
|
||||
#define IRSND_SUPPORT_GRUNDIG_PROTOCOL 0 // Grundig >= 10000 ~300 bytes
|
||||
#define IRSND_SUPPORT_SIEMENS_PROTOCOL 0 // Siemens, Gigaset >= 15000 ~150 bytes
|
||||
#define IRSND_SUPPORT_NOKIA_PROTOCOL 0 // Nokia >= 10000 ~400 bytes
|
||||
|
||||
// exotic protocols, enable here! Enable Remarks F_INTERRUPTS Program Space
|
||||
#define IRSND_SUPPORT_BOSE_PROTOCOL 0 // BOSE >= 10000 ~100 bytes
|
||||
#define IRSND_SUPPORT_KATHREIN_PROTOCOL 0 // Kathrein >= 10000 DON'T CHANGE, NOT SUPPORTED YET!
|
||||
#define IRSND_SUPPORT_NUBERT_PROTOCOL 0 // NUBERT >= 10000 ~100 bytes
|
||||
#define IRSND_SUPPORT_FAN_PROTOCOL 0 // FAN (ventilator) >= 10000 ~100 bytes
|
||||
#define IRSND_SUPPORT_SPEAKER_PROTOCOL 0 // SPEAKER >= 10000 ~100 bytes
|
||||
#define IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL 0 // Bang&Olufsen >= 10000 ~250 bytes
|
||||
#define IRSND_SUPPORT_RECS80_PROTOCOL 0 // RECS80 >= 15000 ~100 bytes
|
||||
#define IRSND_SUPPORT_RECS80EXT_PROTOCOL 0 // RECS80EXT >= 15000 ~100 bytes
|
||||
#define IRSND_SUPPORT_THOMSON_PROTOCOL 0 // Thomson >= 10000 ~250 bytes
|
||||
#define IRSND_SUPPORT_NIKON_PROTOCOL 0 // NIKON >= 10000 ~150 bytes
|
||||
#define IRSND_SUPPORT_NETBOX_PROTOCOL 0 // Netbox keyboard >= 10000 DON'T CHANGE, NOT SUPPORTED YET!
|
||||
#define IRSND_SUPPORT_ORTEK_PROTOCOL 0 // ORTEK (Hama) >= 10000 DON'T CHANGE, NOT SUPPORTED YET!
|
||||
#define IRSND_SUPPORT_TELEFUNKEN_PROTOCOL 0 // Telefunken 1560 >= 10000 ~150 bytes
|
||||
#define IRSND_SUPPORT_FDC_PROTOCOL 0 // FDC IR keyboard >= 10000 (better 15000) ~150 bytes
|
||||
#define IRSND_SUPPORT_RCCAR_PROTOCOL 0 // RC CAR >= 10000 (better 15000) ~150 bytes
|
||||
#define IRSND_SUPPORT_ROOMBA_PROTOCOL 0 // iRobot Roomba >= 10000 ~150 bytes
|
||||
#define IRSND_SUPPORT_RUWIDO_PROTOCOL 0 // RUWIDO, T-Home >= 15000 ~250 bytes
|
||||
#define IRSND_SUPPORT_A1TVBOX_PROTOCOL 0 // A1 TV BOX >= 15000 (better 20000) ~200 bytes
|
||||
#define IRSND_SUPPORT_LEGO_PROTOCOL 0 // LEGO Power RC >= 20000 ~150 bytes
|
||||
#define IRSND_SUPPORT_RCMM_PROTOCOL 0 // RCMM 12,24, or 32 >= 20000 DON'T CHANGE, NOT SUPPORTED YET!
|
||||
#define IRSND_SUPPORT_LGAIR_PROTOCOL 0 // LG Air Condition >= 10000 ~150 bytes.
|
||||
#define IRSND_SUPPORT_SAMSUNG48_PROTOCOL 0 // Samsung48 >= 10000 ~100 bytes
|
||||
#define IRSND_SUPPORT_PENTAX_PROTOCOL 0 // Pentax >= 10000 ~150 bytes
|
||||
#define IRSND_SUPPORT_S100_PROTOCOL 0 // S100 >= 10000 ~150 bytes
|
||||
#define IRSND_SUPPORT_ACP24_PROTOCOL 0 // ACP24 >= 10000 ~150 bytes
|
||||
#define IRSND_SUPPORT_TECHNICS_PROTOCOL 0 // TECHNICS >= 10000 DON'T CHANGE, NOT SUPPORTED YET!
|
||||
#define IRSND_SUPPORT_PANASONIC_PROTOCOL 0 // PANASONIC Beamer >= 10000 ~150 bytes
|
||||
#define IRSND_SUPPORT_MITSU_HEAVY_PROTOCOL 0 // Mitsubishi-Heavy Aircondition, similar Timing to Panasonic beamer
|
||||
#define IRSND_SUPPORT_IRMP16_PROTOCOL 0 // IRMP specific >= 15000 ~250 bytes
|
||||
#define IRSND_SUPPORT_MELINERA_PROTOCOL 0 // MELINERA (Lidl) >= 10000 ~100 bytes
|
||||
#endif // ! defined(ARDUINO)
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* AVR XMega section:
|
||||
*
|
||||
* Change hardware pin here: IRSND_XMEGA_OC0A = OC0A on ATxmegas supporting OC0A, e.g. ATxmega128A1U
|
||||
* IRSND_XMEGA_OC0B = OC0B on ATxmegas supporting OC0B, e.g. ATxmega128A1U
|
||||
* IRSND_XMEGA_OC0C = OC0C on ATxmegas supporting OC0C, e.g. ATxmega128A1U
|
||||
* IRSND_XMEGA_OC0D = OC0D on ATxmegas supporting OC0D, e.g. ATxmega128A1U
|
||||
* IRSND_XMEGA_OC1A = OC1A on ATxmegas supporting OC1A, e.g. ATxmega128A1U
|
||||
* IRSND_XMEGA_OC1B = OC1B on ATxmegas supporting OC1B, e.g. ATxmega128A1U
|
||||
*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
#if defined(__AVR_XMEGA__) // XMEGA
|
||||
# define IRSND_PORT_PRE PORTD
|
||||
# define XMEGA_Timer TCD0
|
||||
# define IRSND_OCx IRSND_XMEGA_OC0B // use OC0B
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* AVR ATMega/ATTiny section:
|
||||
*
|
||||
* Change hardware pin here: IRSND_OC2 = OC2 on ATmegas supporting OC2, e.g. ATmega8
|
||||
* IRSND_OC2A = OC2A on ATmegas supporting OC2A, e.g. ATmega88
|
||||
* IRSND_OC2B = OC2B on ATmegas supporting OC2B, e.g. ATmega88
|
||||
* IRSND_OC0 = OC0 on ATmegas supporting OC0, e.g. ATmega162
|
||||
* IRSND_OC0A = OC0A on ATmegas/ATtinys supporting OC0A, e.g. ATtiny84, ATtiny85, ATtiny87/167
|
||||
* IRSND_OC0B = OC0B on ATmegas/ATtinys supporting OC0B, e.g. ATtiny84, ATtiny85
|
||||
*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
#elif defined(ATMEL_AVR)
|
||||
# define IRSND_OCx IRSND_OC2 // use OC2B
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* PIC C18 or XC8 section:
|
||||
*
|
||||
* Change hardware pin here: IRSND_PIC_CCP1 = RC2 on PIC 18F2550/18F4550, ...
|
||||
* IRSND_PIC_CCP2 = RC1 on PIC 18F2550/18F4550, ...
|
||||
*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
#elif defined(PIC_C18) // C18 or XC8 compiler
|
||||
# if defined(__12F1840) // XC8 compiler
|
||||
# define Pre_Scaler 1 // define prescaler for timer2 e.g. 1,4,16
|
||||
# define F_CPU 32000000UL // PIC frequency: set your freq here
|
||||
# define PIC_Scaler 2 // PIC needs /2 extra in IRSND_FREQ_32_KHZ calculation for right value
|
||||
|
||||
# else // C18 compiler
|
||||
# define IRSND_OCx IRSND_PIC_CCP2 // Use PWMx for PIC
|
||||
// change other PIC C18 specific settings:
|
||||
# define F_CPU 48000000UL // PIC frequency: set your freq here
|
||||
# define Pre_Scaler 4 // define prescaler for timer2 e.g. 1,4,16
|
||||
# define PIC_Scaler 2 // PIC needs /2 extra in IRSND_FREQ_32_KHZ calculation for right value
|
||||
# endif
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* ARM STM32 section:
|
||||
*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
#elif defined (ARM_STM32) // use B6 as IR output on STM32
|
||||
# define IRSND_PORT_LETTER B
|
||||
# define IRSND_BIT_NUMBER 6
|
||||
# define IRSND_TIMER_NUMBER 4
|
||||
# define IRSND_TIMER_CHANNEL_NUMBER 1 // only channel 1 can be used at the moment, others won't work
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* ARM STM32 with HAL section - don't change here, define IRSND_Transmit_GPIO_Port & IRSND_Transmit_Pin in STM32Cube (Main.h)
|
||||
*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
#elif defined (ARM_STM32_HAL) // IRSND_Transmit_GPIO_Port & IRSND_Transmit_Pin must be defined in STM32Cube
|
||||
# define IRSND_PORT_LETTER IRSND_Transmit_GPIO_Port//Port of Transmit PWM Pin e.g.
|
||||
# define IRSND_BIT_NUMBER IRSND_Transmit_Pin //Pim of Transmit PWM Pin e.g.
|
||||
# define IRSND_TIMER_HANDLER htim2 //Handler of Timer e.g. htim (see tim.h)
|
||||
# define IRSND_TIMER_CHANNEL_NUMBER TIM_CHANNEL_2 //Channel of the used Timer PWM Pin e.g. TIM_CHANNEL_2
|
||||
# define IRSND_TIMER_SPEED_APBX 64000000 //Speed of the corresponding APBx. (see STM32CubeMX: Clock Configuration)
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* Teensy 3.x with teensyduino gcc compiler
|
||||
*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
#elif defined (TEENSY_ARM_CORTEX_M4)
|
||||
# define IRSND_PIN 5 // choose an arduino pin with PWM function!
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* ESP8266 (Arduino, see IRSEND.ino)
|
||||
*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
#elif defined (__xtensa__)
|
||||
# define IRSND_PIN 0 // choose an arduino pin with PWM function!
|
||||
|
||||
#elif defined(ARDUINO)
|
||||
// specified here to avoid else case
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* Other target systems
|
||||
*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
#elif !defined (UNIX_OR_WINDOWS)
|
||||
# error target system not defined.
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* Use Callbacks to indicate output signal or something else
|
||||
*---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef IRSND_USE_CALLBACK
|
||||
# define IRSND_USE_CALLBACK 0 // flag: 0 = don't use callbacks, 1 = use callbacks, default is 0
|
||||
#endif
|
||||
|
||||
#endif // _IRSNDCONFIG_H_
|
||||
Reference in New Issue
Block a user