Rev | Line | |
---|
[136] | 1 | /*
|
---|
| 2 | * Copyright (c) 2010 by Cristian Maglie <c.maglie@bug.st>
|
---|
| 3 | * SPI Master library for arduino.
|
---|
| 4 | *
|
---|
| 5 | * This file is free software; you can redistribute it and/or modify
|
---|
| 6 | * it under the terms of either the GNU General Public License version 2
|
---|
| 7 | * or the GNU Lesser General Public License version 2.1, both as
|
---|
| 8 | * published by the Free Software Foundation.
|
---|
| 9 | */
|
---|
| 10 |
|
---|
| 11 | #ifndef _SPI_H_INCLUDED
|
---|
| 12 | #define _SPI_H_INCLUDED
|
---|
| 13 |
|
---|
| 14 | #include "variant.h"
|
---|
| 15 | #include "wiring_constants.h"
|
---|
| 16 |
|
---|
| 17 | #define SPI_MODE0 0x02
|
---|
| 18 | #define SPI_MODE1 0x00
|
---|
| 19 | #define SPI_MODE2 0x03
|
---|
| 20 | #define SPI_MODE3 0x01
|
---|
| 21 |
|
---|
| 22 | class SPIClass {
|
---|
| 23 | public:
|
---|
| 24 | SPIClass(SERCOM *p_sercom, uint8_t uc_pinMISO, uint8_t uc_pinSCK, uint8_t uc_pinMOSI);
|
---|
| 25 |
|
---|
| 26 | byte transfer(uint8_t data);
|
---|
| 27 |
|
---|
| 28 | // SPI Configuration methods
|
---|
| 29 | void attachInterrupt();
|
---|
| 30 | void detachInterrupt();
|
---|
| 31 |
|
---|
| 32 | void begin();
|
---|
| 33 | void end();
|
---|
| 34 |
|
---|
| 35 | void setBitOrder(BitOrder order);
|
---|
| 36 | void setDataMode(uint8_t uc_mode);
|
---|
| 37 | void setClockDivider(uint8_t uc_div);
|
---|
| 38 |
|
---|
| 39 | private:
|
---|
| 40 | SERCOM *_p_sercom;
|
---|
| 41 | uint8_t _uc_pinMiso;
|
---|
| 42 | uint8_t _uc_pinMosi;
|
---|
| 43 | uint8_t _uc_pinSCK;
|
---|
| 44 | };
|
---|
| 45 |
|
---|
| 46 | #if SPI_INTERFACES_COUNT > 0
|
---|
| 47 | extern SPIClass SPI;
|
---|
| 48 | #endif
|
---|
| 49 |
|
---|
| 50 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.