100 likes | 359 Views
CS-423 Dick Steflik. AVR32 GPIO. What is a GPIO. GPIO – General Purpose Input/Output Flexible software control digital signal Each GPIO represents a bit connected to a MCU pin or ball (on the BGA) AVR32 GPIO Processor features
E N D
CS-423 Dick Steflik AVR32 GPIO
What is a GPIO • GPIO – General Purpose Input/Output • Flexible software control digital signal • Each GPIO represents a bit connected to a MCU pin or ball (on the BGA) • AVR32 GPIO Processor features • An input change interrupt - Enables level detection on any I/O line • Glitch filtering – reject pulses of < ½ clock cycle • Control of the internal pull-ups on I/O lines • Inout visability and output control
Use of GPIOs • Configuration should be done in the board setup code, once setup can be used from: • User-space • Slow • Mainly used for turning something on/off • Can be used from scripts or C • Kernel-space • Device drivers • Fast
/dev GPIO Interface • Uses the configfs ram based virtual file system • Mounts at /config (already done on NGW100) • mount -t configfs config /config • Exists only for the current boot session • Could be made to be created by running a script at system startup, script would have to create each object • Manipulated by mkdir and rmdir to create and remove objects
/config • NGW100 already has three predefined GPIOs • bootled – GPIO0 • leda – GPIO1 bit 19 • ledb – GPIO2 bit 19 • each GPIO directory has 4 files • gpio_id – which GPIO (0-4) • pin-mask – which pin(s) • oe_mask – output enable mask • enabled – enable the GPIO (0-disable, 1-enable)
/dev • GPIO0 • GPIO1- bit 19 LED A • GPIO2 – bit 19 LED B
Using • Define devices in the shell • Use them from C using C I/O functions read/write/poll • define a file descriptor for the file in /dev • for output write to that file descriptor • for input read from the file descriptor • for waiting on a condition poll the filedescriptor
GPIOs in a module • GPIOs can be done faster and easier by doing from a kernel module (this is similar to what we did with the 2313s)