Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
SUFST-Arduino-Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
SUFST
SUFST-Arduino-Firmware
Commits
bd3e71fc
Commit
bd3e71fc
authored
5 years ago
by
nrs1g15
Browse files
Options
Downloads
Patches
Plain Diff
Added arduino interrupt
parent
74b130df
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sufst-controller/can.cpp
+9
-35
9 additions, 35 deletions
sufst-controller/can.cpp
sufst-controller/can.h
+1
-1
1 addition, 1 deletion
sufst-controller/can.h
with
10 additions
and
36 deletions
sufst-controller/can.cpp
+
9
−
35
View file @
bd3e71fc
...
@@ -45,6 +45,13 @@ extern void ecuCanMsg0x2008(CanMsgTemplate *canMsg);
...
@@ -45,6 +45,13 @@ extern void ecuCanMsg0x2008(CanMsgTemplate *canMsg);
extern
void
ecuCanMsg0x2009
(
CanMsgTemplate
*
canMsg
);
extern
void
ecuCanMsg0x2009
(
CanMsgTemplate
*
canMsg
);
static
void
canISR
();
static
void
canISR
()
{
canSaveMsg
();
}
// ECU can messages function pointers for calling the corresponding function when that msg is seen.
// ECU can messages function pointers for calling the corresponding function when that msg is seen.
// Used in function canParseRxMsg.
// Used in function canParseRxMsg.
void
void
...
@@ -68,6 +75,8 @@ uint8_t canBegin()
...
@@ -68,6 +75,8 @@ uint8_t canBegin()
pinMode
(
CAN_INT_PIN
,
INPUT_PULLUP
);
pinMode
(
CAN_INT_PIN
,
INPUT_PULLUP
);
attachInterrupt
(
digitalPinToInterrupt
(
CAN_INT_PIN
),
canISR
,
FALLING
);
// Initialize the Arduino CAN class with slave select pin.
// Initialize the Arduino CAN class with slave select pin.
can
.
init_CS
(
CAN_CS_PIN
);
can
.
init_CS
(
CAN_CS_PIN
);
...
@@ -145,41 +154,6 @@ void canAddTxRequest(CanMsgTemplate *canMsg)
...
@@ -145,41 +154,6 @@ void canAddTxRequest(CanMsgTemplate *canMsg)
cirBufferWrite
(
&
canTxCirBuffer
,
canMsg
);
cirBufferWrite
(
&
canTxCirBuffer
,
canMsg
);
}
}
// External interrupt currently only designed to work with atmega 2560
#if !defined(__AVR_ATmega2560__)
#error "PLATFORM NOT SUPPORTED CURRENTLY"
#endif // !defined(atmega2560)
#if CAN_INT_PIN != 2
#error "CAN_INT_PIN CHANGED FROM 2"
#endif //CAN_INT_PIN != 2
void
canBeginExtInterrupt
()
{
noInterrupts
();
// On the mega 2560 pin 2 is external interrupt 4
EIMSK
&=
~
(
1
<<
INT4
);
EICRB
&=
~
(
1
<<
ISC41
);
//EICRB &= ~(1 << ISC40);
EIMSK
|=
(
1
<<
INT4
);
interrupts
();
}
ISR
(
INT4_vect
)
{
noInterrupts
();
lastCanMsgRecTimeMs
=
millis
();
canSaveMsg
();
interrupts
();
}
void
canParseRxMsg
(
CanMsgTemplate
*
canMsg
)
void
canParseRxMsg
(
CanMsgTemplate
*
canMsg
)
{
{
if
((
canMsg
->
id
>=
0x2000
)
&&
(
canMsg
->
id
<=
0x200A
))
{
if
((
canMsg
->
id
>=
0x2000
)
&&
(
canMsg
->
id
<=
0x200A
))
{
...
...
This diff is collapsed.
Click to expand it.
sufst-controller/can.h
+
1
−
1
View file @
bd3e71fc
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
// CAN_INT_PIN MUST BE 2
// CAN_INT_PIN MUST BE 2
#define CAN_INT_PIN 2
#define CAN_INT_PIN 2
#define CAN_CS_PIN
9
#define CAN_CS_PIN
10
#define CAN_RX_BUFFER_LEN 32
#define CAN_RX_BUFFER_LEN 32
#define CAN_TX_BUFFER_LEN 32
#define CAN_TX_BUFFER_LEN 32
...
...
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