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.

What's the exact address of AM1808's LED

Other Parts Discussed in Thread: AM1808, TCA6416

Hi, I'm conducting some experiments with my AM1808 development board. And I want to blink it's LED. So I read some example codes provided. But these examples all use the GPIO. and I found that I2C_ADDR_GPIO_EX (0x0021) maybe the address of GPIO related to LED. But how can I get it's exact address. Because I don't know the GPIO technology, so I don't want to use it.Thanks

  • QIANXUN,

    I am assuming that you are working with the EVM or the experimenter kit as your development platform. If you look at the schematics of the platform the LED is connected to an I2C controlled GPIO IO expander (TCA6416) whose slave address is 0x0021 that you found in the code so if you want to control the LED you need to send commands to this slave device using that address and then set the appropriate GPIO signal to the LED. The simplest example that shows this functionality is the I2C example that is provided in starterware(non-OS hardwaware abstraction software).

    I2C example for LED blink:

    http://processors.wiki.ti.com/index.php/StarterWare_01.10.01.01_User_Guide#I2C

    Hope this helps ....let us know if there are follow up questions.

    Regards,

    Rahul

  • Hi, thanks for your last reply. And it do helps me. But I'm a newer in embeded system programming, and our teacher ask us to blink LED by using exact LED address, he also told me that we will use I2C in the furture but not now. The attached code is provided by him. And I think I should get this address to conduct this experiment. Please help me with it, or told me how to change these code.

    Thank you!

    #include <linux/ioport.h>
    #include <asm/uaccess.h> // 문제가 있을 경우 asm-arm으로 변경
    #include <linux/module.h>
    #include <linux/fs.h>
    #include <asm/io.h> // 문제가 있을 경우 asm-arm으로 변경
    // 문제가 있을 경우 linux/init.h, linux/version.h 추가
    #define LED_MAJOR 239
    #define LED_NAME "LED"
    #define LED_MODULE_VERSION "LED IO PORT V0.1"
    #define LED_ADDRESS 0x12400000 // 0x0c000016 으로 고칠 것
    #define LED_CS (*((volatile unsigned char *)(mem_base)))
    
    static void *mem_base;
    unsigned long mem_addr, mem_len;
    
    static int led_clear(void) {
    	LED_CS = 0xFF;
    	return 0;
    }
    
    int led_open(struct inode *minode, struct file *mfile)
    {
    	return 0;
    }
    
    int led_release(struct inode *minode, struct file *mfile)
    {
    	return 0;
    }
    
    ssize_t led_write_byte(struct file *inode, const char *gdata, size_t length, loff_t *off_what)
    {
    	unsigned char c;
    	get_user(c, (unsigned char *)gdata);
    	LED_CS = c; // 문제가 있을 경우 outw(c, LED_CS); 로 변경
    	return length;
    }
    
    static struct file_operations led_fops = {
    	.owner = THIS_MODULE,
    	.write = led_write_byte,
    	.open = led_open,
    	.release = led_release,
    };
    
    int led_init(void)
    {
    	int result;
    	result = register_chrdev(LED_MAJOR, LED_NAME, &led_fops);
    	if(result < 0) {
    		printk(KERN_WARNING "can't get any major number.\n");
    		return result;
    	}
    	mem_addr = LED_ADDRESS;
    	mem_len = 0x1000;
    	mem_base = ioremap_nocache(mem_addr, mem_len);
    	if( !mem_base) {
    		printk("Error mapping LED memory\n");
    		release_mem_region(mem_addr, mem_len);
    		return -EBUSY;
    	}
    	printk("init module, LED major number : %d\n", LED_MAJOR);
    	return 0;
    }
    
    void led_exit(void)
    {
    	led_clear();
    	if (unregister_chrdev(LED_MAJOR, LED_NAME))
    		printk(KERN_WARNING"%s driver cleanup failed.\n", LED_NAME);
    	iounmap(mem_base);
    }
    
    MODULE_LICENSE("GPL");
    module_init(led_init);
    module_exit(led_exit);
    

    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    
    int main(int argc, char **argv)
    {
    	int dev;
    	char buff;
    
    	if(argc <= 1) {
    		printf("please input the parameter! ex)./test 0xa1\n");
    		return -1;
    	}
    
    	dev = open("/dev/LED", O_WRONLY);
    	if (dev != -1) {
    		if(argv[1][0] == '0' && (argv[1][1] == 'x' || argv[1][1] == 'X'))
    			buff = (unsigned char)strtol(&argv[1][2], NULL, 16);
    		else
    			buff = atoi(argv[1]);
    		write(dev, &buff, 1);
    		close(dev);
    	}
    	else {
    		printf( "Device Open ERROR!\n");
    		exit(-1);
    	}
    
    	return(0);
    }