Skip to content

Commit

Permalink
General formatting and code cleanup
Browse files Browse the repository at this point in the history
No major functionality changes
  • Loading branch information
McNeight committed Jun 7, 2014
1 parent 4363fb3 commit 345b7cb
Show file tree
Hide file tree
Showing 7 changed files with 496 additions and 601 deletions.
6 changes: 3 additions & 3 deletions examples/SendCANMessages/SendCANMessages.ino
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void extendedMessage()
// There are at least two ways to put data into the message; memcpy() and individual arrays
uint8_t message_data[8] = { 0 }; // data message with an added counter

extended_message.id = extended_counter + 0x800; // Random Extended Message ID
extended_message.id = extended_counter + 0x02DACBF1; // Random Extended Message ID
extended_message.valid = true;
extended_message.rtr = 0;
extended_message.extended = CAN_EXTENDED_FRAME;
Expand All @@ -98,10 +98,10 @@ void standardMessage()
{
CAN_FRAME standard_message; // Create message object to use CAN message structure

standard_message.id = standard_counter; // Random Standard Message ID
standard_message.id = standard_counter + 0x555; // Random Standard Message ID
standard_message.valid = true;
standard_message.rtr = 0;
standard_message.extended = CAN_BASE_FRAME;
standard_message.extended = CAN_STANDARD_FRAME;
//Serial.print("standard_message.extended:");
//Serial.println(standard_message.extended);

Expand Down
47 changes: 29 additions & 18 deletions src/CAN.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,38 @@ DATE VER WHO WHAT
#include <Arduino.h>

// From the spec
#define CAN_DOMINANT 0
#define CAN_RECESSIVE 1
#define CAN_DOMINANT 0
#define CAN_RECESSIVE 1

// Base and Extended ID defines
#define CAN_BASE_FRAME 0
#define CAN_EXTENDED_FRAME 1
// Standard and Extended ID defines
#define CAN_STANDARD_FRAME 0
#define CAN_EXTENDED_FRAME 1

// For an 11 bit standard frame ID within a 16 bit variable, the first 5
// bits [15:11] are ignored
#define CAN_STANDARD_ID_MASK 0x07FF

// For a 29 bit extended frame ID within a 32 bit variable, the first 3
// bits [31:29] are ignored
#define CAN_EXTENDED_ID_MASK 0x1FFFFFFF

//

// Define the typical bitrate for CAN communication in kbps.
#define CAN_BPS_1M 1000000
#define CAN_BPS_1000K 1000000
#define CAN_BPS_800K 800000
#define CAN_BPS_500K 500000
#define CAN_BPS_250K 250000
#define CAN_BPS_125K 125000
#define CAN_BPS_100K 100000
#define CAN_BPS_50K 50000
#define CAN_BPS_33333 33333
#define CAN_BPS_25K 25000
#define CAN_BPS_20K 20000
#define CAN_BPS_10K 10000
#define CAN_BPS_5K 5000
#define CAN_BPS_1M 1000000
#define CAN_BPS_1000K 1000000
#define CAN_BPS_800K 800000
#define CAN_BPS_500K 500000
#define CAN_BPS_250K 250000
#define CAN_BPS_125K 125000
#define CAN_BPS_100K 100000
#define CAN_BPS_83K 83333 // According to ARINC 825, this is a thing
#define CAN_BPS_50K 50000
#define CAN_BPS_33333 33333
#define CAN_BPS_25K 25000
#define CAN_BPS_20K 20000
#define CAN_BPS_10K 10000
#define CAN_BPS_5K 5000

typedef struct
{
Expand Down
26 changes: 26 additions & 0 deletions src/CAN_ARINC825.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// The Logical Communication Channels (LCCs) are coded into the upper
// three bits [28:26] of the identifier fields
#define CAN_ARINC825_LCC_MASK 0x1C000000

// The Exception Event Channel (EEC) shall only be used for fast and high
// priority transmission to override other message transfers. These events will
// usually require some sort of immediate action (i.e., system degradation,
// shifting functions to other units or communicating the events to higher
// order systems). This channel is used for one-to-many communication.
#define CAN_ARINC825_LCC_EEC 0x0

// The Normal Operation Channel (NOC) shall be used for the transmission of
// aircraft operational periodic or aperiodic data based upon one-to-many
// communication. All data that is not assigned to another channel shall be
// transmitted over the NOC.
#define CAN_ARINC825_LCC_NOC 0x2

// The Node Service Channel (NSC) provides peer-to-peer communication for
// client/server type services. These services may be connectionless (no
// response transmitted) or connection-oriented (handshake type
// communication).
#define CAN_ARINC825_LCC_NSC 0x4

class CAN_ARINC825
{
}
Loading

0 comments on commit 345b7cb

Please sign in to comment.