Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ICBM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
detectors
DSSC
ICBM
Commits
bd36aa98
Commit
bd36aa98
authored
3 months ago
by
Cyril Danilevski
Browse files
Options
Downloads
Patches
Plain Diff
Validate MCP port expander logic
Add poll once on start to have accurate information on webpage
parent
b1331c84
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#160167
passed
3 months ago
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
icbm.ino
+2
-0
2 additions, 0 deletions
icbm.ino
panel.hpp
+1
-1
1 addition, 1 deletion
panel.hpp
pins.cpp
+42
-10
42 additions, 10 deletions
pins.cpp
pins.hpp
+1
-0
1 addition, 0 deletions
pins.hpp
with
46 additions
and
11 deletions
icbm.ino
+
2
−
0
View file @
bd36aa98
...
@@ -17,6 +17,8 @@ void setup() {
...
@@ -17,6 +17,8 @@ void setup() {
initializeSNMP
();
initializeSNMP
();
start
=
millis
();
start
=
millis
();
poll_port_expander
();
}
}
...
...
This diff is collapsed.
Click to expand it.
panel.hpp
+
1
−
1
View file @
bd36aa98
...
@@ -36,7 +36,7 @@ String buildPanel(bool sib, bool plc, bool ups, unsigned long elapsed_secs) {
...
@@ -36,7 +36,7 @@ String buildPanel(bool sib, bool plc, bool ups, unsigned long elapsed_secs) {
else
{
page
+=
"<span class=
\"
status-value status-ok
\"
>OK</span>
\n
"
;
}
else
{
page
+=
"<span class=
\"
status-value status-ok
\"
>OK</span>
\n
"
;
}
page
+=
"</div>
\n
"
;
page
+=
"</div>
\n
"
;
page
+=
"<h3>Last I
NT
: "
;
page
+=
"<h3>Last I
nterrupt
: "
;
page
+=
elapsed_secs
;
page
+=
elapsed_secs
;
page
+=
" secs. ago"
;
page
+=
" secs. ago"
;
page
+=
"</h3></div></body></html>"
;
page
+=
"</h3></div></body></html>"
;
...
...
This diff is collapsed.
Click to expand it.
pins.cpp
+
42
−
10
View file @
bd36aa98
...
@@ -11,17 +11,16 @@ void IRAM_ATTR isr(){
...
@@ -11,17 +11,16 @@ void IRAM_ATTR isr(){
void
initializeMCP
()
void
initializeMCP
()
{
{
pinMode
(
ISR_PIN
,
INPUT_PULLUP
);
pinMode
(
ISR_PIN
,
INPUT_PULLUP
);
//attachInterrupt(digitalPinToInterrupt(ISR_PIN), isr, CHANGE);
attachInterrupt
(
digitalPinToInterrupt
(
ISR_PIN
),
isr
,
CHANGE
);
attachInterrupt
(
digitalPinToInterrupt
(
TRIGGER_SIGNAL
),
isr
,
CHANGE
);
SPI
.
begin
();
SPI
.
begin
();
MCP
.
begin
();
MCP
.
begin
();
// Enable inputs and interrupts on pins 0-2
// Enable inputs and interrupts on pins 0-2
MCP
.
pinMode8
(
0b00000111
);
MCP
.
pinMode8
(
0b00000111
);
MCP
.
enableInterrupt
(
0
,
FALLI
NG
);
MCP
.
enableInterrupt
(
0
,
CHA
NG
E
);
MCP
.
enableInterrupt
(
1
,
FALLI
NG
);
MCP
.
enableInterrupt
(
1
,
CHA
NG
E
);
MCP
.
enableInterrupt
(
2
,
FALLI
NG
);
MCP
.
enableInterrupt
(
2
,
CHA
NG
E
);
Serial
.
println
(
"MCP23S08 Started"
);
Serial
.
println
(
"MCP23S08 Started"
);
}
}
...
@@ -37,23 +36,23 @@ void isr_check_loop()
...
@@ -37,23 +36,23 @@ void isr_check_loop()
Serial
.
print
(
"Interrupt: "
);
Serial
.
print
(
"Interrupt: "
);
uint8_t
regval
=
MCP
.
getInterruptCaptureRegister
();
//INTCAP
uint8_t
regval
=
MCP
.
getInterruptCaptureRegister
();
//INTCAP
Serial
.
print
(
regval
);
Serial
.
print
(
regval
,
BIN
);
uint8_t
mask
=
1
<<
0
;
uint8_t
mask
=
1
<<
0
;
if
(
!
(
regval
&
mask
))
{
if
((
regval
&
mask
))
{
Serial
.
print
(
"UPS"
);
Serial
.
print
(
"
UPS"
);
PINS
.
ups
=
true
;
PINS
.
ups
=
true
;
}
}
mask
=
1
<<
1
;
mask
=
1
<<
1
;
if
(
!
(
regval
&
mask
))
{
if
(
!
(
regval
&
mask
))
{
Serial
.
print
(
"PLC"
);
Serial
.
print
(
"
PLC"
);
PINS
.
plc
=
true
;
PINS
.
plc
=
true
;
}
}
mask
=
1
<<
2
;
mask
=
1
<<
2
;
if
(
!
(
regval
&
mask
))
{
if
(
!
(
regval
&
mask
))
{
Serial
.
print
(
"SIB"
);
Serial
.
print
(
"
SIB"
);
PINS
.
sib
=
true
;
PINS
.
sib
=
true
;
}
}
...
@@ -62,6 +61,39 @@ void isr_check_loop()
...
@@ -62,6 +61,39 @@ void isr_check_loop()
}
}
}
}
void
poll_port_expander
()
{
PINS
.
sib
=
false
;
PINS
.
plc
=
false
;
PINS
.
ups
=
false
;
PINS
.
last_triggered
=
millis
();
int
regval
=
MCP
.
read8
();
uint8_t
mask
=
1
<<
0
;
if
((
regval
&
mask
))
{
Serial
.
print
(
" UPS"
);
PINS
.
ups
=
true
;
}
mask
=
1
<<
1
;
if
(
!
(
regval
&
mask
))
{
Serial
.
print
(
" PLC"
);
PINS
.
plc
=
true
;
}
mask
=
1
<<
2
;
if
(
!
(
regval
&
mask
))
{
Serial
.
print
(
" SIB"
);
PINS
.
sib
=
true
;
}
Serial
.
println
();
}
bool
on
=
true
;
bool
on
=
true
;
unsigned
long
toggle_start
=
0
;
unsigned
long
toggle_start
=
0
;
void
toggle_status_led
()
{
void
toggle_status_led
()
{
...
...
This diff is collapsed.
Click to expand it.
pins.hpp
+
1
−
0
View file @
bd36aa98
...
@@ -28,4 +28,5 @@ extern MCP23S08 MCP;
...
@@ -28,4 +28,5 @@ extern MCP23S08 MCP;
void
IRAM_ATTR
isr
();
void
IRAM_ATTR
isr
();
void
initializeMCP
();
void
initializeMCP
();
void
isr_check_loop
();
void
isr_check_loop
();
void
poll_port_expander
();
void
toggle_status_led
();
void
toggle_status_led
();
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment