127 128 129 void application() { using namespace hal::literals; 25 26 222 namespace hal::lpc40 { class spi: public hal:: spi 27 { 130 28 public: 131 hal::cortex_m:: dwt_counter steady_clock( 29 132 p_cpu_frequency: hal::lpc40::get_frequency (p_peripheral: hal::lpc40:: peripheral::cpu 30 /// Information used to configure the spi bus struct bus_info 133 31 { 134 std::array uart_buffer{}; 32 135 hal::lpc40::uart uart0(0, uart_buffer); 33 /// peripheral id used to power on the spi peripheral at creation peripheral peripheral_id; 136 34 /// spi data pin 137 hal::lpc40::spi spi2(2); 35 pin clock; 138 hal::lpc40::output_pin chip_select(1, 10); 36 /// spi clock pin 139 hal::lpc40::output_pin chip_select_mirror(1, 14); 37 pin data_out; 140 chip_select. level(true); 38 /// spi clock pin 141 39 pin data_in; 142 hal::print(uarto, "Starting SPI Application...\n"); 40 /// clock function code 143 41 std::uint8_t clock_function; 144 while (true) { 42 145 using namespace std:: literals; 43 146 147 std::array payload{ 0xDE, 0xAD, 0xBE, 0xEF }; std::array buffer{}; 44 45 /// scl pin function code std::uint8_t data_out_function; /// scl pin function code std::uint8_t data_in_function; 148 46 }; 149 hal:: print(uart0, "Write operation\n"); 47 150 151 152 153 154 155 156 157 hal::write(spi2, payload); hal::delay(steady_clock, 1s); hal::print(uarto, "Read operation: [ "); hal::read(spi2, buffer); for (const auto& byte : buffer) { hal::print<32>(uart0, "0x%02x", byte); 48 /** 49 * @brief Construct a new spi object 50 * 51 * @param p_bus - bus number to use 52 * @param p_settings - spi settings to achieve 53 * @throws hal::operation_not_supported - if the p_bus is not 0, 1, or 2 or if 54 * the spi settings could not be achieved. 55 */ 158 } 56 spi(std::uint8_t p_bus, const spi::settings& p_settings = = {}); 159 57 ** 160 161 162 163 164 165 166 167 hal::print(uarto, "]\n"); hal::delay(steady_clock, 1s); hal::print(uartØ, "Full-duplex transfer\n"); spi2.transfer (payload, buffer); hal::delay(steady_clock, 1s); hal:: print(uarto, "Half-duplex transfer\n"); 58 * @brief Construct a new spi object using bus info directly 59 * 60 * @param p_bus - Full bus information 61 62 spi(bus_info p_bus); 63 64 spi(spi& p_other) = delete; 65 spi& operator= (spi& p_other) = delete; 168 169 hal::write_then_read(spi2, payload, buffer); hal::delay(steady_clock, 1s); 66 spi(spi&& p_other) noexcept = delete; 67 170 68 spi& operator= (spi&& p_other) noexcept = delete; ~spi(); 171 { 69 172 173 std::array read_manufacturer_id{ hal::byte{ 0x9F } }; std::array id_data{}; 70 private: 71 174 72 175 chip_select.level(false); 73 void driver_configure(const settings & p_settings) override; void driver_transfer(std::span p_data_out, std::span p_data_in, www www 176 bal delay(steady clock 250ns).

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

In firmware development if I wanted to develop a driver for the SSD1331, what is the thought process in reading the datasheet? As in what things should I look for in the data sheet? How do I also correspond to what registers on the SSD1331 display with the registers on the board, and what if that board does not have a DC register? What are other ways of analyzing if they have a DC pin but its not called DC?

Can you simplify a clear detailed explanation of how I would use SPI to interact with SSD1331 if there are multiple buses that SPI can read from?

Reference to the example image. Using this open-source framework that has a SPI driver.

127
128
129
void application()
{
using namespace hal::literals;
25
26
222
namespace hal::lpc40 {
class spi: public hal:: spi
27
{
130
28
public:
131
hal::cortex_m:: dwt_counter steady_clock(
29
132
p_cpu_frequency: hal::lpc40::get_frequency (p_peripheral: hal::lpc40:: peripheral::cpu
30
/// Information used to configure the spi bus
struct bus_info
133
31
{
134
std::array<hal:: byte, 32> uart_buffer{};
32
135
hal::lpc40::uart uart0(0, uart_buffer);
33
/// peripheral id used to power on the spi peripheral at creation
peripheral peripheral_id;
136
34
/// spi data pin
137
hal::lpc40::spi spi2(2);
35
pin clock;
138
hal::lpc40::output_pin chip_select(1, 10);
36
/// spi clock pin
139
hal::lpc40::output_pin chip_select_mirror(1, 14);
37
pin data_out;
140
chip_select. level(true);
38
/// spi clock pin
141
39
pin data_in;
142
hal::print(uarto, "Starting SPI Application...\n");
40
/// clock function code
143
41
std::uint8_t clock_function;
144
while (true) {
42
145
using namespace std:: literals;
43
146
147
std::array<hal::byte, 4> payload{ 0xDE, 0xAD, 0xBE, 0xEF };
std::array<hal::byte, 8> buffer{};
44
45
/// scl pin function code
std::uint8_t data_out_function;
/// scl pin function code
std::uint8_t data_in_function;
148
46
};
149
hal:: print(uart0, "Write operation\n");
47
150
151
152
153
154
155
156
157
hal::write(spi2, payload);
hal::delay(steady_clock, 1s);
hal::print(uarto, "Read operation: [ ");
hal::read(spi2, buffer);
for (const auto& byte : buffer) {
hal::print<32>(uart0, "0x%02x", byte);
48
/**
49
* @brief Construct a new spi object
50
*
51
* @param p_bus - bus number to use
52
* @param p_settings - spi settings to achieve
53
* @throws hal::operation_not_supported - if the p_bus is not 0, 1, or 2 or if
54
* the spi settings could not be achieved.
55
*/
158
}
56
spi(std::uint8_t p_bus, const spi::settings& p_settings =
=
{});
159
57
**
160
161
162
163
164
165
166
167
hal::print(uarto, "]\n");
hal::delay(steady_clock, 1s);
hal::print(uartØ, "Full-duplex transfer\n");
spi2.transfer (payload, buffer);
hal::delay(steady_clock, 1s);
hal:: print(uarto, "Half-duplex transfer\n");
58
* @brief Construct a new spi object using bus info directly
59
*
60
* @param p_bus
-
Full bus information
61
62
spi(bus_info p_bus);
63
64
spi(spi& p_other) = delete;
65
spi& operator= (spi& p_other)
= delete;
168
169
hal::write_then_read(spi2, payload, buffer);
hal::delay(steady_clock, 1s);
66
spi(spi&& p_other) noexcept = delete;
67
170
68
spi& operator= (spi&& p_other) noexcept = delete;
~spi();
171
{
69
172
173
std::array read_manufacturer_id{ hal::byte{ 0x9F } };
std::array<hal::byte, 4> id_data{};
70
private:
71
174
72
175
chip_select.level(false);
73
void driver_configure(const settings & p_settings) override;
void driver_transfer(std::span<const hal::byte> p_data_out,
std::span<hal::byte> p_data_in,
www
www
176
bal delay(steady clock 250ns).
Transcribed Image Text:127 128 129 void application() { using namespace hal::literals; 25 26 222 namespace hal::lpc40 { class spi: public hal:: spi 27 { 130 28 public: 131 hal::cortex_m:: dwt_counter steady_clock( 29 132 p_cpu_frequency: hal::lpc40::get_frequency (p_peripheral: hal::lpc40:: peripheral::cpu 30 /// Information used to configure the spi bus struct bus_info 133 31 { 134 std::array<hal:: byte, 32> uart_buffer{}; 32 135 hal::lpc40::uart uart0(0, uart_buffer); 33 /// peripheral id used to power on the spi peripheral at creation peripheral peripheral_id; 136 34 /// spi data pin 137 hal::lpc40::spi spi2(2); 35 pin clock; 138 hal::lpc40::output_pin chip_select(1, 10); 36 /// spi clock pin 139 hal::lpc40::output_pin chip_select_mirror(1, 14); 37 pin data_out; 140 chip_select. level(true); 38 /// spi clock pin 141 39 pin data_in; 142 hal::print(uarto, "Starting SPI Application...\n"); 40 /// clock function code 143 41 std::uint8_t clock_function; 144 while (true) { 42 145 using namespace std:: literals; 43 146 147 std::array<hal::byte, 4> payload{ 0xDE, 0xAD, 0xBE, 0xEF }; std::array<hal::byte, 8> buffer{}; 44 45 /// scl pin function code std::uint8_t data_out_function; /// scl pin function code std::uint8_t data_in_function; 148 46 }; 149 hal:: print(uart0, "Write operation\n"); 47 150 151 152 153 154 155 156 157 hal::write(spi2, payload); hal::delay(steady_clock, 1s); hal::print(uarto, "Read operation: [ "); hal::read(spi2, buffer); for (const auto& byte : buffer) { hal::print<32>(uart0, "0x%02x", byte); 48 /** 49 * @brief Construct a new spi object 50 * 51 * @param p_bus - bus number to use 52 * @param p_settings - spi settings to achieve 53 * @throws hal::operation_not_supported - if the p_bus is not 0, 1, or 2 or if 54 * the spi settings could not be achieved. 55 */ 158 } 56 spi(std::uint8_t p_bus, const spi::settings& p_settings = = {}); 159 57 ** 160 161 162 163 164 165 166 167 hal::print(uarto, "]\n"); hal::delay(steady_clock, 1s); hal::print(uartØ, "Full-duplex transfer\n"); spi2.transfer (payload, buffer); hal::delay(steady_clock, 1s); hal:: print(uarto, "Half-duplex transfer\n"); 58 * @brief Construct a new spi object using bus info directly 59 * 60 * @param p_bus - Full bus information 61 62 spi(bus_info p_bus); 63 64 spi(spi& p_other) = delete; 65 spi& operator= (spi& p_other) = delete; 168 169 hal::write_then_read(spi2, payload, buffer); hal::delay(steady_clock, 1s); 66 spi(spi&& p_other) noexcept = delete; 67 170 68 spi& operator= (spi&& p_other) noexcept = delete; ~spi(); 171 { 69 172 173 std::array read_manufacturer_id{ hal::byte{ 0x9F } }; std::array<hal::byte, 4> id_data{}; 70 private: 71 174 72 175 chip_select.level(false); 73 void driver_configure(const settings & p_settings) override; void driver_transfer(std::span<const hal::byte> p_data_out, std::span<hal::byte> p_data_in, www www 176 bal delay(steady clock 250ns).
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY