3 * Detlev Zundel, DENX Software Engineering, dzu@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 #define TWS_IMPLEMENTATION
28 /*=====================================================================*/
29 /* Public Functions */
30 /*=====================================================================*/
32 /*-----------------------------------------------------------------------
35 int tws_read(uchar *buffer, int len)
40 debug("tws_read: buffer %p len %d\n", buffer, len);
42 /* Configure the data pin for input */
43 tws_data_config_output(0);
45 /* Disable WR, i.e. setup a read */
54 for (shift = 0, accu = 0;
55 (rem > 0) && (shift < 8);
59 accu |= (tws_data_read() << shift); /* LSB first */
73 /*-----------------------------------------------------------------------
76 int tws_write(uchar *buffer, int len)
81 debug("tws_write: buffer %p len %d\n", buffer, len);
83 /* Configure the data pin for output */
84 tws_data_config_output(1);
86 /* Enable WR, i.e. setup a write */
95 for (shift = 0, accu = *buffer++;
96 (rem > 0) && (shift < 8);
98 tws_data(accu & 0x01); /* LSB first */