Lines Matching refs:mpsse
32 int raw_write(struct mpsse_context* mpsse, uint8_t* buf, int size) {
35 if (mpsse->mode) {
36 if (ftdi_write_data(&mpsse->ftdi, buf, size) == size) {
45 int raw_read(struct mpsse_context* mpsse, uint8_t* buf, int size) { in raw_read() argument
48 if (mpsse->mode) { in raw_read()
50 r = ftdi_read_data(&mpsse->ftdi, buf, size); in raw_read()
56 if (mpsse->flush_after_read) { in raw_read()
64 ftdi_usb_purge_rx_buffer(&mpsse->ftdi); in raw_read()
72 void set_timeouts(struct mpsse_context* mpsse, int timeout) { in set_timeouts() argument
73 if (mpsse->mode) { in set_timeouts()
74 mpsse->ftdi.usb_read_timeout = timeout; in set_timeouts()
75 mpsse->ftdi.usb_write_timeout = timeout; in set_timeouts()
92 uint8_t* build_block_buffer(struct mpsse_context* mpsse, in build_block_buffer() argument
105 if (mpsse->mode == I2C || (cmd & MPSSE_BITMODE)) { in build_block_buffer()
108 xfer_size = mpsse->xsize; in build_block_buffer()
120 if (mpsse->mode == I2C) { in build_block_buffer()
139 if (mpsse->mode == I2C) { in build_block_buffer()
141 buf[i++] = mpsse->pstart & ~SK; in build_block_buffer()
145 if (cmd == mpsse->rx) { in build_block_buffer()
146 buf[i++] = mpsse->tris & ~DO; in build_block_buffer()
148 buf[i++] = mpsse->tris; in build_block_buffer()
160 if (cmd == mpsse->tx || cmd == mpsse->txrx) { in build_block_buffer()
170 if (mpsse->mode == I2C) { in build_block_buffer()
173 if (cmd == mpsse->rx) { in build_block_buffer()
175 buf[i++] = mpsse->pstart & ~SK; in build_block_buffer()
176 buf[i++] = mpsse->tris; in build_block_buffer()
178 buf[i++] = mpsse->tx | MPSSE_BITMODE; in build_block_buffer()
180 buf[i++] = mpsse->tack; in build_block_buffer()
184 else if (cmd == mpsse->tx) { in build_block_buffer()
188 buf[i++] = mpsse->pstart & ~SK; in build_block_buffer()
189 buf[i++] = mpsse->tris & ~DO; in build_block_buffer()
191 buf[i++] = mpsse->rx | MPSSE_BITMODE; in build_block_buffer()
205 int set_bits_low(struct mpsse_context* mpsse, int port) { in set_bits_low() argument
210 buf[2] = mpsse->tris; in set_bits_low()
212 return raw_write(mpsse, (uint8_t*)&buf, sizeof(buf)); in set_bits_low()
216 int set_bits_high(struct mpsse_context* mpsse, int port) { in set_bits_high() argument
221 buf[2] = mpsse->trish; in set_bits_high()
223 return raw_write(mpsse, (uint8_t*)&buf, sizeof(buf)); in set_bits_high()
227 int gpio_write(struct mpsse_context* mpsse, int pin, int direction) { in gpio_write() argument
230 if (mpsse->mode == BITBANG) { in gpio_write()
232 mpsse->bitbang |= (1 << pin); in gpio_write()
234 mpsse->bitbang &= ~(1 << pin); in gpio_write()
237 if (set_bits_high(mpsse, mpsse->bitbang) == MPSSE_OK) { in gpio_write()
238 retval = raw_write(mpsse, (uint8_t*)&mpsse->bitbang, 1); in gpio_write()
242 if (pin < NUM_GPIOL_PINS && mpsse->status == STOPPED) { in gpio_write()
247 mpsse->pstart |= pin; in gpio_write()
248 mpsse->pidle |= pin; in gpio_write()
249 mpsse->pstop |= pin; in gpio_write()
251 mpsse->pstart &= ~pin; in gpio_write()
252 mpsse->pidle &= ~pin; in gpio_write()
253 mpsse->pstop &= ~pin; in gpio_write()
256 retval = set_bits_low(mpsse, mpsse->pstop); in gpio_write()
262 mpsse->gpioh |= (1 << pin); in gpio_write()
264 mpsse->gpioh &= ~(1 << pin); in gpio_write()
267 retval = set_bits_high(mpsse, mpsse->gpioh); in gpio_write()
275 int is_valid_context(struct mpsse_context* mpsse) { in is_valid_context() argument
276 return mpsse != NULL; in is_valid_context()