Difference between revisions of "Unit STMPE"

From Ultibo.org
Jump to: navigation, search
Line 9: Line 9:
 
The ST Microelectronics STMPE devices are a range of multi function chips that include GPIO, ADC, 4 wire touchscreen controller and PWM outputs in varying combinations. Many of the functions overlap so a pin can be used for example as a GPIO or a PWM but not both at once. The Touchscreen controller also consumes many of the GPIO pins in the models that support it. This driver supports the GPIO and Touchscreen functions of the following chips:
 
The ST Microelectronics STMPE devices are a range of multi function chips that include GPIO, ADC, 4 wire touchscreen controller and PWM outputs in varying combinations. Many of the functions overlap so a pin can be used for example as a GPIO or a PWM but not both at once. The Touchscreen controller also consumes many of the GPIO pins in the models that support it. This driver supports the GPIO and Touchscreen functions of the following chips:
 
   
 
   
STMPE610 - 6 GPIO / 4-wire Touch / I2C / SPI
+
STMPE610 - 6 GPIO/4-wire Touch/I2C/SPI
 
   
 
   
STMPE801 - 8 GPIO / I2C
+
STMPE801 - 8 GPIO/I2C
 
   
 
   
STMPE811 - 8 GPIO / 4-wire Touch / I2C / SPI
+
STMPE811 - 8 GPIO/4-wire Touch/I2C/SPI
 
   
 
   
STMPE1601 - 16 GPIO / 4 PWM / I2C
+
STMPE1601 - 16 GPIO/4 PWM/I2C
 
   
 
   
STMPE1801 - 18 GPIO / I2C
+
STMPE1801 - 18 GPIO/I2C
 
   
 
   
STMPE2401 - 24 GPIO / 3 PWM / I2C
+
STMPE2401 - 24 GPIO/3 PWM/I2C
 
   
 
   
STMPE2403 - 24 GPIO / 3 PWM / I2C  
+
STMPE2403 - 24 GPIO/3 PWM/I2C  
  
 
Note: A number of variations also support Keypad, Temperature and other features which are not currently handled by this driver.
 
Note: A number of variations also support Keypad, Temperature and other features which are not currently handled by this driver.
Line 178: Line 178:
 
|-
 
|-
 
| <code>STMPE1601_GPIO_MAX_FUNCTION = GPIO_FUNCTION_ALT1;</code>
 
| <code>STMPE1601_GPIO_MAX_FUNCTION = GPIO_FUNCTION_ALT1;</code>
| Alternate function 0 = Keypad / Alternate function 1 = PWM
+
| Alternate function 0 = Keypad/Alternate function 1 = PWM
 
|-
 
|-
 
| <code>STMPE1601_GPIO_FUNCTION_COUNT = 4;</code>
 
| <code>STMPE1601_GPIO_FUNCTION_COUNT = 4;</code>
Line 314: Line 314:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
|colspan="2"|''STMPE610 / STMPE811''
+
|colspan="2"|''STMPE610/STMPE811''
 
|-
 
|-
 
| <code>STMPE811_REG_CHIP_ID = $00;</code>
 
| <code>STMPE811_REG_CHIP_ID = $00;</code>
Line 320: Line 320:
 
|-
 
|-
 
| <code>STMPE811_REG_ID_VER = $02;</code>
 
| <code>STMPE811_REG_ID_VER = $02;</code>
| Revision number (0x01 for engineering sample / 0x03 for final silicon)
+
| Revision number (0x01 for engineering sample/0x03 for final silicon)
 
|-
 
|-
 
| <code>STMPE811_REG_SYS_CTRL1 = $03;</code>
 
| <code>STMPE811_REG_SYS_CTRL1 = $03;</code>
Line 495: Line 495:
 
|-
 
|-
 
| <code>STMPE801_REG_ID_VER = $02;</code>
 
| <code>STMPE801_REG_ID_VER = $02;</code>
| Revision number (0x01 for engineering sample / 0x02 for final silicon)
+
| Revision number (0x01 for engineering sample/0x02 for final silicon)
 
|-
 
|-
 
| <code>STMPE801_REG_SYS_CTRL = $04;</code>
 
| <code>STMPE801_REG_SYS_CTRL = $04;</code>
Line 828: Line 828:
 
|colspan="2"|&nbsp;  
 
|colspan="2"|&nbsp;  
 
|-
 
|-
|colspan="2"|''STMPE2401 / STMPE2403''
+
|colspan="2"|''STMPE2401/STMPE2403''
 
