[453] | 1 | /*
|
---|
| 2 | * TOPPERS BASE PLATFORM MIDDLEWARE
|
---|
| 3 | *
|
---|
| 4 | * Copyright (C) 2017-2019 by TOPPERS PROJECT
|
---|
| 5 | * Educational Working Group.
|
---|
| 6 | *
|
---|
| 7 | * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
|
---|
| 8 | * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
---|
| 9 | * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
---|
| 10 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
| 11 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
| 12 | * スコード中に含まれていること.
|
---|
| 13 | * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
| 14 | * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
| 15 | * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
| 16 | * の無保証規定を掲載すること.
|
---|
| 17 | * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
| 18 | * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
---|
| 19 | * と.
|
---|
| 20 | * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
| 21 | * 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
| 22 | * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
---|
| 23 | * 報告すること.
|
---|
| 24 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
| 25 | * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
| 26 | * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
---|
| 27 | * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
---|
| 28 | * 免責すること.
|
---|
| 29 | *
|
---|
| 30 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
| 31 | * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
---|
| 32 | * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
---|
| 33 | * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
---|
| 34 | * の責任を負わない.
|
---|
| 35 | *
|
---|
| 36 | * @(#) $Id$
|
---|
| 37 | */
|
---|
| 38 |
|
---|
| 39 | /*
|
---|
| 40 | * Written by Limor Fried/Ladyada for Adafruit Industries.
|
---|
| 41 | * MIT license, all text above must be included in any redistribution
|
---|
| 42 | * http://opensource.org/licenses/mit-license.php
|
---|
| 43 | */
|
---|
| 44 |
|
---|
| 45 | #ifndef _ADAFRUITTS_STMP610_H_
|
---|
| 46 | #define _ADAFRUITTS_STMP610_H_
|
---|
| 47 |
|
---|
| 48 | #include <kernel.h>
|
---|
| 49 | #include <t_syslog.h>
|
---|
| 50 | #include <t_stdlib.h>
|
---|
| 51 | #include "device.h"
|
---|
| 52 | #include "spi.h"
|
---|
| 53 |
|
---|
| 54 | #ifdef __cplusplus
|
---|
| 55 | extern "C" {
|
---|
| 56 | #endif
|
---|
| 57 |
|
---|
| 58 | #define STMPE_ADDR 0x41
|
---|
| 59 |
|
---|
| 60 | #define STMPE_SYS_CTRL1 0x03
|
---|
| 61 | #define STMPE_SYS_CTRL1_RESET 0x02
|
---|
| 62 | #define STMPE_SYS_CTRL2 0x04
|
---|
| 63 |
|
---|
| 64 | #define STMPE_TSC_CTRL 0x40
|
---|
| 65 | #define STMPE_TSC_CTRL_EN 0x01
|
---|
| 66 | #define STMPE_TSC_CTRL_XYZ 0x00
|
---|
| 67 | #define STMPE_TSC_CTRL_XY 0x02
|
---|
| 68 |
|
---|
| 69 | #define STMPE_INT_CTRL 0x09
|
---|
| 70 | #define STMPE_INT_CTRL_POL_HIGH 0x04
|
---|
| 71 | #define STMPE_INT_CTRL_POL_LOW 0x00
|
---|
| 72 | #define STMPE_INT_CTRL_EDGE 0x02
|
---|
| 73 | #define STMPE_INT_CTRL_LEVEL 0x00
|
---|
| 74 | #define STMPE_INT_CTRL_ENABLE 0x01
|
---|
| 75 | #define STMPE_INT_CTRL_DISABLE 0x00
|
---|
| 76 |
|
---|
| 77 |
|
---|
| 78 |
|
---|
| 79 | #define STMPE_INT_EN 0x0A
|
---|
| 80 | #define STMPE_INT_EN_TOUCHDET 0x01
|
---|
| 81 | #define STMPE_INT_EN_FIFOTH 0x02
|
---|
| 82 | #define STMPE_INT_EN_FIFOOF 0x04
|
---|
| 83 | #define STMPE_INT_EN_FIFOFULL 0x08
|
---|
| 84 | #define STMPE_INT_EN_FIFOEMPTY 0x10
|
---|
| 85 | #define STMPE_INT_EN_ADC 0x40
|
---|
| 86 | #define STMPE_INT_EN_GPIO 0x80
|
---|
| 87 |
|
---|
| 88 | #define STMPE_INT_STA 0x0B
|
---|
| 89 | #define STMPE_INT_STA_TOUCHDET 0x01
|
---|
| 90 |
|
---|
| 91 | #define STMPE_ADC_CTRL1 0x20
|
---|
| 92 | #define STMPE_ADC_CTRL1_12BIT 0x08
|
---|
| 93 | #define STMPE_ADC_CTRL1_10BIT 0x00
|
---|
| 94 |
|
---|
| 95 | #define STMPE_ADC_CTRL2 0x21
|
---|
| 96 | #define STMPE_ADC_CTRL2_1_625MHZ 0x00
|
---|
| 97 | #define STMPE_ADC_CTRL2_3_25MHZ 0x01
|
---|
| 98 | #define STMPE_ADC_CTRL2_6_5MHZ 0x02
|
---|
| 99 |
|
---|
| 100 | #define STMPE_TSC_CFG 0x41
|
---|
| 101 | #define STMPE_TSC_CFG_1SAMPLE 0x00
|
---|
| 102 | #define STMPE_TSC_CFG_2SAMPLE 0x40
|
---|
| 103 | #define STMPE_TSC_CFG_4SAMPLE 0x80
|
---|
| 104 | #define STMPE_TSC_CFG_8SAMPLE 0xC0
|
---|
| 105 | #define STMPE_TSC_CFG_DELAY_10US 0x00
|
---|
| 106 | #define STMPE_TSC_CFG_DELAY_50US 0x08
|
---|
| 107 | #define STMPE_TSC_CFG_DELAY_100US 0x10
|
---|
| 108 | #define STMPE_TSC_CFG_DELAY_500US 0x18
|
---|
| 109 | #define STMPE_TSC_CFG_DELAY_1MS 0x20
|
---|
| 110 | #define STMPE_TSC_CFG_DELAY_5MS 0x28
|
---|
| 111 | #define STMPE_TSC_CFG_DELAY_10MS 0x30
|
---|
| 112 | #define STMPE_TSC_CFG_DELAY_50MS 0x38
|
---|
| 113 | #define STMPE_TSC_CFG_SETTLE_10US 0x00
|
---|
| 114 | #define STMPE_TSC_CFG_SETTLE_100US 0x01
|
---|
| 115 | #define STMPE_TSC_CFG_SETTLE_500US 0x02
|
---|
| 116 | #define STMPE_TSC_CFG_SETTLE_1MS 0x03
|
---|
| 117 | #define STMPE_TSC_CFG_SETTLE_5MS 0x04
|
---|
| 118 | #define STMPE_TSC_CFG_SETTLE_10MS 0x05
|
---|
| 119 | #define STMPE_TSC_CFG_SETTLE_50MS 0x06
|
---|
| 120 | #define STMPE_TSC_CFG_SETTLE_100MS 0x07
|
---|
| 121 |
|
---|
| 122 | #define STMPE_FIFO_TH 0x4A
|
---|
| 123 |
|
---|
| 124 | #define STMPE_FIFO_SIZE 0x4C
|
---|
| 125 |
|
---|
| 126 | #define STMPE_FIFO_STA 0x4B
|
---|
| 127 | #define STMPE_FIFO_STA_RESET 0x01
|
---|
| 128 | #define STMPE_FIFO_STA_OFLOW 0x80
|
---|
| 129 | #define STMPE_FIFO_STA_FULL 0x40
|
---|
| 130 | #define STMPE_FIFO_STA_EMPTY 0x20
|
---|
| 131 | #define STMPE_FIFO_STA_THTRIG 0x10
|
---|
| 132 |
|
---|
| 133 | #define STMPE_TSC_I_DRIVE 0x58
|
---|
| 134 | #define STMPE_TSC_I_DRIVE_20MA 0x00
|
---|
| 135 | #define STMPE_TSC_I_DRIVE_50MA 0x01
|
---|
| 136 |
|
---|
| 137 | #define STMPE_TSC_DATA_X 0x4D
|
---|
| 138 | #define STMPE_TSC_DATA_Y 0x4F
|
---|
| 139 | #define STMPE_TSC_FRACTION_Z 0x56
|
---|
| 140 |
|
---|
| 141 | #define STMPE_GPIO_SET_PIN 0x10
|
---|
| 142 | #define STMPE_GPIO_CLR_PIN 0x11
|
---|
| 143 | #define STMPE_GPIO_DIR 0x13
|
---|
| 144 | #define STMPE_GPIO_ALT_FUNCT 0x17
|
---|
| 145 |
|
---|
| 146 | typedef struct
|
---|
| 147 | {
|
---|
| 148 | int16_t x;
|
---|
| 149 | int16_t y;
|
---|
| 150 | int16_t z;
|
---|
| 151 | } TouchScreen_Point_t;
|
---|
| 152 |
|
---|
| 153 | /*
|
---|
| 154 | * TouchScreenハンドラ構造体定義
|
---|
| 155 | */
|
---|
| 156 | typedef struct
|
---|
| 157 | {
|
---|
| 158 | SPI_Handle_t *hspi; /* spiハンドラ */
|
---|
| 159 | uint16_t min_x;
|
---|
| 160 | uint16_t min_y;
|
---|
| 161 | uint16_t max_x;
|
---|
| 162 | uint16_t max_y;
|
---|
| 163 | uint8_t cs_pin;
|
---|
| 164 | uint32_t otype;
|
---|
| 165 | uint32_t pullmode;
|
---|
| 166 | ID spi_lock;
|
---|
| 167 | } TouchScreen_Handle_t;
|
---|
| 168 |
|
---|
| 169 | extern ER touchscreen_init(TouchScreen_Handle_t *hts, uint8_t orientation);
|
---|
| 170 | extern ER_BOOL touchscreen_touched(TouchScreen_Handle_t *hts);
|
---|
| 171 | extern ER_UINT touchscreen_buffersize(TouchScreen_Handle_t *hts);
|
---|
| 172 | extern ER_UINT touchscreen_getversion(TouchScreen_Handle_t *hts);
|
---|
| 173 | extern ER touchscreen_getpoint(TouchScreen_Handle_t *hts, TouchScreen_Point_t *point, uint8_t len);
|
---|
| 174 | extern ER touchscreen_writeRegister(TouchScreen_Handle_t *hts, uint8_t reg, uint8_t val);
|
---|
| 175 |
|
---|
| 176 |
|
---|
| 177 | #ifdef __cplusplus
|
---|
| 178 | }
|
---|
| 179 | #endif
|
---|
| 180 |
|
---|
| 181 | #endif /* _ADAFRUITTS_STMP610_H_ */
|
---|
| 182 |
|
---|