AsDevices

From ArmadeusWiki
Revision as of 14:42, 9 August 2010 by FabienM (Talk | contribs) (Using library in C)

Jump to: navigation, search

Page under construction... Construction.png 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".

Note Note: This library is under development, see the Development planning. to know which fonctionnality is finnished.


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.


Using library in C

All functions in AsDevices library are constructed on the same way. An as_*_open() function return a device structure or an int that represent the device used. All function take this device structure in first parameter, and a function as_*_close() close the device :

struct as_devicename_dev * as_devicename_open(<some parameters>);

as_devicename_do-something-with-device(struct as_devicename_dev *aDev, <some parameters>);

int as_devicename_close(struct as_devicename_dev *aDev);

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, not fully tested NOK NOK NOK NOK Drive SPI
gpio Ok NOK In progress In progress NOK Drive GPIO
max1027 Ok for SLOW mode NOK NOK NOK NOK Drive Analog to Digital chip MAX1027
max5821 OK NOK NOK NOK NOK Drive Digital to Analog chip MAX5821
93LCxx OK NOK NOK NOK NOK EEPROM memory on SPI.
PWM OK NOK NOK NOK NOK