blob: d59f2c750e66655bd3bc59354a9f4301cf7cc943 [file] [log] [blame]
Damien Georgebc08c882016-12-06 12:20:10 +11001/*
2 * This file is part of the MicroPython project, http://micropython.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2017 "Eric Poulsen" <eric@zyxod.com>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26
27#include <stdio.h>
28#include <stdint.h>
29#include <string.h>
30
31#include "py/runtime.h"
32#include "py/stream.h"
33#include "py/mphal.h"
34#include "extmod/machine_spi.h"
35#include "modmachine.h"
36
37#include "driver/spi_master.h"
38
Damien Georgeb24fcd72021-03-11 13:32:00 +110039// Default pins for SPI(1), can be overridden by a board
40#ifndef MICROPY_HW_SPI1_SCK
41#define MICROPY_HW_SPI1_SCK (14)
42#define MICROPY_HW_SPI1_MOSI (13)
43#define MICROPY_HW_SPI1_MISO (12)
44#endif
45
46// Default pins for SPI(2), can be overridden by a board
47#ifndef MICROPY_HW_SPI2_SCK
48#define MICROPY_HW_SPI2_SCK (18)
49#define MICROPY_HW_SPI2_MOSI (23)
50#define MICROPY_HW_SPI2_MISO (19)
51#endif
52
Eric Poulsen9123c8d2017-11-28 18:48:30 -080053#define MP_HW_SPI_MAX_XFER_BYTES (4092)
54#define MP_HW_SPI_MAX_XFER_BITS (MP_HW_SPI_MAX_XFER_BYTES * 8) // Has to be an even multiple of 8
55
Damien Georgeb24fcd72021-03-11 13:32:00 +110056typedef struct _machine_hw_spi_default_pins_t {
57 int8_t sck;
58 int8_t mosi;
59 int8_t miso;
60} machine_hw_spi_default_pins_t;
61
Damien Georgebc08c882016-12-06 12:20:10 +110062typedef struct _machine_hw_spi_obj_t {
63 mp_obj_base_t base;
64 spi_host_device_t host;
65 uint32_t baudrate;
66 uint8_t polarity;
67 uint8_t phase;
68 uint8_t bits;
69 uint8_t firstbit;
70 int8_t sck;
71 int8_t mosi;
72 int8_t miso;
73 spi_device_handle_t spi;
74 enum {
75 MACHINE_HW_SPI_STATE_NONE,
76 MACHINE_HW_SPI_STATE_INIT,
77 MACHINE_HW_SPI_STATE_DEINIT
78 } state;
79} machine_hw_spi_obj_t;
80
Damien Georgeb24fcd72021-03-11 13:32:00 +110081// Default pin mappings for the hardware SPI instances
82STATIC const machine_hw_spi_default_pins_t machine_hw_spi_default_pins[2] = {
83 { .sck = MICROPY_HW_SPI1_SCK, .mosi = MICROPY_HW_SPI1_MOSI, .miso = MICROPY_HW_SPI1_MISO },
84 { .sck = MICROPY_HW_SPI2_SCK, .mosi = MICROPY_HW_SPI2_MOSI, .miso = MICROPY_HW_SPI2_MISO },
85};
86
Damien Georgeda72bb62019-01-23 23:47:36 +110087// Static objects mapping to HSPI and VSPI hardware peripherals
88STATIC machine_hw_spi_obj_t machine_hw_spi_obj[2];
89
Damien Georgebc08c882016-12-06 12:20:10 +110090STATIC void machine_hw_spi_deinit_internal(machine_hw_spi_obj_t *self) {
91 switch (spi_bus_remove_device(self->spi)) {
92 case ESP_ERR_INVALID_ARG:
Jim Mussareddef76fe2020-03-02 22:35:22 +110093 mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("invalid configuration"));
Damien Georgebc08c882016-12-06 12:20:10 +110094 return;
95
96 case ESP_ERR_INVALID_STATE:
Jim Mussareddef76fe2020-03-02 22:35:22 +110097 mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("SPI device already freed"));
Damien Georgebc08c882016-12-06 12:20:10 +110098 return;
99 }
100
101 switch (spi_bus_free(self->host)) {
102 case ESP_ERR_INVALID_ARG:
Jim Mussareddef76fe2020-03-02 22:35:22 +1100103 mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("invalid configuration"));
Damien Georgebc08c882016-12-06 12:20:10 +1100104 return;
105
106 case ESP_ERR_INVALID_STATE:
Jim Mussareddef76fe2020-03-02 22:35:22 +1100107 mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("SPI bus already freed"));
Damien Georgebc08c882016-12-06 12:20:10 +1100108 return;
109 }
110
111 int8_t pins[3] = {self->miso, self->mosi, self->sck};
112
113 for (int i = 0; i < 3; i++) {
114 if (pins[i] != -1) {
115 gpio_pad_select_gpio(pins[i]);
116 gpio_matrix_out(pins[i], SIG_GPIO_OUT_IDX, false, false);
117 gpio_set_direction(pins[i], GPIO_MODE_INPUT);
118 }
119 }
120}
121
122STATIC void machine_hw_spi_init_internal(
Damien George69661f32020-02-27 15:36:53 +1100123 machine_hw_spi_obj_t *self,
124 int8_t host,
125 int32_t baudrate,
126 int8_t polarity,
127 int8_t phase,
128 int8_t bits,
129 int8_t firstbit,
130 int8_t sck,
131 int8_t mosi,
132 int8_t miso) {
Damien Georgebc08c882016-12-06 12:20:10 +1100133
134 // if we're not initialized, then we're
135 // implicitly 'changed', since this is the init routine
136 bool changed = self->state != MACHINE_HW_SPI_STATE_INIT;
137
138 esp_err_t ret;
139
140 machine_hw_spi_obj_t old_self = *self;
141
142 if (host != -1 && host != self->host) {
143 self->host = host;
144 changed = true;
145 }
146
147 if (baudrate != -1 && baudrate != self->baudrate) {
148 self->baudrate = baudrate;
149 changed = true;
150 }
151
152 if (polarity != -1 && polarity != self->polarity) {
153 self->polarity = polarity;
154 changed = true;
155 }
156
157 if (phase != -1 && phase != self->phase) {
Damien George69661f32020-02-27 15:36:53 +1100158 self->phase = phase;
Damien Georgebc08c882016-12-06 12:20:10 +1100159 changed = true;
160 }
161
162 if (bits != -1 && bits != self->bits) {
163 self->bits = bits;
164 changed = true;
165 }
166
167 if (firstbit != -1 && firstbit != self->firstbit) {
168 self->firstbit = firstbit;
169 changed = true;
170 }
171
172 if (sck != -2 && sck != self->sck) {
173 self->sck = sck;
174 changed = true;
175 }
176
177 if (mosi != -2 && mosi != self->mosi) {
178 self->mosi = mosi;
179 changed = true;
180 }
181
182 if (miso != -2 && miso != self->miso) {
183 self->miso = miso;
184 changed = true;
185 }
186
187 if (self->host != HSPI_HOST && self->host != VSPI_HOST) {
Jim Mussareddef76fe2020-03-02 22:35:22 +1100188 mp_raise_ValueError(MP_ERROR_TEXT("SPI ID must be either HSPI(1) or VSPI(2)"));
Damien Georgebc08c882016-12-06 12:20:10 +1100189 }
190
191 if (changed) {
192 if (self->state == MACHINE_HW_SPI_STATE_INIT) {
193 self->state = MACHINE_HW_SPI_STATE_DEINIT;
194 machine_hw_spi_deinit_internal(&old_self);
195 }
196 } else {
197 return; // no changes
198 }
199
200 spi_bus_config_t buscfg = {
201 .miso_io_num = self->miso,
202 .mosi_io_num = self->mosi,
203 .sclk_io_num = self->sck,
204 .quadwp_io_num = -1,
205 .quadhd_io_num = -1
206 };
207
208 spi_device_interface_config_t devcfg = {
209 .clock_speed_hz = self->baudrate,
210 .mode = self->phase | (self->polarity << 1),
211 .spics_io_num = -1, // No CS pin
212 .queue_size = 1,
213 .flags = self->firstbit == MICROPY_PY_MACHINE_SPI_LSB ? SPI_DEVICE_TXBIT_LSBFIRST | SPI_DEVICE_RXBIT_LSBFIRST : 0,
214 .pre_cb = NULL
215 };
216
stijn84fa3312020-04-16 09:13:57 +0200217 // Initialize the SPI bus
Damien Georgebc08c882016-12-06 12:20:10 +1100218
Damien Georged82f3442019-01-23 23:40:06 +1100219 // Select DMA channel based on the hardware SPI host
220 int dma_chan = 0;
221 if (self->host == HSPI_HOST) {
222 dma_chan = 1;
223 } else if (self->host == VSPI_HOST) {
224 dma_chan = 2;
225 }
226
227 ret = spi_bus_initialize(self->host, &buscfg, dma_chan);
Damien Georgebc08c882016-12-06 12:20:10 +1100228 switch (ret) {
229 case ESP_ERR_INVALID_ARG:
Jim Mussareddef76fe2020-03-02 22:35:22 +1100230 mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("invalid configuration"));
Damien Georgebc08c882016-12-06 12:20:10 +1100231 return;
232
233 case ESP_ERR_INVALID_STATE:
Jim Mussareddef76fe2020-03-02 22:35:22 +1100234 mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("SPI host already in use"));
Damien Georgebc08c882016-12-06 12:20:10 +1100235 return;
236 }
237
238 ret = spi_bus_add_device(self->host, &devcfg, &self->spi);
239 switch (ret) {
240 case ESP_ERR_INVALID_ARG:
Jim Mussareddef76fe2020-03-02 22:35:22 +1100241 mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("invalid configuration"));
Damien Georgebc08c882016-12-06 12:20:10 +1100242 spi_bus_free(self->host);
243 return;
244
245 case ESP_ERR_NO_MEM:
Jim Mussareddef76fe2020-03-02 22:35:22 +1100246 mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("out of memory"));
Damien Georgebc08c882016-12-06 12:20:10 +1100247 spi_bus_free(self->host);
248 return;
249
250 case ESP_ERR_NOT_FOUND:
Jim Mussareddef76fe2020-03-02 22:35:22 +1100251 mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("no free slots"));
Damien Georgebc08c882016-12-06 12:20:10 +1100252 spi_bus_free(self->host);
253 return;
254 }
255 self->state = MACHINE_HW_SPI_STATE_INIT;
256}
257
258STATIC void machine_hw_spi_deinit(mp_obj_base_t *self_in) {
Damien George1a3e3862020-03-27 00:35:04 +1100259 machine_hw_spi_obj_t *self = (machine_hw_spi_obj_t *)self_in;
Damien Georgebc08c882016-12-06 12:20:10 +1100260 if (self->state == MACHINE_HW_SPI_STATE_INIT) {
261 self->state = MACHINE_HW_SPI_STATE_DEINIT;
262 machine_hw_spi_deinit_internal(self);
263 }
264}
265
266STATIC void machine_hw_spi_transfer(mp_obj_base_t *self_in, size_t len, const uint8_t *src, uint8_t *dest) {
267 machine_hw_spi_obj_t *self = MP_OBJ_TO_PTR(self_in);
268
Damien Georgebc08c882016-12-06 12:20:10 +1100269 if (self->state == MACHINE_HW_SPI_STATE_DEINIT) {
Jim Mussareddef76fe2020-03-02 22:35:22 +1100270 mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("transfer on deinitialized SPI"));
Damien Georgebc08c882016-12-06 12:20:10 +1100271 return;
272 }
273
Eric Poulsen9123c8d2017-11-28 18:48:30 -0800274 struct spi_transaction_t transaction = { 0 };
Damien Georgebc08c882016-12-06 12:20:10 +1100275
Eric Poulsen9123c8d2017-11-28 18:48:30 -0800276 // Round to nearest whole set of bits
277 int bits_to_send = len * 8 / self->bits * self->bits;
278
279
280 if (len <= 4) {
Damien Georgebc08c882016-12-06 12:20:10 +1100281 if (src != NULL) {
282 memcpy(&transaction.tx_data, src, len);
283 }
Eric Poulsen9123c8d2017-11-28 18:48:30 -0800284
285 transaction.flags = SPI_TRANS_USE_TXDATA | SPI_TRANS_USE_RXDATA;
286 transaction.length = bits_to_send;
287 spi_device_transmit(self->spi, &transaction);
288
289 if (dest != NULL) {
290 memcpy(dest, &transaction.rx_data, len);
291 }
Damien Georgebc08c882016-12-06 12:20:10 +1100292 } else {
Eric Poulsen9123c8d2017-11-28 18:48:30 -0800293 int offset = 0;
294 int bits_remaining = bits_to_send;
Damien Georgebc08c882016-12-06 12:20:10 +1100295
Eric Poulsen9123c8d2017-11-28 18:48:30 -0800296 while (bits_remaining) {
297 memset(&transaction, 0, sizeof(transaction));
Damien Georgebc08c882016-12-06 12:20:10 +1100298
Eric Poulsen9123c8d2017-11-28 18:48:30 -0800299 transaction.length =
300 bits_remaining > MP_HW_SPI_MAX_XFER_BITS ? MP_HW_SPI_MAX_XFER_BITS : bits_remaining;
301
302 if (src != NULL) {
303 transaction.tx_buffer = src + offset;
304 }
305 if (dest != NULL) {
306 transaction.rx_buffer = dest + offset;
307 }
308
309 spi_device_transmit(self->spi, &transaction);
310 bits_remaining -= transaction.length;
311
312 // doesn't need ceil(); loop ends when bits_remaining is 0
313 offset += transaction.length / 8;
314 }
Damien Georgebc08c882016-12-06 12:20:10 +1100315 }
316}
317
318/******************************************************************************/
319// MicroPython bindings for hw_spi
320
321STATIC void machine_hw_spi_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
322 machine_hw_spi_obj_t *self = MP_OBJ_TO_PTR(self_in);
323 mp_printf(print, "SPI(id=%u, baudrate=%u, polarity=%u, phase=%u, bits=%u, firstbit=%u, sck=%d, mosi=%d, miso=%d)",
Damien George69661f32020-02-27 15:36:53 +1100324 self->host, self->baudrate, self->polarity,
325 self->phase, self->bits, self->firstbit,
326 self->sck, self->mosi, self->miso);
Damien Georgebc08c882016-12-06 12:20:10 +1100327}
328
329STATIC void machine_hw_spi_init(mp_obj_base_t *self_in, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
Damien George1a3e3862020-03-27 00:35:04 +1100330 machine_hw_spi_obj_t *self = (machine_hw_spi_obj_t *)self_in;
Damien Georgebc08c882016-12-06 12:20:10 +1100331
332 enum { ARG_id, ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits, ARG_firstbit, ARG_sck, ARG_mosi, ARG_miso };
333 static const mp_arg_t allowed_args[] = {
Damien Georged1fd8892017-12-18 15:46:08 +1100334 { MP_QSTR_id, MP_ARG_INT, {.u_int = -1} },
Damien Georgebc08c882016-12-06 12:20:10 +1100335 { MP_QSTR_baudrate, MP_ARG_INT, {.u_int = -1} },
336 { MP_QSTR_polarity, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -1} },
337 { MP_QSTR_phase, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -1} },
338 { MP_QSTR_bits, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -1} },
339 { MP_QSTR_firstbit, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -1} },
340 { MP_QSTR_sck, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
341 { MP_QSTR_mosi, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
342 { MP_QSTR_miso, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
343 };
344
345 mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
346 mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args),
Damien George69661f32020-02-27 15:36:53 +1100347 allowed_args, args);
Damien Georgebc08c882016-12-06 12:20:10 +1100348 int8_t sck, mosi, miso;
349
350 if (args[ARG_sck].u_obj == MP_OBJ_NULL) {
351 sck = -2;
352 } else if (args[ARG_sck].u_obj == mp_const_none) {
353 sck = -1;
354 } else {
355 sck = machine_pin_get_id(args[ARG_sck].u_obj);
356 }
357
358 if (args[ARG_miso].u_obj == MP_OBJ_NULL) {
359 miso = -2;
360 } else if (args[ARG_miso].u_obj == mp_const_none) {
361 miso = -1;
362 } else {
363 miso = machine_pin_get_id(args[ARG_miso].u_obj);
364 }
365
366 if (args[ARG_mosi].u_obj == MP_OBJ_NULL) {
367 mosi = -2;
368 } else if (args[ARG_mosi].u_obj == mp_const_none) {
369 mosi = -1;
370 } else {
371 mosi = machine_pin_get_id(args[ARG_mosi].u_obj);
372 }
373
374 machine_hw_spi_init_internal(self, args[ARG_id].u_int, args[ARG_baudrate].u_int,
Damien George69661f32020-02-27 15:36:53 +1100375 args[ARG_polarity].u_int, args[ARG_phase].u_int, args[ARG_bits].u_int,
376 args[ARG_firstbit].u_int, sck, mosi, miso);
Damien Georgebc08c882016-12-06 12:20:10 +1100377}
378
379mp_obj_t machine_hw_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
Damien George71f3ade2020-09-25 14:47:34 +1000380 MP_MACHINE_SPI_CHECK_FOR_LEGACY_SOFTSPI_CONSTRUCTION(n_args, n_kw, all_args);
381
Damien Georgebc08c882016-12-06 12:20:10 +1100382 enum { ARG_id, ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits, ARG_firstbit, ARG_sck, ARG_mosi, ARG_miso };
383 static const mp_arg_t allowed_args[] = {
Damien Georged1fd8892017-12-18 15:46:08 +1100384 { MP_QSTR_id, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = -1} },
Damien Georgebc08c882016-12-06 12:20:10 +1100385 { MP_QSTR_baudrate, MP_ARG_INT, {.u_int = 500000} },
386 { MP_QSTR_polarity, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
387 { MP_QSTR_phase, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
388 { MP_QSTR_bits, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 8} },
389 { MP_QSTR_firstbit, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = MICROPY_PY_MACHINE_SPI_MSB} },
390 { MP_QSTR_sck, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
391 { MP_QSTR_mosi, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
392 { MP_QSTR_miso, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
393 };
394 mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
395 mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
396
Damien Georgeda72bb62019-01-23 23:47:36 +1100397 machine_hw_spi_obj_t *self;
Damien Georgeb24fcd72021-03-11 13:32:00 +1100398 const machine_hw_spi_default_pins_t *default_pins;
Damien Georgeda72bb62019-01-23 23:47:36 +1100399 if (args[ARG_id].u_int == HSPI_HOST) {
400 self = &machine_hw_spi_obj[0];
Damien Georgeb24fcd72021-03-11 13:32:00 +1100401 default_pins = &machine_hw_spi_default_pins[0];
Damien Georgeda72bb62019-01-23 23:47:36 +1100402 } else {
403 self = &machine_hw_spi_obj[1];
Damien Georgeb24fcd72021-03-11 13:32:00 +1100404 default_pins = &machine_hw_spi_default_pins[1];
Damien Georgeda72bb62019-01-23 23:47:36 +1100405 }
Damien Georgebc08c882016-12-06 12:20:10 +1100406 self->base.type = &machine_hw_spi_type;
407
408 machine_hw_spi_init_internal(
409 self,
410 args[ARG_id].u_int,
411 args[ARG_baudrate].u_int,
412 args[ARG_polarity].u_int,
413 args[ARG_phase].u_int,
414 args[ARG_bits].u_int,
415 args[ARG_firstbit].u_int,
Damien Georgeb24fcd72021-03-11 13:32:00 +1100416 args[ARG_sck].u_obj == MP_OBJ_NULL ? default_pins->sck : machine_pin_get_id(args[ARG_sck].u_obj),
417 args[ARG_mosi].u_obj == MP_OBJ_NULL ? default_pins->mosi : machine_pin_get_id(args[ARG_mosi].u_obj),
418 args[ARG_miso].u_obj == MP_OBJ_NULL ? default_pins->miso : machine_pin_get_id(args[ARG_miso].u_obj));
Damien Georgebc08c882016-12-06 12:20:10 +1100419
420 return MP_OBJ_FROM_PTR(self);
421}
422
423STATIC const mp_machine_spi_p_t machine_hw_spi_p = {
424 .init = machine_hw_spi_init,
425 .deinit = machine_hw_spi_deinit,
426 .transfer = machine_hw_spi_transfer,
427};
428
429const mp_obj_type_t machine_hw_spi_type = {
430 { &mp_type_type },
431 .name = MP_QSTR_SPI,
432 .print = machine_hw_spi_print,
433 .make_new = machine_hw_spi_make_new,
434 .protocol = &machine_hw_spi_p,
Damien George1a3e3862020-03-27 00:35:04 +1100435 .locals_dict = (mp_obj_dict_t *)&mp_machine_spi_locals_dict,
Damien Georgebc08c882016-12-06 12:20:10 +1100436};