FastLED 3.9.7
Loading...
Searching...
No Matches
fastspi_ref.h
Go to the documentation of this file.
1
4
5#ifndef __INC_FASTSPI_ARM_SAM_H
6#define __INC_FASTSPI_ARM_SAM_H
7
8#if FASTLED_DOXYGEN // guard against the arduino ide idiotically including every header file
9#include "FastLED.h"
10
12
15template <uint8_t _DATA_PIN, uint8_t _CLOCK_PIN, uint32_t _SPI_CLOCK_DIVIDER>
17 Selectable *m_pSelect;
18
19public:
21 SAMHardwareSPIOutput() { m_pSelect = NULL; }
22
24 SAMHArdwareSPIOutput(Selectable *pSelect) { m_pSelect = pSelect; }
25
27 void setSelect(Selectable *pSelect) { /* TODO */ }
28
30 void init() { /* TODO */ }
31
33 void inline select() __attribute__((always_inline)) { if(m_pSelect != NULL) { m_pSelect->select(); } }
34
36 void inline release() __attribute__((always_inline)) { if(m_pSelect != NULL) { m_pSelect->release(); } }
37
39 static void waitFully() { /* TODO */ }
40
42 static void writeByte(uint8_t b) { /* TODO */ }
43
45 static void writeWord(uint16_t w) { /* TODO */ }
46
48 static void writeBytesValueRaw(uint8_t value, int len) {
49 while(len--) { writeByte(value); }
50 }
51
53 void writeBytesValue(uint8_t value, int len) {
54 select(); writeBytesValueRaw(value, len); release();
55 }
56
58 template <class D> void writeBytes(FASTLED_REGISTER uint8_t *data, int len) {
59 uint8_t *end = data + len;
60 select();
61 // could be optimized to write 16bit words out instead of 8bit bytes
62 while(data != end) {
63 writeByte(D::adjust(*data++));
64 }
65 D::postBlock(len);
66 waitFully();
67 release();
68 }
69
71 void writeBytes(FASTLED_REGISTER uint8_t *data, int len) { writeBytes<DATA_NOP>(data, len); }
72
74 template <uint8_t BIT> inline static void writeBit(uint8_t b) { /* TODO */ }
75
78 template <uint8_t FLAGS, class D, EOrder RGB_ORDER> void writePixels(PixelController<RGB_ORDER> pixels, void* context = NULL) {
79 select();
80 while(data != end) {
81 if(FLAGS & FLAG_START_BIT) {
82 writeBit<0>(1);
83 }
84 writeByte(D::adjust(pixels.loadAndScale0()));
85 writeByte(D::adjust(pixels.loadAndScale1()));
86 writeByte(D::adjust(pixels.loadAndScale2()));
87
88 pixels.advanceData();
89 pixels.stepDithering();
90 data += (3+skip);
91 }
92 D::postBlock(len);
93 release();
94 }
95
96};
97
99
100#endif
101
102#endif
103
central include file for FastLED, defines the CFastLED class/object
A skeletal implementation of hardware SPI support.
Definition fastspi_ref.h:16
static void writeByte(uint8_t b)
write a byte out via SPI (returns immediately on writing register)
Definition fastspi_ref.h:42
void writePixels(PixelController< RGB_ORDER > pixels, void *context=NULL)
write a block of uint8_ts out in groups of three.
Definition fastspi_ref.h:78
SAMHArdwareSPIOutput(Selectable *pSelect)
Constructor with selectable.
Definition fastspi_ref.h:24
void writeBytes(FASTLED_REGISTER uint8_t *data, int len)
A full cycle of writing a value for len bytes, including select, release, and waiting.
Definition fastspi_ref.h:71
static void writeBit(uint8_t b)
write a single bit out, which bit from the passed in byte is determined by template parameter
Definition fastspi_ref.h:74
SAMHardwareSPIOutput()
Default Constructor.
Definition fastspi_ref.h:21
void writeBytesValue(uint8_t value, int len)
A full cycle of writing a value for len bytes, including select, release, and waiting.
Definition fastspi_ref.h:53
void release()
release the CS select
Definition fastspi_ref.h:36
void setSelect(Selectable *pSelect)
set the object representing the selectable
Definition fastspi_ref.h:27
void select()
latch the CS select
Definition fastspi_ref.h:33
static void writeBytesValueRaw(uint8_t value, int len)
A raw set of writing byte values, assumes setup/init/waiting done elsewhere.
Definition fastspi_ref.h:48
void init()
initialize the SPI subssytem
Definition fastspi_ref.h:30
static void writeWord(uint16_t w)
write a word out via SPI (returns immediately on writing register)
Definition fastspi_ref.h:45
static void waitFully()
wait until all queued up data has been written
Definition fastspi_ref.h:39
void writeBytes(FASTLED_REGISTER uint8_t *data, int len)
A full cycle of writing a value for len bytes, including select, release, and waiting.
Definition fastspi_ref.h:58
Abstract class for "selectable" things.
Definition fastpin.h:34
virtual void release()=0
Release this object.
virtual void select()=0
Select this object.
#define FLAG_START_BIT
Flag for the start of an SPI transaction.
#define FASTLED_NAMESPACE_END
End of the FastLED namespace.
Definition namespace.h:16
#define FASTLED_NAMESPACE_BEGIN
Start of the FastLED namespace.
Definition namespace.h:14
Pixel controller class.
FASTLED_FORCE_INLINE uint8_t loadAndScale1(int lane, uint8_t scale)
non-template alias of loadAndScale<1>()
FASTLED_FORCE_INLINE uint8_t loadAndScale2(int lane, uint8_t scale)
non-template alias of loadAndScale<2>()
FASTLED_FORCE_INLINE uint8_t loadAndScale0(int lane, uint8_t scale)
non-template alias of loadAndScale<0>()
FASTLED_FORCE_INLINE void advanceData()
Advance the data pointer forward, adjust position counter.
FASTLED_FORCE_INLINE void stepDithering()
Step the dithering forward.