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
d46bc5cc
Commit
d46bc5cc
authored
Oct 26, 2015
by
devsaurus
Browse files
align spi_recv to platform_spi_send_recv
parent
7d773989
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/modules/spi.c
View file @
d46bc5cc
...
@@ -173,11 +173,12 @@ static int spi_send_recv( lua_State *L )
...
@@ -173,11 +173,12 @@ static int spi_send_recv( lua_State *L )
return
spi_generic_send_recv
(
L
,
1
);
return
spi_generic_send_recv
(
L
,
1
);
}
}
// Lua: read = spi.recv( id, size )
// Lua: read = spi.recv( id, size
, [default data]
)
static
int
spi_recv
(
lua_State
*
L
)
static
int
spi_recv
(
lua_State
*
L
)
{
{
int
id
=
luaL_checkinteger
(
L
,
1
);
int
id
=
luaL_checkinteger
(
L
,
1
);
int
size
=
luaL_checkinteger
(
L
,
2
),
i
;
int
size
=
luaL_checkinteger
(
L
,
2
),
i
;
int
def
=
luaL_optinteger
(
L
,
3
,
0xffffffff
);
luaL_Buffer
b
;
luaL_Buffer
b
;
...
@@ -189,10 +190,7 @@ static int spi_recv( lua_State *L )
...
@@ -189,10 +190,7 @@ static int spi_recv( lua_State *L )
luaL_buffinit
(
L
,
&
b
);
luaL_buffinit
(
L
,
&
b
);
for
(
i
=
0
;
i
<
size
;
i
++
)
for
(
i
=
0
;
i
<
size
;
i
++
)
{
{
if
(
PLATFORM_OK
!=
platform_spi_transaction
(
id
,
0
,
0
,
0
,
0
,
0
,
0
,
spi_databits
[
id
]
))
{
luaL_addchar
(
&
b
,
(
char
)
platform_spi_send_recv
(
id
,
spi_databits
[
id
],
def
)
);
return
luaL_error
(
L
,
"failed"
);
}
luaL_addchar
(
&
b
,
(
char
)
platform_spi_get_miso
(
id
,
0
,
spi_databits
[
id
]
)
);
}
}
luaL_pushresult
(
&
b
);
luaL_pushresult
(
&
b
);
...
...
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