mirror of
https://github.com/rvtr/twl_wrapsdk.git
synced 2025-10-31 06:11:10 -04:00
CODECがTWLモードでのタッチパネルデータの取得に初対応。
ライブラリ及びサンプルを追加・更新。 git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/twl_wrapsdk/trunk@241 4ee2a332-4b2b-5046-8439-1ba90f034370
This commit is contained in:
parent
83c72ef695
commit
78993181c6
@ -17,31 +17,32 @@
|
|||||||
#include <twl/i2c/ARM7/i2c.h>
|
#include <twl/i2c/ARM7/i2c.h>
|
||||||
#include <twl/cdc/ARM7/cdc_reg.h>
|
#include <twl/cdc/ARM7/cdc_reg.h>
|
||||||
#include <twl/cdc/ARM7/cdc.h>
|
#include <twl/cdc/ARM7/cdc.h>
|
||||||
|
|
||||||
#include "spi_sp.h"
|
#include "spi_sp.h"
|
||||||
|
|
||||||
void CDCi_PreInitAudio( void );
|
/*
|
||||||
void CDCi_PostInitAudio( void );
|
このソースで定義されているSPIアクセス関数はTWLモード時に使用します。
|
||||||
void CDCi_PreInitMic( void );
|
DSモード時は cdc_dsmode_access.c の関数を使用してください。
|
||||||
void CDCi_PostInitMic( void );
|
*/
|
||||||
void CDCi_InitTouchPanel( void );
|
|
||||||
void CDCi_InitCoefTable( void );
|
|
||||||
|
|
||||||
|
|
||||||
SPIBaudRate cdcSPIBaudRate = CDC_SPI_BAUDRATE_DEFAULT;
|
SPIBaudRate cdcSPIBaudRate = CDC_SPI_BAUDRATE_DEFAULT;
|
||||||
BOOL cdcIsTwlMode = TRUE;
|
BOOL cdcIsTwlMode = TRUE;
|
||||||
int cdcCurrentPage = 0;
|
int cdcCurrentPage = 0;
|
||||||
|
|
||||||
int cdcRevisionID = 0;
|
int cdcRevisionID = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
#define CDC_SPI_MODE_SETTING_REVISION_A ((u16)((1 << REG_SPI_SPICNT_E_SHIFT) | \
|
#define CDC_SPI_MODE_SETTING_REVISION_A ((u16)((1 << REG_SPI_SPICNT_E_SHIFT) | \
|
||||||
(0 << REG_SPI_SPICNT_I_SHIFT) | \
|
(0 << REG_SPI_SPICNT_I_SHIFT) | \
|
||||||
(SPI_SLAVE_RESERVED << REG_SPI_SPICNT_SEL_SHIFT) | \
|
(SPI_SLAVE_RESERVED << REG_SPI_SPICNT_SEL_SHIFT) | \
|
||||||
(CDC_SPI_BAUDRATE_DEFAULT << REG_SPI_SPICNT_BAUDRATE_SHIFT)))
|
(CDC_SPI_BAUDRATE_DEFAULT << REG_SPI_SPICNT_BAUDRATE_SHIFT)))
|
||||||
|
*/
|
||||||
|
|
||||||
#define CDC_SPI_MODE_SETTING_REVISION_B ((u16)((1 << REG_SPI_SPICNT_E_SHIFT) | \
|
#define CDC_SPI_MODE_SETTING_REVISION_B ((u16)((1 << REG_SPI_SPICNT_E_SHIFT) | \
|
||||||
(0 << REG_SPI_SPICNT_I_SHIFT) | \
|
(0 << REG_SPI_SPICNT_I_SHIFT) | \
|
||||||
(SPI_COMMPARTNER_TP << REG_SPI_SPICNT_SEL_SHIFT) | \
|
(SPI_COMMPARTNER_TP << REG_SPI_SPICNT_SEL_SHIFT) | \
|
||||||
(CDC_SPI_BAUDRATE_DEFAULT << REG_SPI_SPICNT_BAUDRATE_SHIFT)))
|
(CDC_SPI_BAUDRATE_DEFAULT << REG_SPI_SPICNT_BAUDRATE_SHIFT)))
|
||||||
|
|
||||||
#define CDC_SPI_MODE_SETTING_REVISION_C CDC_SPI_MODE_SETTING_REVISION_B
|
#define CDC_SPI_MODE_SETTING_REVISION_C CDC_SPI_MODE_SETTING_REVISION_B
|
||||||
|
|
||||||
u16 cdcSpiMode = CDC_SPI_MODE_SETTING_REVISION_B;
|
u16 cdcSpiMode = CDC_SPI_MODE_SETTING_REVISION_B;
|
||||||
@ -147,9 +148,9 @@ void CDCi_WriteSpiRegister( u8 reg, u8 data )
|
|||||||
/*---------------------------------------------------------------------------*
|
/*---------------------------------------------------------------------------*
|
||||||
Name: CDCi_ReadSpiRegister
|
Name: CDCi_ReadSpiRegister
|
||||||
|
|
||||||
Description: get value from PMIC register
|
Description: get value from register
|
||||||
|
|
||||||
Arguments: reg : PMIC register
|
Arguments: reg : register
|
||||||
|
|
||||||
Returns: value which is read from specified PMIC register
|
Returns: value which is read from specified PMIC register
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
@ -160,7 +161,7 @@ u8 CDCi_ReadSpiRegister( u8 reg )
|
|||||||
SPI_Wait();
|
SPI_Wait();
|
||||||
|
|
||||||
CDCi_ChangeSpiMode( SPI_TRANSMODE_CONTINUOUS );
|
CDCi_ChangeSpiMode( SPI_TRANSMODE_CONTINUOUS );
|
||||||
SPI_SendWait( (u8)(reg << 1) );
|
SPI_SendWait( (u8)((reg << 1) | 1));
|
||||||
|
|
||||||
CDCi_ChangeSpiMode( SPI_TRANSMODE_1BYTE );
|
CDCi_ChangeSpiMode( SPI_TRANSMODE_1BYTE );
|
||||||
data = (u8)SPI_DummyWaitReceive();
|
data = (u8)SPI_DummyWaitReceive();
|
||||||
@ -212,7 +213,7 @@ void CDCi_ReadSpiRegisters( u8 reg, u8 *bufp, size_t size )
|
|||||||
SPI_Wait();
|
SPI_Wait();
|
||||||
|
|
||||||
CDCi_ChangeSpiMode( SPI_TRANSMODE_CONTINUOUS );
|
CDCi_ChangeSpiMode( SPI_TRANSMODE_CONTINUOUS );
|
||||||
SPI_SendWait( (u8)(reg << 1) );
|
SPI_SendWait( (u8)((reg << 1) | 1));
|
||||||
|
|
||||||
for ( i=0; i<(size-1); i++ )
|
for ( i=0; i<(size-1); i++ )
|
||||||
{
|
{
|
||||||
|
|||||||
@ -18,24 +18,11 @@
|
|||||||
|
|
||||||
#include "pm_pmic.h"
|
#include "pm_pmic.h"
|
||||||
|
|
||||||
//#define MEASUREMENT_BY_TICK
|
|
||||||
#ifdef MEASUREMENT_BY_TICK
|
|
||||||
#include <twl/vlink.h>
|
|
||||||
|
|
||||||
u64 tick_cdcInit_head = 0;
|
|
||||||
u64 tick_cdcPowerUpPLL_head = 0;
|
|
||||||
u64 tick_cdcInitSound_head = 0;
|
|
||||||
u64 tick_cdcPowerUpDAC_head = 0;
|
|
||||||
u64 tick_cdcSetupDAC_head = 0;
|
|
||||||
u64 tick_cdcEnableHeadphoneDriver_head = 0;
|
|
||||||
u64 tick_cdcEnableSpeakerDriver_head = 0;
|
|
||||||
u64 tick_cdcUnmuteDAC_head = 0;
|
|
||||||
u64 tick_cdcInit_tail = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BOOL isADCOn = FALSE;
|
BOOL isADCOn = FALSE;
|
||||||
BOOL isDACOn = FALSE;
|
BOOL isDACOn = FALSE;
|
||||||
|
|
||||||
#define CDC_PLL_STABLE_WAIT_TIME 18
|
#define CDC_PLL_STABLE_WAIT_TIME 18
|
||||||
|
#define CDC_SCAN_MODE_TIMER_CLOCK_DIVIDER_VALUE 24
|
||||||
|
|
||||||
static void CDCi_PowerUpPLL( void );
|
static void CDCi_PowerUpPLL( void );
|
||||||
static void CDCi_PowerDownPLL( void );
|
static void CDCi_PowerDownPLL( void );
|
||||||
@ -54,49 +41,17 @@ static void CDCi_PowerDownPLL( void );
|
|||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
void CDC_Init( void )
|
void CDC_Init( void )
|
||||||
{
|
{
|
||||||
#ifdef MEASUREMENT_BY_TICK
|
|
||||||
OS_InitTimer();
|
|
||||||
OS_InitTick();
|
|
||||||
// tick_cdcInit_head =OS_GetTick();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
reg_CFG_CLK |= REG_CFG_CLK_SND_MASK;
|
reg_CFG_CLK |= REG_CFG_CLK_SND_MASK;
|
||||||
|
|
||||||
CDC_Reset();
|
CDC_Reset();
|
||||||
|
|
||||||
cdcRevisionID = CDC_GetRevisionId();
|
cdcRevisionID = CDC_GetRevisionId();
|
||||||
|
|
||||||
#ifdef MEASUREMENT_BY_TICK
|
|
||||||
tick_cdcPowerUpPLL_head =OS_GetTick();
|
|
||||||
#endif
|
|
||||||
CDCi_PowerUpPLL();
|
CDCi_PowerUpPLL();
|
||||||
|
|
||||||
#ifdef MEASUREMENT_BY_TICK
|
|
||||||
tick_cdcInitSound_head =OS_GetTick();
|
|
||||||
#endif
|
|
||||||
CDC_InitSound();
|
CDC_InitSound();
|
||||||
#ifdef MEASUREMENT_BY_TICK
|
|
||||||
tick_cdcInit_tail =OS_GetTick();
|
|
||||||
|
|
||||||
OS_TPrintf("CDC_Init = %llu, %6d\n", tick_cdcInit_head,
|
CDC_SetScanModeTimerClockDivider( CDC_SCAN_MODE_TIMER_CLOCK_DIVIDER_VALUE );
|
||||||
OS_TICK_TO_USEC(tick_cdcInit_head));
|
|
||||||
OS_TPrintf("CDC_PowerUpPLL = %llu, %6d\n", tick_cdcPowerUpPLL_head,
|
|
||||||
OS_TICK_TO_USEC(tick_cdcPowerUpPLL_head));
|
|
||||||
OS_TPrintf("CDC_InitSound = %llu, %6d\n", tick_cdcInitSound_head,
|
|
||||||
OS_TICK_TO_USEC(tick_cdcInitSound_head));
|
|
||||||
OS_TPrintf("CDC_PowerUpDAC = %llu, %6d\n", tick_cdcPowerUpDAC_head,
|
|
||||||
OS_TICK_TO_USEC(tick_cdcPowerUpDAC_head));
|
|
||||||
OS_TPrintf("CDC_SetupDAC = %llu, %6d\n", tick_cdcSetupDAC_head,
|
|
||||||
OS_TICK_TO_USEC(tick_cdcSetupDAC_head));
|
|
||||||
OS_TPrintf("CDC_EnableHeadphoneDriver = %llu, %6d\n", tick_cdcEnableHeadphoneDriver_head,
|
|
||||||
OS_TICK_TO_USEC(tick_cdcEnableHeadphoneDriver_head));
|
|
||||||
OS_TPrintf("CDC_EnableSpeakerDriver = %llu, %6d\n", tick_cdcEnableSpeakerDriver_head,
|
|
||||||
OS_TICK_TO_USEC(tick_cdcEnableSpeakerDriver_head));
|
|
||||||
OS_TPrintf("CDC_UnmuteDAC = %llu, %6d\n", tick_cdcUnmuteDAC_head,
|
|
||||||
OS_TICK_TO_USEC(tick_cdcUnmuteDAC_head));
|
|
||||||
OS_TPrintf("CDC_Init tail = %llu, %6d\n", tick_cdcInit_tail,
|
|
||||||
OS_TICK_TO_USEC(tick_cdcInit_tail));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*
|
/*---------------------------------------------------------------------------*
|
||||||
@ -140,31 +95,16 @@ void CDC_InitSound( void )
|
|||||||
// CDC_MuteDAC();
|
// CDC_MuteDAC();
|
||||||
|
|
||||||
// Setup DAC, Speaker Driver, Headphone Driver
|
// Setup DAC, Speaker Driver, Headphone Driver
|
||||||
#ifdef MEASUREMENT_BY_TICK
|
|
||||||
tick_cdcPowerUpDAC_head =OS_GetTick();
|
|
||||||
#endif
|
|
||||||
CDC_PowerUpDAC();
|
CDC_PowerUpDAC();
|
||||||
|
|
||||||
#ifdef MEASUREMENT_BY_TICK
|
|
||||||
tick_cdcSetupDAC_head =OS_GetTick();
|
|
||||||
#endif
|
|
||||||
CDC_SetupDAC( CDC_HP_DRV_PWON_TM_DEFAULT,
|
CDC_SetupDAC( CDC_HP_DRV_PWON_TM_DEFAULT,
|
||||||
CDC_HP_DRV_RAMPUP_TM_DEFAULT,
|
CDC_HP_DRV_RAMPUP_TM_DEFAULT,
|
||||||
CDC_HPSP_DRV_RAMPDWN_TM_DEFAULT );
|
CDC_HPSP_DRV_RAMPDWN_TM_DEFAULT );
|
||||||
|
|
||||||
#ifdef MEASUREMENT_BY_TICK
|
|
||||||
tick_cdcEnableHeadphoneDriver_head =OS_GetTick();
|
|
||||||
#endif
|
|
||||||
CDC_EnableHeadphoneDriver(); // enable headphone driver
|
CDC_EnableHeadphoneDriver(); // enable headphone driver
|
||||||
|
|
||||||
#ifdef MEASUREMENT_BY_TICK
|
|
||||||
tick_cdcEnableSpeakerDriver_head =OS_GetTick();
|
|
||||||
#endif
|
|
||||||
CDC_EnableSpeakerDriver(); // enable speaker driver
|
CDC_EnableSpeakerDriver(); // enable speaker driver
|
||||||
|
|
||||||
#ifdef MEASUREMENT_BY_TICK
|
|
||||||
tick_cdcUnmuteDAC_head =OS_GetTick();
|
|
||||||
#endif
|
|
||||||
CDC_UnmuteDAC();
|
CDC_UnmuteDAC();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +151,7 @@ void CDC_InitMic( void )
|
|||||||
|
|
||||||
Returns: TRUE : CTR-mode, FALSE : DS-mode
|
Returns: TRUE : CTR-mode, FALSE : DS-mode
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
static inline BOOL CDC_IsTwlMode( void )
|
BOOL CDC_IsTwlMode( void )
|
||||||
{
|
{
|
||||||
return cdcIsTwlMode;
|
return cdcIsTwlMode;
|
||||||
}
|
}
|
||||||
@ -266,16 +206,26 @@ void CDC_GoDsMode( void )
|
|||||||
//#ifdef CDC_REVISION_A
|
//#ifdef CDC_REVISION_A
|
||||||
|
|
||||||
// CODEC-IC bug workaround
|
// CODEC-IC bug workaround
|
||||||
CDC_WriteI2cRegister( REG_CDC0_ADC_PWR_STEP_ADDR, CDC0_ADC_PWR_STEP_PWRUP );
|
CDC_PowerUpADC();
|
||||||
CDC_WriteI2cRegister( REG_CDC0_ADC_MUTE_ADDR, CDC0_ADC_MUTE_D );
|
CDC_UnmuteADC();
|
||||||
|
|
||||||
//#endif // CDC_REVISION_A
|
//#endif // CDC_REVISION_A
|
||||||
|
|
||||||
|
///////////////// 箕輪君の要望により+7dB設定を試す(従来の2.5倍音圧相当)
|
||||||
|
CDC_WriteI2cRegister( REG_CDC0_DIG_VOL_L_ADDR, 14 );
|
||||||
|
CDC_WriteI2cRegister( REG_CDC0_DIG_VOL_R_ADDR, 14 );
|
||||||
|
/////////////////
|
||||||
|
|
||||||
// マイクバイアスを設定しておく必要がある。DSモードに入ってからは
|
// マイクバイアスを設定しておく必要がある。DSモードに入ってからは
|
||||||
// この設定を行う手段がない。
|
// この設定を行う手段がない。
|
||||||
CDC_ChangePage( 1 );
|
CDC_ChangePage( 1 );
|
||||||
CDC_WriteI2cRegister( REG_CDC1_MIC_BIAS_ADDR, CDC1_MIC_BIAS_2_5V );
|
CDC_WriteI2cRegister( REG_CDC1_MIC_BIAS_ADDR, CDC1_MIC_BIAS_2_5V );
|
||||||
|
|
||||||
|
// PGA 設定も同様(18.8k 設定でDSと同等のゲインが得られる)
|
||||||
|
CDC_WriteI2cRegister( REG_CDC1_MIC_PGA_P_ADDR, 1 << CDC1_MIC_PGA_P_I_SHIFT);
|
||||||
|
CDC_WriteI2cRegister( REG_CDC1_MIC_PGA_M_ADDR, 1 << CDC1_MIC_PGA_M_I_SHIFT);
|
||||||
|
|
||||||
|
|
||||||
// PLL 設定を DS 用に変更
|
// PLL 設定を DS 用に変更
|
||||||
CDC_WriteI2cRegister( REG_CDC0_PLL_J_ADDR, 21 );
|
CDC_WriteI2cRegister( REG_CDC0_PLL_J_ADDR, 21 );
|
||||||
CDC_WriteI2cRegister( REG_CDC0_NDAC_DIV_ADDR, CDC0_NDAC_DIV_PWR | 7 );
|
CDC_WriteI2cRegister( REG_CDC0_NDAC_DIV_ADDR, CDC0_NDAC_DIV_PWR | 7 );
|
||||||
@ -781,3 +731,33 @@ void CDC_Init1stOrderFilter( u8 *coef, int filter_target )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: CDC_SetScanModeTimerClockDivider
|
||||||
|
|
||||||
|
Description: スキャンモードのクロックディバイダーを設定します。
|
||||||
|
ARM7から供給されるMCLK(12.19MHz)はディバイダーの値に
|
||||||
|
よって分周されます。
|
||||||
|
|
||||||
|
結果として、ディバイダーの値に比例して
|
||||||
|
・インターバルタイマー
|
||||||
|
・デバウンスタイマー
|
||||||
|
の時間がスケールされます。
|
||||||
|
|
||||||
|
基本的には 24 固定とします。
|
||||||
|
|
||||||
|
MCLK = 12.19MHz
|
||||||
|
divider = 24
|
||||||
|
interval time = 16ms 2ms 4ms 6ms 8ms 10ms 12ms 14ms
|
||||||
|
de-bounce time = 0us 16us 32us 64us 128us 256us 512us 1024us
|
||||||
|
|
||||||
|
Arguments: value :
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void CDC_SetScanModeTimerClockDivider( u8 value )
|
||||||
|
{
|
||||||
|
SDK_ASSERT( value < 128);
|
||||||
|
CDC_ChangePage( 3 );
|
||||||
|
CDC_WriteI2cRegister( REG_CDC3_TP_DELAY_CLK_ADDR, value );
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,8 +17,12 @@
|
|||||||
|
|
||||||
#include "spi_sp.h"
|
#include "spi_sp.h"
|
||||||
|
|
||||||
SPIBaudRate cdcDsmodeSPIBaudRate = DSMODE_SPI_BAUDRATE_DEFAULT;
|
/*
|
||||||
|
このソースで定義されているSPIアクセス関数はDSモード時に使用します。
|
||||||
|
TWLモード時は cdc.c の関数を使用してください。
|
||||||
|
*/
|
||||||
|
|
||||||
|
SPIBaudRate cdcDsmodeSPIBaudRate = DSMODE_SPI_BAUDRATE_DEFAULT;
|
||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
// SPI BIT CONTROL
|
// SPI BIT CONTROL
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
# $NoKeywords: $
|
# $NoKeywords: $
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
SUBDIRS = nvram pm # tp mic
|
SUBDIRS = nvram pm tp # mic
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
77
build/libraries/spi/ARM7/tp/Makefile
Normal file
77
build/libraries/spi/ARM7/tp/Makefile
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#! make -f
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Project: NitroSDK - libraries - spi
|
||||||
|
# File: Makefile
|
||||||
|
#
|
||||||
|
# Copyright 2003-2005 Nintendo. All rights reserved.
|
||||||
|
#
|
||||||
|
# These coded instructions, statements, and computer programs contain
|
||||||
|
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
# Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
# not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
# in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
#
|
||||||
|
# $Log: Makefile,v $
|
||||||
|
# Revision 1.7 2005/03/06 23:52:59 terui
|
||||||
|
# Update copyright.
|
||||||
|
#
|
||||||
|
# Revision 1.6 2005/03/05 02:02:04 terui
|
||||||
|
# DEBUGビルド時にRELEASEビルドのコンパイルオプションでビルドされるように改造。
|
||||||
|
#
|
||||||
|
# Revision 1.5 2004/09/06 13:30:37 terui
|
||||||
|
# INCDIRをlibraries/spi/ARM7/includeを指すようにpath変更。
|
||||||
|
#
|
||||||
|
# Revision 1.4 2004/08/27 08:49:21 yasu
|
||||||
|
# Fix around NITRO_CODEGEN_ALL
|
||||||
|
#
|
||||||
|
# Revision 1.3 2004/07/14 14:12:07 yasu
|
||||||
|
# Change NITRO_CODEGEN=ALL -> NITRO_CODEGEN_ALL=True
|
||||||
|
#
|
||||||
|
# Revision 1.2 2004/07/14 11:52:57 yasu
|
||||||
|
# Build ARM & THUMB code always
|
||||||
|
#
|
||||||
|
# Revision 1.1 2004/05/25 01:05:33 terui
|
||||||
|
# TPライブラリをSPIライブラリから分離
|
||||||
|
#
|
||||||
|
# $NoKeywords: $
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SUBDIRS =
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# build ARM & THUMB libraries
|
||||||
|
TWL_CODEGEN_ALL ?= True
|
||||||
|
|
||||||
|
TWL_PROC = ARM7
|
||||||
|
|
||||||
|
SRCDIR = ./src
|
||||||
|
SRCDIR += $(TWL_NITROSDK_ROOT)/build/libraries/spi/ARM7/tp/src \
|
||||||
|
|
||||||
|
SRCS = tp_sp.c tp_sampling.c
|
||||||
|
|
||||||
|
TARGET_LIB = libtp_sp$(TWL_LIBSUFFIX).a
|
||||||
|
INCDIR = ../include
|
||||||
|
INCDIR += $(TWL_NITROSDK_ROOT)/build/libraries/spi/ARM7/include
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# DEBUG版ビルドの場合、RELEASE版でビルドして
|
||||||
|
# DEBUG版のライブラリを装います。
|
||||||
|
|
||||||
|
ifdef NITRO_DEBUG
|
||||||
|
NITRO_BUILD_TYPE = RELEASE
|
||||||
|
endif
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||||
|
|
||||||
|
INSTALL_TARGETS = $(TARGETS)
|
||||||
|
INSTALL_DIR = $(TWL_INSTALL_LIBDIR)
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
do-build: $(TARGETS)
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||||
|
|
||||||
|
#===== End of Makefile =====
|
||||||
964
build/libraries/spi/ARM7/tp/src/tp_sp.c
Normal file
964
build/libraries/spi/ARM7/tp/src/tp_sp.c
Normal file
@ -0,0 +1,964 @@
|
|||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Project: NitroSDK - libraries - spi
|
||||||
|
File: tp_sp.c
|
||||||
|
|
||||||
|
Copyright 2003-2006 Nintendo. All rights reserved.
|
||||||
|
|
||||||
|
These coded instructions, statements, and computer programs contain
|
||||||
|
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
|
||||||
|
$Log: tp_sp.c,v $
|
||||||
|
Revision 1.15 2006/01/18 02:12:29 kitase_hirotake
|
||||||
|
do-indent
|
||||||
|
|
||||||
|
Revision 1.14 2005/02/28 05:26:32 yosizaki
|
||||||
|
do-indent.
|
||||||
|
|
||||||
|
Revision 1.13 2004/12/29 02:04:13 takano_makoto
|
||||||
|
SetStability関数のretryパラメータを廃止
|
||||||
|
|
||||||
|
Revision 1.12 2004/12/20 00:41:05 takano_makoto
|
||||||
|
自動サンプリング時のVAlarmのdelayを設定
|
||||||
|
|
||||||
|
Revision 1.11 2004/12/15 12:02:51 takano_makoto
|
||||||
|
コードの省サイズ化
|
||||||
|
|
||||||
|
Revision 1.10 2004/12/15 09:12:19 takano_makoto
|
||||||
|
rangeの自動調整を追加。tp_sp.hのSDK_TP_AUTO_ADJUST_RANGEによって有効になる。
|
||||||
|
|
||||||
|
Revision 1.9 2004/10/21 04:02:57 terui
|
||||||
|
LCDのライン数定義名を変更。
|
||||||
|
|
||||||
|
Revision 1.8 2004/10/20 06:34:45 terui
|
||||||
|
LCDのライン数定義名を変更
|
||||||
|
|
||||||
|
Revision 1.7 2004/09/06 13:08:42 terui
|
||||||
|
SPI処理予約方式の実装に伴う修正。
|
||||||
|
|
||||||
|
Revision 1.6 2004/08/10 05:07:44 takano_makoto
|
||||||
|
内部リファレンスでサンプリングの場合、TPi_ExecSamplingInSpaceTime()実行後に
|
||||||
|
マイクデバイスの起動処理追加
|
||||||
|
|
||||||
|
Revision 1.5 2004/08/09 13:19:32 takano_makoto
|
||||||
|
MIC自動サンプリング時にTPの1回サンプリングが実行できるように修正
|
||||||
|
|
||||||
|
Revision 1.4 2004/07/31 02:29:20 terui
|
||||||
|
ICのreset処理を一部変更
|
||||||
|
|
||||||
|
Revision 1.3 2004/07/29 13:09:13 takano_makoto
|
||||||
|
TP_InitにICのリセット処理追加
|
||||||
|
|
||||||
|
Revision 1.2 2004/06/03 11:12:10 terui
|
||||||
|
SPIデバイス毎にスレッド優先度を調整する改造。
|
||||||
|
|
||||||
|
Revision 1.1 2004/05/25 01:05:48 terui
|
||||||
|
TPライブラリをSPIライブラリから分離
|
||||||
|
|
||||||
|
Revision 1.2 2004/04/29 10:20:17 terui
|
||||||
|
排他制御を共通関数で行うよう変更
|
||||||
|
|
||||||
|
Revision 1.1 2004/04/14 06:27:50 terui
|
||||||
|
SPIライブラリのソース整理に伴う更新
|
||||||
|
|
||||||
|
$NoKeywords: $
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "tp_sp.h"
|
||||||
|
#include <tp_reg.h> //////////////
|
||||||
|
#include <twl/cdc/ARM7/cdc.h> //////////////
|
||||||
|
#include <twl/cdc/ARM7/cdc_api.h> //////////////
|
||||||
|
|
||||||
|
|
||||||
|
#define PRINT_DEBUG
|
||||||
|
|
||||||
|
#ifdef PRINT_DEBUG
|
||||||
|
#include <nitro/os/common/printf.h>
|
||||||
|
#define DBG_PRINTF OS_TPrintf
|
||||||
|
#else
|
||||||
|
#define DBG_PRINTF( ... ) ((void)0)
|
||||||
|
#define DBG_CHAR( c ) ((void)0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
内部変数定義
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
static TPWork tpw;
|
||||||
|
|
||||||
|
/////////////////////////// TWL
|
||||||
|
tpData_t tpData;
|
||||||
|
///////////////////////////
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
内部関数定義
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
static void TpVAlarmHandler(void *arg);
|
||||||
|
static void SetStability(u16 range);
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
関数定義
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TP_Init
|
||||||
|
|
||||||
|
Description: タッチパネルに関する内部管理変数を初期化する。
|
||||||
|
|
||||||
|
Arguments: None.
|
||||||
|
|
||||||
|
Returns: None.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// CODECの電源は現在SndInitでONになっていたはず。
|
||||||
|
// CDCInitでONにするようにするか?
|
||||||
|
|
||||||
|
// ここでCODECの状態がDSモードかTWLモードかによって
|
||||||
|
// 分岐させるという考えもある。
|
||||||
|
// スレッドを別にする。
|
||||||
|
// TPのスレッドはそういえばSPIスレッドとしてまとめられているんだった。
|
||||||
|
// TP_AnalyzeCommandwを別にするだけでいい?
|
||||||
|
// いやTP_ExecuteProcessでしょ。
|
||||||
|
|
||||||
|
|
||||||
|
void TP_Init(void)
|
||||||
|
{
|
||||||
|
s32 i;
|
||||||
|
|
||||||
|
// 内部状態管理変数をクリア
|
||||||
|
tpw.status = TP_STATUS_READY;
|
||||||
|
tpw.range = SPI_TP_DEFAULT_STABILITY_RANGE;
|
||||||
|
tpw.rangeMin = SPI_TP_DEFAULT_STABILITY_RANGE;
|
||||||
|
|
||||||
|
// PXIコマンド退避用の配列をクリア
|
||||||
|
for (i = 0; i < SPI_PXI_CONTINUOUS_PACKET_MAX; i++)
|
||||||
|
{
|
||||||
|
tpw.command[i] = 0x0000;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vカウントアラームを初期化
|
||||||
|
if (!OS_IsVAlarmAvailable())
|
||||||
|
{
|
||||||
|
OS_InitVAlarm();
|
||||||
|
}
|
||||||
|
for (i = 0; i < SPI_TP_SAMPLING_FREQUENCY_MAX; i++)
|
||||||
|
{
|
||||||
|
OS_CreateVAlarm(&(tpw.vAlarm[i]));
|
||||||
|
OS_SetVAlarmTag(&(tpw.vAlarm[i]), SPI_TP_VALARM_TAG);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CDC_IsTwlMode())
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
tpSetPrechargeTime( TP_SETUP_TIME_0_1US );
|
||||||
|
tpSetSenseTime( TP_SETUP_TIME_0_1US );
|
||||||
|
tpSetStabilizationTime( TP_SETUP_TIME_0_1US ); // 済み
|
||||||
|
|
||||||
|
tpSetDebounceTime( TP_DEBOUNCE_16US );
|
||||||
|
|
||||||
|
tpSetResolution( TP_RESOLUTION_12 ); // 済み
|
||||||
|
tpSetInterval( TP_INTERVAL_4MS ); // 済み
|
||||||
|
|
||||||
|
tpSetTouchPanelDataDepth( TP_DATA_SAMPLE_DEPTH_DEFAULT ); // 済み
|
||||||
|
|
||||||
|
tpSetConvertChannel( TP_CHANNEL_XY ); // 済み
|
||||||
|
|
||||||
|
tpEnableNewBufferMode(); // 済み
|
||||||
|
*/
|
||||||
|
|
||||||
|
TWL_TP_DisableNewBufferMode(); // for TSC2101 mode
|
||||||
|
TWL_TP_SetResolution( TP_RESOLUTION_12 );
|
||||||
|
TWL_TP_SetInterval(TP_INTERVAL_NONE); // for TSC2101 mode
|
||||||
|
TWL_TP_SetTouchPanelDataDepth( 5 /*TP_DATA_SAMPLE_DEPTH_DEFAULT*/ );
|
||||||
|
TWL_TP_SetConvertChannel( TP_CHANNEL_XY );
|
||||||
|
TWL_TP_SetStabilizationTime( TP_SETUP_TIME_100US ); // Yの座標が全部同じになることがあったため0.1us->1us
|
||||||
|
TWL_TP_SetSenseTime( TP_SETUP_TIME_3US ); // Yの座標が全部同じになることがあったため0.1us->1us
|
||||||
|
TWL_TP_SetPrechargeTime( TP_SETUP_TIME_3US ); // Yの座標が全部同じになることがあったため0.1us->1us
|
||||||
|
|
||||||
|
// シングルショットモードに設定する
|
||||||
|
// CDC_ChangePage( 3 );
|
||||||
|
// CDC_SetI2cParams( REG_TP_NEW_BUFFER_MODE, TP_CONVERSION_MODE_SINGLESHOT, TP_CONVERSION_MODE_MASK );
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TP制御ICの初期化
|
||||||
|
/* 8クロック送信後にすぐCSを上げても多分大丈夫とは思うが、
|
||||||
|
将来TPコントローラがコストダウン品に差替わることも考慮して
|
||||||
|
24サイクルでCSを上げる保証された通信方法をとっておく。 */
|
||||||
|
SPI_Wait();
|
||||||
|
TP_SPIChangeMode(SPI_TRANSMODE_CONTINUOUS);
|
||||||
|
SPI_SendWait(TP_COMMAND_DETECT_TOUCH);
|
||||||
|
SPI_DummyWait();
|
||||||
|
TP_SPIChangeMode(SPI_TRANSMODE_1BYTE);
|
||||||
|
SPI_DummyWait();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TP_AnalyzeCommand
|
||||||
|
|
||||||
|
Description: タッチパネル関連PXIコマンドを解析し、処理の準備をする。
|
||||||
|
ここではスレッドに処理要求を予約し、実際のSPI操作はスレッド内
|
||||||
|
で行われる。
|
||||||
|
|
||||||
|
Arguments: data - PXI経由で受け取ったARM9からの要求コマンド。
|
||||||
|
|
||||||
|
Returns: None.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void TP_AnalyzeCommand(u32 data)
|
||||||
|
{
|
||||||
|
// 連続パケット開始をチェック
|
||||||
|
if (data & SPI_PXI_START_BIT)
|
||||||
|
{
|
||||||
|
s32 i;
|
||||||
|
|
||||||
|
// 連続パケット開始ならコマンド退避配列をクリア
|
||||||
|
for (i = 0; i < SPI_PXI_CONTINUOUS_PACKET_MAX; i++)
|
||||||
|
{
|
||||||
|
tpw.command[i] = 0x0000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 受信データをコマンド退避配列に退避
|
||||||
|
tpw.command[(data & SPI_PXI_INDEX_MASK) >> SPI_PXI_INDEX_SHIFT] = (u16)((data &
|
||||||
|
SPI_PXI_DATA_MASK) >>
|
||||||
|
SPI_PXI_DATA_SHIFT);
|
||||||
|
|
||||||
|
if (data & SPI_PXI_END_BIT)
|
||||||
|
{
|
||||||
|
u16 command;
|
||||||
|
u16 wu16[2];
|
||||||
|
|
||||||
|
// 受信データからコマンドを抽出
|
||||||
|
command = (u16)((tpw.command[0] & 0xff00) >> 8);
|
||||||
|
|
||||||
|
// コマンドを解析
|
||||||
|
switch (command)
|
||||||
|
{
|
||||||
|
// サンプリング安定判定パラメータ変更
|
||||||
|
case SPI_PXI_COMMAND_TP_SETUP_STABILITY:
|
||||||
|
wu16[0] = (u16)(tpw.command[0] & 0x00FF);
|
||||||
|
SetStability(wu16[0]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// 単体サンプリング
|
||||||
|
case SPI_PXI_COMMAND_TP_SAMPLING:
|
||||||
|
// TPサンプリング操作をスレッドに予約
|
||||||
|
if (!SPIi_SetEntry(SPI_DEVICE_TYPE_TP, (u32)command, 0))
|
||||||
|
{
|
||||||
|
SPIi_ReturnResult(command, SPI_PXI_RESULT_EXCLUSIVE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
// 自動サンプリング開始
|
||||||
|
case SPI_PXI_COMMAND_TP_AUTO_ON:
|
||||||
|
// 内部状態をチェック
|
||||||
|
if (tpw.status != TP_STATUS_READY)
|
||||||
|
{
|
||||||
|
// 既に自動サンプリング中の場合は不正な状態と見なす
|
||||||
|
SPIi_ReturnResult(command, SPI_PXI_RESULT_ILLEGAL_STATUS);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// "frequency"パラメータをチェック
|
||||||
|
wu16[0] = (u16)(tpw.command[0] & 0x00ff);
|
||||||
|
if ((wu16[0] == 0) || (wu16[0] > SPI_TP_SAMPLING_FREQUENCY_MAX))
|
||||||
|
{
|
||||||
|
SPIi_ReturnResult(command, SPI_PXI_RESULT_INVALID_PARAMETER);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// "vCount"パラメータをチェック
|
||||||
|
wu16[1] = tpw.command[1];
|
||||||
|
if (wu16[1] >= HW_LCD_LINES)
|
||||||
|
{
|
||||||
|
SPIi_ReturnResult(command, SPI_PXI_RESULT_INVALID_PARAMETER);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 自動サンプリング開始操作をスレッドに予約
|
||||||
|
if (!SPIi_SetEntry(SPI_DEVICE_TYPE_TP, (u32)command, 2, (u32)wu16[0], (u32)wu16[1]))
|
||||||
|
{ // スレッドへの処理予約に失敗
|
||||||
|
SPIi_ReturnResult(command, SPI_PXI_RESULT_EXCLUSIVE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 内部状態を更新
|
||||||
|
tpw.status = TP_STATUS_AUTO_START; // 状態を"自動サンプリング開始待ち"へ
|
||||||
|
break;
|
||||||
|
|
||||||
|
// 自動サンプリング停止
|
||||||
|
case SPI_PXI_COMMAND_TP_AUTO_OFF:
|
||||||
|
// 内部状態をチェック
|
||||||
|
if (tpw.status != TP_STATUS_AUTO_SAMPLING)
|
||||||
|
{
|
||||||
|
SPIi_ReturnResult(command, SPI_PXI_RESULT_ILLEGAL_STATUS);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 自動サンプリング停止操作をスレッドに予約
|
||||||
|
if (!SPIi_SetEntry(SPI_DEVICE_TYPE_TP, (u32)command, 0))
|
||||||
|
{ // スレッドへの処理予約に失敗
|
||||||
|
SPIi_ReturnResult(command, SPI_PXI_RESULT_EXCLUSIVE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 内部状態を更新
|
||||||
|
tpw.status = TP_STATUS_AUTO_WAIT_END; // 状態を"自動サンプリング停止待ち"へ
|
||||||
|
break;
|
||||||
|
|
||||||
|
// 不明なコマンド
|
||||||
|
default:
|
||||||
|
SPIi_ReturnResult(command, SPI_PXI_RESULT_INVALID_COMMAND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef SDK_TP_AUTO_ADJUST_RANGE // rangeの自動調整スイッチ
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TP_AutoAdjustRange
|
||||||
|
|
||||||
|
Description: タッチパネルのチャタリング対策パラメータを自動調整します。
|
||||||
|
|
||||||
|
Arguments: tpdata サンプリングしたTPデータ
|
||||||
|
density サンプリング時の座標密度
|
||||||
|
|
||||||
|
Returns: None.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
static void TP_AutoAdjustRange(SPITpData *tpdata, u16 density)
|
||||||
|
{
|
||||||
|
static u8 invalid_cnt = 0;
|
||||||
|
static u8 valid_cnt = 0;
|
||||||
|
#define RANGE_MAX 35
|
||||||
|
#define RANGE_INC_CNT 4
|
||||||
|
#define RANGE_DEC_CNT 4
|
||||||
|
#define RANGE_DEC_CONDITION( d, r ) ( (d) < ( (r) >> 1 ) )
|
||||||
|
|
||||||
|
if (!tpdata->e.touch)
|
||||||
|
{
|
||||||
|
// タッチされていない場合には、カウンタをリセット
|
||||||
|
invalid_cnt = 0;
|
||||||
|
valid_cnt = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// タッチされている場合にはrangeの自動調整をします。
|
||||||
|
|
||||||
|
if (tpdata->e.validity)
|
||||||
|
// INVALIDの場合には invalid_cntをカウントアップします。
|
||||||
|
{
|
||||||
|
valid_cnt = 0;
|
||||||
|
if (++invalid_cnt >= RANGE_INC_CNT) // 一定回数連続してINVALIDを取得した場合にはrangeを調整
|
||||||
|
{
|
||||||
|
invalid_cnt = 0;
|
||||||
|
if (tpw.range < RANGE_MAX)
|
||||||
|
{
|
||||||
|
tpw.range += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// サンプリングした座標値が一定幅以上に収束していたらvalid_cntをカウントアップします。
|
||||||
|
invalid_cnt = 0;
|
||||||
|
if (!RANGE_DEC_CONDITION(density, tpw.range))
|
||||||
|
{
|
||||||
|
valid_cnt = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (++valid_cnt >= RANGE_DEC_CNT)
|
||||||
|
{
|
||||||
|
valid_cnt = 0;
|
||||||
|
if (tpw.range > tpw.rangeMin) // 一定回数連続して余分に収束していた場合にはrangeを調整
|
||||||
|
{
|
||||||
|
tpw.range -= 1;
|
||||||
|
// rangeを減らしてみて駄目だった場合にはすぐに元の状態に戻れるようにしておく。
|
||||||
|
invalid_cnt = RANGE_INC_CNT - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TP_ExecuteProcess
|
||||||
|
|
||||||
|
Description: タッチパネルに関する実際の処理を行う。
|
||||||
|
この関数はSPIを一元管理するスレッドから呼び出される。
|
||||||
|
|
||||||
|
Arguments: entry - エントリー構造体へのポインタ。
|
||||||
|
|
||||||
|
Returns: None.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void TP_ExecuteProcess(SPIEntry * entry)
|
||||||
|
{
|
||||||
|
switch (entry->process)
|
||||||
|
{
|
||||||
|
// 自動サンプリング( VAlarmからのエントリー )
|
||||||
|
case SPI_PXI_COMMAND_TP_AUTO_SAMPLING:
|
||||||
|
if (tpw.status != TP_STATUS_AUTO_SAMPLING)
|
||||||
|
{
|
||||||
|
// 自動サンプリング中でない場合は何もせずに終了
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 単体サンプリング
|
||||||
|
case SPI_PXI_COMMAND_TP_SAMPLING:
|
||||||
|
|
||||||
|
// 排他はCDC_ReadSpiRegister(s)内部でのSPI_Lock()->SPIi_GetExceptionで実現する
|
||||||
|
/*
|
||||||
|
// 排他制御開始
|
||||||
|
{
|
||||||
|
OSIntrMode e;
|
||||||
|
|
||||||
|
e = OS_DisableInterrupts();
|
||||||
|
if (!SPIi_CheckException(SPI_DEVICE_TYPE_TP))
|
||||||
|
{
|
||||||
|
(void)OS_RestoreInterrupts(e);
|
||||||
|
// 外部スレッドからのSPI排他中
|
||||||
|
SPIi_ReturnResult((u16)(entry->process), SPI_PXI_RESULT_EXCLUSIVE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SPIi_GetException(SPI_DEVICE_TYPE_TP);
|
||||||
|
(void)OS_RestoreInterrupts(e);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
// サンプリングを実行
|
||||||
|
{
|
||||||
|
SPITpData temp;
|
||||||
|
|
||||||
|
if (CDC_IsTwlMode())
|
||||||
|
{
|
||||||
|
// OSTick tick = OS_GetTick(); ///////////////////////
|
||||||
|
|
||||||
|
if (TWL_TP_ReadBuffer(&temp))
|
||||||
|
{
|
||||||
|
// システム領域に書き出し( 2バイトアクセス )
|
||||||
|
*((u16 *)(&(OS_GetSystemWork()->touch_panel[0]))) = temp.halfs[0];
|
||||||
|
*((u16 *)(&(OS_GetSystemWork()->touch_panel[2]))) = temp.halfs[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
// DBG_PRINTF("TWL_TP_ReadBuffer = %6d us\n", OS_TicksToMicroSeconds(OS_GetTick() - tick)); /////////
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// OSTick tick = OS_GetTick(); /////////////////
|
||||||
|
|
||||||
|
#ifdef SDK_TP_AUTO_ADJUST_RANGE // rangeの自動調整スイッチ
|
||||||
|
u16 density;
|
||||||
|
TP_ExecSampling(&temp, tpw.range, &density);
|
||||||
|
TP_AutoAdjustRange(&temp, density);
|
||||||
|
#else
|
||||||
|
TP_ExecSampling(&temp, tpw.range);
|
||||||
|
#endif
|
||||||
|
// システム領域に書き出し( 2バイトアクセス )
|
||||||
|
*((u16 *)(&(OS_GetSystemWork()->touch_panel[0]))) = temp.halfs[0];
|
||||||
|
*((u16 *)(&(OS_GetSystemWork()->touch_panel[2]))) = temp.halfs[1];
|
||||||
|
|
||||||
|
// DBG_PRINTF("TP_ExecSampling = %6d us\n", OS_TicksToMicroSeconds(OS_GetTick() - tick)); /////////
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ARM9に処理の成功を通達
|
||||||
|
if (entry->process == SPI_PXI_COMMAND_TP_SAMPLING)
|
||||||
|
{
|
||||||
|
// 単体サンプリングの応答
|
||||||
|
SPIi_ReturnResult((u16)(entry->process), SPI_PXI_RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 自動サンプリングのインジケート
|
||||||
|
SPIi_ReturnResult((u16)(entry->process), (u16)(entry->arg[0] & 0x00ff));
|
||||||
|
}
|
||||||
|
// 排他制御終了
|
||||||
|
// SPIi_ReleaseException(SPI_DEVICE_TYPE_TP);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// 自動サンプリング開始
|
||||||
|
case SPI_PXI_COMMAND_TP_AUTO_ON:
|
||||||
|
if (tpw.status == TP_STATUS_AUTO_START)
|
||||||
|
{
|
||||||
|
s32 i;
|
||||||
|
|
||||||
|
// Vアラームを起動
|
||||||
|
for (i = 0; i < entry->arg[0]; i++)
|
||||||
|
{
|
||||||
|
// 総ライン数をサンプリング頻度で分割し、各Vカウントを計算
|
||||||
|
tpw.vCount[i] = (u16)((entry->arg[1] +
|
||||||
|
((i * HW_LCD_LINES) / entry->arg[0])) % HW_LCD_LINES);
|
||||||
|
// Vカウントアラームを開始(割込みハンドラ外でないといけない)
|
||||||
|
OS_SetPeriodicVAlarm(&(tpw.vAlarm[i]),
|
||||||
|
(s16)(tpw.vCount[i]),
|
||||||
|
TP_VALARM_DELAY_MAX, TpVAlarmHandler, (void *)i);
|
||||||
|
}
|
||||||
|
// ARM9に処理の成功を通達
|
||||||
|
SPIi_ReturnResult((u16)(entry->process), SPI_PXI_RESULT_SUCCESS);
|
||||||
|
// 内部状態を更新
|
||||||
|
tpw.status = TP_STATUS_AUTO_SAMPLING; // 状態を"自動サンプリング中"へ
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// ARM9に処理の失敗を通達
|
||||||
|
SPIi_ReturnResult((u16)(entry->process), SPI_PXI_RESULT_ILLEGAL_STATUS);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
// 自動サンプリング停止
|
||||||
|
case SPI_PXI_COMMAND_TP_AUTO_OFF:
|
||||||
|
if (tpw.status == TP_STATUS_AUTO_WAIT_END)
|
||||||
|
{
|
||||||
|
// Vアラームを止める
|
||||||
|
OS_CancelVAlarms(SPI_TP_VALARM_TAG);
|
||||||
|
// ARM9に処理の成功を通達
|
||||||
|
SPIi_ReturnResult((u16)(entry->process), SPI_PXI_RESULT_SUCCESS);
|
||||||
|
// 内部状態を更新
|
||||||
|
tpw.status = TP_STATUS_READY; // 状態を"通常操作待ち"へ
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// ARM9に処理の失敗を通達
|
||||||
|
SPIi_ReturnResult((u16)(entry->process), SPI_PXI_RESULT_ILLEGAL_STATUS);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TpVAlarmHandler
|
||||||
|
|
||||||
|
Description: Vカウントアラームのハンドラ。
|
||||||
|
一回サンプリングする度に止まるスレッドを再開させる。
|
||||||
|
|
||||||
|
Arguments: arg - 複数あるVカウントアラームのID
|
||||||
|
|
||||||
|
Returns: None.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
static void TpVAlarmHandler(void *arg)
|
||||||
|
{
|
||||||
|
// TPサンプリング操作をスレッドに予約
|
||||||
|
if (!SPIi_SetEntry(SPI_DEVICE_TYPE_TP, SPI_PXI_COMMAND_TP_AUTO_SAMPLING, 1, (u32)arg))
|
||||||
|
{ // スレッドへのサンプリング処理予約に失敗
|
||||||
|
SPITpData temp;
|
||||||
|
|
||||||
|
// サンプリングデータを偽装
|
||||||
|
temp.e.validity = SPI_TP_VALIDITY_INVALID_XY;
|
||||||
|
// システム領域に書き出し( 2バイトアクセス )
|
||||||
|
*((u16 *)(&(OS_GetSystemWork()->touch_panel[0]))) = temp.halfs[0];
|
||||||
|
*((u16 *)(&(OS_GetSystemWork()->touch_panel[2]))) = temp.halfs[1];
|
||||||
|
// 自動サンプリングのインジケート
|
||||||
|
SPIi_ReturnResult(SPI_PXI_COMMAND_TP_AUTO_SAMPLING, (u16)((u32)arg & 0x00ff));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: SetStability
|
||||||
|
|
||||||
|
Description: タッチパネルの安定判定パラメータを変更。
|
||||||
|
|
||||||
|
Arguments: range 値の誤差の閾値.
|
||||||
|
|
||||||
|
Returns: None.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
static void SetStability(u16 range)
|
||||||
|
{
|
||||||
|
// rangeパラメータをチェック
|
||||||
|
if (range == 0)
|
||||||
|
{
|
||||||
|
SPIi_ReturnResult(SPI_PXI_COMMAND_TP_SETUP_STABILITY, SPI_PXI_RESULT_INVALID_PARAMETER);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 安定判定パラメータ(内部管理)を変更
|
||||||
|
tpw.range = (s32)range;
|
||||||
|
tpw.rangeMin = (s32)range;
|
||||||
|
|
||||||
|
// ARM9に処理の成功を通達
|
||||||
|
SPIi_ReturnResult(SPI_PXI_COMMAND_TP_SETUP_STABILITY, SPI_PXI_RESULT_SUCCESS);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TWL_TP_SetTouchPanelDataDepth
|
||||||
|
|
||||||
|
Description: set touch-panel data depth (1 <= depth <= 8)
|
||||||
|
|
||||||
|
Arguments: int depth : data depth (1<= depth <= 8)
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/ //TODO: depthの切り替えはPage3, Reg14, D7 is "0"の状態で行うように修正する
|
||||||
|
void TWL_TP_SetTouchPanelDataDepth( u8 depth )
|
||||||
|
{
|
||||||
|
u8 tmp;
|
||||||
|
|
||||||
|
SDK_ASSERT( (1 <= depth) && (depth <= 8) );
|
||||||
|
|
||||||
|
tmp = (u8)(depth << TP_DATA_DEPTH_SHIFT);
|
||||||
|
if (depth == 8) tmp = 0;
|
||||||
|
|
||||||
|
CDC_ChangePage( 3 );
|
||||||
|
CDC_SetI2cParams( REG_TP_DATA_DEPTH, tmp, TP_DATA_DEPTH_MASK );
|
||||||
|
|
||||||
|
tpData.tpDepth = depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TWL_TP_SetConvertChannel
|
||||||
|
|
||||||
|
Description: set ADC target channel
|
||||||
|
|
||||||
|
Arguments: TpChannel_t ch : Convert Channel
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void TWL_TP_SetConvertChannel( TpChannel_t ch )
|
||||||
|
{
|
||||||
|
SDK_ASSERT( (ch == TP_CHANNEL_NONE) || (ch == TP_CHANNEL_XY) ||
|
||||||
|
(ch == TP_CHANNEL_XYZ) || (ch == TP_CHANNEL_X) ||
|
||||||
|
(ch == TP_CHANNEL_Y) || (ch == TP_CHANNEL_Z) ||
|
||||||
|
(ch == TP_CHANNEL_AUX3) || (ch == TP_CHANNEL_AUX2) ||
|
||||||
|
(ch == TP_CHANNEL_AUX1) || (ch == TP_CHANNEL_AUTO_AUX) ||
|
||||||
|
(ch == TP_CHANNEL_AUX123) || (ch == TP_CHANNEL_XP_XM) ||
|
||||||
|
(ch == TP_CHANNEL_YP_YM) || (ch == TP_CHANNEL_YP_XM) );
|
||||||
|
|
||||||
|
CDC_ChangePage( 3 );
|
||||||
|
|
||||||
|
// i_tpWriteSpiRegister( REG_TP_CHANNEL, ch );
|
||||||
|
// cdcWriteI2cRegister( REG_TP_CHANNEL, ch );
|
||||||
|
// CDC_WriteI2cRegister( REG_TP_CHANNEL, ch ); // TODO: マスク書き換えに修正する
|
||||||
|
|
||||||
|
// CDC_WriteI2cRegister( REG_TP_CHANNEL, (ch & 0x7f) ); // 強引にホストコントロールモード
|
||||||
|
|
||||||
|
CDC_WriteI2cRegister( REG_TP_CHANNEL, (u8)(ch & 0xfd) ); // 2101 & self
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TWL_TP_SetInterval
|
||||||
|
|
||||||
|
Description: set Touch-Panel / AUX Interval Time
|
||||||
|
Either Touch-Panel or AUX can be enabled, the last setting
|
||||||
|
is only valid. Normally, Touch-Panel is enabled.
|
||||||
|
|
||||||
|
Arguments: tpInterval_t interval : interval time between sampling
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void TWL_TP_SetInterval( tpInterval_t interval )
|
||||||
|
{
|
||||||
|
SDK_ASSERT( (interval == TP_INTERVAL_NONE) ||
|
||||||
|
(interval == TP_INTERVAL_8MS) || (interval == TP_AUX_INTERVAL_1_12M) ||
|
||||||
|
(interval == TP_INTERVAL_1MS) || (interval == TP_AUX_INTERVAL_3_36M) ||
|
||||||
|
(interval == TP_INTERVAL_2MS) || (interval == TP_AUX_INTERVAL_5_59M) ||
|
||||||
|
(interval == TP_INTERVAL_3MS) || (interval == TP_AUX_INTERVAL_7_83M) ||
|
||||||
|
(interval == TP_INTERVAL_4MS) || (interval == TP_AUX_INTERVAL_10_01M) ||
|
||||||
|
(interval == TP_INTERVAL_5MS) || (interval == TP_AUX_INTERVAL_12_30M) ||
|
||||||
|
(interval == TP_INTERVAL_6MS) || (interval == TP_AUX_INTERVAL_14_54M) ||
|
||||||
|
(interval == TP_INTERVAL_7MS) || (interval == TP_AUX_INTERVAL_16_78M)
|
||||||
|
);
|
||||||
|
|
||||||
|
// i_tpChangePage( 3 );
|
||||||
|
CDC_ChangePage( 3 );
|
||||||
|
|
||||||
|
// i_tpWriteSpiRegister( REG_TP_INTERVAL, interval );
|
||||||
|
// cdcWriteI2cRegister( REG_TP_INTERVAL, interval );
|
||||||
|
CDC_WriteI2cRegister( REG_TP_INTERVAL, interval );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: tpEnableNewBufferMode
|
||||||
|
|
||||||
|
Description: enable new buffer mode
|
||||||
|
|
||||||
|
Arguments: None
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void TWL_TP_EnableNewBufferMode( void )
|
||||||
|
{
|
||||||
|
// i_tpChangePage( 3 );
|
||||||
|
CDC_ChangePage( 3 );
|
||||||
|
|
||||||
|
// i_tpSetSpiParams( REG_TP_NEW_BUFFER_MODE, TP_NEW_BUFFER_MODE_E, TP_NEW_BUFFER_MODE_MASK );
|
||||||
|
// i_tpSetI2cParams( REG_TP_NEW_BUFFER_MODE, TP_NEW_BUFFER_MODE_E, TP_NEW_BUFFER_MODE_MASK );
|
||||||
|
CDC_SetI2cParams( REG_TP_NEW_BUFFER_MODE, TP_NEW_BUFFER_MODE_E, TP_NEW_BUFFER_MODE_MASK );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: tpDisableNewBufferMode
|
||||||
|
|
||||||
|
Description: disable new buffer mode
|
||||||
|
|
||||||
|
Arguments: None
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void TWL_TP_DisableNewBufferMode( void )
|
||||||
|
{
|
||||||
|
// i_tpChangePage( 3 );
|
||||||
|
CDC_ChangePage( 3 );
|
||||||
|
|
||||||
|
// i_tpSetSpiParams( REG_TP_NEW_BUFFER_MODE, TP_NEW_BUFFER_MODE_D, TP_NEW_BUFFER_MODE_MASK );
|
||||||
|
// i_tpSetI2cParams( REG_TP_NEW_BUFFER_MODE, TP_NEW_BUFFER_MODE_D, TP_NEW_BUFFER_MODE_MASK );
|
||||||
|
CDC_SetI2cParams( REG_TP_NEW_BUFFER_MODE, TP_NEW_BUFFER_MODE_D, TP_NEW_BUFFER_MODE_MASK );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TWL_TP_SetResolution
|
||||||
|
|
||||||
|
Description: set AD Converting Resolution (8, 10, or 12-bit)
|
||||||
|
|
||||||
|
Arguments: TpResolution_t res : Converting Resolution
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void TWL_TP_SetResolution( TpResolution_t res )
|
||||||
|
{
|
||||||
|
SDK_ASSERT( (res == TP_RESOLUTION_12) ||
|
||||||
|
(res == TP_RESOLUTION_8) ||
|
||||||
|
(res == TP_RESOLUTION_10) );
|
||||||
|
|
||||||
|
// i_tpChangePage( 3 );
|
||||||
|
CDC_ChangePage( 3 );
|
||||||
|
|
||||||
|
|
||||||
|
// i_tpSetSpiParams( REG_TP_RESOLUTION, res, TP_RESOLUTION_MASK );
|
||||||
|
// i_tpSetI2cParams( REG_TP_RESOLUTION, res, TP_RESOLUTION_MASK );
|
||||||
|
CDC_SetI2cParams( REG_TP_RESOLUTION, res, TP_RESOLUTION_MASK );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TWL_TP_GetResolution
|
||||||
|
|
||||||
|
Description: get AD Converting Resolution (8, 10, or 12-bit)
|
||||||
|
|
||||||
|
Arguments: TpResolution_t *res : Converting Resolution
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void TWL_TP_GetResolution( TpResolution_t *res )
|
||||||
|
{
|
||||||
|
// i_tpChangePage( 3 );
|
||||||
|
CDC_ChangePage( 3 );
|
||||||
|
|
||||||
|
// *res = (TpResolution_t)(i_tpReadSpiRegister( REG_TP_RESOLUTION ) & TP_RESOLUTION_MASK);
|
||||||
|
// *res = (TpResolution_t)( cdcReadI2cRegister( REG_TP_RESOLUTION ) & TP_RESOLUTION_MASK);
|
||||||
|
*res = (TpResolution_t)( CDC_ReadI2cRegister( REG_TP_RESOLUTION ) & TP_RESOLUTION_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TWL_TP_SetStabilizationTime
|
||||||
|
|
||||||
|
Description: set ADC stabilization time before touch detection
|
||||||
|
|
||||||
|
Arguments: TpSetupTime_t time : stabilization time
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void TWL_TP_SetStabilizationTime( TpSetupTime_t time )
|
||||||
|
{
|
||||||
|
SDK_ASSERT( (TP_SETUP_TIME_0_1US <= time) || (time <= TP_SETUP_TIME_1MS) );
|
||||||
|
|
||||||
|
CDC_ChangePage( 3 );
|
||||||
|
CDC_SetI2cParams( REG_TP_STABILIZATION_TIME, time, TP_STABILIZATION_TIME_MASK );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TWL_TP_SetPrechargeTime
|
||||||
|
|
||||||
|
Description: set ADC precharge time before touch detection
|
||||||
|
|
||||||
|
Arguments: TpSetupTime_t time : precharge time
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void TWL_TP_SetPrechargeTime( TpSetupTime_t time )
|
||||||
|
{
|
||||||
|
SDK_ASSERT( (TP_SETUP_TIME_0_1US <= time) || (time <= TP_SETUP_TIME_1MS) );
|
||||||
|
|
||||||
|
CDC_ChangePage( 3 );
|
||||||
|
CDC_SetI2cParams( REG_TP_PRECHARGE, (u8)(time << TP_PRECHARGE_SHIFT), TP_PRECHARGE_MASK );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TWL_TP_SetSenseTime
|
||||||
|
|
||||||
|
Description: set ADC sense time before touch detection
|
||||||
|
|
||||||
|
Arguments: TpSetupTime_t time : sense time
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void TWL_TP_SetSenseTime( TpSetupTime_t time )
|
||||||
|
{
|
||||||
|
SDK_ASSERT( (TP_SETUP_TIME_0_1US <= time) || (time <= TP_SETUP_TIME_1MS) );
|
||||||
|
|
||||||
|
CDC_ChangePage( 3 );
|
||||||
|
CDC_SetI2cParams( REG_TP_SENSE_TIME, time, TP_SENSE_TIME_MASK );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TWL_TP_IS_TOUCH
|
||||||
|
|
||||||
|
Description: タッチパネル接触判定
|
||||||
|
|
||||||
|
Arguments: none
|
||||||
|
|
||||||
|
Returns: BOOL : if touched, return TRUE. otherwise FALSE.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
static BOOL TWL_TP_IS_TOUCH( void )
|
||||||
|
{
|
||||||
|
vu8 penup = 0;
|
||||||
|
|
||||||
|
penup = CDC_ReadSpiRegister( 9 );
|
||||||
|
if ((penup & 0x80) == 0x00)
|
||||||
|
{
|
||||||
|
penup = CDC_ReadSpiRegister( 9 );
|
||||||
|
if ((penup & 0x80) == 0x00)
|
||||||
|
{
|
||||||
|
penup = CDC_ReadSpiRegister( 9 );
|
||||||
|
if ((penup & 0x80) == 0x00)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define ABS(x) ( ( (x) >= 0 ) ? (x) : ( -(x) ) )
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TWL_TP_ReadBuffer
|
||||||
|
|
||||||
|
Description: read Touch-Panel Buffer
|
||||||
|
|
||||||
|
Arguments: data : データ格納ポインタ
|
||||||
|
|
||||||
|
Returns: BOOL : if read success, return TRUE. otherwise FALSE.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
BOOL TWL_TP_ReadBuffer( SPITpData *data )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int target_index = 0; // 今からデータを格納する領域の先頭インデックス
|
||||||
|
u8 buf[32];
|
||||||
|
u8 not_readready;
|
||||||
|
|
||||||
|
// (void)cdcLock(); // CODECデバイスの操作権利を取得
|
||||||
|
|
||||||
|
CDC_ChangePage( 3 );
|
||||||
|
|
||||||
|
|
||||||
|
// ペンアップ判定
|
||||||
|
if (!TWL_TP_IS_TOUCH())
|
||||||
|
{
|
||||||
|
data->e.touch = FALSE;
|
||||||
|
data->e.validity = FALSE;
|
||||||
|
return TRUE; // ここはペンアップとしてシステム領域に書き出す
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
//----- Availableチェック
|
||||||
|
not_readready = (u8)(CDC_ReadI2cRegister( 9 ));
|
||||||
|
if ((not_readready && 0x0c) == 0x0c)
|
||||||
|
{
|
||||||
|
(void)cdcUnlock(); // CODECデバイスの操作権利を解放 (忘れずに)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (tpData.tpIndex == 0)
|
||||||
|
target_index = TP_DATA_SAMPLE_DEPTH_MAX;
|
||||||
|
|
||||||
|
|
||||||
|
for (i=0;i<tpData.tpDepth;i++)
|
||||||
|
{
|
||||||
|
// OS_SpinWait(100); // サンプリング時間が不足しているようなら追加も検討(ここは本来レディチェックするべき)
|
||||||
|
|
||||||
|
// XYサンプリング
|
||||||
|
CDC_ReadSpiRegisters( 42, &buf[i*4], 4 );
|
||||||
|
|
||||||
|
// サンプリング後のペンアップ判定 (サンプリング時間も稼げる)
|
||||||
|
if (!TWL_TP_IS_TOUCH())
|
||||||
|
{
|
||||||
|
return FALSE; // システム領域には書き出さない
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (i=0; i<tpData.tpDepth; i++)
|
||||||
|
{
|
||||||
|
tpData.xBuf[target_index+i] = (u16)((buf[i*4] << 8) | buf[i*4 + 1]);
|
||||||
|
tpData.yBuf[target_index+i] = (u16)((buf[i*4 + 2] << 8) | buf[i*4 + 3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
tpData.tpIndex = target_index;
|
||||||
|
|
||||||
|
// (void)cdcUnlock(); // CODECデバイスの操作権利を解放
|
||||||
|
|
||||||
|
{
|
||||||
|
int i, j, index;
|
||||||
|
int xSum = 0;
|
||||||
|
int ySum = 0;
|
||||||
|
int same_required = (tpData.tpDepth >> 1) + 1;
|
||||||
|
int same_chance = tpData.tpDepth - same_required + 1;
|
||||||
|
int same_count = 0;
|
||||||
|
|
||||||
|
index = tpData.tpIndex;
|
||||||
|
|
||||||
|
/*
|
||||||
|
// ペンアップbitチェック
|
||||||
|
for (i=0; i<tpData.tpDepth; i++, index++)
|
||||||
|
{
|
||||||
|
if ((tpData.xBuf[index] & TP_NOT_TOUCH_MASK) || (tpData.yBuf[index] & TP_NOT_TOUCH_MASK))
|
||||||
|
{
|
||||||
|
data->e.touch = FALSE;
|
||||||
|
data->e.validity = FALSE;
|
||||||
|
return TRUE; // ここはペンアップとしてシステム領域に書き出す
|
||||||
|
}
|
||||||
|
// xSum += tpData.xBuf[index];
|
||||||
|
// ySum += tpData.yBuf[index];
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
index = tpData.tpIndex;
|
||||||
|
|
||||||
|
// サンプリングした内の半数以上がrange以内であればvalidなデータとする。
|
||||||
|
for (i=0; i<same_chance; i++)
|
||||||
|
{
|
||||||
|
same_count = 0;
|
||||||
|
xSum = tpData.xBuf[index + i];
|
||||||
|
ySum = tpData.yBuf[index + i];
|
||||||
|
|
||||||
|
for (j=0; j<tpData.tpDepth; j++)
|
||||||
|
{
|
||||||
|
if (i==j) { continue; }
|
||||||
|
if ((ABS( tpData.xBuf[index + i] - tpData.xBuf[index + j] ) < 5) &&
|
||||||
|
(ABS( tpData.yBuf[index + i] - tpData.yBuf[index + j] ) < 5))
|
||||||
|
{
|
||||||
|
same_count++;
|
||||||
|
xSum += tpData.xBuf[index + j];
|
||||||
|
ySum += tpData.yBuf[index + j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (same_count >= same_required) { break; }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (same_count < same_required)
|
||||||
|
{
|
||||||
|
return FALSE; // システム領域には書き出さない
|
||||||
|
}
|
||||||
|
|
||||||
|
data->e.x = xSum / (same_count+1);
|
||||||
|
data->e.y = ySum / (same_count+1);
|
||||||
|
data->e.touch = TRUE;
|
||||||
|
data->e.validity = TRUE;
|
||||||
|
|
||||||
|
//DBG_PRINTF("x : %4d %4d %4d %4d %4d %4d %4d %4d -> %4d\n", tpData.xBuf[index], tpData.xBuf[index + 1], tpData.xBuf[index + 2], tpData.xBuf[index + 3], tpData.xBuf[index + 4], tpData.xBuf[index + 5], tpData.xBuf[index + 6], tpData.xBuf[index + 7], data->e.x);
|
||||||
|
//DBG_PRINTF("y : %4d %4d %4d %4d %4d %4d %4d %4d -> %4d\n\n", tpData.yBuf[index], tpData.yBuf[index + 1], tpData.yBuf[index + 2], tpData.yBuf[index + 3], tpData.yBuf[index + 4], tpData.yBuf[index + 5], tpData.yBuf[index + 6], tpData.yBuf[index + 7], data->e.y);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
End of file
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
@ -603,11 +603,12 @@ void TP_SetCalibrateParam(const TPCalibrateParam *param)
|
|||||||
|
|
||||||
if (param->xDotSize != 0)
|
if (param->xDotSize != 0)
|
||||||
{
|
{
|
||||||
CP_SetDiv32_32(0x10000000, (u32)param->xDotSize);
|
// CP_SetDiv32_32(0x10000000, (u32)param->xDotSize);
|
||||||
|
|
||||||
tpState.calibrate.x0 = param->x0;
|
tpState.calibrate.x0 = param->x0;
|
||||||
tpState.calibrate.xDotSize = param->xDotSize;
|
tpState.calibrate.xDotSize = param->xDotSize;
|
||||||
tpState.calibrate.xDotSizeInv = (s32)CP_GetDivResult32();
|
// tpState.calibrate.xDotSizeInv = (s32)CP_GetDivResult32();
|
||||||
|
tpState.calibrate.xDotSizeInv = (s32)0x10000000/param->xDotSize;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -618,11 +619,12 @@ void TP_SetCalibrateParam(const TPCalibrateParam *param)
|
|||||||
|
|
||||||
if (param->yDotSize != 0)
|
if (param->yDotSize != 0)
|
||||||
{
|
{
|
||||||
CP_SetDiv32_32(0x10000000, (u32)param->yDotSize);
|
// CP_SetDiv32_32(0x10000000, (u32)param->yDotSize);
|
||||||
|
|
||||||
tpState.calibrate.y0 = param->y0;
|
tpState.calibrate.y0 = param->y0;
|
||||||
tpState.calibrate.yDotSize = param->yDotSize;
|
tpState.calibrate.yDotSize = param->yDotSize;
|
||||||
tpState.calibrate.yDotSizeInv = (s32)CP_GetDivResult32();
|
// tpState.calibrate.yDotSizeInv = (s32)CP_GetDivResult32();
|
||||||
|
tpState.calibrate.yDotSizeInv = (s32)0x10000000/param->yDotSize;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1086,13 +1088,15 @@ u32 TP_CalcCalibrateParam(TPCalibrateParam *calibrate,
|
|||||||
enabled = OS_DisableInterrupts();
|
enabled = OS_DisableInterrupts();
|
||||||
|
|
||||||
// xDotSize‚ðŒvŽZ
|
// xDotSize‚ðŒvŽZ
|
||||||
CP_SetDiv32_32(((u32)rx_width) << TP_CALIBRATE_DOT_SCALE_SHIFT, (u32)dx_width);
|
// CP_SetDiv32_32(((u32)rx_width) << TP_CALIBRATE_DOT_SCALE_SHIFT, (u32)dx_width);
|
||||||
|
|
||||||
ry_width = raw_y1 - raw_y2;
|
ry_width = raw_y1 - raw_y2;
|
||||||
dy_width = dy1 - dy2;
|
dy_width = dy1 - dy2;
|
||||||
|
|
||||||
tmp32 = CP_GetDivResult32();
|
// tmp32 = CP_GetDivResult32();
|
||||||
CP_SetDiv32_32(((u32)ry_width) << TP_CALIBRATE_DOT_SCALE_SHIFT, (u32)dy_width);
|
tmp32 = ((rx_width) << TP_CALIBRATE_DOT_SCALE_SHIFT)/dx_width;
|
||||||
|
|
||||||
|
// CP_SetDiv32_32(((u32)ry_width) << TP_CALIBRATE_DOT_SCALE_SHIFT, (u32)dy_width);
|
||||||
|
|
||||||
if (!IN_S16_RANGE(tmp32))
|
if (!IN_S16_RANGE(tmp32))
|
||||||
{
|
{
|
||||||
@ -1111,7 +1115,9 @@ u32 TP_CalcCalibrateParam(TPCalibrateParam *calibrate,
|
|||||||
}
|
}
|
||||||
calibrate->x0 = (s16)tmp32;
|
calibrate->x0 = (s16)tmp32;
|
||||||
|
|
||||||
tmp32 = CP_GetDivResult32();
|
// tmp32 = CP_GetDivResult32();
|
||||||
|
tmp32 = ((ry_width) << TP_CALIBRATE_DOT_SCALE_SHIFT)/dy_width;
|
||||||
|
|
||||||
(void)OS_RestoreInterrupts(enabled);
|
(void)OS_RestoreInterrupts(enabled);
|
||||||
|
|
||||||
if (!IN_S16_RANGE(tmp32))
|
if (!IN_S16_RANGE(tmp32))
|
||||||
|
|||||||
@ -20,7 +20,10 @@ include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
|||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
SUBDIRS = tp-3 \
|
SUBDIRS = tp-sampling \
|
||||||
|
tp-sampling-twl-mode \
|
||||||
|
tp-auto-sampling \
|
||||||
|
tp-auto-sampling-twl-mode
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
196
build/tests/spi/tp-auto-sampling-twl-mode/ARM7/src/main.c
Normal file
196
build/tests/spi/tp-auto-sampling-twl-mode/ARM7/src/main.c
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Project: TwlSDK - tests - snd - channel
|
||||||
|
File: main.c
|
||||||
|
|
||||||
|
Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
|
||||||
|
These coded instructions, statements, and computer programs contain
|
||||||
|
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
|
||||||
|
$Log: main.c,v $
|
||||||
|
$NoKeywords: $
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
TP_RequestAutoSamplingStart のテストプログラムです。
|
||||||
|
|
||||||
|
最初にキャリブレーションの処理を入れています。
|
||||||
|
画面に表示される2点をタッチしてください。
|
||||||
|
|
||||||
|
tp-auto-sampling と
|
||||||
|
tp-auto-sampling-twlmode の違いは、
|
||||||
|
ARM7側のコードで CDC_GoDsMode() を呼ぶかどうかの違いだけです。
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <twl_sp.h>
|
||||||
|
#include <twl/cdc.h> // for DS mode
|
||||||
|
#include <twl/snd/ARM7/i2s.h>
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
定数定義
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
// ===== スレッド優先度 =====
|
||||||
|
|
||||||
|
#define THREAD_PRIO_SPI 2
|
||||||
|
#define THREAD_PRIO_SND 6
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
内部関数定義
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
static OSHeapHandle InitializeAllocateSystem(void);
|
||||||
|
static void VBlankIntr(void);
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TwlSpMain
|
||||||
|
|
||||||
|
Description: Initialize and do main
|
||||||
|
|
||||||
|
Arguments: None.
|
||||||
|
|
||||||
|
Returns: None.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void TwlSpMain(void)
|
||||||
|
{
|
||||||
|
OSHeapHandle heapHandle;
|
||||||
|
|
||||||
|
// OS初期化
|
||||||
|
OS_Init();
|
||||||
|
OS_InitThread();
|
||||||
|
|
||||||
|
// PXI初期化、ARM9と同期
|
||||||
|
PXI_Init();
|
||||||
|
|
||||||
|
// ヒープ領域設定
|
||||||
|
heapHandle = InitializeAllocateSystem();
|
||||||
|
|
||||||
|
// 割込み許可
|
||||||
|
(void)OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr);
|
||||||
|
(void)OS_EnableIrqMask(OS_IE_V_BLANK);
|
||||||
|
(void)GX_VBlankIntr(TRUE);
|
||||||
|
(void)OS_EnableIrq();
|
||||||
|
(void)OS_EnableInterrupts();
|
||||||
|
|
||||||
|
// サウンド初期化
|
||||||
|
SND_Init(THREAD_PRIO_SND);
|
||||||
|
|
||||||
|
/////////////////
|
||||||
|
SND_Disable();
|
||||||
|
SND_StopIntervalTimer();
|
||||||
|
//////////////////
|
||||||
|
|
||||||
|
// DS mode
|
||||||
|
// SND_Disable();
|
||||||
|
// SND_I2SSetSamplingRatio(FALSE); // 32kHz
|
||||||
|
// CDC_GoDsMode();
|
||||||
|
// SND_Enable();
|
||||||
|
|
||||||
|
|
||||||
|
// reg_CFG_DS_MDFY |= REG_CFG_DS_MDFY_SND_MASK; // SOUND回路バグ修正 (default: off)
|
||||||
|
// reg_CFG_DS_MDFY |= REG_CFG_DS_MDFY_SDMA_MASK; // SOUND-DMAバグ修正 (default: off)
|
||||||
|
// reg_CFG_DS_EX &= ~REG_CFG_DS_EX_SDMA2_MASK; // SOUND-DMA新回路 (default: on)
|
||||||
|
|
||||||
|
// ボタン入力サーチ初期化
|
||||||
|
(void)PAD_InitXYButton();
|
||||||
|
|
||||||
|
// SPI初期化
|
||||||
|
SPI_Init(THREAD_PRIO_SPI);
|
||||||
|
|
||||||
|
while (TRUE)
|
||||||
|
{
|
||||||
|
// int i;
|
||||||
|
OS_Halt();
|
||||||
|
|
||||||
|
//---- check reset
|
||||||
|
if (OS_IsResetOccurred())
|
||||||
|
{
|
||||||
|
OS_ResetSystem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: InitializeAllocateSystem
|
||||||
|
|
||||||
|
Description: メモリ割当てシステムを初期化する。
|
||||||
|
|
||||||
|
Arguments: None.
|
||||||
|
|
||||||
|
Returns: None.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
static OSHeapHandle InitializeAllocateSystem(void)
|
||||||
|
{
|
||||||
|
void *tempLo;
|
||||||
|
OSHeapHandle hh;
|
||||||
|
|
||||||
|
OS_TPrintf("OS_GetWramSubPrivArenaLo() = %p\n", OS_GetWramSubPrivArenaLo());
|
||||||
|
OS_TPrintf("OS_GetWramSubPrivArenaHi() = %p\n", OS_GetWramSubPrivArenaHi());
|
||||||
|
OS_TPrintf("OS_GetWramSubArenaLo() = %p\n", OS_GetWramSubArenaLo());
|
||||||
|
OS_TPrintf("OS_GetWramSubArenaHi() = %p\n", OS_GetWramSubArenaHi());
|
||||||
|
OS_TPrintf("OS_GetSubPrivArenaLo() = %p\n", OS_GetSubPrivArenaLo());
|
||||||
|
OS_TPrintf("OS_GetSubPrivArenaHi() = %p\n", OS_GetSubPrivArenaHi());
|
||||||
|
|
||||||
|
OS_TPrintf("call OS_SetWramSubPrivArenaHi(0x0380f980); to fix arena.\n");
|
||||||
|
OS_SetWramSubPrivArenaHi((void*)0x0380f980);
|
||||||
|
|
||||||
|
// メモリ割当て初期化
|
||||||
|
tempLo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV,
|
||||||
|
OS_GetWramSubPrivArenaLo(), OS_GetWramSubPrivArenaHi(), 1);
|
||||||
|
|
||||||
|
// アリーナを0クリア
|
||||||
|
MI_CpuClear8(tempLo, (u32)OS_GetWramSubPrivArenaHi() - (u32)tempLo);
|
||||||
|
|
||||||
|
// アリーナ下位アドレスを設定
|
||||||
|
OS_SetArenaLo(OS_ARENA_WRAM_SUBPRIV, tempLo);
|
||||||
|
|
||||||
|
// ヒープ作成
|
||||||
|
hh = OS_CreateHeap(OS_ARENA_WRAM_SUBPRIV,
|
||||||
|
OS_GetWramSubPrivArenaLo(), OS_GetWramSubPrivArenaHi());
|
||||||
|
|
||||||
|
if (hh < 0)
|
||||||
|
{
|
||||||
|
OS_Panic("ARM7: Fail to create heap.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// カレントヒープに設定
|
||||||
|
(void)OS_SetCurrentHeap(OS_ARENA_WRAM_SUBPRIV, hh);
|
||||||
|
|
||||||
|
return hh;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: VBlankIntr
|
||||||
|
|
||||||
|
Description: VBlank interrupt handler
|
||||||
|
|
||||||
|
Arguments: None
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
#ifndef SDK_TEG
|
||||||
|
|
||||||
|
extern BOOL PMi_Initialized;
|
||||||
|
void PM_SelfBlinkProc(void);
|
||||||
|
|
||||||
|
static void VBlankIntr(void)
|
||||||
|
{
|
||||||
|
//---- LED blink system
|
||||||
|
if (PMi_Initialized)
|
||||||
|
{
|
||||||
|
PM_SelfBlinkProc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static void VBlankIntr(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
End of file
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
265
build/tests/spi/tp-auto-sampling-twl-mode/ARM9/src/main.c
Normal file
265
build/tests/spi/tp-auto-sampling-twl-mode/ARM9/src/main.c
Normal file
@ -0,0 +1,265 @@
|
|||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Project: TwlSDK - SND - tests - channel
|
||||||
|
File: main.c
|
||||||
|
|
||||||
|
Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
|
||||||
|
These coded instructions, statements, and computer programs contain
|
||||||
|
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
|
||||||
|
$Log: main.c,v $
|
||||||
|
$NoKeywords: $
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include <twl.h>
|
||||||
|
#include <nitro/spi/ARM9/tp.h>
|
||||||
|
|
||||||
|
void VBlankIntr(void);
|
||||||
|
void DrawPos(int x, int y);
|
||||||
|
void DrawPosScreen(int x, int y);
|
||||||
|
|
||||||
|
#define SAMPLING_FREQUENCE 4 // Touch panel sampling frequence per frame
|
||||||
|
#define SAMPLING_BUFSIZE (SAMPLING_FREQUENCE + 1) // AutoSampling buffer size
|
||||||
|
#define SAMPLING_START_VCOUNT 0 // base vcount value in auto sampling.
|
||||||
|
|
||||||
|
#define abs(x) (x) > 0 ? (x) : -(x)
|
||||||
|
|
||||||
|
typedef void* (*Func)(void);
|
||||||
|
|
||||||
|
void* Sequence1(void);
|
||||||
|
void* Sequence2(void);
|
||||||
|
void* Sequence3(void);
|
||||||
|
void* Sequence4(void);
|
||||||
|
|
||||||
|
#define CALIBRATE_SCREEN_X1 20
|
||||||
|
#define CALIBRATE_SCREEN_Y1 20
|
||||||
|
#define CALIBRATE_SCREEN_X2 236
|
||||||
|
#define CALIBRATE_SCREEN_Y2 171
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Static variables definition
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
static TPData gTpBuf[SAMPLING_BUFSIZE];
|
||||||
|
Func func = Sequence1;
|
||||||
|
u16 caliberate_raw_x1;
|
||||||
|
u16 caliberate_raw_y1;
|
||||||
|
u16 caliberate_raw_x2;
|
||||||
|
u16 caliberate_raw_y2;
|
||||||
|
|
||||||
|
TPCalibrateParam calibrate;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TwlMain
|
||||||
|
|
||||||
|
Description: main
|
||||||
|
|
||||||
|
Arguments: None
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void TwlMain()
|
||||||
|
{
|
||||||
|
// 初期化
|
||||||
|
OS_Init();
|
||||||
|
GX_Init();
|
||||||
|
TP_Init();
|
||||||
|
|
||||||
|
// Vブランク割り込み設定
|
||||||
|
OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr);
|
||||||
|
(void)OS_EnableIrqMask(OS_IE_V_BLANK);
|
||||||
|
(void)OS_EnableIrq();
|
||||||
|
(void)GX_VBlankIntr(TRUE);
|
||||||
|
|
||||||
|
// Send parameter of revision noise.
|
||||||
|
if (TP_RequestSetStability(3, 15) != 0)
|
||||||
|
{
|
||||||
|
OS_Panic("SetStability request err!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
GX_DispOff();
|
||||||
|
GXS_DispOff();
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// All VRAM banks to LCDC
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
GX_SetBankForLCDC(GX_VRAM_LCDC_ALL);
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// Clear all LCDC space
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
MI_CpuClearFast((void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE);
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// Set graphics mode VRAM display mode
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
GX_SetGraphicsMode(GX_DISPMODE_VRAM_A, // display VRAM-A
|
||||||
|
(GXBGMode)0, // dummy
|
||||||
|
(GXBG0As)0); // dummy
|
||||||
|
|
||||||
|
GX_DispOn();
|
||||||
|
GXS_DispOn();
|
||||||
|
|
||||||
|
// send auto sampling start request.
|
||||||
|
if (TP_RequestAutoSamplingStart(SAMPLING_START_VCOUNT, SAMPLING_FREQUENCE,
|
||||||
|
gTpBuf, SAMPLING_BUFSIZE))
|
||||||
|
{
|
||||||
|
OS_Panic("auto sampling start reqeuest err!\n");
|
||||||
|
}
|
||||||
|
OS_Printf("Start auto sampling\n");
|
||||||
|
|
||||||
|
|
||||||
|
// メインループ
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
OS_WaitVBlankIntr();
|
||||||
|
|
||||||
|
// 画面全体クリア
|
||||||
|
MI_DmaClear32(3, (void *)HW_LCDC_VRAM, 256*192*2);
|
||||||
|
// シーケンス処理
|
||||||
|
func = func();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void* Sequence1(void)
|
||||||
|
{
|
||||||
|
s32 last_idx = TP_GetLatestIndexInAuto();
|
||||||
|
|
||||||
|
DrawPosScreen(CALIBRATE_SCREEN_X1, CALIBRATE_SCREEN_Y1);
|
||||||
|
|
||||||
|
if (gTpBuf[last_idx].touch)
|
||||||
|
{
|
||||||
|
if (abs(caliberate_raw_x1 - gTpBuf[last_idx].x) < 1 &&
|
||||||
|
abs(caliberate_raw_y1 - gTpBuf[last_idx].y) < 1 )
|
||||||
|
{
|
||||||
|
DrawPos(caliberate_raw_x1, caliberate_raw_y1);
|
||||||
|
return Sequence2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
caliberate_raw_x1 = gTpBuf[last_idx].x;
|
||||||
|
caliberate_raw_y1 = gTpBuf[last_idx].y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Sequence1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* Sequence2(void)
|
||||||
|
{
|
||||||
|
s32 last_idx = TP_GetLatestIndexInAuto();
|
||||||
|
|
||||||
|
if (!gTpBuf[last_idx].touch)
|
||||||
|
{
|
||||||
|
return Sequence3;
|
||||||
|
}
|
||||||
|
return Sequence2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* Sequence3(void)
|
||||||
|
{
|
||||||
|
s32 last_idx = TP_GetLatestIndexInAuto();
|
||||||
|
|
||||||
|
DrawPosScreen(CALIBRATE_SCREEN_X2, CALIBRATE_SCREEN_Y2);
|
||||||
|
|
||||||
|
if (gTpBuf[last_idx].touch)
|
||||||
|
{
|
||||||
|
if (abs(caliberate_raw_x2 - gTpBuf[last_idx].x) < 1 &&
|
||||||
|
abs(caliberate_raw_y2 - gTpBuf[last_idx].y) < 1 )
|
||||||
|
{
|
||||||
|
DrawPos(caliberate_raw_x2, caliberate_raw_y2);
|
||||||
|
|
||||||
|
TP_CalcCalibrateParam( &calibrate,
|
||||||
|
caliberate_raw_x1, caliberate_raw_y1,
|
||||||
|
CALIBRATE_SCREEN_X1, CALIBRATE_SCREEN_Y1,
|
||||||
|
caliberate_raw_x2, caliberate_raw_y2,
|
||||||
|
CALIBRATE_SCREEN_X2, CALIBRATE_SCREEN_Y2 );
|
||||||
|
|
||||||
|
TP_SetCalibrateParam( &calibrate );
|
||||||
|
|
||||||
|
return Sequence4;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
caliberate_raw_x2 = gTpBuf[last_idx].x;
|
||||||
|
caliberate_raw_y2 = gTpBuf[last_idx].y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Sequence3;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* Sequence4(void)
|
||||||
|
{
|
||||||
|
s32 last_idx = TP_GetLatestIndexInAuto();
|
||||||
|
|
||||||
|
if (gTpBuf[last_idx].touch)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
///////////
|
||||||
|
if (gTpBuf[last_idx].x < 300) { OS_Printf("0: %4d\n", gTpBuf[last_idx].x); }
|
||||||
|
if (gTpBuf[last_idx].x > 3500) { OS_Printf("0: %4d\n", gTpBuf[last_idx].x); }
|
||||||
|
if (gTpBuf[last_idx].y < 300) { OS_Printf("0: %4d\n", gTpBuf[last_idx].y); }
|
||||||
|
if (gTpBuf[last_idx].y > 3500) { OS_Printf("0: %4d\n", gTpBuf[last_idx].y); }
|
||||||
|
///////////
|
||||||
|
*/
|
||||||
|
TP_GetCalibratedPoint( &gTpBuf[last_idx], &gTpBuf[last_idx] );
|
||||||
|
/*
|
||||||
|
///////////
|
||||||
|
if (gTpBuf[last_idx].x < 1) { OS_Printf("1: %4d\n", gTpBuf[last_idx].x); }
|
||||||
|
if (gTpBuf[last_idx].x > 254) { OS_Printf("1: %4d\n", gTpBuf[last_idx].x); }
|
||||||
|
if (gTpBuf[last_idx].y < 1) { OS_Printf("1: %4d\n", gTpBuf[last_idx].y); }
|
||||||
|
if (gTpBuf[last_idx].y > 190) { OS_Printf("1: %4d\n", gTpBuf[last_idx].y); }
|
||||||
|
///////////
|
||||||
|
*/
|
||||||
|
DrawPosScreen(gTpBuf[last_idx].x, gTpBuf[last_idx].y);
|
||||||
|
}
|
||||||
|
return Sequence4;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// Vブランク割り込み処理
|
||||||
|
//
|
||||||
|
void VBlankIntr(void)
|
||||||
|
{
|
||||||
|
OS_SetIrqCheckFlag(OS_IE_V_BLANK); // checking VBlank interrupt
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// 画面座標描画
|
||||||
|
//
|
||||||
|
void DrawPos(int x, int y)
|
||||||
|
{
|
||||||
|
const int screen_width = 256;
|
||||||
|
const int screen_height = 191;
|
||||||
|
const int axis_max = 4096;
|
||||||
|
int adjust_x = x * screen_width / axis_max;
|
||||||
|
int adjust_y = y * screen_height / axis_max;
|
||||||
|
int address;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
address = HW_LCDC_VRAM + screen_width*2*adjust_y;
|
||||||
|
MI_DmaFill16( 3, (void*)address, 0x7fff, 256*2 );
|
||||||
|
|
||||||
|
for (i=0;i<192;i++)
|
||||||
|
{
|
||||||
|
address = HW_LCDC_VRAM + screen_width*2*i + 2*adjust_x;
|
||||||
|
*(u16 *)(address) = 0x7fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawPosScreen(int x, int y)
|
||||||
|
{
|
||||||
|
const int screen_width = 256;
|
||||||
|
int address;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
address = HW_LCDC_VRAM + screen_width*2*y;
|
||||||
|
MI_DmaFill16( 3, (void*)address, 0x7fff, 256*2 );
|
||||||
|
|
||||||
|
for (i=0;i<192;i++)
|
||||||
|
{
|
||||||
|
address = HW_LCDC_VRAM + screen_width*2*i + 2*x;
|
||||||
|
*(u16 *)(address) = 0x7fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
44
build/tests/spi/tp-auto-sampling/ARM7/Makefile
Normal file
44
build/tests/spi/tp-auto-sampling/ARM7/Makefile
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#! make -f
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Project: TwlSDK - SND - demos - channel
|
||||||
|
# File: Makefile
|
||||||
|
#
|
||||||
|
# Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
#
|
||||||
|
# These coded instructions, statements, and computer programs contain
|
||||||
|
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
# Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
# not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
# in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
#
|
||||||
|
# $Log: $
|
||||||
|
# $NoKeywords: $
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SUBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#TWL_CODEGEN = THUMB
|
||||||
|
TWL_PROC = ARM7
|
||||||
|
|
||||||
|
TARGET_BIN = main.axf
|
||||||
|
|
||||||
|
SRCS = main.c
|
||||||
|
|
||||||
|
#SRCDIR = # using default
|
||||||
|
#LCFILE = # using default
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
do-build: $(TARGETS)
|
||||||
|
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||||
|
|
||||||
|
|
||||||
|
#===== End of Makefile =====
|
||||||
233
build/tests/spi/tp-auto-sampling/ARM7/src/main.c
Normal file
233
build/tests/spi/tp-auto-sampling/ARM7/src/main.c
Normal file
@ -0,0 +1,233 @@
|
|||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Project: TwlSDK - tests - snd - channel
|
||||||
|
File: main.c
|
||||||
|
|
||||||
|
Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
|
||||||
|
These coded instructions, statements, and computer programs contain
|
||||||
|
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
|
||||||
|
$Log: main.c,v $
|
||||||
|
$NoKeywords: $
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
TP_RequestAutoSamplingStart のテストプログラムです。
|
||||||
|
|
||||||
|
最初にキャリブレーションの処理を入れています。
|
||||||
|
画面に表示される2点をタッチしてください。
|
||||||
|
|
||||||
|
tp-auto-sampling と
|
||||||
|
tp-auto-sampling-twlmode の違いは、
|
||||||
|
ARM7側のコードで CDC_GoDsMode() を呼ぶかどうかの違いだけです。
|
||||||
|
|
||||||
|
CDC_GoDsMode()内部でOS_Sleep()が呼ばれます。
|
||||||
|
全スレッドが同時にスリープに入るのを避けるため暫定的にアイドルスレッド
|
||||||
|
を生成しています。
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <twl_sp.h>
|
||||||
|
#include <twl/cdc.h> // for DS mode
|
||||||
|
#include <twl/snd/ARM7/i2s.h>
|
||||||
|
|
||||||
|
#define OSi_IDLE_CHECKNUM_SIZE ( sizeof(u32)*2 )
|
||||||
|
#define OSi_IDLE_SVC_SIZE ( sizeof(u32)*16 ) // arm7 svc stacks 14 words
|
||||||
|
#define OSi_IDLE_THREAD_STACK_SIZE ( OSi_IDLE_CHECKNUM_SIZE + OSi_IDLE_SVC_SIZE )
|
||||||
|
extern u32 OSi_IdleThreadStack[OSi_IDLE_THREAD_STACK_SIZE / sizeof(u32)];
|
||||||
|
extern OSThread OSi_IdleThread;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
定数定義
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
// ===== スレッド優先度 =====
|
||||||
|
|
||||||
|
#define THREAD_PRIO_SPI 2
|
||||||
|
#define THREAD_PRIO_SND 6
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
内部関数定義
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
static OSHeapHandle InitializeAllocateSystem(void);
|
||||||
|
static void VBlankIntr(void);
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: OSi_IdleThreadProc
|
||||||
|
|
||||||
|
Description: procedure of idle thread which system creates
|
||||||
|
|
||||||
|
Arguments: None
|
||||||
|
|
||||||
|
Returns: None (never return)
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
static void OSi_IdleThreadProc(void *)
|
||||||
|
{
|
||||||
|
(void)OS_EnableInterrupts();
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
OS_Halt();
|
||||||
|
}
|
||||||
|
// never return
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TwlSpMain
|
||||||
|
|
||||||
|
Description: Initialize and do main
|
||||||
|
|
||||||
|
Arguments: None.
|
||||||
|
|
||||||
|
Returns: None.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void TwlSpMain(void)
|
||||||
|
{
|
||||||
|
OSHeapHandle heapHandle;
|
||||||
|
|
||||||
|
// OS初期化
|
||||||
|
OS_Init();
|
||||||
|
OS_InitThread();
|
||||||
|
|
||||||
|
// PXI初期化、ARM9と同期
|
||||||
|
PXI_Init();
|
||||||
|
|
||||||
|
// ヒープ領域設定
|
||||||
|
heapHandle = InitializeAllocateSystem();
|
||||||
|
|
||||||
|
// 割込み許可
|
||||||
|
(void)OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr);
|
||||||
|
(void)OS_EnableIrqMask(OS_IE_V_BLANK);
|
||||||
|
(void)GX_VBlankIntr(TRUE);
|
||||||
|
(void)OS_EnableIrq();
|
||||||
|
(void)OS_EnableInterrupts();
|
||||||
|
|
||||||
|
// create idle thread to sleep in main thread
|
||||||
|
OS_CreateThread(&OSi_IdleThread,
|
||||||
|
OSi_IdleThreadProc,
|
||||||
|
(void *)NULL,
|
||||||
|
OSi_IdleThreadStack + OSi_IDLE_THREAD_STACK_SIZE / sizeof(u32),
|
||||||
|
OSi_IDLE_THREAD_STACK_SIZE,
|
||||||
|
OS_THREAD_PRIORITY_MAX /*pseudo. change at next line. */ );
|
||||||
|
OSi_IdleThread.priority = OS_THREAD_PRIORITY_MAX + 1; // lower priority than the lowest (=OS_THREAD_PRIORITY_MAX)
|
||||||
|
OSi_IdleThread.state = OS_THREAD_STATE_READY;
|
||||||
|
|
||||||
|
// サウンド初期化
|
||||||
|
SND_Init(THREAD_PRIO_SND);
|
||||||
|
|
||||||
|
/////////////////
|
||||||
|
SND_Disable();
|
||||||
|
SND_StopIntervalTimer();
|
||||||
|
//////////////////
|
||||||
|
|
||||||
|
// DS mode
|
||||||
|
SND_Disable();
|
||||||
|
// SND_I2SSetSamplingRatio(FALSE); // 32kHz
|
||||||
|
CDC_GoDsMode();
|
||||||
|
SND_Enable();
|
||||||
|
|
||||||
|
// reg_CFG_DS_MDFY |= REG_CFG_DS_MDFY_SND_MASK; // SOUND回路バグ修正 (default: off)
|
||||||
|
// reg_CFG_DS_MDFY |= REG_CFG_DS_MDFY_SDMA_MASK; // SOUND-DMAバグ修正 (default: off)
|
||||||
|
// reg_CFG_DS_EX &= ~REG_CFG_DS_EX_SDMA2_MASK; // SOUND-DMA新回路 (default: on)
|
||||||
|
|
||||||
|
// ボタン入力サーチ初期化
|
||||||
|
(void)PAD_InitXYButton();
|
||||||
|
|
||||||
|
// SPI初期化
|
||||||
|
SPI_Init(THREAD_PRIO_SPI);
|
||||||
|
|
||||||
|
while (TRUE)
|
||||||
|
{
|
||||||
|
OS_Halt();
|
||||||
|
|
||||||
|
//---- check reset
|
||||||
|
if (OS_IsResetOccurred())
|
||||||
|
{
|
||||||
|
OS_ResetSystem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: InitializeAllocateSystem
|
||||||
|
|
||||||
|
Description: メモリ割当てシステムを初期化する。
|
||||||
|
|
||||||
|
Arguments: None.
|
||||||
|
|
||||||
|
Returns: None.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
static OSHeapHandle InitializeAllocateSystem(void)
|
||||||
|
{
|
||||||
|
void *tempLo;
|
||||||
|
OSHeapHandle hh;
|
||||||
|
|
||||||
|
OS_TPrintf("OS_GetWramSubPrivArenaLo() = %p\n", OS_GetWramSubPrivArenaLo());
|
||||||
|
OS_TPrintf("OS_GetWramSubPrivArenaHi() = %p\n", OS_GetWramSubPrivArenaHi());
|
||||||
|
OS_TPrintf("OS_GetWramSubArenaLo() = %p\n", OS_GetWramSubArenaLo());
|
||||||
|
OS_TPrintf("OS_GetWramSubArenaHi() = %p\n", OS_GetWramSubArenaHi());
|
||||||
|
OS_TPrintf("OS_GetSubPrivArenaLo() = %p\n", OS_GetSubPrivArenaLo());
|
||||||
|
OS_TPrintf("OS_GetSubPrivArenaHi() = %p\n", OS_GetSubPrivArenaHi());
|
||||||
|
|
||||||
|
OS_TPrintf("call OS_SetWramSubPrivArenaHi(0x0380f980); to fix arena.\n");
|
||||||
|
OS_SetWramSubPrivArenaHi((void*)0x0380f980);
|
||||||
|
|
||||||
|
// メモリ割当て初期化
|
||||||
|
tempLo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV,
|
||||||
|
OS_GetWramSubPrivArenaLo(), OS_GetWramSubPrivArenaHi(), 1);
|
||||||
|
|
||||||
|
// アリーナを0クリア
|
||||||
|
MI_CpuClear8(tempLo, (u32)OS_GetWramSubPrivArenaHi() - (u32)tempLo);
|
||||||
|
|
||||||
|
// アリーナ下位アドレスを設定
|
||||||
|
OS_SetArenaLo(OS_ARENA_WRAM_SUBPRIV, tempLo);
|
||||||
|
|
||||||
|
// ヒープ作成
|
||||||
|
hh = OS_CreateHeap(OS_ARENA_WRAM_SUBPRIV,
|
||||||
|
OS_GetWramSubPrivArenaLo(), OS_GetWramSubPrivArenaHi());
|
||||||
|
|
||||||
|
if (hh < 0)
|
||||||
|
{
|
||||||
|
OS_Panic("ARM7: Fail to create heap.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// カレントヒープに設定
|
||||||
|
(void)OS_SetCurrentHeap(OS_ARENA_WRAM_SUBPRIV, hh);
|
||||||
|
|
||||||
|
return hh;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: VBlankIntr
|
||||||
|
|
||||||
|
Description: VBlank interrupt handler
|
||||||
|
|
||||||
|
Arguments: None
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
#ifndef SDK_TEG
|
||||||
|
|
||||||
|
extern BOOL PMi_Initialized;
|
||||||
|
void PM_SelfBlinkProc(void);
|
||||||
|
|
||||||
|
static void VBlankIntr(void)
|
||||||
|
{
|
||||||
|
//---- LED blink system
|
||||||
|
if (PMi_Initialized)
|
||||||
|
{
|
||||||
|
PM_SelfBlinkProc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static void VBlankIntr(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
End of file
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
43
build/tests/spi/tp-auto-sampling/ARM9/Makefile
Normal file
43
build/tests/spi/tp-auto-sampling/ARM9/Makefile
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#! make -f
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Project: TwlSDK - SND - demos - channel
|
||||||
|
# File: Makefile
|
||||||
|
#
|
||||||
|
# Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
#
|
||||||
|
# These coded instructions, statements, and computer programs contain
|
||||||
|
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
# Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
# not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
# in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
#
|
||||||
|
# $Log: $
|
||||||
|
# $NoKeywords: $
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SUBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#TWL_CODEGEN = THUMB
|
||||||
|
|
||||||
|
TARGET_BIN = main.axf
|
||||||
|
|
||||||
|
SRCS = main.c
|
||||||
|
|
||||||
|
#SRCDIR = # using default
|
||||||
|
#LCFILE = # using default
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
do-build: $(TARGETS)
|
||||||
|
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||||
|
|
||||||
|
|
||||||
|
#===== End of Makefile =====
|
||||||
265
build/tests/spi/tp-auto-sampling/ARM9/src/main.c
Normal file
265
build/tests/spi/tp-auto-sampling/ARM9/src/main.c
Normal file
@ -0,0 +1,265 @@
|
|||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Project: TwlSDK - SND - tests - channel
|
||||||
|
File: main.c
|
||||||
|
|
||||||
|
Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
|
||||||
|
These coded instructions, statements, and computer programs contain
|
||||||
|
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
|
||||||
|
$Log: main.c,v $
|
||||||
|
$NoKeywords: $
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include <twl.h>
|
||||||
|
#include <nitro/spi/ARM9/tp.h>
|
||||||
|
|
||||||
|
void VBlankIntr(void);
|
||||||
|
void DrawPos(int x, int y);
|
||||||
|
void DrawPosScreen(int x, int y);
|
||||||
|
|
||||||
|
#define SAMPLING_FREQUENCE 4 // Touch panel sampling frequence per frame
|
||||||
|
#define SAMPLING_BUFSIZE (SAMPLING_FREQUENCE + 1) // AutoSampling buffer size
|
||||||
|
#define SAMPLING_START_VCOUNT 0 // base vcount value in auto sampling.
|
||||||
|
|
||||||
|
#define abs(x) (x) > 0 ? (x) : -(x)
|
||||||
|
|
||||||
|
typedef void* (*Func)(void);
|
||||||
|
|
||||||
|
void* Sequence1(void);
|
||||||
|
void* Sequence2(void);
|
||||||
|
void* Sequence3(void);
|
||||||
|
void* Sequence4(void);
|
||||||
|
|
||||||
|
#define CALIBRATE_SCREEN_X1 20
|
||||||
|
#define CALIBRATE_SCREEN_Y1 20
|
||||||
|
#define CALIBRATE_SCREEN_X2 236
|
||||||
|
#define CALIBRATE_SCREEN_Y2 171
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Static variables definition
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
static TPData gTpBuf[SAMPLING_BUFSIZE];
|
||||||
|
Func func = Sequence1;
|
||||||
|
u16 caliberate_raw_x1;
|
||||||
|
u16 caliberate_raw_y1;
|
||||||
|
u16 caliberate_raw_x2;
|
||||||
|
u16 caliberate_raw_y2;
|
||||||
|
|
||||||
|
TPCalibrateParam calibrate;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TwlMain
|
||||||
|
|
||||||
|
Description: main
|
||||||
|
|
||||||
|
Arguments: None
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void TwlMain()
|
||||||
|
{
|
||||||
|
// 初期化
|
||||||
|
OS_Init();
|
||||||
|
GX_Init();
|
||||||
|
TP_Init();
|
||||||
|
|
||||||
|
// Vブランク割り込み設定
|
||||||
|
OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr);
|
||||||
|
(void)OS_EnableIrqMask(OS_IE_V_BLANK);
|
||||||
|
(void)OS_EnableIrq();
|
||||||
|
(void)GX_VBlankIntr(TRUE);
|
||||||
|
|
||||||
|
// Send parameter of revision noise.
|
||||||
|
if (TP_RequestSetStability(3, 15) != 0)
|
||||||
|
{
|
||||||
|
OS_Panic("SetStability request err!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
GX_DispOff();
|
||||||
|
GXS_DispOff();
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// All VRAM banks to LCDC
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
GX_SetBankForLCDC(GX_VRAM_LCDC_ALL);
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// Clear all LCDC space
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
MI_CpuClearFast((void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE);
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// Set graphics mode VRAM display mode
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
GX_SetGraphicsMode(GX_DISPMODE_VRAM_A, // display VRAM-A
|
||||||
|
(GXBGMode)0, // dummy
|
||||||
|
(GXBG0As)0); // dummy
|
||||||
|
|
||||||
|
GX_DispOn();
|
||||||
|
GXS_DispOn();
|
||||||
|
|
||||||
|
// send auto sampling start request.
|
||||||
|
if (TP_RequestAutoSamplingStart(SAMPLING_START_VCOUNT, SAMPLING_FREQUENCE,
|
||||||
|
gTpBuf, SAMPLING_BUFSIZE))
|
||||||
|
{
|
||||||
|
OS_Panic("auto sampling start reqeuest err!\n");
|
||||||
|
}
|
||||||
|
OS_Printf("Start auto sampling\n");
|
||||||
|
|
||||||
|
|
||||||
|
// メインループ
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
OS_WaitVBlankIntr();
|
||||||
|
|
||||||
|
// 画面全体クリア
|
||||||
|
MI_DmaClear32(3, (void *)HW_LCDC_VRAM, 256*192*2);
|
||||||
|
// シーケンス処理
|
||||||
|
func = func();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void* Sequence1(void)
|
||||||
|
{
|
||||||
|
s32 last_idx = TP_GetLatestIndexInAuto();
|
||||||
|
|
||||||
|
DrawPosScreen(CALIBRATE_SCREEN_X1, CALIBRATE_SCREEN_Y1);
|
||||||
|
|
||||||
|
if (gTpBuf[last_idx].touch)
|
||||||
|
{
|
||||||
|
if (abs(caliberate_raw_x1 - gTpBuf[last_idx].x) < 1 &&
|
||||||
|
abs(caliberate_raw_y1 - gTpBuf[last_idx].y) < 1 )
|
||||||
|
{
|
||||||
|
DrawPos(caliberate_raw_x1, caliberate_raw_y1);
|
||||||
|
return Sequence2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
caliberate_raw_x1 = gTpBuf[last_idx].x;
|
||||||
|
caliberate_raw_y1 = gTpBuf[last_idx].y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Sequence1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* Sequence2(void)
|
||||||
|
{
|
||||||
|
s32 last_idx = TP_GetLatestIndexInAuto();
|
||||||
|
|
||||||
|
if (!gTpBuf[last_idx].touch)
|
||||||
|
{
|
||||||
|
return Sequence3;
|
||||||
|
}
|
||||||
|
return Sequence2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* Sequence3(void)
|
||||||
|
{
|
||||||
|
s32 last_idx = TP_GetLatestIndexInAuto();
|
||||||
|
|
||||||
|
DrawPosScreen(CALIBRATE_SCREEN_X2, CALIBRATE_SCREEN_Y2);
|
||||||
|
|
||||||
|
if (gTpBuf[last_idx].touch)
|
||||||
|
{
|
||||||
|
if (abs(caliberate_raw_x2 - gTpBuf[last_idx].x) < 1 &&
|
||||||
|
abs(caliberate_raw_y2 - gTpBuf[last_idx].y) < 1 )
|
||||||
|
{
|
||||||
|
DrawPos(caliberate_raw_x2, caliberate_raw_y2);
|
||||||
|
|
||||||
|
TP_CalcCalibrateParam( &calibrate,
|
||||||
|
caliberate_raw_x1, caliberate_raw_y1,
|
||||||
|
CALIBRATE_SCREEN_X1, CALIBRATE_SCREEN_Y1,
|
||||||
|
caliberate_raw_x2, caliberate_raw_y2,
|
||||||
|
CALIBRATE_SCREEN_X2, CALIBRATE_SCREEN_Y2 );
|
||||||
|
|
||||||
|
TP_SetCalibrateParam( &calibrate );
|
||||||
|
|
||||||
|
return Sequence4;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
caliberate_raw_x2 = gTpBuf[last_idx].x;
|
||||||
|
caliberate_raw_y2 = gTpBuf[last_idx].y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Sequence3;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* Sequence4(void)
|
||||||
|
{
|
||||||
|
s32 last_idx = TP_GetLatestIndexInAuto();
|
||||||
|
|
||||||
|
if (gTpBuf[last_idx].touch)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
///////////
|
||||||
|
if (gTpBuf[last_idx].x < 300) { OS_Printf("0: %4d\n", gTpBuf[last_idx].x); }
|
||||||
|
if (gTpBuf[last_idx].x > 3500) { OS_Printf("0: %4d\n", gTpBuf[last_idx].x); }
|
||||||
|
if (gTpBuf[last_idx].y < 300) { OS_Printf("0: %4d\n", gTpBuf[last_idx].y); }
|
||||||
|
if (gTpBuf[last_idx].y > 3500) { OS_Printf("0: %4d\n", gTpBuf[last_idx].y); }
|
||||||
|
///////////
|
||||||
|
*/
|
||||||
|
TP_GetCalibratedPoint( &gTpBuf[last_idx], &gTpBuf[last_idx] );
|
||||||
|
/*
|
||||||
|
///////////
|
||||||
|
if (gTpBuf[last_idx].x < 1) { OS_Printf("1: %4d\n", gTpBuf[last_idx].x); }
|
||||||
|
if (gTpBuf[last_idx].x > 254) { OS_Printf("1: %4d\n", gTpBuf[last_idx].x); }
|
||||||
|
if (gTpBuf[last_idx].y < 1) { OS_Printf("1: %4d\n", gTpBuf[last_idx].y); }
|
||||||
|
if (gTpBuf[last_idx].y > 190) { OS_Printf("1: %4d\n", gTpBuf[last_idx].y); }
|
||||||
|
///////////
|
||||||
|
*/
|
||||||
|
DrawPosScreen(gTpBuf[last_idx].x, gTpBuf[last_idx].y);
|
||||||
|
}
|
||||||
|
return Sequence4;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// Vブランク割り込み処理
|
||||||
|
//
|
||||||
|
void VBlankIntr(void)
|
||||||
|
{
|
||||||
|
OS_SetIrqCheckFlag(OS_IE_V_BLANK); // checking VBlank interrupt
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// 画面座標描画
|
||||||
|
//
|
||||||
|
void DrawPos(int x, int y)
|
||||||
|
{
|
||||||
|
const int screen_width = 256;
|
||||||
|
const int screen_height = 191;
|
||||||
|
const int axis_max = 4096;
|
||||||
|
int adjust_x = x * screen_width / axis_max;
|
||||||
|
int adjust_y = y * screen_height / axis_max;
|
||||||
|
int address;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
address = HW_LCDC_VRAM + screen_width*2*adjust_y;
|
||||||
|
MI_DmaFill16( 3, (void*)address, 0x7fff, 256*2 );
|
||||||
|
|
||||||
|
for (i=0;i<192;i++)
|
||||||
|
{
|
||||||
|
address = HW_LCDC_VRAM + screen_width*2*i + 2*adjust_x;
|
||||||
|
*(u16 *)(address) = 0x7fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawPosScreen(int x, int y)
|
||||||
|
{
|
||||||
|
const int screen_width = 256;
|
||||||
|
int address;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
address = HW_LCDC_VRAM + screen_width*2*y;
|
||||||
|
MI_DmaFill16( 3, (void*)address, 0x7fff, 256*2 );
|
||||||
|
|
||||||
|
for (i=0;i<192;i++)
|
||||||
|
{
|
||||||
|
address = HW_LCDC_VRAM + screen_width*2*i + 2*x;
|
||||||
|
*(u16 *)(address) = 0x7fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
32
build/tests/spi/tp-auto-sampling/Makefile
Normal file
32
build/tests/spi/tp-auto-sampling/Makefile
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#! make -f
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Project: TwlSDK - build
|
||||||
|
# File: Makefile
|
||||||
|
#
|
||||||
|
# Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
#
|
||||||
|
# These coded instructions, statements, and computer programs contain
|
||||||
|
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
# Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
# not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
# in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
#
|
||||||
|
# $Log: $
|
||||||
|
# $NoKeywords: $
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SUBDIRS = \
|
||||||
|
ARM7 \
|
||||||
|
ARM9 \
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||||
|
|
||||||
|
|
||||||
|
#===== End of Makefile =====
|
||||||
44
build/tests/spi/tp-sampling-twl-mode/ARM7/Makefile
Normal file
44
build/tests/spi/tp-sampling-twl-mode/ARM7/Makefile
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#! make -f
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Project: TwlSDK - SND - demos - channel
|
||||||
|
# File: Makefile
|
||||||
|
#
|
||||||
|
# Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
#
|
||||||
|
# These coded instructions, statements, and computer programs contain
|
||||||
|
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
# Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
# not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
# in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
#
|
||||||
|
# $Log: $
|
||||||
|
# $NoKeywords: $
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SUBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#TWL_CODEGEN = THUMB
|
||||||
|
TWL_PROC = ARM7
|
||||||
|
|
||||||
|
TARGET_BIN = main.axf
|
||||||
|
|
||||||
|
SRCS = main.c
|
||||||
|
|
||||||
|
#SRCDIR = # using default
|
||||||
|
#LCFILE = # using default
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
do-build: $(TARGETS)
|
||||||
|
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||||
|
|
||||||
|
|
||||||
|
#===== End of Makefile =====
|
||||||
@ -14,6 +14,14 @@
|
|||||||
$NoKeywords: $
|
$NoKeywords: $
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
TP_RequestRawSampling のテストプログラムです。
|
||||||
|
|
||||||
|
tp-sampling と
|
||||||
|
tp-sampling-twlmode の違いは、
|
||||||
|
ARM7側のコードで CDC_GoDsMode() を呼ぶかどうかの違いだけです。
|
||||||
|
*/
|
||||||
|
|
||||||
#include <twl_sp.h>
|
#include <twl_sp.h>
|
||||||
#include <twl/cdc.h> // for DS mode
|
#include <twl/cdc.h> // for DS mode
|
||||||
#include <twl/snd/ARM7/i2s.h>
|
#include <twl/snd/ARM7/i2s.h>
|
||||||
@ -65,12 +73,16 @@ void TwlSpMain(void)
|
|||||||
// サウンド初期化
|
// サウンド初期化
|
||||||
SND_Init(THREAD_PRIO_SND);
|
SND_Init(THREAD_PRIO_SND);
|
||||||
|
|
||||||
|
/////////////////
|
||||||
|
SND_Disable();
|
||||||
|
SND_StopIntervalTimer();
|
||||||
|
//////////////////
|
||||||
|
|
||||||
// DS mode
|
// DS mode
|
||||||
SND_Disable();
|
// SND_Disable();
|
||||||
// SND_I2SSetSamplingRatio(FALSE); // 32kHz
|
// SND_I2SSetSamplingRatio(FALSE); // 32kHz
|
||||||
CDC_GoDsMode();
|
// CDC_GoDsMode();
|
||||||
SND_Enable();
|
// SND_Enable();
|
||||||
|
|
||||||
|
|
||||||
// reg_CFG_DS_MDFY |= REG_CFG_DS_MDFY_SND_MASK; // SOUND回路バグ修正 (default: off)
|
// reg_CFG_DS_MDFY |= REG_CFG_DS_MDFY_SND_MASK; // SOUND回路バグ修正 (default: off)
|
||||||
43
build/tests/spi/tp-sampling-twl-mode/ARM9/Makefile
Normal file
43
build/tests/spi/tp-sampling-twl-mode/ARM9/Makefile
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#! make -f
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Project: TwlSDK - SND - demos - channel
|
||||||
|
# File: Makefile
|
||||||
|
#
|
||||||
|
# Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
#
|
||||||
|
# These coded instructions, statements, and computer programs contain
|
||||||
|
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
# Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
# not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
# in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
#
|
||||||
|
# $Log: $
|
||||||
|
# $NoKeywords: $
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SUBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#TWL_CODEGEN = THUMB
|
||||||
|
|
||||||
|
TARGET_BIN = main.axf
|
||||||
|
|
||||||
|
SRCS = main.c
|
||||||
|
|
||||||
|
#SRCDIR = # using default
|
||||||
|
#LCFILE = # using default
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
do-build: $(TARGETS)
|
||||||
|
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||||
|
|
||||||
|
|
||||||
|
#===== End of Makefile =====
|
||||||
32
build/tests/spi/tp-sampling-twl-mode/Makefile
Normal file
32
build/tests/spi/tp-sampling-twl-mode/Makefile
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#! make -f
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Project: TwlSDK - build
|
||||||
|
# File: Makefile
|
||||||
|
#
|
||||||
|
# Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
#
|
||||||
|
# These coded instructions, statements, and computer programs contain
|
||||||
|
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
# Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
# not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
# in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
#
|
||||||
|
# $Log: $
|
||||||
|
# $NoKeywords: $
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SUBDIRS = \
|
||||||
|
ARM7 \
|
||||||
|
ARM9 \
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||||
|
|
||||||
|
|
||||||
|
#===== End of Makefile =====
|
||||||
44
build/tests/spi/tp-sampling/ARM7/Makefile
Normal file
44
build/tests/spi/tp-sampling/ARM7/Makefile
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#! make -f
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Project: TwlSDK - SND - demos - channel
|
||||||
|
# File: Makefile
|
||||||
|
#
|
||||||
|
# Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
#
|
||||||
|
# These coded instructions, statements, and computer programs contain
|
||||||
|
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
# Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
# not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
# in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
#
|
||||||
|
# $Log: $
|
||||||
|
# $NoKeywords: $
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SUBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#TWL_CODEGEN = THUMB
|
||||||
|
TWL_PROC = ARM7
|
||||||
|
|
||||||
|
TARGET_BIN = main.axf
|
||||||
|
|
||||||
|
SRCS = main.c
|
||||||
|
|
||||||
|
#SRCDIR = # using default
|
||||||
|
#LCFILE = # using default
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
do-build: $(TARGETS)
|
||||||
|
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||||
|
|
||||||
|
|
||||||
|
#===== End of Makefile =====
|
||||||
227
build/tests/spi/tp-sampling/ARM7/src/main.c
Normal file
227
build/tests/spi/tp-sampling/ARM7/src/main.c
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Project: TwlSDK - tests - snd - channel
|
||||||
|
File: main.c
|
||||||
|
|
||||||
|
Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
|
||||||
|
These coded instructions, statements, and computer programs contain
|
||||||
|
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
|
||||||
|
$Log: main.c,v $
|
||||||
|
$NoKeywords: $
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
TP_RequestRawSampling のテストプログラムです。
|
||||||
|
|
||||||
|
tp-sampling と
|
||||||
|
tp-sampling-twlmode の違いは、
|
||||||
|
ARM7側のコードで CDC_GoDsMode() を呼ぶかどうかの違いだけです。
|
||||||
|
|
||||||
|
CDC_GoDsMode()内部でOS_Sleep()が呼ばれます。
|
||||||
|
全スレッドが同時にスリープに入るのを避けるため暫定的にアイドルスレッド
|
||||||
|
を生成しています。
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <twl_sp.h>
|
||||||
|
#include <twl/cdc.h> // for DS mode
|
||||||
|
#include <twl/snd/ARM7/i2s.h>
|
||||||
|
|
||||||
|
#define OSi_IDLE_CHECKNUM_SIZE ( sizeof(u32)*2 )
|
||||||
|
#define OSi_IDLE_SVC_SIZE ( sizeof(u32)*16 ) // arm7 svc stacks 14 words
|
||||||
|
#define OSi_IDLE_THREAD_STACK_SIZE ( OSi_IDLE_CHECKNUM_SIZE + OSi_IDLE_SVC_SIZE )
|
||||||
|
extern u32 OSi_IdleThreadStack[OSi_IDLE_THREAD_STACK_SIZE / sizeof(u32)];
|
||||||
|
extern OSThread OSi_IdleThread;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
定数定義
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
// ===== スレッド優先度 =====
|
||||||
|
|
||||||
|
#define THREAD_PRIO_SPI 2
|
||||||
|
#define THREAD_PRIO_SND 6
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
内部関数定義
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
static OSHeapHandle InitializeAllocateSystem(void);
|
||||||
|
static void VBlankIntr(void);
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: OSi_IdleThreadProc
|
||||||
|
|
||||||
|
Description: procedure of idle thread which system creates
|
||||||
|
|
||||||
|
Arguments: None
|
||||||
|
|
||||||
|
Returns: None (never return)
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
static void OSi_IdleThreadProc(void *)
|
||||||
|
{
|
||||||
|
(void)OS_EnableInterrupts();
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
OS_Halt();
|
||||||
|
}
|
||||||
|
// never return
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TwlSpMain
|
||||||
|
|
||||||
|
Description: Initialize and do main
|
||||||
|
|
||||||
|
Arguments: None.
|
||||||
|
|
||||||
|
Returns: None.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void TwlSpMain(void)
|
||||||
|
{
|
||||||
|
OSHeapHandle heapHandle;
|
||||||
|
|
||||||
|
// OS初期化
|
||||||
|
OS_Init();
|
||||||
|
OS_InitThread();
|
||||||
|
|
||||||
|
// PXI初期化、ARM9と同期
|
||||||
|
PXI_Init();
|
||||||
|
|
||||||
|
// ヒープ領域設定
|
||||||
|
heapHandle = InitializeAllocateSystem();
|
||||||
|
|
||||||
|
// 割込み許可
|
||||||
|
(void)OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr);
|
||||||
|
(void)OS_EnableIrqMask(OS_IE_V_BLANK);
|
||||||
|
(void)GX_VBlankIntr(TRUE);
|
||||||
|
(void)OS_EnableIrq();
|
||||||
|
(void)OS_EnableInterrupts();
|
||||||
|
|
||||||
|
// create idle thread to sleep in main thread
|
||||||
|
OS_CreateThread(&OSi_IdleThread,
|
||||||
|
OSi_IdleThreadProc,
|
||||||
|
(void *)NULL,
|
||||||
|
OSi_IdleThreadStack + OSi_IDLE_THREAD_STACK_SIZE / sizeof(u32),
|
||||||
|
OSi_IDLE_THREAD_STACK_SIZE,
|
||||||
|
OS_THREAD_PRIORITY_MAX /*pseudo. change at next line. */ );
|
||||||
|
OSi_IdleThread.priority = OS_THREAD_PRIORITY_MAX + 1; // lower priority than the lowest (=OS_THREAD_PRIORITY_MAX)
|
||||||
|
OSi_IdleThread.state = OS_THREAD_STATE_READY;
|
||||||
|
|
||||||
|
// サウンド初期化
|
||||||
|
SND_Init(THREAD_PRIO_SND);
|
||||||
|
|
||||||
|
|
||||||
|
// DS mode
|
||||||
|
SND_Disable();
|
||||||
|
// SND_I2SSetSamplingRatio(FALSE); // 32kHz
|
||||||
|
CDC_GoDsMode();
|
||||||
|
SND_Enable();
|
||||||
|
|
||||||
|
|
||||||
|
// reg_CFG_DS_MDFY |= REG_CFG_DS_MDFY_SND_MASK; // SOUND回路バグ修正 (default: off)
|
||||||
|
// reg_CFG_DS_MDFY |= REG_CFG_DS_MDFY_SDMA_MASK; // SOUND-DMAバグ修正 (default: off)
|
||||||
|
// reg_CFG_DS_EX &= ~REG_CFG_DS_EX_SDMA2_MASK; // SOUND-DMA新回路 (default: on)
|
||||||
|
|
||||||
|
// ボタン入力サーチ初期化
|
||||||
|
(void)PAD_InitXYButton();
|
||||||
|
|
||||||
|
// SPI初期化
|
||||||
|
SPI_Init(THREAD_PRIO_SPI);
|
||||||
|
|
||||||
|
while (TRUE)
|
||||||
|
{
|
||||||
|
OS_Halt();
|
||||||
|
|
||||||
|
//---- check reset
|
||||||
|
if (OS_IsResetOccurred())
|
||||||
|
{
|
||||||
|
OS_ResetSystem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: InitializeAllocateSystem
|
||||||
|
|
||||||
|
Description: メモリ割当てシステムを初期化する。
|
||||||
|
|
||||||
|
Arguments: None.
|
||||||
|
|
||||||
|
Returns: None.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
static OSHeapHandle InitializeAllocateSystem(void)
|
||||||
|
{
|
||||||
|
void *tempLo;
|
||||||
|
OSHeapHandle hh;
|
||||||
|
|
||||||
|
OS_TPrintf("OS_GetWramSubPrivArenaLo() = %p\n", OS_GetWramSubPrivArenaLo());
|
||||||
|
OS_TPrintf("OS_GetWramSubPrivArenaHi() = %p\n", OS_GetWramSubPrivArenaHi());
|
||||||
|
OS_TPrintf("OS_GetWramSubArenaLo() = %p\n", OS_GetWramSubArenaLo());
|
||||||
|
OS_TPrintf("OS_GetWramSubArenaHi() = %p\n", OS_GetWramSubArenaHi());
|
||||||
|
OS_TPrintf("OS_GetSubPrivArenaLo() = %p\n", OS_GetSubPrivArenaLo());
|
||||||
|
OS_TPrintf("OS_GetSubPrivArenaHi() = %p\n", OS_GetSubPrivArenaHi());
|
||||||
|
|
||||||
|
OS_TPrintf("call OS_SetWramSubPrivArenaHi(0x0380f980); to fix arena.\n");
|
||||||
|
OS_SetWramSubPrivArenaHi((void*)0x0380f980);
|
||||||
|
|
||||||
|
// メモリ割当て初期化
|
||||||
|
tempLo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV,
|
||||||
|
OS_GetWramSubPrivArenaLo(), OS_GetWramSubPrivArenaHi(), 1);
|
||||||
|
|
||||||
|
// アリーナを0クリア
|
||||||
|
MI_CpuClear8(tempLo, (u32)OS_GetWramSubPrivArenaHi() - (u32)tempLo);
|
||||||
|
|
||||||
|
// アリーナ下位アドレスを設定
|
||||||
|
OS_SetArenaLo(OS_ARENA_WRAM_SUBPRIV, tempLo);
|
||||||
|
|
||||||
|
// ヒープ作成
|
||||||
|
hh = OS_CreateHeap(OS_ARENA_WRAM_SUBPRIV,
|
||||||
|
OS_GetWramSubPrivArenaLo(), OS_GetWramSubPrivArenaHi());
|
||||||
|
|
||||||
|
if (hh < 0)
|
||||||
|
{
|
||||||
|
OS_Panic("ARM7: Fail to create heap.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// カレントヒープに設定
|
||||||
|
(void)OS_SetCurrentHeap(OS_ARENA_WRAM_SUBPRIV, hh);
|
||||||
|
|
||||||
|
return hh;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: VBlankIntr
|
||||||
|
|
||||||
|
Description: VBlank interrupt handler
|
||||||
|
|
||||||
|
Arguments: None
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
#ifndef SDK_TEG
|
||||||
|
|
||||||
|
extern BOOL PMi_Initialized;
|
||||||
|
void PM_SelfBlinkProc(void);
|
||||||
|
|
||||||
|
static void VBlankIntr(void)
|
||||||
|
{
|
||||||
|
//---- LED blink system
|
||||||
|
if (PMi_Initialized)
|
||||||
|
{
|
||||||
|
PM_SelfBlinkProc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static void VBlankIntr(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
End of file
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
43
build/tests/spi/tp-sampling/ARM9/Makefile
Normal file
43
build/tests/spi/tp-sampling/ARM9/Makefile
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#! make -f
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Project: TwlSDK - SND - demos - channel
|
||||||
|
# File: Makefile
|
||||||
|
#
|
||||||
|
# Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
#
|
||||||
|
# These coded instructions, statements, and computer programs contain
|
||||||
|
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
# Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
# not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
# in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
#
|
||||||
|
# $Log: $
|
||||||
|
# $NoKeywords: $
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SUBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#TWL_CODEGEN = THUMB
|
||||||
|
|
||||||
|
TARGET_BIN = main.axf
|
||||||
|
|
||||||
|
SRCS = main.c
|
||||||
|
|
||||||
|
#SRCDIR = # using default
|
||||||
|
#LCFILE = # using default
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
do-build: $(TARGETS)
|
||||||
|
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||||
|
|
||||||
|
|
||||||
|
#===== End of Makefile =====
|
||||||
108
build/tests/spi/tp-sampling/ARM9/src/main.c
Normal file
108
build/tests/spi/tp-sampling/ARM9/src/main.c
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Project: TwlSDK - SND - tests - channel
|
||||||
|
File: main.c
|
||||||
|
|
||||||
|
Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
|
||||||
|
These coded instructions, statements, and computer programs contain
|
||||||
|
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
|
||||||
|
$Log: main.c,v $
|
||||||
|
$NoKeywords: $
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include <twl.h>
|
||||||
|
#include <nitro/spi/ARM9/tp.h>
|
||||||
|
|
||||||
|
void VBlankIntr(void);
|
||||||
|
void DrawPos(int x, int y);
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TwlMain
|
||||||
|
|
||||||
|
Description: main
|
||||||
|
|
||||||
|
Arguments: None
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void TwlMain()
|
||||||
|
{
|
||||||
|
TPData raw_point;
|
||||||
|
|
||||||
|
// 初期化
|
||||||
|
OS_Init();
|
||||||
|
GX_Init();
|
||||||
|
TP_Init();
|
||||||
|
|
||||||
|
// Vブランク割り込み設定
|
||||||
|
OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr);
|
||||||
|
(void)OS_EnableIrqMask(OS_IE_V_BLANK);
|
||||||
|
(void)OS_EnableIrq();
|
||||||
|
(void)GX_VBlankIntr(TRUE);
|
||||||
|
|
||||||
|
// Send parameter of revision noise.
|
||||||
|
if (TP_RequestSetStability(3, 15) != 0)
|
||||||
|
{
|
||||||
|
OS_Panic("SetStability request err!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
GX_DispOff();
|
||||||
|
GXS_DispOff();
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// All VRAM banks to LCDC
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
GX_SetBankForLCDC(GX_VRAM_LCDC_ALL);
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// Clear all LCDC space
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
MI_CpuClearFast((void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE);
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// Set graphics mode VRAM display mode
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
GX_SetGraphicsMode(GX_DISPMODE_VRAM_A, // display VRAM-A
|
||||||
|
(GXBGMode)0, // dummy
|
||||||
|
(GXBG0As)0); // dummy
|
||||||
|
|
||||||
|
GX_DispOn();
|
||||||
|
GXS_DispOn();
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
OS_WaitVBlankIntr();
|
||||||
|
|
||||||
|
if (TP_RequestRawSampling(&raw_point) == 0)
|
||||||
|
{
|
||||||
|
DrawPos(raw_point.x, raw_point.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// Vブランク割り込み処理
|
||||||
|
//
|
||||||
|
void VBlankIntr(void)
|
||||||
|
{
|
||||||
|
OS_SetIrqCheckFlag(OS_IE_V_BLANK); // checking VBlank interrupt
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// 画面座標描画
|
||||||
|
//
|
||||||
|
void DrawPos(int x, int y)
|
||||||
|
{
|
||||||
|
const int screen_width = 256;
|
||||||
|
const int screen_height = 191;
|
||||||
|
const int axis_max = 4096;
|
||||||
|
int adjust_x = x * screen_width / axis_max;
|
||||||
|
int adjust_y = y * screen_height / axis_max;
|
||||||
|
int address = HW_LCDC_VRAM + screen_width*2*adjust_y + 2*adjust_x;
|
||||||
|
|
||||||
|
*(u16 *)(address) = 0x7fff;
|
||||||
|
}
|
||||||
32
build/tests/spi/tp-sampling/Makefile
Normal file
32
build/tests/spi/tp-sampling/Makefile
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#! make -f
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Project: TwlSDK - build
|
||||||
|
# File: Makefile
|
||||||
|
#
|
||||||
|
# Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
#
|
||||||
|
# These coded instructions, statements, and computer programs contain
|
||||||
|
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
# Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
# not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
# in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
#
|
||||||
|
# $Log: $
|
||||||
|
# $NoKeywords: $
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SUBDIRS = \
|
||||||
|
ARM7 \
|
||||||
|
ARM9 \
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||||
|
|
||||||
|
|
||||||
|
#===== End of Makefile =====
|
||||||
@ -47,7 +47,8 @@ extern u16 cdcSpiMode;
|
|||||||
// BAUDRATE parameter
|
// BAUDRATE parameter
|
||||||
//================================================================
|
//================================================================
|
||||||
|
|
||||||
#define CDC_SPI_BAUDRATE_DEFAULT SPI_BAUDRATE_1MHZ // SPI_BAUDRATE_4MHZ
|
// CODECの制限により4MHZを最大とする
|
||||||
|
#define CDC_SPI_BAUDRATE_DEFAULT SPI_BAUDRATE_4MHZ
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*
|
/*---------------------------------------------------------------------------*
|
||||||
Name: CDCi_SetSPIBaudRate
|
Name: CDCi_SetSPIBaudRate
|
||||||
@ -289,11 +290,13 @@ static inline void CDC_WriteSpiRegister( u8 reg, u8 data )
|
|||||||
Returns: value which is read from specified decive register
|
Returns: value which is read from specified decive register
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
u8 CDCi_ReadSpiRegister( u8 reg );
|
u8 CDCi_ReadSpiRegister( u8 reg );
|
||||||
static inline void CDC_ReadSpiRegister( u8 reg )
|
static inline u8 CDC_ReadSpiRegister( u8 reg )
|
||||||
{
|
{
|
||||||
|
u8 value;
|
||||||
(void)SPI_Lock(123);
|
(void)SPI_Lock(123);
|
||||||
CDCi_ReadSpiRegister( reg );
|
value = CDCi_ReadSpiRegister( reg );
|
||||||
(void)SPI_Unlock(123);
|
(void)SPI_Unlock(123);
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*
|
/*---------------------------------------------------------------------------*
|
||||||
|
|||||||
@ -23,7 +23,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
// INIT APIs
|
// INIT APIs
|
||||||
//================================================================================
|
//================================================================================
|
||||||
@ -84,7 +83,7 @@ void CDC_InitMic( void );
|
|||||||
|
|
||||||
Returns: TRUE : TWL-mode, FALSE : DS-mode
|
Returns: TRUE : TWL-mode, FALSE : DS-mode
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
inline BOOL CDC_IsTwlMode( void );
|
BOOL CDC_IsTwlMode( void );
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*
|
/*---------------------------------------------------------------------------*
|
||||||
Name: CDC_GetVendorId
|
Name: CDC_GetVendorId
|
||||||
@ -341,6 +340,32 @@ void CDC_DisableAGC( void );
|
|||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
void CDC_Init1stOrderFilter( u8 *coef, int filter_target );
|
void CDC_Init1stOrderFilter( u8 *coef, int filter_target );
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: CDC_SetScanModeTimerClockDivider
|
||||||
|
|
||||||
|
Description: スキャンモードのクロックディバイダーを設定します。
|
||||||
|
ARM7から供給されるMCLK(12.19MHz)はディバイダーの値に
|
||||||
|
よって分周されます。
|
||||||
|
|
||||||
|
結果として、ディバイダーの値に比例して
|
||||||
|
・インターバルタイマー
|
||||||
|
・デバウンスタイマー
|
||||||
|
の時間がスケールされます。
|
||||||
|
|
||||||
|
基本的には 24 固定とします。
|
||||||
|
|
||||||
|
MCLK = 12.19MHz
|
||||||
|
divider = 24
|
||||||
|
interval time = 16ms 2ms 4ms 6ms 8ms 10ms 12ms 14ms
|
||||||
|
de-bounce time = 0us 16us 32us 64us 128us 256us 512us 1024us
|
||||||
|
|
||||||
|
Arguments: value :
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void CDC_SetScanModeTimerClockDivider( u8 value );
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user