AsDevices
Page under construction... Informations on this page are not guaranteed !!
AsDevices is an ARMadeus specific library that simplify APF-board devices usage for developers. This library is written to be used with C, C++, Python, LUA, (Java?) languages. The core is written in C and other languages support is done with "wrappers".
Contents
Install AsDevices on target
The library is included in Buildroot menu, to use it just select it in «make menuconfig» :
Package Selection for the target ---> *** Armadeus specific packages *** Armadeus specific tools/utilities ---> [*] as_devices [*] wrapper C++ [*] wrapper Python
The base library is in C, to use it with C++ or Python, select the wrapper you want.
Use library in an application
In C
To use AsDevices library in a C program, include the header of the device needed (all C headers are under ${ARMADEUS_PATH}/target/package/as_devices/c/ directory ). For example with gpio :
#include "as_gpio.h"
And compile with following command :
arm-linux-gcc prog.c ${ARMADEUS_PATH}/buildroot/build_arm5vt/as_devices-1.0/c/libas_devices.so -o prog -I${ARMADEUS_PATH}/buildroot/build_arm5vt/as_devices-1.0/c/
An example of code can be found in ${ARMADEUS_PATH}/target/package/as_devices/ directory, take a look of test_c.h and main.c.
In C++
To use AsDevices library in a C++ program, include the header of the class needed (all C++ headers are under ${ARMADEUS_PATH}/target/package/as_devices/cpp/ directory). For example with apf27 pwm :
#include "as_apf27_pwm.hpp"
And compile with following command :
${CXX} ${CFLAGS} prog.cpp ${C_LIB} ${CPP_LIB} -I${C_INCLUDE} -I${CPP_INCLUDE} -o prog
An example of code canbe found in ${ARMADEUS_PATH}/target/package/as_devices/ directory, take a look at test_cpp.h and main.c.
In Python
To use AsDevices library with python, select the Python wrapper in menuconfig then, on platform, import the module :
>>> import AsDevices
All python classes available in the module can be found with the dir() function :
>>> dir(AsDevices)
['Apf27Pwm', 'Apf27PwmError', 'NUMBER_OF_PWM', '__author__', '__builtins__', '__doc__', '__file__', '__name__', '__path__', '__versionTime__', '__version__', 'wrappers']
In LUA
TODO
Devices supported by library
I²C
SPI
To use as_spi_* function, the kernel module spidev is required. See SPI page to know how to configure it.
Once the special file /dev/spidevx.x is available in the kernel, as_spi library can be used including the header as_spi.h in your C source code :
#include "as_spi.h"
Full description of the API can be found in this header, available on sourceforge repository. Functions are not all implemented, if TODO in comment it needed to be done.
The three mains usefull functions used to communicate with a slave SPI device are :
int as_spi_open(const unsigned char *aSpidev_name);
To open the /dev/spidevx.x special spi file. This function return a file handler that will be used for all othes as_spi_* function.
void as_spi_close(int aFd);
As its name said, to close the device.
uint32_t as_spi_msg(int aFd,
uint32_t aMsg,
size_t aLen,
uint32_t aSpeed);
This function forge spi messages on MOSI pin and return MISO message.
GPIO
MAX1027
DS1374
MAX5821
93LCXX
PWM
AD5258
Development planning
AsDevices is not finished, following table indicates the remaining work:
Name | C functions | C++ wrapper | Python wrapper | Python class | LUA wrapper | description |
---|---|---|---|---|---|---|
i2c | Ok | NOK | NOK | NOK | compile | Drive I2C |
spi | Ok | NOK | NOK | NOK | NOK | Drive SPI |
gpio | Ok | NOK | In progress | In progress | NOK | Drive GPIO |
max1027 | in progress | NOK | NOK | NOK | NOK | Drive Analog to Digital chip MAX1027 |
ds1374 | NOK | NOK | NOK | NOK | NOK | Drive RTC chip DS1374 |
max5821 | NOK | NOK | NOK | NOK | NOK | Drive Digital to Analog chip MAX5821 |
93LCxx | OK | NOK | NOK | NOK | NOK | EEPROM memory on SPI. |
pwm | NOK | NOK | NOK | NOK | NOK | - align="center" |
ad5258 | NOK | NOK | NOK | NOK | NOK | Drive Digital potentiometer AD5258 |