mirror of
https://github.com/elua/elua.git
synced 2025-01-08 20:56:17 +08:00
pio.port.setval bugfix (thanks, Teo! :))
This commit is contained in:
parent
fd2379c07e
commit
42ec61613b
@ -8,6 +8,11 @@
|
||||
|
||||
#include "platform_conf.h"
|
||||
|
||||
// The maximum 32 GPIO ports limitation is given by the port_mask variable in src/modules/pio.c
|
||||
#if NUM_PIO > 32
|
||||
#error "Can't have more than 32 GPIO ports"
|
||||
#endif
|
||||
|
||||
// Can't define more than one console devices
|
||||
#if defined( BUILD_CON_TCP ) && defined( BUILD_CON_GENERIC )
|
||||
#error "Can't have two console devices (don't enable BUILD_CON_TCP and BUILD_CON_GENERIC in platform_conf.h at the same time)"
|
||||
|
@ -68,9 +68,8 @@ static int pioh_set_ports( lua_State* L, int stackidx, int op, pio_type mask )
|
||||
{
|
||||
int total = lua_gettop( L );
|
||||
int i, v, port;
|
||||
|
||||
pioh_clear_masks();
|
||||
|
||||
u32 port_mask = 0;
|
||||
|
||||
// Get all masks
|
||||
for( i = stackidx; i <= total; i ++ )
|
||||
{
|
||||
@ -78,13 +77,13 @@ static int pioh_set_ports( lua_State* L, int stackidx, int op, pio_type mask )
|
||||
port = PLATFORM_IO_GET_PORT( v );
|
||||
if( !PLATFORM_IO_IS_PORT( v ) || !platform_pio_has_port( port ) )
|
||||
return luaL_error( L, "invalid port" );
|
||||
pio_masks[ port ] = mask;
|
||||
port_mask |= ( 1ULL << port );
|
||||
}
|
||||
|
||||
// Ask platform to execute the given operation
|
||||
for( i = 0; i < PLATFORM_IO_PORTS; i ++ )
|
||||
if( pio_masks[ i ] )
|
||||
if( !platform_pio_op( i, pio_masks[ i ], op ) )
|
||||
if( port_mask & ( 1ULL << i ) )
|
||||
if( !platform_pio_op( i, mask, op ) )
|
||||
return luaL_error( L, "invalid PIO operation" );
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user