Low-Level Software

Controlling pins on the AVR

Pins are controlled through three registers: DDRx, PORTx, and PINx, where x is A-F (though the AVR seems to have only B, D, E, F, and G). Each port has eight pins, corresponding to the eight bits of the registers. DDRx is the data direction register; 0 means a pin is input, 1 means output. Output values are written to the PORTx registers, 0 for low and 1 for high. For input pins a 1 in its PORTx register enables an internal pull-up resistor. Current pin values, whether input or output, can be read from the PINx registers. The registers and lots of macros are defined in <avr/io.h>. There is a handy macro _BV(x) defined as (1 << x) for writing to a specific bit, and there are also macros for each bit (eg, PF6 = PORTF6 = PINF6 = 6 = DDE6).

Sample code:

#include <avr/io.h>

int main() {
  DDRB = _BV(DDB4) | _BV(DDB5); // set the 4th and 5th pins of port B to output, and the rest input
  PORTB = 0;
  while (1) {
    if (PINB & _BV(PINB3)) // if 3rd pin of port B is high,
      PORTB |= _BV(PB4); // set 4th pin to high for some reason, and leave it that way forever
  }
  return 0;
}

Controlling GPIO on ARM9 Gumstix board

Pin Setup

The Texas Instruments OMAP3503 Processor Chip controls the GPIO available through the two 70-pin connectors on the bottom of the Gumstix. However, just because the GPIO pins are connected to solder pads on the bottom of the OMAP processor doesn't mean they actually do GPIO. The OMAP processor is capable of assigning something like six different functions (!) to each of the pins on it, so these have to be set to GPIO mode. Hopefully, these have already been set properly by the bootloader (U-Boot).

Details

http://www.jumpnowtek.com/index.php?option=com_content&view=article&id=54&Itemid=60
Instead of using shell tools (echo, cat), you should in your C++/C Ros driver open the file with fopen or the C++ equivalent, then write to the file and read from it. Calling shell functions from your C program is just DUMB.

Controlling PWM on ARM9 Gumstix board

Pin Setup

All the same issues as GPIO pin setup.

Details

http://www.jumpnowtek.com/index.php?option=com_content&view=article&id=56&Itemid=63
You REALLY want to use the kernel module, otherwise stuff gets complicated quick. This means Jeff Cooper has to give me a gumstix to play with to build a new kernel for PWM. But we haven't coordinated this yet.
Instead of using shell tools (echo, cat), you should in your C++/C Ros driver open the file with fopen or the C++ equivalent, then write to the file and read from it. Calling shell functions from your C program is just DUMB.

Caveats for Gumstix pin configuration

If I recall correctly, some GPIO and/or PWM is connected to the power management chip on the gumstix (the smaller IC next to the sd card reader). I don't know how to get to these since I've never had to. If you do...Ask me! (Alexander Lam, finger me on the unix servers)

Using rosserial

rosserial is a ROS module that allows ROS modules on one machine to communicate transparently over a serial link. There are also client libraries that allow the creation of ROS nodes on embedded architectures. We intend to use this to create ROS nodes on the AVR that can communicate with those on the Gumstix. This section may expand as research continues, but for now, here are some links:
  • Main ROS wiki page
  • Page for rosserial_python, the node that will run on the Gumstix side of the connection
  • Tutorials for setting up rosserial to communicate with rosserial_arduino, the main embedded client library. These should give you an idea of what the platform is capable of and how it is used.
  • Tutorials for porting rosserial_client to another AVR platform. This is what we will need to do for Scout, and porting rosserial_client to our microcontroller is our first order of business on this front.
  • Serial message format documentation for the curious

scout-avr.png - reference for what is connected to each pin (33.7 KB) Thomas Mullins, 02/07/2012 10:23 pm

gumstix-overo-pinout.png - reference for what is connected to each pin on gumstix (69.3 KB) Alexander Lam, 02/08/2012 09:57 pm

Also available in: HTML TXT