• Stars
    star
    154
  • Rank 242,095 (Top 5 %)
  • Language
    C++
  • License
    GNU General Publi...
  • Created about 11 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Arduino hardware SPI library for ATtiny44/84, 45/85, 461/861, 2313/4313.

Arduino tinySPI Library

http://github.com/JChristensen/tinySPI
README file
Jack Christensen
Oct 2013

License

Arduino tinySPI Library Copyright (C) 2018 Jack Christensen GNU GPL v3.0

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License v3.0 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/gpl.html

Description

tinySPI is an Arduino SPI master library for ATtiny microcontrollers that utilizes the USI hardware in the ATtiny MCUs. Supported MCUs include ATtiny24/44/84, 25/45/85, 261/461/861, 2313/4313.

Because the USI hardware is not as sophisticated as the dedicated SPI hardware in the ATmega MCUs, tinySPI is more limited than the standard Arduino SPI library but still has several advantages over software bit-bang approaches.

As compared to the Arduino shiftOut() function, tinySPI

  • is about 15 times faster,
  • has a smaller program memory footprint, and
  • has a consistent bit clock period.

tinySPI does not support

  • sending the least-significant bit first,
  • SPI data modes 2 and 3, or
  • user-selectable SPI clock frequencies.

tinySPI will generate an SPI bit clock that is about one-tenth the MCU system clock frequency. For example, given a 1MHz system clock, the SPI clock will be about 100kHz, and it will take about 80μs to transfer one byte.

Interrupts are inhibited during each byte transfer to ensure a consistent bit clock period.

Included with the library are example sketches that demonstrate driving a 74HC595 shift register from an ATtiny84 and from an ATtiny85.

tinySPI has been tested with Arduino 1.8.5 and the ATTiny Core.

Methods

  • begin()
  • end()
  • setDataMode()
  • transfer()

begin()

Description

Initializes the SPI bus, sets the USCK and DO pins to outputs, sets the DI pin to input.

Syntax

SPI.begin();

Parameters

None.

Returns

None.

end()

Description

Disables the SPI bus (leaving the pin modes unchanged).

Syntax

SPI.end();

Parameters

None.

Returns

None.

setDataMode()

Description

Sets the SPI data mode, i.e. clock polarity and phase. See the Wikipedia article on SPI for details.

Syntax

SPI.setDataMode(mode)

Parameters

mode: SPI_MODE0 or SPI_MODE1 (modes 2 and 3 are not supported)

Returns

None.

transfer()

Description

Transfers one byte over the SPI bus, both sending and receiving. Interrupts are inhibited during each byte transfer to ensure a consistent bit clock period.

Syntax

SPI.transfer(val);

Parameters

val: the byte to send over the bus (byte)

Returns

the byte read from the bus (byte)

More Repositories

1

JC_Button

Arduino library to debounce button switches, detect presses, releases, and long presses
C++
423
star
2

DS3232RTC

Arduino Library for Maxim Integrated DS3232 and DS3231 Real-Time Clocks
C++
393
star
3

Timer

A fork of Simon Monk's Arduino Timer library
C++
372
star
4

Timezone

Arduino library to facilitate time zone conversions and automatic daylight saving (summer) time adjustments.
C++
279
star
5

extEEPROM

Arduino library to support external I2C EEPROMs.
C++
114
star
6

movingAvg

A simple Arduino library for calculating moving averages.
C++
90
star
7

MCP79412RTC

Arduino library for the Microchip MCP79411/12 Real-Time Clock/Calendar
C++
22
star
8

CurrentTransformer

Arduino Current Transformer Library
C++
16
star
9

mini1284

A minimal breadboard-friendly design for the ATmega1284P MCU
16
star
10

JC_EEPROM

Arduino library to support external I2C EEPROMs.
C++
14
star
11

usb-condom

A little something for the tinfoil hat crowd.
13
star
12

Thermocouple

Thermocouple library for Arduino and MAX6675
Java
11
star
13

millionOhms_SW

Warning One Million Ohms (firmware): Amuse your friends and confuse your enemies! Keep the uninititated away from your desk or out of your lab!
C++
10
star
14

PowerOutageMonitor_SW

Sketch for an Arduino-based Power Outage Logger
C++
9
star
15

TinyWireM

My modifications to the TinyWireM library from the Arduino Playground
C++
8
star
16

serialLogger

An Arduino-Compatible Serial Data Logger
C++
8
star
17

JC_Sunrise

