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#include "fl/int.h"
13
15
18template <fl::u8 _DATA_PIN, fl::u8 _CLOCK_PIN, fl::u32 _SPI_CLOCK_DIVIDER>
21
22public:
25
27 SAMHArdwareSPIOutput(Selectable *pSelect) { m_pSelect = pSelect; }
28
30 void setSelect(Selectable *pSelect) { /* TODO */ }
31
33 void init() { /* TODO */ }
34
36 void inline select() __attribute__((always_inline)) { if(m_pSelect != NULL) { m_pSelect->select(); } }
37
39 void inline release() __attribute__((always_inline)) { if(m_pSelect != NULL) { m_pSelect->release(); } }
40
42 static void waitFully() { /* TODO */ }
43
45 static void writeByte(fl::u8 b) { /* TODO */ }
46
48 static void writeWord(uint16_t w) { /* TODO */ }
49
51 static void writeBytesValueRaw(fl::u8 value, int len) {
52 while(len--) { writeByte(value); }
53 }
54
56 void writeBytesValue(fl::u8 value, int len) {
57 select(); writeBytesValueRaw(value, len); release();
58 }
59
61 template <class D> void writeBytes(FASTLED_REGISTER fl::u8 *data, int len) {
62 fl::u8 *end = data + len;
63 select();
64 // could be optimized to write 16bit words out instead of 8bit bytes
65 while(data != end) {
66 writeByte(D::adjust(*data++));
67 }
68 D::postBlock(len);
69 waitFully();
70 release();
71 }
72
74 void writeBytes(FASTLED_REGISTER fl::u8 *data, int len) { writeBytes<DATA_NOP>(data, len); }
75
77 template <fl::u8 BIT> inline static void writeBit(fl::u8 b) { /* TODO */ }
78
81 template <fl::u8 FLAGS, class D, EOrder RGB_ORDER> void writePixels(PixelController<RGB_ORDER> pixels, void* context = NULL) {
82 select();
83 while(data != end) {
84 if(FLAGS & FLAG_START_BIT) {
85 writeBit<0>(1);
86 }
87 writeByte(D::adjust(pixels.loadAndScale0()));
88 writeByte(D::adjust(pixels.loadAndScale1()));
89 writeByte(D::adjust(pixels.loadAndScale2()));
90
91 pixels.advanceData();
92 pixels.stepDithering();
93 data += (3+skip);
94 }
95 D::postBlock(len);
96 release();
97 }
98
99};
100
102
103#endif
104
105#endif
central include file for FastLED, defines the CFastLED class/object
void writeBytes(FASTLED_REGISTER fl::u8 *data, int len)
A full cycle of writing a value for len bytes, including select, release, and waiting.
Definition fastspi_ref.h:74
static void writeBit(fl::u8 b)
write a single bit out, which bit from the passed in byte is determined by template parameter
Definition fastspi_ref.h:77
void writePixels(PixelController< RGB_ORDER > pixels, void *context=NULL)
write a block of uint8_ts out in groups of three.
Definition fastspi_ref.h:81
Selectable * m_pSelect
Definition fastspi_ref.h:20
static void writeByte(fl::u8 b)
write a byte out via SPI (returns immediately on writing register)
Definition fastspi_ref.h:45
SAMHArdwareSPIOutput(Selectable *pSelect)
Constructor with selectable.
Definition fastspi_ref.h:27
SAMHardwareSPIOutput()
Default Constructor.
Definition fastspi_ref.h:24
void release()
release the CS select
Definition fastspi_ref.h:39
void setSelect(Selectable *pSelect)
set the object representing the selectable
Definition fastspi_ref.h:30
void select()
latch the CS select
Definition fastspi_ref.h:36
static void writeBytesValueRaw(fl::u8 value, int len)
A raw set of writing byte values, assumes setup/init/waiting done elsewhere.
Definition fastspi_ref.h:51
void init()
initialize the SPI subssytem
Definition fastspi_ref.h:33
static void writeWord(uint16_t w)
write a word out via SPI (returns immediately on writing register)
Definition fastspi_ref.h:48
static void waitFully()
wait until all queued up data has been written
Definition fastspi_ref.h:42
void writeBytesValue(fl::u8 value, int len)
A full cycle of writing a value for len bytes, including select, release, and waiting.
Definition fastspi_ref.h:56
void writeBytes(FASTLED_REGISTER fl::u8 *data, int len)
A full cycle of writing a value for len bytes, including select, release, and waiting.
Definition fastspi_ref.h:61
A skeletal implementation of hardware SPI support.
Definition fastspi_ref.h:19
Abstract class for "selectable" things.
Definition fastpin.h:38
#define FLAG_START_BIT
Flag for the start of an SPI transaction.
#define FASTLED_NAMESPACE_END
Definition namespace.h:23
#define FASTLED_NAMESPACE_BEGIN
Definition namespace.h:22
unsigned char u8
Definition int.h:17
#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:9
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.