-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3dca237
commit 3213eb5
Showing
15 changed files
with
2,785 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,229 @@ | ||
## Mac hidden files: | ||
.DS_Store | ||
|
||
## Other files | ||
*.pyc | ||
test-ACANSettings-on-desktop/build/ | ||
*/*.xcodeproj/project.xcworkspace | ||
*/*.xcodeproj/xcuserdata | ||
|
||
## Core latex/pdflatex auxiliary files: | ||
*.aux | ||
*.lof | ||
*.log | ||
*.lot | ||
*.fls | ||
*.out | ||
*.toc | ||
*.fmt | ||
*.fot | ||
*.cb | ||
*.cb2 | ||
|
||
## Intermediate documents: | ||
*.dvi | ||
*-converted-to.* | ||
# these rules might exclude image files for figures etc. | ||
# *.ps | ||
# *.eps | ||
|
||
## Generated if empty string is given at "Please type another file name for output:" | ||
|
||
## Bibliography auxiliary files (bibtex/biblatex/biber): | ||
*.bbl | ||
*.bcf | ||
*.blg | ||
*-blx.aux | ||
*-blx.bib | ||
*.run.xml | ||
|
||
## Build tool auxiliary files: | ||
*.fdb_latexmk | ||
*.synctex | ||
*.synctex(busy) | ||
*.synctex.gz | ||
*.synctex.gz(busy) | ||
*.pdfsync | ||
|
||
## Auxiliary and intermediate files from other packages: | ||
# algorithms | ||
*.alg | ||
*.loa | ||
|
||
# achemso | ||
acs-*.bib | ||
|
||
# amsthm | ||
*.thm | ||
|
||
# beamer | ||
*.nav | ||
*.pre | ||
*.snm | ||
*.vrb | ||
|
||
# changes | ||
*.soc | ||
|
||
# cprotect | ||
*.cpt | ||
|
||
# elsarticle (documentclass of Elsevier journals) | ||
*.spl | ||
|
||
# endnotes | ||
*.ent | ||
|
||
# fixme | ||
*.lox | ||
|
||
# feynmf/feynmp | ||
*.mf | ||
*.mp | ||
*.t[1-9] | ||
*.t[1-9][0-9] | ||
*.tfm | ||
|
||
#(r)(e)ledmac/(r)(e)ledpar | ||
*.end | ||
*.?end | ||
*.[1-9] | ||
*.[1-9][0-9] | ||
*.[1-9][0-9][0-9] | ||
*.[1-9]R | ||
*.[1-9][0-9]R | ||
*.[1-9][0-9][0-9]R | ||
*.eledsec[1-9] | ||
*.eledsec[1-9]R | ||
*.eledsec[1-9][0-9] | ||
*.eledsec[1-9][0-9]R | ||
*.eledsec[1-9][0-9][0-9] | ||
*.eledsec[1-9][0-9][0-9]R | ||
|
||
# glossaries | ||
*.acn | ||
*.acr | ||
*.glg | ||
*.glo | ||
*.gls | ||
*.glsdefs | ||
|
||
# gnuplottex | ||
*-gnuplottex-* | ||
|
||
# gregoriotex | ||
*.gaux | ||
*.gtex | ||
|
||
# hyperref | ||
*.brf | ||
|
||
# knitr | ||
*-concordance.tex | ||
# TODO Comment the next line if you want to keep your tikz graphics files | ||
*.tikz | ||
*-tikzDictionary | ||
|
||
# listings | ||
*.lol | ||
|
||
# makeidx | ||
*.idx | ||
*.ilg | ||
*.ind | ||
*.ist | ||
|
||
# minitoc | ||
*.maf | ||
*.mlf | ||
*.mlt | ||
*.mtc[0-9]* | ||
*.slf[0-9]* | ||
*.slt[0-9]* | ||
*.stc[0-9]* | ||
|
||
# minted | ||
_minted* | ||
*.pyg | ||
|
||
# morewrites | ||
*.mw | ||
|
||
# nomencl | ||
*.nlo | ||
|
||
# pax | ||
*.pax | ||
|
||
# pdfpcnotes | ||
*.pdfpc | ||
|
||
# sagetex | ||
*.sagetex.sage | ||
*.sagetex.py | ||
*.sagetex.scmd | ||
|
||
# scrwfile | ||
*.wrt | ||
|
||
# sympy | ||
*.sout | ||
*.sympy | ||
sympy-plots-for-*.tex/ | ||
|
||
# pdfcomment | ||
*.upa | ||
*.upb | ||
|
||
# pythontex | ||
*.pytxcode | ||
pythontex-files-*/ | ||
|
||
# thmtools | ||
*.loe | ||
|
||
# TikZ & PGF | ||
*.dpth | ||
*.md5 | ||
*.auxlock | ||
|
||
# todonotes | ||
*.tdo | ||
|
||
# easy-todo | ||
*.lod | ||
|
||
# xindy | ||
*.xdy | ||
|
||
# xypic precompiled matrices | ||
*.xyc | ||
|
||
# endfloat | ||
*.ttt | ||
*.fff | ||
|
||
# Latexian | ||
TSWLatexianTemp* | ||
|
||
## Editors: | ||
# WinEdt | ||
*.bak | ||
*.sav | ||
|
||
# Texpad | ||
.texpadtmp | ||
|
||
# Kile | ||
*.backup | ||
|
||
# KBibTeX | ||
*~[0-9]* | ||
|
||
# auto folder when using emacs and auctex | ||
/auto/* | ||
|
||
# expex forward references with \gathertags | ||
*-tags.tex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
//—————————————————————————————————————————————————————————————————————————————— | ||
// ACAN2517FD Demo in loopback mode, using hardware SPI1, with an external interrupt | ||
//—————————————————————————————————————————————————————————————————————————————— | ||
|
||
#include <ACAN2517FD.h> | ||
|
||
//—————————————————————————————————————————————————————————————————————————————— | ||
// MCP2517 connections: adapt theses settings to your design | ||
// As hardware SPI is used, you should select pins that support SPI functions. | ||
// This sketch is designed for a Teensy 3.5, using SPI1 | ||
// But standard Teensy 3.5 SPI1 pins are not used | ||
// SCK input of MCP2517 is connected to pin #32 | ||
// SDI input of MCP2517 is connected to pin #0 | ||
// SDO output of MCP2517 is connected to pin #1 | ||
// CS input of MCP2517 should be connected to a digital output port | ||
// INT output of MCP2517 should be connected to a digital input port, with interrupt capability | ||
//—————————————————————————————————————————————————————————————————————————————— | ||
|
||
static const byte MCP2517_SCK = 32 ; // SCK input of MCP2517 | ||
static const byte MCP2517_SDI = 0 ; // SDI input of MCP2517 | ||
static const byte MCP2517_SDO = 1 ; // SDO output of MCP2517 | ||
|
||
static const byte MCP2517_CS = 31 ; // CS input of MCP2517 | ||
static const byte MCP2517_INT = 38 ; // INT output of MCP2517 | ||
|
||
//—————————————————————————————————————————————————————————————————————————————— | ||
// ACAN2517FD Driver object | ||
//—————————————————————————————————————————————————————————————————————————————— | ||
|
||
ACAN2517FD can (MCP2517_CS, SPI1, MCP2517_INT) ; | ||
|
||
//—————————————————————————————————————————————————————————————————————————————— | ||
// SETUP | ||
//—————————————————————————————————————————————————————————————————————————————— | ||
|
||
void setup () { | ||
//--- Switch on builtin led | ||
pinMode (LED_BUILTIN, OUTPUT) ; | ||
digitalWrite (LED_BUILTIN, HIGH) ; | ||
//--- Start serial | ||
Serial.begin (38400) ; | ||
//--- Wait for serial (blink led at 10 Hz during waiting) | ||
while (!Serial) { | ||
delay (50) ; | ||
digitalWrite (LED_BUILTIN, !digitalRead (LED_BUILTIN)) ; | ||
} | ||
//--- Define alternate pins for SPI1 (see https://www.pjrc.com/teensy/td_libs_SPI.html) | ||
Serial.print ("Using pin #") ; | ||
Serial.print (MCP2517_SDI) ; | ||
Serial.print (" for MOSI: ") ; | ||
Serial.println (SPI1.pinIsMOSI (MCP2517_SDI) ? "yes" : "NO!!!") ; | ||
Serial.print ("Using pin #") ; | ||
Serial.print (MCP2517_SDO) ; | ||
Serial.print (" for MISO: ") ; | ||
Serial.println (SPI1.pinIsMISO (MCP2517_SDO) ? "yes" : "NO!!!") ; | ||
Serial.print ("Using pin #") ; | ||
Serial.print (MCP2517_SCK) ; | ||
Serial.print (" for SCK: ") ; | ||
Serial.println (SPI1.pinIsSCK (MCP2517_SCK) ? "yes" : "NO!!!") ; | ||
SPI1.setMOSI (MCP2517_SDI) ; | ||
SPI1.setMISO (MCP2517_SDO) ; | ||
SPI1.setSCK (MCP2517_SCK) ; | ||
//----------------------------------- Begin SPI1 | ||
SPI1.begin () ; | ||
//--- Configure ACAN2517FD | ||
Serial.println ("Configure ACAN2517FD") ; | ||
ACAN2517FDSettings settings (ACAN2517FDSettings::OSC_4MHz10xPLL, 125 * 1000, ACAN2517FDSettings::DATA_BITRATE_x1) ; | ||
settings.mRequestedMode = ACAN2517FDSettings::InternalLoopBack ; // Select loopback mode | ||
//--- RAM Usage | ||
Serial.print ("MCP2517FD RAM Usage: ") ; | ||
Serial.print (settings.ramUsage ()) ; | ||
Serial.println (" bytes") ; | ||
//--- Begin | ||
const uint32_t errorCode = can.begin (settings, [] { can.isr () ; }) ; | ||
if (errorCode == 0) { | ||
Serial.print ("Bit Rate prescaler: ") ; | ||
Serial.println (settings.mBitRatePrescaler) ; | ||
Serial.print ("Arbitration Phase segment 1: ") ; | ||
Serial.println (settings.mArbitrationPhaseSegment1) ; | ||
Serial.print ("Arbitration Phase segment 2: ") ; | ||
Serial.println (settings.mArbitrationPhaseSegment2) ; | ||
Serial.print ("Arbitration SJW:") ; | ||
Serial.println (settings.mArbitrationSJW) ; | ||
Serial.print ("Actual Arbitration Bit Rate: ") ; | ||
Serial.print (settings.actualArbitrationBitRate ()) ; | ||
Serial.println (" bit/s") ; | ||
Serial.print ("Exact Arbitration Bit Rate ? ") ; | ||
Serial.println (settings.exactArbitrationBitRate () ? "yes" : "no") ; | ||
Serial.print ("Arbitration Sample point: ") ; | ||
Serial.print (settings.arbitrationSamplePointFromBitStart ()) ; | ||
Serial.println ("%") ; | ||
}else{ | ||
Serial.print ("Configuration error 0x") ; | ||
Serial.println (errorCode, HEX) ; | ||
} | ||
} | ||
|
||
//—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— | ||
|
||
static unsigned gBlinkLedDate = 0 ; | ||
static unsigned gReceivedFrameCount = 0 ; | ||
static unsigned gSentFrameCount = 0 ; | ||
|
||
//—————————————————————————————————————————————————————————————————————————————— | ||
|
||
void loop() { | ||
CANFDMessage frame ; | ||
if (gBlinkLedDate < millis ()) { | ||
gBlinkLedDate += 2000 ; | ||
digitalWrite (LED_BUILTIN, !digitalRead (LED_BUILTIN)) ; | ||
frame.len = 64 ; | ||
for (uint8_t i=0 ; i<frame.len ; i++) { | ||
frame.data [i] = i ; | ||
} | ||
const bool ok = can.tryToSend (frame) ; | ||
if (ok) { | ||
gSentFrameCount += 1 ; | ||
Serial.print ("Sent: ") ; | ||
Serial.println (gSentFrameCount) ; | ||
}else{ | ||
Serial.println ("Send failure") ; | ||
} | ||
} | ||
if (can.available ()) { | ||
can.receive (frame) ; | ||
bool ok = frame.len == 64 ; | ||
if (!ok) { | ||
Serial.println ("length error") ; | ||
} | ||
for (uint8_t i=0 ; (i<frame.len) && ok ; i++) { | ||
ok = frame.data [i] == i ; | ||
} | ||
gReceivedFrameCount ++ ; | ||
Serial.print ("Received: ") ; | ||
Serial.print (gReceivedFrameCount) ; | ||
Serial.print (", ") ; | ||
Serial.println (ok ? "ok" : "error") ; | ||
} | ||
} | ||
|
||
//—————————————————————————————————————————————————————————————————————————————— |
Oops, something went wrong.