avr Namespace Reference

AVR Access Module. More...


Functions

def portA
def ddrA
def digitalRead
def digitalWrite
def delay


Detailed Description

AVR Access Module.

Provides generic access to the AVR microcontroller

Note that to save RAM when the module is imported, many of the port & ddr methods below are commented out. Uncomment and recompile in order to use!

USAGE

 import avr
 avr.ddrA(0) # Set all pins as input
 a = avr.portA()
 avr.ddrA(0xFF) # Set all pins as output
 avr.portA(42)

 avr.delay(500) # Half second pause

 if avr.digitalRead('A', 3):
   avr.digitalWrite('D', 0, True)


Function Documentation

def avr::ddrA (   a  ) 

__NATIVE__
return _ddrX(&DDRA);

Definition at line 267 of file avr.py.

def avr::delay (   ms  ) 

__NATIVE__
PmReturn_t retval = PM_RET_OK;

if(NATIVE_GET_NUM_ARGS() != 1)
{
  PM_RAISE(retval, PM_RET_EX_TYPE);
  return retval;
}

pPmObj_t pa = NATIVE_GET_LOCAL(0);
if (OBJ_GET_TYPE(pa) == OBJ_TYPE_INT)
{
  _delay_ms((double) ((pPmInt_t)pa)->val);
}
else if (OBJ_GET_TYPE(pa) == OBJ_TYPE_FLT)
{
  _delay_ms((double) ((pPmFloat_t)pa)->val);
}
else
{
  PM_RAISE(retval, PM_RET_EX_TYPE);
}

NATIVE_SET_TOS(PM_NONE);
return retval;

Definition at line 382 of file avr.py.

def avr::digitalRead (   port,
  pin 
)

__NATIVE__
volatile uint8_t *port;
volatile uint8_t *direction;
uint8_t pin;
PmReturn_t retval = PM_RET_OK;

if(NATIVE_GET_NUM_ARGS() != 2)
{
  PM_RAISE(retval, PM_RET_EX_TYPE);
  return retval;
}

retval = _get_port_register(&port, NULL, &direction, &pin);
if(retval != PM_RET_OK)
  return retval;

*direction &= ~(1<<pin); // Set pin to input
pPmObj_t pa = (*port & (1<<pin)) ? PM_TRUE : PM_FALSE;
NATIVE_SET_TOS(pa); // Push our result object onto the stack
return retval;

Definition at line 311 of file avr.py.

def avr::digitalWrite (   port,
  pin,
  value 
)

__NATIVE__
volatile uint8_t *port;
volatile uint8_t *direction;
uint8_t pin;
pPmObj_t pc;
PmReturn_t retval = PM_RET_OK;

NATIVE_SET_TOS(PM_NONE);

if(NATIVE_GET_NUM_ARGS() != 3)
{
  PM_RAISE(retval, PM_RET_EX_TYPE);
  return retval;
}

retval = _get_port_register(NULL, &port, &direction, &pin);
if(retval != PM_RET_OK)
  return retval;

pc = NATIVE_GET_LOCAL(2);

/* If the arg is not an integer, raise TypeError */
if (OBJ_GET_TYPE(pc) != OBJ_TYPE_INT && OBJ_GET_TYPE(pc) != OBJ_TYPE_BOOL)
{
  PM_RAISE(retval, PM_RET_EX_TYPE);
  return retval;
}

*direction |= (1<<pin); // Set pin to output

if(((pPmInt_t)pc)->val)
  *port |= 1<<pin;
else
  *port &= ~(1<<pin);
return retval;

Definition at line 342 of file avr.py.

def avr::portA (   a  ) 

__NATIVE__
return _portX(&PORTA, &DDRA, &PINA);

Definition at line 231 of file avr.py.


Generated on Mon Oct 18 07:40:49 2010 for Python-on-a-chip by  doxygen 1.5.9