Skip to content

Commit

Permalink
Namespace updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ThadHouse committed Nov 23, 2019
1 parent 7b99759 commit 2c0c1cd
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 11 deletions.
4 changes: 2 additions & 2 deletions FRC_CAN.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "frc/CAN.h"
#include "mcp2515/mcp2515.h"
#include "frc/mcp2515.h"

using namespace frc;

MCP2515 *CAN::m_mcp2515 = nullptr;
frc::MCP2515 *CAN::m_mcp2515 = nullptr;
uint8_t CAN::m_interruptPin = 0;
CAN::MessageCallback CAN::m_messageCb = nullptr;
CAN::UnknownMessageCallback CAN::m_unknownMessageCb = nullptr;
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FRC Arduino MCP2515 CAN interface library
---------------------------------------------------------

Documentation incoming
6 changes: 3 additions & 3 deletions examples/FRC_CAN_Communication/FRC_CAN_Communication.ino
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

#include "mcp2515/mcp2515.h"
#include "frc/mcp2515.h"
#include "frc/CAN.h"

// Define the CS pin and the interrupt pin
#define CAN_CS 10
#define CAN_INTERRUPT 2

// Create an MCP2515 device. Only need to create 1 of these
MCP2515 mcp2515{CAN_CS};
frc::MCP2515 mcp2515{CAN_CS};

// Create an FRC CAN Device. You can create up to 16 of these in 1 progam
// Any more will overflow a global array
Expand All @@ -31,7 +31,7 @@ void setup() {
auto err = mcp2515.reset();
// CAN rate must be 1000KBPS to work with the FRC Ecosystem
// Clock rate must match clock rate of CAN Board.
err = mcp2515.setBitrate(CAN_1000KBPS, CAN_CLOCK::MCP_8MHZ);
err = mcp2515.setBitrate(frc::CAN_1000KBPS, frc::CAN_CLOCK::MCP_8MHZ);

// Set up to normal CAN mode
err = mcp2515.setNormalMode();
Expand Down
3 changes: 1 addition & 2 deletions frc/CAN.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

#include <stdint.h>

class MCP2515;

namespace frc
{
class MCP2515;
struct CANData
{
uint8_t data[8];
Expand Down
File renamed without changes.
10 changes: 7 additions & 3 deletions mcp2515/mcp2515.h → frc/mcp2515.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef _MCP2515_H_
#define _MCP2515_H_
#ifndef _FRC_MCP2515_H_
#define _FRC_MCP2515_H_

#include <SPI.h>
#include "can.h"
#include "frc/can_core.h"

/*
* Speed 8M
Expand Down Expand Up @@ -169,6 +169,8 @@
#define MCP_20MHz_33k3BPS_CFG2 (0xFF)
#define MCP_20MHz_33k3BPS_CFG3 (0x87)

namespace frc {

enum CAN_CLOCK {
MCP_20MHZ,
MCP_16MHZ,
Expand Down Expand Up @@ -486,4 +488,6 @@ class MCP2515
void clearERRIF();
};

}

#endif
15 changes: 15 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
MCP2515 KEYWORD1
CAN KEYWORD1

CAN_5KBPS LITERAL1
CAN_10KBPS LITERAL1
CAN_20KBPS LITERAL1
CAN_40KBPS LITERAL1
CAN_50KBPS LITERAL1
CAN_80KBPS LITERAL1
CAN_100KBPS LITERAL1
CAN_125KBPS LITERAL1
CAN_200KBPS LITERAL1
CAN_250KBPS LITERAL1
CAN_500KBPS LITERAL1
CAN_1000KBPS LITERAL1
4 changes: 3 additions & 1 deletion mcp2515.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "mcp2515/mcp2515.h"
#include "frc/mcp2515.h"

using namespace frc;

const struct MCP2515::TXBn_REGS MCP2515::TXB[MCP2515::N_TXBUFFERS] = {
{MCP_TXB0CTRL, MCP_TXB0SIDH, MCP_TXB0DATA},
Expand Down

0 comments on commit 2c0c1cd

Please sign in to comment.