2010-02-19 03:01:18 +00:00
|
|
|
-- This auxiliary platform dependent module defines some hardware devices
|
2009-11-02 17:44:35 +00:00
|
|
|
-- available in the specific development kit.
|
|
|
|
-- It will be automatically require()d when eLua detects it is running on the
|
2010-02-19 03:01:18 +00:00
|
|
|
-- respective platform, exposing auxiliary constants and functions to facilitate
|
2009-11-02 17:44:35 +00:00
|
|
|
-- and keep portable the access to the underlying hardware.
|
|
|
|
-- The code configures the MCU to interface with the platform devices and
|
2010-02-19 03:01:18 +00:00
|
|
|
-- exposes the following objects, constants and functions:
|
|
|
|
-- On-board buttons:
|
2009-11-02 17:44:35 +00:00
|
|
|
-- BTN_UP, BTN_DOWN, BTN_LEFT, BTN_RIGHT, BTN_SELECT
|
2010-02-19 03:01:18 +00:00
|
|
|
-- On-board LED:
|
|
|
|
-- LED_1
|
|
|
|
-- On-board LED:
|
|
|
|
-- Auxiliary Function:
|
2009-11-02 17:44:35 +00:00
|
|
|
-- btn_pressed( button )
|
|
|
|
-- returns true if the arg button is pressed, false otherwise
|
|
|
|
|
2009-10-13 02:14:27 +00:00
|
|
|
local pio = pio
|
|
|
|
|
|
|
|
module(...)
|
|
|
|
|
|
|
|
BTN_UP = pio.PE_0
|
|
|
|
BTN_DOWN = pio.PE_1
|
|
|
|
BTN_LEFT = pio.PE_2
|
|
|
|
BTN_RIGHT = pio.PE_3
|
|
|
|
BTN_SELECT = pio.PF_1
|
|
|
|
|
|
|
|
btn_pressed = function( button )
|
|
|
|
return pio.pin.getval( button ) == 0
|
|
|
|
end
|
|
|
|
|
|
|
|
LED_1 = pio.PF_0
|
|
|
|
|
|
|
|
pio.pin.setdir( pio.INPUT, BTN_UP, BTN_DOWN, BTN_LEFT, BTN_RIGHT, BTN_SELECT )
|
|
|
|
pio.pin.setpull( pio.PULLUP, BTN_UP, BTN_DOWN, BTN_LEFT, BTN_RIGHT, BTN_SELECT )
|
|
|
|
pio.pin.setdir( pio.OUTPUT, LED_1 )
|
|
|
|
|