Commit d46bc5cc authored by devsaurus's avatar devsaurus
Browse files

align spi_recv to platform_spi_send_recv

parent 7d773989
...@@ -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 );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment