Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
RHHardwareSPI.h
00001 // RHHardwareSPI.h 00002 // Author: Mike McCauley (mikem@airspayce.com) 00003 // Copyright (C) 2011 Mike McCauley 00004 // Contributed by Joanna Rutkowska 00005 // $Id: RHHardwareSPI.h,v 1.9 2014/08/12 00:54:52 mikem Exp $ 00006 00007 #ifndef RHHardwareSPI_h 00008 #define RHHardwareSPI_h 00009 00010 #include <RHGenericSPI.h> 00011 00012 ///////////////////////////////////////////////////////////////////// 00013 /// \class RHHardwareSPI RHHardwareSPI.h <RHHardwareSPI.h> 00014 /// \brief Encapsulate a hardware SPI bus interface 00015 /// 00016 /// This concrete subclass of GenericSPIClass encapsulates the standard Arduino hardware and other 00017 /// hardware SPI interfaces. 00018 class RHHardwareSPI : public RHGenericSPI 00019 { 00020 #ifdef RH_HAVE_HARDWARE_SPI 00021 public: 00022 /// Constructor 00023 /// Creates an instance of a hardware SPI interface, using whatever SPI hardware is available on 00024 /// your processor platform. On Arduino and Uno32, uses SPI. On Maple, uses HardwareSPI. 00025 /// \param[in] frequency One of RHGenericSPI::Frequency to select the SPI bus frequency. The frequency 00026 /// is mapped to the closest available bus frequency on the platform. 00027 /// \param[in] bitOrder Select the SPI bus bit order, one of RHGenericSPI::BitOrderMSBFirst or 00028 /// RHGenericSPI::BitOrderLSBFirst. 00029 /// \param[in] dataMode Selects the SPI bus data mode. One of RHGenericSPI::DataMode 00030 RHHardwareSPI(Frequency frequency = Frequency1MHz, BitOrder bitOrder = BitOrderMSBFirst, DataMode dataMode = DataMode0); 00031 00032 /// Transfer a single octet to and from the SPI interface 00033 /// \param[in] data The octet to send 00034 /// \return The octet read from SPI while the data octet was sent 00035 uint8_t transfer(uint8_t data); 00036 00037 // SPI Configuration methods 00038 /// Enable SPI interrupts 00039 /// This can be used in an SPI slave to indicate when an SPI message has been received 00040 /// It will cause the SPI_STC_vect interrupt vectr to be executed 00041 void attachInterrupt(); 00042 00043 /// Disable SPI interrupts 00044 /// This can be used to diable the SPI interrupt in slaves where that is supported. 00045 void detachInterrupt(); 00046 00047 /// Initialise the SPI library 00048 /// Call this after configuring the SPI interface and before using it to transfer data. 00049 /// Initializes the SPI bus by setting SCK, MOSI, and SS to outputs, pulling SCK and MOSI low, and SS high. 00050 void begin(); 00051 00052 /// Disables the SPI bus (leaving pin modes unchanged). 00053 /// Call this after you have finished using the SPI interface. 00054 void end(); 00055 #else 00056 // not supported on ATTiny etc 00057 uint8_t transfer(uint8_t data) {return 0;} 00058 void begin(){} 00059 void end(){} 00060 00061 #endif 00062 }; 00063 00064 // Built in default instance 00065 extern RHHardwareSPI hardware_spi; 00066 00067 #endif
Generated on Tue Jul 12 2022 18:05:56 by
1.7.2