NOTICE: The Processors Wiki will End-of-Life in December of 2020. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

LED usage on DVEVM

From Texas Instruments Wiki
Jump to: navigation, search

This article describes the usage of the 8 user controlled LEDs on DM6446 DVEVM.

Hardware[edit]

On DM6446 DVEVM there are 8 user controllable LEDs available. These are controlled using I2C device PCF 8574A (I2C address 0x38).

See page 27 of TMS320DM6446 EVM schematic and section 2.4 (page 2-7) of Davinci-DM644x EVM Technical Reference.

Software[edit]

In MontaVisata Linux kernel and recent git kernel device driver to control LEDs is located in

arch/arm/mach-davinci/leds-evm.c

It controls four LEDs:

  • "red" -> DS1
  • "amber" -> DS2
  • "green" -> DS3
  • "blue" -> DS4

Note: Actually, all LEDs on DM6446 DVEVM are green :) But ARMs LED framework defines only these four colors. This seems to be the reason why only four of the 8 possible LEDs are controlled using this framework.

LED at DS8 is defined as "timer LED" and can be controlled by kernel configuration option CONFIG_LEDS_TIMER.

Note: CONFIG_LEDS_TIMER can only be set if CONFIG_GENERIC_CLOCKEVENTS is not set. Therefore this option isn't available in default DM6446 DVEVM git kernel configuration.

Usage[edit]

The 8 user controlled LEDs can be switched by user space software or by device drivers.

User space[edit]

From user space, you can control the four above LEDs via sysfs:

> echo claim > /sys/devices/system/leds/leds0/event
> echo green on > /sys/devices/system/leds/leds0/event
> echo red on > /sys/devices/system/leds/leds0/event
> echo red off > /sys/devices/system/leds/leds0/event
> echo amber on > /sys/devices/system/leds/leds0/event
> echo blue on > /sys/devices/system/leds/leds0/event
> echo release > /sys/devices/system/leds/leds0/event

Note: the release turns off the LED's!

Example program[edit]

/**********************************************************************
* EVM_LED_BLINKING.C  
* Eric Tanner 2007.
*
* Simple program to blink the LEDs on the DaVinci
* EVM using the the LED port expander PCF8574A at I2C Slave Address 0x38.
* I2C Support and I2C device interface must be turned on in the kernel. 
*
**************************************************************************/

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <signal.h>
 
#define I2C_DEVICE      "/dev/i2c/0"
#define I2C_DEV_ADDR    0x38
#define I2C_SLAVE       0x0703

int main()
{
       int i2c_fd;
       int state = 0;
       unsigned char val = 0x00;
       int ret;

       struct timespec req = {
               .tv_sec = 0,
               .tv_nsec = 100000000,
       };

       if((i2c_fd = open(I2C_DEVICE,O_RDWR)) < 0) {
               printf("Unable to open the i2c port!\n");
               exit(1);
       }

       if(ioctl(i2c_fd, I2C_SLAVE, I2C_DEV_ADDR)== -1) {
               close( i2c_fd );
               printf("Unable to setup the i2c port!\n");
               exit(1);
       }

       do {
               val <<= 1;
               val |= 0x01;
               if(val == 0xFF)
                       val = 0xFE;
               write( i2c_fd, &val, 1);

        } while (!nanosleep (&req, NULL));

       close ( i2c_fd );
       printf ("End.\n");
       return 0;
}

Device drivers[edit]

Device drivers can use function call

leds_event(led_{green,amber,red,blue}_{on,off});

including

#include <asm/leds.h>
E2e.jpg {{
  1. switchcategory:MultiCore=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article LED usage on DVEVM here.

Keystone=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article LED usage on DVEVM here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article LED usage on DVEVM here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article LED usage on DVEVM here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article LED usage on DVEVM here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article LED usage on DVEVM here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article LED usage on DVEVM here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article LED usage on DVEVM here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article LED usage on DVEVM here.

}}

Hyperlink blue.png Links

Amplifiers & Linear
Audio
Broadband RF/IF & Digital Radio
Clocks & Timers
Data Converters

DLP & MEMS
High-Reliability
Interface
Logic
Power Management

Processors

Switches & Multiplexers
Temperature Sensors & Control ICs
Wireless Connectivity