Files
allwpilib/wpilibc/wpilibC++Devices/include/SPI.h
James Kuszmaul 7eb8550bdb Major formatting changes (breaks diffs). No code changes.
The changes made in this commit do not affect any actual code,
    they are purely aesthetic. I ran clang-format with google style
    over all .h/.cpp files in wpilibc that weren't in wpilibC++Sim
    or gtest, and the eclipse formatter over all of the Java files
    using the Google eclipse formatting configuration.

Change-Id: I9627bca0bc103c398ecc1c5ba17467193291ae63
2015-06-25 15:07:55 -04:00

58 lines
1.5 KiB
C++

/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.
*/
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#pragma once
#include "HAL/HAL.hpp"
#include "SensorBase.h"
class DigitalOutput;
class DigitalInput;
/**
* SPI bus interface class.
*
* This class is intended to be used by sensor (and other SPI device) drivers.
* It probably should not be used directly.
*
*/
class SPI : public SensorBase {
public:
enum Port { kOnboardCS0, kOnboardCS1, kOnboardCS2, kOnboardCS3, kMXP };
SPI(Port SPIport);
virtual ~SPI();
void SetClockRate(double hz);
void SetMSBFirst();
void SetLSBFirst();
void SetSampleDataOnFalling();
void SetSampleDataOnRising();
void SetClockActiveLow();
void SetClockActiveHigh();
void SetChipSelectActiveHigh();
void SetChipSelectActiveLow();
virtual int32_t Write(uint8_t* data, uint8_t size);
virtual int32_t Read(bool initiate, uint8_t* dataReceived, uint8_t size);
virtual int32_t Transaction(uint8_t* dataToSend, uint8_t* dataReceived,
uint8_t size);
protected:
uint8_t m_port;
bool m_msbFirst;
bool m_sampleOnTrailing;
bool m_clk_idle_high;
private:
void Init();
DISALLOW_COPY_AND_ASSIGN(SPI);
};