|-
 
|-
 
| <code>STMPE240X_REG_CHIP_ID = $80;</code>
 
| <code>STMPE240X_REG_CHIP_ID = $80;</code>
Line 1,039: Line 1,039:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
|colspan="2"|''STMPE610 / STMPE811''
+
|colspan="2"|''STMPE610/STMPE811''
 
|-
 
|-
 
| <code>STMPE811_CHIP_ID = $0811;</code>
 
| <code>STMPE811_CHIP_ID = $0811;</code>
Line 1,067: Line 1,067:
 
|colspan="2"|&nbsp;
 
|colspan="2"|&nbsp;
 
|-
 
|-
|colspan="2"|''STMPE2401 / STMPE2403''
+
|colspan="2"|''STMPE2401/STMPE2403''
 
|-
 
|-
 
| <code>STMPE240X_CHIP_ID = $01;</code>
 
| <code>STMPE240X_CHIP_ID = $01;</code>
Line 1,080: Line 1,080:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
|colspan="2"|''STMPE610 / STMPE811''
+
|colspan="2"|''STMPE610/STMPE811''
 
|-
 
|-
 
| <code>STMPE811_SYS_CTRL2_TS_OFF = (1 shl 3);</code>
 
| <code>STMPE811_SYS_CTRL2_TS_OFF = (1 shl 3);</code>
Line 1,157: Line 1,157:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
|colspan="2"|''STMPE610 / STMPE811''
+
|colspan="2"|''STMPE610/STMPE811''
 
|-
 
|-
 
| <code>STMPE811_TSC_CTRL_TSC_STA = (1 shl 7);</code>
 
| <code>STMPE811_TSC_CTRL_TSC_STA = (1 shl 7);</code>
| TSC status (Reads '1' when touch is detected / Reads '0' when touch is not detected)
+
| TSC status (Reads '1' when touch is detected/Reads '0' when touch is not detected)
 
|-
 
|-
 
| <code>STMPE811_TSC_CTRL_TRACK_MASK = (7 shl 4);</code>
 
| <code>STMPE811_TSC_CTRL_TRACK_MASK = (7 shl 4);</code>
Line 1,191: Line 1,191:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
|colspan="2"|''STMPE610 / STMPE811''
+
|colspan="2"|''STMPE610/STMPE811''
 
|-
 
|-
 
| <code>STMPE811_TSC_CFG_AVE_CTRL_1 = (0 shl 6);</code>
 
| <code>STMPE811_TSC_CFG_AVE_CTRL_1 = (0 shl 6);</code>
Line 1,219: Line 1,219:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
|colspan="2"|''STMPE610 / STMPE811''
+
|colspan="2"|''STMPE610/STMPE811''
 
|-
 
|-
 
| <code>STMPE811_ADC_CTRL1_SAMPLE_TIME_MASK = (7 shl 4);</code>
 
| <code>STMPE811_ADC_CTRL1_SAMPLE_TIME_MASK = (7 shl 4);</code>
Line 1,225: Line 1,225:
 
|-
 
|-
 
| <code>STMPE811_ADC_CTRL1_MOD_12B = (1 shl 3);</code>
 
| <code>STMPE811_ADC_CTRL1_MOD_12B = (1 shl 3);</code>
| MOD_12B: Selects 10 or 12-bit ADC operation (1: 12 bit ADC / 0: 10 bit ADC)
+
| MOD_12B: Selects 10 or 12-bit ADC operation (1: 12 bit ADC/0: 10 bit ADC)
 
|-
 
|-
 
| <code>STMPE811_ADC_CTRL1_REF_SEL = (1 shl 1);</code>
 
| <code>STMPE811_ADC_CTRL1_REF_SEL = (1 shl 1);</code>
| REF_SEL: Selects between internal or external reference for the ADC (1: External reference / 0: Internal reference)
+
| REF_SEL: Selects between internal or external reference for the ADC (1: External reference/0: Internal reference)
 
|-
 
|-
 
|}
 
|}
Line 1,238: Line 1,238:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
|colspan="2"|''STMPE610 / STMPE811''
+
|colspan="2"|''STMPE610/STMPE811''
 
|-
 
|-
 
| <code>STMPE811_ADC_CTRL2_ADC_FREQ_MASK = (3 shl 0);</code>
 
| <code>STMPE811_ADC_CTRL2_ADC_FREQ_MASK = (3 shl 0);</code>
Line 1,251: Line 1,251:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
|colspan="2"|''STMPE610 / STMPE811''
+
|colspan="2"|''STMPE610/STMPE811''
 
