Skip to content

Commit

Permalink
Added support for ESP8266.
Browse files Browse the repository at this point in the history
  • Loading branch information
Slavey Karadzhov committed Mar 17, 2018
1 parent db68f78 commit 7b82bb5
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 18 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ sentence=Lightweight Infrared library for Arduino
paragraph=IRLremote implements a fast and compact way to analyze IR signals with PinInterrupts and PinChangeInterrupts.
category=Signal Input/Output
url=https://github.com/NicoHood/IRLremote
architectures=avr
architectures=avr,esp8266
5 changes: 1 addition & 4 deletions src/IRL_Decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ THE SOFTWARE.
// Include guard
#pragma once

#ifdef ARDUINO
#include <Arduino.h> // micros()
#endif
#include <util/atomic.h>
#include "IRL_Platform.h"

//==============================================================================
// CIRL_DecodeSpaces Class
Expand Down
63 changes: 63 additions & 0 deletions src/IRL_Platform.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
Copyright (c) 2014-2018 NicoHood
See the readme for credit to other people.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

// Include guard
#pragma once

#ifdef ARDUINO
#include <Arduino.h> // micros()
#endif

#if defined(ARDUINO_ARCH_AVR)
#include <util/atomic.h>
#elif defined(ARDUINO_ARCH_ESP8266) || defined(ESP8266)
// copied from https://github.com/wizard97/SimplyAtomic/blob/master/esp8266.h

#ifndef __STRINGIFY
#define __STRINGIFY(a) #a
#endif

#ifndef xt_rsil
#define xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state)); state;}))
#endif

#ifndef xt_wsr_ps
#define xt_wsr_ps(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory")
#endif

static __inline__ void SA_iRestore(const uint32_t *__s)
{
xt_wsr_ps(*__s);
}

// Note value can be 0-15, 0 = Enable all interrupts, 15 = no interrupts
#define SA_ATOMIC_RESTORESTATE uint32_t _sa_saved \
__attribute__((__cleanup__(SA_iRestore))) = xt_rsil(15)

#define ATOMIC_RESTORESTATE
#define ATOMIC_BLOCK(A) \
for ( SA_ATOMIC_RESTORESTATE, _sa_done = 1; \
_sa_done; _sa_done = 0 )
#else
#error "This library supports only AVR and ESP8266 Boards."
#endif
5 changes: 1 addition & 4 deletions src/IRL_Protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ THE SOFTWARE.
// Include guard
#pragma once

#ifdef ARDUINO
#include <Arduino.h> // micros()
#endif
#include <util/atomic.h>
#include "IRL_Platform.h"

//==============================================================================
// IRL_Protocol Class
Expand Down
5 changes: 1 addition & 4 deletions src/IRL_Time.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ THE SOFTWARE.
// Include guard
#pragma once

#ifdef ARDUINO
#include <Arduino.h> // micros()
#endif
#include <util/atomic.h>
#include "IRL_Platform.h"

//==============================================================================
// IRL_Time Class
Expand Down
6 changes: 1 addition & 5 deletions src/IRLremote.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ THE SOFTWARE.
#include <util/delay_basic.h>
#endif

// Include external libraries
#ifdef ARDUINO
#include <Arduino.h>
#endif
#include <util/atomic.h>
#include "IRL_Platform.h"

// Include all protocol implementations
#include "IRL_Nec.h"
Expand Down

0 comments on commit 7b82bb5

Please sign in to comment.