mirror of
https://github.com/elua/elua.git
synced 2025-01-08 20:56:17 +08:00
42ff856578
- new addition to the PIO module: now you can use pin ranges in PIO expressions. For example: gpio.PA_3_6_DIR = gpio.OUTPUT -- make pins 3-6 from PORTA outputs gpio.PB_0_30_PULL = gpio.PULLUP -- activate pullups on all but the last pin of PORTB gpio.PB_3_6 = 11 -- set value 10 (1011) to pins 3-6 of PB (so PB.6 == 1, PB.5 == 0, PB.4 == 1, PB.3 == 1 ) value = gpio.PB_2_9 -- read the value of pins 2-9 of PB into 'value' Of course, one can still specify a single pin instead of a range. This is still tested, but seems to work fine for now. - romfs/ samples updated to work with the new module name and syntax - small fix to buf.c (in the BUF_MOD_INCR macro).
20 lines
370 B
Lua
20 lines
370 B
Lua
local gpio = gpio
|
|
|
|
module(...)
|
|
|
|
BTN_UP = "PE_0"
|
|
BTN_DOWN = "PE_1"
|
|
BTN_LEFT = "PE_2"
|
|
BTN_RIGHT = "PE_3"
|
|
BTN_SELECT = "PF_1"
|
|
btnpressed = function( button )
|
|
return ( gpio[ button ] == 0 )
|
|
end
|
|
|
|
LED_1 = "PF_0"
|
|
|
|
gpio.PE_0_3_DIR, gpio.PF_1_DIR = gpio.INPUT, gpio.INPUT
|
|
gpio.PE_0_3_PULL, gpio.PF_1_PULL = gpio.PULLUP, gpio.PULLUP
|
|
gpio.PF_0_DIR = gpio.OUTPUT
|
|
|