mirror of
https://github.com/elua/elua.git
synced 2025-01-25 01:02:54 +08:00
45285ea064
- complete rewrite of the PIO module. New usage: pio.PA = 10 -- set the value of PA to 10 pio.PB_1 = 1 -- set the value of pin 1 of PB to 1 local value = pio.PB -- get the value of PB local value = pio.PB_3 -- get the value of pin 3 of PB pio.PA_DIR = pio.OUTPUT/pio.INPUT - set the direction of PA pio.dir[ pio.PA ] = pio.OUTPUT/pio.INPUT - same as above pio.PA_2_DIR = pio.OUTPUT/pio.INPUT - set the direction of pin 2 of PA pio.dir[ pio.PA_2 ] = pio.OUTPUT/pio.INPUT - same as above pio.PA_PULL = pio.PULLUP/pio.PULLDOWN/pio.NOPULL - set pulls on PA pio.pull[ pio.PA ] = pio.PULLUP/pio.PULLDOWN/pio.NOPULL - same as above pio.P0_3_PULL = pio.PULLUP/pio.PULLDOWN/pio.NOPULL - set pulls on pin 3 of P0 pio.pull[ pio.P0_3 ] = pio.PULLUP/pio.PULLDOWN/pio.NOPULL - same as above - samples modified to use the new PIO syntax - bugfix in AT91SAM7X256 UART int handler - fixed yet another bug in AVR32's libc (actually replaced strcmp (which is broken on AVR32) with a custom version).
22 lines
593 B
Lua
22 lines
593 B
Lua
local pio = pio
|
|
|
|
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 ( pio[ button ] == 0 )
|
|
end
|
|
|
|
LED_1 = pio.PF_0
|
|
|
|
pio.dir[ BTN_UP ], pio.dir[ BTN_DOWN ], pio.dir[ BTN_LEFT ], pio.dir[ BTN_RIGHT ], pio.dir[ BTN_SELECT ] =
|
|
pio.INPUT, pio.INPUT, pio.INPUT, pio.INPUT, pio.INPUT
|
|
pio.pull[ BTN_UP ], pio.pull[ BTN_DOWN ], pio.pull[ BTN_LEFT ], pio.pull[ BTN_RIGHT ], pio.pull[ BTN_SELECT ] =
|
|
pio.PULLUP, pio.PULLUP, pio.PULLUP, pio.PULLUP, pio.PULLUP
|
|
pio.dir[ LED_1 ] = pio.OUTPUT
|
|
|