# HG changeset patch # User Mychaela Falconia # Date 1446597996 0 # Node ID df1dccc0ef9c599be5f610d3bf9041337540301c # Parent c73516dd50bb1ce772909e54cde914420d8faf8e c139explore: GPIO init and backlight on/off control implemented diff -r c73516dd50bb -r df1dccc0ef9c target-utils/c139explore/Makefile --- a/target-utils/c139explore/Makefile Mon Nov 02 22:11:06 2015 +0000 +++ b/target-utils/c139explore/Makefile Wed Nov 04 00:46:36 2015 +0000 @@ -5,7 +5,7 @@ OBJCOPY=arm-elf-objcopy PROG= c139explore -OBJS= crt0.o cmdtab.o main.o mygetchar.o +OBJS= crt0.o backlight.o cmdtab.o main.o mygetchar.o LIBS= ../libcommon/libcommon.a ../libprintf/libprintf.a LDS= ../env/compalram.lds diff -r c73516dd50bb -r df1dccc0ef9c target-utils/c139explore/backlight.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/target-utils/c139explore/backlight.c Wed Nov 04 00:46:36 2015 +0000 @@ -0,0 +1,42 @@ +#include +#include +#include "types.h" +#include "abbdefs.h" + +#define GPIO_OUT_REG (*(volatile u16 *) 0xfffe4802) +#define BACKLIGHT_GPIO_MASK 0x0002 + +#define AUXLED_KPBL_OFF 0x000 +#define AUXLED_KPBL_ON 0x002 + +void +cmd_dbl(argbulk) + char *argbulk; +{ + char *argv[2]; + + if (parse_args(argbulk, 1, 1, argv, 0) < 0) + return; + if (!strcmp(argv[0], "on")) + GPIO_OUT_REG |= BACKLIGHT_GPIO_MASK; + else if (!strcmp(argv[0], "off")) + GPIO_OUT_REG &= ~BACKLIGHT_GPIO_MASK; + else + printf("ERROR: \"on\" or \"off\" argument expected\n"); +} + +void +cmd_kpbl(argbulk) + char *argbulk; +{ + char *argv[2]; + + if (parse_args(argbulk, 1, 1, argv, 0) < 0) + return; + if (!strcmp(argv[0], "on")) + abb_reg_write(AUXLED, AUXLED_KPBL_ON); + else if (!strcmp(argv[0], "off")) + abb_reg_write(AUXLED, AUXLED_KPBL_OFF); + else + printf("ERROR: \"on\" or \"off\" argument expected\n"); +} diff -r c73516dd50bb -r df1dccc0ef9c target-utils/c139explore/cmdtab.c --- a/target-utils/c139explore/cmdtab.c Mon Nov 02 22:11:06 2015 +0000 +++ b/target-utils/c139explore/cmdtab.c Wed Nov 04 00:46:36 2015 +0000 @@ -2,6 +2,8 @@ extern void cmd_abbr(); extern void cmd_abbw(); +extern void cmd_dbl(); +extern void cmd_kpbl(); extern void cmd_r8(); extern void cmd_r16(); extern void cmd_r32(); @@ -16,6 +18,8 @@ {"abbinit", abb_init}, {"abbr", cmd_abbr}, {"abbw", cmd_abbw}, + {"dbl", cmd_dbl}, + {"kpbl", cmd_kpbl}, {"poweroff", abb_power_off}, {"r8", cmd_r8}, {"r16", cmd_r16}, diff -r c73516dd50bb -r df1dccc0ef9c target-utils/c139explore/main.c --- a/target-utils/c139explore/main.c Mon Nov 02 22:11:06 2015 +0000 +++ b/target-utils/c139explore/main.c Wed Nov 04 00:46:36 2015 +0000 @@ -9,6 +9,10 @@ osmo_delay_ms(30); uart_base = (struct ns16550_regs *) 0xFFFF5800; printf("C139 hardware exploration utility running\n"); + /* GPIO init */ + *(volatile u16 *)0xfffe4802 = 0x0002; + *(volatile u16 *)0xfffe4804 = 0xFFF5; + abb_init(); for (;;) { putchar('='); if (command_entry())