| WRAP Access Server: User's and Developer's Guide | ||
|---|---|---|
| <<< Previous | Next >>> | |
The Bluegiga I/O API defines how to access the Access Server's LEDs, buzzer and general purpose I/O and contains functions to accomplish this.
The I/O API is accessed by using functions, macros, and constants defined in the header file bgio.h. You can use the macros by including the file.
Example:
#include <bgio.h> |
Access Server's LEDs are controlled by using the following macros and functions. You need to add an extra linker flag LDFLAGS = -lbgio to your Makefile when using the LED API.
BGIO_LED returns ledmask for lednum. lednum is the number of LED in the range 0 to BGIO_LED_MAX.
bgio_led_status reads LEDs and returns current ledmask.
bgio_led_set sets LEDs in ledmask ON.
bgio_led_clr sets LEDs in ledmask OFF.
ledmask is a bit mask where bit 0 is LED 0, bit 1 is LED 1, etc..
See asdk/examples/io/led/ for a LED API example.
LEDs and the buzzer can also be accessed via /dev/led. You can check the status of the LEDs and buzzer with cat /dev/led command and set LEDs or buzzer with echo abcde > /dev/led command. A letter in upper case means that the LED or buzzer is ON, lower case means that the LED or buzzer is OFF. Letter "a" is the buzzer, letters "b".."e" are LEDs 1..4.
The Digital I/O pins of the Access Server can be controlled write-only using the device /dev/io in a same way that the LEDs and buzzer described above.
The letter-to-I/O mapping of the 16 pins is as follows, when looking at the connector:
hgfedcba
Xijklmno
|
X is the ground pin (and cannot be set).
o is the voltage sense pin (user can use any voltage from 3.3V to 5.0V).
The I/O must first be enabled by echo Z > /dev/io. After that, pins can be driven up by echoing corresponding upper case letter (A-N) or down by echoing lower case letter (a-n) to the device /dev/io.
Example:
[root@wrap /] modprobe io
[root@wrap /] echo ZaBcD > /dev/io
|
| <<< Previous | Home | Next >>> |
| iWRAP - Bluetooth Interface | Advanced Use Cases for Access Server |