-
Notifications
You must be signed in to change notification settings - Fork 0
/
ws2812b_attiny13.h
32 lines (26 loc) · 1.13 KB
/
ws2812b_attiny13.h
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
// Headers for WS2812B protocol implementation for the attiny13
//
// Author: Amber Sprenkels <amber@electricdusk.com>
// License: MIT
#ifndef WS2812B_ATTINY13_H_
#define WS2812B_ATTINY13_H_
#include <avr/io.h>
#include <inttypes.h>
#include <util/delay.h>
// AVR_LAB MODIFICATION START
// We try to utilize this as well for 8MHz
#if F_CPU != 9600000UL && F_CPU != 8000000UL //#if F_CPU != 9600000UL
// AVR_LAB MODIFICATION END
# error "The WS2812b code can only be used with an F_CPU of exactly 9600000UL"
# pragma message("The default clock frequency of an attiny13 is 1.2 MHz. \
To set the clock frequency to 9.6 MHz, unprogram the CKDIV8 bit (bit no. 4) from the lower fuse register. \
For more information, look at the datasheet (pages 25, 103).")
#endif
void ws2812b_set_color_no_reset(const uint8_t pin_value, const uint8_t red, const uint8_t green, const uint8_t blue);
static void ws2812b_set_color(const uint8_t pin_value, const uint8_t red, const uint8_t green, const uint8_t blue) {
DDRB |= pin_value;
PORTB &= ~pin_value;
_delay_us(50);
ws2812b_set_color_no_reset(pin_value, red, green, blue);
}
#endif // WS2812B_ATTINY13_H_