Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
MarlinKimbra
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
MarlinKimbra
Commits
49ff3bfa
Commit
49ff3bfa
authored
9 years ago
by
MagoKimbra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Arduino
parent
cb401f82
master
dev
k40_flow_cooler
k40_noflow_nocooler
nextime
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
172 deletions
+0
-172
SPI.cpp
Arduino/libraries/SPI/SPI.cpp
+0
-66
SPI.h
Arduino/libraries/SPI/SPI.h
+0
-70
keywords.txt
Arduino/libraries/SPI/keywords.txt
+0
-36
No files found.
Arduino/libraries/SPI/SPI.cpp
deleted
100644 → 0
View file @
cb401f82
/*
* Copyright (c) 2010 by Cristian Maglie <c.maglie@bug.st>
* SPI Master library for arduino.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of either the GNU General Public License version 2
* or the GNU Lesser General Public License version 2.1, both as
* published by the Free Software Foundation.
*/
#include "pins_arduino.h"
#include "SPI.h"
SPIClass
SPI
;
void
SPIClass
::
begin
()
{
// Set SS to high so a connected chip will be "deselected" by default
digitalWrite
(
SS
,
HIGH
);
// When the SS pin is set as OUTPUT, it can be used as
// a general purpose output port (it doesn't influence
// SPI operations).
pinMode
(
SS
,
OUTPUT
);
// Warning: if the SS pin ever becomes a LOW INPUT then SPI
// automatically switches to Slave, so the data direction of
// the SS pin MUST be kept as OUTPUT.
SPCR
|=
_BV
(
MSTR
);
SPCR
|=
_BV
(
SPE
);
// Set direction register for SCK and MOSI pin.
// MISO pin automatically overrides to INPUT.
// By doing this AFTER enabling SPI, we avoid accidentally
// clocking in a single bit since the lines go directly
// from "input" to SPI control.
// http://code.google.com/p/arduino/issues/detail?id=888
pinMode
(
SCK
,
OUTPUT
);
pinMode
(
MOSI
,
OUTPUT
);
}
void
SPIClass
::
end
()
{
SPCR
&=
~
_BV
(
SPE
);
}
void
SPIClass
::
setBitOrder
(
uint8_t
bitOrder
)
{
if
(
bitOrder
==
LSBFIRST
)
{
SPCR
|=
_BV
(
DORD
);
}
else
{
SPCR
&=
~
(
_BV
(
DORD
));
}
}
void
SPIClass
::
setDataMode
(
uint8_t
mode
)
{
SPCR
=
(
SPCR
&
~
SPI_MODE_MASK
)
|
mode
;
}
void
SPIClass
::
setClockDivider
(
uint8_t
rate
)
{
SPCR
=
(
SPCR
&
~
SPI_CLOCK_MASK
)
|
(
rate
&
SPI_CLOCK_MASK
);
SPSR
=
(
SPSR
&
~
SPI_2XCLOCK_MASK
)
|
((
rate
>>
2
)
&
SPI_2XCLOCK_MASK
);
}
This diff is collapsed.
Click to expand it.
Arduino/libraries/SPI/SPI.h
deleted
100644 → 0
View file @
cb401f82
/*
* Copyright (c) 2010 by Cristian Maglie <c.maglie@bug.st>
* SPI Master library for arduino.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of either the GNU General Public License version 2
* or the GNU Lesser General Public License version 2.1, both as
* published by the Free Software Foundation.
*/
#ifndef _SPI_H_INCLUDED
#define _SPI_H_INCLUDED
#include <stdio.h>
#include <Arduino.h>
#include <avr/pgmspace.h>
#define SPI_CLOCK_DIV4 0x00
#define SPI_CLOCK_DIV16 0x01
#define SPI_CLOCK_DIV64 0x02
#define SPI_CLOCK_DIV128 0x03
#define SPI_CLOCK_DIV2 0x04
#define SPI_CLOCK_DIV8 0x05
#define SPI_CLOCK_DIV32 0x06
//#define SPI_CLOCK_DIV64 0x07
#define SPI_MODE0 0x00
#define SPI_MODE1 0x04
#define SPI_MODE2 0x08
#define SPI_MODE3 0x0C
#define SPI_MODE_MASK 0x0C // CPOL = bit 3, CPHA = bit 2 on SPCR
#define SPI_CLOCK_MASK 0x03 // SPR1 = bit 1, SPR0 = bit 0 on SPCR
#define SPI_2XCLOCK_MASK 0x01 // SPI2X = bit 0 on SPSR
class
SPIClass
{
public
:
inline
static
byte
transfer
(
byte
_data
);
// SPI Configuration methods
inline
static
void
attachInterrupt
();
inline
static
void
detachInterrupt
();
// Default
static
void
begin
();
// Default
static
void
end
();
static
void
setBitOrder
(
uint8_t
);
static
void
setDataMode
(
uint8_t
);
static
void
setClockDivider
(
uint8_t
);
};
extern
SPIClass
SPI
;
byte
SPIClass
::
transfer
(
byte
_data
)
{
SPDR
=
_data
;
while
(
!
(
SPSR
&
_BV
(
SPIF
)))
;
return
SPDR
;
}
void
SPIClass
::
attachInterrupt
()
{
SPCR
|=
_BV
(
SPIE
);
}
void
SPIClass
::
detachInterrupt
()
{
SPCR
&=
~
_BV
(
SPIE
);
}
#endif
This diff is collapsed.
Click to expand it.
Arduino/libraries/SPI/keywords.txt
deleted
100644 → 0
View file @
cb401f82
#######################################
# Syntax Coloring Map SPI
#######################################
#######################################
# Datatypes (KEYWORD1)
#######################################
SPI KEYWORD1
#######################################
# Methods and Functions (KEYWORD2)
#######################################
begin KEYWORD2
end KEYWORD2
transfer KEYWORD2
setBitOrder KEYWORD2
setDataMode KEYWORD2
setClockDivider KEYWORD2
#######################################
# Constants (LITERAL1)
#######################################
SPI_CLOCK_DIV4 LITERAL1
SPI_CLOCK_DIV16 LITERAL1
SPI_CLOCK_DIV64 LITERAL1
SPI_CLOCK_DIV128 LITERAL1
SPI_CLOCK_DIV2 LITERAL1
SPI_CLOCK_DIV8 LITERAL1
SPI_CLOCK_DIV32 LITERAL1
SPI_CLOCK_DIV64 LITERAL1
SPI_MODE0 LITERAL1
SPI_MODE1 LITERAL1
SPI_MODE2 LITERAL1
SPI_MODE3 LITERAL1
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment