/* * TOPPERS BASE PLATFORM MIDDLEWARE * * Copyright (C) 2017-2019 by TOPPERS PROJECT * Educational Working Group. * * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー * スコード中に含まれていること. * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 * の無保証規定を掲載すること. * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ * と. * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 * 作権表示,この利用条件および下記の無保証規定を掲載すること. * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに * 報告すること. * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを * 免責すること. * * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ * の責任を負わない. * * @(#) $Id$ */ /* * Written by Limor Fried/Ladyada for Adafruit Industries. * MIT license, all text above must be included in any redistribution * http://opensource.org/licenses/mit-license.php */ #ifndef _ADAFRUITTS_STMP610_H_ #define _ADAFRUITTS_STMP610_H_ #include #include #include #include "device.h" #include "spi.h" #ifdef __cplusplus extern "C" { #endif #define STMPE_ADDR 0x41 #define STMPE_SYS_CTRL1 0x03 #define STMPE_SYS_CTRL1_RESET 0x02 #define STMPE_SYS_CTRL2 0x04 #define STMPE_TSC_CTRL 0x40 #define STMPE_TSC_CTRL_EN 0x01 #define STMPE_TSC_CTRL_XYZ 0x00 #define STMPE_TSC_CTRL_XY 0x02 #define STMPE_INT_CTRL 0x09 #define STMPE_INT_CTRL_POL_HIGH 0x04 #define STMPE_INT_CTRL_POL_LOW 0x00 #define STMPE_INT_CTRL_EDGE 0x02 #define STMPE_INT_CTRL_LEVEL 0x00 #define STMPE_INT_CTRL_ENABLE 0x01 #define STMPE_INT_CTRL_DISABLE 0x00 #define STMPE_INT_EN 0x0A #define STMPE_INT_EN_TOUCHDET 0x01 #define STMPE_INT_EN_FIFOTH 0x02 #define STMPE_INT_EN_FIFOOF 0x04 #define STMPE_INT_EN_FIFOFULL 0x08 #define STMPE_INT_EN_FIFOEMPTY 0x10 #define STMPE_INT_EN_ADC 0x40 #define STMPE_INT_EN_GPIO 0x80 #define STMPE_INT_STA 0x0B #define STMPE_INT_STA_TOUCHDET 0x01 #define STMPE_ADC_CTRL1 0x20 #define STMPE_ADC_CTRL1_12BIT 0x08 #define STMPE_ADC_CTRL1_10BIT 0x00 #define STMPE_ADC_CTRL2 0x21 #define STMPE_ADC_CTRL2_1_625MHZ 0x00 #define STMPE_ADC_CTRL2_3_25MHZ 0x01 #define STMPE_ADC_CTRL2_6_5MHZ 0x02 #define STMPE_TSC_CFG 0x41 #define STMPE_TSC_CFG_1SAMPLE 0x00 #define STMPE_TSC_CFG_2SAMPLE 0x40 #define STMPE_TSC_CFG_4SAMPLE 0x80 #define STMPE_TSC_CFG_8SAMPLE 0xC0 #define STMPE_TSC_CFG_DELAY_10US 0x00 #define STMPE_TSC_CFG_DELAY_50US 0x08 #define STMPE_TSC_CFG_DELAY_100US 0x10 #define STMPE_TSC_CFG_DELAY_500US 0x18 #define STMPE_TSC_CFG_DELAY_1MS 0x20 #define STMPE_TSC_CFG_DELAY_5MS 0x28 #define STMPE_TSC_CFG_DELAY_10MS 0x30 #define STMPE_TSC_CFG_DELAY_50MS 0x38 #define STMPE_TSC_CFG_SETTLE_10US 0x00 #define STMPE_TSC_CFG_SETTLE_100US 0x01 #define STMPE_TSC_CFG_SETTLE_500US 0x02 #define STMPE_TSC_CFG_SETTLE_1MS 0x03 #define STMPE_TSC_CFG_SETTLE_5MS 0x04 #define STMPE_TSC_CFG_SETTLE_10MS 0x05 #define STMPE_TSC_CFG_SETTLE_50MS 0x06 #define STMPE_TSC_CFG_SETTLE_100MS 0x07 #define STMPE_FIFO_TH 0x4A #define STMPE_FIFO_SIZE 0x4C #define STMPE_FIFO_STA 0x4B #define STMPE_FIFO_STA_RESET 0x01 #define STMPE_FIFO_STA_OFLOW 0x80 #define STMPE_FIFO_STA_FULL 0x40 #define STMPE_FIFO_STA_EMPTY 0x20 #define STMPE_FIFO_STA_THTRIG 0x10 #define STMPE_TSC_I_DRIVE 0x58 #define STMPE_TSC_I_DRIVE_20MA 0x00 #define STMPE_TSC_I_DRIVE_50MA 0x01 #define STMPE_TSC_DATA_X 0x4D #define STMPE_TSC_DATA_Y 0x4F #define STMPE_TSC_FRACTION_Z 0x56 #define STMPE_GPIO_SET_PIN 0x10 #define STMPE_GPIO_CLR_PIN 0x11 #define STMPE_GPIO_DIR 0x13 #define STMPE_GPIO_ALT_FUNCT 0x17 typedef struct { int16_t x; int16_t y; int16_t z; } TouchScreen_Point_t; /* * TouchScreenハンドラ構造体定義 */ typedef struct { SPI_Handle_t *hspi; /* spiハンドラ */ uint16_t min_x; uint16_t min_y; uint16_t max_x; uint16_t max_y; uint8_t cs_pin; uint32_t otype; uint32_t pullmode; ID spi_lock; } TouchScreen_Handle_t; extern ER touchscreen_init(TouchScreen_Handle_t *hts, uint8_t orientation); extern ER_BOOL touchscreen_touched(TouchScreen_Handle_t *hts); extern ER_UINT touchscreen_buffersize(TouchScreen_Handle_t *hts); extern ER_UINT touchscreen_getversion(TouchScreen_Handle_t *hts); extern ER touchscreen_getpoint(TouchScreen_Handle_t *hts, TouchScreen_Point_t *point, uint8_t len); extern ER touchscreen_writeRegister(TouchScreen_Handle_t *hts, uint8_t reg, uint8_t val); #ifdef __cplusplus } #endif #endif /* _ADAFRUITTS_STMP610_H_ */