Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
8010e1be
Commit
8010e1be
authored
Mar 24, 2022
by
Eric Duminil
Browse files
Renaming
parent
f1647b8b
Pipeline
#6047
passed with stage
in 1 minute and 44 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/co2_sensor.cpp
View file @
8010e1be
...
...
@@ -19,10 +19,10 @@ namespace config {
#if defined(ESP8266)
//NOTE: This library requires much less memory than SoftwareSerial.h
# include "src/lib/Esp8266EdgeSoftwareSerial/
My
SoftwareSerial.h"
# include "src/lib/Esp8266EdgeSoftwareSerial/
ESP8266
SoftwareSerial.h"
# define S8_RX_PIN 13 // GPIO13, a.k.a. D7, connected to S8 Tx pin.
# define S8_TX_PIN 15 // GPIO15, a.k.a. D8, connected to S8 Rx pin.
My
SoftwareSerial
S8_serial
(
S8_RX_PIN
,
S8_TX_PIN
,
false
,
16
);
// 16 bytes buffer should be enough.
ESP8266
SoftwareSerial
S8_serial
(
S8_RX_PIN
,
S8_TX_PIN
,
false
,
16
);
// 16 bytes buffer should be enough.
#endif
#if defined(ESP32)
// GPIO16 connected to S8 Tx pin.
...
...
ampel-firmware/src/lib/Esp8266EdgeSoftwareSerial/
My
SoftwareSerial.cpp
→
ampel-firmware/src/lib/Esp8266EdgeSoftwareSerial/
ESP8266
SoftwareSerial.cpp
View file @
8010e1be
/*
My
SoftwareSerial.cpp - Implementation of the Arduino software serial for ESP8266.
ESP8266
SoftwareSerial.cpp - Implementation of the Arduino software serial for ESP8266.
Copyright (c) 2015-2016 Peter Lerup. All rights reserved.
This library is free software; you can redistribute it and/or
...
...
@@ -27,13 +27,13 @@ extern "C" {
#include "gpio.h"
}
#include "
My
SoftwareSerial.h"
#include "
ESP8266
SoftwareSerial.h"
#define MAX_PIN 15
// As the Arduino attachInterrupt has no parameter, lists of objects
// and callbacks corresponding to each possible GPIO pins have to be defined
My
SoftwareSerial
*
ObjList
[
MAX_PIN
+
1
];
ESP8266
SoftwareSerial
*
ObjList
[
MAX_PIN
+
1
];
void
ICACHE_RAM_ATTR
sws_isr_0
()
{
ObjList
[
0
]
->
rxRead
();
};
void
ICACHE_RAM_ATTR
sws_isr_1
()
{
ObjList
[
1
]
->
rxRead
();
};
...
...
@@ -68,7 +68,7 @@ static void(*ISRList[MAX_PIN + 1])() = {
sws_isr_15
};
My
SoftwareSerial
::
My
SoftwareSerial
(
int
receivePin
,
int
transmitPin
,
bool
inverse_logic
,
unsigned
int
buffSize
,
bool
edge_triggered
)
{
ESP8266
SoftwareSerial
::
ESP8266
SoftwareSerial
(
int
receivePin
,
int
transmitPin
,
bool
inverse_logic
,
unsigned
int
buffSize
,
bool
edge_triggered
)
{
m_oneWire
=
(
receivePin
==
transmitPin
);
m_rxValid
=
m_txValid
=
m_txEnableValid
=
false
;
m_buffer
=
NULL
;
...
...
@@ -99,7 +99,7 @@ MySoftwareSerial::MySoftwareSerial(int receivePin, int transmitPin, bool inverse
begin
(
9600
);
}
My
SoftwareSerial
::~
My
SoftwareSerial
()
{
ESP8266
SoftwareSerial
::~
ESP8266
SoftwareSerial
()
{
enableRx
(
false
);
if
(
m_rxValid
)
ObjList
[
m_rxPin
]
=
NULL
;
...
...
@@ -107,11 +107,11 @@ MySoftwareSerial::~MySoftwareSerial() {
free
(
m_buffer
);
}
bool
My
SoftwareSerial
::
isValidGPIOpin
(
int
pin
)
{
bool
ESP8266
SoftwareSerial
::
isValidGPIOpin
(
int
pin
)
{
return
(
pin
>=
0
&&
pin
<=
5
)
||
(
pin
>=
12
&&
pin
<=
MAX_PIN
);
}
void
My
SoftwareSerial
::
begin
(
long
speed
)
{
void
ESP8266
SoftwareSerial
::
begin
(
long
speed
)
{
// Use getCycleCount() loop to get as exact timing as possible
m_bitTime
=
F_CPU
/
speed
;
// By default enable interrupt during tx only for low speed
...
...
@@ -121,11 +121,11 @@ void MySoftwareSerial::begin(long speed) {
enableRx
(
true
);
}
long
My
SoftwareSerial
::
baudRate
()
{
long
ESP8266
SoftwareSerial
::
baudRate
()
{
return
F_CPU
/
m_bitTime
;
}
void
My
SoftwareSerial
::
setTransmitEnablePin
(
int
transmitEnablePin
)
{
void
ESP8266
SoftwareSerial
::
setTransmitEnablePin
(
int
transmitEnablePin
)
{
if
(
isValidGPIOpin
(
transmitEnablePin
))
{
m_txEnableValid
=
true
;
m_txEnablePin
=
transmitEnablePin
;
...
...
@@ -137,11 +137,11 @@ void MySoftwareSerial::setTransmitEnablePin(int transmitEnablePin) {
}
}
void
My
SoftwareSerial
::
enableIntTx
(
bool
on
)
{
void
ESP8266
SoftwareSerial
::
enableIntTx
(
bool
on
)
{
m_intTxEnabled
=
on
;
}
void
My
SoftwareSerial
::
enableTx
(
bool
on
)
{
void
ESP8266
SoftwareSerial
::
enableTx
(
bool
on
)
{
if
(
m_oneWire
&&
m_txValid
)
{
if
(
on
)
{
enableRx
(
false
);
...
...
@@ -157,7 +157,7 @@ void MySoftwareSerial::enableTx(bool on) {
}
}
void
My
SoftwareSerial
::
enableRx
(
bool
on
)
{
void
ESP8266
SoftwareSerial
::
enableRx
(
bool
on
)
{
if
(
m_rxValid
)
{
if
(
on
)
{
if
(
m_edge
)
...
...
@@ -171,14 +171,14 @@ void MySoftwareSerial::enableRx(bool on) {
}
}
int
My
SoftwareSerial
::
read
()
{
int
ESP8266
SoftwareSerial
::
read
()
{
if
(
!
m_rxValid
||
(
m_inPos
==
m_outPos
))
return
-
1
;
uint8_t
ch
=
m_buffer
[
m_outPos
];
m_outPos
=
(
m_outPos
+
1
)
%
m_buffSize
;
return
ch
;
}
int
My
SoftwareSerial
::
available
()
{
int
ESP8266
SoftwareSerial
::
available
()
{
if
(
!
m_rxValid
)
return
0
;
int
avail
=
m_inPos
-
m_outPos
;
if
(
avail
<
0
)
avail
+=
m_buffSize
;
...
...
@@ -187,7 +187,7 @@ int MySoftwareSerial::available() {
#define WAIT { while (ESP.getCycleCount()-start < wait) if (m_intTxEnabled) optimistic_yield(1); wait += m_bitTime; }
size_t
My
SoftwareSerial
::
write
(
uint8_t
b
)
{
size_t
ESP8266
SoftwareSerial
::
write
(
uint8_t
b
)
{
if
(
!
m_txValid
)
return
0
;
if
(
m_invert
)
b
=
~
b
;
...
...
@@ -215,22 +215,22 @@ size_t MySoftwareSerial::write(uint8_t b) {
return
1
;
}
void
My
SoftwareSerial
::
flush
()
{
void
ESP8266
SoftwareSerial
::
flush
()
{
m_inPos
=
m_outPos
=
0
;
}
bool
My
SoftwareSerial
::
overflow
()
{
bool
ESP8266
SoftwareSerial
::
overflow
()
{
bool
res
=
m_overflow
;
m_overflow
=
false
;
return
res
;
}
int
My
SoftwareSerial
::
peek
()
{
int
ESP8266
SoftwareSerial
::
peek
()
{
if
(
!
m_rxValid
||
(
m_inPos
==
m_outPos
))
return
-
1
;
return
m_buffer
[
m_outPos
];
}
inline
bool
My
SoftwareSerial
::
propgateBits
(
bool
level
,
int
pulseBitLength
)
inline
bool
ESP8266
SoftwareSerial
::
propgateBits
(
bool
level
,
int
pulseBitLength
)
{
for
(
int
i
=
0
;
i
<
pulseBitLength
;
i
++
)
{
...
...
@@ -247,12 +247,12 @@ inline bool MySoftwareSerial::propgateBits(bool level, int pulseBitLength)
return
false
;
}
inline
void
My
SoftwareSerial
::
setWaitingForStart
()
inline
void
ESP8266
SoftwareSerial
::
setWaitingForStart
()
{
m_getByteState
=
awaitingStart
;
}
inline
void
My
SoftwareSerial
::
setStartBit
(
unsigned
long
start
)
inline
void
ESP8266
SoftwareSerial
::
setStartBit
(
unsigned
long
start
)
{
// mark - the start of a pulse
// set the timers and wait for the next pulse
...
...
@@ -263,7 +263,7 @@ inline void MySoftwareSerial::setStartBit(unsigned long start)
m_getByteState
=
gotStart
;
}
void
ICACHE_RAM_ATTR
My
SoftwareSerial
::
rxRead
()
{
void
ICACHE_RAM_ATTR
ESP8266
SoftwareSerial
::
rxRead
()
{
// Advance the starting point for the samples but compensate for the
// initial delay which occurs before the interrupt is delivered
unsigned
long
wait
=
m_bitTime
+
m_bitTime
/
3
-
500
;
...
...
@@ -398,4 +398,4 @@ void ICACHE_RAM_ATTR MySoftwareSerial::rxRead() {
// it gets set even when interrupts are disabled
GPIO_REG_WRITE
(
GPIO_STATUS_W1TC_ADDRESS
,
1
<<
m_rxPin
);
}
#endif
\ No newline at end of file
#endif
ampel-firmware/src/lib/Esp8266EdgeSoftwareSerial/
My
SoftwareSerial.h
→
ampel-firmware/src/lib/Esp8266EdgeSoftwareSerial/
ESP8266
SoftwareSerial.h
View file @
8010e1be
/*
My
SoftwareSerial.h
ESP8266
SoftwareSerial.h
My
SoftwareSerial.cpp - Implementation of the Arduino software serial for ESP8266.
ESP8266
SoftwareSerial.cpp - Implementation of the Arduino software serial for ESP8266.
Copyright (c) 2015-2016 Peter Lerup. All rights reserved.
This library is free software; you can redistribute it and/or
...
...
@@ -20,9 +20,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef
My
SoftwareSerial_h
#ifndef
ESP8266
SoftwareSerial_h
#if defined(ESP8266)
#define
My
SoftwareSerial_h
#define
ESP8266
SoftwareSerial_h
#include <inttypes.h>
#include <Stream.h>
...
...
@@ -33,10 +33,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// Speed up to 115200 can be used.
class
My
SoftwareSerial
:
public
Stream
{
class
ESP8266
SoftwareSerial
:
public
Stream
{
public:
My
SoftwareSerial
(
int
receivePin
,
int
transmitPin
,
bool
inverse_logic
=
false
,
unsigned
int
buffSize
=
64
,
bool
edge_triggered
=
false
);
virtual
~
My
SoftwareSerial
();
ESP8266
SoftwareSerial
(
int
receivePin
,
int
transmitPin
,
bool
inverse_logic
=
false
,
unsigned
int
buffSize
=
64
,
bool
edge_triggered
=
false
);
virtual
~
ESP8266
SoftwareSerial
();
void
begin
(
long
speed
);
long
baudRate
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment