xcore / sc_can Goto Github PK
View Code? Open in Web Editor NEWCAN Phy/link layer component
Home Page: None
License: Other
CAN Phy/link layer component
Home Page: None
License: Other
Hello,
I've only used assembler a few times. Therefore, I don't understand the structure of the can.s file and what different parts of the code do.
Could someone enlighten me?
Thanks
I am puzzled that the CAN stack uses a soft implementation of the CRC, rather than the CRC instruction - which should save a considerable amount of time. I was going to try this in a forked repo, but the current CAN implementation does not have any self-testing harness so I have held off for a bit.
Just to capture my thoughts:
The polynomial and bitstrings have to be reversed, after that it is plain sailing (some code attached that computes a crc over a 26 bit packet that includes 15-bit CRC and shows that a soft and hard CRC end up with the same '0000' indicating that the packet is correct)
On a normal packet:
On an extended packet:
Code::
int crc15(int nxtBit, unsigned int crc_rg) {
#pragma xta label "excludeCrc"
int crc_nxt = (nxtBit ^ (crc_rg >> 14)) & 0x1;
crc_rg = crc_rg << 1;
if (crc_nxt) {
crc_rg = crc_rg ^ 0x4599;
}
return crc_rg;
}
char bitstring[] = {
1,0,0, 1,1,0,1,0,0,1,0,
1,1,0,1,1,0,0,1,1,0,1,1,0,0,1
};
int main(void) {
unsigned int cc = 0;
int bits;
int poly = 0x4cd1;
for(int i = 0; i < 26; i++) {
cc = crc15(bitstring[i], cc);
}
printf("%04x\n", cc&0x7fff);
cc = 0;
bits = 0;
for(int i = 0; i < 2; i++) {
bits = bits << 1 | bitstring[i];
}
cc = bitrev(bits);
for(int j = 0; j < 3; j++) {
bits = 0;
for(int i = 2; i < 10; i++) {
bits = bits << 1 | bitstring[i+j*8];
}
crc8shr(cc, bitrev(bits)>>24, poly);
}
crc32(cc, 0, poly);
printf("%04x\n", bitrev(cc)>>17&0x7fff);
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.