|-
 
|-
 
| <code>STMPE811_FIFO_STA_RESET = (1 shl 0);</code>
 
| <code>STMPE811_FIFO_STA_RESET = (1 shl 0);</code>
| FIFO Reset (Write 0 : FIFO put out of reset mode / Write 1 : Resets FIFO. All data in FIFO will be cleared)
+
| FIFO Reset (Write 0 : FIFO put out of reset mode/Write 1 : Resets FIFO. All data in FIFO will be cleared)
 
|-
 
|-
 
|}
 
|}
Line 1,264: Line 1,264:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
|colspan="2"|''STMPE610 / STMPE811''
+
|colspan="2"|''STMPE610/STMPE811''
 
|-
 
|-
 
| <code>STMPE811_INT_CTRL_POLARITY = (1 shl 2);</code>
 
| <code>STMPE811_INT_CTRL_POLARITY = (1 shl 2);</code>
| This bit sets the INT pin polarity (1: Active high/rising edge / 0: Active low/falling edge)
+
| This bit sets the INT pin polarity (1: Active high/rising edge/0: Active low/falling edge)
 
|-
 
|-
 
| <code>STMPE811_INT_CTRL_TYPE = (1 shl 1);</code>
 
| <code>STMPE811_INT_CTRL_TYPE = (1 shl 1);</code>
| This bit sets the type of interrupt signal required by the host (1: Edge interrupt / 0: Level interrupt)
+
| This bit sets the type of interrupt signal required by the host (1: Edge interrupt/0: Level interrupt)
 
|-
 
|-
 
| <code>STMPE811_INT_CTRL_GLOBAL = (1 shl 0);</code>
 
| <code>STMPE811_INT_CTRL_GLOBAL = (1 shl 0);</code>
| This is master enable for the interrupt system (1: Global interrupt / 0: Stops all interrupts)
+
| This is master enable for the interrupt system (1: Global interrupt/0: Stops all interrupts)
 
|-
 
|-
 
|}
 
|}
Line 1,283: Line 1,283:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
|colspan="2"|''STMPE610 / STMPE811''
+
|colspan="2"|''STMPE610/STMPE811''
 
|-
 
|-
 
| <code>STMPE811_INT_EN_GPIO = (1 shl 7);</code>
 
| <code>STMPE811_INT_EN_GPIO = (1 shl 7);</code>
Line 1,317: Line 1,317:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
|colspan="2"|''STMPE610 / STMPE811''
+
|colspan="2"|''STMPE610/STMPE811''
 
|-
 
|-
 
| <code>STMPE811_INT_STA_GPIO = (1 shl 7);</code>
 
| <code>STMPE811_INT_STA_GPIO = (1 shl 7);</code>
Line 1,355: Line 1,355:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
|colspan="2"|''STMPE610 / STMPE811 Offsets''
+
|colspan="2"|''STMPE610/STMPE811 Offsets''
 
|-
 
|-
 
