3 * Detlev Zundel, DENX Software Engineering, dzu@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
8 #define TWS_IMPLEMENTATION
11 /*=====================================================================*/
12 /* Public Functions */
13 /*=====================================================================*/
15 /*-----------------------------------------------------------------------
18 int tws_read(uchar
*buffer
, int len
)
23 debug("tws_read: buffer %p len %d\n", buffer
, len
);
25 /* Configure the data pin for input */
26 tws_data_config_output(0);
28 /* Disable WR, i.e. setup a read */
37 for (shift
= 0, accu
= 0;
38 (rem
> 0) && (shift
< 8);
42 accu
|= (tws_data_read() << shift
); /* LSB first */
56 /*-----------------------------------------------------------------------
59 int tws_write(uchar
*buffer
, int len
)
64 debug("tws_write: buffer %p len %d\n", buffer
, len
);
66 /* Configure the data pin for output */
67 tws_data_config_output(1);
69 /* Enable WR, i.e. setup a write */
78 for (shift
= 0, accu
= *buffer
++;
79 (rem
> 0) && (shift
< 8);
81 tws_data(accu
& 0x01); /* LSB first */