Beispiel #1
0
def run():
  clkoutcfg_reg = 0x400FC1C8
  
  PinCfg = PINSEL_CFG_Type()
  PinCfg.Portnum = 1
  PinCfg.Pinnum = 27
  PinCfg.Pinmode = 0
  PinCfg.OpenDrain = 0
  PinCfg.Funcnum = 1
  PINSEL_ConfigPin(PinCfg.ptr)
  
  print "Possible clock output frequencies:"
  for i in range(1, 17):
    print "%2d) %.2fMHz" % (i, 120.0/float(i))
  user_clkout_sel = raw_input("Enter your selection: ")
  
  try:
    clkout_sel = int(user_clkout_sel)
    if clkout_sel < 1 or clkout_sel > 16:
      raise InputError  
  except:
    print "error: invalid input"
    clkout_sel = 1
  
  clkoutcfg_val = deref(clkoutcfg_reg, 4)
  clkoutcfg_val &= 0xFFFFFF0F
  clkoutcfg_val += ((clkout_sel - 1) << 4)
  deref(clkoutcfg_reg, 4, clkoutcfg_val)
  
  print "You should now see a %.2fMHz square wave on P1_27" % (120.0/float(clkout_sel))
  
  while True:
    time.sleep(1)
Beispiel #2
0
def run():
  # control the LED manually
  heartbeatOff()
  pinMode(LED, OUTPUT)
  
  # setup EINT0 on pin 2.10
  PinCfg = PINSEL_CFG_Type()
  PinCfg.Funcnum = 1
  PinCfg.OpenDrain = 0
  PinCfg.Pinmode = 0
  PinCfg.Pinnum = 10
  PinCfg.Portnum = 2
  PINSEL_ConfigPin(PinCfg.ptr)
  EXTI_Init()
  
  # register the callback
  registerCallback(IRQn_Type.EINT0_IRQn, EINT0Callback)
  
  # enable EINT0
  NVIC_EnableIRQ(IRQn_Type.EINT0_IRQn)
  
  # the callback does everything from here
  while True:
  	sleep(1)
Beispiel #3
0
    """Callback function for EINT0.
	"""
    while not digitalRead(BTN):
        sleep(0)
    print "%s don't touch that!" % choice(responses)
    state = digitalRead(LED)
    digitalWrite(LED, state ^ 1)
    EXTI_ClearEXTIFlag(0)


# control the LED manually
heartbeatOff()
pinMode(LED, OUTPUT)

# setup EINT0 on pin 2.10
PinCfg = PINSEL_CFG_Type()
PinCfg.Funcnum = 1
PinCfg.OpenDrain = 0
PinCfg.Pinmode = 0
PinCfg.Pinnum = 10
PinCfg.Portnum = 2
PINSEL_ConfigPin(PinCfg.ptr)
EXTI_Init()

# register the callback
registerCallback(IRQn_Type.EINT0_IRQn, EINT0Callback)

# enable EINT0
NVIC_EnableIRQ(IRQn_Type.EINT0_IRQn)

# the callback does everything from here
Beispiel #4
0
"""Outputs a fraction fo the core system clock on P1_27
"""

from robovero.lpc17xx_pinsel import PINSEL_CFG_Type, PINSEL_ConfigPin
from robovero.internals import deref

__author__ =      "Neil MacMunn"
__email__ =       "*****@*****.**"
__copyright__ =   "Copyright 2011, Gumstix Inc"
__license__ =     "BSD 2-Clause"
__version__ =     "0.1"

clkoutcfg_reg = 0x400FC1C8

PinCfg = PINSEL_CFG_Type()
PinCfg.Portnum = 1
PinCfg.Pinnum = 27
PinCfg.Pinmode = 0
PinCfg.OpenDrain = 0
PinCfg.Funcnum = 1
PINSEL_ConfigPin(PinCfg.ptr)

print "Possible clock output frequencies:"
for i in range(1, 17):
  print "%2d) %.2fMHz" % (i, 120.0/float(i))
user_clkout_sel = raw_input("Enter your selection: ")

try:
  clkout_sel = int(user_clkout_sel)
  if clkout_sel < 1 or clkout_sel > 16:
    raise InputError