Arduino library to calculate sunrise and sunset times.
C++
8
star
18

PowerOutageMonitor_HW

Arduino-Based Power Outage Logger PC Board
8
star
19

tinyTorch

Hardware design for a small LED flashlight powered by an ATtiny84A.
Eagle
6
star
20

MCP9808

Arduino Library for Microchip MCP9808 Maximum Accuracy Digital Temperature Sensor
C++
6
star
21

gpsFreq

Arduino frequency counter library, uses a 1 Hz (PPS) signal from a GPS receiver as an accurate time base
C++
6
star
22

nightLight

An Arduino-based demonstration/educational project with several interesting hardware and software features.
Java
5
star
23

rtc79412

Breakout Board for the Microchip MCP79412 Real-Time Clock/Calendar
5
star
24

geiger

Firmware for the MightyOhm Geiger Counter
C
4
star
25

tinyTorch-fw

Firmware for a small LED flashlight powered by an ATtiny84A.
C++
4
star
26

ledFire_HW

LED PWM Fire Effect using ATtiny84A (hardware design)
3
star
27

FiveLEDs

My spin on Technoblogy's Five LEDs Puzzle.
C++
3
star
28

ledFire_FW

LED PWM Fire Effect using ATtiny84A (firmware)
Arduino
3
star
29

aaLogger_SW

Code for the Double-A DataLogger - A low-power Arduino-based data logger.
Arduino
3
star
30

GroveStreams

GroveStreams Library for Arduino
C++
3
star
31

ds18b20

C++
3
star
32

CurrentMonitor

Arduino-compatible board to measure AC mains current with current transformers
2
star
33

piXBee

Interfaces Andrew Rapp's XBee-Arduino library to C++ running on a Raspberry Pi.
C++
2
star
34

jcGoldieClock

My firmware for LarryD's Goldie Clock
C++
2
star
35

MCP9800

Arduino Library for Microchip MCP9800/1/2/3 2-Wire High-Accuracy Temperature Sensors
C++
2
star
36

larson84

Firmware for the tinyLarson scanner
C++
2
star
37

jc_MAX31856

Arduino library for the Maxim Integrated MAX31856 Thermocouple to Digital Converter
C++
2
star
38

tinyLarson

Larson scanner powered by an ATtiny84a
2
star
39

tinyTimer

A small battery-operated timer based on an ATtiny84A.
1
star
40

rtc7941x

MCP78411/12 RTC Break-Out Board with MCP9800/2 Temperature Sensor
1
star
41

aaLogger_HW

Schematic and board for the Double-A DataLogger - A low-power Arduino-based data logger.
1
star
42

Vetinari_SW

Arduino
1
star
43

aaXBee_HW

Double-A XBee Sensor Node
Eagle
1
star
44

Vetinari_HW

1
star
45

xmasCandles

Arduino-powered Christmas Window Candles
Arduino
1
star
46

gsXBee

Arduino XBee Library for GroveStreams Wireless Sensor Network
C++
1
star
47

bbhTinyX5

ATtinyX5 Breadboard Helper, the easiest way to breadboard an ATtiny microcontroller!
1
star
48

entropyTest

A sketch to test the Arduino Entropy library at http://code.google.com/p/avr-hardware-random-number-generation/ and capture the data to an SD card.
Arduino
1
star
49

dotstar4

Simple board to hold four APA102C addressable RGB LEDs.
1
star
50

Ethernet

A modified version of the Ethernet library from Arduino 1.8.5 that supports both the WIZnet W5100 and W5200 chips.
C++
1
star
51

ac-timer-panel

Small PCB to support switch and LEDs for AC timer project.
1
star
52

bbhTinyX4

ATtinyX4 Breadboard Helper, the easiest way to breadboard an ATtiny microcontroller!
1
star
53

ac-timer-hw

Arduino-based daily timer for AC appliances.
1
star
54

aaXBee

Arduino-based wireless sensor node using XBee-ZB. Powered by two AA cells.
C++
1
star
55

Trace

Bash script to run traceroute for a given IP and log the results to a file.
Shell
1
star
56

backup

A simple rsync backup script
Shell
1
star
57

dehumid

A daily timer sketch for Arduino to control a 120VAC appliance according to a schedule with a solid-state relay.
C++
1
star
58

Minimal-Sensor-Network

A minimal Arduino/XBee/Pachube sensor network
1
star
59

Arduino-Breadboard-Helpers

Two small breakout boards that make building an Arduino-compatible breadboard a snap!
1
star