FastLED 3.9.15
Loading...
Searching...
No Matches
fastspi_ref.h
Go to the documentation of this file.
1#pragma once
2
6
7#ifndef __INC_FASTSPI_ARM_SAM_H
8#define __INC_FASTSPI_ARM_SAM_H
9
10#if FASTLED_DOXYGEN // guard against the arduino ide idiotically including every header file
11#include "FastLED.h"
12
14
17template <uint8_t _DATA_PIN, uint8_t _CLOCK_PIN, uint32_t _SPI_CLOCK_DIVIDER>
20
21public:
24
26 SAMHArdwareSPIOutput(Selectable *pSelect) { m_pSelect = pSelect; }
27
29 void setSelect(Selectable *pSelect) { /* TODO */ }
30
32 void init() { /* TODO */ }
33
35 void inline select() __attribute__((always_inline)) { if(m_pSelect != NULL) { m_pSelect->select(); } }
36
38 void inline release() __attribute__((always_inline)) { if(m_pSelect != NULL) { m_pSelect->release(); } }
39
41 static void waitFully() { /* TODO */ }
42
44 static void writeByte(uint8_t b) { /* TODO */ }
45
47 static void writeWord(uint16_t w) { /* TODO */ }
48
50 static void writeBytesValueRaw(uint8_t value, int len) {
51 while(len--) { writeByte(value); }
52 }
53
55 void writeBytesValue(uint8_t value, int len) {
56 select(); writeBytesValueRaw(value, len); release();
57 }
58
60 template <class D> void writeBytes(FASTLED_REGISTER uint8_t *data, int len) {
61 uint8_t *end = data + len;
62 select();
63 // could be optimized to write 16bit words out instead of 8bit bytes
64 while(data != end) {
65 writeByte(D::adjust(*data++));
66 }
67 D::postBlock(len);
68 waitFully();
69 release();
70 }
71
73 void writeBytes(FASTLED_REGISTER uint8_t *data, int len) { writeBytes<DATA_NOP>(data, len); }
74
76 template <uint8_t BIT> inline static void writeBit(uint8_t b) { /* TODO */ }
77
80 template <uint8_t FLAGS, class D, EOrder RGB_ORDER> void writePixels(PixelController<RGB_ORDER> pixels, void* context = NULL) {
81 select();
82 while(data != end) {
83 if(FLAGS & FLAG_START_BIT) {
84 writeBit<0>(1);
85 }
86 writeByte(D::adjust(pixels.loadAndScale0()));
87 writeByte(D::adjust(pixels.loadAndScale1()));
88 writeByte(D::adjust(pixels.loadAndScale2()));
89
90 pixels.advanceData();
91 pixels.stepDithering();
92 data += (3+skip);
93 }
94 D::postBlock(len);
95 release();
96 }
97
98};
99
101
102#endif
103
104#endif
105
central include file for FastLED, defines the CFastLED class/object
static void writeByte(uint8_t b)
write a byte out via SPI (returns immediately on writing register)
Definition fastspi_ref.h:44
void writePixels(PixelController< RGB_ORDER > pixels, void *context=NULL)
write a block of uint8_ts out in groups of three.
Definition fastspi_ref.h:80
Selectable * m_pSelect
Definition fastspi_ref.h:19
SAMHArdwareSPIOutput(Selectable *pSelect)
Constructor with selectable.
Definition fastspi_ref.h:26
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:73
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:76
SAMHardwareSPIOutput()
Default Constructor.
Definition fastspi_ref.h:23
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:55
void release()
release the CS select
Definition fastspi_ref.h:38
void setSelect(Selectable *pSelect)
set the object representing the selectable
Definition fastspi_ref.h:29
void select()
latch the CS select
Definition fastspi_ref.h:35
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:50
void init()
initialize the SPI subssytem
Definition fastspi_ref.h:32
static void writeWord(uint16_t w)
write a word out via SPI (returns immediately on writing register)
Definition fastspi_ref.h:47
static void waitFully()
wait until all queued up data has been written
Definition fastspi_ref.h:41
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:60
A skeletal implementation of hardware SPI support.
Definition fastspi_ref.h:18
Abstract class for "selectable" things.
Definition fastpin.h:36
#define FLAG_START_BIT
Flag for the start of an SPI transaction.
#define FASTLED_NAMESPACE_END
Definition namespace.h:23
#define FASTLED_REGISTER
Helper macro to replace the deprecated 'register' keyword if we're using modern C++ where it's been r...
Definition register.h:8
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.
Pixel controller class.