|colspan="2"|<code>STMPE811Offsets:TSTMPEOffsets = (</code>
 
|colspan="2"|<code>STMPE811Offsets:TSTMPEOffsets = (</code>
Line 1,719: Line 1,719:
 
|colspan="2"|&nbsp;
 
|colspan="2"|&nbsp;
 
|-
 
|-
|colspan="2"|''STMPE2401 / STMPE2403 Offsets''
+
|colspan="2"|''STMPE2401/STMPE2403 Offsets''
 
|-
 
|-
 
|colspan="2"|<code>STMPE240XOffsets:TSTMPEOffsets = (</code>
 
|colspan="2"|<code>STMPE240XOffsets:TSTMPEOffsets = (</code>
Line 1,855: Line 1,855:
 
|-
 
|-
 
| <code>RegDir:LongWord;</code>
 
| <code>RegDir:LongWord;</code>
| The register address direction (Ascending / Descending)
+
| The register address direction (Ascending/Descending)
 
|-
 
|-
 
| <code>RegSize:LongWord;</code>
 
| <code>RegSize:LongWord;</code>

Revision as of 04:26, 13 April 2017

Return to Unit Reference


Description


ST Microelectronics STMPE Driver unit

The ST Microelectronics STMPE devices are a range of multi function chips that include GPIO, ADC, 4 wire touchscreen controller and PWM outputs in varying combinations. Many of the functions overlap so a pin can be used for example as a GPIO or a PWM but not both at once. The Touchscreen controller also consumes many of the GPIO pins in the models that support it. This driver supports the GPIO and Touchscreen functions of the following chips:

STMPE610 - 6 GPIO/4-wire Touch/I2C/SPI

STMPE801 - 8 GPIO/I2C

STMPE811 - 8 GPIO/4-wire Touch/I2C/SPI

STMPE1601 - 16 GPIO/4 PWM/I2C

STMPE1801 - 18 GPIO/I2C

STMPE2401 - 24 GPIO/3 PWM/I2C

STMPE2403 - 24 GPIO/3 PWM/I2C

Note: A number of variations also support Keypad, Temperature and other features which are not currently handled by this driver.

Constants



[Expand]
STMPE specific constants STMPE*_*


[Expand]
STMPE chip STMPE_CHIP_*


[Expand]
STMPE direction STMPE_DIR_*


[Expand]
STMPE I2C STMPE_I2C_*


[Expand]
STMPE SPI STMPE_SPI_*


[Expand]
STMPE register STMPE*_REG_*


[Expand]
STMPE Id STMPE*_CHIP_ID


[Expand]
STMPE system control STMPE*_SYS_CTRL*_*


[Expand]
STMPE touchscreen control STMPE*_TSC_CTRL_*


[Expand]
STMPE touchscreen configuration STMPE*_TSC_CFG_*


[Expand]
STMPE ADC control 1 STMPE*_ADC_CTRL1_*


[Expand]
STMPE ADC control 2 STMPE*_ADC_CTRL2_*


[Expand]
STMPE FIFO control and status STMPE*_FIFO_STA_*


[Expand]
STMPE interrupt control STMPE*_INT_CTRL_*


[Expand]
STMPE interrupt enable STMPE*_INT_EN_*


[Expand]
STMPE interrupt status STMPE*_INT_STA_*


[Expand]
STMPE offset STMPE*Offsets*


Type definitions



STMPE control

[Expand]

PSTMPEControl = ^TSTMPEControl;

TSTMPEControl = record

STMPE offsets

[Expand]

PSTMPEOffsets = ^TSTMPEOffsets;

TSTMPEOffsets = record

STMPE GPIO

[Expand]

PSTMPEGPIO = ^TSTMPEGPIO;

TSTMPEGPIO = record

STMPE touch

[Expand]

PSTMPETouch = ^TSTMPETouch;

TSTMPETouch = record


Public variables



STMPE specific variables

STMPE_SAMPLE_TIME:Byte = 4;
STMPE_MOD_12B:Byte = 1;
STMPE_REF_SEL:Byte = 0;
STMPE_ADC_FREQ:Byte = 2;
STMPE_AVE_CTRL:Byte = 3;
STMPE_TOUCH_DET_DELAY:Byte = 4;
STMPE_SETTLING:Byte = 2;
STMPE_FRACTION_Z:Byte = 7;
STMPE_I_DRIVE:Byte = 0;


Function declarations



Initialization functions

[Expand]
procedure STMPEInit;
Description: Initialize the STMPE unit and parameters


STMPE functions

[Expand]
function STMPE610GPIOCreate(I2C:PI2CDevice; SPI:PSPIDevice; Address,ChipSelect:Word; IRQ:PGPIOInfo):PGPIODevice;
Description: Create, register and start a new STMPE610 GPIO device connected to the specified I2C or SPI device


[Expand]
function STMPE801GPIOCreate(I2C:PI2CDevice; Address:Word; IRQ:PGPIOInfo):PGPIODevice;
Description: Create, register and start a new STMPE801 GPIO device connected to the specified I2C device


[Expand]
function STMPE811GPIOCreate(I2C:PI2CDevice; SPI:PSPIDevice; Address,ChipSelect:Word; IRQ:PGPIOInfo):PGPIODevice;
Description: Create, register and start a new STMPE811 GPIO device connected to the specified I2C or SPI device


[Expand]
function STMPE1601GPIOCreate(I2C:PI2CDevice; Address:Word; IRQ:PGPIOInfo):PGPIODevice;
Description: Create, register and start a new STMPE1601 GPIO device connected to the specified I2C device


[Expand]
function STMPE1801GPIOCreate(I2C:PI2CDevice; Address:Word; IRQ:PGPIOInfo):PGPIODevice;
Description: Create, register and start a new STMPE1801 GPIO device connected to the specified I2C device


[Expand]
function STMPE2401GPIOCreate(I2C:PI2CDevice; Address:Word; IRQ:PGPIOInfo):PGPIODevice;
Description: Create, register and start a new STMPE2401 GPIO device connected to the specified I2C device


[Expand]
function STMPEGPIODestroy(GPIO:PGPIODevice):LongWord;
Description: Stop, deregister and destroy an STMPE GPIO device created by this driver


[Expand]
function STMPE610TouchCreate(I2C:PI2CDevice; SPI:PSPIDevice; Address,ChipSelect:Word; Width,Height:LongWord; IRQ:PGPIOInfo):PTouchDevice;
Description: Create, register and start a new STMPE610 Touch device connected to the specified I2C or SPI device


[Expand]
function STMPE811TouchCreate(I2C:PI2CDevice; SPI:PSPIDevice; Address,ChipSelect:Word; Width,Height:LongWord; IRQ:PGPIOInfo):PTouchDevice;
Description: Create, register and start a new STMPE811 Touch device connected to the specified I2C or SPI device


[Expand]
function STMPETouchDestroy(Touch:PTouchDevice):LongWord;
Description: Stop, deregister and destroy an STMPE Touch device created by this driver


STMPE GPIO functions

[Expand]
function STMPEGPIOStart(GPIO:PGPIODevice):LongWord;
Description: Implementation of GPIODeviceStart API for STMPE


[Expand]
function STMPEGPIOStop(GPIO:PGPIODevice):LongWord;
Description: Implementation of GPIODeviceStop API for STMPE


[Expand]
function STMPEGPIORead(GPIO:PGPIODevice; Reg:LongWord):LongWord;
Description: Implementation of GPIODeviceRead API for STMPE


[Expand]
procedure STMPEGPIOWrite(GPIO:PGPIODevice; Reg,Value:LongWord);
Description: Implementation of GPIODeviceWrite API for STMPE


[Expand]
function STMPEGPIOInputGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
Description: Implementation of GPIODeviceInputGet API for STMPE


[Expand]
function STMPEGPIOOutputSet(GPIO:PGPIODevice; Pin,Level:LongWord):LongWord;
Description: Implementation of GPIODeviceOutputSet API for STMPE


[Expand]
function STMPEGPIOPullGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
Description: Implementation of GPIODevicePullGet API for STMPE


[Expand]
function STMPEGPIOPullSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
Description: Implementation of GPIODevicePullSelect API for STMPE


[Expand]
function STMPEGPIOFunctionGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
Description: Implementation of GPIODeviceFunctionGet API for STMPE


[Expand]
function STMPEGPIOFunctionSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
Description: Implementation of GPIODeviceFunctionSelect API for STMPE


STMPE touch functions

[Expand]
function STMPETouchStart(Touch:PTouchDevice):LongWord;
Description: Implementation of TouchDeviceStart API for STMPE


[Expand]
function STMPETouchStop(Touch:PTouchDevice):LongWord;
Description: Implementation of TouchDeviceStop API for STMPE


[Expand]
procedure STMPETouchTimer(Touch:PSTMPETouch);
Description: Touch device timer event handler for STMPE


[Expand]
procedure STMPETouchCallback(Touch:PSTMPETouch; Pin,Trigger:LongWord);
Description: Touch device event callback (Interrupt) handler for STMPE


STMPE helper functions

[Expand]
function STMPEReadByte(Control:PSTMPEControl; Reg:Byte; Value:PByte):LongWord;
Description: To be documented


[Expand]
function STMPEWriteByte(Control:PSTMPEControl; Reg,Value:Byte):LongWord;
Description: To be documented


[Expand]
function STMPEReadWord(Control:PSTMPEControl; Reg:Byte; Value:PWord):LongWord;
Description: To be documented


[Expand]
function STMPEWriteWord(Control:PSTMPEControl; Reg:Byte; Value:Word):LongWord;
Description: To be documented


[Expand]
function STMPEReadBytes(Control:PSTMPEControl; Reg,Len:Byte; Values:PByte):LongWord;
Description: To be documented


[Expand]
function STMPEWriteBytes(Control:PSTMPEControl; Reg,Len:Byte; Values:PByte):LongWord;
Description: To be documented


[Expand]
function STMPESetBits(Control:PSTMPEControl; Reg,Mask,Value:Byte):LongWord;
Description: To be documented


[Expand]
function STMPEResetFIFO(Control:PSTMPEControl; Reg:Byte):LongWord;
Description: To be documented


Return to Unit Reference