gateware

A collection of little open source FPGA hobby projects
git clone http://frotz.net/git/gateware.git
Log | Files | Refs | README

ftdi.h (1733B)


      1 // Copyright 2015 Brian Swetland <swetland@frotz.net>
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 // http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 #ifndef _FTDI_H_
     16 #define _FTDI_H_
     17 
     18 typedef unsigned char u8;
     19 typedef unsigned short u16;
     20 typedef unsigned int u32;
     21 
     22 #define FTDI_GPIO_READ_LO		0x81
     23 #define FTDI_GPIO_READ_HI		0x83
     24 #define FTDI_GPIO_WRITE_LO		0x80 // Val Dir  (1=Out 0=In)
     25 #define FTDI_GPIO_WRITE_HI		0x82 // Val Dir  (1=Out 0=In)
     26 
     27 #define FTDI_LOOPBACK_OFF		0x85
     28 #define FTDI_CLOCK_DIV_1		0x8A
     29 #define FTDI_CLOCK_DIV_5		0x8B
     30 #define FTDI_DIVISOR_SET		0x86
     31 
     32 // TN = TX on Negative Clock Edge
     33 // TP = TX on Positive CLock Edge
     34 // byte transfers followed by LenLo LenHi (len-1) then data
     35 #define FTDI_MSB_TX_BYTES_TP		0x10
     36 #define FTDI_MSB_TX_BYTES_TN		0x11 //
     37 #define FTDI_MSB_IO_BYTES_TN_RP		0x31 //
     38 #define FTDI_MSB_IO_BYTES_TP_RN		0x34
     39 
     40 #define FTDI_LSB_TX_BYTES_TP		0x18
     41 #define FTDI_LSB_TX_BYTES_TN		0x19
     42 #define FTDI_LSB_IO_BYTES_TN_RP		0x39
     43 #define FTDI_LSB_IO_BYTES_TP_RN		0x3C
     44 
     45 typedef struct FTDI FTDI;
     46 
     47 FTDI *ftdi_open(void);
     48 int ftdi_read(FTDI *d, unsigned char *data, int count, int timeout_ms);
     49 int ftdi_send(FTDI *ftdi, void *data, int len, int timeout_ms);
     50 
     51 int ftdi_gpio_set_lo(FTDI *d, u8 val, u8 out);
     52 int ftdi_gpio_get_lo(FTDI *d);
     53 
     54 #endif