forked from mkschreder/avr-ultimate-driver-pack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
l74hc595.c
39 lines (29 loc) · 833 Bytes
/
l74hc595.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
l74hc595 lib 0x01
copyright (c) Davide Gironi, 2011
References: bildr 74hc595 library for arduino
http://bildr.org/2011/08/74hc595-breakout-arduino/
Released under GPLv3.
Please refer to LICENSE file for licensing information.
*/
#include <stdio.h>
#include <avr/io.h>
#include <util/delay.h>
#include "l74hc595.h"
#include "spi.h"
#define L74HC595_STCLo {L74HC595_PORT &= ~_BV(L74HC595_STCPIN);}
#define L74HC595_STCHi {L74HC595_PORT |= _BV(L74HC595_STCPIN);}
/*
* init the shift register
*/
void l74hc595_init(void) {
spi_init();
L74HC595_DDR |= _BV(L74HC595_STCPIN);
L74HC595_STCLo;
}
void l74hc595_write(uint8_t data) {
spi_writereadbyte(data);
L74HC595_STCHi;
_delay_us(1); // not needed but still for safety (16ns is minimum high period)
L74HC595_STCLo;
}