Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
e5892a72
Unverified
Commit
e5892a72
authored
Jan 27, 2022
by
Philip Gladstone
Committed by
GitHub
Jan 27, 2022
Browse files
Give the SPI module a chance of working... (#3496)
parent
8f9295b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
components/modules/spi_master.c
View file @
e5892a72
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include "lextra.h"
#include "lextra.h"
#include "driver/spi_master.h"
#include "driver/spi_master.h"
#include "driver/gpio.h"
#include "esp_heap_caps.h"
#include "esp_heap_caps.h"
#include "esp_log.h"
#include "esp_log.h"
...
@@ -107,6 +108,7 @@ static int lspi_device_transfer( lua_State *L )
...
@@ -107,6 +108,7 @@ static int lspi_device_transfer( lua_State *L )
//
//
lua_getfield
(
L
,
stack
,
"mode"
);
lua_getfield
(
L
,
stack
,
"mode"
);
trans
.
flags
|=
options_flags
[
luaL_checkoption
(
L
,
-
1
,
options
[
0
],
options
)
];
trans
.
flags
|=
options_flags
[
luaL_checkoption
(
L
,
-
1
,
options
[
0
],
options
)
];
lua_pop
(
L
,
1
);
//
//
data_len
=
0
;
data_len
=
0
;
data
=
opt_checklstring
(
L
,
"txdata"
,
""
,
&
data_len
);
data
=
opt_checklstring
(
L
,
"txdata"
,
""
,
&
data_len
);
...
@@ -296,6 +298,19 @@ static int lspi_host_device( lua_State *L )
...
@@ -296,6 +298,19 @@ static int lspi_host_device( lua_State *L )
CONFIG_DEVICE_FROM_BOOL_FIELD
(
halfduplex
,
SPI_DEVICE_HALFDUPLEX
);
CONFIG_DEVICE_FROM_BOOL_FIELD
(
halfduplex
,
SPI_DEVICE_HALFDUPLEX
);
CONFIG_DEVICE_FROM_BOOL_FIELD
(
clk_as_cs
,
SPI_DEVICE_CLK_AS_CS
);
CONFIG_DEVICE_FROM_BOOL_FIELD
(
clk_as_cs
,
SPI_DEVICE_CLK_AS_CS
);
lua_settop
(
L
,
stack
);
lua_settop
(
L
,
stack
);
//
if
(
config
.
spics_io_num
>=
0
)
{
// Configure the gpio
gpio_config_t
cfg
;
memset
(
&
cfg
,
0
,
sizeof
(
cfg
));
cfg
.
mode
=
GPIO_MODE_OUTPUT
;
cfg
.
pin_bit_mask
=
1ULL
<<
config
.
spics_io_num
;
if
(
!
no_err
(
gpio_config
(
&
cfg
))
||
!
no_err
(
gpio_set_level
(
config
.
spics_io_num
,
(
config
.
flags
&
SPI_DEVICE_POSITIVE_CS
)
?
0
:
1
)))
{
return
luaL_error
(
L
,
"failed to configure gpio"
);
}
}
//
//
// fill remaining config entries
// fill remaining config entries
config
.
queue_size
=
1
;
config
.
queue_size
=
1
;
...
...
docs/modules/spi.md
View file @
e5892a72
...
@@ -147,8 +147,8 @@ device:transfer(txdata)
...
@@ -147,8 +147,8 @@ device:transfer(txdata)
#### Parameters
#### Parameters
`trans`
table containing the elements of the transaction:
`trans`
table containing the elements of the transaction:
-
`c
omman
d`
data for command phase, amount of bits was defined during device creation, optional
-
`c
m
d`
data for command phase, amount of bits was defined during device creation, optional
-
`addr
ess
`
data for address phase, amount of bits was defined during device creation, optional
-
`addr`
data for address phase, amount of bits was defined during device creation, optional
-
`txdata`
string of data to be sent to the device, optional
-
`txdata`
string of data to be sent to the device, optional
-
`rxlen`
number of bytes to be received, optional
-
`rxlen`
number of bytes to be received, optional
-
`mode`
optional, one of
-
`mode`
optional, one of
...
...
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