Download TE USB API - Trenz Electronic

Transcript
Appendix B. Example program source code
UM-FX2-USB-API (v 1.01) 7 May 2012
Appendix B. Example program source code
import sys
from ctypes import *
# FX2 Commands definition
CMD_FX2_READ_VERSION
= b'\x00'
CMD_FX2_INITALIZE
= b'\xA0'
CMD_FX2_READ_STATUS
= b'\xA1'
CMD_FX2_WRITE_REGISTER
= b'\xA2'
CMD_FX2_READ_REGISTER
= b'\xA3'
CMD_FX2_RESET_FIFO_STATUS
= b'\xA4'
CMD_FX2_FLASH_READ
= b'\xA5'
CMD_FX2_FLASH_WRITE
= b'\xA6'
CMD_FX2_FLASH_ERASE
= b'\xA7'
CMD_FX2_EEPROM_READ
= b'\xA8'
CMD_FX2_EEPROM_WRITE
= b'\xA9'
CMD_FX2_GET_FIFO_STATUS
= b'\xAC'
CMD_FX2_I2C_WRITE
= b'\xAD'
CMD_FX2_I2C_READ
= b'\xAE'
CMD_FX2_POWER_ON
= b'\xAF'
CMD_FX2_FLASH_WRITE_COMMAND
= b'\xAA'
CMD_FX2_SET_INTERRUPT
= b'\xB0'
CMD_FX2_GET_INTERRUPT
= b'\xB1'
print "FX2 API Example"
# Load dll
fx2dll = windll.LoadLibrary("TE0300DLL.dll")
# Scan for cards
cards = fx2dll.TE0300_ScanCards()
print "Found %d card(s)" % cards
if cards == 0:
print "ERROR: No cards to connect"
raw_input('Press Enter...')
sys.exit()
# connecting to card 1
m_handle = c_int(0)
if fx2dll.TE0300_Open(byref(m_handle), 0) != 0:
20/36
www.trenz-electronic.de
TE USB API