FreeCalypso > hg > freecalypso-sw
changeset 949:df1dccc0ef9c
c139explore: GPIO init and backlight on/off control implemented
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Wed, 04 Nov 2015 00:46:36 +0000 |
parents | c73516dd50bb |
children | cd34e0d534b9 |
files | target-utils/c139explore/Makefile target-utils/c139explore/backlight.c target-utils/c139explore/cmdtab.c target-utils/c139explore/main.c |
diffstat | 4 files changed, 51 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- /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 <sys/types.h> +#include <string.h> +#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"); +}
--- 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},
--- 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())