This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Example code to press a button on the DM355 Eval board?

Hi,

I want to be able to press one of the buttons on the Dm355 Eval board to give me notification of a quit to my software, so that I can shut down all the threads and exit gracefully.

My understanding is that the buttons are all controlled via I2C, is there some sample code that I can look at that shows me how to capture the button value?  Is this interrupt based?

Thanks in advance

  • You are correct that some push buttons on the EM are user readable via I2C bus: see technical reference manual for more details (http://c6000.spectrumdigital.com/evmdm355/revd/files/EVMDM355_TechRef_RevD.pdf)

    Unfortunately, we do not have any sample source code to provide, but it should be pretty trivial to read push button values via i2c.  To get interrupt is a bit tougher, since I do not believe this mechanism is built-in to MSP430 firmware (what is actually reading push butting value and passing it along i2c bus).  If you were to design your own hardware board, you can use one of the GPIO pins to connect to push button and register for GPIO interrupt.

  •  

    Hi,

    So I am attempting to simple access the LED's for now, isnce they are on the same I2C Bus, the code below, doesnt have any errors, and it finds the I2C bus but the LED's dont turn off.  What am I doing incorrect?

    Thanks in advance.

     

     

    #include <unistd.h>
    #include <stdio.h>
    #include <fcntl.h>
    #include <sys/ioctl.h>
    #include <asm/types.h>
    #include <linux/videodev2.h>

    #include "../include/gpioCap.h"

    #include <linux/i2c.h>
    #include <linux/i2c-dev.h>


    #define I2C_DEVICE         "/dev/i2c/0"
    #define I2C_DEV_ADDR     0x25

    static int gpioHandle = -1;

    int gpioInit( ) {
        int i = 0;
        printf( "GPIO Initialization\n" );

        if ( ( gpioHandle = open(I2C_DEVICE, O_RDWR) ) < 0 ) {
            printf( "An error opening the I2C\n" );
        }

        if ( ioctl( gpioHandle, I2C_SLAVE, I2C_DEV_ADDR ) == -1 ) {
              printf("Failed to set I2C_SLAVE to %#x\n", I2C_DEV_ADDR);
              return 0;
        }

        char buf[10];

        buf[0] = 0x90;
        buf[1] = 0x00;
        buf[2] = 0x00;

        write( gpioHandle, buf, 3);

        usleep( 1000 );

        return 1;
    }