摘要:本應用筆記介紹怎樣使用MAX1233/MAX1234觸摸屏控制器的功能。所提供的簡化控制臺菜單系統支持對MAX1233/MAX1234器件寄存器的底層直接訪問。每一寄存器在32個SPI?時鐘周期內完成讀寫操作。軟件對每一寄存器使用簡短的助記名。使用MAX1234評估板(EV Kit)和MINIQUSB+命令模塊時,軟件支持最大底層控制。在隨附的zip文件中,提供所有源代碼。
MAX1233的工作方式和MAX1234一致,只是MAX1233采用3.3V供電,而不是5.0V。MAX1234評估板上的跳接器JU1使MAX1234工作在3.3V,以仿真MAX1233。
注意:符號"/" (例如,/CS)表示CS、PENIRQ、KEYIRQ和BUSY引腳為低電平有效。
內容目錄
MAX1233/MAX1234觸摸屏控制器入門
1.1) 需要的硬件
1.2) MINIQUSB+固件更新說明
1.3) 設置
1.4) 步驟
1.5) 解釋SPI data in實例格式
2) 模擬I/O實例
2.1) 控制DAC輸出電壓
2.2) 選擇ADC基準電源模式
2.3) 測量外部電壓輸入AUX1和AUX2
2.4) 將AUX1和AUX2轉換結果譯為物理值
2.5) 測量外部電壓輸入BAT1和BAT2
2.6) 將BAT1和BAT2轉換結果譯為物理值
2.7) 測量內部溫度TEMP1和TEMP2
2.8) 將TEMP1轉換結果譯為物理值
2.9) 將TEMP1和TEMP2轉換結果譯為物理值
2.10) 測量外部電壓輸入AUX1、AUX2、BAT1、BAT2和溫度
3) 觸摸屏實例
3.1) 低成本商用觸摸屏
3.2) 連接觸摸屏和評估板
3.3) 驗證觸摸屏的連接
3.4) 檢測觸摸屏操作:根據需要掃描
3.5) 檢測觸摸屏操作:自動掃描
4) 鍵盤和通用輸入/輸出引腳
4.1) 配置鍵盤和GPIO引腳
4.2) 讀寫GPIO引腳
4.3) 檢測按鍵:自動掃描
4.4) 從鍵盤中屏蔽單個按鍵
4.5) 從鍵盤中屏蔽一列
5) 管理功耗
6) 菜單系統
6.1) 寄存器讀/寫命令
6.2) 中斷和狀態引腳命令
6.3) 加入到更新后的MINIQUSB+固件中的命令
7) 結論
除了提高SPI接口的/CS時序之外,固件更新還包括中斷驅動脈沖累加器,在MAX1233/MAX1234配置為自動掃描模式時,支持驗證/PENIRQ和/KEYIRQ是否發送其自清除中斷脈沖。/PENIRQ的持續時間取決于所配置的ADC轉換率,/KEYIRQ的持續時間取決于所配置的開關反彈時間。
根據圖1來組裝硬件。
圖1. 硬件配置(在后面章節中連接觸摸屏)。
圖2. 系統圖片,使用一個3M內部連接器來連接MINIQUSB+和MAX1234評估板。
* DEMO1234 Command命令列出了輸入到DEMO1234.exe程序中的命令。
** Verification列出了可以進行的物理測試,驗證所執行的命令。
寄存器寫操作是0000 0000 a7-a0 d15-d0格式的32位SPI傳送過程。
寄存器讀操作是1000 0000 a7-a0 0000 0000格式的32位SPI傳送過程,在最后16位,接收到的數據從DOUT同步輸入。
對于AVDD = 3.3V ±5%,DACOUT滿量程范圍在2.65V和3.27V之間,通常為2.96V。
對于AVDD = 5.0V ±5%,DACOUT滿量程范圍在4.02V和4.97V之間,通常為4.48V。
表3. DAC輸出命令
對于第一次診斷,保持上電模式(ADC3210 = 0000,RES10 = 01)支持使用手持式DVM對基準電壓進行外部驗證。
ADC掃描選擇位設置為0000,寫入ADC控制寄存器(0x40),來設置ADC基準電源模式。RES1/RES0位選擇基準電源模式,基準控制位RFV選擇內部1.0V或者2.5V基準(請參考MAX1233/MAX1234數據資料的表13)。
ADC控制字:x x 0 0 0 0 RES1 RES0 x x x x x x x RFV
表4. 內部基準命令
表5. 外部基準命令
表10. 觸摸屏物理連接驗證命令序列
表11. 糾正觸摸屏連接問題
表12. 觸摸屏檢測命令序列:根據需要掃描
表13. 觸摸屏檢測命令序列:自動掃描
表14. 鍵盤和GPIO配置實例
表15. GPIO實例
表16. 按鍵命令序列:自動掃描
表17. 按鍵命令序列:屏蔽單個按鍵
表18. 按鍵命令序列:屏蔽鍵盤的一列
CmodComm測試程序主菜單—在連接前
A) adjust timing parameters
L) CmodLog... functions
C) connect
D) Debug Messages
X) exit
對C (連接)命令的響應
C
Hardware supports optimized native SMBus commands.
Board connected.
Got board banner: Maxim MINIQUSB V01.05.41 >
Firmware version is OK.
(configured for SPI auto-CS 4-byte mode) (SCLK=2MHz) ...
主菜單—連接后有效
T) Test the device
8) CmodP8Bus... functions
A) adjust timing parameters
L) CmodLog... functions
P) CmodPin... functions
S) CmodSpi... functions
M) CmodSMBus... functions
$) CmodCommStringWrite list of hex codes
R) CmodBoardReset
D) Disconnect
測試菜單命令—連接后有效
R) Read register
W) Write register
M0) measure no measurement; configure reference
M1) measure X,Y
M2) measure X,Y,Z1,Z2
M3) measure X
M4) measure Y
M5) measure Z1,Z2
M6) measure BAT1/4
M7) measure BAT2/4
M8) measure AUX1
M9) measure AUX2
MA) measure TEMP1
MB) measure BAT1/4,BAT2/4,AUX1,AUX2,TEMP1,TEMP2
MC) measure TEMP1,TEMP2
MD) no measurement; drive Y+,Y-
ME) no measurement; drive X+,X-
MF) no measurement; drive Y+,X-
.) Exit this menu
表21. 寫入寄存器助記符
表22. 觸摸屏測量命令序列
表25. 更新后MINIQUSB+固件01.05.41中的中斷脈沖累加器命令
MAX1233的工作方式和
注意:符號"/" (例如,/CS)表示CS、PENIRQ、KEYIRQ和BUSY引腳為低電平有效。
內容目錄
MAX1233/MAX1234觸摸屏控制器入門
1.1) 需要的硬件
1.2) MINIQUSB+固件更新說明
1.3) 設置
1.4) 步驟
1.5) 解釋SPI data in實例格式
2) 模擬I/O實例
2.1) 控制DAC輸出電壓
2.2) 選擇ADC基準電源模式
2.3) 測量外部電壓輸入AUX1和AUX2
2.4) 將AUX1和AUX2轉換結果譯為物理值
2.5) 測量外部電壓輸入BAT1和BAT2
2.6) 將BAT1和BAT2轉換結果譯為物理值
2.7) 測量內部溫度TEMP1和TEMP2
2.8) 將TEMP1轉換結果譯為物理值
2.9) 將TEMP1和TEMP2轉換結果譯為物理值
2.10) 測量外部電壓輸入AUX1、AUX2、BAT1、BAT2和溫度
3) 觸摸屏實例
3.1) 低成本商用觸摸屏
3.2) 連接觸摸屏和評估板
3.3) 驗證觸摸屏的連接
3.4) 檢測觸摸屏操作:根據需要掃描
3.5) 檢測觸摸屏操作:自動掃描
4) 鍵盤和通用輸入/輸出引腳
4.1) 配置鍵盤和GPIO引腳
4.2) 讀寫GPIO引腳
4.3) 檢測按鍵:自動掃描
4.4) 從鍵盤中屏蔽單個按鍵
4.5) 從鍵盤中屏蔽一列
5) 管理功耗
6) 菜單系統
6.1) 寄存器讀/寫命令
6.2) 中斷和狀態引腳命令
6.3) 加入到更新后的MINIQUSB+固件中的命令
7) 結論
1.1) 需要的硬件
- Maxim MAX1234評估板 (MAX1234EVKIT)
- Maxim MINIQUSB+ (包括USB A-B電纜和MINIQUSB-X+擴展板)
- Windows? 2000/XP PC,支持USB。
- 四線阻性觸摸屏(例如,PDA數字轉換器/玻璃屏等)
- 可選:測量DAC輸出電壓的DMM
- 可選:驅動AUX和BAT輸入的電壓源
- 可選:示波器,用于觀察/PENIRQ和/KEYIRQ引腳上的自動掃描中斷脈沖。
1.2) MINIQUSB+固件更新說明
MAX1233/MAX1234要求/CS引腳在第一次轉換結束之前,解除高電平置位;否則,ADC將無法存儲轉換結果。在使用本應用筆記之前,必須更新標準MINIQUSB+模塊固件,使SPI接口/CS引腳在第32個SCLK 1.4μs內解除置位。在2MHz時,32位自動/CS受控模式將/CS保持低電平21.70μs。只需要對MAXQ2000微控制器非易失閃存MINIQUSB+固件更新一次。這一新固件和標準01.05.39基本固件后向兼容。除了提高SPI接口的/CS時序之外,固件更新還包括中斷驅動脈沖累加器,在MAX1233/MAX1234配置為自動掃描模式時,支持驗證/PENIRQ和/KEYIRQ是否發送其自清除中斷脈沖。/PENIRQ的持續時間取決于所配置的ADC轉換率,/KEYIRQ的持續時間取決于所配置的開關反彈時間。
1.3) 設置
下載并解壓縮應用筆記文件 (ZIP, 2.4MB)。根據圖1來組裝硬件。
- 按照表1連接MAX1234評估板連接器J1和MINIQUSB-X+擴展電路板(包含在MINIQUSB+中)??梢圆捎?M?內部連接器922576-40來替代連接MAX1234評估板的焊線,將其插入到J1中,以提供方便的連接點。不要連接終端模塊TB1。
表1. MAX1234評估板和MINIQUSB+電路板之間的連接設置MAX1234 Signal MAX1234 EV Kit MINIQUSB-X+ MINIQUSB Signal GND J1-1 H2-8 GND VCC J1-7 H2-1 3.3V supply from MINIQUSB+ BUSY-Bar J1-27 H2-7 GPIO-K7 (MAXQ2000-INT2) PENIRQ-Bar J1-29 H1-3 GPIO-K6 (MAXQ2000-INT1) KEYIRQ-Bar J1-31 H1-8 GPIO-K5 (MAXQ2000-INT0) DOUT J1-35* H2-2 MISO (SPI master in, slave out) DIN J1-36* H2-5 MOSI (SPI master out, slave in) SCLK J1-37* H2-3 SCLK (SPI clock) CS-Bar J1-38 H2-4 CS-bar (SPI chip select) USB+5V J1-5 J4-7 USB+5V supply from PC
- 將MINIQUSB+插入到擴展板的頂部。
- 連接MINIQUSB+和PC的USB端口。如果這是MINIQUSB+第一次和PC連接,將出現即插即用向導。指南窗口將提示器件驅動器(它包含在隨附zip文件中)的安裝位置。
- 啟動固件更新批處理文件FWUPDATE.BAT來更新MINIQUSB+固件。
- 固件更新完成后,從PC的USB端口斷開MINIQUSB+。
圖1. 硬件配置(在后面章節中連接觸摸屏)。
圖2. 系統圖片,使用一個3M內部連接器來連接MINIQUSB+和MAX1234評估板。
1.4) 步驟
- 將MAX1234評估板跳接器JU1設置到“MAX1234”位置。
- 將MINIQUSB+連接至PC的USB端口。確定DACOUT電壓 = mid-scale (2.2V)。
- 啟動DEMO1234.EXE程序。屏幕上將出現控制臺。
- 在控制臺中輸入下面的命令序列。
DEMO1234 Command* |
Expected Program Output | SPI data in |
Verification** |
C |
Board connected. Got board banner: Maxim MINIQUSB V01.05.41 > Firmware version is OK. (configured for SPI auto-CS 4-byte mode) (SCLK=2MHz) ... |
||
T W DD FF |
Write_Register(regAddr=0x000b wr_DAC_data , data=0x00ff {(no bits defined for this register)}) result = 1 |
0x000b 0x00ff | DACOUT = full-scale (4.5V) |
T R DD |
Read_Register(regAddr=0x800b wr_DAC_data ) result = 1, buffer = 0x00ff = 255 {(no bits defined for this register)} |
0x800b 0x0000 | Data buffer = 0x00ff |
T W DD 80 |
Write_Register(regAddr=0x000b wr_DAC_data , data=0x0080 {(no bits defined for this register)}) result = 1 |
0x000b 0x0080 | DACOUT = mid-scale (2.2V) |
T R DD |
Read_Register(regAddr=0x800b wr_DAC_data ) result = 1, buffer = 0x0080 = 128 {(no bits defined for this register)} |
0x800b 0x0000 | data buffer = 0x0080 |
** Verification列出了可以進行的物理測試,驗證所執行的命令。
1.5) SPI data in實例格式
SPI data in一列列出了驅動至MAX1233/MAX1234 DIN引腳的SPI數據,采用了十六進制格式,最高有效字節在前。例如,序列0x000b 0x00ff中的SPI數據表示同步輸入到DIN的32位序列是0000 0000 0000 1011 0000 0000 1111 1111。第一位0用于寄存器寫操作,1用于寄存器讀操作。寄存器寫操作是0000 0000 a7-a0 d15-d0格式的32位SPI傳送過程。
寄存器讀操作是1000 0000 a7-a0 0000 0000格式的32位SPI傳送過程,在最后16位,接收到的數據從DOUT同步輸入。
2) 模擬I/O實例
下面的例子介紹了怎樣使用DEMO1234.EXE程序來控制DAC輸出,配置基準電壓,測量AUX1/AUX2/BAT1/BAT2電壓輸入,以及測量內部MAX1234溫度。2.1) 控制DAC輸出電壓
由兩個寄存器來控制DAC。寫入DAC數據寄存器來設置輸出電壓。寫入DAC控制寄存器來關斷或者對DAC上電。默認上電狀態是DAC加電,DAC輸出位于量程中部。DAC滿量程電壓通常為AVDD的90% (最小85%,最大95%)。對于AVDD = 3.3V ±5%,DACOUT滿量程范圍在2.65V和3.27V之間,通常為2.96V。
對于AVDD = 5.0V ±5%,DACOUT滿量程范圍在4.02V和4.97V之間,通常為4.48V。
表3. DAC輸出命令
DEMO1234 Command |
Action | SPI data in |
MAX1233 (3.3V) | MAX1234 (5.0V) |
T W DD FF |
DACOUT = full-scale | 0x000b 0x00ff |
DACOUT = 2.96V | DACOUT = 4.48V |
T W DD 00 |
DACOUT = 0V | 0x000b 0x0000 |
DACOUT = 0.0V | DACOUT = 0.0V |
T W DD 80 |
DACOUT = mid-scale | 0x000b 0x0080 |
DACOUT = 1.485V | DACOUT = 2.25V |
T W DC 8000 |
Disable DAC | 0x0042 0x8000 |
DACOUT = 0.0V | DACOUT = 0.0V |
T W DC 0 |
Enable DAC | 0x0042 0x0000 |
DACOUT = 1.485V | DACOUT = 2.25V |
2.2) 選擇ADC基準電源模式
ADC需要一個基準電壓。對于典型的嵌入式系統工作,默認設置是fine。在自動上電模式(ADC3210 = 0000,RES10 = 00)下,MAX1233/MAX1234提供自己的內部基準電壓。在每次測量之前,內部基準自動上電,測量完成后關斷。對于第一次診斷,保持上電模式(ADC3210 = 0000,RES10 = 01)支持使用手持式DVM對基準電壓進行外部驗證。
ADC掃描選擇位設置為0000,寫入ADC控制寄存器(0x40),來設置ADC基準電源模式。RES1/RES0位選擇基準電源模式,基準控制位RFV選擇內部1.0V或者2.5V基準(請參考MAX1233/MAX1234數據資料的表13)。
ADC控制字:x x 0 0 0 0 RES1 RES0 x x x x x x x RFV
表4. 內部基準命令
DEMO1234 Command |
Action | SPI data in |
Verification |
T W AC 0100 |
Internal 1V reference always powered; write ADC control word with ADC3210 = 0000, RES10 = 01, RFV = 0 |
0x0040 0x0100 |
Voltage at pin 12 REF is between 0.98V and 1.02V |
T W AC 0101 |
Internal 2.5V reference always powered; write ADC control word with ADC3210 = 0000, RES10 = 01, RFV = 1 |
0x0040 0x0101 |
Voltage at pin 12 REF is between 2.47V and 2.53V |
T W AC 0001 |
Internal 2.5V reference powered when needed; write ADC control word with ADC3210 = 0000, RES10 = 00, RFV = 1 |
0x0040 0x0001 |
Voltage at pin 12 REF will be powered only briefly as necessary |
表5. 外部基準命令
DEMO1234 Command |
Action | SPI data in |
T W AC 0300 |
External reference must be provided; ADC_control_wr_demand_scan:(write)demand scan ADC_control_AD0000:configure reference ADC_control_RES11:external reference |
0x0040 0x0300 |
2.3) 測量外部電壓輸入AUX1和AUX2
表6. ADC測量命令序列DEMO1234 Command |
Action (Triggered by A/D3210 Bits) | SPI data in |
T M8 |
Measure AUX1 with 12-bit resolution and 3.5μs conversion rate | 0x0040 0x2301 0x8007 0x0000 |
T W AC 2301 |
Trigger ADC scan of AUX1; ADC control word 0x2301 means: ADC_control_wr_demand_scan ADC_control_AD1000 /* measure AUX1 */ ADC_control_RES11 /* 12-bit resolution */ ADC_control_AVG00 /* no averaging */ ADC_control_CNR00 /* conversion rate 3.5μs */ ADC_control_RFV /* RFV=1: VREF=2.5V */ |
0x0040 0x2301 |
T R A1 |
Read AUX1 result AUX1_code | 0x8007 0x0000 |
T M9 |
Measure AUX2 with 12-bit resolution and 3.5μs conversion rate | 0x0040 0x2701 0x8008 0x0000 |
2.4) 將AUX1和AUX2轉換結果譯為物理值
下面的C/C++偽代碼片斷總結了DEMO1234程序是怎樣解釋AUX1和AUX2轉換結果的。/* ADC control resolution value selects num_codes 4096 (12-bit), 1024 (10-bit), or 256 (8-bit) */ int num_codes = 4096; /* ADC_control_RES11: 12-bit resolution */ /* Voltage that corresponds to the full-scale ADC code; may be internal 1V or 2.5V ref, or ext ref. */ double ADC_fullscale_voltage = 2.5; /* ADC_control_RFV=1: VREF=2.5V. RFV=0: VREF=1.0V. */ /* AUX1_code is the 16-bit result read by SPI command 0x8007 */ double AUX1_Voltage = (AUX1_code * ADC_fullscale_voltage) / num_codes; /* AUX2_code is the 16-bit result read by SPI command 0x8008 */ double AUX2_Voltage = (AUX2_code * ADC_fullscale_voltage) / num_codes;
2.5) 測量外部電壓輸入BAT1和BAT2
表7. ADC測量命令序列DEMO1234 Command |
Action (Triggered by A/D3210 Bits) | SPI data in |
T M6 |
Measure BAT1 with 12-bit resolution and 3.5μs conversion rate | 0x0040 0x1b01 0x8005 0x0000 |
T W AC 1b01 |
Trigger ADC scan of BAT1; ADC control word 0x1b01 means: ADC_control_wr_demand_scan ADC_control_AD0110 /* measure BAT1 */ ADC_control_RES11 /* 12-bit resolution */ ADC_control_AVG00 /* no averaging */ ADC_control_CNR00 /* conversion rate 3.5μs */ ADC_control_RFV /* RFV=1: VREF=2.5V */ |
0x0040 0x1b01 |
T R B1 |
Read BAT1 result BAT1_code | 0x8005 0x0000 |
T W AC 1b21 |
Trigger ADC scan of BAT1; ADC control word 0x1b21 means: ADC_control_wr_demand_scan ADC_control_AD0110 /* measure BAT1 */ ADC_control_RES11 /* 12-bit resolution */ ADC_control_AVG00 /* no averaging */ ADC_control_CNR10 /* conversion rate 10μs */ ADC_control_RFV /* RFV=1: VREF=2.5V */ |
0x0040 0x1b21 |
T R B1 |
Read BAT1 result BAT1_code | 0x8005 0x0000 |
T M7 |
Measure BAT2 with 12-bit resolution and 3.5μs conversion rate | 0x0040 0x1f01 0x8006 0x0000 |
2.6) 將BAT1和BAT2轉換結果譯為物理值
下面的C/C++偽代碼片斷總結了DEMO1234程序是怎樣解釋BAT1和BAT2轉換結果的。注意:通過一個4:1輸入分配器來測量BAT1和BAT2。/* ADC control resolution value selects num_codes 4096 (12-bit), 1024 (10-bit), or 256 (8-bit) */ int num_codes = 4096; /* ADC_control_RES11: 12-bit resolution */ /* Voltage that corresponds to the full-scale ADC code; may be internal 1V or 2.5V ref, or ext ref. */ double ADC_fullscale_voltage = 2.5; /* ADC_control_RFV=1: VREF=2.5V. RFV=0: VREF=1.0V. */ /* Note: BAT1 and BAT2 measure through a 4:1 input divider. */ /* BAT1_code is the 16-bit result read by SPI command 0x8005 */ double BAT1_Voltage = 4 * (BAT1_code * ADC_fullscale_voltage) / num_codes; /* BAT2_code is the 16-bit result read by SPI command 0x8006 */ double BAT2_Voltage = 4 * (BAT2_code * ADC_fullscale_voltage) / num_codes;
2.7) 測量內部溫度TEMP1和TEMP2
表8. ADC測量命令序列DEMO1234 Command |
Action (Triggered by A/D3210 Bits) | SPI data in |
T MA |
Measure TEMP1 with 12-bit resolution and 3.5μs conversion rate | 0x0040 0x2b01 0x8009 0x0000 |
T W AC 2b01 |
Trigger ADC scan of TEMP1; ADC control word 0x2b01 means: ADC_control_wr_demand_scan ADC_control_ AD1010 /* measure TEMP1 */ ADC_control_RES11 /* 12-bit resolution */ ADC_control_AVG00 /* no averaging */ ADC_control_CNR00 /* conversion rate 3.5μs */ ADC_control_RFV /* RFV=1: VREF=2.5V */ |
0x0040 0x2b01 |
T R T1 |
Read TEMP1 result TEMP1 _code | 0x8009 0x0000 |
T MC |
Measure TEMP1, TEMP2 with 12-bit resolution and 3.5μs conversion rate | 0x0040 0x3301 0x8009 0x0000 0x800a 0x0000 |
T W AC 3301 |
Trigger ADC scan of TEMP1 and TEMP2; ADC control word 0x3301 means: ADC_control_wr_demand_scan ADC_control_ AD1100 /* measure TEMP1,TEMP2 */ ADC_control_RES11 /* 12-bit resolution */ ADC_control_AVG00 /* no averaging */ ADC_control_CNR00 /* conversion rate 3.5μs */ ADC_control_RFV /* RFV=1: VREF=2.5V */ |
0x0040 0x3301 |
T R T1 |
Read TEMP1 result TEMP1 _code | 0x8009 0x0000 |
T R T2 |
Read TEMP2 result TEMP2 _code | 0x800a 0x0000 |
2.8) 將TEMP1轉換結果譯為物理值
下面的C/C++偽代碼片斷總結了DEMO1234程序是怎樣解釋TEMP1轉換結果的。/* ADC control resolution value selects num_codes 4096 (12-bit), 1024 (10-bit), or 256 (8-bit) */ int num_codes = 4096; /* ADC_control_RES11: 12-bit resolution */ /* Voltage that corresponds to the full-scale ADC code; may be internal 1V or 2.5V ref, or ext ref. */ double ADC_fullscale_voltage = 2.5; /* ADC_control_RFV=1: VREF=2.5V. RFV=0: VREF=1.0V. */ /* TEMP1_code is the 16-bit result read by SPI command 0x8009 */ double TEMP1_Voltage = (TEMP1_code * ADC_fullscale_voltage) / num_codes; /* Calibration values */ const double Temp1V_Room = 0.590; // temp1 voltage at room temperature 25C const double Temp1K_Room = 298.15; // Room temperature Kelvins (298.15K=25C) const double Temp1V_Per_K = -0.002; // TempCo -2mV per degree C /* Convert to absolute temperature */ double Kelvin = (TEMP1_Voltage - Temp1V_Room) / Temp1V_Per_K + Temp1K_Room; /* Optional conversion to commonly used temperature units */ double Centigrade = Kelvin - 273.15; double Fahrenheit = (Centigrade * 9.0 / 5.0) + 32;
2.9) 將TEMP1和TEMP2轉換結果譯為物理值
下面的C/C++偽代碼片斷總結了DEMO1234程序是怎樣解釋TEMP1和TEMP2轉換結果的。TEMP2只在和TEMP1對比時才有意義。/* ADC control resolution value selects num_codes 4096 (12-bit), 1024 (10-bit), or 256 (8-bit) */ int num_codes = 4096; /* ADC_control_RES11: 12-bit resolution */ /* Voltage that corresponds to the full-scale ADC code; may be internal 1V or 2.5V ref, or ext ref. */ double ADC_fullscale_voltage = 2.5; /* ADC_control_RFV=1: VREF=2.5V. RFV=0: VREF=1.0V. */ /* TEMP1_code is the 16-bit result read by SPI command 0x8009 */ double TEMP1_Voltage = (TEMP1_code * ADC_fullscale_voltage) / num_codes; /* TEMP2_code is the 16-bit result read by SPI command 0x800a */ double TEMP2_Voltage = (TEMP2_code * ADC_fullscale_voltage) / num_codes; /* Calibration values */ const double K_Per_Temp21_Delta_V = 2680.0; // nominal 2680 5/27/2002 /* Convert to absolute temperature */ double Kelvin = (TEMP2_Voltage - TEMP1_Voltage) * K_Per_Temp21_Delta_V; /* Optional conversion to commonly used temperature units */ double Centigrade = Kelvin - 273.15; double Fahrenheit = (Centigrade * 9.0 / 5.0) + 32;
2.10) 測量外部電壓輸入AUX1、AUX2、BAT1、BAT2和溫度
表9. ADC測量命令序列DEMO1234 Command |
Action (Triggered by A/D3210 Bits) | SPI data in |
T MB |
Measure BAT1/4, BAT2/4, AUX1, AUX2, TEMP1, TEMP2 with 12-bit resolution and 3.5μs conversion rate | 0x0040 0x2f01 0x8005 0x0000 0x8006 0x0000 0x8007 0x0000 0x8008 0x0000 0x8009 0x0000 0x800a 0x0000 |
T W AC 2f01 |
Trigger ADC scan of BAT1-2, AUX1-2, TEMP1-2; ADC control word 0x2f01 means: ADC_control_wr_demand_scan ADC_control_ AD1011 /* measure AUX1 etc. */ ADC_control_RES11 /* 12-bit resolution */ ADC_control_AVG00 /* no averaging */ ADC_control_CNR00 /* conversion rate 3.5μs */ ADC_control_RFV /* RFV=1: VREF=2.5V */ |
0x0040 0x2f01 |
T R B1 |
Read BAT1 result BAT1 _code | 0x8005 0x0000 |
T R B2 |
Read BAT2 result BAT2_code | 0x8006 0x0000 |
T R A1 |
Read AUX1 result AUX1 _code | 0x8007 0x0000 |
T R A2 |
Read AUX2 result AUX2 _code | 0x8008 0x0000 |
T R T1 |
Read TEMP1 result TEMP1 _code | 0x8009 0x0000 |
T R T2 |
Read TEMP2 result TEMP2 _code | 0x800a 0x0000 |
3) 觸摸屏實例
下面的例子解釋了怎樣使用DEMO1234.EXE程序來獲得觸摸屏數據。3.1) 低成本商用觸摸屏
在互聯網上搜索"PDA Digitizer/Glasstop",尋找合適的替代觸摸屏。高清觸摸屏玻璃的價格范圍在50美元至10美元之間,價格取決于型號以及玻璃是否全部貼在顯示屏上。3.2) 連接觸摸屏和評估板
MAX1234評估板提供突出插頭H5/H6來連接10mm柔性電纜或者長度更短的電纜。H6連接器的間距是0.5mm,比實際觸摸屏柔性電纜間距更精細。把柔性電纜插入H6,上鎖,選擇位于四條柔性電纜中每一電纜中心位置的H5引腳。跳接器連接H5和標有U1的X+、Y+、X-以及Y-測試點。3.3) 檢驗觸摸屏的連接
第一次連接觸摸屏時,通過下面的步驟來驗證X和Y連接是否正確。可以有幾個觸摸屏交叉連接,但大部分不會正常工作。在這些例子中,我們假設X- = left,X+ = right,Y- = top,Y+ = bottom。表10. 觸摸屏物理連接驗證命令序列
DEMO1234 Command |
Action | SPI data in |
Verification |
? | Connect DVM to X+/GND | ? | ? |
T MD |
No measurement; drive Y+,Y- | 0x0040 0x3701 |
|
Touch top left | X+ = approx. Y- | ||
Touch top right | X+ = approx. Y- | ||
Touch bottom left | X+ = approx. Y+ | ||
Touch bottom right | X+ = approx. Y+ | ||
Connect DVM to Y+/GND | |||
T ME |
No measurement; drive X+,X- | 0x0040 0x3b01 |
|
Touch top left | Y+ = approx. X- | ||
Touch top right | Y+ = approx. X+ | ||
Touch bottom left | Y+ = approx. X- | ||
Touch bottom right | Y+ = approx. X+ |
表11. 糾正觸摸屏連接問題
Symptom | Correction |
Touch coordinates are mirrored top-to-bottom | Swap the Y+ and Y- connections |
Touch coordinates are mirrored left-to-right | Swap the X+ and X- connections |
Touch coordinates are rotated 180 degrees | Swap the X+ and X- connections, and swap the Y+ and Y- connections |
Touch coordinates are mirrored diagonally | Swap the X+ and Y+ connections, and swap the X- and Y- connections |
Touch coordinates do not seem to track, and the distortion is not a simple flip/rotate/mirror transformation | Swap the X+ and Y+ connections; if distortion persists, swap the X+ and Y- connections; if distortion still persists, disconnect touch screen and use DVM to verify X+ to X- resistance and Y+ to Y- resistance; verify with no touch X+ and X- are isolated from Y+ and Y- |
3.4) 檢測觸摸屏的操作:根據需要掃描
在配置MAX1234檢測觸摸屏操作,根據需要數字化接觸屏的位置時,寫入寄存器0x40 (ADC控制),其PENSTS=0,ADSTS=0 (請參考MAX1233/MAX1234數據資料的表6)。讀取寄存器0x00 (X軸)后,檢測到后續的觸摸屏操作時,/PENIRQ信號鎖存至低電平,在寫入ADC控制寄存器測量X、Y軸之前,保持低電平。表12. 觸摸屏檢測命令序列:根據需要掃描
DEMO1234 Command |
Action | SPI data in |
Verification |
T W AC 0b01 |
Demand scan | 0x0040 0x0b01 |
|
T R AX |
Read conversion result register X | 0x8000 0x0000 |
|
P R 6 |
Read PENIRQ-bar pin status | PENIRQ = 1 | |
Touch the touch screen | |||
P R 6 |
Read PENIRQ-bar pin status | PENIRQ = 0 | |
T M2 |
Measure X,Y,Z1,Z2 | 0x0040 0x0b01 0x8000 0x0000 0x8001 0x0000 0x8002 0x0000 0x8003 0x0000 |
|
P R 6 |
Read PENIRQ-bar pin status | PENIRQ = 1 | |
Touch and hold the touch screen | |||
P R 6 |
Read PENIRQ-bar pin status | PENIRQ = 0 | |
T M2 |
Measure X,Y,Z1,Z2 | 0x0040 0x0b01 0x8000 0x0000 0x8001 0x0000 0x8002 0x0000 0x8003 0x0000 |
|
P R 6 |
Read PENIRQ-bar pin status | PENIRQ = 0 | |
T M2 |
Measure X,Y,Z1,Z2 | 0x0040 0x0b01 0x8000 0x0000 0x8001 0x0000 0x8002 0x0000 0x8003 0x0000 |
|
P R 6 |
Read PENIRQ-bar pin status | PENIRQ = 0 | |
Release the touch screen | |||
P R 6 |
Read PENIRQ-bar pin status | PENIRQ = 0 | |
T M2 |
Measure X,Y,Z1,Z2 | 0x0040 0x0b01 0x8000 0x0000 0x8001 0x0000 0x8002 0x0000 0x8003 0x0000 |
|
P R 6 |
Read PENIRQ-bar pin status | PENIRQ = 1 |
3.5) 檢測觸摸屏操作:自動掃描
在檢測觸摸屏操作,配置MAX1234,自動數字化觸摸屏的接觸位置時,寫入寄存器0x40 (ADC控制),其PENSTS=1,ADSTS=0 (請參考MAX1233/MAX1234數據資料的表6)。第一次接觸屏幕時,/PENIRQ信號暫時變為低電平,并在讀取X寄存器之前不會變化。表13. 觸摸屏檢測命令序列:自動掃描
DEMO1234 Command |
Action | SPI data in |
Verification |
Optional: connect oscilloscope to PENIRQ-bar | |||
I C 1 3 |
Configure PENIRQ-bar pulse accumulator: falling-edge trigger | ||
I 0 1 |
Reset the pulse accumulator | ||
I R 1 |
Read the number of times PENIRQ-bar has pulsed low | count = 0 | |
T W AC 8bff |
Wait for touch, then scan X,Y,Z1,Z2 | 0x0040 0x8bff |
|
Touch the touch screen | PENIRQ pulse | ||
I R 1 |
Read the number of times PENIRQ-bar has pulsed low | count has increased | |
T R P |
Read X,Y,Z1,Z2 conversion results | 0x8000 0x0000 0x8001 0x0000 0x8002 0x0000 0x8003 0x0000 |
|
Touch the touch screen | PENIRQ pulse | ||
I R 1 |
Read the number of times PENIRQ-bar has pulsed low | count has increased | |
T R P |
Read X,Y,Z1,Z2 conversion results | 0x8000 0x0000 0x8001 0x0000 0x8002 0x0000 0x8003 0x0000 |
|
Touch the touch screen | PENIRQ pulse | ||
I R 1 |
Read the number of times PENIRQ-bar has pulsed low | count has increased | |
T R P |
Read X,Y,Z1,Z2 conversion results | 0x8000 0x0000 0x8001 0x0000 0x8002 0x0000 0x8003 0x0000 |
4) 鍵盤和通用輸入/輸出引腳
下面的例子介紹了怎樣使用DEMO1234.EXE程序來掃描鍵盤,怎樣使用GPIO鍵盤掃描引腳。4.1) 配置鍵盤和GPIO引腳
GPIO控制寄存器將每個C1–C4和R1–R4引腳分別配置為輸入、輸出或者是鍵盤的一部分(請參考MAX1233/MAX1234數據資料的表26和表27)。此外,寫入GPIO上拉禁止寄存器,將輸出引腳配置為開漏輸出。表14. 鍵盤和GPIO配置實例
DEMO1234 Command |
Action | SPI data in |
T W GC FFFF |
Keypad: none; GPIO outputs: C4,C3,C2,C1,R4,R3,R2,R1; GPIO inputs: none |
0x004f 0xffff |
T W GC FF00 |
Keypad: none; GPIO outputs: none; GPIO inputs: C4,C3,C2,C1,R4,R3,R2,R1 |
0x004f 0xff00 |
T W GC 0000 |
Keypad: (C4,C3,C2,C1) x (R4,R3,R2,R1); GPIO outputs: none; GPIO inputs: none |
0x004f 0x0000 |
T W GC C8C0 |
Keypad: (C2,C1) x (R3,R2,R1); GPIO outputs: C4,C3; GPIO input: R4 |
0x004f 0xc8c0 |
T W GP 4000 |
GPIO pullup disable: C3 | 0x004e 0x4000 |
4.2) 讀寫GPIO引腳
GPIO數據寄存器讀取GPIO輸入引腳,寫入GPIO輸出引腳。注意:在這些例子中,C3、C4和R4是引腳名稱,而不是元件名稱。表15. GPIO實例
DEMO1234 Command |
Action | SPI data in |
Verification |
T W GC C8C0 |
Keypad: (C2,C1) x (R3,R2,R1); GPIO outputs: C4,C3; GPIO input: R4 |
0x004f 0xc8c0 |
|
T W GP 4000 |
GPIO pullup disable: C3 | 0x004e 0x4000 |
|
Connect external resistor between C3 pin and DVDD | |||
Connect DVM to C4 pin | |||
T W GD 8000 |
GPIO write C4 = 1 | 0x000f 0x8000 |
C4 pin = high |
T W GD 0000 |
GPIO write C4 = 0 | 0x000f 0x0000 |
C4 pin = low |
T W GD 8000 |
GPIO write C4 = 1 | 0x000f 0x8000 |
C4 pin = high |
T W GD 0000 |
GPIO write C4 = 0 | 0x000f 0x0000 |
C4 pin = low |
Connect DVM to C3 pin | |||
T W GD 4000 |
GPIO write C3 = 1 | 0x000f 0x4000 |
C3 pin = high |
T W GD 0000 |
GPIO write C3 = 0 | 0x000f 0x0000 |
C3 pin = low |
T W GD 4000 |
GPIO write C3 = 1 | 0x000f 0x4000 |
C3 pin = high |
T W GD 0000 |
GPIO write C3 = 0 | 0x000f 0x0000 |
C3 pin = low |
Connect R4 pin to DVDD | |||
T R GD |
GPIO read | 0x800f 0x0000 |
Buffer = 0x0800 |
Connect R4 pin to GND | |||
T R GD |
GPIO read | 0x800f 0x0000 |
Buffer = 0x0000 |
4.3) 檢測按鍵:自動掃描
可以配置鍵盤控制寄存器在探測到有按鍵按下時,自動掃描鍵盤。表16. 按鍵命令序列:自動掃描
DEMO1234 Command |
Action | SPI data in |
Verification |
Optional: connect oscilloscope to KEYIRQ-bar | |||
I C 0 3 |
Configure KEYIRQ-bar pulse accumulator: falling-edge trigger | ||
I 0 0 |
Reset the pulse accumulator | ||
I R 0 |
Read the number of times KEYIRQ-bar has pulsed low | count = 0 | |
T W GC 0000 |
Keypad: (C4,C3,C2,C1) x (R4,R3,R2,R1); GPIO outputs: none; GPIO inputs: none |
0x004f 0x0000 |
|
T W KC bf00 |
Wait for keypress; maximum debounce and hold times |
0x0041 0xbf00 |
|
Press and release R1C1 (key "1") | KEYIRQ pulse | ||
I R 0 |
Read the number of times KEYIRQ-bar has pulsed low | count has increased | |
T R KB |
Read raw keypad result | 0x8004 0x0000 |
0x0001 = R1C1 key |
Press and release R2C2 (key "5") | KEYIRQ pulse | ||
I R 0 |
Read the number of times KEYIRQ-bar has pulsed low | count has increased | |
T R KB |
Read raw keypad result | 0x8004 0x0000 |
0x0020 = R2C2 key |
Press and release R3C2 (key "8") | KEYIRQ pulse | ||
I R 0 |
Read the number of times KEYIRQ-bar has pulsed low | count has increased | |
T R KB |
Read raw keypad result | 0x8004 0x0000 |
0x0040 = R3C2 key |
4.4) 從鍵盤中屏蔽單個按鍵
使用鍵盤屏蔽寄存器和鍵盤2結果寄存器來屏蔽每個按鍵。屏蔽掉的按鍵被掃描至KPD寄存器,但是不在鍵盤2結果寄存器中報告。表17. 按鍵命令序列:屏蔽單個按鍵
DEMO1234 Command |
Action | SPI data in |
Verification |
T W GC 0000 |
Keypad: (C4,C3,C2,C1) x (R4,R3,R2,R1); GPIO outputs: none; GPIO inputs: none |
0x004f 0x0000 |
|
T W KC bf00 |
Wait for keypress; maximum debounce and hold times |
0x0041 0xbf00 |
|
T W KM 0020 |
Mask only R2C2 key | 0x0050 0x0020 |
|
Press and release R1C1 (key "1") | |||
T R KB |
Read raw keypad result | 0x8004 0x0000 |
0x0001 = R1C1 key |
T R K2 |
Read masked keypad result | 0x8011 0x0000 |
0x0001 = R1C1 key |
Press and release R2C2 (key "5") | |||
T R KB |
Read raw keypad result | 0x8004 0x0000 |
0x0020 = R2C2 key |
T R K2 |
Read masked keypad result | 0x8011 0x0000 |
0x0000 = no key |
Press and release R3C2 (key "8") | |||
T R KB |
Read raw keypad result | 0x8004 0x0000 |
0x0040 = R3C2 key |
T R K2 |
Read masked keypad result | 0x8011 0x0000 |
0x0040 = R3C2 key |
4.5) 從鍵盤中屏蔽一列
使用鍵盤列寄存器來屏蔽所有列。不掃描屏蔽列,因此,KPD寄存器不會探測這些列中的按鍵。表18. 按鍵命令序列:屏蔽鍵盤的一列
DEMO1234 Command |
Action | SPI data in |
Verification |
T W GC 0000 |
Keypad: (C4,C3,C2,C1) x (R4,R3,R2,R1); GPIO outputs: none; GPIO inputs: none |
0x004f 0x0000 |
|
T W KC bf00 |
Wait for keypress; maximum debounce and hold times |
0x0041 0xbf00 |
|
T W KK 2000 |
Mask entire C2 column | 0x0051 0x2000 |
|
Press and release R1C1 (key "1") | |||
T R KB |
Read raw keypad result | 0x8004 0x0000 |
0x0001 = R1C1 key |
Press and release R2C2 (key "5") | |||
T R KB |
Read raw keypad result | 0x8004 0x0000 |
(previous value) |
Press and release R3C2 (key "8") | |||
T R KB |
Read raw keypad result | 0x8004 0x0000 |
(previous value) |
Press and release R2C3 (key "6") | |||
T R KB |
Read raw keypad result | 0x8004 0x0000 |
0x0200 = R2C3 key |
5) 電源管理
表19. 關斷命令DEMO1234 Command |
Action | SPI data in |
Verification |
T W AC C000 |
Power off ADC | 0x0040 0xc000 |
— |
T W AC 0300 |
Power off internal reference | 0x0040 0x0300 |
REF = not driven |
T W DC 8000 |
Disable DAC | 0x0042 0x8000 |
DACOUT = 0.0V |
T W KC C000 |
Power off keypad | 0x0041 0xc000 |
— |
6) 菜單系統
全部源代碼實現下面的控制臺菜單系統,它連接至MINIQUSB+模塊。CmodComm測試程序主菜單—在連接前
A) adjust timing parameters
L) CmodLog... functions
C) connect
D) Debug Messages
X) exit
對C (連接)命令的響應
C
Hardware supports optimized native SMBus commands.
Board connected.
Got board banner: Maxim MINIQUSB V01.05.41 >
Firmware version is OK.
(configured for SPI auto-CS 4-byte mode) (SCLK=2MHz) ...
主菜單—連接后有效
T) Test the device
8) CmodP8Bus... functions
A) adjust timing parameters
L) CmodLog... functions
P) CmodPin... functions
S) CmodSpi... functions
M) CmodSMBus... functions
$) CmodCommStringWrite list of hex codes
R) CmodBoardReset
D) Disconnect
測試菜單命令—連接后有效
R) Read register
W) Write register
M0) measure no measurement; configure reference
M1) measure X,Y
M2) measure X,Y,Z1,Z2
M3) measure X
M4) measure Y
M5) measure Z1,Z2
M6) measure BAT1/4
M7) measure BAT2/4
M8) measure AUX1
M9) measure AUX2
MA) measure TEMP1
MB) measure BAT1/4,BAT2/4,AUX1,AUX2,TEMP1,TEMP2
MC) measure TEMP1,TEMP2
MD) no measurement; drive Y+,Y-
ME) no measurement; drive X+,X-
MF) no measurement; drive Y+,X-
.) Exit this menu
6.1) 寄存器讀/寫命令
表20. 讀取寄存器助記符DEMO1234 Command |
Mnemonic | SPI data in |
T R A1 |
Test Read AUX1 register | 0x8007 0x0000 |
T R A2 |
Test Read AUX2 register | 0x8008 0x0000 |
T R AC |
Test Read ADC_control register | 0x8040 0x0000 |
T R AX |
Test Read X register | 0x8000 0x0000 |
T R AY |
Test Read Y register | 0x8001 0x0000 |
T R AZ1 |
Test Read Z1 register | 0x8002 0x0000 |
T R AZ2 |
Test Read Z2 register | 0x8003 0x0000 |
T R B1 |
Test Read BAT1 register | 0x8005 0x0000 |
T R B2 |
Test Read BAT2 register | 0x8006 0x0000 |
T R DC |
Test Read DAC_control register | 0x8042 0x0000 |
T R DD |
Test Read DAC_data register | 0x800b 0x0000 |
T R GC |
Test Read GPIO_control register | 0x804f 0x0000 |
T R GD |
Test Read GPIO_data register | 0x800f 0x0000 |
T R GP |
Test Read GPIO_pullup register | 0x804e 0x0000 |
T R K1 |
Test Read KPDATA1 register | 0x8010 0x0000 |
T R K2 |
Test Read KPDATA2 register | 0x8011 0x0000 |
T R KB |
Test Read KPD register | 0x8004 0x0000 |
T R KC |
Test Read KEY_control register | 0x8041 0x0000 |
T R KK |
Test Read KPCOLMASK register | 0x8051 0x0000 |
T R KM |
Test Read KPKEYMASK register | 0x8050 0x0000 |
T R T1 |
Test Read TEMP1 register | 0x8009 0x0000 |
T R T2 |
Test Read TEMP2 register | 0x800a 0x0000 |
表21. 寫入寄存器助記符
DEMO1234 Command |
Mnemonic | SPI data in |
T W AC hexValue |
Test Write ADC_control register | 0x0040 hexValue |
T W DC hexValue |
Test Write DAC_control register | 0x0042 hexValue |
T W DD hexValue |
Test Write DAC_data register | 0x000b hexValue |
T W GC hexValue |
Test Write GPIO_control register | 0x004f hexValue |
T W GD hexValue |
Test Write GPIO_data register | 0x000f hexValue |
T W GP hexValue |
Test Write GPIO_pullup register | 0x004e hexValue |
T W KC hexValue |
Test Write KEY_control register | 0x0041 hexValue |
T W KK hexValue |
Test Write KPCOLMASK register | 0x0051 hexValue |
T W KM hexValue |
Test Write KPKEYMASK register | 0x0050 hexValue |
表22. 觸摸屏測量命令序列
DEMO1234 Command |
Action (Triggered by A/D3210 Bits) | SPI data in Sequence |
T M1 |
Measure X,Y | 0x0040 0x07010x8000 0x00000x8001 0x0000 |
T M2 |
Measure X,Y,Z1,Z2 | 0x0040 0x0b010x8000 0x00000x8001 0x00000x8002 0x00000x8003 0x0000 |
T M3 |
Measure X | 0x0040 0x0f010x8000 0x0000 |
T M4 |
Measure Y | 0x0040 0x13010x8001 0x0000 |
T M5 |
Measure Z1,Z2 | 0x0040 0x17010x8002 0x00000x8003 0x0000 |
T MD |
No measurement; drive Y+,Y- | 0x0040 0x3701 |
T ME |
No measurement; drive X+,X- | 0x0040 0x3b01 |
T MF |
No measurement; drive Y+,X- | 0x0040 0x3f01 |
6.2) 中斷和狀態引腳命令
表23. 引腳狀態讀取命令DEMO1234 Command |
Action | SPI data in |
P R 5 |
Read KEYIRQ-bar pin status | N/A |
I C 0 3 |
Enable KEYIRQ-bar falling-edge trigger pulse accumulator | N/A |
I C 0 1 |
Enable KEYIRQ-bar rising-edge trigger pulse accumulator | N/A |
I C 0 0 |
Disable KEYIRQ-bar pulse accumulator | N/A |
I R 0 |
Read the number of times KEYIRQ-bar has pulsed low | N/A |
I 0 0 |
Clear the KEYIRQ-bar pulse accumulator | N/A |
P R 6 |
Read PENIRQ-bar pin status | N/A |
I C 1 3 |
Enable PENIRQ-bar falling-edge trigger pulse accumulator | N/A |
I C 1 1 |
Enable PENIRQ-bar rising-edge trigger pulse accumulator | N/A |
I C 1 0 |
Disable PENIRQ-bar pulse accumulator | N/A |
I R 1 |
Read the number of times PENIRQ-bar has pulsed low | N/A |
I 0 1 |
Clear the PENIRQ-bar pulse accumulator | N/A |
P R 7 |
Read BUSY-bar pin status | N/A |
6.3) 加入到更新后的MINIQUSB+固件中的命令
表24. 更新后MINIQUSB+固件01.05.40支持的SPI命令DEMO1234 Command |
Action | CPOL | CPHA | CS-Bar Control | AF Length |
S C L0 |
Configure SPI for CPOL=0 | 0 | — | GPIO-K9 | 1 byte |
S C L1 |
Configure SPI for CPOL=1 | 1 | — | GPIO-K9 | 1 byte |
S C A0 |
Configure SPI for CPHA=0 | — | 0 | GPIO-K9 | 1 byte |
S C A1 |
Configure SPI for CPHA=1 | — | 1 | GPIO-K9 | 1 byte |
S C C0 |
Configure SPI for 8-bit | — | — | GPIO-K9 | 1 byte |
S C C1 |
Configure SPI for 8-bit auto-CS-bar | — | — | Automatic | 1 byte |
S C C2 |
Configure SPI for 16-bit auto-CS-bar | — | — | Automatic | 2 bytes |
S C C3 |
Configure SPI for 24-bit auto-CS-bar | — | — | Automatic | 3 bytes |
S C C4 |
Configure SPI for 32-bit auto-CS-bar | — | — | Automatic | 4 bytes |
$ 2 AE 00 |
Configure SPI for 8-bit | 0 | 0 | GPIO-K9 | 1 byte |
$ 2 AE 01 |
Configure SPI for 8-bit | 0 | 1 | GPIO-K9 | 1 byte |
$ 2 AE 02 |
Configure SPI for 8-bit | 1 | 0 | GPIO-K9 | 1 byte |
$ 2 AE 03 |
Configure SPI for 8-bit | 1 | 1 | GPIO-K9 | 1 byte |
$ 2 AE 08 |
Configure SPI for 8-bit auto-CS-bar | 0 | 0 | Automatic | 1 byte |
$ 2 AE 09 |
Configure SPI for 8-bit auto-CS-bar | 0 | 1 | Automatic | 1 byte |
$ 2 AE 0A |
Configure SPI for 8-bit auto-CS-bar | 1 | 0 | Automatic | 1 byte |
$ 2 AE 0B |
Configure SPI for 8-bit auto-CS-bar | 1 | 1 | Automatic | 1 byte |
$ 2 AE 18 |
Configure SPI for 16-bit auto-CS-bar | 0 | 0 | Automatic | 2 bytes |
$ 2 AE 19 |
Configure SPI for 16-bit auto-CS-bar | 0 | 1 | Automatic | 2 bytes |
$ 2 AE 1A |
Configure SPI for 16-bit auto-CS-bar | 1 | 0 | Automatic | 2 bytes |
$ 2 AE 1B |
Configure SPI for 16-bit auto-CS-bar | 1 | 1 | Automatic | 2 bytes |
$ 2 AE 28 |
Configure SPI for 24-bit auto-CS-bar | 0 | 0 | Automatic | 3 bytes |
$ 2 AE 29 |
Configure SPI for 24-bit auto-CS-bar | 0 | 1 | Automatic | 3 bytes |
$ 2 AE 2A |
Configure SPI for 24-bit auto-CS-bar | 1 | 0 | Automatic | 3 bytes |
$ 2 AE 2B |
Configure SPI for 24-bit auto-CS-bar | 1 | 1 | Automatic | 3 bytes |
$ 2 AE 38 |
Configure SPI for 32-bit auto-CS-bar | 0 | 0 | Automatic | 4 bytes |
$ 2 AE 39 |
Configure SPI for 32-bit auto-CS-bar | 0 | 1 | Automatic | 4 bytes |
$ 2 AE 3A |
Configure SPI for 32-bit auto-CS-bar | 1 | 0 | Automatic | 4 bytes |
$ 2 AE 3B |
Configure SPI for 32-bit auto-CS-bar | 1 | 1 | Automatic | 4 bytes |
$ 2 AF xx |
Perform an 8-bit SPI transfer (CS-bar = GPIO or auto-CS-bar = 1-byte) | — | — | — | 1 byte |
$ 3 AF xx xx |
Perform a 16-bit SPI transfer (requires auto-CS-bar = 2-byte mode) | — | — | — | 2 bytes |
$ 4 AF xx xx xx |
Perform a 24-bit SPI transfer (requires auto-CS-bar = 3-byte mode) | — | — | — | 3 bytes |
$ 5 AF xx xx xx xx |
Perform a 32-bit SPI transfer (requires auto-CS-bar = 4-byte mode) | — | — | — | 4 bytes |
$ 2 F9 0 |
Drive CS-bar pin low | — | — | GPIO-K9 | — |
$ 2 F9 1 |
Drive CS-bar pin high | — | — | GPIO-K9 | — |
表25. 更新后MINIQUSB+固件01.05.41中的中斷脈沖累加器命令
DEMO1234 Command |
Action | Int | GPIO Input | Firmware Command |
$ 2 C3 00 |
Query which of the C3 commands are supported; the return value is a 2-byte bitmap of commands C300 to C30F, msb first | — | — | C3 00 |
I Q 0 |
Query configuration of pulse accumulator | INT0 | GPIO-K5 | C3 01 00 |
I Q 1 |
Query configuration of pulse accumulator | INT1 | GPIO-K6 | C3 01 01 |
I Q 2 |
Query configuration of pulse accumulator | INT2 | GPIO-K7 | C3 01 02 |
I Q 3 |
Query configuration of pulse accumulator | INT3 | GPIO-K8 | C3 01 03 |
I C 0 0 |
Configure pulse accumulator: disable interrupt | INT0 | GPIO-K5 | C3 02 00 00 |
I C 1 0 |
Configure pulse accumulator: disable interrupt | INT1 | GPIO-K6 | C3 02 01 00 |
I C 2 0 |
Configure pulse accumulator: disable interrupt | INT2 | GPIO-K7 | C3 02 02 00 |
I C 3 0 |
Configure pulse accumulator: disable interrupt | INT3 | GPIO-K8 | C3 02 03 00 |
I C 0 1 |
Configure pulse accumulator: rising-edge trigger | INT0 | GPIO-K5 | C3 02 00 01 |
I C 1 1 |
Configure pulse accumulator: rising-edge trigger | INT1 | GPIO-K6 | C3 02 01 01 |
I C 2 1 |
Configure pulse accumulator: rising-edge trigger | INT2 | GPIO-K7 | C3 02 02 01 |
I C 3 1 |
Configure pulse accumulator: rising-edge trigger | INT3 | GPIO-K8 | C3 02 03 01 |
I C 0 3 |
Configure pulse accumulator: falling-edge trigger | INT0 | GPIO-K5 | C3 02 00 03 |
I C 1 3 |
Configure pulse accumulator: falling-edge trigger | INT1 | GPIO-K6 | C3 02 01 03 |
I C 2 3 |
Configure pulse accumulator: falling-edge trigger | INT2 | GPIO-K7 | C3 02 02 03 |
I C 3 3 |
Configure pulse accumulator: falling-edge trigger | INT3 | GPIO-K8 | C3 02 03 03 |
I R 0 |
Read pulse accumulator | INT0 | GPIO-K5 | C3 03 00 |
I R 1 |
Read pulse accumulator | INT1 | GPIO-K6 | C3 03 01 |
I R 2 |
Read pulse accumulator | INT2 | GPIO-K7 | C3 03 02 |
I R 3 |
Read pulse accumulator | INT3 | GPIO-K8 | C3 03 03 |
I 0 0 |
Clear pulse accumulator | INT0 | GPIO-K5 | C3 04 00 |
I 0 1 |
Clear pulse accumulator | INT1 | GPIO-K6 | C3 04 01 |
I 0 2 |
Clear pulse accumulator | INT2 | GPIO-K7 | C3 04 02 |
I 0 3 |
Clear pulse accumulator | INT3 | GPIO-K8 | C3 04 03 |
I S 0 xx |
Set pulse accumulator count xx = 0 to 255 | INT0 | GPIO-K5 | C3 05 00 xx |
I S 1 xx |
Set pulse accumulator count xx = 0 to 255 | INT1 | GPIO-K6 | C3 05 01 xx |
I S 2 xx |
Set pulse accumulator count xx = 0 to 255 | INT2 | GPIO-K7 | C3 05 02 xx |
I S 3 xx |
Set pulse accumulator count xx = 0 to 255 | INT3 | GPIO-K8 | C3 05 03 xx |
評論
查看更多