Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
e3eed26d
Commit
e3eed26d
authored
Aug 26, 2021
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stm32/boards/LEGO_HUB_NO6: Change SPI flash storage to use hardware SPI.
Signed-off-by:
Damien George
<
damien@micropython.org
>
parent
6936f410
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
15 deletions
+20
-15
ports/stm32/boards/LEGO_HUB_NO6/bdev.c
ports/stm32/boards/LEGO_HUB_NO6/bdev.c
+12
-11
ports/stm32/boards/LEGO_HUB_NO6/mpconfigboard.h
ports/stm32/boards/LEGO_HUB_NO6/mpconfigboard.h
+8
-4
No files found.
ports/stm32/boards/LEGO_HUB_NO6/bdev.c
View file @
e3eed26d
...
...
@@ -26,25 +26,26 @@
#include "py/obj.h"
#include "storage.h"
#include "spi.h"
#define CMD_EXIT_4_BYTE_ADDRESS_MODE (0xE9)
STATIC
const
mp_soft_spi_obj_t
soft_spi_bus
=
{
.
delay_half
=
MICROPY_HW_SOFTSPI_MIN_DELAY
,
STATIC
const
spi_proto_cfg_t
spi_bus
=
{
.
spi
=
&
spi_obj
[
1
],
// SPI2 hardware peripheral
.
baudrate
=
25000000
,
.
polarity
=
0
,
.
phase
=
0
,
.
sck
=
MICROPY_HW_SPIFLASH_SCK
,
.
mosi
=
MICROPY_HW_SPIFLASH_MOSI
,
.
miso
=
MICROPY_HW_SPIFLASH_MISO
,
.
bits
=
8
,
.
firstbit
=
SPI_FIRSTBIT_MSB
,
};
STATIC
mp_spiflash_cache_t
spi_bdev_cache
;
const
mp_spiflash_config_t
spiflash_config
=
{
.
bus_kind
=
MP_SPIFLASH_BUS_SPI
,
.
bus
.
u_spi
.
cs
=
MICROPY_HW_SPIFLASH_
NS
S
,
.
bus
.
u_spi
.
data
=
(
void
*
)
&
s
oft_s
pi_bus
,
.
bus
.
u_spi
.
proto
=
&
mp_soft_
spi_proto
,
.
bus
.
u_spi
.
cs
=
MICROPY_HW_SPIFLASH_
C
S
,
.
bus
.
u_spi
.
data
=
(
void
*
)
&
spi_bus
,
.
bus
.
u_spi
.
proto
=
&
spi_proto
,
.
cache
=
&
spi_bdev_cache
,
};
...
...
@@ -55,9 +56,9 @@ int32_t board_bdev_ioctl(void) {
// Exit 4-byte address mode
uint8_t
cmd
=
CMD_EXIT_4_BYTE_ADDRESS_MODE
;
mp_hal_pin_write
(
MICROPY_HW_SPIFLASH_
NS
S
,
0
);
mp_soft_spi_proto
.
transfer
(
MP_OBJ_FROM_PTR
(
&
soft_
spi_bus
),
1
,
&
cmd
,
NULL
);
mp_hal_pin_write
(
MICROPY_HW_SPIFLASH_
NS
S
,
1
);
mp_hal_pin_write
(
MICROPY_HW_SPIFLASH_
C
S
,
0
);
spi_proto
.
transfer
(
MP_OBJ_FROM_PTR
(
&
spi_bus
),
1
,
&
cmd
,
NULL
);
mp_hal_pin_write
(
MICROPY_HW_SPIFLASH_
C
S
,
1
);
return
ret
;
}
ports/stm32/boards/LEGO_HUB_NO6/mpconfigboard.h
View file @
e3eed26d
...
...
@@ -61,6 +61,10 @@
#define MICROPY_HW_SPI1_SCK (pin_A5) // shared with DAC
#define MICROPY_HW_SPI1_MISO (pin_A6)
#define MICROPY_HW_SPI1_MOSI (pin_A7)
#define MICROPY_HW_SPI2_NSS (pin_B12)
#define MICROPY_HW_SPI2_SCK (pin_B13)
#define MICROPY_HW_SPI2_MISO (pin_C2)
#define MICROPY_HW_SPI2_MOSI (pin_C3)
// USB config
#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)
...
...
@@ -76,10 +80,10 @@
// SPI flash, for R/W storage
#define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1)
#define MICROPY_HW_SPIFLASH_SIZE_BITS (256 * 1024 * 1024)
#define MICROPY_HW_SPIFLASH_
NSS (pin_B12
)
#define MICROPY_HW_SPIFLASH_SCK (
pin_B13
)
#define MICROPY_HW_SPIFLASH_MISO (
pin_C2
)
#define MICROPY_HW_SPIFLASH_MOSI (
pin_C3
)
#define MICROPY_HW_SPIFLASH_
CS (MICROPY_HW_SPI2_NSS
)
#define MICROPY_HW_SPIFLASH_SCK (
MICROPY_HW_SPI2_SCK
)
#define MICROPY_HW_SPIFLASH_MISO (
MICROPY_HW_SPI2_MISO
)
#define MICROPY_HW_SPIFLASH_MOSI (
MICROPY_HW_SPI2_MOSI
)
// SPI flash, block device config
extern
int32_t
board_bdev_ioctl
(
void
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment