2 * Copyright © 2009 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19 #ifndef _CC_BITBANG_H_
20 #define _CC_BITBANG_H_
26 #define CC_RESET_N 0x4
27 #define CC_CLOCK_US (2)
29 /* Telemetrum has a 10k pull-up to 3.3v, a 0.001uF cap to ground
30 * and a 2.7k resistor to the reset line. This takes about 6us
31 * to settle, so we'll wait longer than that after changing the reset line
33 #define CC_RESET_US (12)
38 cc_bitbang_set_clock(uint32_t us);
41 cc_bitbang_half_clock(struct cc_bitbang *bb);
44 cc_bitbang_wait_reset(struct cc_bitbang *bb);
47 cc_bitbang_open(void);
50 cc_bitbang_close(struct cc_bitbang *bb);
53 cc_bitbang_debug_mode(struct cc_bitbang *bb);
56 cc_bitbang_reset(struct cc_bitbang *bb);
59 cc_bitbang_write(struct cc_bitbang *bb, uint8_t mask, uint8_t value);
62 cc_bitbang_read(struct cc_bitbang *bb, uint8_t *valuep);
65 cc_bitbang_sync(struct cc_bitbang *bb);
68 cc_bitbang_print(char *format, uint8_t mask, uint8_t set);
71 cc_bitbang_print(char *format, uint8_t mask, uint8_t set);
74 cc_bitbang_send(struct cc_bitbang *bb, uint8_t mask, uint8_t set);
77 cc_bitbang_send_bit(struct cc_bitbang *bb, uint8_t bit);
80 cc_bitbang_send_byte(struct cc_bitbang *bb, uint8_t byte);
83 cc_bitbang_send_bytes(struct cc_bitbang *bb, uint8_t *bytes, int nbytes);
86 cc_bitbang_recv_bit(struct cc_bitbang *bb, int first, uint8_t *bit);
89 cc_bitbang_recv_byte(struct cc_bitbang *bb, int first, uint8_t *bytep);
92 cc_bitbang_recv_bytes(struct cc_bitbang *bb, uint8_t *bytes, int nbytes);
94 #endif /* _CC_BITBANG_H_ */