aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--board/trab/Makefile18
-rw-r--r--board/trab/rs485.c203
-rw-r--r--board/trab/rs485.h37
-rw-r--r--board/trab/trab_fkt.c1093
-rw-r--r--board/trab/tsc2000.c18
-rw-r--r--board/trab/tsc2000.h18
-rw-r--r--examples/Makefile5
-rw-r--r--include/_exports.h2
-rw-r--r--include/exports.h2
10 files changed, 1376 insertions, 25 deletions
diff --git a/Makefile b/Makefile
index 300f37e0d60..f0d17dd17f0 100644
--- a/Makefile
+++ b/Makefile
@@ -76,6 +76,7 @@ export CROSS_COMPILE
# The "tools" are needed early, so put this first
SUBDIRS = tools \
+ examples \
lib_generic \
lib_$(ARCH) \
cpu/$(CPU) \
@@ -89,8 +90,7 @@ SUBDIRS = tools \
drivers \
drivers/sk98lin \
post \
- post/cpu \
- examples
+ post/cpu
#########################################################################
# U-Boot objects....order is important (i.e. start must be first)
@@ -921,6 +921,7 @@ clean:
rm -f tools/gdb/astest tools/gdb/gdbcont tools/gdb/gdbsend
rm -f tools/env/fw_printenv tools/env/fw_setenv
rm -f board/cray/L1/bootscript.c board/cray/L1/bootscript.image
+ rm -f board/trab/trab_fkt
clobber: clean
find . -type f \
diff --git a/board/trab/Makefile b/board/trab/Makefile
index 08a1dbc1786..f3767716865 100644
--- a/board/trab/Makefile
+++ b/board/trab/Makefile
@@ -28,9 +28,27 @@ LIB = lib$(BOARD).a
OBJS := trab.o flash.o vfd.o cmd_trab.o memory.o tsc2000.o
SOBJS := memsetup.o
+gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
+
+LOAD_ADDR = 0xc100000
+
+#########################################################################
+
+all: $(LIB) trab_fkt.srec trab_fkt.bin
+
$(LIB): $(OBJS) $(SOBJS)
$(AR) crv $@ $(OBJS) $(SOBJS)
+trab_fkt.srec: trab_fkt.o rs485.o tsc2000.o $(LIB)
+ $(LD) -g -Ttext $(LOAD_ADDR) -o $(<:.o=) -e $(<:.o=) $^ $(LIB) \
+ -L../../examples -lstubs \
+ -L../../lib_generic -lgeneric \
+ -L$(gcclibdir) -lgcc
+ $(OBJCOPY) -O srec $(<:.o=) $@
+
+trab_fkt.bin: trab_fkt.srec
+ $(OBJCOPY) -O binary $< $@ 2>/dev/null
+
clean:
rm -f $(SOBJS) $(OBJS)
diff --git a/board/trab/rs485.c b/board/trab/rs485.c
new file mode 100644
index 00000000000..774fd59a49a
--- /dev/null
+++ b/board/trab/rs485.c
@@ -0,0 +1,203 @@
+/*
+ * (C) Copyright 2003
+ * Martin Krause, TQ-Systems GmbH, <martin.krause@tqs.de>
+ *
+ * Based on cpu/arm920t/serial.c, by Gary Jennejohn
+ * (C) Copyright 2002 Gary Jennejohn, DENX Software Engineering, <gj@denx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <common.h>
+#include <s3c2400.h>
+#include "rs485.h"
+
+static void rs485_setbrg (void);
+static void rs485_cfgio (void);
+static void set_rs485re(unsigned char rs485re_state);
+static void set_rs485de(unsigned char rs485de_state);
+static void rs485_setbrg (void);
+#ifdef NOT_USED
+static void trab_rs485_disable_tx(void);
+static void trab_rs485_disable_rx(void);
+#endif
+
+#define UART_NR S3C24X0_UART1
+
+/* CPLD-Register for controlling TRAB hardware functions */
+#define CPLD_RS485_RE ((volatile unsigned long *)0x04028000)
+
+static void rs485_setbrg (void)
+{
+ S3C24X0_UART * const uart = S3C24X0_GetBase_UART(UART_NR);
+ int i;
+ unsigned int reg = 0;
+
+ /* value is calculated so : (int)(PCLK/16./baudrate) -1 */
+ /* reg = (33000000 / (16 * gd->baudrate)) - 1; */
+ reg = (33000000 / (16 * 38.400)) - 1;
+
+ /* FIFO enable, Tx/Rx FIFO clear */
+ uart->UFCON = 0x07;
+ uart->UMCON = 0x0;
+ /* Normal,No parity,1 stop,8 bit */
+ uart->ULCON = 0x3;
+ /*
+ * tx=level,rx=edge,disable timeout int.,enable rx error int.,
+ * normal,interrupt or polling
+ */
+ uart->UCON = 0x245;
+ uart->UBRDIV = reg;
+
+ for (i = 0; i < 100; i++);
+}
+
+static void rs485_cfgio (void)
+{
+ S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+
+ gpio->PFCON &= ~(0x3 << 2);
+ gpio->PFCON |= (0x2 << 2); /* configure GPF1 as RXD1 */
+
+ gpio->PFCON &= ~(0x3 << 6);
+ gpio->PFCON |= (0x2 << 6); /* configure GPF3 as TXD1 */
+
+ gpio->PFUP |= (1 << 1); /* disable pullup on GPF1 */
+ gpio->PFUP |= (1 << 3); /* disable pullup on GPF3 */
+
+ gpio->PACON &= ~(1 << 11); /* set GPA11 (RS485_DE) to output */
+}
+
+/*
+ * Initialise the rs485 port with the given baudrate. The settings
+ * are always 8 data bits, no parity, 1 stop bit, no start bits.
+ *
+ */
+int rs485_init (void)
+{
+ rs485_cfgio ();
+ rs485_setbrg ();
+
+ return (0);
+}
+
+/*
+ * Read a single byte from the rs485 port. Returns 1 on success, 0
+ * otherwise. When the function is succesfull, the character read is
+ * written into its argument c.
+ */
+int rs485_getc (void)
+{
+ S3C24X0_UART * const uart = S3C24X0_GetBase_UART(UART_NR);
+
+ /* wait for character to arrive */
+ while (!(uart->UTRSTAT & 0x1));
+
+ return uart->URXH & 0xff;
+}
+
+/*
+ * Output a single byte to the rs485 port.
+ */
+void rs485_putc (const char c)
+{
+ S3C24X0_UART * const uart = S3C24X0_GetBase_UART(UART_NR);
+
+ /* wait for room in the tx FIFO */
+ while (!(uart->UTRSTAT & 0x2));
+
+ uart->UTXH = c;
+
+ /* If \n, also do \r */
+ if (c == '\n')
+ rs485_putc ('\r');
+}
+
+/*
+ * Test whether a character is in the RX buffer
+ */
+int rs485_tstc (void)
+{
+ S3C24X0_UART * const uart = S3C24X0_GetBase_UART(UART_NR);
+
+ return uart->UTRSTAT & 0x1;
+}
+
+void rs485_puts (const char *s)
+{
+ while (*s) {
+ rs485_putc (*s++);
+ }
+}
+
+
+/*
+ * State table:
+ * RE DE Result
+ * 1 1 XMIT
+ * 0 0 RCV
+ * 1 0 Shutdown
+ */
+
+/* function that controls the receiver enable for the rs485 */
+/* rs485re_state reflects the level (0/1) of the RE pin */
+
+static void set_rs485re(unsigned char rs485re_state)
+{
+ if(rs485re_state)
+ *CPLD_RS485_RE = 0x010000;
+ else
+ *CPLD_RS485_RE = 0x0;
+}
+
+/* function that controls the sender enable for the rs485 */
+/* rs485de_state reflects the level (0/1) of the DE pin */
+
+static void set_rs485de(unsigned char rs485de_state)
+{
+ S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+
+ /* This is on PORT A bit 11 */
+ if(rs485de_state)
+ gpio->PADAT |= (1 << 11);
+ else
+ gpio->PADAT &= ~(1 << 11);
+}
+
+
+void trab_rs485_enable_tx(void)
+{
+ set_rs485de(1);
+ set_rs485re(1);
+}
+
+void trab_rs485_enable_rx(void)
+{
+ set_rs485re(0);
+ set_rs485de(0);
+}
+
+#ifdef NOT_USED
+static void trab_rs485_disable_tx(void)
+{
+ set_rs485de(0);
+}
+
+static void trab_rs485_disable_rx(void)
+{
+ set_rs485re(1);
+}
+#endif
diff --git a/board/trab/rs485.h b/board/trab/rs485.h
new file mode 100644
index 00000000000..d4a008a323d
--- /dev/null
+++ b/board/trab/rs485.h
@@ -0,0 +1,37 @@
+/*
+ * (C) Copyright 2003
+ * Martin Krause, TQ-Systems GmbH, <martin.krause@tqs.de>
+ *
+ * Based on cpu/arm920t/serial.c, by Gary Jennejohn
+ * (C) Copyright 2002 Gary Jennejohn, DENX Software Engineering, <gj@denx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _RS485_H_
+#define _RS485_H_
+
+#include <s3c2400.h>
+
+int rs485_init (void);
+int rs485_getc (void);
+void rs485_putc (const char c);
+int rs485_tstc (void);
+void rs485_puts (const char *s);
+void trab_rs485_enable_tx(void);
+void trab_rs485_enable_rx(void);
+
+#endif /* _RS485_H_ */
diff --git a/board/trab/trab_fkt.c b/board/trab/trab_fkt.c
new file mode 100644
index 00000000000..c147353033c
--- /dev/null
+++ b/board/trab/trab_fkt.c
@@ -0,0 +1,1093 @@
+/*
+ * (C) Copyright 2003
+ * Martin Krause, TQ-Systems GmbH, martin.krause@tqs.de
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#define DEBUG
+
+#include <common.h>
+#include <exports.h>
+#include <s3c2400.h>
+#include "tsc2000.h"
+#include "rs485.h"
+
+/* assignment of CPU internal ADC channels with TRAB hardware */
+#define VCC5V 2
+#define VCC12V 3
+
+/* CPLD-Register for controlling TRAB hardware functions */
+#define CPLD_BUTTONS ((volatile unsigned long *)0x04020000)
+#define CPLD_FILL_LEVEL ((volatile unsigned long *)0x04008000)
+#define CPLD_ROTARY_SWITCH ((volatile unsigned long *)0x04018000)
+#define CPLD_RS485_RE ((volatile unsigned long *)0x04028000)
+
+/* timer configuration bits for buzzer and PWM */
+#define START2 (1 << 12)
+#define UPDATE2 (1 << 13)
+#define INVERT2 (1 << 14)
+#define RELOAD2 (1 << 15)
+#define START3 (1 << 16)
+#define UPDATE3 (1 << 17)
+#define INVERT3 (1 << 18)
+#define RELOAD3 (1 << 19)
+
+#define PCLK 66000000
+#define BUZZER_FREQ 1000 /* frequency in Hz */
+#define BUZZER_TIME 1000000 /* time in us */
+#define PWM_FREQ 500
+
+
+/* definitions of I2C EEPROM device address */
+#define I2C_EEPROM_DEV_ADDR 0x54
+
+/* definition for touch panel calibration points */
+#define CALIB_TL 0 /* calibration point in (T)op (L)eft corner */
+#define CALIB_DR 1 /* calibration point in (D)own (R)ight corner */
+
+/* EEPROM addresse map */
+#define SERIAL_NUMBER 8
+#define TOUCH_X0 52
+#define TOUCH_Y0 54
+#define TOUCH_X1 56
+#define TOUCH_Y1 58
+#define CRC16 60
+
+/* EEPROM stuff */
+#define EEPROM_MAX_CRC_BUF 64
+
+/* RS485 stuff */
+#define RS485_MAX_RECEIVE_BUF_LEN 100
+
+/* Bit definitions for ADCCON */
+#define ADC_ENABLE_START 0x1
+#define ADC_READ_START 0x2
+#define ADC_STDBM 0x4
+#define ADC_INP_AIN0 (0x0 << 3)
+#define ADC_INP_AIN1 (0x1 << 3)
+#define ADC_INP_AIN2 (0x2 << 3)
+#define ADC_INP_AIN3 (0x3 << 3)
+#define ADC_INP_AIN4 (0x4 << 3)
+#define ADC_INP_AIN5 (0x5 << 3)
+#define ADC_INP_AIN6 (0x6 << 3)
+#define ADC_INP_AIN7 (0x7 << 3)
+#define ADC_PRSCEN 0x4000
+#define ADC_ECFLG 0x8000
+
+/* function test functions */
+int do_dip (void);
+int do_info (void);
+int do_vcc5v (void);
+int do_vcc12v (void);
+int do_buttons (void);
+int do_fill_level (void);
+int do_rotary_switch (void);
+int do_pressure (void);
+int do_v_bat (void);
+int do_vfd_id (void);
+int do_buzzer (void);
+int do_led (char **);
+int do_full_bridge (char **);
+int do_dac (char **);
+int do_motor_contact (void);
+int do_motor (char **);
+int do_pwm (char **);
+int do_thermo (char **);
+int do_touch (char **);
+int do_rs485 (char **);
+int do_serial_number (char **);
+int do_crc16 (void);
+
+/* helper functions */
+static void adc_init (void);
+static int adc_read (unsigned int channel);
+static void print_identifier (void);
+static void touch_wait_pressed (void);
+static void touch_read_x_y (int *x, int *y);
+static int touch_write_clibration_values (int calib_point, int x, int y);
+static int rs485_send_line (const char *data);
+static int rs485_receive_chars (char *data, int timeout);
+static unsigned short updcrc(unsigned short icrc, unsigned char *icp,
+ unsigned int icnt);
+
+
+/*
+ * TRAB board specific commands. Especially commands for burn-in and function
+ * test.
+ */
+
+int trab_fkt (int argc, char *argv[])
+{
+ int i;
+
+ app_startup(argv);
+ if (get_version () != XF_VERSION) {
+ printf ("Wrong XF_VERSION. Please re-compile with actual "
+ "u-boot sources\n");
+ printf ("Example expects ABI version %d\n", XF_VERSION);
+ printf ("Actual U-Boot ABI version %d\n", (int)get_version());
+ return 1;
+ }
+
+ debug ("argc = %d\n", argc);
+
+ for (i=0; i<=argc; ++i) {
+ debug ("argv[%d] = \"%s\"\n", i, argv[i] ? argv[i] : "<NULL>");
+ }
+
+ adc_init ();
+
+ switch (argc) {
+
+ case 0:
+ case 1:
+ break;
+
+ case 2:
+ if (strcmp (argv[1], "info") == 0) {
+ return (do_info ());
+ }
+ if (strcmp (argv[1], "dip") == 0) {
+ return (do_dip ());
+ }
+ if (strcmp (argv[1], "vcc5v") == 0) {
+ return (do_vcc5v ());
+ }
+ if (strcmp (argv[1], "vcc12v") == 0) {
+ return (do_vcc12v ());
+ }
+ if (strcmp (argv[1], "buttons") == 0) {
+ return (do_buttons ());
+ }
+ if (strcmp (argv[1], "fill_level") == 0) {
+ return (do_fill_level ());
+ }
+ if (strcmp (argv[1], "rotary_switch") == 0) {
+ return (do_rotary_switch ());
+ }
+ if (strcmp (argv[1], "pressure") == 0) {
+ return (do_pressure ());
+ }
+ if (strcmp (argv[1], "v_bat") == 0) {
+ return (do_v_bat ());
+ }
+ if (strcmp (argv[1], "vfd_id") == 0) {
+ return (do_vfd_id ());
+ }
+ if (strcmp (argv[1], "buzzer") == 0) {
+ return (do_buzzer ());
+ }
+ if (strcmp (argv[1], "motor_contact") == 0) {
+ return (do_motor_contact ());
+ }
+ if (strcmp (argv[1], "crc16") == 0) {
+ return (do_crc16 ());
+ }
+ break;
+
+ case 3:
+ if (strcmp (argv[1], "full_bridge") == 0) {
+ return (do_full_bridge (argv));
+ }
+ if (strcmp (argv[1], "dac") == 0) {
+ return (do_dac (argv));
+ }
+ if (strcmp (argv[1], "motor") == 0) {
+ return (do_motor (argv));
+ }
+ if (strcmp (argv[1], "pwm") == 0) {
+ return (do_pwm (argv));
+ }
+ if (strcmp (argv[1], "thermo") == 0) {
+ return (do_thermo (argv));
+ }
+ if (strcmp (argv[1], "touch") == 0) {
+ return (do_touch (argv));
+ }
+ if (strcmp (argv[1], "serial_number") == 0) {
+ return (do_serial_number (argv));
+ }
+ break;
+
+ case 4:
+ if (strcmp (argv[1], "led") == 0) {
+ return (do_led (argv));
+ }
+ if (strcmp (argv[1], "rs485") == 0) {
+ return (do_rs485 (argv));
+ }
+ if (strcmp (argv[1], "serial_number") == 0) {
+ return (do_serial_number (argv));
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ printf ("Usage:\n<command> <parameter1> <parameter2> ...\n");
+ return 1;
+}
+
+int do_info (void)
+{
+ printf ("Stand-alone application for TRAB board function test\n");
+ printf ("Built: %s at %s\n", __DATE__ , __TIME__ );
+
+ return 0;
+}
+
+int do_dip (void)
+{
+ unsigned int result = 0;
+ int adc_val;
+ int i;
+
+ /***********************************************************
+ DIP switch connection (according to wa4-cpu.sp.301.pdf, page 3):
+ SW1 - AIN4
+ SW2 - AIN5
+ SW3 - AIN6
+ SW4 - AIN7
+
+ "On" DIP switch position short-circuits the voltage from
+ the input channel (i.e. '0' conversion result means "on").
+ *************************************************************/
+
+ for (i = 7; i > 3; i--) {
+
+ if ((adc_val = adc_read (i)) == -1) {
+ printf ("Channel %d could not be read\n", i);
+ return 1;
+ }
+
+ /*
+ * Input voltage (switch open) is 1.8 V.
+ * (Vin_High/VRef)*adc_res = (1,8V/2,5V)*1023) = 736
+ * Set trigger at halve that value.
+ */
+ if (adc_val < 368)
+ result |= (1 << (i-4));
+ }
+
+ /* print result to console */
+ print_identifier ();
+ for (i = 0; i < 4; i++) {
+ if ((result & (1 << i)) == 0)
+ printf("0");
+ else
+ printf("1");
+ }
+ printf("\n");
+
+ return 0;
+}
+
+
+int do_vcc5v (void)
+{
+ int result;
+
+ /* VCC5V is connected to channel 2 */
+
+ if ((result = adc_read (VCC5V)) == -1) {
+ printf ("VCC5V could not be read\n");
+ return 1;
+ }
+
+ /*
+ * Calculate voltage value. Split in two parts because there is no
+ * floating point support. VCC5V is connected over an resistor divider:
+ * VCC5V=ADCval*2,5V/1023*(10K+30K)/10K.
+ */
+ print_identifier ();
+ printf ("%d", (result & 0x3FF)* 10 / 1023);
+ printf (".%d", ((result & 0x3FF)* 10 % 1023)* 10 / 1023);
+ printf ("%d V\n", (((result & 0x3FF) * 10 % 1023 ) * 10 % 1023)
+ * 10 / 1024);
+
+ return 0;
+}
+
+
+int do_vcc12v (void)
+{
+ int result;
+
+ if ((result = adc_read (VCC12V)) == -1) {
+ printf ("VCC12V could not be read\n");
+ return 1;
+ }
+
+ /*
+ * Calculate voltage value. Split in two parts because there is no
+ * floating point support. VCC5V is connected over an resistor divider:
+ * VCC12V=ADCval*2,5V/1023*(30K+270K)/30K.
+ */
+ print_identifier ();
+ printf ("%d", (result & 0x3FF)* 25 / 1023);
+ printf (".%d V\n", ((result & 0x3FF)* 25 % 1023) * 10 / 1023);
+
+ return 0;
+}
+
+static int adc_read (unsigned int channel)
+{
+ int j = 1000; /* timeout value for wait loop in us */
+ S3C2400_ADC *padc;
+
+ padc = S3C2400_GetBase_ADC();
+ channel &= 0x7;
+
+ debug ("%s: adccon %#x\n", __FUNCTION__, padc->ADCCON);
+
+ padc->ADCCON &= ~ADC_STDBM; /* select normal mode */
+ padc->ADCCON &= ~(0x7 << 3); /* clear the channel bits */
+ padc->ADCCON |= ((channel << 3) | ADC_ENABLE_START);
+
+ debug ("%s: reading ch %d, addcon %#x\n", __FUNCTION__,
+ (padc->ADCCON >> 3) & 0x7, padc->ADCCON);
+
+ while (j--) {
+ if ((padc->ADCCON & ADC_ENABLE_START) == 0)
+ break;
+ udelay (1);
+ }
+
+ if (j == 0) {
+ printf("%s: ADC timeout\n", __FUNCTION__);
+ padc->ADCCON |= ADC_STDBM; /* select standby mode */
+ return -1;
+ }
+
+ padc->ADCCON |= ADC_STDBM; /* select standby mode */
+
+ debug ("%s: return %#x, adccon %#x\n", __FUNCTION__, padc->ADCDAT & 0x3FF,
+ padc->ADCCON);
+
+ return (padc->ADCDAT & 0x3FF);
+}
+
+
+static void adc_init (void)
+{
+ S3C2400_ADC *padc;
+
+ padc = S3C2400_GetBase_ADC();
+
+ debug ("%s: adccon %#x\n", __FUNCTION__, padc->ADCCON);
+
+ padc->ADCCON &= ~(0xff << 6); /* clear prescaler bits */
+ padc->ADCCON |= ((65 << 6) | ADC_PRSCEN); /* set prescaler */
+
+ debug ("%s: init completed: adccon %#x\n", __FUNCTION__, padc->ADCCON);
+ return;
+}
+
+
+int do_buttons (void)
+{
+ int result;
+ int i;
+
+ result = *CPLD_BUTTONS; /* read CPLD */
+ debug ("%s: cpld_taster (32 bit) %#x\n", __FUNCTION__, result);
+
+ /* print result to console */
+ print_identifier ();
+ for (i = 16; i <= 19; i++) {
+ if ((result & (1 << i)) == 0)
+ printf("0");
+ else
+ printf("1");
+ }
+ printf("\n");
+ return 0;
+}
+
+
+int do_fill_level (void)
+{
+ int result;
+
+ result = *CPLD_FILL_LEVEL; /* read CPLD */
+ debug ("%s: cpld_fuellstand (32 bit) %#x\n", __FUNCTION__, result);
+
+ /* print result to console */
+ print_identifier ();
+ if ((result & (1 << 16)) == 0)
+ printf("0\n");
+ else
+ printf("1\n");
+ return 0;
+}
+
+
+int do_rotary_switch (void)
+{
+ int result;
+
+ result = *CPLD_ROTARY_SWITCH; /* read CPLD */
+ debug ("%s: cpld_inc (32 bit) %#x\n", __FUNCTION__, result);
+
+ *CPLD_ROTARY_SWITCH |= (3 << 16); /* clear direction bits in CPLD */
+
+ /* print result to console */
+ print_identifier ();
+ if ((result & (1 << 16)) == (1 << 16))
+ printf("R");
+ if ((result & (1 << 17)) == (1 << 17))
+ printf("L");
+ if (((result & (1 << 16)) == 0) && ((result & (1 << 17)) == 0))
+ printf("0");
+ if ((result & (1 << 18)) == 0)
+ printf("0\n");
+ else
+ printf("1\n");
+ return 0;
+}
+
+
+int do_vfd_id (void)
+{
+ int i;
+ long int pcup_old, pccon_old;
+ int vfd_board_id;
+ S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+
+ /* try to red vfd board id from the value defined by pull-ups */
+
+ pcup_old = gpio->PCUP;
+ pccon_old = gpio->PCCON;
+
+ gpio->PCUP = (gpio->PCUP & 0xFFF0); /* activate GPC0...GPC3 pull-ups */
+ gpio->PCCON = (gpio->PCCON & 0xFFFFFF00); /* configure GPC0...GPC3 as
+ * inputs */
+ udelay (10); /* allow signals to settle */
+ vfd_board_id = (~gpio->PCDAT) & 0x000F; /* read GPC0...GPC3 port pins */
+
+ gpio->PCCON = pccon_old;
+ gpio->PCUP = pcup_old;
+
+ /* print vfd_board_id to console */
+ print_identifier ();
+ for (i = 0; i < 4; i++) {
+ if ((vfd_board_id & (1 << i)) == 0)
+ printf("0");
+ else
+ printf("1");
+ }
+ printf("\n");
+ return 0;
+}
+
+int do_buzzer (void)
+{
+ int counter;
+
+ S3C24X0_TIMERS * const timers = S3C24X0_GetBase_TIMERS();
+ S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+
+ /* configure pin GPD7 as TOUT2 */
+ gpio->PDCON &= ~0xC000;
+ gpio->PDCON |= 0x8000;
+
+ /* set prescaler for timer 2, 3 and 4 */
+ timers->TCFG0 &= ~0xFF00;
+ timers->TCFG0 |= 0x0F00;
+
+ /* set divider for timer 2 */
+ timers->TCFG1 &= ~0xF00;
+ timers->TCFG1 |= 0x300;
+
+ /* set frequency */
+ counter = (PCLK / BUZZER_FREQ) >> 9;
+ timers->ch[2].TCNTB = counter;
+ timers->ch[2].TCMPB = counter / 2;
+
+ debug ("%s: frequency: %d, duration: %d\n", __FUNCTION__, BUZZER_FREQ,
+ BUZZER_TIME);
+
+ /* start */
+ timers->TCON = (timers->TCON | UPDATE2 | RELOAD2) & ~INVERT2;
+ timers->TCON = (timers->TCON | START2) & ~UPDATE2;
+
+ udelay (BUZZER_TIME);
+
+ /* stop */
+ timers->TCON &= ~(START2 | RELOAD2);
+
+ /* port pin configuration */
+ gpio->PDCON &= ~0xC000;
+ gpio->PDCON |= 0x4000;
+ gpio->PDDAT &= ~0x80;
+ return 0;
+}
+
+
+int do_led (char **argv)
+{
+ S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+
+ /* configure PC14 and PC15 as output */
+ gpio->PCCON &= ~(0xF << 28);
+ gpio->PCCON |= (0x5 << 28);
+
+ /* configure PD0 and PD4 as output */
+ gpio->PDCON &= ~((0x3 << 8) | 0x3);
+ gpio->PDCON |= ((0x1 << 8) | 0x1);
+
+ switch (simple_strtoul(argv[2], NULL, 10)) {
+
+ case 0:
+ case 1:
+ break;
+
+ case 2:
+ if (strcmp (argv[3], "on") == 0)
+ gpio->PCDAT |= (1 << 14);
+ else
+ gpio->PCDAT &= ~(1 << 14);
+ return 0;
+
+ case 3:
+ if (strcmp (argv[3], "on") == 0)
+ gpio->PCDAT |= (1 << 15);
+ else
+ gpio->PCDAT &= ~(1 << 15);
+ return 0;
+
+ case 4:
+ if (strcmp (argv[3], "on") == 0)
+ gpio->PDDAT |= (1 << 0);
+ else
+ gpio->PDDAT &= ~(1 << 0);
+ return 0;
+
+ case 5:
+ if (strcmp (argv[3], "on") == 0)
+ gpio->PDDAT |= (1 << 4);
+ else
+ gpio->PDDAT &= ~(1 << 4);
+ return 0;
+
+ default:
+ break;
+
+ }
+ printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+ return 1;
+}
+
+
+int do_full_bridge (char **argv)
+{
+ S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+
+ /* configure PD5 and PD6 as output */
+ gpio->PDCON &= ~((0x3 << 5*2) | (0x3 << 6*2));
+ gpio->PDCON |= ((0x1 << 5*2) | (0x1 << 6*2));
+
+ if (strcmp (argv[2], "+") == 0) {
+ gpio->PDDAT |= (1 << 5);
+ gpio->PDDAT |= (1 << 6);
+ return 0;
+ }
+ else if (strcmp (argv[2], "-") == 0) {
+ gpio->PDDAT &= ~(1 << 5);
+ gpio->PDDAT |= (1 << 6);
+ return 0;
+ }
+ else if (strcmp (argv[2], "off") == 0) {
+ gpio->PDDAT &= ~(1 << 5);
+ gpio->PDDAT &= ~(1 << 6);
+ return 0;
+ }
+ printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+ return 1;
+}
+
+/* val must be in [0, 4095] */
+static inline unsigned long tsc2000_to_uv (u16 val)
+{
+ return ((250000 * val) / 4096) * 10;
+}
+
+
+int do_dac (char **argv)
+{
+ int brightness;
+
+ /* initialize SPI */
+ spi_init ();
+
+ if (((brightness = simple_strtoul (argv[2], NULL, 10)) < 0) ||
+ (brightness > 255)) {
+ printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+ return 1;
+ }
+ tsc2000_write(TSC2000_REG_DACCTL, 0x0); /* Power up DAC */
+ tsc2000_write(TSC2000_REG_DAC, brightness & 0xff);
+
+ return 0;
+}
+
+
+int do_v_bat (void)
+{
+ unsigned long ret, res;
+
+ /* initialize SPI */
+ spi_init ();
+
+ tsc2000_write(TSC2000_REG_ADC, 0x1836);
+
+ /* now wait for data available */
+ adc_wait_conversion_done();
+
+ ret = tsc2000_read(TSC2000_REG_BAT1);
+ res = (tsc2000_to_uv(ret) + 1250) / 2500;
+ res += (ERROR_BATTERY * res) / 1000;
+
+ print_identifier ();
+ printf ("%ld", (res / 100));
+ printf (".%ld", ((res % 100) / 10));
+ printf ("%ld V\n", (res % 10));
+ return 0;
+}
+
+
+int do_pressure (void)
+{
+ /* initialize SPI */
+ spi_init ();
+
+ tsc2000_write(TSC2000_REG_ADC, 0x2436);
+
+ /* now wait for data available */
+ adc_wait_conversion_done();
+
+ print_identifier ();
+ printf ("%d\n", tsc2000_read(TSC2000_REG_AUX2));
+ return 0;
+}
+
+
+int do_motor_contact (void)
+{
+ int result;
+
+ result = *CPLD_FILL_LEVEL; /* read CPLD */
+ debug ("%s: cpld_fuellstand (32 bit) %#x\n", __FUNCTION__, result);
+
+ /* print result to console */
+ print_identifier ();
+ if ((result & (1 << 17)) == 0)
+ printf("0\n");
+ else
+ printf("1\n");
+ return 0;
+}
+
+int do_motor (char **argv)
+{
+ S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+
+ /* Configure I/O port */
+ gpio->PGCON &= ~(0x3 << 0);
+ gpio->PGCON |= (0x1 << 0);
+
+ if (strcmp (argv[2], "on") == 0) {
+ gpio->PGDAT &= ~(1 << 0);
+ return 0;
+ }
+ if (strcmp (argv[2], "off") == 0) {
+ gpio->PGDAT |= (1 << 0);
+ return 0;
+ }
+ printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+ return 1;
+}
+
+static void print_identifier (void)
+{
+ printf ("## FKT: ");
+}
+
+int do_pwm (char **argv)
+{
+ int counter;
+ S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+ S3C24X0_TIMERS * const timers = S3C24X0_GetBase_TIMERS();
+
+ if (strcmp (argv[2], "on") == 0) {
+ /* configure pin GPD8 as TOUT3 */
+ gpio->PDCON &= ~(0x3 << 8*2);
+ gpio->PDCON |= (0x2 << 8*2);
+
+ /* set prescaler for timer 2, 3 and 4 */
+ timers->TCFG0 &= ~0xFF00;
+ timers->TCFG0 |= 0x0F00;
+
+ /* set divider for timer 3 */
+ timers->TCFG1 &= ~(0xf << 12);
+ timers->TCFG1 |= (0x3 << 12);
+
+ /* set frequency */
+ counter = (PCLK / PWM_FREQ) >> 9;
+ timers->ch[3].TCNTB = counter;
+ timers->ch[3].TCMPB = counter / 2;
+
+ /* start timer */
+ timers->TCON = (timers->TCON | UPDATE3 | RELOAD3) & ~INVERT3;
+ timers->TCON = (timers->TCON | START3) & ~UPDATE3;
+ return 0;
+ }
+ if (strcmp (argv[2], "off") == 0) {
+
+ /* stop timer */
+ timers->TCON &= ~(START2 | RELOAD2);
+
+ /* configure pin GPD8 as output and set to 0 */
+ gpio->PDCON &= ~(0x3 << 8*2);
+ gpio->PDCON |= (0x1 << 8*2);
+ gpio->PDDAT &= ~(1 << 8);
+ return 0;
+ }
+ printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+ return 1;
+}
+
+
+int do_thermo (char **argv)
+{
+ int channel, res;
+
+ tsc2000_reg_init ();
+ tsc2000_set_range (3);
+
+ if (strcmp (argv[2], "all") == 0) {
+ int i;
+ for (i=0; i <= 15; i++) {
+ res = tsc2000_read_channel(i);
+ print_identifier ();
+ printf ("c%d: %d\n", i, res);
+ }
+ return 0;
+ }
+ channel = simple_strtoul (argv[2], NULL, 10);
+ res = tsc2000_read_channel(channel);
+ print_identifier ();
+ printf ("%d\n", res);
+ return 0; /* return OK */
+}
+
+
+
+int do_touch (char **argv)
+{
+ int x, y;
+
+ if (strcmp (argv[2], "tl") == 0) {
+ touch_wait_pressed();
+ touch_read_x_y (&x, &y);
+
+ print_identifier ();
+ printf ("x=%d y=%d\n", x, y);
+ return touch_write_clibration_values (CALIB_TL, x, y);
+ }
+ else if (strcmp (argv[2], "dr") == 0) {
+ touch_wait_pressed();
+ touch_read_x_y (&x, &y);
+
+ print_identifier ();
+ printf ("x=%d y=%d\n", x, y);
+
+ return touch_write_clibration_values (CALIB_DR, x, y);
+ }
+ return 1; /* return error */
+}
+
+
+static void touch_wait_pressed (void)
+{
+ while (!(tsc2000_read(TSC2000_REG_ADC) & TC_PSM));
+}
+
+
+static int touch_write_clibration_values (int calib_point, int x, int y)
+{
+#if (CONFIG_COMMANDS & CFG_CMD_I2C)
+ tsc2000_reg_init ();
+
+ if (calib_point == CALIB_TL) {
+ if (i2c_write (I2C_EEPROM_DEV_ADDR, TOUCH_X0, 1,
+ (char *)&x, 2)) {
+ printf ("could not write to eeprom\n");
+ return 1;
+ }
+ udelay(11000);
+ if (i2c_write (I2C_EEPROM_DEV_ADDR, TOUCH_Y0, 1,
+ (char *)&y, 2)) {
+ printf ("could not write to eeprom\n");
+ return 1;
+ }
+ udelay(11000);
+ return 0;
+ }
+ else if (calib_point == CALIB_DR) {
+ if (i2c_write (I2C_EEPROM_DEV_ADDR, TOUCH_X1, 1,
+ (char *)&x, 2)) {
+ printf ("could not write to eeprom\n");
+ return 1;
+ }
+ udelay(11000);
+ if (i2c_write (I2C_EEPROM_DEV_ADDR, TOUCH_Y1, 1,
+ (char *)&y, 2)) {
+ printf ("could not write to eeprom\n");
+ return 1;
+ }
+ udelay(11000);
+ return 0;
+ }
+ return 1;
+#else
+ printf ("No I2C support enabled (CFG_CMD_I2C), could not write "
+ "to EEPROM\n");
+ return (1);
+#endif /* CFG_CMD_I2C */
+}
+
+
+static void touch_read_x_y (int *px, int *py)
+{
+ tsc2000_write(TSC2000_REG_ADC, DEFAULT_ADC | TC_AD0 | TC_AD1);
+ adc_wait_conversion_done();
+ *px = tsc2000_read(TSC2000_REG_X);
+
+ tsc2000_write(TSC2000_REG_ADC, DEFAULT_ADC | TC_AD2);
+ adc_wait_conversion_done();
+ *py = tsc2000_read(TSC2000_REG_Y);
+}
+
+
+
+int do_rs485 (char **argv)
+{
+ int timeout;
+ char data[RS485_MAX_RECEIVE_BUF_LEN];
+
+ if (strcmp (argv[2], "send") == 0) {
+ return (rs485_send_line (argv[3]));
+ }
+ else if (strcmp (argv[2], "receive") == 0) {
+ timeout = simple_strtoul(argv[3], NULL, 10);
+ if (rs485_receive_chars (data, timeout) != 0) {
+ print_identifier ();
+ printf ("## nothing received\n");
+ return (1);
+ }
+ else {
+ print_identifier ();
+ printf ("%s\n", data);
+ return (0);
+ }
+ }
+ printf ("%s: unknown command %s\n", __FUNCTION__, argv[2]);
+ return (1); /* unknown command, return error */
+}
+
+
+static int rs485_send_line (const char *data)
+{
+ rs485_init ();
+ trab_rs485_enable_tx ();
+ rs485_puts (data);
+ rs485_putc ('\n');
+
+ return (0);
+}
+
+
+static int rs485_receive_chars (char *data, int timeout)
+{
+ int i;
+ int receive_count = 0;
+
+ rs485_init ();
+ trab_rs485_enable_rx ();
+
+ /* test every 1 ms for received characters to avoid a receive FIFO
+ * overrun (@ 38.400 Baud) */
+ for (i = 0; i < (timeout * 1000); i++) {
+ while (rs485_tstc ()) {
+ if (receive_count >= RS485_MAX_RECEIVE_BUF_LEN-1)
+ break;
+ *data++ = rs485_getc ();
+ receive_count++;
+ }
+ udelay (1000); /* pause 1 ms */
+ }
+ *data = '\0'; /* terminate string */
+
+ if (receive_count == 0)
+ return (1);
+ else
+ return (0);
+}
+
+
+int do_serial_number (char **argv)
+{
+#if (CONFIG_COMMANDS & CFG_CMD_I2C)
+ unsigned int serial_number;
+
+ if (strcmp (argv[2], "read") == 0) {
+ if (i2c_read (I2C_EEPROM_DEV_ADDR, SERIAL_NUMBER, 1,
+ (char *)&serial_number, 4)) {
+ printf ("could not read from eeprom\n");
+ return (1);
+ }
+ print_identifier ();
+ printf ("%08d\n", serial_number);
+ return (0);
+ }
+ else if (strcmp (argv[2], "write") == 0) {
+ serial_number = simple_strtoul(argv[3], NULL, 10);
+ if (i2c_write (I2C_EEPROM_DEV_ADDR, SERIAL_NUMBER, 1,
+ (char *)&serial_number, 4)) {
+ printf ("could not write to eeprom\n");
+ return (1);
+ }
+ return (0);
+ }
+ printf ("%s: unknown command %s\n", __FUNCTION__, argv[2]);
+ return (1); /* unknown command, return error */
+#else
+ printf ("No I2C support enabled (CFG_CMD_I2C), could not write "
+ "to EEPROM\n");
+ return (1);
+#endif /* CFG_CMD_I2C */
+}
+
+
+int do_crc16 (void)
+{
+#if (CONFIG_COMMANDS & CFG_CMD_I2C)
+ int crc;
+ char buf[EEPROM_MAX_CRC_BUF];
+
+ if (i2c_read (I2C_EEPROM_DEV_ADDR, 0, 1, buf, 60)) {
+ printf ("could not read from eeprom\n");
+ return (1);
+ }
+ crc = 0; /* start value of crc calculation */
+ crc = updcrc (crc, buf, 60);
+
+ print_identifier ();
+ printf ("crc16=%#04x\n", crc);
+
+ if (i2c_write (I2C_EEPROM_DEV_ADDR, CRC16, 1, (char *)&crc,
+ sizeof (crc))) {
+ printf ("could not read from eeprom\n");
+ return (1);
+ }
+ return (0);
+#else
+ printf ("No I2C support enabled (CFG_CMD_I2C), could not write "
+ "to EEPROM\n");
+ return (1);
+#endif /* CFG_CMD_I2C */
+}
+
+
+/*
+ * Calculate, intelligently, the CRC of a dataset incrementally given a
+ * buffer full at a time.
+ * Initialize crc to 0 for XMODEM, -1 for CCITT.
+ *
+ * Usage:
+ * newcrc = updcrc( oldcrc, bufadr, buflen )
+ * unsigned int oldcrc, buflen;
+ * char *bufadr;
+ *
+ * Compile with -DTEST to generate program that prints CRC of stdin to stdout.
+ * Compile with -DMAKETAB to print values for crctab to stdout
+ */
+
+ /* the CRC polynomial. This is used by XMODEM (almost CCITT).
+ * If you change P, you must change crctab[]'s initial value to what is
+ * printed by initcrctab()
+ */
+#define P 0x1021
+
+ /* number of bits in CRC: don't change it. */
+#define W 16
+
+ /* this the number of bits per char: don't change it. */
+#define B 8
+
+static unsigned short crctab[1<<B] = { /* as calculated by initcrctab() */
+ 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
+ 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
+ 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
+ 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
+ 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
+ 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
+ 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
+ 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
+ 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
+ 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
+ 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
+ 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
+ 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
+ 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
+ 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
+ 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
+ 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
+ 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
+ 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
+ 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
+ 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
+ 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
+ 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
+ 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
+ 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
+ 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
+ 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
+ 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
+ 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
+ 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
+ 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
+ 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
+ };
+
+static unsigned short updcrc(unsigned short icrc, unsigned char *icp,
+ unsigned int icnt )
+{
+ register unsigned short crc = icrc;
+ register unsigned char *cp = icp;
+ register unsigned int cnt = icnt;
+
+ while (cnt--)
+ crc = (crc<<B) ^ crctab[(crc>>(W-B)) ^ *cp++];
+
+ return (crc);
+}
diff --git a/board/trab/tsc2000.c b/board/trab/tsc2000.c
index 4d960854c20..ad118609774 100644
--- a/board/trab/tsc2000.c
+++ b/board/trab/tsc2000.c
@@ -29,6 +29,8 @@
#include <s3c2400.h>
#include "tsc2000.h"
+#include "Pt1000_temp_data.h"
+
void spi_init(void)
{
S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
@@ -56,7 +58,7 @@ void spi_init(void)
}
-static void spi_wait_transmit_done(void)
+void spi_wait_transmit_done(void)
{
S3C24X0_SPI * const spi = S3C24X0_GetBase_SPI();
@@ -64,7 +66,7 @@ static void spi_wait_transmit_done(void)
}
-static void tsc2000_write(unsigned short reg, unsigned short data)
+void tsc2000_write(unsigned short reg, unsigned short data)
{
S3C24X0_SPI * const spi = S3C24X0_GetBase_SPI();
unsigned int command;
@@ -84,7 +86,7 @@ static void tsc2000_write(unsigned short reg, unsigned short data)
}
-static unsigned short tsc2000_read (unsigned short reg)
+unsigned short tsc2000_read (unsigned short reg)
{
unsigned short command, data;
S3C24X0_SPI * const spi = S3C24X0_GetBase_SPI();
@@ -108,7 +110,7 @@ static unsigned short tsc2000_read (unsigned short reg)
}
-static void tsc2000_set_mux (unsigned int channel)
+void tsc2000_set_mux (unsigned int channel)
{
S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
@@ -185,7 +187,7 @@ static void tsc2000_set_mux (unsigned int channel)
}
-static void tsc2000_set_range (unsigned int range)
+void tsc2000_set_range (unsigned int range)
{
S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
@@ -206,7 +208,7 @@ static void tsc2000_set_range (unsigned int range)
}
-static u16 tsc2000_read_channel (unsigned int channel)
+u16 tsc2000_read_channel (unsigned int channel)
{
u16 res;
@@ -284,7 +286,7 @@ void tsc2000_reg_init (void)
}
-static int tsc2000_interpolate(long value, long data[][2], long *result)
+int tsc2000_interpolate(long value, long data[][2], long *result)
{
int i;
@@ -311,7 +313,7 @@ static int tsc2000_interpolate(long value, long data[][2], long *result)
}
-static void adc_wait_conversion_done(void)
+void adc_wait_conversion_done(void)
{
while (!(tsc2000_read(TSC2000_REG_ADC) & (1 << 14)));
}
diff --git a/board/trab/tsc2000.h b/board/trab/tsc2000.h
index 4f118692cb2..e6efe183996 100644
--- a/board/trab/tsc2000.h
+++ b/board/trab/tsc2000.h
@@ -28,8 +28,6 @@
#ifndef _TSC2000_H_
#define _TSC2000_H_
-#include "Pt1000_temp_data.h"
-
/* temperature channel multiplexer definitions */
#define CON_MUX0 (gpio->PCCON = (gpio->PCCON & 0x0FFFFFCFF) | 0x00000100)
#define CLR_MUX0 (gpio->PCDAT &= 0x0FFEF)
@@ -116,17 +114,17 @@
#define ERROR_BATTERY 220 /* must be adjusted, if R68 is changed on
* TRAB */
-static void tsc2000_write(unsigned short, unsigned short);
-static unsigned short tsc2000_read (unsigned short);
-static u16 tsc2000_read_channel (unsigned int);
-static void tsc2000_set_mux (unsigned int);
-static void tsc2000_set_range (unsigned int);
+void tsc2000_write(unsigned short, unsigned short);
+unsigned short tsc2000_read (unsigned short);
+u16 tsc2000_read_channel (unsigned int);
+void tsc2000_set_mux (unsigned int);
+void tsc2000_set_range (unsigned int);
void tsc2000_reg_init (void);
s32 tsc2000_contact_temp (void);
-static void spi_wait_transmit_done (void);
+void spi_wait_transmit_done (void);
void spi_init(void);
-static int tsc2000_interpolate(long value, long data[][2], long *result);
-static void adc_wait_conversion_done(void);
+int tsc2000_interpolate(long value, long data[][2], long *result);
+void adc_wait_conversion_done(void);
static inline void SET_CS_TOUCH(void)
diff --git a/examples/Makefile b/examples/Makefile
index 542791b8b83..febc501e9f6 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -69,11 +69,6 @@ ifeq ($(BOARD),oxc)
SREC += eepro100_eeprom.srec
endif
-##ifeq ($(BOARD),trab)
-##SREC += trab_fkt.srec
-##BIN += trab_fkt.bin
-##endif
-
OBJS = $(SREC:.srec=.o)
LIB = libstubs.a
diff --git a/include/_exports.h b/include/_exports.h
index 17cb91be3de..61dcaaf331c 100644
--- a/include/_exports.h
+++ b/include/_exports.h
@@ -10,6 +10,8 @@ EXPORT_FUNC(malloc)
EXPORT_FUNC(free)
EXPORT_FUNC(udelay)
EXPORT_FUNC(get_timer)
+EXPORT_FUNC(vprintf)
+EXPORT_FUNC(do_reset)
#if (CONFIG_COMMANDS & CFG_CMD_I2C)
EXPORT_FUNC(i2c_write)
EXPORT_FUNC(i2c_read)
diff --git a/include/exports.h b/include/exports.h
index 84bc56b7a05..3c60dbdf322 100644
--- a/include/exports.h
+++ b/include/exports.h
@@ -18,6 +18,8 @@ void *malloc(size_t);
void free(void*);
void udelay(unsigned long);
unsigned long get_timer(unsigned long);
+void vprintf(const char *, va_list);
+void do_reset (void);
#if (CONFIG_COMMANDS & CFG_CMD_I2C)
int i2c_write (uchar, uint, int , uchar* , int);
int i2c_read (uchar, uint, int , uchar* , int);